Compare commits
4 Commits
928c4f91f9
...
5b4ee3c677
Author | SHA1 | Date | |
---|---|---|---|
5b4ee3c677 | |||
|
ef0eb903a7 | ||
|
f511244d59 | ||
|
a5a70391a4 |
1
env/.env.test
vendored
1
env/.env.test
vendored
@ -8,4 +8,5 @@ VUE_APP_PREVIEW=false
|
|||||||
VITE_BASE_API=http://114.218.158.24:8503
|
VITE_BASE_API=http://114.218.158.24:8503
|
||||||
VITE_SOCKET_API=ws://114.218.158.24:8504
|
VITE_SOCKET_API=ws://114.218.158.24:8504
|
||||||
VITE_EPR_BASEURL=http://114.218.158.24:9020
|
VITE_EPR_BASEURL=http://114.218.158.24:9020
|
||||||
|
VITE_PAGE_URL=http://172.16.100.93:9032
|
||||||
VUE_APP_WEBSITE_NAME=""
|
VUE_APP_WEBSITE_NAME=""
|
@ -363,22 +363,9 @@ async function onUploadFile(e: any) {
|
|||||||
console.log("文件类型"+file.type)
|
console.log("文件类型"+file.type)
|
||||||
if (file.type.indexOf('image/') === 0) {
|
if (file.type.indexOf('image/') === 0) {
|
||||||
console.log("进入图片")
|
console.log("进入图片")
|
||||||
// 处理图片文件
|
// 处理图片文件 - 立即显示临时消息,然后上传
|
||||||
const quill = getQuill()
|
let fn = emitCall('image_event', file, () => {})
|
||||||
let index = getQuillSelectionIndex()
|
emit('editor-event', fn)
|
||||||
|
|
||||||
// 删除编辑器中多余的换行符
|
|
||||||
if (index == 1 && quill.getLength() == 1 && quill.getText(0, 1) == '\n') {
|
|
||||||
quill.deleteText(0, 1)
|
|
||||||
index = 0
|
|
||||||
}
|
|
||||||
|
|
||||||
// 上传图片并插入到编辑器中
|
|
||||||
let src = await onUploadImage(file)
|
|
||||||
if (src) {
|
|
||||||
quill.insertEmbed(index, 'image', src)
|
|
||||||
quill.setSelection(index + 1)
|
|
||||||
}
|
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -437,8 +424,7 @@ function onClipboardMatcher(node: any, Delta) {
|
|||||||
function onSendMessage() {
|
function onSendMessage() {
|
||||||
var delta = getQuill().getContents()
|
var delta = getQuill().getContents()
|
||||||
let data = deltaToMessage(delta) // 转换Delta为消息格式
|
let data = deltaToMessage(delta) // 转换Delta为消息格式
|
||||||
|
if (data.items.length === 0||!data.items[0].content.trim()) {
|
||||||
if (data.items.length === 0) {
|
|
||||||
return // 没有内容不发送
|
return // 没有内容不发送
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -49,7 +49,7 @@ const PPT_EXTENSIONS = ['PPT', 'PPTX', 'PPS', 'PPSX']
|
|||||||
|
|
||||||
// 获取文件类型信息
|
// 获取文件类型信息
|
||||||
const fileInfo = computed(() => {
|
const fileInfo = computed(() => {
|
||||||
const extension = getFileExtension(props.extra.name)
|
const extension = getFileExtension(props.extra.path)
|
||||||
if (EXCEL_EXTENSIONS.includes(extension)) {
|
if (EXCEL_EXTENSIONS.includes(extension)) {
|
||||||
return fileTypes.EXCEL
|
return fileTypes.EXCEL
|
||||||
}
|
}
|
||||||
@ -63,8 +63,8 @@ const fileInfo = computed(() => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
// 获取文件扩展名
|
// 获取文件扩展名
|
||||||
function getFileExtension(filename) {
|
function getFileExtension(filepath) {
|
||||||
const parts = filename.split('.')
|
const parts = filepath.split('.')
|
||||||
return parts.length > 1 ? parts.pop().toUpperCase() : ''
|
return parts.length > 1 ? parts.pop().toUpperCase() : ''
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -88,7 +88,7 @@ const strokeDashoffset = computed(() =>
|
|||||||
const handleClick = () => {
|
const handleClick = () => {
|
||||||
if(!props.extra.is_uploading){
|
if(!props.extra.is_uploading){
|
||||||
window.open(
|
window.open(
|
||||||
`${window.location.origin}/office?url=${props.extra.path}`,
|
`${import.meta.env.VITE_PAGE_URL}/office?url=${props.extra.path}`,
|
||||||
'_blank',
|
'_blank',
|
||||||
'width=1200,height=900,left=200,top=200,toolbar=no,menubar=no,scrollbars=yes,resizable=yes,location=no,status=no'
|
'width=1200,height=900,left=200,top=200,toolbar=no,menubar=no,scrollbars=yes,resizable=yes,location=no,status=no'
|
||||||
);
|
);
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { NImage } from 'naive-ui'
|
import { NImage, NSpin } from 'naive-ui'
|
||||||
import { getImageInfo } from '@/utils/functions'
|
import { getImageInfo } from '@/utils/functions'
|
||||||
import { ITalkRecordExtraImage, ITalkRecord } from '@/types/chat'
|
import { ITalkRecordExtraImage, ITalkRecord } from '@/types/chat'
|
||||||
|
|
||||||
defineProps<{
|
const props = defineProps<{
|
||||||
extra: ITalkRecordExtraImage
|
extra: ITalkRecordExtraImage
|
||||||
data: ITalkRecord
|
data: ITalkRecord
|
||||||
maxWidth?: Boolean
|
maxWidth?: Boolean
|
||||||
@ -35,7 +35,13 @@ const img = (src: string, width = 200) => {
|
|||||||
:class="{ left: data.float === 'left' }"
|
:class="{ left: data.float === 'left' }"
|
||||||
:style="img(extra.url, 350)"
|
:style="img(extra.url, 350)"
|
||||||
>
|
>
|
||||||
<n-image class="h-149px" :src="extra.url" />
|
<div class="image-container">
|
||||||
|
<n-image class="h-149px" :src="extra.url" />
|
||||||
|
<!-- 上传中的loading蒙版 -->
|
||||||
|
<div v-if="props.extra.is_uploading" class="loading-overlay">
|
||||||
|
<n-spin size="large" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</section>
|
</section>
|
||||||
</template>
|
</template>
|
||||||
<style lang="less" scoped>
|
<style lang="less" scoped>
|
||||||
@ -44,11 +50,32 @@ const img = (src: string, width = 200) => {
|
|||||||
padding: 5px;
|
padding: 5px;
|
||||||
border-radius: 5px;
|
border-radius: 5px;
|
||||||
background: var(--im-message-left-bg-color);
|
background: var(--im-message-left-bg-color);
|
||||||
height:149px
|
height:149px;
|
||||||
|
|
||||||
&.left {
|
&.left {
|
||||||
background: var(--im-message-right-bg-color);
|
background: var(--im-message-right-bg-color);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.image-container {
|
||||||
|
position: relative;
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.loading-overlay {
|
||||||
|
position: absolute;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
right: 0;
|
||||||
|
bottom: 0;
|
||||||
|
background: rgba(0, 0, 0, 0.5);
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
border-radius: 5px;
|
||||||
|
z-index: 1;
|
||||||
|
}
|
||||||
|
|
||||||
:deep(.n-image img) {
|
:deep(.n-image img) {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
|
@ -17,7 +17,7 @@ let textContent = props.extra?.content || ''
|
|||||||
textContent = textReplaceLink(textContent)
|
textContent = textReplaceLink(textContent)
|
||||||
|
|
||||||
if (props.data.talk_type == 2) {
|
if (props.data.talk_type == 2) {
|
||||||
textContent = textReplaceMention(textContent, '#462AA0')
|
textContent = textReplaceMention(textContent, float==='right'?'#fff':'#462AA0')
|
||||||
}
|
}
|
||||||
|
|
||||||
textContent = textReplaceEmoji(textContent)
|
textContent = textReplaceEmoji(textContent)
|
||||||
|
@ -21,7 +21,7 @@ export function useFriendsMenu() {
|
|||||||
dropdown.item = Object.assign({}, item)
|
dropdown.item = Object.assign({}, item)
|
||||||
|
|
||||||
dropdown.options = []
|
dropdown.options = []
|
||||||
dropdown.options.push({ label: '删除好友', key: 'delete' })
|
// dropdown.options.push({ label: '删除好友', key: 'delete' })
|
||||||
|
|
||||||
dropdown.x = e.clientX
|
dropdown.x = e.clientX
|
||||||
dropdown.y = e.clientY
|
dropdown.y = e.clientY
|
||||||
|
@ -71,11 +71,11 @@ export function useSessionMenu() {
|
|||||||
})
|
})
|
||||||
|
|
||||||
if (item.talk_type == 1) {
|
if (item.talk_type == 1) {
|
||||||
options.push({
|
// options.push({
|
||||||
|
|
||||||
label: '删除好友',
|
// label: '删除好友',
|
||||||
key: 'delete_contact'
|
// key: 'delete_contact'
|
||||||
})
|
// })
|
||||||
} else {
|
} else {
|
||||||
options.push({
|
options.push({
|
||||||
|
|
||||||
@ -107,9 +107,7 @@ export function useSessionMenu() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const onUserInfo = (item: ISession) => {
|
const onUserInfo = (item: ISession) => {
|
||||||
console.error('item',item)
|
user(item.erp_user_id)
|
||||||
|
|
||||||
user(item.id)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 移除会话
|
// 移除会话
|
||||||
|
@ -27,6 +27,7 @@ export interface ISession {
|
|||||||
content?: string // 消息内容
|
content?: string // 消息内容
|
||||||
last_message?: ISessionLastMessage
|
last_message?: ISessionLastMessage
|
||||||
draft_text?: string // 草稿文本
|
draft_text?: string // 草稿文本
|
||||||
|
erp_user_id:number
|
||||||
}
|
}
|
||||||
|
|
||||||
// 消息记录
|
// 消息记录
|
||||||
|
@ -18,7 +18,7 @@ export function isLoggedIn() {
|
|||||||
*/
|
*/
|
||||||
export function getAccessToken() {
|
export function getAccessToken() {
|
||||||
// return storage.get(AccessToken) || ''
|
// return storage.get(AccessToken) || ''
|
||||||
return JSON.parse(localStorage.getItem('token'))||'46d71a72d8d845ad7ed23eba9bdde260e635407190c2ce1bf7fd22088e41682ea07773ec65cae8946d2003f264d55961f96e0fc5da10eb96d3a348c1664e9644ce2108c311309f398ae8ea1b8200bfd490e5cb6e8c52c9e5d493cbabb163368f8351420451a631dbfa749829ee4cda49b77b5ed2d3dced5d0f2b7dd9ee76ba5465c84a17c23af040cd92b6b2a4ea48befbb5c729dcdad0a9c9668befe84074cc24f78899c1d947f8e7f94c7eda5325b8ed698df729e76febb98549ef3482ae942fb4f4a1c92d21836fa784728f0c5483aab2760a991b6b36e6b10c84f840a6433a6ecc31dee36e8f1c6158818bc89d22a02b52442e2e6a79ca35b2fa54a4bb215abd3b9cc8ad2ef018b380a88e93a2fc55fb3e36695ae76a0ea52c973374861c70339249f89f36d787b0dfa7fc99339470dbc626eb5ff42232137ef97447e79f'
|
return JSON.parse(localStorage.getItem('token'))||'46d71a72d8d845ad7ed23eba9bdde260e635407190c2ce1bf7fd22088e41682ea07773ec65cae8946d2003f264d55961f96e0fc5da10eb96d3a348c1664e9644ce2108c311309f398ae8ea1b8200bfd490e5cb6e8c52c9e5d493cbabb163368f8351420451a631dbfa749829ee4cda49b77b5ed2d3dced5d0f2b7dd9ee76ba5465c84a17c23af040cd92b6b2a4ea48befbb5c729dcdad0a9c9668befe84074cc24f78899c1d947f8e7f94c7eda5325b8ed698df729e76febb98549ef3482ae942fb4f4a1c92d21836fa784728f0c5483aab2760a991b6b36e6b10c84f840a6433a6ecc31dee36e8f1c6158818bc89d22726726265e9af0db370a54ea5ee002b43662d571b84c8468ac15330f79503a5cd5e72282d8bee92749b1a3c1b7fd87ae70b64b90e437e84c1b558c64a35e181b2ecf5db3007680c3607eac1edee7f59d'
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -94,8 +94,60 @@ const onSendTextEvent = throttle((value: any) => {
|
|||||||
}, 1000)
|
}, 1000)
|
||||||
|
|
||||||
// 发送图片消息
|
// 发送图片消息
|
||||||
const onSendImageEvent = ({ data, callBack }) => {
|
const onSendImageEvent = ({ data }) => {
|
||||||
onSendMessage({ type: 'image', ...data }, callBack)
|
console.log('onSendImageEvent')
|
||||||
|
|
||||||
|
// 先创建一个带有上传ID的临时消息对象,用于显示进度
|
||||||
|
const uploadId = `image-${Date.now()}-${Math.floor(Math.random() * 1000)}`
|
||||||
|
|
||||||
|
// 创建本地预览URL
|
||||||
|
const previewUrl = URL.createObjectURL(data)
|
||||||
|
|
||||||
|
// 创建临时消息记录
|
||||||
|
const tempMessage = {
|
||||||
|
msg_id: uploadId,
|
||||||
|
sequence: Date.now(),
|
||||||
|
talk_type: props.talk_type,
|
||||||
|
msg_type: 3, // 图片消息类型
|
||||||
|
user_id: props.uid,
|
||||||
|
receiver_id: props.receiver_id,
|
||||||
|
is_revoke: 0,
|
||||||
|
is_mark: 0,
|
||||||
|
is_read: 1,
|
||||||
|
content: '',
|
||||||
|
created_at: parseTime(new Date(), '{y}-{m}-{d} {h}:{i}'),
|
||||||
|
extra: {
|
||||||
|
url: previewUrl, // 使用本地预览URL
|
||||||
|
size: data.size,
|
||||||
|
is_uploading: true,
|
||||||
|
upload_id: uploadId,
|
||||||
|
percentage: 0
|
||||||
|
},
|
||||||
|
isCheck: false,
|
||||||
|
send_status: 1,
|
||||||
|
float: 'right' // 我发送的消息显示在右侧
|
||||||
|
}
|
||||||
|
|
||||||
|
// 直接添加到对话记录中
|
||||||
|
dialogueStore.addDialogueRecord(tempMessage)
|
||||||
|
nextTick(()=>{
|
||||||
|
scrollToBottom()
|
||||||
|
})
|
||||||
|
uploadsStore.initUploadFile(
|
||||||
|
data,
|
||||||
|
props.talk_type,
|
||||||
|
props.receiver_id,
|
||||||
|
uploadId,
|
||||||
|
async (percentage) => {
|
||||||
|
dialogueStore.updateUploadProgress(uploadId, percentage)
|
||||||
|
},
|
||||||
|
async () => {
|
||||||
|
// 清理本地预览URL
|
||||||
|
URL.revokeObjectURL(previewUrl)
|
||||||
|
dialogueStore.batchDelDialogueRecord([uploadId])
|
||||||
|
|
||||||
|
}
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 发送视频消息
|
// 发送视频消息
|
||||||
|
@ -46,9 +46,9 @@ export default defineConfig(({ mode }) => {
|
|||||||
vueJsx({}),
|
vueJsx({}),
|
||||||
compressPlugin(),
|
compressPlugin(),
|
||||||
UnoCSS(),
|
UnoCSS(),
|
||||||
// vueDevTools({
|
vueDevTools({
|
||||||
// launchEditor: 'trae',
|
launchEditor: 'trae',
|
||||||
// })
|
})
|
||||||
],
|
],
|
||||||
define: {
|
define: {
|
||||||
__APP_ENV__: env.APP_ENV
|
__APP_ENV__: env.APP_ENV
|
||||||
|
Loading…
Reference in New Issue
Block a user