Trim locale and notification payload
This commit is contained in:
@@ -1,5 +1,4 @@
|
|||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import type { ChatMessage } from '#/api/core/chat';
|
|
||||||
import type {
|
import type {
|
||||||
AnnouncementItem,
|
AnnouncementItem,
|
||||||
NotificationItem,
|
NotificationItem,
|
||||||
@@ -8,11 +7,10 @@ import type {
|
|||||||
import { computed, ref } from 'vue';
|
import { computed, ref } from 'vue';
|
||||||
|
|
||||||
import { useVbenDrawer } from '@vben-core/popup-ui';
|
import { useVbenDrawer } from '@vben-core/popup-ui';
|
||||||
import { Mail, MailCheck, Megaphone, MessageSquare, Trash2 } from '@vben/icons';
|
import { Mail, MailCheck, Megaphone, Trash2 } from '@vben/icons';
|
||||||
|
|
||||||
import { ElButton, ElEmpty, ElScrollbar, ElTooltip } from 'element-plus';
|
import { ElButton, ElEmpty, ElScrollbar, ElTooltip } from 'element-plus';
|
||||||
|
|
||||||
import UserAvatar from '#/components/user-avatar/index.vue';
|
|
||||||
import { ZqTabs } from '#/components/zq-tabs';
|
import { ZqTabs } from '#/components/zq-tabs';
|
||||||
import { $t } from '#/locales';
|
import { $t } from '#/locales';
|
||||||
|
|
||||||
@@ -25,12 +23,8 @@ interface Props {
|
|||||||
announcements?: AnnouncementItem[];
|
announcements?: AnnouncementItem[];
|
||||||
// 公告未读数
|
// 公告未读数
|
||||||
announcementUnreadCount?: number;
|
announcementUnreadCount?: number;
|
||||||
// 未读聊天消息列表
|
|
||||||
unreadChats?: ChatMessage[];
|
|
||||||
// 聊天未读总数
|
|
||||||
chatUnreadCount?: number;
|
|
||||||
// 当前激活的 Tab
|
// 当前激活的 Tab
|
||||||
activeTab?: 'announcement' | 'chat' | 'message';
|
activeTab?: 'announcement' | 'message';
|
||||||
}
|
}
|
||||||
|
|
||||||
defineOptions({ name: 'NotificationDrawer' });
|
defineOptions({ name: 'NotificationDrawer' });
|
||||||
@@ -40,18 +34,15 @@ const props = withDefaults(defineProps<Props>(), {
|
|||||||
messageUnreadCount: 0,
|
messageUnreadCount: 0,
|
||||||
announcements: () => [],
|
announcements: () => [],
|
||||||
announcementUnreadCount: 0,
|
announcementUnreadCount: 0,
|
||||||
unreadChats: () => [],
|
|
||||||
chatUnreadCount: 0,
|
|
||||||
activeTab: 'message',
|
activeTab: 'message',
|
||||||
});
|
});
|
||||||
|
|
||||||
const emit = defineEmits<{
|
const emit = defineEmits<{
|
||||||
clear: [];
|
clear: [];
|
||||||
clickChat: [ChatMessage];
|
|
||||||
makeAll: [];
|
makeAll: [];
|
||||||
readAnnouncement: [AnnouncementItem];
|
readAnnouncement: [AnnouncementItem];
|
||||||
readMessage: [NotificationItem];
|
readMessage: [NotificationItem];
|
||||||
'update:activeTab': ['announcement' | 'chat' | 'message'];
|
'update:activeTab': ['announcement' | 'message'];
|
||||||
viewAll: [];
|
viewAll: [];
|
||||||
}>();
|
}>();
|
||||||
|
|
||||||
@@ -65,11 +56,6 @@ const tabItems = computed(() => [
|
|||||||
label: `${$t('message.drawer.messageTab')}${props.messageUnreadCount > 0 ? ` (${props.messageUnreadCount})` : ''}`,
|
label: `${$t('message.drawer.messageTab')}${props.messageUnreadCount > 0 ? ` (${props.messageUnreadCount})` : ''}`,
|
||||||
icon: Mail,
|
icon: Mail,
|
||||||
},
|
},
|
||||||
{
|
|
||||||
key: 'chat',
|
|
||||||
label: `${$t('message.drawer.chatTab')}${props.chatUnreadCount > 0 ? ` (${props.chatUnreadCount})` : ''}`,
|
|
||||||
icon: MessageSquare,
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
key: 'announcement',
|
key: 'announcement',
|
||||||
label: `${$t('message.drawer.announcementTab')}${props.announcementUnreadCount > 0 ? ` (${props.announcementUnreadCount})` : ''}`,
|
label: `${$t('message.drawer.announcementTab')}${props.announcementUnreadCount > 0 ? ` (${props.announcementUnreadCount})` : ''}`,
|
||||||
@@ -78,34 +64,10 @@ const tabItems = computed(() => [
|
|||||||
]);
|
]);
|
||||||
|
|
||||||
function handleTabChange(value: string) {
|
function handleTabChange(value: string) {
|
||||||
currentTab.value = value as 'announcement' | 'chat' | 'message';
|
currentTab.value = value as 'announcement' | 'message';
|
||||||
emit('update:activeTab', currentTab.value);
|
emit('update:activeTab', currentTab.value);
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleChatClick(msg: ChatMessage) {
|
|
||||||
emit('clickChat', msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
function getMessagePreview(msg: ChatMessage): string {
|
|
||||||
if (msg.msg_type === 'text') return msg.content || '';
|
|
||||||
if (msg.msg_type === 'image') return `[${$t('chat.image')}]`;
|
|
||||||
if (msg.msg_type === 'file')
|
|
||||||
return `[${$t('chat.file')}] ${msg.file_name || ''}`;
|
|
||||||
if (msg.msg_type === 'voice') return `[${$t('chat.voice')}]`;
|
|
||||||
return `[${msg.msg_type}]`;
|
|
||||||
}
|
|
||||||
|
|
||||||
function formatChatTime(datetime?: string): string {
|
|
||||||
if (!datetime) return '';
|
|
||||||
const date = new Date(datetime);
|
|
||||||
const now = new Date();
|
|
||||||
const isToday = date.toDateString() === now.toDateString();
|
|
||||||
if (isToday) {
|
|
||||||
return date.toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' });
|
|
||||||
}
|
|
||||||
return date.toLocaleDateString([], { month: '2-digit', day: '2-digit' });
|
|
||||||
}
|
|
||||||
|
|
||||||
function handleViewAll() {
|
function handleViewAll() {
|
||||||
emit('viewAll');
|
emit('viewAll');
|
||||||
}
|
}
|
||||||
@@ -240,59 +202,6 @@ function getPriorityClass(priority: number): string {
|
|||||||
</template>
|
</template>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<!-- 聊天未读列表 -->
|
|
||||||
<template v-else-if="currentTab === 'chat'">
|
|
||||||
<ElScrollbar v-if="unreadChats.length > 0" class="flex-1">
|
|
||||||
<ul class="flex w-full flex-col gap-2">
|
|
||||||
<template v-for="msg in unreadChats" :key="msg.id">
|
|
||||||
<li
|
|
||||||
class="relative flex w-full cursor-pointer items-center gap-3 rounded-lg border border-[var(--el-border-color)] p-3 transition-colors hover:bg-[var(--el-fill-color-light)]"
|
|
||||||
@click="handleChatClick(msg)"
|
|
||||||
>
|
|
||||||
<UserAvatar
|
|
||||||
:user-id="msg.sender_id"
|
|
||||||
:name="msg.sender_name || ''"
|
|
||||||
:avatar="msg.sender_avatar"
|
|
||||||
:size="40"
|
|
||||||
:font-size="16"
|
|
||||||
:show-popover="false"
|
|
||||||
class="shrink-0"
|
|
||||||
/>
|
|
||||||
<div class="flex flex-1 flex-col gap-1 leading-none">
|
|
||||||
<div class="flex items-center justify-between">
|
|
||||||
<p class="text-sm font-medium">
|
|
||||||
{{ msg.sender_name || '' }}
|
|
||||||
</p>
|
|
||||||
<span
|
|
||||||
class="text-xs text-[var(--el-text-color-placeholder)]"
|
|
||||||
>
|
|
||||||
{{ formatChatTime(msg.sys_create_datetime) }}
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
<p
|
|
||||||
class="truncate text-xs text-[var(--el-text-color-secondary)]"
|
|
||||||
>
|
|
||||||
{{ getMessagePreview(msg) }}
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
</li>
|
|
||||||
</template>
|
|
||||||
</ul>
|
|
||||||
</ElScrollbar>
|
|
||||||
|
|
||||||
<template v-else>
|
|
||||||
<div class="flex flex-1 items-center justify-center">
|
|
||||||
<ElEmpty :description="$t('message.drawer.noChats')">
|
|
||||||
<template #image>
|
|
||||||
<MessageSquare
|
|
||||||
class="size-16 text-[var(--el-text-color-placeholder)]"
|
|
||||||
/>
|
|
||||||
</template>
|
|
||||||
</ElEmpty>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<!-- 公告列表 -->
|
<!-- 公告列表 -->
|
||||||
<template v-else>
|
<template v-else>
|
||||||
<ElScrollbar v-if="announcements.length > 0" class="flex-1">
|
<ElScrollbar v-if="announcements.length > 0" class="flex-1">
|
||||||
|
|||||||
@@ -1,19 +1,11 @@
|
|||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import type { ChatMessage } from '#/api/core/chat';
|
|
||||||
import type {
|
import type {
|
||||||
AnnouncementItem,
|
AnnouncementItem,
|
||||||
NotificationItem,
|
NotificationItem,
|
||||||
} from '#/composables/useNotification';
|
} from '#/composables/useNotification';
|
||||||
import type { WatchStopHandle } from 'vue';
|
import type { WatchStopHandle } from 'vue';
|
||||||
|
|
||||||
import {
|
import { computed, defineAsyncComponent, onUnmounted, ref, watch } from 'vue';
|
||||||
computed,
|
|
||||||
defineAsyncComponent,
|
|
||||||
onUnmounted,
|
|
||||||
ref,
|
|
||||||
watch,
|
|
||||||
} from 'vue';
|
|
||||||
import { useRouter } from 'vue-router';
|
|
||||||
|
|
||||||
import { useWatermark } from '@vben/hooks';
|
import { useWatermark } from '@vben/hooks';
|
||||||
import { BasicLayout } from '@vben/layouts';
|
import { BasicLayout } from '@vben/layouts';
|
||||||
@@ -27,11 +19,13 @@ import { useAuthStore } from '#/store';
|
|||||||
const LoginForm = defineAsyncComponent(
|
const LoginForm = defineAsyncComponent(
|
||||||
() => import('#/views/_core/authentication/login.vue'),
|
() => import('#/views/_core/authentication/login.vue'),
|
||||||
);
|
);
|
||||||
const AuthenticationLoginExpiredModal = defineAsyncComponent(() =>
|
const AuthenticationLoginExpiredModal = defineAsyncComponent(
|
||||||
import('@vben/common-ui/es/login-expired-modal'),
|
() => import('@vben/common-ui/es/login-expired-modal'),
|
||||||
);
|
);
|
||||||
const UserDropdown = defineAsyncComponent(() =>
|
const UserDropdown = defineAsyncComponent(() =>
|
||||||
import('@vben/layouts/es/user-dropdown').then((module) => module.UserDropdown),
|
import('@vben/layouts/es/user-dropdown').then(
|
||||||
|
(module) => module.UserDropdown,
|
||||||
|
),
|
||||||
);
|
);
|
||||||
const NotificationPopup = defineAsyncComponent(
|
const NotificationPopup = defineAsyncComponent(
|
||||||
() => import('#/components/notification/NotificationPopup.vue'),
|
() => import('#/components/notification/NotificationPopup.vue'),
|
||||||
@@ -41,12 +35,10 @@ const notifications = ref<NotificationItem[]>([]);
|
|||||||
const messageUnreadCount = ref(0);
|
const messageUnreadCount = ref(0);
|
||||||
const announcements = ref<AnnouncementItem[]>([]);
|
const announcements = ref<AnnouncementItem[]>([]);
|
||||||
const announcementUnreadCount = ref(0);
|
const announcementUnreadCount = ref(0);
|
||||||
const activeTab = ref<'announcement' | 'chat' | 'message'>('message');
|
const activeTab = ref<'announcement' | 'message'>('message');
|
||||||
const showDot = computed(
|
const showDot = computed(
|
||||||
() => messageUnreadCount.value + announcementUnreadCount.value > 0,
|
() => messageUnreadCount.value + announcementUnreadCount.value > 0,
|
||||||
);
|
);
|
||||||
const unreadChatMessages = ref<ChatMessage[]>([]);
|
|
||||||
const chatTotalUnread = ref(0);
|
|
||||||
|
|
||||||
const userStore = useUserStore();
|
const userStore = useUserStore();
|
||||||
const authStore = useAuthStore();
|
const authStore = useAuthStore();
|
||||||
@@ -54,9 +46,7 @@ const accessStore = useAccessStore();
|
|||||||
const { destroyWatermark, updateWatermark } = useWatermark();
|
const { destroyWatermark, updateWatermark } = useWatermark();
|
||||||
|
|
||||||
// 初始化消息通知
|
// 初始化消息通知
|
||||||
const router = useRouter();
|
|
||||||
let notificationApi: any = null;
|
let notificationApi: any = null;
|
||||||
let chatApi: any = null;
|
|
||||||
let layoutActive = true;
|
let layoutActive = true;
|
||||||
let realtimeInitializing: Promise<void> | null = null;
|
let realtimeInitializing: Promise<void> | null = null;
|
||||||
let realtimeInitialized = false;
|
let realtimeInitialized = false;
|
||||||
@@ -67,7 +57,6 @@ onUnmounted(() => {
|
|||||||
stopRealtimeWatches.forEach((stop) => stop());
|
stopRealtimeWatches.forEach((stop) => stop());
|
||||||
stopRealtimeWatches = [];
|
stopRealtimeWatches = [];
|
||||||
notificationApi?.cleanup();
|
notificationApi?.cleanup();
|
||||||
chatApi?.disconnectChat();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
async function initRealtimeFeatures() {
|
async function initRealtimeFeatures() {
|
||||||
@@ -81,15 +70,11 @@ async function initRealtimeFeatures() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function doInitRealtimeFeatures() {
|
async function doInitRealtimeFeatures() {
|
||||||
const [notificationModule, chatModule] = await Promise.all([
|
const notificationModule = await import('#/composables/useNotification');
|
||||||
import('#/composables/useNotification'),
|
|
||||||
import('#/views/_core/chat/composables/useChat'),
|
|
||||||
]);
|
|
||||||
|
|
||||||
if (!layoutActive) return;
|
if (!layoutActive) return;
|
||||||
|
|
||||||
notificationApi = notificationModule.useNotification();
|
notificationApi = notificationModule.useNotification();
|
||||||
chatApi = chatModule.useChat();
|
|
||||||
|
|
||||||
stopRealtimeWatches = [
|
stopRealtimeWatches = [
|
||||||
watch(
|
watch(
|
||||||
@@ -123,30 +108,13 @@ async function doInitRealtimeFeatures() {
|
|||||||
watch(
|
watch(
|
||||||
notificationApi.activeTab,
|
notificationApi.activeTab,
|
||||||
(value) => {
|
(value) => {
|
||||||
activeTab.value = value;
|
activeTab.value = value === 'announcement' ? value : 'message';
|
||||||
},
|
|
||||||
{ immediate: true },
|
|
||||||
),
|
|
||||||
watch(
|
|
||||||
chatApi.unreadChatMessages,
|
|
||||||
(value) => {
|
|
||||||
unreadChatMessages.value = value;
|
|
||||||
},
|
|
||||||
{ immediate: true },
|
|
||||||
),
|
|
||||||
watch(
|
|
||||||
chatApi.totalUnread,
|
|
||||||
(value) => {
|
|
||||||
chatTotalUnread.value = value;
|
|
||||||
},
|
},
|
||||||
{ immediate: true },
|
{ immediate: true },
|
||||||
),
|
),
|
||||||
];
|
];
|
||||||
|
|
||||||
notificationApi.init();
|
notificationApi.init();
|
||||||
chatApi.connectChat();
|
|
||||||
chatApi.loadConversations();
|
|
||||||
chatApi.loadUnreadChatMessages();
|
|
||||||
realtimeInitialized = true;
|
realtimeInitialized = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -225,7 +193,7 @@ function handleViewAll() {
|
|||||||
notificationApi?.viewAllMessages();
|
notificationApi?.viewAllMessages();
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleTabChange(tab: 'announcement' | 'chat' | 'message') {
|
function handleTabChange(tab: 'announcement' | 'message') {
|
||||||
activeTab.value = tab;
|
activeTab.value = tab;
|
||||||
if (notificationApi) {
|
if (notificationApi) {
|
||||||
notificationApi.activeTab.value = tab;
|
notificationApi.activeTab.value = tab;
|
||||||
@@ -236,19 +204,6 @@ function handleNotificationOpen() {
|
|||||||
void initRealtimeFeatures();
|
void initRealtimeFeatures();
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleChatClick(msg: ChatMessage) {
|
|
||||||
// 新开tab跳转到聊天页面,带上会话ID
|
|
||||||
const url = router.resolve(
|
|
||||||
`/chat?conversationId=${msg.conversation_id}`,
|
|
||||||
).href;
|
|
||||||
window.open(url, '_blank');
|
|
||||||
|
|
||||||
// 从未读聊天列表中移除
|
|
||||||
const index = unreadChatMessages.value.findIndex((m) => m.id === msg.id);
|
|
||||||
if (index !== -1) {
|
|
||||||
unreadChatMessages.value.splice(index, 1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
watch(
|
watch(
|
||||||
() => ({
|
() => ({
|
||||||
enable: preferences.app.watermark,
|
enable: preferences.app.watermark,
|
||||||
@@ -287,16 +242,13 @@ watch(
|
|||||||
</template>
|
</template>
|
||||||
<template #notification>
|
<template #notification>
|
||||||
<NotificationPopup
|
<NotificationPopup
|
||||||
:dot="showDot || chatTotalUnread > 0"
|
:dot="showDot"
|
||||||
:notifications="notifications"
|
:notifications="notifications"
|
||||||
:message-unread-count="messageUnreadCount"
|
:message-unread-count="messageUnreadCount"
|
||||||
:announcements="announcements"
|
:announcements="announcements"
|
||||||
:announcement-unread-count="announcementUnreadCount"
|
:announcement-unread-count="announcementUnreadCount"
|
||||||
:unread-chats="unreadChatMessages"
|
|
||||||
:chat-unread-count="chatTotalUnread"
|
|
||||||
:active-tab="activeTab"
|
:active-tab="activeTab"
|
||||||
@clear="handleNoticeClear"
|
@clear="handleNoticeClear"
|
||||||
@click-chat="handleChatClick"
|
|
||||||
@make-all="handleMakeAll"
|
@make-all="handleMakeAll"
|
||||||
@open="handleNotificationOpen"
|
@open="handleNotificationOpen"
|
||||||
@read-message="handleNoticeRead"
|
@read-message="handleNoticeRead"
|
||||||
@@ -322,7 +274,8 @@ watch(
|
|||||||
sidebarFooterProps?.compact
|
sidebarFooterProps?.compact
|
||||||
? PRODUCT_BRAND_SHORT
|
? PRODUCT_BRAND_SHORT
|
||||||
: $t('ui.layout.poweredBy')
|
: $t('ui.layout.poweredBy')
|
||||||
}}</span>
|
}}</span
|
||||||
|
>
|
||||||
</button>
|
</button>
|
||||||
</template>
|
</template>
|
||||||
<template #extra>
|
<template #extra>
|
||||||
|
|||||||
@@ -30,23 +30,11 @@ const baseModules = import.meta.glob([
|
|||||||
]);
|
]);
|
||||||
|
|
||||||
const businessModules = import.meta.glob([
|
const businessModules = import.meta.glob([
|
||||||
'./langs/zh-CN/account-settings.json',
|
|
||||||
'./langs/zh-CN/api-token.json',
|
|
||||||
'./langs/zh-CN/ai-platform.json',
|
'./langs/zh-CN/ai-platform.json',
|
||||||
'./langs/zh-CN/announcement.json',
|
'./langs/zh-CN/announcement.json',
|
||||||
'./langs/zh-CN/application.json',
|
|
||||||
'./langs/zh-CN/chat.json',
|
|
||||||
'./langs/zh-CN/dashboard-design.json',
|
|
||||||
'./langs/zh-CN/dept.json',
|
|
||||||
'./langs/zh-CN/dict.json',
|
|
||||||
'./langs/zh-CN/file-manager.json',
|
|
||||||
'./langs/zh-CN/loginLog.json',
|
|
||||||
'./langs/zh-CN/menu.json',
|
'./langs/zh-CN/menu.json',
|
||||||
'./langs/zh-CN/message.json',
|
'./langs/zh-CN/message.json',
|
||||||
'./langs/zh-CN/org-chart.json',
|
|
||||||
'./langs/zh-CN/page-manager.json',
|
|
||||||
'./langs/zh-CN/permission.json',
|
'./langs/zh-CN/permission.json',
|
||||||
'./langs/zh-CN/post.json',
|
|
||||||
'./langs/zh-CN/role.json',
|
'./langs/zh-CN/role.json',
|
||||||
'./langs/zh-CN/system-config.json',
|
'./langs/zh-CN/system-config.json',
|
||||||
'./langs/zh-CN/system.json',
|
'./langs/zh-CN/system.json',
|
||||||
|
|||||||
@@ -71,7 +71,7 @@ const coreRoutes: RouteRecordRaw[] = [
|
|||||||
hideInBreadcrumb: true,
|
hideInBreadcrumb: true,
|
||||||
hideInMenu: true,
|
hideInMenu: true,
|
||||||
hideInTab: true,
|
hideInTab: true,
|
||||||
title: $t('file-manager.filePreview'),
|
title: '文件预览',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -10,6 +10,12 @@ import { ElButton, ElMessage } from 'element-plus';
|
|||||||
import { getFileTypeIcon } from '#/assets/file-icons';
|
import { getFileTypeIcon } from '#/assets/file-icons';
|
||||||
import { getFileUrl } from '#/composables/useFileUrl';
|
import { getFileUrl } from '#/composables/useFileUrl';
|
||||||
|
|
||||||
|
const FILE_PREVIEW_TITLE = '文件预览';
|
||||||
|
const FILE_DOWNLOAD_TEXT = '下载';
|
||||||
|
const FILE_DOWNLOAD_FAILED = '下载文件失败';
|
||||||
|
const FILE_PREVIEW_FAILED = '预览失败';
|
||||||
|
const FILE_PREVIEW_NOT_SUPPORTED = '该文件类型暂不支持预览';
|
||||||
|
|
||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
|
|
||||||
const fileId = computed(() => route.params.id as string);
|
const fileId = computed(() => route.params.id as string);
|
||||||
@@ -20,7 +26,9 @@ const textContent = ref('');
|
|||||||
const errorMsg = ref('');
|
const errorMsg = ref('');
|
||||||
const loading = ref(false);
|
const loading = ref(false);
|
||||||
|
|
||||||
const normalizedExt = computed(() => fileExt.value.toLowerCase().replace('.', ''));
|
const normalizedExt = computed(() =>
|
||||||
|
fileExt.value.toLowerCase().replace('.', ''),
|
||||||
|
);
|
||||||
const textExts = new Set([
|
const textExts = new Set([
|
||||||
'bash',
|
'bash',
|
||||||
'conf',
|
'conf',
|
||||||
@@ -87,7 +95,7 @@ async function handleDownload() {
|
|||||||
link.remove();
|
link.remove();
|
||||||
window.URL.revokeObjectURL(blobUrl);
|
window.URL.revokeObjectURL(blobUrl);
|
||||||
} catch {
|
} catch {
|
||||||
ElMessage.error($t('file-manager.downloadFailed'));
|
ElMessage.error(FILE_DOWNLOAD_FAILED);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -96,7 +104,7 @@ function handleBack() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
document.title = fileName.value || $t('file-manager.filePreview');
|
document.title = fileName.value || FILE_PREVIEW_TITLE;
|
||||||
loadFile();
|
loadFile();
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
@@ -119,7 +127,7 @@ onMounted(() => {
|
|||||||
</div>
|
</div>
|
||||||
<ElButton v-if="fileUrl" size="small" @click="handleDownload">
|
<ElButton v-if="fileUrl" size="small" @click="handleDownload">
|
||||||
<Download class="mr-1 size-4" />
|
<Download class="mr-1 size-4" />
|
||||||
{{ $t('file-manager.download') }}
|
{{ FILE_DOWNLOAD_TEXT }}
|
||||||
</ElButton>
|
</ElButton>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -130,7 +138,7 @@ onMounted(() => {
|
|||||||
|
|
||||||
<div v-else-if="errorMsg" class="max-w-md text-center">
|
<div v-else-if="errorMsg" class="max-w-md text-center">
|
||||||
<p class="mb-2 text-lg text-[var(--el-color-danger)]">
|
<p class="mb-2 text-lg text-[var(--el-color-danger)]">
|
||||||
{{ $t('file-manager.previewFailed') }}
|
{{ FILE_PREVIEW_FAILED }}
|
||||||
</p>
|
</p>
|
||||||
<p class="text-sm text-[var(--el-text-color-secondary)]">
|
<p class="text-sm text-[var(--el-text-color-secondary)]">
|
||||||
{{ errorMsg }}
|
{{ errorMsg }}
|
||||||
@@ -152,16 +160,17 @@ onMounted(() => {
|
|||||||
<pre
|
<pre
|
||||||
v-else-if="previewType === 'text'"
|
v-else-if="previewType === 'text'"
|
||||||
class="h-full w-full overflow-auto bg-[var(--el-fill-color-light)] p-4 text-sm leading-6"
|
class="h-full w-full overflow-auto bg-[var(--el-fill-color-light)] p-4 text-sm leading-6"
|
||||||
>{{ textContent }}</pre>
|
>{{ textContent }}</pre
|
||||||
|
>
|
||||||
|
|
||||||
<div v-else class="text-center">
|
<div v-else class="text-center">
|
||||||
<img :src="getFileTypeIcon(fileExt)" class="mx-auto mb-4 size-20" />
|
<img :src="getFileTypeIcon(fileExt)" class="mx-auto mb-4 size-20" />
|
||||||
<p class="mb-4 text-lg text-[var(--el-text-color-secondary)]">
|
<p class="mb-4 text-lg text-[var(--el-text-color-secondary)]">
|
||||||
{{ $t('file-manager.previewNotSupported') }}
|
{{ FILE_PREVIEW_NOT_SUPPORTED }}
|
||||||
</p>
|
</p>
|
||||||
<ElButton v-if="fileUrl" type="primary" @click="handleDownload">
|
<ElButton v-if="fileUrl" type="primary" @click="handleDownload">
|
||||||
<Download class="mr-1 size-4" />
|
<Download class="mr-1 size-4" />
|
||||||
{{ $t('file-manager.download') }}
|
{{ FILE_DOWNLOAD_TEXT }}
|
||||||
</ElButton>
|
</ElButton>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user