diff --git a/resources/assets/js/app.js b/resources/assets/js/app.js index 59ba22659..7dc500de5 100644 --- a/resources/assets/js/app.js +++ b/resources/assets/js/app.js @@ -86,27 +86,31 @@ const routeMode = isSoftware && !/https?:/i.test(window.location.protocol) ? 'ha const router = new VueRouter({mode: routeMode, routes}); // 进度条配置 -if (!isSoftware) { - ViewUI.LoadingBar.config({ - color: '#3fcc25', - failedColor: '#ff0000' - }); - router.beforeEach((to, from, next) => { +ViewUI.LoadingBar.config({ + color: '#3fcc25', + failedColor: '#ff0000' +}); +router.beforeEach((to, from, next) => { + if (!isSoftware) { ViewUI.LoadingBar._timer && clearTimeout(ViewUI.LoadingBar._timer) ViewUI.LoadingBar._timer = setTimeout(_ => { ViewUI.LoadingBar._load = true; ViewUI.LoadingBar.start(); }, 300) - next(); - }); - router.afterEach(() => { + } + store.commit('route/loading', true); + next(); +}); +router.afterEach(() => { + if (!isSoftware) { ViewUI.LoadingBar._timer && clearTimeout(ViewUI.LoadingBar._timer) if (ViewUI.LoadingBar._load === true) { ViewUI.LoadingBar._load = false; ViewUI.LoadingBar.finish(); } - }); -} + } + store.commit('route/loading', false); +}); // 加载路由 Vue.prototype.goForward = function(route, isReplace, autoBroadcast = true) { diff --git a/resources/assets/js/components/SearchBox.vue b/resources/assets/js/components/SearchBox.vue index d60d104eb..ee45df3d1 100755 --- a/resources/assets/js/components/SearchBox.vue +++ b/resources/assets/js/components/SearchBox.vue @@ -218,7 +218,6 @@ export default { case 'message': this.$store.dispatch("openDialog", item.id).then(() => { this.onHide() - this.goForward({name: 'manage-messenger', params: {dialogAction: 'dialog'}}) this.$store.state.dialogSearchMsgId = /^\d+$/.test(item.rawData.search_msg_id) ? item.rawData.search_msg_id : 0 }).catch(({msg}) => { $A.modalError(msg || this.$L('打开会话失败')) diff --git a/resources/assets/js/functions/common.js b/resources/assets/js/functions/common.js index 91b07aebd..2ad97a315 100755 --- a/resources/assets/js/functions/common.js +++ b/resources/assets/js/functions/common.js @@ -1322,6 +1322,27 @@ const timezone = require("dayjs/plugin/timezone"); } } throw new Error(`Element not found after ${maxAttempts} attempts`); + }, + + /** + * 轮询等待条件满足 + * @param {Function} conditionFn - 返回布尔值的条件函数 + * @param {number} intervalMs - 轮询间隔(毫秒,默认300ms) + * @param {number} timeoutMs - 超时时间(毫秒,默认3000ms) + * @returns {Promise} + */ + async waitForCondition(conditionFn, intervalMs = 300, timeoutMs = 3000) { + const startTime = Date.now(); + + while (Date.now() - startTime < timeoutMs) { + if (conditionFn()) { + return true; // 条件满足 + } + // 等待指定时间 + await new Promise(resolve => setTimeout(resolve, intervalMs)); + } + + throw new Error('等待条件超时'); } }); @@ -2204,7 +2225,7 @@ const timezone = require("dayjs/plugin/timezone"); /** * ============================================================================= - * *********************************** time ******************************** + * *********************************** sort ******************************** * ============================================================================= */ $.extend({ diff --git a/resources/assets/js/pages/manage.vue b/resources/assets/js/pages/manage.vue index 59585106b..9501a2674 100644 --- a/resources/assets/js/pages/manage.vue +++ b/resources/assets/js/pages/manage.vue @@ -1,6 +1,6 @@