mirror of
https://github.com/kuaifan/dootask.git
synced 2025-12-12 11:19:56 +00:00
perf: 优化消息窗口
This commit is contained in:
parent
15f3f9c0e5
commit
82230d70a5
20
resources/assets/js/app.js
vendored
20
resources/assets/js/app.js
vendored
@ -86,27 +86,31 @@ const routeMode = isSoftware && !/https?:/i.test(window.location.protocol) ? 'ha
|
|||||||
const router = new VueRouter({mode: routeMode, routes});
|
const router = new VueRouter({mode: routeMode, routes});
|
||||||
|
|
||||||
// 进度条配置
|
// 进度条配置
|
||||||
if (!isSoftware) {
|
ViewUI.LoadingBar.config({
|
||||||
ViewUI.LoadingBar.config({
|
|
||||||
color: '#3fcc25',
|
color: '#3fcc25',
|
||||||
failedColor: '#ff0000'
|
failedColor: '#ff0000'
|
||||||
});
|
});
|
||||||
router.beforeEach((to, from, next) => {
|
router.beforeEach((to, from, next) => {
|
||||||
|
if (!isSoftware) {
|
||||||
ViewUI.LoadingBar._timer && clearTimeout(ViewUI.LoadingBar._timer)
|
ViewUI.LoadingBar._timer && clearTimeout(ViewUI.LoadingBar._timer)
|
||||||
ViewUI.LoadingBar._timer = setTimeout(_ => {
|
ViewUI.LoadingBar._timer = setTimeout(_ => {
|
||||||
ViewUI.LoadingBar._load = true;
|
ViewUI.LoadingBar._load = true;
|
||||||
ViewUI.LoadingBar.start();
|
ViewUI.LoadingBar.start();
|
||||||
}, 300)
|
}, 300)
|
||||||
|
}
|
||||||
|
store.commit('route/loading', true);
|
||||||
next();
|
next();
|
||||||
});
|
});
|
||||||
router.afterEach(() => {
|
router.afterEach(() => {
|
||||||
|
if (!isSoftware) {
|
||||||
ViewUI.LoadingBar._timer && clearTimeout(ViewUI.LoadingBar._timer)
|
ViewUI.LoadingBar._timer && clearTimeout(ViewUI.LoadingBar._timer)
|
||||||
if (ViewUI.LoadingBar._load === true) {
|
if (ViewUI.LoadingBar._load === true) {
|
||||||
ViewUI.LoadingBar._load = false;
|
ViewUI.LoadingBar._load = false;
|
||||||
ViewUI.LoadingBar.finish();
|
ViewUI.LoadingBar.finish();
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
}
|
store.commit('route/loading', false);
|
||||||
|
});
|
||||||
|
|
||||||
// 加载路由
|
// 加载路由
|
||||||
Vue.prototype.goForward = function(route, isReplace, autoBroadcast = true) {
|
Vue.prototype.goForward = function(route, isReplace, autoBroadcast = true) {
|
||||||
|
|||||||
@ -218,7 +218,6 @@ export default {
|
|||||||
case 'message':
|
case 'message':
|
||||||
this.$store.dispatch("openDialog", item.id).then(() => {
|
this.$store.dispatch("openDialog", item.id).then(() => {
|
||||||
this.onHide()
|
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
|
this.$store.state.dialogSearchMsgId = /^\d+$/.test(item.rawData.search_msg_id) ? item.rawData.search_msg_id : 0
|
||||||
}).catch(({msg}) => {
|
}).catch(({msg}) => {
|
||||||
$A.modalError(msg || this.$L('打开会话失败'))
|
$A.modalError(msg || this.$L('打开会话失败'))
|
||||||
|
|||||||
23
resources/assets/js/functions/common.js
vendored
23
resources/assets/js/functions/common.js
vendored
@ -1322,6 +1322,27 @@ const timezone = require("dayjs/plugin/timezone");
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
throw new Error(`Element not found after ${maxAttempts} attempts`);
|
throw new Error(`Element not found after ${maxAttempts} attempts`);
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 轮询等待条件满足
|
||||||
|
* @param {Function} conditionFn - 返回布尔值的条件函数
|
||||||
|
* @param {number} intervalMs - 轮询间隔(毫秒,默认300ms)
|
||||||
|
* @param {number} timeoutMs - 超时时间(毫秒,默认3000ms)
|
||||||
|
* @returns {Promise<boolean>}
|
||||||
|
*/
|
||||||
|
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({
|
$.extend({
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="page-manage" :class="{'show-tabbar': showMobileTabbar, 'not-logged': userId <= 0}">
|
<div class="page-manage" :class="{'show-tabbar': showMobileTabbar, 'not-logged': userId <= 0}">
|
||||||
<div class="manage-box-menu" :class="{'show-mobile-menu': showMobileMenu}">
|
<div class="manage-box-menu">
|
||||||
<Dropdown
|
<Dropdown
|
||||||
class="page-manage-menu-dropdown main-menu"
|
class="page-manage-menu-dropdown main-menu"
|
||||||
trigger="click"
|
trigger="click"
|
||||||
@ -433,7 +433,6 @@ export default {
|
|||||||
|
|
||||||
openMenu: {},
|
openMenu: {},
|
||||||
visibleMenu: false,
|
visibleMenu: false,
|
||||||
showMobileMenu: false,
|
|
||||||
|
|
||||||
allUserShow: false,
|
allUserShow: false,
|
||||||
allProjectShow: false,
|
allProjectShow: false,
|
||||||
@ -766,9 +765,8 @@ export default {
|
|||||||
},
|
},
|
||||||
|
|
||||||
async toggleRoute(path, params) {
|
async toggleRoute(path, params) {
|
||||||
this.showMobileMenu = false;
|
const location = {name: 'manage-' + path, params: params || {}};
|
||||||
let location = {name: 'manage-' + path, params: params || {}};
|
const fileFolderId = await $A.IDBInt("fileFolderId");
|
||||||
let fileFolderId = await $A.IDBInt("fileFolderId");
|
|
||||||
if (path === 'file' && fileFolderId > 0) {
|
if (path === 'file' && fileFolderId > 0) {
|
||||||
location.params.folderId = fileFolderId
|
location.params.folderId = fileFolderId
|
||||||
}
|
}
|
||||||
@ -1050,7 +1048,6 @@ export default {
|
|||||||
this.createGroupData = {};
|
this.createGroupData = {};
|
||||||
this.$store.dispatch("saveDialog", data);
|
this.$store.dispatch("saveDialog", data);
|
||||||
this.$store.dispatch('openDialog', data.id)
|
this.$store.dispatch('openDialog', data.id)
|
||||||
this.toggleRoute('messenger', {dialogAction: 'dialog'})
|
|
||||||
}).catch(({msg}) => {
|
}).catch(({msg}) => {
|
||||||
$A.modalError(msg);
|
$A.modalError(msg);
|
||||||
}).finally(_ => {
|
}).finally(_ => {
|
||||||
@ -1089,7 +1086,6 @@ export default {
|
|||||||
title,
|
title,
|
||||||
desc: body,
|
desc: body,
|
||||||
callback: () => {
|
callback: () => {
|
||||||
this.goForward({name: 'manage-messenger'});
|
|
||||||
this.$store.dispatch('openDialog', dialog_id)
|
this.$store.dispatch('openDialog', dialog_id)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@ -1259,7 +1255,6 @@ export default {
|
|||||||
if (!$A.isJson(data)) {
|
if (!$A.isJson(data)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.goForward({name: 'manage-messenger'});
|
|
||||||
this.$nextTick(_ => {
|
this.$nextTick(_ => {
|
||||||
this.$store.dispatch('openDialog', data.dialog_id)
|
this.$store.dispatch('openDialog', data.dialog_id)
|
||||||
})
|
})
|
||||||
|
|||||||
@ -382,6 +382,7 @@ export default {
|
|||||||
'cacheDialogs',
|
'cacheDialogs',
|
||||||
'windowOrientation',
|
'windowOrientation',
|
||||||
'formOptions',
|
'formOptions',
|
||||||
|
'routeLoading',
|
||||||
]),
|
]),
|
||||||
isExistAdminList() {
|
isExistAdminList() {
|
||||||
return this.applyList.map(h => h.type).indexOf('admin') !== -1;
|
return this.applyList.map(h => h.type).indexOf('admin') !== -1;
|
||||||
@ -543,7 +544,6 @@ export default {
|
|||||||
chatMybot(userid) {
|
chatMybot(userid) {
|
||||||
this.$store.dispatch("openDialogUserid", userid).then(_ => {
|
this.$store.dispatch("openDialogUserid", userid).then(_ => {
|
||||||
this.mybotShow = false;
|
this.mybotShow = false;
|
||||||
this.goForward({name: 'manage-messenger', params: {dialogAction: 'dialog'}})
|
|
||||||
}).catch(({msg}) => {
|
}).catch(({msg}) => {
|
||||||
$A.modalError(msg || this.$L('打开会话失败'))
|
$A.modalError(msg || this.$L('打开会话失败'))
|
||||||
});
|
});
|
||||||
@ -635,11 +635,7 @@ export default {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
if (dialogId) {
|
if (dialogId) {
|
||||||
if (this.windowOrientation == 'landscape') {
|
|
||||||
this.goForward({ name: 'manage-messenger', params: { dialog_id: dialogId } });
|
|
||||||
} else {
|
|
||||||
this.$store.dispatch("openDialog", dialogId)
|
this.$store.dispatch("openDialog", dialogId)
|
||||||
}
|
|
||||||
this.aibotShow = false;
|
this.aibotShow = false;
|
||||||
} else {
|
} else {
|
||||||
this.aibotDialogSearchLoad = type;
|
this.aibotDialogSearchLoad = type;
|
||||||
@ -745,23 +741,15 @@ export default {
|
|||||||
// 前往接龙与投票
|
// 前往接龙与投票
|
||||||
goWordChainAndVote() {
|
goWordChainAndVote() {
|
||||||
const dialog_id = Number(this.sendData[0].replace('d:', ''))
|
const dialog_id = Number(this.sendData[0].replace('d:', ''))
|
||||||
|
this.$store.dispatch("openDialog", dialog_id).then(async () => {
|
||||||
|
try {
|
||||||
|
await $A.waitForCondition(() => this.routeLoading === 0);
|
||||||
const type = this.sendType == 'word-chain' ? 'dialogDroupWordChain' : 'dialogGroupVote'
|
const type = this.sendType == 'word-chain' ? 'dialogDroupWordChain' : 'dialogGroupVote'
|
||||||
if (this.windowPortrait) {
|
this.$store.state[type] = {type: 'create', dialog_id: dialog_id}
|
||||||
this.$store.dispatch("openDialog", dialog_id).then(() => {
|
} catch (error) {
|
||||||
this.$store.state[type] = {
|
// Handle the error
|
||||||
type: 'create',
|
|
||||||
dialog_id: dialog_id
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
} else {
|
|
||||||
this.goForward({
|
|
||||||
name: 'manage-messenger',
|
|
||||||
params: {
|
|
||||||
open: this.sendType,
|
|
||||||
dialog_id: dialog_id
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1205,25 +1205,6 @@ export default {
|
|||||||
},
|
},
|
||||||
|
|
||||||
watch: {
|
watch: {
|
||||||
'$route': {
|
|
||||||
handler(data) {
|
|
||||||
const { name, params } = data || {}
|
|
||||||
if (name != 'manage-messenger') {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if (params.dialog_id && params.open && ['word-chain', 'vote'].includes(params.open)) {
|
|
||||||
this.$nextTick(_ => {
|
|
||||||
this.$store.state[params.open == 'word-chain' ? 'dialogDroupWordChain' : 'dialogGroupVote'] = {
|
|
||||||
type: 'create',
|
|
||||||
dialog_id: params.dialog_id
|
|
||||||
}
|
|
||||||
params.open = "";
|
|
||||||
})
|
|
||||||
}
|
|
||||||
},
|
|
||||||
immediate: true
|
|
||||||
},
|
|
||||||
|
|
||||||
dialogId: {
|
dialogId: {
|
||||||
handler(dialog_id, old_id) {
|
handler(dialog_id, old_id) {
|
||||||
this.getDialogBase(dialog_id)
|
this.getDialogBase(dialog_id)
|
||||||
|
|||||||
@ -65,7 +65,6 @@ export default {
|
|||||||
methods: {
|
methods: {
|
||||||
onMsgOpen() {
|
onMsgOpen() {
|
||||||
this.$store.dispatch("openDialog", this.projectData.dialog_id);
|
this.$store.dispatch("openDialog", this.projectData.dialog_id);
|
||||||
this.goForward({name: 'manage-messenger', params: {dialogAction: 'dialog'}});
|
|
||||||
this.beforeDestroyClose = true;
|
this.beforeDestroyClose = true;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
@ -1617,18 +1617,15 @@ export default {
|
|||||||
data: {
|
data: {
|
||||||
task_id: this.taskDetail.id,
|
task_id: this.taskDetail.id,
|
||||||
},
|
},
|
||||||
}).then(({data}) => {
|
}).then(async ({data}) => {
|
||||||
this.$store.dispatch("saveTask", {
|
await this.$store.dispatch("saveTask", {id: data.id, dialog_id: data.dialog_id});
|
||||||
id: data.id,
|
await this.$store.dispatch("saveDialog", data.dialog_data);
|
||||||
dialog_id: data.dialog_id,
|
|
||||||
});
|
|
||||||
this.$store.dispatch("saveDialog", data.dialog_data);
|
|
||||||
//
|
//
|
||||||
if ($A.isSubElectron) {
|
if ($A.isSubElectron) {
|
||||||
this.resizeDialog().then(() => {
|
await this.resizeDialog()
|
||||||
this.sendDialogMsg(msgText);
|
this.sendDialogMsg(msgText);
|
||||||
});
|
return
|
||||||
} else {
|
}
|
||||||
this.$nextTick(() => {
|
this.$nextTick(() => {
|
||||||
if (this.windowPortrait) {
|
if (this.windowPortrait) {
|
||||||
$A.onBlur();
|
$A.onBlur();
|
||||||
@ -1654,7 +1651,6 @@ export default {
|
|||||||
this.sendDialogMsg(msgText);
|
this.sendDialogMsg(msgText);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
|
||||||
}).catch(({msg}) => {
|
}).catch(({msg}) => {
|
||||||
$A.modalError(msg);
|
$A.modalError(msg);
|
||||||
}).finally(_ => {
|
}).finally(_ => {
|
||||||
|
|||||||
@ -1312,7 +1312,6 @@ export default {
|
|||||||
if ($A.leftExists(val, 'dialog_')) {
|
if ($A.leftExists(val, 'dialog_')) {
|
||||||
const dialogId = parseInt(val.substr(7))
|
const dialogId = parseInt(val.substr(7))
|
||||||
this.$store.dispatch("openDialog", dialogId).then(() => {
|
this.$store.dispatch("openDialog", dialogId).then(() => {
|
||||||
this.goForward({name: 'manage-messenger'})
|
|
||||||
this.$emit('on-close')
|
this.$emit('on-close')
|
||||||
}).catch(({msg}) => {
|
}).catch(({msg}) => {
|
||||||
$A.modalError(msg || this.$L('打开会话失败'))
|
$A.modalError(msg || this.$L('打开会话失败'))
|
||||||
|
|||||||
3
resources/assets/js/store/actions.js
vendored
3
resources/assets/js/store/actions.js
vendored
@ -3061,6 +3061,9 @@ export default {
|
|||||||
state.dialogSearchMsgId = search_msg_id;
|
state.dialogSearchMsgId = search_msg_id;
|
||||||
state.dialogMsgId = dialog_msg_id;
|
state.dialogMsgId = dialog_msg_id;
|
||||||
state.dialogId = dialog_id;
|
state.dialogId = dialog_id;
|
||||||
|
if (dialog_id > 0 && state.windowLandscape) {
|
||||||
|
$A.goForward({name: 'manage-messenger', params: {dialogAction: 'dialog'}});
|
||||||
|
}
|
||||||
resolve()
|
resolve()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
9
resources/assets/js/store/mutations.js
vendored
9
resources/assets/js/store/mutations.js
vendored
@ -1,4 +1,13 @@
|
|||||||
export default {
|
export default {
|
||||||
|
// 路由加载
|
||||||
|
'route/loading': function(state, load) {
|
||||||
|
if (load) {
|
||||||
|
state.routeLoading++
|
||||||
|
} else {
|
||||||
|
state.routeLoading--
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
// 会员管理
|
// 会员管理
|
||||||
'user/push': function(state, data) {
|
'user/push': function(state, data) {
|
||||||
state.cacheUserBasic.push(data)
|
state.cacheUserBasic.push(data)
|
||||||
|
|||||||
1
resources/assets/js/store/state.js
vendored
1
resources/assets/js/store/state.js
vendored
@ -52,6 +52,7 @@ export default {
|
|||||||
routeName: null,
|
routeName: null,
|
||||||
routeHistorys: [],
|
routeHistorys: [],
|
||||||
routeHistoryLast: {},
|
routeHistoryLast: {},
|
||||||
|
routeLoading: 0,
|
||||||
|
|
||||||
// 请求时间
|
// 请求时间
|
||||||
callAt: [],
|
callAt: [],
|
||||||
|
|||||||
11
resources/assets/sass/pages/page-manage.scss
vendored
11
resources/assets/sass/pages/page-manage.scss
vendored
@ -446,16 +446,7 @@ body.window-portrait {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
.manage-box-menu {
|
.manage-box-menu {
|
||||||
position: fixed;
|
display: none;
|
||||||
z-index: 49;
|
|
||||||
left: 0;
|
|
||||||
top: 0;
|
|
||||||
bottom: 0;
|
|
||||||
width: 100%;
|
|
||||||
transform: translateX(-120%);
|
|
||||||
&.show-mobile-menu {
|
|
||||||
transform: translateX(0);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user