@chenghongyu/xpt-file-viewer 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.vscode/extensions.json +3 -0
- package/README.md +5 -0
- package/auto-imports.d.ts +12 -0
- package/components.d.ts +45 -0
- package/dist.zip +0 -0
- package/index.html +13 -0
- package/package.json +100 -0
- package/presets/eslint/.eslintrc-auto-import.json +462 -0
- package/presets/plugins/html.ts +14 -0
- package/presets/shared/env.ts +46 -0
- package/presets/shared/resolvers.ts +29 -0
- package/presets/tov.ts +132 -0
- package/presets/types/auto-imports.d.ts +806 -0
- package/presets/types/components.d.ts +164 -0
- package/presets/types/env.d.ts +17 -0
- package/public/favicon.svg +1 -0
- package/public/icons.svg +24 -0
- package/public/testfile/README.md +5 -0
- package/public/testfile/useFileContextMenu.js +74 -0
- package/public/testfile//345/217/221/347/245/250.pdf +0 -0
- package/public/testfile//346/216/245/346/224/266/345/207/275.docx +0 -0
- package/public/testfile//350/247/204/346/240/274/345/236/213/345/217/2671.txt +263 -0
- package/public/testfile//350/247/206/351/242/2211.mp4 +0 -0
- package/public/testfile//351/237/263/351/242/2211.mp3 +0 -0
- package/src/App.vue +8 -0
- package/src/api/admin/admin-2fa.js +18 -0
- package/src/api/admin/admin-download-log.js +37 -0
- package/src/api/admin/admin-login-log.js +9 -0
- package/src/api/admin/admin-permission.js +9 -0
- package/src/api/admin/admin-setting.js +121 -0
- package/src/api/admin/admin-share.js +20 -0
- package/src/api/admin/admin-short-link.js +49 -0
- package/src/api/admin/admin-sso.js +38 -0
- package/src/api/admin/admin-storage.js +189 -0
- package/src/api/admin/admin-user.js +61 -0
- package/src/api/home/common.js +9 -0
- package/src/api/home/file-operator.js +89 -0
- package/src/api/home/home.js +87 -0
- package/src/api/home/install.js +18 -0
- package/src/api/home/login.js +9 -0
- package/src/api/home/only-office.js +10 -0
- package/src/api/home/share.js +115 -0
- package/src/api/home/user.js +74 -0
- package/src/api/tools/tools-115.js +17 -0
- package/src/api/tools/tools-gd.js +13 -0
- package/src/api/tools/tools-s3.js +25 -0
- package/src/api/tools/tools-sharepoint.js +19 -0
- package/src/assets/hero.png +0 -0
- package/src/assets/icons/401.svg +1 -0
- package/src/assets/icons/403.svg +45 -0
- package/src/assets/icons/404.svg +1 -0
- package/src/assets/icons/500.svg +1 -0
- package/src/assets/icons/admin-login.svg +1 -0
- package/src/assets/icons/document.svg +1 -0
- package/src/assets/icons/empty.svg +145 -0
- package/src/assets/icons/file-type-apk.svg +1 -0
- package/src/assets/icons/file-type-archive.svg +1 -0
- package/src/assets/icons/file-type-audio.svg +1 -0
- package/src/assets/icons/file-type-back.svg +1 -0
- package/src/assets/icons/file-type-css.svg +1 -0
- package/src/assets/icons/file-type-deb.svg +1 -0
- package/src/assets/icons/file-type-dll.svg +1 -0
- package/src/assets/icons/file-type-doc.svg +1 -0
- package/src/assets/icons/file-type-document.svg +1 -0
- package/src/assets/icons/file-type-docx.svg +1 -0
- package/src/assets/icons/file-type-exe.svg +1 -0
- package/src/assets/icons/file-type-expression.svg +1 -0
- package/src/assets/icons/file-type-file.svg +1 -0
- package/src/assets/icons/file-type-folder.svg +1 -0
- package/src/assets/icons/file-type-html.svg +1 -0
- package/src/assets/icons/file-type-image.svg +1 -0
- package/src/assets/icons/file-type-java.svg +1 -0
- package/src/assets/icons/file-type-js.svg +1 -0
- package/src/assets/icons/file-type-less.svg +1 -0
- package/src/assets/icons/file-type-md.svg +1 -0
- package/src/assets/icons/file-type-office.svg +1 -0
- package/src/assets/icons/file-type-pdf.svg +1 -0
- package/src/assets/icons/file-type-php.svg +1 -0
- package/src/assets/icons/file-type-ppt.svg +1 -0
- package/src/assets/icons/file-type-pptx.svg +1 -0
- package/src/assets/icons/file-type-py.svg +1 -0
- package/src/assets/icons/file-type-rb.svg +1 -0
- package/src/assets/icons/file-type-root.svg +1 -0
- package/src/assets/icons/file-type-rpm.svg +1 -0
- package/src/assets/icons/file-type-rust.svg +1 -0
- package/src/assets/icons/file-type-script.svg +1 -0
- package/src/assets/icons/file-type-text.svg +1 -0
- package/src/assets/icons/file-type-three3d.svg +5 -0
- package/src/assets/icons/file-type-vbs.svg +1 -0
- package/src/assets/icons/file-type-video.svg +1 -0
- package/src/assets/icons/file-type-xls.svg +1 -0
- package/src/assets/icons/file-type-xlsx.svg +1 -0
- package/src/assets/icons/file-type-xml.svg +1 -0
- package/src/assets/icons/file-type-yaml.svg +1 -0
- package/src/assets/icons/file-upload.svg +1 -0
- package/src/assets/icons/github.svg +1 -0
- package/src/assets/icons/install-step.svg +40 -0
- package/src/assets/icons/reset-password.svg +1 -0
- package/src/assets/icons/storage-aliyun.svg +1 -0
- package/src/assets/icons/storage-baidu.svg +1 -0
- package/src/assets/icons/storage-doge-cloud.svg +207 -0
- package/src/assets/icons/storage-ftp.svg +13 -0
- package/src/assets/icons/storage-google-drive.svg +8 -0
- package/src/assets/icons/storage-huawei.svg +1 -0
- package/src/assets/icons/storage-local.svg +11 -0
- package/src/assets/icons/storage-minio.svg +1 -0
- package/src/assets/icons/storage-onedrive-china.svg +18 -0
- package/src/assets/icons/storage-onedrive.svg +4 -0
- package/src/assets/icons/storage-open115.svg +23 -0
- package/src/assets/icons/storage-qiniu.svg +1 -0
- package/src/assets/icons/storage-s3.svg +5 -0
- package/src/assets/icons/storage-sftp.svg +13 -0
- package/src/assets/icons/storage-sharepoint-china.svg +23 -0
- package/src/assets/icons/storage-sharepoint.svg +1 -0
- package/src/assets/icons/storage-tencent.svg +9 -0
- package/src/assets/icons/storage-ufile.svg +14 -0
- package/src/assets/icons/storage-upyun.svg +1 -0
- package/src/assets/icons/storage-webdav.svg +1 -0
- package/src/assets/icons/upload.svg +50 -0
- package/src/assets/icons/zfile-basic.svg +17 -0
- package/src/assets/icons/zfile-horizontal.svg +16 -0
- package/src/assets/icons/zfile.svg +1 -0
- package/src/assets/vite.svg +1 -0
- package/src/assets/vue.svg +1 -0
- package/src/components/HelloWorld.vue +319 -0
- package/src/components/common/QrCodePreview.vue +118 -0
- package/src/components/common/dialog/ZDialog.vue +171 -0
- package/src/components/common/dialog/types.ts +19 -0
- package/src/components/common/dialog/useDialog.ts +18 -0
- package/src/components/common/dialog/useDialogWithForm.ts +21 -0
- package/src/components/copy.vue +133 -0
- package/src/components/file/preview/AudioPlayer.vue +333 -0
- package/src/components/file/preview/CopyCode.vue +47 -0
- package/src/components/file/preview/FileGallery.vue +199 -0
- package/src/components/file/preview/ImageViewer.vue +432 -0
- package/src/components/file/preview/KkFileViewer.vue +86 -0
- package/src/components/file/preview/KkFileViewerDialog.vue +42 -0
- package/src/components/file/preview/MarkdownViewer.vue +102 -0
- package/src/components/file/preview/MarkdownViewerAsyncLoading.vue +17 -0
- package/src/components/file/preview/MarkdownViewerDialogAsyncLoading.vue +12 -0
- package/src/components/file/preview/OfficeViewer.vue +76 -0
- package/src/components/file/preview/OfficeViewerDialog.vue +55 -0
- package/src/components/file/preview/PdfViewer.vue +157 -0
- package/src/components/file/preview/PdfViewerDialog.vue +41 -0
- package/src/components/file/preview/TextViewer.vue +232 -0
- package/src/components/file/preview/TextViewerAsyncLoading.vue +22 -0
- package/src/components/file/preview/TextViewerDialog.vue +53 -0
- package/src/components/file/preview/Three3dPreview.vue +114 -0
- package/src/components/file/preview/Three3dPreviewDialog.vue +50 -0
- package/src/components/file/preview/VideoPlayer.vue +341 -0
- package/src/components/file/preview/VideoPlayerAsyncLoading.vue +45 -0
- package/src/components/file/preview/VideoPlayerDialog.vue +51 -0
- package/src/components/file/selectFolder/SelectFolder.vue +208 -0
- package/src/components/file/selectFolder/index.ts +50 -0
- package/src/components/file/selectFolder/types.ts +5 -0
- package/src/components/fileReview/AudioPlayer-copy.vue +333 -0
- package/src/components/fileReview/PdfViewer-copy.vue +157 -0
- package/src/components/fileReview/TextViewer-copy.vue +44 -0
- package/src/components/fileReview/VideoPlayer-copy.vue +341 -0
- package/src/components/messageBox/confirm/confirm.vue +137 -0
- package/src/components/messageBox/confirm/index.ts +27 -0
- package/src/components/messageBox/confirm/types.ts +15 -0
- package/src/components/messageBox/messageBox.ts +9 -0
- package/src/components/messageBox/prompt/index.ts +27 -0
- package/src/components/messageBox/prompt/prompt.vue +178 -0
- package/src/components/messageBox/prompt/types.ts +24 -0
- package/src/components/vue-codemirror/editor.vue +212 -0
- package/src/components/vue-codemirror/encodings.ts +27 -0
- package/src/components/vue-codemirror/index.vue +380 -0
- package/src/components/vue-codemirror/lang-code/cpp/index.ts +3 -0
- package/src/components/vue-codemirror/lang-code/css/index.ts +2 -0
- package/src/components/vue-codemirror/lang-code/dockerfile/index.ts +5 -0
- package/src/components/vue-codemirror/lang-code/erlang/index.ts +6 -0
- package/src/components/vue-codemirror/lang-code/go/index.ts +5 -0
- package/src/components/vue-codemirror/lang-code/html/index.ts +3 -0
- package/src/components/vue-codemirror/lang-code/java/index.ts +3 -0
- package/src/components/vue-codemirror/lang-code/javascript/index.ts +3 -0
- package/src/components/vue-codemirror/lang-code/json/index.ts +3 -0
- package/src/components/vue-codemirror/lang-code/jsx/index.ts +3 -0
- package/src/components/vue-codemirror/lang-code/lua/index.ts +6 -0
- package/src/components/vue-codemirror/lang-code/markdown/index.ts +2 -0
- package/src/components/vue-codemirror/lang-code/mysql/index.ts +3 -0
- package/src/components/vue-codemirror/lang-code/nginx/index.ts +6 -0
- package/src/components/vue-codemirror/lang-code/perl/index.ts +5 -0
- package/src/components/vue-codemirror/lang-code/pgsql/index.ts +2 -0
- package/src/components/vue-codemirror/lang-code/php/index.ts +3 -0
- package/src/components/vue-codemirror/lang-code/powershell/index.ts +3 -0
- package/src/components/vue-codemirror/lang-code/python/index.ts +2 -0
- package/src/components/vue-codemirror/lang-code/r/index.ts +5 -0
- package/src/components/vue-codemirror/lang-code/ruby/index.ts +5 -0
- package/src/components/vue-codemirror/lang-code/rust/index.ts +2 -0
- package/src/components/vue-codemirror/lang-code/shell/index.ts +5 -0
- package/src/components/vue-codemirror/lang-code/sql/index.ts +3 -0
- package/src/components/vue-codemirror/lang-code/stylus/index.ts +3 -0
- package/src/components/vue-codemirror/lang-code/swift/index.ts +4 -0
- package/src/components/vue-codemirror/lang-code/toml/index.ts +3 -0
- package/src/components/vue-codemirror/lang-code/tsx/index.ts +2 -0
- package/src/components/vue-codemirror/lang-code/typescript/index.ts +2 -0
- package/src/components/vue-codemirror/lang-code/vb/index.ts +3 -0
- package/src/components/vue-codemirror/lang-code/vbscript/index.ts +3 -0
- package/src/components/vue-codemirror/lang-code/xml/index.ts +2 -0
- package/src/components/vue-codemirror/lang-code/yaml/index.ts +3 -0
- package/src/components/vue-codemirror/languages.ts +8 -0
- package/src/components/vue-codemirror/themes.ts +5 -0
- package/src/components/vue-codemirror/toolbar.vue +183 -0
- package/src/components/vue-codemirror/types.ts +12 -0
- package/src/components.d.ts +49 -0
- package/src/composables/admin/layout/admin-layout.js +53 -0
- package/src/composables/admin/link/useLinkSetting.js +16 -0
- package/src/composables/admin/sso/baseSsoConfig.js +54 -0
- package/src/composables/admin/sso/useSsoConfig.js +176 -0
- package/src/composables/admin/storage/storage-copy.js +89 -0
- package/src/composables/admin/storage/storage-filter.js +64 -0
- package/src/composables/admin/storage/storage-list.js +202 -0
- package/src/composables/admin/storage/storage-password.js +101 -0
- package/src/composables/admin/storage/storage-readme.js +102 -0
- package/src/composables/admin/storage/utils/open115-util.js +61 -0
- package/src/composables/admin/useAdminSetting.js +60 -0
- package/src/composables/admin/useClientInfo.js +20 -0
- package/src/composables/admin/user/user-copy.js +79 -0
- package/src/composables/file/useBatchOperatorResult.js +19 -0
- package/src/composables/file/useFileContextMenu.js +74 -0
- package/src/composables/file/useFileData.js +243 -0
- package/src/composables/file/useFileLink.js +175 -0
- package/src/composables/file/useFileLoading.js +41 -0
- package/src/composables/file/useFileLongPressEvent.js +71 -0
- package/src/composables/file/useFileOperator.js +347 -0
- package/src/composables/file/useFilePreview.js +99 -0
- package/src/composables/file/useFilePwd.js +138 -0
- package/src/composables/file/useFileSelect.js +105 -0
- package/src/composables/file/useFileShare.js +39 -0
- package/src/composables/file/useFileUpload.js +1045 -0
- package/src/composables/file/useKkFileViewDialog.js +24 -0
- package/src/composables/file/useOfficeViewerDialog.js +20 -0
- package/src/composables/file/usePdfViewerDialog.js +22 -0
- package/src/composables/file/useShareActions.js +94 -0
- package/src/composables/file/useShareTableOperator.js +84 -0
- package/src/composables/file/useTableOperator.js +211 -0
- package/src/composables/file/useTextViewerDialog.js +22 -0
- package/src/composables/file/useThree3dPreviewDialog.js +23 -0
- package/src/composables/file/useVideoPlayerDialog.js +19 -0
- package/src/composables/header/useHeaderBreadcrumb.js +111 -0
- package/src/composables/header/useHeaderStorageList.js +150 -0
- package/src/composables/header/useSetting.js +58 -0
- package/src/composables/share/useShareData.js +178 -0
- package/src/composables/useDarks.ts +4 -0
- package/src/composables/useRouterData.js +41 -0
- package/src/constant/index.js +193 -0
- package/src/http/index.js +153 -0
- package/src/http/request.js +31 -0
- package/src/main.ts +23 -0
- package/src/stores/file-data.ts +108 -0
- package/src/stores/global-config.ts +115 -0
- package/src/stores/storage-config.ts +123 -0
- package/src/style.css +296 -0
- package/src/styles/admin.scss +91 -0
- package/src/styles/code-editor-variables.scss +52 -0
- package/src/styles/element-plus.scss +22 -0
- package/src/styles/error-page.css +26 -0
- package/src/styles/main.css +142 -0
- package/src/styles/tailwind/index.scss +33 -0
- package/src/utils/index.ts +7 -0
- package/src/utils/models/base.ts +34 -0
- package/src/utils/models/file.ts +95 -0
- package/src/utils/models/path.ts +117 -0
- package/src/utils/models/qrcode.ts +21 -0
- package/src/utils/models/time.ts +132 -0
- package/src/utils/models/util.ts +42 -0
- package/src/utils/models/window.ts +14 -0
- package/stats.html +4950 -0
- package/tsconfig.app.json +16 -0
- package/tsconfig.json +7 -0
- package/tsconfig.node.json +26 -0
- package/vite.config.ts +57 -0
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
import axios from 'axios'
|
|
2
|
+
import {ElMessage} from 'element-plus';
|
|
3
|
+
// 修改后:延迟初始化或通过 pinia 实例获取
|
|
4
|
+
import { createPinia } from 'pinia';
|
|
5
|
+
import useGlobalConfigStore from '~/stores/global-config';
|
|
6
|
+
import MessageBox from "~/components/messageBox/messageBox";
|
|
7
|
+
const pinia = createPinia();
|
|
8
|
+
let globalConfigStore = useGlobalConfigStore(pinia);
|
|
9
|
+
// 创建 axios 的一个实例
|
|
10
|
+
const instance = axios.create({
|
|
11
|
+
baseURL: globalConfigStore.zfileConfig.baseUrl, //接口统一域名
|
|
12
|
+
timeout: 0, //设置超时
|
|
13
|
+
headers: {
|
|
14
|
+
'Content-Type': 'application/json;charset=UTF-8;',
|
|
15
|
+
},
|
|
16
|
+
})
|
|
17
|
+
|
|
18
|
+
// 请求拦截器
|
|
19
|
+
instance.interceptors.request.use((config) => {
|
|
20
|
+
// 每次发送请求之前判断是否存在 token,如果存在,则统一在 http 请求的 header 都加上 token,不用每次请求都手动添加了
|
|
21
|
+
let token = window.localStorage.getItem('zfile-token');
|
|
22
|
+
// 如果 token 不存在,则从 cookie 中获取
|
|
23
|
+
if (!token) {
|
|
24
|
+
const cookieToken = document.cookie.split('; ').find(row => row.startsWith('zfile-token='));
|
|
25
|
+
if (cookieToken) {
|
|
26
|
+
token = cookieToken.split('=')[1];
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
// 非外部链接,才增加 token 到请求头
|
|
30
|
+
if (!config.url.startsWith("http") || config.containToken === true) {
|
|
31
|
+
token && (config.headers['zfile-token'] = token)
|
|
32
|
+
config.headers['axios-request'] = true
|
|
33
|
+
config.headers['axios-from'] = globalConfigStore.serverAddress
|
|
34
|
+
}
|
|
35
|
+
// console.log('开始请求的 url 为:', config.url, '\n时间为:', new Date().getTime())
|
|
36
|
+
// requestTimeCache[config.url] = new Date().getTime();
|
|
37
|
+
console.time(config.url);
|
|
38
|
+
|
|
39
|
+
return config;
|
|
40
|
+
}, (error) =>
|
|
41
|
+
// 对请求错误做些什么
|
|
42
|
+
Promise.reject(error)
|
|
43
|
+
);
|
|
44
|
+
|
|
45
|
+
// 响应拦截器
|
|
46
|
+
instance.interceptors.response.use((response) => {
|
|
47
|
+
// console.log('结束请求的 url 为:', response.config.url, '\n时间为:', new Date().getTime(), '\n耗时为:', new Date().getTime() - requestTimeCache[response.config.url])
|
|
48
|
+
console.timeEnd(response.config.url);
|
|
49
|
+
// 如果不需要话执行响应拦截器, 直接返回
|
|
50
|
+
if (response.config.responseIntercept === false) {
|
|
51
|
+
return response;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
if (response.data.code !== constant.responseCode.SUCCESS) {
|
|
55
|
+
|
|
56
|
+
if (response.config.showDefaultMsg !== false) {
|
|
57
|
+
ElMessage({
|
|
58
|
+
type: 'error',
|
|
59
|
+
dangerouslyUseHTMLString: true,
|
|
60
|
+
grouping: true,
|
|
61
|
+
message: response.data.msg
|
|
62
|
+
})
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
return Promise.reject(response);
|
|
66
|
+
}
|
|
67
|
+
return response.data;
|
|
68
|
+
}, (error) => {
|
|
69
|
+
// 响应错误
|
|
70
|
+
if(error.response && error.response.status){
|
|
71
|
+
const responseDataCode = error.response.data.code;
|
|
72
|
+
|
|
73
|
+
if (responseDataCode === constant.responseCode.BAD_REQUEST) {
|
|
74
|
+
let errorObj = error.response.data.data;
|
|
75
|
+
|
|
76
|
+
let message;
|
|
77
|
+
if (errorObj) {
|
|
78
|
+
let keys = Object.keys(errorObj);
|
|
79
|
+
|
|
80
|
+
if (keys.length > 1) {
|
|
81
|
+
message = '非法参数!<br>';
|
|
82
|
+
keys.forEach((key) => {
|
|
83
|
+
message += `字段[${key}]: ${errorObj[key]}<br>`
|
|
84
|
+
})
|
|
85
|
+
} else {
|
|
86
|
+
message = errorObj[keys[0]];
|
|
87
|
+
}
|
|
88
|
+
} else {
|
|
89
|
+
message = error.response.data.msg;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
ElMessage({
|
|
93
|
+
type: 'error',
|
|
94
|
+
dangerouslyUseHTMLString: true,
|
|
95
|
+
grouping: true,
|
|
96
|
+
message: message
|
|
97
|
+
})
|
|
98
|
+
return Promise.reject(error);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
if (responseDataCode === constant.responseCode.UNAUTHORIZED) {
|
|
102
|
+
window.location.href = '/login?redirect=' + window.location.pathname + window.location.search + window.location.hash;
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
if (responseDataCode === constant.responseCode.FORBIDDEN) {
|
|
107
|
+
MessageBox.confirm('您没有权限访问此资源,是否前往登录?', '提示', {
|
|
108
|
+
confirmButtonText: '确定',
|
|
109
|
+
cancelButtonText: '取消',
|
|
110
|
+
type: 'warning'
|
|
111
|
+
}).then(() => {
|
|
112
|
+
window.location.href = '/login?redirect=' + window.location.pathname + window.location.search + window.location.hash;
|
|
113
|
+
}).catch(() => {
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
if (error.response.config.showDefaultMsg !== false) {
|
|
118
|
+
if (responseDataCode) {
|
|
119
|
+
if (responseDataCode.startsWith(constant.responseCode.PRO_CHECK_PREFIX)) {
|
|
120
|
+
MessageBox.confirm(`授权校验异常, 错误信息: <font color="red">${error.response.data.msg}</font>,是否前往后台查看授权设置?`, '提示', {
|
|
121
|
+
confirmButtonText: '确定',
|
|
122
|
+
cancelButtonText: '取消',
|
|
123
|
+
dangerouslyUseHTMLString: true,
|
|
124
|
+
type: 'info'
|
|
125
|
+
}).then(() => {
|
|
126
|
+
window.location.href = '/admin';
|
|
127
|
+
}).catch(() => {
|
|
128
|
+
});
|
|
129
|
+
} else {
|
|
130
|
+
ElMessage({
|
|
131
|
+
type: 'error',
|
|
132
|
+
grouping: true,
|
|
133
|
+
message: error.response.data.msg
|
|
134
|
+
})
|
|
135
|
+
}
|
|
136
|
+
} else {
|
|
137
|
+
let msg = '请求失败,请联系管理员';
|
|
138
|
+
if (error.response.status === 403) {
|
|
139
|
+
msg = error.response.data;
|
|
140
|
+
}
|
|
141
|
+
ElMessage({
|
|
142
|
+
type: 'error',
|
|
143
|
+
grouping: true,
|
|
144
|
+
message: msg
|
|
145
|
+
})
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
return Promise.reject(error);
|
|
149
|
+
}
|
|
150
|
+
return Promise.reject(error);
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
export default instance;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
// http/request.js
|
|
2
|
+
import instance from "~/http"
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* @param {String} method 请求的方法:get、post、delete、put
|
|
6
|
+
* @param {String} url 请求的url:
|
|
7
|
+
* @param {Object} data 请求的参数
|
|
8
|
+
* @param {Object} config 请求的配置
|
|
9
|
+
* @returns {Promise} 返回一个 promise 对象,其实就相当于 axios 请求数据的返回值
|
|
10
|
+
*/
|
|
11
|
+
const axios = ({
|
|
12
|
+
method,
|
|
13
|
+
url,
|
|
14
|
+
data,
|
|
15
|
+
config
|
|
16
|
+
}) => {
|
|
17
|
+
method = method.toLowerCase();
|
|
18
|
+
if (method === 'get') {
|
|
19
|
+
return instance.get(url, {params: data, ...config});
|
|
20
|
+
} else if (method === 'post') {
|
|
21
|
+
return instance.post(url, data, {...config})
|
|
22
|
+
} else if (method === 'put') {
|
|
23
|
+
return instance.put(url, data, {...config})
|
|
24
|
+
} else if (method === 'delete') {
|
|
25
|
+
return instance.delete(url, {params: data, ...config});
|
|
26
|
+
} else {
|
|
27
|
+
console.error('未知的 method:' + method)
|
|
28
|
+
return Promise.reject('不支持的 Method');
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
export default axios
|
package/src/main.ts
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
// src/main.ts
|
|
2
|
+
import { createApp } from 'vue'
|
|
3
|
+
import ElementPlus from 'element-plus'
|
|
4
|
+
import 'element-plus/dist/index.css'
|
|
5
|
+
import { createPinia } from 'pinia'
|
|
6
|
+
import App from './App.vue'
|
|
7
|
+
// 导出文件预览主组件
|
|
8
|
+
import HelloWorld from './components/HelloWorld.vue'
|
|
9
|
+
|
|
10
|
+
const app = createApp(App)
|
|
11
|
+
const pinia = createPinia()
|
|
12
|
+
|
|
13
|
+
export function install(app: any) {
|
|
14
|
+
app.component('FileViewer', HelloWorld)
|
|
15
|
+
}
|
|
16
|
+
// 默认导出(兼容多种引入方式)
|
|
17
|
+
export default {
|
|
18
|
+
install,
|
|
19
|
+
FileViewer: HelloWorld,
|
|
20
|
+
}
|
|
21
|
+
app.use(ElementPlus)
|
|
22
|
+
app.use(pinia)
|
|
23
|
+
// app.mount('#app')
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
// @ts-ignore
|
|
2
|
+
import { getFileType, getFileIconName } from "../utils";
|
|
3
|
+
import { defineStore } from 'pinia'
|
|
4
|
+
|
|
5
|
+
// @ts-ignore
|
|
6
|
+
import useStorageConfigStore from "./storage-config";
|
|
7
|
+
|
|
8
|
+
// 当前存储源的配置信息,数据来源为服务端配置。请求存储源后会获取其配置信息。
|
|
9
|
+
const useFileDataStore = defineStore('fileDataStore', {
|
|
10
|
+
state: () => {
|
|
11
|
+
return {
|
|
12
|
+
currentClickRow: {},
|
|
13
|
+
currentRightClickRow: {},
|
|
14
|
+
currentStorageSource: {
|
|
15
|
+
id: null,
|
|
16
|
+
type: {
|
|
17
|
+
description: '',
|
|
18
|
+
key: ''
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
imgMode: false,
|
|
22
|
+
newImgMode: false,
|
|
23
|
+
oldStorageKey: null,
|
|
24
|
+
searchParam: '',
|
|
25
|
+
fileListSource: [],
|
|
26
|
+
loadFileSize: -1,
|
|
27
|
+
audioArray: [],
|
|
28
|
+
audioIndex: 0,
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
getters: {
|
|
32
|
+
filterFileByType: (state) => {
|
|
33
|
+
return (type: string) => {
|
|
34
|
+
return state.fileListSource.filter(function (item:any) {
|
|
35
|
+
if (item.type === 'BACK') {
|
|
36
|
+
return false
|
|
37
|
+
}
|
|
38
|
+
let name = item.name;
|
|
39
|
+
let suffix = name.substr(name.lastIndexOf('.') + 1).toLowerCase();
|
|
40
|
+
return constant.fileTypeMap[type].indexOf(suffix) !== -1;
|
|
41
|
+
});
|
|
42
|
+
};
|
|
43
|
+
},
|
|
44
|
+
fileList: state => {
|
|
45
|
+
if (state.loadFileSize === -1) return [];
|
|
46
|
+
let firstIsBack = state.fileListSource[0]?.type === 'BACK';
|
|
47
|
+
let toSize = firstIsBack ? state.loadFileSize + 1 : state.loadFileSize;
|
|
48
|
+
toSize = toSize > state.fileListSource.length ? state.fileListSource.length : toSize;
|
|
49
|
+
let tableData = state.fileListSource.slice(0, toSize);
|
|
50
|
+
tableData.forEach((item:any) => {
|
|
51
|
+
// 生成图标
|
|
52
|
+
if (!item.icon) {
|
|
53
|
+
item['icon'] = getFileIconName(item);
|
|
54
|
+
}
|
|
55
|
+
if (item.preview !== null) {
|
|
56
|
+
// 获取文件类型
|
|
57
|
+
let fileType = getFileType(item.name);
|
|
58
|
+
if (fileType) {
|
|
59
|
+
// 获取文件是否可预览
|
|
60
|
+
item['fileType'] = fileType;
|
|
61
|
+
item.preview = constant.previewFileType.indexOf(fileType) !== -1;
|
|
62
|
+
} else {
|
|
63
|
+
item.preview = false;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
return tableData;
|
|
68
|
+
},
|
|
69
|
+
getFileUrlByName: state => {
|
|
70
|
+
return (name: string) => {
|
|
71
|
+
let item = state.fileListSource.find((item:any) => item.name === name);
|
|
72
|
+
if (item) {
|
|
73
|
+
return item.url;
|
|
74
|
+
}
|
|
75
|
+
return '';
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
},
|
|
79
|
+
actions: {
|
|
80
|
+
updateCurrentStorageSource(val: any) {
|
|
81
|
+
this.currentStorageSource = val;
|
|
82
|
+
},
|
|
83
|
+
updateAudioIndex(val: any) {
|
|
84
|
+
this.audioIndex = val;
|
|
85
|
+
},
|
|
86
|
+
updateAudioList(val: any) {
|
|
87
|
+
this.audioArray = val;
|
|
88
|
+
},
|
|
89
|
+
updateCurrentClickRow(val: any) {
|
|
90
|
+
this.currentClickRow = val;
|
|
91
|
+
},
|
|
92
|
+
updateCurrentRightClickRow(val: any) {
|
|
93
|
+
this.currentRightClickRow = val;
|
|
94
|
+
},
|
|
95
|
+
updateFileList(val: any) {
|
|
96
|
+
this.fileListSource = val;
|
|
97
|
+
this.loadFileSize = useStorageConfigStore().globalConfig.maxShowSize;
|
|
98
|
+
},
|
|
99
|
+
updateOldStorageKey(val: any) {
|
|
100
|
+
this.oldStorageKey = val;
|
|
101
|
+
},
|
|
102
|
+
updateLoadFileSize(val: number) {
|
|
103
|
+
this.loadFileSize = val;
|
|
104
|
+
}
|
|
105
|
+
},
|
|
106
|
+
})
|
|
107
|
+
|
|
108
|
+
export default useFileDataStore;
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { defineStore } from "pinia";
|
|
2
|
+
// @ts-ignore
|
|
3
|
+
import { isMobile } from "../utils";
|
|
4
|
+
import type { FormProps } from "element-plus";
|
|
5
|
+
|
|
6
|
+
// 全局配置信息, 初始化自 /public/zfile.config.json 文件中.
|
|
7
|
+
const useGlobalConfigStore = defineStore("globalConfigStore", {
|
|
8
|
+
state: () => {
|
|
9
|
+
return {
|
|
10
|
+
zfileConfig: {
|
|
11
|
+
baseUrl: "",
|
|
12
|
+
router: {
|
|
13
|
+
mode: "history"
|
|
14
|
+
},
|
|
15
|
+
skeleton: {
|
|
16
|
+
enable: true,
|
|
17
|
+
show: "always",
|
|
18
|
+
size: 20
|
|
19
|
+
},
|
|
20
|
+
gallery: {
|
|
21
|
+
mobileColumn: 5,
|
|
22
|
+
column: 3,
|
|
23
|
+
columnSpacing: 50,
|
|
24
|
+
rowSpacing: 10,
|
|
25
|
+
showInfo: true,
|
|
26
|
+
showInfoMode: "hover",
|
|
27
|
+
roundedBorder: true,
|
|
28
|
+
showBackTop: true
|
|
29
|
+
},
|
|
30
|
+
imagePreview: {
|
|
31
|
+
mode: "full",
|
|
32
|
+
gallery: true
|
|
33
|
+
},
|
|
34
|
+
officePreview: {},
|
|
35
|
+
admin: {
|
|
36
|
+
form: {
|
|
37
|
+
mobile: {
|
|
38
|
+
"size": "mini",
|
|
39
|
+
"labelWidth": "120px",
|
|
40
|
+
"labelPosition": "left",
|
|
41
|
+
},
|
|
42
|
+
pc: {
|
|
43
|
+
"size": "mini",
|
|
44
|
+
"labelWidth": "120px",
|
|
45
|
+
"labelPosition": "left",
|
|
46
|
+
}
|
|
47
|
+
},
|
|
48
|
+
search: {
|
|
49
|
+
mobile: {
|
|
50
|
+
size: "mini",
|
|
51
|
+
spanSize: 16,
|
|
52
|
+
},
|
|
53
|
+
pc: {
|
|
54
|
+
size: "mini",
|
|
55
|
+
spanSize: 8,
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
table: {
|
|
59
|
+
mobile: {
|
|
60
|
+
"size": "default",
|
|
61
|
+
"pager": {
|
|
62
|
+
"size": "small",
|
|
63
|
+
"background": true,
|
|
64
|
+
"layout": "prev, pager, next",
|
|
65
|
+
"pagerCount": 5
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
pc: {
|
|
69
|
+
"size": "default",
|
|
70
|
+
"pager": {
|
|
71
|
+
"size": "default",
|
|
72
|
+
"background": true,
|
|
73
|
+
"layout": "total, sizes, prev, pager, next, jumper",
|
|
74
|
+
"pagerCount": 5
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
},
|
|
82
|
+
actions: {
|
|
83
|
+
updateZfileConfig(val: any) {
|
|
84
|
+
this.zfileConfig = val;
|
|
85
|
+
}
|
|
86
|
+
},
|
|
87
|
+
getters: {
|
|
88
|
+
serverAddress(): string {
|
|
89
|
+
return this.zfileConfig.baseUrl || window.location.origin;
|
|
90
|
+
},
|
|
91
|
+
frontAddress() {
|
|
92
|
+
return window.location.origin;
|
|
93
|
+
},
|
|
94
|
+
adminForm(): FormProps {
|
|
95
|
+
return isMobile.value ?
|
|
96
|
+
this.zfileConfig.admin.form.mobile as FormProps
|
|
97
|
+
:
|
|
98
|
+
this.zfileConfig.admin.form.pc as FormProps;
|
|
99
|
+
},
|
|
100
|
+
adminSearch(): any {
|
|
101
|
+
return isMobile.value ?
|
|
102
|
+
this.zfileConfig.admin.search.mobile
|
|
103
|
+
:
|
|
104
|
+
this.zfileConfig.admin.search.pc;
|
|
105
|
+
},
|
|
106
|
+
adminTable(): any {
|
|
107
|
+
return isMobile.value ?
|
|
108
|
+
this.zfileConfig.admin.table.mobile
|
|
109
|
+
:
|
|
110
|
+
this.zfileConfig.admin.table.pc;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
export default useGlobalConfigStore;
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { defineStore } from "pinia";
|
|
2
|
+
|
|
3
|
+
import useFileSelect from "~/composables/file/useFileSelect";
|
|
4
|
+
|
|
5
|
+
let { selectStatistics } = useFileSelect();
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
// 当前存储源的配置信息,数据来源为服务端配置。请求存储源后会获取其配置信息。
|
|
9
|
+
const useStorageConfigStore = defineStore('storageConfigStore', {
|
|
10
|
+
state: () => {
|
|
11
|
+
return {
|
|
12
|
+
globalConfig: {
|
|
13
|
+
siteName: '',
|
|
14
|
+
directLinkPrefix: '',
|
|
15
|
+
infoEnable: false,
|
|
16
|
+
showLinkBtn: false,
|
|
17
|
+
recordDownloadLog: false,
|
|
18
|
+
showShortLink: false,
|
|
19
|
+
showPathLink: false,
|
|
20
|
+
tableSize: 'small',
|
|
21
|
+
rootShowStorage: true,
|
|
22
|
+
fileClickMode: 'dbclick',
|
|
23
|
+
mobileFileClickMode: 'dbclick',
|
|
24
|
+
showDocument: false,
|
|
25
|
+
debugMode: false,
|
|
26
|
+
icp: '',
|
|
27
|
+
announcement: '',
|
|
28
|
+
layout: 'full',
|
|
29
|
+
mobileLayout: 'full',
|
|
30
|
+
showAnnouncement: false,
|
|
31
|
+
searchEnable: false,
|
|
32
|
+
showLogin: false,
|
|
33
|
+
siteHomeName: '首页',
|
|
34
|
+
siteHomeLogo: '',
|
|
35
|
+
siteHomeLogoLink: '',
|
|
36
|
+
siteHomeLogoTargetMode: '',
|
|
37
|
+
maxShowSize: 1000,
|
|
38
|
+
loadMoreSize: 50,
|
|
39
|
+
defaultSortField: 'name',
|
|
40
|
+
defaultSortOrder: 'asc',
|
|
41
|
+
linkExpireTimes: '',
|
|
42
|
+
forceBackendAddress: '',
|
|
43
|
+
enableNormalDownloadConfirm: true,
|
|
44
|
+
},
|
|
45
|
+
loginInfo: {
|
|
46
|
+
isLogin: null,
|
|
47
|
+
isAdmin: null,
|
|
48
|
+
username: '',
|
|
49
|
+
nickname: ''
|
|
50
|
+
},
|
|
51
|
+
folderConfig: {
|
|
52
|
+
readmeText: null,
|
|
53
|
+
proxyUpload: false,
|
|
54
|
+
readmeDisplayMode: null,
|
|
55
|
+
defaultSwitchToImgMode: false,
|
|
56
|
+
permission: {
|
|
57
|
+
preview: true,
|
|
58
|
+
},
|
|
59
|
+
metadata: {
|
|
60
|
+
uploadType: null,
|
|
61
|
+
supportRenameFolder: null,
|
|
62
|
+
supportMoveFolder: null,
|
|
63
|
+
supportCopyFolder: null,
|
|
64
|
+
supportDeleteNotEmptyFolder: null,
|
|
65
|
+
needCreateFolderBeforeUpload: null,
|
|
66
|
+
},
|
|
67
|
+
rootPath: null,
|
|
68
|
+
},
|
|
69
|
+
user: {
|
|
70
|
+
rootPath: '',
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
},
|
|
74
|
+
getters: {
|
|
75
|
+
permission: (state) => {
|
|
76
|
+
let originPermission = state.folderConfig.permission;
|
|
77
|
+
// 当全局允许使用直链,且当前用户有直链权限时,才显示直链按钮
|
|
78
|
+
let pathLink = state.globalConfig.showPathLink && originPermission.generateLink;
|
|
79
|
+
let shortLink = state.globalConfig.showShortLink && originPermission.generateShortLink;
|
|
80
|
+
let download = originPermission.download && selectStatistics.value.isAllFile;
|
|
81
|
+
return {
|
|
82
|
+
open: selectStatistics.value.isSingleSelectFolder,
|
|
83
|
+
preview: originPermission.preview && selectStatistics.value.isSingleSelectFile,
|
|
84
|
+
download: download,
|
|
85
|
+
copyDownloadLink: download && originPermission.copyDownloadLink,
|
|
86
|
+
rename: originPermission.rename && selectStatistics.value.isSingleSelect,
|
|
87
|
+
|
|
88
|
+
link: (pathLink || shortLink) && selectStatistics.value.isAllFile,
|
|
89
|
+
pathLink: pathLink,
|
|
90
|
+
shortLink: shortLink,
|
|
91
|
+
bothLink: (pathLink && shortLink) && selectStatistics.value.isAllFile,
|
|
92
|
+
|
|
93
|
+
copy: originPermission.copy,
|
|
94
|
+
move: originPermission.move,
|
|
95
|
+
delete: originPermission.delete,
|
|
96
|
+
upload: originPermission.upload,
|
|
97
|
+
uploadFolder: originPermission.upload && originPermission.newFolder,
|
|
98
|
+
search: originPermission.search,
|
|
99
|
+
newFolder: originPermission.newFolder,
|
|
100
|
+
batchDownload: download && originPermission.batchDownload,
|
|
101
|
+
packageDownload: download && originPermission.packageDownload,
|
|
102
|
+
createShareLink: originPermission.createShareLink,
|
|
103
|
+
customShareKey: originPermission.customShareKey
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
},
|
|
107
|
+
actions: {
|
|
108
|
+
updateUserRootPath(val: string) {
|
|
109
|
+
this.user.rootPath = val;
|
|
110
|
+
},
|
|
111
|
+
updateGlobalConfig(val: any) {
|
|
112
|
+
this.globalConfig = val;
|
|
113
|
+
},
|
|
114
|
+
updateFolderConfig(val: any) {
|
|
115
|
+
this.folderConfig = val;
|
|
116
|
+
},
|
|
117
|
+
updateLoginInfo(val: any) {
|
|
118
|
+
this.loginInfo = val;
|
|
119
|
+
},
|
|
120
|
+
},
|
|
121
|
+
})
|
|
122
|
+
|
|
123
|
+
export default useStorageConfigStore;
|