mirror of
https://github.com/kuaifan/dootask.git
synced 2026-01-20 16:08:14 +00:00
perf: 优化引用消息
This commit is contained in:
parent
69fc0a118b
commit
cf5e126eaa
@ -548,7 +548,7 @@ export default {
|
|||||||
'isModKey',
|
'isModKey',
|
||||||
]),
|
]),
|
||||||
|
|
||||||
...mapGetters(['getDialogDraft']),
|
...mapGetters(['getDialogDraft', 'getDialogQuote']),
|
||||||
|
|
||||||
isEnterSend({cacheKeyboard}) {
|
isEnterSend({cacheKeyboard}) {
|
||||||
if (this.$isEEUiApp) {
|
if (this.$isEEUiApp) {
|
||||||
@ -687,16 +687,16 @@ export default {
|
|||||||
return this.dialogId > 0 ? (this.cacheDialogs.find(({id}) => id == this.dialogId) || {}) : {};
|
return this.dialogId > 0 ? (this.cacheDialogs.find(({id}) => id == this.dialogId) || {}) : {};
|
||||||
},
|
},
|
||||||
|
|
||||||
quoteUpdate() {
|
draftData() {
|
||||||
return this.dialogData.extra_quote_type === 'update'
|
return this.getDialogDraft(this.dialogId)?.content || ''
|
||||||
},
|
},
|
||||||
|
|
||||||
quoteData() {
|
quoteData() {
|
||||||
const {extra_quote_id} = this.dialogData;
|
return this.getDialogQuote(this.dialogId)?.content || null
|
||||||
if (extra_quote_id) {
|
},
|
||||||
return this.dialogMsgs.find(item => item.id === extra_quote_id)
|
|
||||||
}
|
quoteUpdate() {
|
||||||
return null;
|
return this.getDialogQuote(this.dialogId)?.type === 'update'
|
||||||
},
|
},
|
||||||
|
|
||||||
chatInputBoxStyle({iOSDevices, fullInput, viewportHeight}) {
|
chatInputBoxStyle({iOSDevices, fullInput, viewportHeight}) {
|
||||||
@ -705,10 +705,6 @@ export default {
|
|||||||
style.height = Math.max(100, viewportHeight - 70) + 'px'
|
style.height = Math.max(100, viewportHeight - 70) + 'px'
|
||||||
}
|
}
|
||||||
return style
|
return style
|
||||||
},
|
|
||||||
|
|
||||||
inputDraft() {
|
|
||||||
return this.getDialogDraft(this.dialogId)
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
@ -750,7 +746,7 @@ export default {
|
|||||||
this.loadInputDraft()
|
this.loadInputDraft()
|
||||||
},
|
},
|
||||||
|
|
||||||
inputDraft() {
|
draftData() {
|
||||||
if (this.isFocus) {
|
if (this.isFocus) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -1214,12 +1210,12 @@ export default {
|
|||||||
},
|
},
|
||||||
|
|
||||||
loadInputDraft() {
|
loadInputDraft() {
|
||||||
if (this.simpleMode || !this.inputDraft) {
|
if (this.simpleMode || !this.draftData) {
|
||||||
this.$emit('input', '')
|
this.$emit('input', '')
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
this.pasteClean = false
|
this.pasteClean = false
|
||||||
this.$emit('input', this.inputDraft)
|
this.$emit('input', this.draftData)
|
||||||
this.$nextTick(_ => this.pasteClean = true)
|
this.$nextTick(_ => this.pasteClean = true)
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -1718,10 +1714,18 @@ export default {
|
|||||||
},
|
},
|
||||||
|
|
||||||
setQuote(id, type = 'reply') {
|
setQuote(id, type = 'reply') {
|
||||||
this.dialogId > 0 && this.$store.dispatch("saveDialog", {
|
if (this.dialogId <= 0) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
const content = this.dialogMsgs.find(item => item.id == id && item.dialog_id == this.dialogId)
|
||||||
|
if (!content) {
|
||||||
|
this.$store.dispatch("removeDialogQuote", this.dialogId);
|
||||||
|
return
|
||||||
|
}
|
||||||
|
this.$store.dispatch("saveDialogQuote", {
|
||||||
id: this.dialogId,
|
id: this.dialogId,
|
||||||
extra_quote_id: id,
|
type: type === 'update' ? 'update' : 'reply',
|
||||||
extra_quote_type: type === 'update' ? 'update' : 'reply'
|
content
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
@ -18,7 +18,7 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import {mapState} from "vuex";
|
import {mapGetters} from "vuex";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'DialogUpload',
|
name: 'DialogUpload',
|
||||||
@ -42,7 +42,7 @@ export default {
|
|||||||
},
|
},
|
||||||
|
|
||||||
computed: {
|
computed: {
|
||||||
...mapState(['cacheDialogs']),
|
...mapGetters(['getDialogQuote']),
|
||||||
|
|
||||||
headers() {
|
headers() {
|
||||||
return {
|
return {
|
||||||
@ -54,12 +54,12 @@ export default {
|
|||||||
params() {
|
params() {
|
||||||
return {
|
return {
|
||||||
dialog_id: this.dialogId,
|
dialog_id: this.dialogId,
|
||||||
reply_id: this.dialogData.extra_quote_id || 0,
|
reply_id: this.quoteData?.id || 0,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
dialogData() {
|
quoteData() {
|
||||||
return this.cacheDialogs.find(({id}) => id == this.dialogId) || {};
|
return this.getDialogQuote(this.dialogId)?.content || null
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
@ -952,7 +952,7 @@ export default {
|
|||||||
'cacheTranslationLanguage'
|
'cacheTranslationLanguage'
|
||||||
]),
|
]),
|
||||||
|
|
||||||
...mapGetters(['isLoad']),
|
...mapGetters(['isLoad', 'getDialogQuote']),
|
||||||
|
|
||||||
isReady() {
|
isReady() {
|
||||||
return this.dialogId > 0 && this.dialogData.id > 0
|
return this.dialogId > 0 && this.dialogData.id > 0
|
||||||
@ -1191,15 +1191,19 @@ export default {
|
|||||||
return this.dialogData.is_disable ?? false
|
return this.dialogData.is_disable ?? false
|
||||||
},
|
},
|
||||||
|
|
||||||
|
quoteData() {
|
||||||
|
return this.getDialogQuote(this.dialogId)?.content || null
|
||||||
|
},
|
||||||
|
|
||||||
|
quoteUpdate() {
|
||||||
|
return this.getDialogQuote(this.dialogId)?.type === 'update'
|
||||||
|
},
|
||||||
|
|
||||||
quoteId() {
|
quoteId() {
|
||||||
if (this.msgId > 0) {
|
if (this.msgId > 0) {
|
||||||
return this.msgId
|
return this.msgId
|
||||||
}
|
}
|
||||||
return this.dialogData.extra_quote_id || 0
|
return this.quoteData?.id || 0
|
||||||
},
|
|
||||||
|
|
||||||
quoteData() {
|
|
||||||
return this.quoteId ? this.allMsgs.find(({id}) => id === this.quoteId) : null
|
|
||||||
},
|
},
|
||||||
|
|
||||||
todoViewMsg() {
|
todoViewMsg() {
|
||||||
@ -1662,7 +1666,7 @@ export default {
|
|||||||
.replace(/(<span\s+class="mention"(.*?)>.*?<\/span>.*?<\/span>.*?<\/span>)(\x20)?/, "$1 ")
|
.replace(/(<span\s+class="mention"(.*?)>.*?<\/span>.*?<\/span>.*?<\/span>)(\x20)?/, "$1 ")
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
if (this.dialogData.extra_quote_type === 'update') {
|
if (this.quoteUpdate) {
|
||||||
// 修改
|
// 修改
|
||||||
if (textType === "text") {
|
if (textType === "text") {
|
||||||
textBody = textBody.replace(new RegExp(`src=(["'])${$A.mainUrl()}`, "g"), "src=$1{{RemoteURL}}")
|
textBody = textBody.replace(new RegExp(`src=(["'])${$A.mainUrl()}`, "g"), "src=$1{{RemoteURL}}")
|
||||||
|
|||||||
@ -109,7 +109,7 @@
|
|||||||
<div class="dialog-text no-dark-content">
|
<div class="dialog-text no-dark-content">
|
||||||
<template v-if="dialog.id != dialogId && tagDialogDraft(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(getDialogDraft(dialog.id))}}</span></div>
|
<div class="last-text"><span>{{formatDraft(getDialogDraft(dialog.id)?.content)}}</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">
|
||||||
|
|||||||
19
resources/assets/js/store/actions.js
vendored
19
resources/assets/js/store/actions.js
vendored
@ -982,6 +982,7 @@ export default {
|
|||||||
'cacheTranslations',
|
'cacheTranslations',
|
||||||
'dialogMsgs',
|
'dialogMsgs',
|
||||||
'dialogDrafts',
|
'dialogDrafts',
|
||||||
|
'dialogQuotes',
|
||||||
'fileLists',
|
'fileLists',
|
||||||
'callAt',
|
'callAt',
|
||||||
'cacheEmojis',
|
'cacheEmojis',
|
||||||
@ -3209,6 +3210,24 @@ export default {
|
|||||||
}, (immediate || !content) ? 0 : 600)
|
}, (immediate || !content) ? 0 : 600)
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 保存引用
|
||||||
|
* @param commit
|
||||||
|
* @param data {id, type, content}
|
||||||
|
*/
|
||||||
|
saveDialogQuote({commit}, data) {
|
||||||
|
commit('quote/set', data)
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 移除引用
|
||||||
|
* @param commit
|
||||||
|
* @param id
|
||||||
|
*/
|
||||||
|
removeDialogQuote({commit}, id) {
|
||||||
|
commit('quote/remove', id)
|
||||||
|
},
|
||||||
|
|
||||||
/** *****************************************************************************************/
|
/** *****************************************************************************************/
|
||||||
/** ************************************** 消息 **********************************************/
|
/** ************************************** 消息 **********************************************/
|
||||||
/** *****************************************************************************************/
|
/** *****************************************************************************************/
|
||||||
|
|||||||
12
resources/assets/js/store/getters.js
vendored
12
resources/assets/js/store/getters.js
vendored
@ -246,7 +246,7 @@ export default {
|
|||||||
*/
|
*/
|
||||||
getDialogDraft: (state) => (id) => {
|
getDialogDraft: (state) => (id) => {
|
||||||
const draft = state.dialogDrafts.find(item => item.id === id)
|
const draft = state.dialogDrafts.find(item => item.id === id)
|
||||||
return draft ? draft.content : ''
|
return draft || null
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -258,4 +258,14 @@ export default {
|
|||||||
const draft = state.dialogDrafts.find(item => item.id === id)
|
const draft = state.dialogDrafts.find(item => item.id === id)
|
||||||
return !!draft?.tag
|
return !!draft?.tag
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取引用
|
||||||
|
* @param state
|
||||||
|
* @returns {function(*): *}
|
||||||
|
*/
|
||||||
|
getDialogQuote: (state) => (id) => {
|
||||||
|
const quote = state.dialogQuotes.find(item => item.id === id)
|
||||||
|
return quote || null
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
34
resources/assets/js/store/mutations.js
vendored
34
resources/assets/js/store/mutations.js
vendored
@ -81,7 +81,6 @@ export default {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// 草稿标签
|
|
||||||
if (state.dialogId == id) {
|
if (state.dialogId == id) {
|
||||||
item.tag = index !== -1 ? state.dialogDrafts[index].tag : false
|
item.tag = index !== -1 ? state.dialogDrafts[index].tag : false
|
||||||
} else {
|
} else {
|
||||||
@ -89,14 +88,11 @@ export default {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (index !== -1) {
|
if (index !== -1) {
|
||||||
// 更新已存在的草稿
|
|
||||||
state.dialogDrafts.splice(index, 1, item)
|
state.dialogDrafts.splice(index, 1, item)
|
||||||
} else {
|
} else {
|
||||||
// 添加新草稿
|
|
||||||
state.dialogDrafts.push(item)
|
state.dialogDrafts.push(item)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 保存到 IndexedDB
|
|
||||||
$A.IDBSave("dialogDrafts", state.dialogDrafts)
|
$A.IDBSave("dialogDrafts", state.dialogDrafts)
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -110,4 +106,34 @@ export default {
|
|||||||
$A.IDBSave("dialogDrafts", state.dialogDrafts)
|
$A.IDBSave("dialogDrafts", state.dialogDrafts)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
// 引用管理
|
||||||
|
'quote/set': function(state, {id, type, content}) {
|
||||||
|
const index = state.dialogQuotes.findIndex(item => item.id === id)
|
||||||
|
const item = {
|
||||||
|
id,
|
||||||
|
type,
|
||||||
|
content,
|
||||||
|
time: new Date().getTime()
|
||||||
|
}
|
||||||
|
if (index === -1 && !item.content) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if (index !== -1) {
|
||||||
|
state.dialogQuotes.splice(index, 1, item)
|
||||||
|
} else {
|
||||||
|
state.dialogQuotes.push(item)
|
||||||
|
}
|
||||||
|
|
||||||
|
$A.IDBSave("dialogQuotes", state.dialogQuotes)
|
||||||
|
},
|
||||||
|
|
||||||
|
'quote/remove': function(state, id) {
|
||||||
|
const index = state.dialogQuotes.findIndex(item => item.id === id)
|
||||||
|
if (index !== -1) {
|
||||||
|
state.dialogQuotes.splice(index, 1)
|
||||||
|
$A.IDBSave("dialogQuotes", state.dialogQuotes)
|
||||||
|
}
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
3
resources/assets/js/store/state.js
vendored
3
resources/assets/js/store/state.js
vendored
@ -7,7 +7,7 @@ export default {
|
|||||||
clientId: "",
|
clientId: "",
|
||||||
|
|
||||||
// 缓存版本号(如果想升级后清除客户端缓存则修改此参数值)
|
// 缓存版本号(如果想升级后清除客户端缓存则修改此参数值)
|
||||||
cacheVersion: "v13",
|
cacheVersion: "v14",
|
||||||
|
|
||||||
// 窗口是否激活
|
// 窗口是否激活
|
||||||
windowActive: true,
|
windowActive: true,
|
||||||
@ -125,6 +125,7 @@ export default {
|
|||||||
dialogMsgTops: [],
|
dialogMsgTops: [],
|
||||||
dialogHistory: [],
|
dialogHistory: [],
|
||||||
dialogDrafts: [],
|
dialogDrafts: [],
|
||||||
|
dialogQuotes: [],
|
||||||
dialogMsgTransfer: {time: 0},
|
dialogMsgTransfer: {time: 0},
|
||||||
dialogSseList: [],
|
dialogSseList: [],
|
||||||
dialogDroupWordChain: {},
|
dialogDroupWordChain: {},
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user