mirror of
https://github.com/kuaifan/dootask.git
synced 2025-12-12 19:35:50 +00:00
perf: 优化消息窗口
This commit is contained in:
parent
15f3f9c0e5
commit
82230d70a5
26
resources/assets/js/app.js
vendored
26
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});
|
||||
|
||||
// 进度条配置
|
||||
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) {
|
||||
|
||||
@ -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('打开会话失败'))
|
||||
|
||||
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`);
|
||||
},
|
||||
|
||||
/**
|
||||
* 轮询等待条件满足
|
||||
* @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({
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
<template>
|
||||
<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
|
||||
class="page-manage-menu-dropdown main-menu"
|
||||
trigger="click"
|
||||
@ -433,7 +433,6 @@ export default {
|
||||
|
||||
openMenu: {},
|
||||
visibleMenu: false,
|
||||
showMobileMenu: false,
|
||||
|
||||
allUserShow: false,
|
||||
allProjectShow: false,
|
||||
@ -766,9 +765,8 @@ export default {
|
||||
},
|
||||
|
||||
async toggleRoute(path, params) {
|
||||
this.showMobileMenu = false;
|
||||
let location = {name: 'manage-' + path, params: params || {}};
|
||||
let fileFolderId = await $A.IDBInt("fileFolderId");
|
||||
const location = {name: 'manage-' + path, params: params || {}};
|
||||
const fileFolderId = await $A.IDBInt("fileFolderId");
|
||||
if (path === 'file' && fileFolderId > 0) {
|
||||
location.params.folderId = fileFolderId
|
||||
}
|
||||
@ -1050,7 +1048,6 @@ export default {
|
||||
this.createGroupData = {};
|
||||
this.$store.dispatch("saveDialog", data);
|
||||
this.$store.dispatch('openDialog', data.id)
|
||||
this.toggleRoute('messenger', {dialogAction: 'dialog'})
|
||||
}).catch(({msg}) => {
|
||||
$A.modalError(msg);
|
||||
}).finally(_ => {
|
||||
@ -1089,7 +1086,6 @@ export default {
|
||||
title,
|
||||
desc: body,
|
||||
callback: () => {
|
||||
this.goForward({name: 'manage-messenger'});
|
||||
this.$store.dispatch('openDialog', dialog_id)
|
||||
}
|
||||
})
|
||||
@ -1259,7 +1255,6 @@ export default {
|
||||
if (!$A.isJson(data)) {
|
||||
return;
|
||||
}
|
||||
this.goForward({name: 'manage-messenger'});
|
||||
this.$nextTick(_ => {
|
||||
this.$store.dispatch('openDialog', data.dialog_id)
|
||||
})
|
||||
|
||||
@ -382,6 +382,7 @@ export default {
|
||||
'cacheDialogs',
|
||||
'windowOrientation',
|
||||
'formOptions',
|
||||
'routeLoading',
|
||||
]),
|
||||
isExistAdminList() {
|
||||
return this.applyList.map(h => h.type).indexOf('admin') !== -1;
|
||||
@ -543,7 +544,6 @@ export default {
|
||||
chatMybot(userid) {
|
||||
this.$store.dispatch("openDialogUserid", userid).then(_ => {
|
||||
this.mybotShow = false;
|
||||
this.goForward({name: 'manage-messenger', params: {dialogAction: 'dialog'}})
|
||||
}).catch(({msg}) => {
|
||||
$A.modalError(msg || this.$L('打开会话失败'))
|
||||
});
|
||||
@ -635,11 +635,7 @@ export default {
|
||||
}
|
||||
})
|
||||
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;
|
||||
} else {
|
||||
this.aibotDialogSearchLoad = type;
|
||||
@ -745,23 +741,15 @@ export default {
|
||||
// 前往接龙与投票
|
||||
goWordChainAndVote() {
|
||||
const dialog_id = Number(this.sendData[0].replace('d:', ''))
|
||||
const type = this.sendType == 'word-chain' ? 'dialogDroupWordChain' : 'dialogGroupVote'
|
||||
if (this.windowPortrait) {
|
||||
this.$store.dispatch("openDialog", dialog_id).then(() => {
|
||||
this.$store.state[type] = {
|
||||
type: 'create',
|
||||
dialog_id: dialog_id
|
||||
}
|
||||
})
|
||||
} else {
|
||||
this.goForward({
|
||||
name: 'manage-messenger',
|
||||
params: {
|
||||
open: this.sendType,
|
||||
dialog_id: dialog_id
|
||||
}
|
||||
})
|
||||
}
|
||||
this.$store.dispatch("openDialog", dialog_id).then(async () => {
|
||||
try {
|
||||
await $A.waitForCondition(() => this.routeLoading === 0);
|
||||
const type = this.sendType == 'word-chain' ? 'dialogDroupWordChain' : 'dialogGroupVote'
|
||||
this.$store.state[type] = {type: 'create', dialog_id: dialog_id}
|
||||
} catch (error) {
|
||||
// Handle the error
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1205,25 +1205,6 @@ export default {
|
||||
},
|
||||
|
||||
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: {
|
||||
handler(dialog_id, old_id) {
|
||||
this.getDialogBase(dialog_id)
|
||||
|
||||
@ -65,7 +65,6 @@ export default {
|
||||
methods: {
|
||||
onMsgOpen() {
|
||||
this.$store.dispatch("openDialog", this.projectData.dialog_id);
|
||||
this.goForward({name: 'manage-messenger', params: {dialogAction: 'dialog'}});
|
||||
this.beforeDestroyClose = true;
|
||||
},
|
||||
|
||||
|
||||
@ -1617,44 +1617,40 @@ export default {
|
||||
data: {
|
||||
task_id: this.taskDetail.id,
|
||||
},
|
||||
}).then(({data}) => {
|
||||
this.$store.dispatch("saveTask", {
|
||||
id: data.id,
|
||||
dialog_id: data.dialog_id,
|
||||
});
|
||||
this.$store.dispatch("saveDialog", data.dialog_data);
|
||||
}).then(async ({data}) => {
|
||||
await this.$store.dispatch("saveTask", {id: data.id, dialog_id: data.dialog_id});
|
||||
await this.$store.dispatch("saveDialog", data.dialog_data);
|
||||
//
|
||||
if ($A.isSubElectron) {
|
||||
this.resizeDialog().then(() => {
|
||||
this.sendDialogMsg(msgText);
|
||||
});
|
||||
} else {
|
||||
this.$nextTick(() => {
|
||||
if (this.windowPortrait) {
|
||||
$A.onBlur();
|
||||
const transferData = {
|
||||
time: $A.dayjs().unix() + 10,
|
||||
msgRecord: this.msgRecord,
|
||||
msgFile: this.msgFile,
|
||||
msgText: typeof msgText === 'string' && msgText ? msgText : this.msgText,
|
||||
dialogId: data.dialog_id,
|
||||
};
|
||||
this.msgRecord = {};
|
||||
this.msgFile = [];
|
||||
this.msgText = "";
|
||||
this.$nextTick(_ => {
|
||||
if (this.dialogId > 0) {
|
||||
this.$store.dispatch("openTask", 0) // 如果当前打开着对话窗口则关闭任务窗口
|
||||
}
|
||||
this.$store.dispatch('openDialog', data.dialog_id).then(_ => {
|
||||
this.$store.state.dialogMsgTransfer = transferData
|
||||
})
|
||||
})
|
||||
} else {
|
||||
this.sendDialogMsg(msgText);
|
||||
}
|
||||
});
|
||||
await this.resizeDialog()
|
||||
this.sendDialogMsg(msgText);
|
||||
return
|
||||
}
|
||||
this.$nextTick(() => {
|
||||
if (this.windowPortrait) {
|
||||
$A.onBlur();
|
||||
const transferData = {
|
||||
time: $A.dayjs().unix() + 10,
|
||||
msgRecord: this.msgRecord,
|
||||
msgFile: this.msgFile,
|
||||
msgText: typeof msgText === 'string' && msgText ? msgText : this.msgText,
|
||||
dialogId: data.dialog_id,
|
||||
};
|
||||
this.msgRecord = {};
|
||||
this.msgFile = [];
|
||||
this.msgText = "";
|
||||
this.$nextTick(_ => {
|
||||
if (this.dialogId > 0) {
|
||||
this.$store.dispatch("openTask", 0) // 如果当前打开着对话窗口则关闭任务窗口
|
||||
}
|
||||
this.$store.dispatch('openDialog', data.dialog_id).then(_ => {
|
||||
this.$store.state.dialogMsgTransfer = transferData
|
||||
})
|
||||
})
|
||||
} else {
|
||||
this.sendDialogMsg(msgText);
|
||||
}
|
||||
});
|
||||
}).catch(({msg}) => {
|
||||
$A.modalError(msg);
|
||||
}).finally(_ => {
|
||||
|
||||
@ -1312,7 +1312,6 @@ export default {
|
||||
if ($A.leftExists(val, 'dialog_')) {
|
||||
const dialogId = parseInt(val.substr(7))
|
||||
this.$store.dispatch("openDialog", dialogId).then(() => {
|
||||
this.goForward({name: 'manage-messenger'})
|
||||
this.$emit('on-close')
|
||||
}).catch(({msg}) => {
|
||||
$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.dialogMsgId = dialog_msg_id;
|
||||
state.dialogId = dialog_id;
|
||||
if (dialog_id > 0 && state.windowLandscape) {
|
||||
$A.goForward({name: 'manage-messenger', params: {dialogAction: 'dialog'}});
|
||||
}
|
||||
resolve()
|
||||
})
|
||||
})
|
||||
|
||||
9
resources/assets/js/store/mutations.js
vendored
9
resources/assets/js/store/mutations.js
vendored
@ -1,4 +1,13 @@
|
||||
export default {
|
||||
// 路由加载
|
||||
'route/loading': function(state, load) {
|
||||
if (load) {
|
||||
state.routeLoading++
|
||||
} else {
|
||||
state.routeLoading--
|
||||
}
|
||||
},
|
||||
|
||||
// 会员管理
|
||||
'user/push': function(state, 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,
|
||||
routeHistorys: [],
|
||||
routeHistoryLast: {},
|
||||
routeLoading: 0,
|
||||
|
||||
// 请求时间
|
||||
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 {
|
||||
position: fixed;
|
||||
z-index: 49;
|
||||
left: 0;
|
||||
top: 0;
|
||||
bottom: 0;
|
||||
width: 100%;
|
||||
transform: translateX(-120%);
|
||||
&.show-mobile-menu {
|
||||
transform: translateX(0);
|
||||
}
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user