Skip to content

Commit

Permalink
feat:代码优化
Browse files Browse the repository at this point in the history
  • Loading branch information
gzydong committed Dec 31, 2023
1 parent 6771585 commit 3360bc3
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 31 deletions.
25 changes: 0 additions & 25 deletions src/api/chat.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,36 +59,11 @@ export const ServePublishMessage = (data = {}) => {
return post('/api/v1/talk/message/publish', data)
}

// 发送代码块消息服务接口
export const ServeSendTalkText = (data = {}) => {
return post('/api/v1/talk/message/text', data)
}

// 发送代码块消息服务接口
export const ServeSendTalkCodeBlock = (data = {}) => {
return post('/api/v1/talk/message/code', data)
}

// 发送聊天文件服务接口
export const ServeSendTalkFile = (data = {}) => {
return post('/api/v1/talk/message/file', data)
}

// 发送聊天图片服务接口
export const ServeSendTalkImage = (data = {}) => {
return upload('/api/v1/talk/message/image', data)
}

// 发送表情包服务接口
export const ServeSendEmoticon = (data = {}) => {
return post('/api/v1/talk/message/emoticon', data)
}

// 转发消息服务接口
export const ServeForwardRecords = (data = {}) => {
return post('/api/v1/talk/message/forward', data)
}

// 撤回消息服务接口
export const ServeRevokeRecords = (data = {}) => {
return post('/api/v1/talk/message/revoke', data)
Expand Down
4 changes: 2 additions & 2 deletions src/components/talk/message/FileMessage.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<script lang="ts" setup>
import { fileFormatSize } from '@/utils/strings'
import { download } from '@/utils/functions'
import { download, getFileNameSuffix } from '@/utils/functions'
import { ITalkRecordExtraFile, ITalkRecord } from '@/types/chat'
defineProps<{
Expand All @@ -13,7 +13,7 @@ defineProps<{
<template>
<section class="file-message">
<div class="main">
<div class="ext">{{ extra.suffix }}</div>
<div class="ext">{{ getFileNameSuffix(extra.name) }}</div>
<div class="file-box">
<p class="info">
<span class="name">{{ extra.name }}</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const { showUserInfoModal } = useInject()
<template>
<div class="im-message-sys-text">
<div class="sys-text">
<a @click="showUserModal(extra.owner_id)">
<a @click="showUserInfoModal(extra.owner_id)">
{{ extra.owner_name }}
</a>

Expand Down
3 changes: 0 additions & 3 deletions src/types/chat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ export interface ITalkRecordExtraFile {
drive: number
name: string
path: string
suffix: string
size: number
}

Expand Down Expand Up @@ -104,7 +103,6 @@ export interface ITalkRecordExtraMixed {

export interface ITalkRecordExtraAudio {
name: string
suffix: string
size: number
url: string
duration: number
Expand All @@ -121,7 +119,6 @@ export interface ITalkRecordExtraLogin {

export interface ITalkRecordExtraImage {
name: string
suffix: string
size: number
url: string
width: number
Expand Down
6 changes: 6 additions & 0 deletions src/utils/functions.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,3 +98,9 @@ export function downloadImage(src, name) {
}
image.src = src
}

// 获取文件名后缀
export const getFileNameSuffix = (name) => {
const arr = name.split('.')
return arr[arr.length - 1]
}

0 comments on commit 3360bc3

Please sign in to comment.