From 79cc8f711b5c02a2e5d03e4e4504547ea7bdc5cf Mon Sep 17 00:00:00 2001
From: Yann <1319542051@qq.com>
Date: Tue, 11 Nov 2025 17:47:04 +0800
Subject: [PATCH 1/3] =?UTF-8?q?add=20=E6=96=87=E4=BB=B6=E9=A2=84=E8=A7=88?=
=?UTF-8?q?=E5=8A=9F=E8=83=BD?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
package.json | 3 +-
src/api/file.ts | 7 +
src/components/video-player/index.vue | 71 +++++++
src/views/files/components/file-grid-view.vue | 6 +
src/views/files/components/file-previewer.vue | 177 ++++++++++++++++++
src/views/files/components/index.ts | 1 +
src/views/files/hooks/use-file-operations.ts | 27 +++
src/views/files/index.vue | 10 +
8 files changed, 301 insertions(+), 1 deletion(-)
create mode 100644 src/components/video-player/index.vue
create mode 100644 src/views/files/components/file-previewer.vue
diff --git a/package.json b/package.json
index 0ef8faf..8ae0dc1 100644
--- a/package.json
+++ b/package.json
@@ -48,7 +48,8 @@
"spark-md5": "^3.0.2",
"vue": "^3.2.40",
"vue-echarts": "^6.2.3",
- "vue-router": "^4.0.14"
+ "vue-router": "^4.0.14",
+ "xgplayer": "^3.0.23"
},
"devDependencies": {
"@arco-plugins/vite-vue": "^1.4.5",
diff --git a/src/api/file.ts b/src/api/file.ts
index 7adddc0..c247412 100644
--- a/src/api/file.ts
+++ b/src/api/file.ts
@@ -182,5 +182,12 @@ export function unfavoriteFile(fileIds: string[]) {
});
}
+/**
+ * 获取文件访问URL
+ */
+export function getFilePreviewUrl(fileId: string, expireSeconds = 180) {
+ return request.get(`/apis/file/url/${fileId}`, { params: { expireSeconds } });
+}
+
// 导出类型以便在组件中使用
export type { FileListParams, FileItem };
diff --git a/src/components/video-player/index.vue b/src/components/video-player/index.vue
new file mode 100644
index 0000000..05f543f
--- /dev/null
+++ b/src/components/video-player/index.vue
@@ -0,0 +1,71 @@
+
+
+
+
+
+
+
diff --git a/src/views/files/components/file-grid-view.vue b/src/views/files/components/file-grid-view.vue
index 2bc3418..6059424 100644
--- a/src/views/files/components/file-grid-view.vue
+++ b/src/views/files/components/file-grid-view.vue
@@ -113,6 +113,10 @@
+
+
+ 预览
+
分享
@@ -162,6 +166,7 @@
IconRefresh,
IconApps,
IconList,
+ IconEye,
} from '@arco-design/web-vue/es/icon';
import type { FileItem } from '@/types/modules/file';
import { getFileIconPath } from '@/utils/file-icon';
@@ -187,6 +192,7 @@
(e: 'update:selectedKeys', keys: string[]): void;
(e: 'update:viewMode', value: 'list' | 'grid'): void;
(e: 'refresh'): void;
+ (e: 'preview', file: FileItem): void;
}>();
const isSelected = (fileId: string) => {
diff --git a/src/views/files/components/file-previewer.vue b/src/views/files/components/file-previewer.vue
new file mode 100644
index 0000000..3394d69
--- /dev/null
+++ b/src/views/files/components/file-previewer.vue
@@ -0,0 +1,177 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
暂不支持预览.{{ fileExtension }} 类型的文件
+
+ 点击下载
+
+
+
+
+
+
+
+
+
+
diff --git a/src/views/files/components/index.ts b/src/views/files/components/index.ts
index 88ef0c7..c0167e0 100644
--- a/src/views/files/components/index.ts
+++ b/src/views/files/components/index.ts
@@ -18,3 +18,4 @@ export { default as DeleteConfirmModal } from './delete-confirm-modal.vue';
export { default as RecycleBinView } from './recycle-bin-view.vue';
export { default as MySharesView } from './my-shares-view.vue';
export { default as UploadPanel } from './upload-panel.vue';
+export { default as FilePreviewer } from './file-previewer.vue';
\ No newline at end of file
diff --git a/src/views/files/hooks/use-file-operations.ts b/src/views/files/hooks/use-file-operations.ts
index 4968076..dc6213e 100644
--- a/src/views/files/hooks/use-file-operations.ts
+++ b/src/views/files/hooks/use-file-operations.ts
@@ -10,6 +10,7 @@ import {
createFolder,
favoriteFile,
unfavoriteFile,
+ getFilePreviewUrl,
} from '@/api/file';
import type { FileItem } from '@/types/modules/file';
@@ -43,6 +44,10 @@ export default function useFileOperations(refreshCallback: () => void) {
const deletingFile = ref(null);
const deletingFiles = ref([]);
+ // 预览相关
+ const previewModalVisible = ref(false);
+ const previewFile = ref({ fileName: '', fileUrl: '', fileSuffix: '' });
+
/**
* 打开上传弹窗
*/
@@ -360,6 +365,23 @@ export default function useFileOperations(refreshCallback: () => void) {
});
};
+ /**
+ * 预览文件
+ */
+ const openPreview = async (file: FileItem) => {
+ previewModalVisible.value = true;
+ try {
+ const res = await getFilePreviewUrl(file.id);
+ previewFile.value = {
+ fileName: file.originalName,
+ fileSuffix: file.suffix,
+ fileUrl: res.data,
+ };
+ } catch (e) {
+ Message.error('预览失败,请联系管理员');
+ }
+ };
+
return {
// 上传相关
uploadModalVisible,
@@ -406,5 +428,10 @@ export default function useFileOperations(refreshCallback: () => void) {
// 收藏
handleFavorite,
+
+ // 预览
+ previewModalVisible,
+ openPreview,
+ previewFile,
};
}
diff --git a/src/views/files/index.vue b/src/views/files/index.vue
index 3d4250b..47b3dc2 100644
--- a/src/views/files/index.vue
+++ b/src/views/files/index.vue
@@ -138,6 +138,7 @@
@move="operations.openMoveModal"
@favorite="handleFavorite"
@refresh="fileList.refresh"
+ @preview="operations.openPreview"
/>
@@ -153,6 +154,7 @@
style="display: none"
@change="handleFileSelect"
/>
+
+
+
+
@@ -233,6 +241,8 @@
DeleteConfirmModal,
RecycleBinView,
MySharesView,
+ UploadPanel,
+ FilePreviewer,
} from './components';
const route = useRoute();
--
Gitee
From 225be40ba5c619859c1b078a8ad30e33d7c92837 Mon Sep 17 00:00:00 2001
From: yanzy <1319542051@qq.com>
Date: Tue, 11 Nov 2025 20:01:43 +0800
Subject: [PATCH 2/3] =?UTF-8?q?add=20=E6=96=B0=E5=A2=9Ecode=E9=A2=84?=
=?UTF-8?q?=E8=A7=88?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
config/vite.config.base.ts | 4 +
package.json | 2 +
src/components/code-player/index.vue | 134 ++++++++++++++++++
src/views/files/components/file-previewer.vue | 6 +
4 files changed, 146 insertions(+)
create mode 100644 src/components/code-player/index.vue
diff --git a/config/vite.config.base.ts b/config/vite.config.base.ts
index 30efaf6..3e56dba 100644
--- a/config/vite.config.base.ts
+++ b/config/vite.config.base.ts
@@ -3,6 +3,7 @@ import { defineConfig } from 'vite';
import vue from '@vitejs/plugin-vue';
import vueJsx from '@vitejs/plugin-vue-jsx';
import svgLoader from 'vite-svg-loader';
+import monacoEditorPlugin from 'vite-plugin-monaco-editor';
import configArcoStyleImportPlugin from './plugin/arcoStyleImport';
export default defineConfig({
@@ -11,6 +12,9 @@ export default defineConfig({
vueJsx(),
svgLoader({ svgoConfig: {} }),
configArcoStyleImportPlugin(),
+ monacoEditorPlugin({
+ languageWorkers: ['json', 'css', 'html', 'typescript'],
+ }),
],
resolve: {
alias: [
diff --git a/package.json b/package.json
index 8ae0dc1..53891e7 100644
--- a/package.json
+++ b/package.json
@@ -39,6 +39,7 @@
"echarts": "^5.4.0",
"gsap": "^3.13.0",
"mitt": "^3.0.0",
+ "monaco-editor": "^0.54.0",
"motion-v": "^1.7.4",
"nprogress": "^0.2.0",
"pinia": "^2.0.23",
@@ -46,6 +47,7 @@
"radash": "^12.1.0",
"sortablejs": "^1.15.0",
"spark-md5": "^3.0.2",
+ "vite-plugin-monaco-editor": "^1.1.0",
"vue": "^3.2.40",
"vue-echarts": "^6.2.3",
"vue-router": "^4.0.14",
diff --git a/src/components/code-player/index.vue b/src/components/code-player/index.vue
new file mode 100644
index 0000000..9534fa0
--- /dev/null
+++ b/src/components/code-player/index.vue
@@ -0,0 +1,134 @@
+
+
+
+
+
+
+
diff --git a/src/views/files/components/file-previewer.vue b/src/views/files/components/file-previewer.vue
index 3394d69..e0d621c 100644
--- a/src/views/files/components/file-previewer.vue
+++ b/src/views/files/components/file-previewer.vue
@@ -2,6 +2,7 @@
import { computed } from 'vue';
import { IconQuestion } from '@arco-design/web-vue/es/icon';
import VideoPlayer from '@/components/video-player/index.vue';
+ import CodePlayer from '@/components/code-player/index.vue';
/** 文件预览组件 */
interface FileInfo {
@@ -112,6 +113,10 @@
+
+
+
+
@@ -151,6 +156,7 @@
.image-preview,
.video-viewer,
+ .code-text-viewer,
.unsupported-viewer {
width: 100%;
height: 100%;
--
Gitee
From 064327aa3495dc8fae5b41c8c7a739c55bbfd244 Mon Sep 17 00:00:00 2001
From: yanzy <1319542051@qq.com>
Date: Wed, 12 Nov 2025 00:00:43 +0800
Subject: [PATCH 3/3] =?UTF-8?q?add=20=E6=96=B0=E5=A2=9Epdf=E9=A2=84?=
=?UTF-8?q?=E8=A7=88/audio=E9=A2=84=E8=A7=88?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
package.json | 3 +-
src/components/audio-player/index.vue | 153 ++++++++++++++++++
src/components/pdf-player/index.vue | 79 +++++++++
src/views/files/components/file-previewer.vue | 28 +++-
4 files changed, 259 insertions(+), 4 deletions(-)
create mode 100644 src/components/audio-player/index.vue
create mode 100644 src/components/pdf-player/index.vue
diff --git a/package.json b/package.json
index 53891e7..dd41e53 100644
--- a/package.json
+++ b/package.json
@@ -51,7 +51,8 @@
"vue": "^3.2.40",
"vue-echarts": "^6.2.3",
"vue-router": "^4.0.14",
- "xgplayer": "^3.0.23"
+ "xgplayer": "^3.0.23",
+ "xgplayer-music": "^3.0.23"
},
"devDependencies": {
"@arco-plugins/vite-vue": "^1.4.5",
diff --git a/src/components/audio-player/index.vue b/src/components/audio-player/index.vue
new file mode 100644
index 0000000..8e9af45
--- /dev/null
+++ b/src/components/audio-player/index.vue
@@ -0,0 +1,153 @@
+
+
+
+
+
+
+
diff --git a/src/components/pdf-player/index.vue b/src/components/pdf-player/index.vue
new file mode 100644
index 0000000..4160c24
--- /dev/null
+++ b/src/components/pdf-player/index.vue
@@ -0,0 +1,79 @@
+
+
+
+
+
+
+
diff --git a/src/views/files/components/file-previewer.vue b/src/views/files/components/file-previewer.vue
index e0d621c..4c5a538 100644
--- a/src/views/files/components/file-previewer.vue
+++ b/src/views/files/components/file-previewer.vue
@@ -1,8 +1,20 @@