mirror of
https://github.com/kuaifan/dootask.git
synced 2025-12-13 12:02:51 +00:00
perf: 优化草稿消息
This commit is contained in:
parent
4061ae4275
commit
ba52738904
@ -548,7 +548,7 @@ export default {
|
|||||||
'isModKey',
|
'isModKey',
|
||||||
]),
|
]),
|
||||||
|
|
||||||
...mapGetters(['getDraft']),
|
...mapGetters(['getDialogDraft']),
|
||||||
|
|
||||||
isEnterSend({cacheKeyboard}) {
|
isEnterSend({cacheKeyboard}) {
|
||||||
if (this.$isEEUiApp) {
|
if (this.$isEEUiApp) {
|
||||||
@ -708,7 +708,7 @@ export default {
|
|||||||
},
|
},
|
||||||
|
|
||||||
inputDraft() {
|
inputDraft() {
|
||||||
return this.getDraft(this.dialogId)
|
return this.getDialogDraft(this.dialogId)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
@ -723,10 +723,7 @@ export default {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!this.simpleMode) {
|
if (!this.simpleMode) {
|
||||||
this.$store.dispatch("saveDraft", {
|
this.$store.dispatch("saveDialogDraft", {id: this.dialogId, content: val})
|
||||||
dialogId: this.dialogId,
|
|
||||||
content: val
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
@ -1688,10 +1688,7 @@ export default {
|
|||||||
if (!this.msgText) {
|
if (!this.msgText) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.$store.dispatch("saveDraft", {
|
this.$store.dispatch("saveDialogDraft", {id: this.taskDetail.dialog_id, content: this.msgText})
|
||||||
dialogId: this.taskDetail.dialog_id,
|
|
||||||
content: this.msgText
|
|
||||||
})
|
|
||||||
},
|
},
|
||||||
|
|
||||||
taskPasteDrag(e, type) {
|
taskPasteDrag(e, type) {
|
||||||
|
|||||||
@ -107,9 +107,9 @@
|
|||||||
<em v-if="dialog.last_at">{{$A.timeFormat(dialog.last_at)}}</em>
|
<em v-if="dialog.last_at">{{$A.timeFormat(dialog.last_at)}}</em>
|
||||||
</div>
|
</div>
|
||||||
<div class="dialog-text no-dark-content">
|
<div class="dialog-text no-dark-content">
|
||||||
<template v-if="dialog.id != dialogId && tagDraft(dialog.id)">
|
<template v-if="dialog.id != dialogId && tagDialogDraft(dialog.id)">
|
||||||
<div class="last-draft">[{{$L('草稿')}}]</div>
|
<div class="last-draft">[{{$L('草稿')}}]</div>
|
||||||
<div class="last-text"><span>{{formatDraft(getDraft(dialog.id))}}</span></div>
|
<div class="last-text"><span>{{formatDraft(getDialogDraft(dialog.id))}}</span></div>
|
||||||
</template>
|
</template>
|
||||||
<template v-else>
|
<template v-else>
|
||||||
<template v-if="dialog.type=='group' && dialog.last_msg && dialog.last_msg.userid">
|
<template v-if="dialog.type=='group' && dialog.last_msg && dialog.last_msg.userid">
|
||||||
@ -363,7 +363,7 @@ export default {
|
|||||||
'taskColorList'
|
'taskColorList'
|
||||||
]),
|
]),
|
||||||
|
|
||||||
...mapGetters(['getDraft', 'tagDraft']),
|
...mapGetters(['getDialogDraft', 'tagDialogDraft']),
|
||||||
|
|
||||||
routeName() {
|
routeName() {
|
||||||
return this.$route.name
|
return this.$route.name
|
||||||
@ -740,7 +740,7 @@ export default {
|
|||||||
return $A.sortFloat(b.todo_num, a.todo_num);
|
return $A.sortFloat(b.todo_num, a.todo_num);
|
||||||
}
|
}
|
||||||
// 根据草稿排序
|
// 根据草稿排序
|
||||||
const drafts = [this.tagDraft(a.id) ? 1 : 0, this.tagDraft(b.id) ? 1 : 0];
|
const drafts = [this.tagDialogDraft(a.id) ? 1 : 0, this.tagDialogDraft(b.id) ? 1 : 0];
|
||||||
if (drafts[0] || drafts[1]) {
|
if (drafts[0] || drafts[1]) {
|
||||||
return $A.sortFloat(drafts[1], drafts[0]);
|
return $A.sortFloat(drafts[1], drafts[0]);
|
||||||
}
|
}
|
||||||
|
|||||||
14
resources/assets/js/store/actions.js
vendored
14
resources/assets/js/store/actions.js
vendored
@ -971,11 +971,11 @@ export default {
|
|||||||
'cacheTaskBrowse',
|
'cacheTaskBrowse',
|
||||||
'cacheTranslations',
|
'cacheTranslations',
|
||||||
'dialogMsgs',
|
'dialogMsgs',
|
||||||
|
'dialogDrafts',
|
||||||
'fileLists',
|
'fileLists',
|
||||||
'callAt',
|
'callAt',
|
||||||
'cacheEmojis',
|
'cacheEmojis',
|
||||||
'cacheDialogs',
|
'cacheDialogs',
|
||||||
'cacheDrafts',
|
|
||||||
],
|
],
|
||||||
json: [
|
json: [
|
||||||
'userInfo'
|
'userInfo'
|
||||||
@ -1032,7 +1032,7 @@ export default {
|
|||||||
*/
|
*/
|
||||||
onBeforeUnload({commit}) {
|
onBeforeUnload({commit}) {
|
||||||
if ($A.isSubElectron && $A.isJson(window.__dialogDraft)) {
|
if ($A.isSubElectron && $A.isJson(window.__dialogDraft)) {
|
||||||
commit('SET_DRAFT', window.__dialogDraft)
|
commit('SET_DIALOG_DRAFT', window.__dialogDraft)
|
||||||
window.__dialogDraft = null;
|
window.__dialogDraft = null;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -3085,7 +3085,7 @@ export default {
|
|||||||
$A.execMainDispatch("closeDialog", dialog_id)
|
$A.execMainDispatch("closeDialog", dialog_id)
|
||||||
|
|
||||||
// 更新草稿标签
|
// 更新草稿标签
|
||||||
commit('TAG_DRAFT', dialog_id)
|
commit('TAG_DIALOG_DRAFT', dialog_id)
|
||||||
|
|
||||||
// 关闭会话后删除会话超限消息
|
// 关闭会话后删除会话超限消息
|
||||||
const msgs = state.dialogMsgs.filter(item => item.dialog_id == dialog_id)
|
const msgs = state.dialogMsgs.filter(item => item.dialog_id == dialog_id)
|
||||||
@ -3178,15 +3178,15 @@ export default {
|
|||||||
/**
|
/**
|
||||||
* 保存草稿
|
* 保存草稿
|
||||||
* @param commit
|
* @param commit
|
||||||
* @param dialogId
|
* @param id
|
||||||
* @param content
|
* @param content
|
||||||
*/
|
*/
|
||||||
saveDraft({commit}, {dialogId, content}) {
|
saveDialogDraft({commit}, {id, content}) {
|
||||||
if ($A.isSubElectron) {
|
if ($A.isSubElectron) {
|
||||||
window.__dialogDraft = {dialogId, content}
|
window.__dialogDraft = {id, content}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
commit('SET_DRAFT', {dialogId, content})
|
commit('SET_DIALOG_DRAFT', {id, content})
|
||||||
},
|
},
|
||||||
|
|
||||||
/** *****************************************************************************************/
|
/** *****************************************************************************************/
|
||||||
|
|||||||
8
resources/assets/js/store/getters.js
vendored
8
resources/assets/js/store/getters.js
vendored
@ -244,8 +244,8 @@ export default {
|
|||||||
* @param state
|
* @param state
|
||||||
* @returns {function(*): *|string}
|
* @returns {function(*): *|string}
|
||||||
*/
|
*/
|
||||||
getDraft: (state) => (dialogId) => {
|
getDialogDraft: (state) => (id) => {
|
||||||
const draft = state.cacheDrafts.find(item => item.dialogId === dialogId)
|
const draft = state.dialogDrafts.find(item => item.id === id)
|
||||||
return draft ? draft.content : ''
|
return draft ? draft.content : ''
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -254,8 +254,8 @@ export default {
|
|||||||
* @param state
|
* @param state
|
||||||
* @returns {function(*): boolean}
|
* @returns {function(*): boolean}
|
||||||
*/
|
*/
|
||||||
tagDraft: (state) => (dialogId) => {
|
tagDialogDraft: (state) => (id) => {
|
||||||
const draft = state.cacheDrafts.find(item => item.dialogId === dialogId)
|
const draft = state.dialogDrafts.find(item => item.id === id)
|
||||||
return !!draft?.tag
|
return !!draft?.tag
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
24
resources/assets/js/store/mutations.js
vendored
24
resources/assets/js/store/mutations.js
vendored
@ -1,33 +1,33 @@
|
|||||||
export default {
|
export default {
|
||||||
// 设置草稿
|
// 设置草稿
|
||||||
SET_DRAFT(state, {dialogId, content}) {
|
SET_DIALOG_DRAFT(state, {id, content}) {
|
||||||
const index = state.cacheDrafts.findIndex(item => item.dialogId === dialogId)
|
const index = state.dialogDrafts.findIndex(item => item.id === id)
|
||||||
const item = {
|
const item = {
|
||||||
dialogId,
|
id,
|
||||||
content: $A.filterInvalidLine(content),
|
content: $A.filterInvalidLine(content),
|
||||||
time: new Date().getTime()
|
time: new Date().getTime()
|
||||||
}
|
}
|
||||||
|
|
||||||
if (index !== -1) {
|
if (index !== -1) {
|
||||||
// 更新已存在的草稿
|
// 更新已存在的草稿
|
||||||
item.tag = state.cacheDrafts[index].tag
|
item.tag = state.dialogDrafts[index].tag
|
||||||
state.cacheDrafts.splice(index, 1, item)
|
state.dialogDrafts.splice(index, 1, item)
|
||||||
} else {
|
} else {
|
||||||
// 添加新草稿
|
// 添加新草稿
|
||||||
item.tag = state.dialogId != dialogId
|
item.tag = state.dialogId != id
|
||||||
state.cacheDrafts.push(item)
|
state.dialogDrafts.push(item)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 保存到 IndexedDB
|
// 保存到 IndexedDB
|
||||||
$A.IDBSave("cacheDrafts", state.cacheDrafts)
|
$A.IDBSave("dialogDrafts", state.dialogDrafts)
|
||||||
},
|
},
|
||||||
|
|
||||||
// 显示草稿标签
|
// 显示草稿标签
|
||||||
TAG_DRAFT(state, dialogId) {
|
TAG_DIALOG_DRAFT(state, id) {
|
||||||
const index = state.cacheDrafts.findIndex(item => item.dialogId === dialogId)
|
const index = state.dialogDrafts.findIndex(item => item.id === id)
|
||||||
if (index !== -1) {
|
if (index !== -1) {
|
||||||
state.cacheDrafts[index].tag = !!state.cacheDrafts[index].content
|
state.dialogDrafts[index].tag = !!state.dialogDrafts[index].content
|
||||||
$A.IDBSave("cacheDrafts", state.cacheDrafts)
|
$A.IDBSave("dialogDrafts", state.dialogDrafts)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
6
resources/assets/js/store/state.js
vendored
6
resources/assets/js/store/state.js
vendored
@ -7,7 +7,7 @@ export default {
|
|||||||
clientId: "",
|
clientId: "",
|
||||||
|
|
||||||
// 缓存版本号(如果想升级后清除客户端缓存则修改此参数值)
|
// 缓存版本号(如果想升级后清除客户端缓存则修改此参数值)
|
||||||
cacheVersion: "v12",
|
cacheVersion: "v13",
|
||||||
|
|
||||||
// 窗口是否激活
|
// 窗口是否激活
|
||||||
windowActive: true,
|
windowActive: true,
|
||||||
@ -78,9 +78,6 @@ export default {
|
|||||||
// Dialog
|
// Dialog
|
||||||
cacheDialogs: [],
|
cacheDialogs: [],
|
||||||
|
|
||||||
// Draft
|
|
||||||
cacheDrafts: [],
|
|
||||||
|
|
||||||
// Project
|
// Project
|
||||||
cacheProjects: [],
|
cacheProjects: [],
|
||||||
cacheColumns: [],
|
cacheColumns: [],
|
||||||
@ -126,6 +123,7 @@ export default {
|
|||||||
dialogTodos: [],
|
dialogTodos: [],
|
||||||
dialogMsgTops: [],
|
dialogMsgTops: [],
|
||||||
dialogHistory: [],
|
dialogHistory: [],
|
||||||
|
dialogDrafts: [],
|
||||||
dialogMsgTransfer: {time: 0},
|
dialogMsgTransfer: {time: 0},
|
||||||
dialogSseList: [],
|
dialogSseList: [],
|
||||||
dialogDroupWordChain: {},
|
dialogDroupWordChain: {},
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user