diff --git a/src/App.vue b/src/App.vue
index 39a9f809..6c54579d 100644
--- a/src/App.vue
+++ b/src/App.vue
@@ -7,6 +7,7 @@ export default {
animationType: 'slide-in-bottom'
});
})
+ // console.log('预加载');
},
onShow: function () {
// console.log('App Show')
diff --git a/src/api/request.js b/src/api/request.js
index 201569e6..d78bf0f1 100644
--- a/src/api/request.js
+++ b/src/api/request.js
@@ -17,7 +17,7 @@ export const get_base_url = url => {
return baseUrl
// #endif
// #ifdef APP-PLUS
- return ENV.VITE_APP_BASE_API_Url
+ return ENV.VITE_APP_BASE_API_Url
// #endif
} else { // 其他环境,包括生产环境,sit环境,uat环境
return ENV.VITE_APP_BASE_API_Url
@@ -32,15 +32,28 @@ export const REQUES_ERROR_CODES = {
// 去登录弹窗状态
let no_login_show_modal_state = false
// 去登录方法
-export const goto_login_fun = () => {
+export const goto_login_fun = (from = 'http') => {
if (no_login_show_modal_state) return;
no_login_show_modal_state = true
+ let page_route = ''
+ const pages = getCurrentPages();
+ if (pages.length >= 1) {
+ const page = pages[pages.length - 1];
+ page_route = page.route
+ }
+ if (page_route === 'pages/login/login') return;
common.hideLoading()
- common.show('未登录', '现在去登录').then(() => {
+ common.show('未登录', '现在去登录', false).then(() => {
common.navigateTo('/pages/login/login')
+ if (from === 'socket' && page_route !== '') {
+ common.redirectTo('/pages/login/login?path=' + page_route)
+ } else {
+ common.navigateTo('/pages/login/login')
+ }
+
}).finally(() => {
no_login_show_modal_state = false
- })
+ })
}
export default function request({
@@ -73,7 +86,7 @@ export default function request({
data: data,
method: method,
header: headers_base,
- timeout:timeout,
+ timeout: timeout,
success: (response) => {
if (isStream) { // 流式传输,直接返回
return resolve(response);
@@ -83,8 +96,8 @@ export default function request({
const res = response.data
if (res?.rtnCode === '0000') {
return resolve(res)
- }else{
- if(toastErrors){
+ } else {
+ if (toastErrors) {
common.msg(res?.message)
}
}
diff --git a/src/api/socket.js b/src/api/socket.js
index 9d7427f5..03bb31f0 100644
--- a/src/api/socket.js
+++ b/src/api/socket.js
@@ -69,13 +69,13 @@ export default class WebSocketUtil {
clearInterval(this.reconnectTimer);
this.reconnectTimer = null
this.close()
- goto_login_fun();
+ goto_login_fun('socket');
return
}
}else{
clearInterval(this.reconnectTimer); // 清除重连计时器
this.reconnectTimer = null
- goto_login_fun();
+ goto_login_fun('socket');
return
}
this.triggerEvent('message', res); // 触发消息接收事件
@@ -224,7 +224,7 @@ export default class WebSocketUtil {
this.triggerEvent('error', new Error('达到最大重连次数'));
this.reconnectTimer = null
this.close()
- goto_login_fun()
+ goto_login_fun('socket')
}
}
diff --git a/src/common/common.js b/src/common/common.js
index 665d1ade..9628f88f 100644
--- a/src/common/common.js
+++ b/src/common/common.js
@@ -62,11 +62,36 @@ const loading = (title = '加载中', mask = true) => uni.showLoading({
})
const hideLoading = () => uni.hideLoading()
+
+// 防抖工具函数
+function debounce(fn, wait = 300) {
+ let isLocked = false; // 锁定状态标记
+ return function(...args) {
+ // 如果处于锁定状态,直接返回不执行
+ if (isLocked) {
+ return;
+ }
+ // 执行函数
+ fn.apply(this, args);
+
+ // 锁定,防止再次执行
+ isLocked = true;
+
+ // 等待指定时间后解锁
+ setTimeout(() => {
+ isLocked = false;
+ }, wait);
+ };
+}
+
// 保留当前页面,跳转到应用内的某个页面,使用uni.navigateBack可以返回到原页面。
-const navigateTo = (url, data = {}) => uni.navigateTo({
- url: url,
- ...data
-});
+const navigateTo = debounce(function(url, data = {}) {
+ uni.navigateTo({
+ url: url,
+ ...data
+ });
+})
+
// 关闭所有页面,打开到应用内的某个页面。
const reLaunch = url => {
uni.reLaunch({
@@ -80,9 +105,10 @@ const switchTab = url => {
});
}
// 关闭当前页面,返回上一页面或多级页面。可通过 getCurrentPages() 获取当前的页面栈,决定需要返回几层。
-const navigateBack = (delta = 1, fun = () => {}) => {
+const navigateBack = (delta = 1, fun = () => {}, data = {}) => {
uni.navigateBack({
delta: delta,
+ ...data,
success() {
fun()
}
diff --git a/src/common/mascot.js b/src/common/mascot.js
index ac78daa5..1adf0390 100644
--- a/src/common/mascot.js
+++ b/src/common/mascot.js
@@ -1,30 +1,28 @@
// 设置科技鹿
-import {getUserInfo} from "@/common/common.js"
+import {
+ getUserInfo
+} from "@/common/common.js"
import common from "@/common/common.js"
export const setMascot = () => {
- // const mascotState = common.getValue('mascotState') || false
const mascotState = false
- // console.log('设置科技鹿', mascotState);
if (!mascotState) {
-
- try{
+ try {
const userInfo = getUserInfo()
const mascotInfo = userInfo?.mascotInfo
- console.log('设置科技鹿', mascotInfo);
- uni.setTabBarStyle({
- midButton: {
- iconPath: "/static/images/icon/fawn-" + (mascotInfo?.mascotNo || '1') + ".png",
- width: "86px",
- height: "86px",
- iconWidth: "90px"
- },
- success: () => {
- common.setValue('mascotState', true)
- }
- })
- } catch(e){
-
- }
+ if (mascotInfo) {
+ uni.setTabBarStyle({
+ midButton: {
+ iconPath: "/static/images/icon/fawn-" + (mascotInfo?.mascotNo || '1') + ".png",
+ width: "86px",
+ height: "86px",
+ iconWidth: "90px"
+ },
+ success: () => {
+ common.setValue('mascotState', true)
+ }
+ })
+ }
+ } catch (e) {}
}
return mascotState
}
\ No newline at end of file
diff --git a/src/pages.json b/src/pages.json
index eec33217..9069a2c4 100644
--- a/src/pages.json
+++ b/src/pages.json
@@ -5,7 +5,8 @@
"style": {
"navigationBarTitleText": "AI问答",
"app-plus": {
- "titleNView": false
+ "titleNView": false,
+ "animationType": "fade-in"
}
}
},
diff --git a/src/pages/courseDetail/components/comment.vue b/src/pages/courseDetail/components/comment.vue
index a2ddf35e..8493088d 100644
--- a/src/pages/courseDetail/components/comment.vue
+++ b/src/pages/courseDetail/components/comment.vue
@@ -70,7 +70,7 @@
这里什么都没有
-
+