diff --git a/env/.env.test b/env/.env.test index 600e960..344c5ee 100644 --- a/env/.env.test +++ b/env/.env.test @@ -9,3 +9,5 @@ VITE_SHOW_SOURCEMAP = true VITE_BASEURL = 'http://192.168.88.59:9503' #VITE_SOCKET_API VITE_SOCKET_API = 'ws://192.168.88.59:9504' +# EPRAPI baseUrl +VITE_EPR_BASEURL = 'http://114.218.158.24:9020' diff --git a/package.json b/package.json index 195aa40..e2e2215 100644 --- a/package.json +++ b/package.json @@ -28,12 +28,14 @@ "@uni-helper/axios-adapter": "^1.5.2", "@uni-helper/localforage-adapter": "^1.0.2", "@uni-helper/uni-use": "^0.19.12", + "@vueup/vue-quill": "^1.2.0", "@vueuse/core": "^9.13.0", "axios": "^1.7.2", "dayjs": "^1.11.12", "less": "^4.2.0", "nzh": "^1.0.13", "pinia-plugin-persistedstate": "^4.1.3", + "quill-mention": "^6.0.2", "vconsole": "^3.15.1", "vue": "^3.3.8", "vue-i18n": "^9.6.5" diff --git a/src/components/talk/message/ImageMessage.vue b/src/components/talk/message/ImageMessage.vue index df3c846..8b69ad2 100644 --- a/src/components/talk/message/ImageMessage.vue +++ b/src/components/talk/message/ImageMessage.vue @@ -1,31 +1,31 @@ @@ -33,28 +33,22 @@ const img = (src: string, width = 200) => {
- +
diff --git a/src/components/talk/message/MixedMessage.vue b/src/components/talk/message/MixedMessage.vue index 4ab41be..56115d8 100644 --- a/src/components/talk/message/MixedMessage.vue +++ b/src/components/talk/message/MixedMessage.vue @@ -1,5 +1,4 @@ @@ -47,17 +47,16 @@ const img = (src, width = 200) => { >
       
@@ -67,16 +66,16 @@ const img = (src, width = 200) => {
 
 
diff --git a/src/pages/dialog/components/emojiPanel.vue b/src/pages/dialog/components/emojiPanel.vue
new file mode 100644
index 0000000..ea2dac4
--- /dev/null
+++ b/src/pages/dialog/components/emojiPanel.vue
@@ -0,0 +1,64 @@
+
+
+
diff --git a/src/pages/dialog/index.vue b/src/pages/dialog/index.vue
index d473edc..4fb4d94 100644
--- a/src/pages/dialog/index.vue
+++ b/src/pages/dialog/index.vue
@@ -15,109 +15,129 @@
     
     
- - -
- 正在加载数据中 ... - 查看更多消息 ... - 没有更多消息了 -
-
- -
- -
- -
- -
+ + +
+ +
+ +
+ +
+ +
-
- - +
+ + - - - - -
-
- - @{{ item.nickname }} - - {{ parseTime(item.created_at, '{m}/{d} {h}:{i}') }} -
- -
- - -
- + + + +
+
+ + @{{ item.nickname }} + + {{ parseTime(item.created_at, '{m}/{d} {h}:{i}') }}
-
-
- - - 回复 {{ item.extra?.reply?.nickname }}: - {{ item.extra?.reply?.content }} - -
-
+
+ + +
+ + +
+
+ +
+ + + 回复 {{ item.extra?.reply?.nickname }}: + {{ item.extra?.reply?.content }} + +
+ +
+
- -
+
+ 正在加载数据中 ... + 查看更多消息 ... + 没有更多消息了 +
+
-
- +
+ +
- +
+
+ +
+ +
diff --git a/src/pages/dialog/util.ts b/src/pages/dialog/util.ts new file mode 100644 index 0000000..bb569b4 --- /dev/null +++ b/src/pages/dialog/util.ts @@ -0,0 +1,175 @@ +import { Delta } from '@vueup/vue-quill' + +interface Item { + type: number + content: string +} + +interface AnalysisResp { + items: Item[] + mentions: any[] + mentionUids: number[] + msgType: number // 1 文本;2:图片;3图文混合消息 + quoteId: string // 引用的消息ID +} + +function removeLeadingNewlines(str: string) { + return str.replace(/^[\n\s]+/, '') +} + +function removeTrailingNewlines(str: string) { + return str.replace(/[\n\s]+$/, '') +} + +export function deltaToMessage(delta: Delta): AnalysisResp { + const resp: AnalysisResp = { + items: [], + mentions: [], + mentionUids: [], + quoteId: '', + msgType: 1 + } + + for (const iterator of delta.ops) { + const insert: any = iterator.insert + + let node: any = null + if (resp.items.length) { + node = resp.items[resp.items.length - 1] + } + + if (typeof insert === 'string') { + if (!insert || insert == '\n') continue + + if (node && node.type == 1) { + node.content = node.content + insert + continue + } + + resp.items.push({ + type: 1, + content: insert + }) + + continue + } + + // @好友 + if (insert && insert.mention) { + const mention = insert.mention + + resp.mentions.push({ + name: `${mention.denotationChar}${mention.value}`, + atid: parseInt(mention.id) + }) + + if (node && node.type == 1) { + node.content = node.content + ` ${mention.denotationChar}${mention.value}` + continue + } + + resp.items.push({ + type: 1, + content: `${mention.denotationChar}${mention.value}` + }) + + continue + } + + // 图片 + if (insert && insert.image) { + resp.items.push({ + type: 3, + content: insert.image + }) + continue + } + + // 表情 + if (insert && insert.emoji) { + const { emoji } = insert + + if (node && node.type == 1) { + node.content = node.content + emoji.alt + continue + } + + resp.items.push({ + type: 1, + content: emoji.alt + }) + + continue + } + + if (insert && insert.quote) { + resp.quoteId = insert.quote.id + continue + } + } + + // 去除前后多余空格 + if (resp.items.length) { + if (resp.items[0].type == 1) { + resp.items[0].content = removeLeadingNewlines(resp.items[0].content) + } + + if (resp.items[resp.items.length - 1].type == 1) { + resp.items[resp.items.length - 1].content = removeTrailingNewlines( + resp.items[resp.items.length - 1].content + ) + } + } + + if (resp.items.length > 1) { + resp.msgType = 12 + } + + if (resp.items.length == 1) { + resp.msgType = resp.items[0].type + } + + resp.mentionUids = resp.mentions.map((item) => item.atid) + + return resp +} + +export function deltaToString(delta: Delta): string { + let content = '' + + for (const o of delta.ops) { + const insert: any = o.insert + + if (typeof insert === 'string') { + if (!insert || insert == '\n') continue + + content += insert + continue + } + + // @好友 + if (insert && insert.mention) { + const { mention } = insert + content += ` ${mention.denotationChar}${mention.value} ` + continue + } + + // 图片 + if (insert && insert.image) { + content += '[图片]' + continue + } + + // 表情 + if (insert && insert.emoji) { + content += insert.emoji.alt + continue + } + } + + return content +} + +export function isEmptyDelta(delta: Delta): boolean { + return delta.ops.length == 1 && delta.ops[0].insert == '\n' +} diff --git a/src/pages/index/index.vue b/src/pages/index/index.vue index 4173ded..3dbc48d 100644 --- a/src/pages/index/index.vue +++ b/src/pages/index/index.vue @@ -63,6 +63,9 @@ watch(() => talkStore, (newValue, oldValue) => {