Compare commits
24 Commits
Author | SHA1 | Date | |
---|---|---|---|
4cbad14c98 | |||
e0924b14ef | |||
6c6bcb7dce | |||
7d3d47a63c | |||
c00d5da7d7 | |||
32aa5f7d81 | |||
78009bc5e7 | |||
21f413d6e3 | |||
6e0322e2c7 | |||
2d7f2492af | |||
6543ac0607 | |||
6c63946d37 | |||
13830d748b | |||
7999499702 | |||
429c30808b | |||
|
111f303b2a | ||
451974a84f | |||
|
959978a2c7 | ||
a95e53d8a0 | |||
825ca5ec3c | |||
a87395c87c | |||
845281377f | |||
481719a685 | |||
03e84eab94 |
13
env/.env.prod
vendored
13
env/.env.prod
vendored
@ -3,5 +3,14 @@ ENV = 'production'
|
||||
|
||||
VITE_BASE=/
|
||||
VITE_ROUTER_MODE=history
|
||||
VITE_BASE_API=https://xxxx.xxx.com
|
||||
VITE_SOCKET_API=wss://xxxx.xxxx.com
|
||||
VUE_APP_PREVIEW=false
|
||||
VUE_APP_WEBSITE_NAME=""
|
||||
|
||||
# baseUrl
|
||||
VITE_BASE_API = 'https://chat.szjixun.cn' #体制内
|
||||
#VITE_SOCKET_API
|
||||
VITE_SOCKET_API = 'wss://chat.szjixun.cn' #体制内
|
||||
# EPRAPI baseUrl
|
||||
VITE_EPR_BASEURL = 'https://erpapi.fontree.cn' #体制内
|
||||
# 文档查看器
|
||||
VITE_PAGE_URL = https://chat-pc.szjixun.cn #体制内
|
16
env/.env.prodOut
vendored
Normal file
16
env/.env.prodOut
vendored
Normal file
@ -0,0 +1,16 @@
|
||||
# just a flag
|
||||
ENV = 'production'
|
||||
|
||||
VITE_BASE=/
|
||||
VITE_ROUTER_MODE=history
|
||||
VUE_APP_PREVIEW=false
|
||||
VUE_APP_WEBSITE_NAME=""
|
||||
|
||||
# baseUrl
|
||||
VITE_BASE_API = 'https://chat-out.szjixun.cn' #体制外
|
||||
#VITE_SOCKET_API
|
||||
VITE_SOCKET_API = 'wss://chat-out.szjixun.cn' #体制外
|
||||
# EPRAPI baseUrl
|
||||
VITE_EPR_BASEURL = 'https://erpapi-out.szjixun.cn' #体制外
|
||||
# 文档查看器
|
||||
VITE_PAGE_URL = https://chat-pc-out.szjixun.cn #体制外
|
@ -6,8 +6,10 @@
|
||||
"scripts": {
|
||||
"dev:test": "vite --mode test --port 5273",
|
||||
"dev:prod": "vite --mode prod --port 5273",
|
||||
"dev:prod:out": "vite --mode prodOut --port 5273",
|
||||
"build:test": "vite build --mode test",
|
||||
"build:prod": "vite build --mode test",
|
||||
"build:prod": "vite build --mode prod",
|
||||
"build:prod:out": "vite build --mode prodOut",
|
||||
"preview": "vite preview",
|
||||
"type-check": "vue-tsc --noEmit -p tsconfig.app.json --composite false",
|
||||
"lint": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --fix --ignore-path .gitignore",
|
||||
@ -20,6 +22,7 @@
|
||||
"@iconify-json/ion": "^1.2.3",
|
||||
"@kangc/v-md-editor": "^2.3.18",
|
||||
"@onlyoffice/document-editor-vue": "^1.5.0",
|
||||
"@soerenmartius/vue3-clipboard": "^0.1.2",
|
||||
"@tiptap/core": "^2.23.1",
|
||||
"@tiptap/extension-blockquote": "^2.23.1",
|
||||
"@tiptap/extension-emoji": "^2.23.1",
|
||||
|
@ -26,6 +26,9 @@ importers:
|
||||
'@onlyoffice/document-editor-vue':
|
||||
specifier: ^1.5.0
|
||||
version: 1.5.0(vue@3.5.17(typescript@5.2.2))
|
||||
'@soerenmartius/vue3-clipboard':
|
||||
specifier: ^0.1.2
|
||||
version: 0.1.2
|
||||
'@tiptap/core':
|
||||
specifier: ^2.23.1
|
||||
version: 2.23.1(@tiptap/pm@2.23.1)
|
||||
@ -898,6 +901,9 @@ packages:
|
||||
resolution: {integrity: sha512-tlqY9xq5ukxTUZBmoOp+m61cqwQD5pHJtFY3Mn8CA8ps6yghLH/Hw8UPdqg4OLmFW3IFlcXnQNmo/dh8HzXYIQ==}
|
||||
engines: {node: '>=18'}
|
||||
|
||||
'@soerenmartius/vue3-clipboard@0.1.2':
|
||||
resolution: {integrity: sha512-a5er6cFGcFIQ/3qg6kWvU0yFqIz9iWoQGEVs9azjevyRyMAKvj1w3JuLH9y6+u0WhMNby3kn7nuR8nktSnDesg==}
|
||||
|
||||
'@tiptap/core@2.23.1':
|
||||
resolution: {integrity: sha512-EURGKGsEPrwxvOPi9gA+BsczvsECJNV+xgTAGWHmEtU4YJ0AulYrCX3b7FK+aiduVhThIHDoG/Mmvmb/HPLRhQ==}
|
||||
peerDependencies:
|
||||
@ -1613,6 +1619,9 @@ packages:
|
||||
resolution: {integrity: sha512-qOhPa/Fj7s6TY8H8esGu5QNpMMQxz79h+urzrNYN6mn+9BnxlDGf5QZ+XeCDsxSjPqsSR56XOZOJmpeurnLMeg==}
|
||||
engines: {node: '>=0.10.0'}
|
||||
|
||||
clipboard@2.0.11:
|
||||
resolution: {integrity: sha512-C+0bbOqkezLIsmWSvlsXS0Q0bmkugu7jcfMIACB+RDEntIzQIkdr148we28AfSloQLRdZlYL/QYyrq05j/3Faw==}
|
||||
|
||||
cliui@8.0.1:
|
||||
resolution: {integrity: sha512-BSeNnyus75C4//NQ9gQt1/csTXyo/8Sb+afLAkzAptFuMsod9HFokGNudZpi/oQV73hnVK+sR+5PVRMd+Dr7YQ==}
|
||||
engines: {node: '>=12'}
|
||||
@ -2347,6 +2356,9 @@ packages:
|
||||
resolution: {integrity: sha512-ollPHROa5mcxDEkwg6bPt3QbEf4pDQSNtd6JPL1YvOvAo/7/0VAm9TccUeoTmarjPw4pfUthSCqcyfNB1I3ZSg==}
|
||||
engines: {node: '>=6'}
|
||||
|
||||
good-listener@1.2.2:
|
||||
resolution: {integrity: sha512-goW1b+d9q/HIwbVYZzZ6SsTr4IgE+WA44A0GmPIQstuOrgsFcT7VEJ48nmr9GaRtNu0XTKacFLGnBPAM6Afouw==}
|
||||
|
||||
gopd@1.2.0:
|
||||
resolution: {integrity: sha512-ZUKRh6/kUFoAiTAtTYPZJ3hw9wNxx+BIBOijnlG9PnrJsCcSjs1wyyD6vJpaYtgnzDrKYRSqf3OO6Rfa93xsRg==}
|
||||
engines: {node: '>= 0.4'}
|
||||
@ -3358,6 +3370,9 @@ packages:
|
||||
seemly@0.3.10:
|
||||
resolution: {integrity: sha512-2+SMxtG1PcsL0uyhkumlOU6Qo9TAQ/WyH7tthnPIOQB05/12jz9naq6GZ6iZ6ApVsO3rr2gsnTf3++OV63kE1Q==}
|
||||
|
||||
select@1.1.2:
|
||||
resolution: {integrity: sha512-OwpTSOfy6xSs1+pwcNrv0RBMOzI39Lp3qQKUTPVVPRjCdNa5JH/oPRiqsesIskK8TVgmRiHwO4KXlV2Li9dANA==}
|
||||
|
||||
semver@5.7.2:
|
||||
resolution: {integrity: sha512-cBznnQ9KjJqU67B52RMC65CMarK2600WFnbkcaiwWq3xy/5haFJlshgnpjovMVJ+Hff49d8GEn0b87C5pDQ10g==}
|
||||
hasBin: true
|
||||
@ -3543,6 +3558,9 @@ packages:
|
||||
resolution: {integrity: sha512-B71/4oyj61iNH0KeCamLuE2rmKuTO5byTOSVwECM5FA7TiAiAW+UqTKZ9ERueC4qvgSttUhdmq1mXC3kJqGX7A==}
|
||||
engines: {node: '>=12.22'}
|
||||
|
||||
tiny-emitter@2.1.0:
|
||||
resolution: {integrity: sha512-NB6Dk1A9xgQPMoGqC5CVXn123gWyte215ONT5Pp5a0yt4nlEoO1ZWeCwpncaekPHXO60i47ihFnZPiRPjRMq4Q==}
|
||||
|
||||
tinyexec@1.0.1:
|
||||
resolution: {integrity: sha512-5uC6DDlmeqiOwCPmK9jMSdOuZTh8bU39Ys6yidB+UTt5hfZUPGAypSgFRiEp+jbi9qH40BLDvy85jIU88wKSqw==}
|
||||
|
||||
@ -4559,6 +4577,10 @@ snapshots:
|
||||
|
||||
'@sindresorhus/merge-streams@4.0.0': {}
|
||||
|
||||
'@soerenmartius/vue3-clipboard@0.1.2':
|
||||
dependencies:
|
||||
clipboard: 2.0.11
|
||||
|
||||
'@tiptap/core@2.23.1(@tiptap/pm@2.23.1)':
|
||||
dependencies:
|
||||
'@tiptap/pm': 2.23.1
|
||||
@ -5518,6 +5540,12 @@ snapshots:
|
||||
isobject: 3.0.1
|
||||
static-extend: 0.1.2
|
||||
|
||||
clipboard@2.0.11:
|
||||
dependencies:
|
||||
good-listener: 1.2.2
|
||||
select: 1.1.2
|
||||
tiny-emitter: 2.1.0
|
||||
|
||||
cliui@8.0.1:
|
||||
dependencies:
|
||||
string-width: 4.2.3
|
||||
@ -6299,6 +6327,10 @@ snapshots:
|
||||
transitivePeerDependencies:
|
||||
- supports-color
|
||||
|
||||
good-listener@1.2.2:
|
||||
dependencies:
|
||||
delegate: 3.2.0
|
||||
|
||||
gopd@1.2.0: {}
|
||||
|
||||
graceful-fs@4.2.11: {}
|
||||
@ -7430,6 +7462,8 @@ snapshots:
|
||||
|
||||
seemly@0.3.10: {}
|
||||
|
||||
select@1.1.2: {}
|
||||
|
||||
semver@5.7.2:
|
||||
optional: true
|
||||
|
||||
@ -7609,6 +7643,8 @@ snapshots:
|
||||
|
||||
throttle-debounce@5.0.2: {}
|
||||
|
||||
tiny-emitter@2.1.0: {}
|
||||
|
||||
tinyexec@1.0.1: {}
|
||||
|
||||
tinyglobby@0.2.14:
|
||||
|
BIN
src/assets/image/bofang1.png
Normal file
BIN
src/assets/image/bofang1.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.0 KiB |
BIN
src/assets/image/yuyin1.png
Normal file
BIN
src/assets/image/yuyin1.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.3 KiB |
@ -1,5 +1,5 @@
|
||||
<template>
|
||||
<div class="dropdown-menu">
|
||||
<div class="dropdown-menu" ref="dropdownMenuRef">
|
||||
<n-virtual-list
|
||||
ref="virtualListRef"
|
||||
style="max-height: 240px"
|
||||
@ -20,7 +20,7 @@
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, watch, defineProps, defineExpose } from 'vue'
|
||||
import { ref, watch, defineProps, defineExpose, onMounted, onUnmounted } from 'vue'
|
||||
|
||||
const props = defineProps({
|
||||
items: {
|
||||
@ -35,6 +35,40 @@ const props = defineProps({
|
||||
|
||||
const selectedIndex = ref(0)
|
||||
const virtualListRef = ref(null)
|
||||
const dropdownMenuRef = ref(null)
|
||||
|
||||
let observer = null
|
||||
|
||||
let isViewport = ref(true)
|
||||
const handleIntersection = (entries, observer) => {
|
||||
entries.forEach(entry => {
|
||||
if (entry.isIntersecting) {
|
||||
isViewport.value = true
|
||||
// 在这里处理元素可见的逻辑
|
||||
} else {
|
||||
isViewport.value = false
|
||||
// 在这里处理元素不可见的逻辑
|
||||
}
|
||||
})
|
||||
}
|
||||
onMounted(() => {
|
||||
observer = new IntersectionObserver(handleIntersection, {
|
||||
root: null, // null 值表示视口
|
||||
rootMargin: '0px',
|
||||
threshold: 0.1 // 元素至少有 10% 可见时触发回调
|
||||
})
|
||||
|
||||
if (dropdownMenuRef.value) {
|
||||
observer.observe(dropdownMenuRef.value)
|
||||
}
|
||||
})
|
||||
|
||||
onUnmounted(() => {
|
||||
if (observer && dropdownMenuRef.value) {
|
||||
observer.unobserve(dropdownMenuRef.value)
|
||||
observer.disconnect()
|
||||
}
|
||||
})
|
||||
|
||||
watch(
|
||||
() => props.items,
|
||||
@ -44,7 +78,8 @@ watch(
|
||||
)
|
||||
|
||||
const onKeyDown = ({ event }) => {
|
||||
console.log('event',event)
|
||||
console.log('event', event)
|
||||
if(!isViewport.value) return false
|
||||
if (event.key === 'ArrowUp') {
|
||||
upHandler()
|
||||
return true
|
||||
@ -100,6 +135,7 @@ defineExpose({
|
||||
overflow: auto;
|
||||
padding: 0.4rem;
|
||||
position: relative;
|
||||
|
||||
max-height: 200px;
|
||||
width: 200px;
|
||||
button {
|
||||
|
@ -9,7 +9,7 @@ import { computePosition, flip, shift } from '@floating-ui/dom'
|
||||
import Link from '@tiptap/extension-link'
|
||||
import { Extension, Node } from '@tiptap/core'
|
||||
import { Plugin, PluginKey } from '@tiptap/pm/state'
|
||||
|
||||
import { IosSend } from '@vicons/ionicons4'
|
||||
|
||||
import { reactive, watch, ref, markRaw, computed, onMounted, onUnmounted, shallowRef } from 'vue'
|
||||
|
||||
@ -61,6 +61,9 @@ const props = defineProps({
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
uid:{
|
||||
type: Number
|
||||
},
|
||||
members: {
|
||||
default: () => []
|
||||
}
|
||||
@ -216,6 +219,7 @@ const editor = useEditor({
|
||||
return suggestion.items({
|
||||
query,
|
||||
props: {
|
||||
uid: props.uid,
|
||||
members: props.members,
|
||||
isGroupManager: (dialogueStore.groupInfo).is_manager
|
||||
}
|
||||
@ -287,7 +291,8 @@ const editor = useEditor({
|
||||
if (text) {
|
||||
event.preventDefault()
|
||||
const { state, dispatch } = view
|
||||
dispatch(state.tr.insertText(text))
|
||||
// dispatch(state.tr.insertContent(text).replace(/\n/g, '<br>'))
|
||||
editor.value.commands.insertContent(text.replace(/\r/g, '').replace(/\n/g, '<br>'))
|
||||
return true // Handled
|
||||
}
|
||||
|
||||
@ -397,7 +402,11 @@ async function onUploadFile(e) {
|
||||
|
||||
if (file.type.indexOf('image/') === 0) {
|
||||
|
||||
let fn = emitCall('image_event', file, () => {})
|
||||
const form = new FormData()
|
||||
form.append('file', file)
|
||||
form.append('source', 'fonchain-chat')
|
||||
const { data } = await uploadImg(form)
|
||||
let fn = emitCall('image_event', { url: data.ori_url, size: file.size }, () => { })
|
||||
emit('editor-event', fn)
|
||||
|
||||
return
|
||||
@ -522,6 +531,8 @@ function tiptapToString() {
|
||||
result += node.attrs.alt || ''
|
||||
} else if (node.type === 'hardBreak') {
|
||||
result += '\n'
|
||||
} else if (node.type === 'image') {
|
||||
result += '[图片]'
|
||||
}
|
||||
})
|
||||
}
|
||||
@ -705,7 +716,8 @@ function onSubscribeEdit(data) {
|
||||
editor.value.commands.clearContent(true)
|
||||
|
||||
|
||||
editor.value.commands.insertContent(data.content)
|
||||
editor.value.commands.insertContent(data.content.replace(/\n/g, '<br>'))
|
||||
|
||||
|
||||
|
||||
editor.value.commands.focus('end')
|
||||
@ -784,6 +796,16 @@ useEventBus([
|
||||
<p class="tip-title">{{ nav.title }}</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="h-[45px] flex justify-center items-center">
|
||||
<n-button class="w-80px h-30px mr-[22px]" type="primary" @click="onSendMessage">
|
||||
<template #icon>
|
||||
<n-icon>
|
||||
<IosSend />
|
||||
</n-icon>
|
||||
</template>
|
||||
发送
|
||||
</n-button>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<div v-if="quoteData" class="quote-card-wrapper">
|
||||
@ -971,6 +993,7 @@ html[theme-mode='dark'] {
|
||||
outline: none;
|
||||
.tiptap.ProseMirror{
|
||||
height: 100%;
|
||||
white-space: pre-wrap;
|
||||
}
|
||||
.image-upload-loading {
|
||||
position: relative;
|
||||
|
@ -39,6 +39,8 @@ export default {
|
||||
if (props.isGroupManager) {
|
||||
list.unshift({ id: 0, nickname: '所有人', avatar: defAvatar })
|
||||
}
|
||||
// 排除掉自己
|
||||
list.splice(list.findIndex((item) => item.id === props.uid), 1)
|
||||
|
||||
const filteredItems = list.filter(
|
||||
(item) => item.nickname.toLowerCase().includes(query.toLowerCase())
|
||||
|
@ -1,70 +1,172 @@
|
||||
<template>
|
||||
<span>
|
||||
<template v-if="isHtml">
|
||||
<span v-html="highlightedHtml" />
|
||||
</template>
|
||||
<template v-else>
|
||||
<span class="text-content">
|
||||
<template v-for="(part, index) in parts" :key="index">
|
||||
<span v-if="part.highlighted" :class="highlightClass">
|
||||
{{ part.text }}
|
||||
<span
|
||||
v-if="part.highlighted"
|
||||
:class="highlightClass"
|
||||
v-html="textReplaceEmoji(part.text)"
|
||||
/>
|
||||
<span v-else v-html="textReplaceEmoji(part.text)" />
|
||||
</template>
|
||||
</span>
|
||||
<span v-else>{{ part.text }}</span>
|
||||
</template>
|
||||
</span>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { computed } from 'vue'
|
||||
import { textReplaceEmoji } from '@/utils/emojis'
|
||||
|
||||
const props = defineProps({
|
||||
text: {
|
||||
type: String,
|
||||
required: true,
|
||||
required: true
|
||||
},
|
||||
searchText: {
|
||||
type: String,
|
||||
default: '',
|
||||
default: ''
|
||||
},
|
||||
highlightClass: {
|
||||
type: String,
|
||||
default: 'highlight',
|
||||
},
|
||||
default: 'highlight'
|
||||
}
|
||||
})
|
||||
|
||||
// 检测是否为HTML内容
|
||||
const isHtml = computed(() => {
|
||||
return /<[^>]*>/g.test(props.text)
|
||||
})
|
||||
|
||||
const escapedSearchText = computed(() =>
|
||||
String(props.searchText).replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&'),
|
||||
String(props.searchText).replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&')
|
||||
)
|
||||
|
||||
const pattern = computed(() => new RegExp(escapedSearchText.value, 'gi'))
|
||||
|
||||
const parts = computed(() => {
|
||||
if (!props.searchText || !props.text)
|
||||
return [{ text: props.text, highlighted: false }];
|
||||
if (!props.searchText || !props.text) return [{ text: props.text, highlighted: false }]
|
||||
|
||||
const result = [];
|
||||
let currentIndex = 0;
|
||||
const escapedSearchTextValue = escapedSearchText.value;
|
||||
const searchPattern = new RegExp(`(${escapedSearchTextValue})`, 'gi');
|
||||
const result = []
|
||||
let currentIndex = 0
|
||||
const escapedSearchTextValue = escapedSearchText.value
|
||||
const searchPattern = new RegExp(`(${escapedSearchTextValue})`, 'gi')
|
||||
|
||||
props.text.replace(searchPattern, (match, p1, offset) => {
|
||||
// 添加非高亮文本
|
||||
if (currentIndex < offset) {
|
||||
result.push({ text: props.text.slice(currentIndex, offset), highlighted: false });
|
||||
result.push({ text: props.text.slice(currentIndex, offset), highlighted: false })
|
||||
}
|
||||
// 添加高亮文本
|
||||
result.push({ text: p1, highlighted: true });
|
||||
result.push({ text: p1, highlighted: true })
|
||||
// 更新当前索引
|
||||
currentIndex = offset + p1.length;
|
||||
return p1; // 这个返回值不影响最终结果,只是replace方法的要求
|
||||
});
|
||||
currentIndex = offset + p1.length
|
||||
return p1 // 这个返回值不影响最终结果,只是replace方法的要求
|
||||
})
|
||||
|
||||
// 添加剩余的非高亮文本(如果有的话)
|
||||
if (currentIndex < props.text.length) {
|
||||
result.push({ text: props.text.slice(currentIndex), highlighted: false });
|
||||
result.push({ text: props.text.slice(currentIndex), highlighted: false })
|
||||
}
|
||||
|
||||
return result;
|
||||
});
|
||||
return result
|
||||
})
|
||||
|
||||
// 处理特殊字符的函数
|
||||
const processSpecialChars = (text) => {
|
||||
return (
|
||||
text
|
||||
// 处理换行符
|
||||
.replace(/\n/g, '<br>')
|
||||
// 处理制表符
|
||||
.replace(/\t/g, ' ')
|
||||
// 处理连续空格(保留第一个,其余转换为 )
|
||||
.replace(/ {2,}/g, (match) => {
|
||||
return ' '.repeat(match.length)
|
||||
})
|
||||
// 处理不可见字符(零宽空格等)
|
||||
.replace(/[\u200B-\u200D\uFEFF]/g, '')
|
||||
)
|
||||
}
|
||||
|
||||
// 处理HTML内容的高亮 - 使用字符串处理方法
|
||||
const highlightedHtml = computed(() => {
|
||||
if (!props.searchText || !props.text) {
|
||||
// 先处理特殊字符,再处理表情
|
||||
return textReplaceEmoji(processSpecialChars(props.text))
|
||||
}
|
||||
|
||||
// 对于富文本,使用一个更安全的方法
|
||||
// 将HTML内容按标签分割,只对文本部分进行高亮
|
||||
|
||||
// 分割HTML字符串,保护标签
|
||||
const parts = []
|
||||
let lastIndex = 0
|
||||
const tagRegex = /<[^>]*>/g
|
||||
let tagMatch
|
||||
|
||||
// 重置正则表达式的lastIndex
|
||||
tagRegex.lastIndex = 0
|
||||
|
||||
while ((tagMatch = tagRegex.exec(props.text)) !== null) {
|
||||
// 添加标签前的文本
|
||||
if (tagMatch.index > lastIndex) {
|
||||
const textBeforeTag = props.text.slice(lastIndex, tagMatch.index)
|
||||
if (textBeforeTag) {
|
||||
// 先处理特殊字符,再处理高亮
|
||||
const processedText = processSpecialChars(textBeforeTag)
|
||||
const searchPattern = new RegExp(`(${escapedSearchText.value})`, 'gi')
|
||||
const highlightedText = processedText.replace(
|
||||
searchPattern,
|
||||
`<span class="${props.highlightClass}">$1</span>`
|
||||
)
|
||||
parts.push(highlightedText)
|
||||
}
|
||||
}
|
||||
|
||||
// 添加标签本身(不处理)
|
||||
parts.push(tagMatch[0])
|
||||
lastIndex = tagMatch.index + tagMatch[0].length
|
||||
}
|
||||
|
||||
// 添加最后一个标签后的文本
|
||||
if (lastIndex < props.text.length) {
|
||||
const textAfterLastTag = props.text.slice(lastIndex)
|
||||
if (textAfterLastTag) {
|
||||
// 先处理特殊字符,再处理高亮
|
||||
const processedText = processSpecialChars(textAfterLastTag)
|
||||
const searchPattern = new RegExp(`(${escapedSearchText.value})`, 'gi')
|
||||
const highlightedText = processedText.replace(
|
||||
searchPattern,
|
||||
`<span class="${props.highlightClass}">$1</span>`
|
||||
)
|
||||
parts.push(highlightedText)
|
||||
}
|
||||
}
|
||||
|
||||
let html = parts.join('')
|
||||
// 最后处理表情
|
||||
return textReplaceEmoji(html)
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.highlight {
|
||||
color: #7a58de;
|
||||
}
|
||||
|
||||
.text-content {
|
||||
white-space: pre-wrap;
|
||||
word-break: break-word;
|
||||
:deep(.emoji) {
|
||||
vertical-align: text-bottom!important;
|
||||
margin: 0 5px !important;
|
||||
width: 22px !important;
|
||||
height: 22px !important;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
@ -137,7 +137,7 @@
|
||||
@click="toDialogueByMember(item)"
|
||||
:searchResultKey="'search_by_member_condition'"
|
||||
:searchItem="item"
|
||||
:searchText="state.searchText"
|
||||
:searchText="props?.searchRecordByConditionText"
|
||||
:searchRecordDetail="true"
|
||||
></searchItem>
|
||||
</div>
|
||||
@ -296,7 +296,7 @@ import fileType_EXCEL from '@/assets/image/excel-text.png'
|
||||
import fileType_WORD from '@/assets/image/word-text.png'
|
||||
import fileType_PDF from '@/assets/image/pdf-text.png'
|
||||
import fileType_Files from '@/assets/image/file-text.png'
|
||||
import { useDialogueStore } from '@/store'
|
||||
import { useDialogueStore, useUserStore } from '@/store'
|
||||
import { onMounted, reactive, computed, ref, nextTick, watch } from 'vue'
|
||||
import searchItem from './searchItem.vue'
|
||||
import { ServeFindTalkRecords } from '@/api/chat.js'
|
||||
@ -305,6 +305,7 @@ import { parseTime } from '@/utils/datetime'
|
||||
import { fileFormatSize, fileSuffix } from '@/utils/strings'
|
||||
import { NImage, NInfiniteScroll, NScrollbar, NIcon, NDatePicker } from 'naive-ui'
|
||||
import { MessageComponents } from '@/constant/message'
|
||||
import { checkFileCanPreview } from '@/utils/helper/form'
|
||||
|
||||
const emits = defineEmits([
|
||||
'clearSearchMemberByAlphabet',
|
||||
@ -314,10 +315,12 @@ const emits = defineEmits([
|
||||
])
|
||||
|
||||
const dialogueStore = useDialogueStore()
|
||||
const userStore = useUserStore()
|
||||
// 当前对话参数
|
||||
const dialogueParams = reactive({
|
||||
talk_type: computed(() => dialogueStore.talk.talk_type),
|
||||
receiver_id: computed(() => dialogueStore.talk.receiver_id)
|
||||
receiver_id: computed(() => dialogueStore.talk.receiver_id),
|
||||
uid: computed(() => userStore.uid)
|
||||
})
|
||||
|
||||
let nowDay = new Date().setHours(0, 0, 0, 0)
|
||||
@ -667,15 +670,23 @@ const queryAllSearch = () => {
|
||||
|
||||
//文件类型图标
|
||||
const fileTypeAvatar = (fileType) => {
|
||||
//PDF文件扩展名映射
|
||||
const PDF_EXTENSIONS = ['PDF', 'pdf']
|
||||
// Excel文件扩展名映射
|
||||
const EXCEL_EXTENSIONS = ['XLS', 'XLSX', 'CSV', 'xls', 'xlsx', 'csv']
|
||||
// Word文件扩展名映射
|
||||
const WORD_EXTENSIONS = ['DOC', 'DOCX', 'RTF', 'DOT', 'DOTX', 'doc', 'docx', 'rtf', 'dot', 'dotx']
|
||||
// PPT文件扩展名映射
|
||||
const PPT_EXTENSIONS = ['PPT', 'PPTX', 'PPS', 'PPSX', 'ppt', 'pptx', 'pps', 'ppsx']
|
||||
let file_type_avatar = fileType_Files
|
||||
if (fileType) {
|
||||
if (fileType === 'ppt' || fileType === 'pptx') {
|
||||
if (PPT_EXTENSIONS.includes(fileType)) {
|
||||
file_type_avatar = fileType_PPT
|
||||
} else if (fileType === 'pdf') {
|
||||
} else if (PDF_EXTENSIONS.includes(fileType)) {
|
||||
file_type_avatar = fileType_PDF
|
||||
} else if (fileType === 'doc' || fileType === 'docx') {
|
||||
} else if (WORD_EXTENSIONS.includes(fileType)) {
|
||||
file_type_avatar = fileType_WORD
|
||||
} else if (fileType === 'xls' || fileType === 'xlsx') {
|
||||
} else if (EXCEL_EXTENSIONS.includes(fileType)) {
|
||||
file_type_avatar = fileType_EXCEL
|
||||
} else {
|
||||
file_type_avatar = fileType_Files
|
||||
@ -693,11 +704,15 @@ const previewPDF = (item) => {
|
||||
// downloadAndOpenFile(item)
|
||||
// })
|
||||
// }
|
||||
if (checkFileCanPreview(item?.extra?.path || '')) {
|
||||
window.open(
|
||||
`${import.meta.env.VITE_PAGE_URL}/office?url=${item.extra.path}`,
|
||||
'_blank',
|
||||
'width=1200,height=900,left=200,top=200,toolbar=no,menubar=no,scrollbars=yes,resizable=yes,location=no,status=no'
|
||||
)
|
||||
} else {
|
||||
toDialogueByMember(item)
|
||||
}
|
||||
}
|
||||
|
||||
const downloadAndOpenFile = (item) => {
|
||||
@ -726,11 +741,16 @@ const downloadAndOpenFile = (item) => {
|
||||
//跳转到对应的记录位置
|
||||
const toDialogueByMember = async (msgInfo) => {
|
||||
console.error('====跳转到对应的记录位置====', msgInfo)
|
||||
let receiver_id_ = msgInfo.receiver_id
|
||||
//单聊如果receiver_id为当前用户id,则使用user_id
|
||||
if(msgInfo.talk_type === 1 && msgInfo.receiver_id === dialogueParams.uid){
|
||||
receiver_id_ = msgInfo.user_id
|
||||
}
|
||||
// 根据搜索结果, 指定用于查询指定消息上下文的sequence
|
||||
dialogueStore.specifiedMsg = encodeURIComponent(
|
||||
JSON.stringify({
|
||||
talk_type: msgInfo.talk_type,
|
||||
receiver_id: msgInfo.receiver_id,
|
||||
receiver_id: receiver_id_,
|
||||
msg_id: msgInfo.msg_id,
|
||||
cursor: msgInfo.sequence - 15 > 0 ? msgInfo.sequence - 15 : 0,
|
||||
direction: 'down',
|
||||
@ -953,7 +973,7 @@ body:deep(.round-3) {
|
||||
border-bottom: 1px solid #f8f8f8;
|
||||
|
||||
&:hover {
|
||||
background-color: rgba(70, 41, 157, 0.1)
|
||||
background-color: rgba(70, 41, 157, 0.1);
|
||||
}
|
||||
|
||||
.attachment-avatar {
|
||||
|
@ -69,9 +69,17 @@
|
||||
class="text-[12px] font-regular"
|
||||
:text="resultDetail"
|
||||
:searchText="props.searchText"
|
||||
v-if="props.searchItem?.msg_type !== 3 && props.searchItem?.msg_type !== 6"
|
||||
v-if="
|
||||
props.searchItem?.msg_type !== 3 &&
|
||||
props.searchItem?.msg_type !== 5 &&
|
||||
props.searchItem?.msg_type !== 6
|
||||
"
|
||||
/>
|
||||
<div class="message-component-wrapper" v-if="props.searchItem?.msg_type === 3" @click.stop>
|
||||
<div
|
||||
class="message-component-wrapper"
|
||||
v-if="props.searchItem?.msg_type === 3 || props.searchItem?.msg_type === 5"
|
||||
@click.stop
|
||||
>
|
||||
<component
|
||||
:is="MessageComponents[props.searchItem?.msg_type] || 'unknown-message'"
|
||||
:extra="resultDetail"
|
||||
@ -122,6 +130,7 @@ import { ref, watch, computed, onMounted, onUnmounted, reactive, defineProps } f
|
||||
import HighlightText from './highLightText.vue'
|
||||
import { beautifyTime } from '@/utils/datetime'
|
||||
import { ChatMsgTypeMapping, MessageComponents } from '@/constant/message'
|
||||
import { checkFileCanPreview } from '@/utils/helper/form'
|
||||
const props = defineProps({
|
||||
searchItem: Object | Number,
|
||||
searchResultKey: {
|
||||
@ -291,7 +300,9 @@ const resultDetail = computed(() => {
|
||||
result_detail =
|
||||
props.searchItem?.msg_type === 1
|
||||
? props.searchItem?.extra?.content
|
||||
: props.searchItem?.msg_type === 3 || props.searchItem?.msg_type === 6
|
||||
: props.searchItem?.msg_type === 3 ||
|
||||
props.searchItem?.msg_type === 5 ||
|
||||
props.searchItem?.msg_type === 6
|
||||
? props.searchItem?.extra
|
||||
: ChatMsgTypeMapping[props.searchItem?.msg_type]
|
||||
break
|
||||
@ -310,11 +321,16 @@ const previewPDF = (item) => {
|
||||
// downloadAndOpenFile(item)
|
||||
// })
|
||||
// }
|
||||
if (checkFileCanPreview(item || '')) {
|
||||
window.open(
|
||||
`${import.meta.env.VITE_PAGE_URL}/office?url=${item}`,
|
||||
'_blank',
|
||||
'width=1200,height=900,left=200,top=200,toolbar=no,menubar=no,scrollbars=yes,resizable=yes,location=no,status=no'
|
||||
)
|
||||
} else {
|
||||
//由于聊天记录本身有跳转到指定位置的逻辑,所以这里不需要再做跳转
|
||||
window['$message'].warning('暂不支持在线预览该类型文件')
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<style lang="scss" scoped>
|
||||
@ -377,7 +393,8 @@ const previewPDF = (item) => {
|
||||
}
|
||||
.file-message-wrapper {
|
||||
.condition-each-result-attachments {
|
||||
width: 289px;
|
||||
min-width: 289px;
|
||||
max-width: 660px;
|
||||
height: 62px;
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
@ -447,6 +464,7 @@ const previewPDF = (item) => {
|
||||
span {
|
||||
color: #191919;
|
||||
word-break: break-all;
|
||||
max-width: 660px;
|
||||
}
|
||||
.searchRecordDetail-fastLocal {
|
||||
display: none;
|
||||
|
@ -50,13 +50,12 @@ const dropdown=ref({
|
||||
options:[] as any,
|
||||
item:{} as ITalkRecord,
|
||||
})
|
||||
const onConvertText =async (data: ITalkRecord) => {
|
||||
const onConvertText = async (data: ITalkRecord) => {
|
||||
data.is_convert_text = 1
|
||||
const res = await voiceToText({msgId:data.msg_id,voiceUrl:data.extra.url})
|
||||
if(res.code == 200){
|
||||
const res = await voiceToText({ msgId: data.msg_id, voiceUrl: data.extra.url })
|
||||
if (res.code == 200) {
|
||||
data.extra.content = res.data.convText
|
||||
|
||||
}
|
||||
}else data.is_convert_text = 0
|
||||
}
|
||||
const onloseConvertText=(data: ITalkRecord)=>{
|
||||
data.is_convert_text = 0
|
||||
|
@ -1,7 +1,14 @@
|
||||
<script lang="ts" setup>
|
||||
import { ref, reactive } from 'vue'
|
||||
import { ref, reactive, computed } from 'vue'
|
||||
import { PlayOne, PauseOne } from '@icon-park/vue-next'
|
||||
import { ITalkRecordExtraAudio, ITalkRecord } from '@/types/chat'
|
||||
import { onClickOutside } from '@vueuse/core'
|
||||
import { useTemplateRef } from 'vue'
|
||||
import yuyin from "@/assets/image/yuyin.png"
|
||||
import yuyin1 from "@/assets/image/yuyin1.png"
|
||||
import bofang from "@/assets/image/bofang.png"
|
||||
import bofang1 from "@/assets/image/bofang1.png"
|
||||
|
||||
|
||||
const props = defineProps<{
|
||||
extra: ITalkRecordExtraAudio
|
||||
@ -22,16 +29,23 @@ const state = reactive({
|
||||
showText: false
|
||||
})
|
||||
|
||||
const target = useTemplateRef<HTMLElement>('target')
|
||||
const onPlay = () => {
|
||||
if (state.isAudioPlay) {
|
||||
audioRef.value.pause()
|
||||
state.isAudioPlay = false
|
||||
} else {
|
||||
audioRef.value.play()
|
||||
state.isAudioPlay = true
|
||||
onClickOutside(target, () => {
|
||||
console.log('点击了外部区域')
|
||||
audioRef.value.pause() // 关闭当前语音播放
|
||||
state.isAudioPlay = false
|
||||
})
|
||||
}
|
||||
|
||||
state.isAudioPlay = !state.isAudioPlay
|
||||
}
|
||||
|
||||
|
||||
const onPlayEnd = () => {
|
||||
state.isAudioPlay = false
|
||||
state.progress = 0
|
||||
@ -70,10 +84,18 @@ const formatTime = (value: number = 0) => {
|
||||
|
||||
return `${Math.floor(value)}"`
|
||||
}
|
||||
const right = computed(() => props.data.float === 'right')
|
||||
</script>
|
||||
<template>
|
||||
<div class="pointer w-200px bg-#F3F4FD rounded-10px px-11px">
|
||||
<div class="im-message-audio h-44px">
|
||||
<div
|
||||
class="pointer w-200px bg-#F3F4FD rounded-10px px-11px"
|
||||
:class="{
|
||||
'!bg-[var(--im-message-right-bg-color)] !text-[var(--im-message-right-text-color)]': right
|
||||
}"
|
||||
@click.stop="onPlay"
|
||||
ref="target"
|
||||
>
|
||||
<div class="im-message-audio h-44px" :class="{ right }">
|
||||
<aTrumpet :isPlay="false" color="black" :size="30"></aTrumpet>
|
||||
<audio
|
||||
ref="audioRef"
|
||||
@ -87,15 +109,16 @@ const formatTime = (value: number = 0) => {
|
||||
/>
|
||||
|
||||
<div class="play">
|
||||
<div class="btn pointer" @click.stop="onPlay">
|
||||
<div class="btn pointer">
|
||||
<!-- <n-icon :size="18" :component="state.isAudioPlay ? PauseOne : PlayOne" /> -->
|
||||
<img
|
||||
v-if="!state.isAudioPlay"
|
||||
src="@/assets/image/yuyin.png"
|
||||
:src="right ? yuyin1 : yuyin"
|
||||
class="w-[16px] h-[16px]"
|
||||
alt=""
|
||||
:style="{ transform: right && 'rotate(180deg)' }"
|
||||
/>
|
||||
<img v-else src="@/assets/image/bofang.png" class="w-[16px] h-[16px]" alt="" />
|
||||
<img v-else :src="right ? bofang1 : bofang" class="w-[16px] h-[16px]" alt="" />
|
||||
</div>
|
||||
</div>
|
||||
<!-- <div class="desc">
|
||||
@ -129,6 +152,9 @@ const formatTime = (value: number = 0) => {
|
||||
</div>
|
||||
</template>
|
||||
<style lang="less" scoped>
|
||||
.right {
|
||||
flex-direction: row-reverse !important;
|
||||
}
|
||||
.im-message-audio {
|
||||
--audio-bg-color: #f5f5f5;
|
||||
--audio-btn-bg-color: #ffffff;
|
||||
|
@ -17,7 +17,7 @@ let textContent = props.extra?.content || ''
|
||||
textContent = textReplaceLink(textContent)
|
||||
|
||||
if (props.data.talk_type == 2) {
|
||||
textContent = textReplaceMention(textContent, float==='right'?'#462AA0':'#fff',float==='right'?'#EEE9F9':'#462AA0')
|
||||
textContent = textReplaceMention(textContent, float==='right'?'':'black',float==='right'?'':'')
|
||||
}
|
||||
|
||||
textContent = textReplaceEmoji(textContent)
|
||||
|
@ -170,7 +170,7 @@ if(newVal){
|
||||
<div class="w-260px h-517px rounded-4px border-1px border-solid border-#E5E5E5 px-12px">
|
||||
<div class="border-b-2px border-b-solid border-b-#FBFBFB h-35px flex items-center justify-end">
|
||||
<n-button text color="#46299D" class="text-14px" @click="changeSelectType">
|
||||
{{ selectType === 1 ? '多选' : '单选' }}
|
||||
{{ selectType === 1 ? '多选' : '取消多选' }}
|
||||
</n-button>
|
||||
</div>
|
||||
<div>
|
||||
@ -190,9 +190,10 @@ if(newVal){
|
||||
:customStyle="{width:'42px',height:'42px'}"></avatarModule>
|
||||
<!-- <n-image class="w-42px h-42px rounded-full" :src="item.avatar" /> -->
|
||||
</div>
|
||||
<div class="flex items-center">
|
||||
<div class="flex items-center overflow-hidden flex">
|
||||
<span class="text-ellipsis">{{ item.name }}</span>
|
||||
<span v-if="item.type == 2" class="badge group ml-2">群</span>
|
||||
<!-- <span v-if="item.type == 2" class="badge group ml-2">群</span> -->
|
||||
<span v-if="item.talk_type === 2" class="flex-shrink-0">{{ `(${item.group_member_num})` }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
@ -217,9 +218,10 @@ if(newVal){
|
||||
:groupType="item.group_type"
|
||||
:customStyle="{width:'42px',height:'42px'}"></avatarModule>
|
||||
</div>
|
||||
<div class="flex items-center">
|
||||
<div class="flex items-center overflow-hidden flex">
|
||||
<span class="text-ellipsis">{{ item.name }}</span>
|
||||
<span v-if="item.type == 2" class="badge group ml-2">群</span>
|
||||
<!-- <span v-if="item.type == 2" class="badge group ml-2">群</span> -->
|
||||
<span v-if="item.talk_type === 2" class="flex-shrink-0">{{ `(${item.group_member_num})` }}</span>
|
||||
</div>
|
||||
<n-button class="ml-auto" text color="#C7C7C9" @click="onRemoveContact(item)">
|
||||
<n-icon :component="CloseCircle" size="18" />
|
||||
|
@ -259,10 +259,16 @@ class Talk extends Base {
|
||||
updated_at: parseTime(new Date())
|
||||
})
|
||||
|
||||
if (this.talk_type == 1 && this.getAccountId() !== this.sender_id) {
|
||||
if (this.getAccountId() !== this.sender_id) {
|
||||
ServeClearTalkUnreadNum({
|
||||
talk_type: 1,
|
||||
receiver_id: this.sender_id
|
||||
talk_type: this.talk_type,
|
||||
receiver_id: this.talk_type == 1 ? this.sender_id : this.receiver_id
|
||||
}).then(() => {
|
||||
useTalkStore().updateItem({
|
||||
index_name: item.index_name,
|
||||
unread_num: 0,
|
||||
atsign_num: 0
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
@ -274,7 +280,8 @@ class Talk extends Base {
|
||||
useTalkStore().updateMessage({
|
||||
index_name: this.getIndexName(),
|
||||
msg_text: this.getTalkText(),
|
||||
updated_at: parseTime(new Date())
|
||||
updated_at: parseTime(new Date()),
|
||||
isCurrSender: this.isCurrSender()
|
||||
})
|
||||
//收到新消息时,同时判断是否有人@我
|
||||
if (this.resource.msg_type === 1 && this.resource?.extra?.mentions?.length > 0) {
|
||||
|
@ -77,11 +77,11 @@ export function useSessionMenu() {
|
||||
// key: 'delete_contact'
|
||||
// })
|
||||
} else {
|
||||
options.push({
|
||||
// options.push({
|
||||
|
||||
label: '退出群聊',
|
||||
key: 'signout_group'
|
||||
})
|
||||
// label: '退出群聊',
|
||||
// key: 'signout_group'
|
||||
// })
|
||||
}
|
||||
|
||||
dropdown.options = [...options]
|
||||
|
@ -62,10 +62,10 @@ const router = createRouter({
|
||||
// 设置中间件,权限验证
|
||||
router.beforeEach((to) => {
|
||||
if (to.meta?.auth && !isLoggedIn()) {
|
||||
return {
|
||||
path: '/auth/login',
|
||||
query: { redirect: to.fullPath }
|
||||
}
|
||||
// return {
|
||||
// path: '/auth/login',
|
||||
// query: { redirect: to.fullPath }
|
||||
// }
|
||||
}
|
||||
})
|
||||
|
||||
|
@ -383,6 +383,9 @@ export const useDialogueStore = defineStore('dialogue', {
|
||||
|
||||
// 从全局列表中移除
|
||||
this.globalUploadList.splice(taskIndex, 1)
|
||||
// 移除消息记录
|
||||
|
||||
this.batchDelDialogueRecord([uploadId])
|
||||
}
|
||||
},
|
||||
|
||||
|
@ -103,7 +103,10 @@ export const useTalkStore = defineStore('talk', {
|
||||
const item = this.items.find((item) => item.index_name === params.index_name)
|
||||
|
||||
if (item) {
|
||||
if (!params?.isCurrSender) {
|
||||
//如果消息不是自己发的,才更新未读数量
|
||||
item.unread_num++
|
||||
}
|
||||
item.msg_text = params.msg_text
|
||||
item.updated_at = params.updated_at
|
||||
|
||||
|
@ -150,7 +150,7 @@ export const useUploadsStore = defineStore('uploads', {
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("初始化分片上传失败:", error);
|
||||
message.error("初始化上传失败,请重试")
|
||||
message.error("上传失败,请重试")
|
||||
this.handleUploadError(upload_id, clientUploadId)
|
||||
}
|
||||
},
|
||||
|
@ -18,7 +18,7 @@ export function isLoggedIn() {
|
||||
*/
|
||||
export function getAccessToken() {
|
||||
// return storage.get(AccessToken) || ''
|
||||
return JSON.parse(localStorage.getItem('token'))||'46d71a72d8d845ad7ed23eba9bdde260e635407190c2ce1bf7fd22088e41682ea07773ec65cae8946d2003f264d55961f96e0fc5da10eb96d3a348c1664e9644ce2108c311309f398ae8ea1b8200bfd490e5cb6e8c52c9e5d493cbabb163368f8351420451a631dbfa749829ee4cda49b77b5ed2d3dced5d0f2b7dd9ee76ba5465c84a17c23af040cd92b6b2a4ea48befbb5c729dcdad0a9c9668befe84074cc24f78899c1d947f8e7f94c7eda5325b8ed698df729e76febb98549ef3482ae942fb4f4a1c92d21836fa784728f0c5483aab2760a991b6b36e6b10c84f840a6433a6ecc31dee36e8f1c6158818bc89d220365eb2ca93ef31880576e2aa3ca8c45a705b447d40e300a54644829e2da528ea463bd2581a396336ed74880960d35716f5f7594e5b8cbb597027c6133b97b12df23427ca728fd2625977a0658ab470d'
|
||||
return JSON.parse(localStorage.getItem('token'))||''
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1,4 +1,5 @@
|
||||
import { createApp } from 'vue'
|
||||
import { toClipboard } from '@soerenmartius/vue3-clipboard'
|
||||
|
||||
/**
|
||||
* 防抖函数
|
||||
@ -51,12 +52,12 @@ export function throttle(fn, delay, call = function () {}) {
|
||||
* @param {String} text 复制内容
|
||||
* @param {Function} callback 复制成功回调方法
|
||||
*/
|
||||
export function clipboard(text, callback) {
|
||||
export async function clipboard(text, callback) {
|
||||
// 在wujie环境下使用主应用的clipboard
|
||||
const clipboardObj = window.__POWERED_BY_WUJIE__
|
||||
? window.parent.navigator.clipboard
|
||||
: navigator.clipboard
|
||||
|
||||
try {
|
||||
clipboardObj
|
||||
.writeText(text)
|
||||
.then(() => {
|
||||
@ -65,6 +66,11 @@ export function clipboard(text, callback) {
|
||||
.catch(() => {
|
||||
alert('Oops, unable to copy')
|
||||
})
|
||||
} catch (e) {
|
||||
console.error(e)
|
||||
await toClipboard(text)
|
||||
callback && callback()
|
||||
}
|
||||
}
|
||||
|
||||
export async function clipboardImage(src, callback) {
|
||||
|
@ -42,7 +42,7 @@ service.interceptors.response.use(
|
||||
if (response && response.data.status === 409) {
|
||||
// 账户另一处登录 此处踢下线
|
||||
message.error('您的账号已在其他设备登录')
|
||||
$router.push("/login");
|
||||
// $router.push("/login");
|
||||
return;
|
||||
}
|
||||
if (response && response.data.code === 401) {
|
||||
@ -88,7 +88,7 @@ const getRefreshToken = async (response) => {
|
||||
return Promise.resolve(service(response.config));
|
||||
} else {
|
||||
// 跳转登录页
|
||||
$router.push("/login");
|
||||
// $router.push("/login");
|
||||
res.message = res.message || res.msg;
|
||||
return Promise.reject(res);
|
||||
}
|
||||
@ -100,7 +100,7 @@ const getRefreshToken = async (response) => {
|
||||
refreshSubscribers = [];
|
||||
}
|
||||
} else {
|
||||
$router.push("/login");
|
||||
// $router.push("/login");
|
||||
return Promise.reject(response);
|
||||
}
|
||||
} else {
|
||||
|
@ -345,3 +345,29 @@ export const formatNumberWithCommas = (num) => {
|
||||
}
|
||||
return num.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
|
||||
};
|
||||
// 判断文件是否可以预览
|
||||
export const checkFileCanPreview = (path) => {
|
||||
if (!path) {
|
||||
return false
|
||||
}
|
||||
//PDF文件扩展名映射
|
||||
const PDF_EXTENSIONS = ['PDF', 'pdf']
|
||||
// Excel文件扩展名映射
|
||||
const EXCEL_EXTENSIONS = ['XLS', 'XLSX', 'CSV', 'xls', 'xlsx', 'csv']
|
||||
// Word文件扩展名映射
|
||||
const WORD_EXTENSIONS = ['DOC', 'DOCX', 'RTF', 'DOT', 'DOTX', 'doc', 'docx', 'rtf', 'dot', 'dotx']
|
||||
// PPT文件扩展名映射
|
||||
const PPT_EXTENSIONS = ['PPT', 'PPTX', 'PPS', 'PPSX', 'ppt', 'pptx', 'pps', 'ppsx']
|
||||
|
||||
// 获取文件扩展名
|
||||
function getFileExtension(filepath) {
|
||||
const parts = filepath?.split('.')
|
||||
return parts?.length > 1 ? parts?.pop()?.toUpperCase() : ''
|
||||
}
|
||||
|
||||
const extension = getFileExtension(path)
|
||||
return PDF_EXTENSIONS.includes(extension) ||
|
||||
EXCEL_EXTENSIONS.includes(extension) ||
|
||||
WORD_EXTENSIONS.includes(extension) ||
|
||||
PPT_EXTENSIONS.includes(extension)
|
||||
}
|
||||
|
@ -48,7 +48,9 @@ request.interceptors.request.use((config) => {
|
||||
if (token) {
|
||||
config.headers['Authorization'] = `Bearer ${token}`
|
||||
}
|
||||
|
||||
if(config.url.indexOf('api/v1/upload/multipart') > -1){
|
||||
config.timeout = 600000
|
||||
}
|
||||
return config
|
||||
}, errorHandler)
|
||||
|
||||
|
@ -11,7 +11,7 @@ import {
|
||||
nextTick
|
||||
} from 'vue'
|
||||
import { onBeforeRouteUpdate } from 'vue-router'
|
||||
import { useDialogueStore, useTalkStore } from '@/store'
|
||||
import { useDialogueStore, useTalkStore, useUserStore } from '@/store'
|
||||
import {
|
||||
NDropdown,
|
||||
NIcon,
|
||||
@ -62,6 +62,10 @@ const {
|
||||
|
||||
const dialogueStore = useDialogueStore()
|
||||
const talkStore = useTalkStore()
|
||||
const userStore = useUserStore()
|
||||
const userParams = reactive({
|
||||
uid: computed(() => userStore.uid)
|
||||
})
|
||||
const isShowGroup = ref(false)
|
||||
const searchKeyword = ref('')
|
||||
const topItems = computed((): ISession[] => talkStore.topItems)
|
||||
@ -602,6 +606,11 @@ const onTabTalk = (item: ISession, follow = false) => {
|
||||
console.log('item.index_name === indexName.value', item.index_name === indexName.value)
|
||||
if (item.index_name === indexName.value) return
|
||||
|
||||
if (dialogueStore.isOpenMultiSelect) {
|
||||
//切换会话时,如果多选模式开启,则关闭多选模式
|
||||
dialogueStore.closeMultiSelect()
|
||||
}
|
||||
|
||||
searchKeyword.value = ''
|
||||
|
||||
dialogueStore.isManualSwitch = true
|
||||
@ -968,11 +977,16 @@ const handleClickSearchItem = (searchText, searchResultKey, talk_type, receiver_
|
||||
const handleClickSearchResultItem = (searchText, searchResultKey, talk_type, receiver_id, res) => {
|
||||
const result = JSON.parse(decodeURIComponent(res))
|
||||
console.error(result, 'result')
|
||||
let receiver_id_ = receiver_id
|
||||
//单聊如果receiver_id为当前用户id,则使用user_id
|
||||
if(talk_type === 1 && receiver_id === userParams.uid){
|
||||
receiver_id_ = result.user_id
|
||||
}
|
||||
// 根据搜索结果, 指定用于查询指定消息上下文的sequence
|
||||
dialogueStore.specifiedMsg = encodeURIComponent(
|
||||
JSON.stringify({
|
||||
talk_type,
|
||||
receiver_id,
|
||||
receiver_id: receiver_id_,
|
||||
msg_id: result.msg_id,
|
||||
cursor: result.sequence - 15 > 0 ? result.sequence - 15 : 0,
|
||||
direction: 'down',
|
||||
@ -981,7 +995,7 @@ const handleClickSearchResultItem = (searchText, searchResultKey, talk_type, rec
|
||||
})
|
||||
)
|
||||
console.error(dialogueStore.specifiedMsg, 'dialogueStore.specifiedMsg')
|
||||
talkStore.toTalk(talk_type, receiver_id, router)
|
||||
talkStore.toTalk(talk_type, receiver_id_, router)
|
||||
state.isShowSearchRecordModal = false
|
||||
state.searchRecordText = ''
|
||||
searchKeyword.value = ''
|
||||
|
@ -325,7 +325,7 @@ const onConvertText = async (data: ITalkRecord) => {
|
||||
const res = await voiceToText({ msgId: data.msg_id, voiceUrl: data.extra.url })
|
||||
if (res.code == 200) {
|
||||
data.extra.content = res.data.convText
|
||||
}
|
||||
} else data.is_convert_text = 0
|
||||
}
|
||||
const onloseConvertText = (data: ITalkRecord) => {
|
||||
data.is_convert_text = 0
|
||||
@ -354,6 +354,10 @@ const onRowClick = (item: ITalkRecord) => {
|
||||
if (!isOneMonthBefore(item.created_at.split(' ')[0])) {
|
||||
return useMessage.info('只支持转发近一个月内的消息')
|
||||
}
|
||||
// 语音消息和群公告不支持转发
|
||||
if ([4, 13].includes(item.msg_type)) {
|
||||
return useMessage.info('语音消息和群公告不支持转发')
|
||||
}
|
||||
console.log('item.msg_type', item.msg_type)
|
||||
if (ForwardableMessageType.includes(item.msg_type)) {
|
||||
item.isCheck = !item.isCheck
|
||||
@ -435,12 +439,15 @@ const retry = (item: any) => {
|
||||
confirmBox({
|
||||
content: '确定重发吗'
|
||||
}).then(() => {
|
||||
item.extra.percentage = 0
|
||||
uploadsStore.retryCommonUpload(item.extra.upload_id)
|
||||
})
|
||||
}
|
||||
|
||||
const onContextMenuAvatar = (e: any, item: any) => {
|
||||
e.preventDefault()
|
||||
// 单聊不需要@
|
||||
if (+props.talk_type === 1) return
|
||||
if (item.float !== 'right') {
|
||||
bus.emit(EditorConst.Mention, {
|
||||
id: item.user_id,
|
||||
@ -840,7 +847,7 @@ const onCustomSkipBottomEvent = () => {
|
||||
<!-- 近一个月外的消息多选框禁用 {{ item }} -->
|
||||
<n-checkbox
|
||||
size="small"
|
||||
:disabled="!isOneMonthBefore(item.created_at.split(' ')[0])"
|
||||
:disabled="!isOneMonthBefore(item.created_at.split(' ')[0]) || [4, 13].includes(item.msg_type)"
|
||||
:checked="item.isCheck"
|
||||
@update:checked="item.isCheck = !item.isCheck"
|
||||
/>
|
||||
@ -940,7 +947,13 @@ const onCustomSkipBottomEvent = () => {
|
||||
</div>
|
||||
|
||||
<!-- 已读回执 -->
|
||||
<div class="talk_read_num" v-if="item.user_id === props.uid">
|
||||
<!-- item.user_id:发送这条消息的人id -->
|
||||
<!-- props.uid:当前登录人id -->
|
||||
<!-- props.receiver_id:当前消息要发送的人id -->
|
||||
<div
|
||||
class="talk_read_num"
|
||||
v-if="item.user_id === props.uid && props.uid !== props.receiver_id"
|
||||
>
|
||||
<span v-if="props.talk_type === 1">{{
|
||||
item.read_total_num > 0 ? '已读' : '未读'
|
||||
}}</span>
|
||||
|
@ -66,7 +66,7 @@ const onSendMessage = (data = {}, callBack: any) => {
|
||||
if (code == 200) {
|
||||
callBack(true)
|
||||
} else {
|
||||
window['$message'].warning(message || msg)
|
||||
// window['$message'].warning(message || msg)
|
||||
}
|
||||
})
|
||||
.catch(() => {
|
||||
@ -75,7 +75,7 @@ const onSendMessage = (data = {}, callBack: any) => {
|
||||
}
|
||||
|
||||
// 发送文本消息
|
||||
const onSendTextEvent = throttle((value: any) => {
|
||||
const onSendTextEvent = (value: any) => {
|
||||
let { data, callBack } = value
|
||||
|
||||
let message = {
|
||||
@ -93,7 +93,7 @@ const onSendTextEvent = throttle((value: any) => {
|
||||
|
||||
callBack(true)
|
||||
})
|
||||
}, 1000)
|
||||
}
|
||||
|
||||
// 发送图片消息
|
||||
const onSendImageEvent = ({ data, callBack }) => {
|
||||
@ -164,9 +164,18 @@ const onSendVideoEvent = async ({ data }) => {
|
||||
const onSendCodeEvent = ({ data, callBack }) => {
|
||||
onSendMessage({ type: 'code', code: data.code, lang: data.lang }, callBack)
|
||||
}
|
||||
|
||||
// 发送文件消息
|
||||
const onSendFileEvent = ({ data }) => {
|
||||
const fn = (e) => {
|
||||
const confirmationMessage = '文件上传中请勿离开';
|
||||
e.returnValue = confirmationMessage; // 兼容旧版本浏览器
|
||||
return confirmationMessage; // 现代浏览器
|
||||
}
|
||||
window.addEventListener('beforeunload', fn);
|
||||
|
||||
if (data.size / (1024 * 1024) > 100) {
|
||||
return window['$message'].warning('只能上传100MB以内的文件!')
|
||||
}
|
||||
const clientUploadId = `file-${Date.now()}-${Math.floor(Math.random() * 1000)}`
|
||||
const tempMessage = {
|
||||
msg_id: clientUploadId,
|
||||
@ -205,6 +214,7 @@ const onSendFileEvent = ({ data }) => {
|
||||
async () => {
|
||||
// 上传完成后,上传任务已经被removeUploadTask方法移除
|
||||
// 不需要再次从records中删除
|
||||
window.removeEventListener('beforeunload', fn);
|
||||
}
|
||||
)
|
||||
}
|
||||
@ -297,7 +307,7 @@ onMounted(() => {
|
||||
<MultiSelectFooter v-if="dialogueStore.isOpenMultiSelect" />
|
||||
<!-- <Editor v-else @editor-event="onEditorEvent" :vote="talk_type == 2" :members="members" /> -->
|
||||
<!-- <CustomEditor v-else @editor-event="onEditorEvent" :vote="talk_type == 2" :members="members" /> -->
|
||||
<TiptapEditor v-else @editor-event="onEditorEvent" :vote="talk_type == 2" :members="members" />
|
||||
<TiptapEditor v-else @editor-event="onEditorEvent" :uid="uid" :vote="talk_type == 2" :members="members" />
|
||||
</footer>
|
||||
|
||||
<HistoryRecord
|
||||
|
@ -71,11 +71,14 @@ export function useMenu() {
|
||||
dropdown.options.push({ label: '复制', key: 'copy' })
|
||||
}
|
||||
|
||||
if (isOneMonthBefore(new Date(item.created_at.split(' ')[0]))) {
|
||||
// 根据时间判断只有近一个月内的消息才能支持多选
|
||||
if (isOneMonthBefore(new Date(item.created_at.split(' ')[0])) && ![4,13].includes(item.msg_type)) {
|
||||
// 根据时间判断只有近一个月内的消息才能支持多选 // 语音消息和群公告不支持转发
|
||||
dropdown.options.push({ label: '多选', key: 'multiSelect' })
|
||||
}
|
||||
if (isOneMonthBefore(new Date(item.created_at.split(' ')[0]))) {
|
||||
// 根据时间判断只有近一个月内的消息才能支持引用
|
||||
dropdown.options.push({ label: '引用', key: 'quote' })
|
||||
}
|
||||
if (canAddRevokeOption(uid, item, (dialogueStore.groupInfo as any).is_manager)) {
|
||||
dropdown.options.push({ label: '撤回', key: 'revoke' });
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user