@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,178 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<TransitionRoot as="template" :show="show">
|
|
3
|
+
<Dialog as="div" class="zfile-prompt-dialog" @close="handlerClose('close')">
|
|
4
|
+
<TransitionChild as="template" enter="ease-out duration-300" enter-from="opacity-0" enter-to="opacity-100" leave="ease-in duration-200" leave-from="opacity-100" leave-to="opacity-0">
|
|
5
|
+
<div class="fixed inset-0 bg-gray-500 bg-opacity-75 transition-opacity" />
|
|
6
|
+
</TransitionChild>
|
|
7
|
+
|
|
8
|
+
<div class="fixed inset-0 z-10 overflow-y-auto">
|
|
9
|
+
<div class="flex min-h-full items-end justify-center p-4 text-center sm:items-center sm:p-0">
|
|
10
|
+
<TransitionChild as="template" enter="ease-out duration-300" enter-from="opacity-0 translate-y-4 sm:translate-y-0 sm:scale-95" enter-to="opacity-100 translate-y-0 sm:scale-100" leave="ease-in duration-200" leave-from="opacity-100 translate-y-0 sm:scale-100" leave-to="opacity-0 translate-y-4 sm:translate-y-0 sm:scale-95">
|
|
11
|
+
<DialogPanel class="relative transform overflow-hidden rounded-lg bg-white px-4 pb-4 pt-5 text-left shadow-xl transition-all sm:my-8 w-11/12 max-w-sm sm:w-full sm:max-w-md sm:p-6">
|
|
12
|
+
<div class="absolute right-0 top-0 hidden pr-4 pt-4 sm:block">
|
|
13
|
+
<div type="button" class="rounded-md bg-white text-gray-400 hover:text-gray-500 focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2" @click="handlerClose('close')">
|
|
14
|
+
<span class="sr-only">Close</span>
|
|
15
|
+
<XMarkIcon class="h-6 w-6" aria-hidden="true" />
|
|
16
|
+
</div>
|
|
17
|
+
</div>
|
|
18
|
+
<div class="sm:flex sm:items-start">
|
|
19
|
+
<div class="mx-auto flex h-12 w-12 flex-shrink-0 items-center justify-center rounded-full bg-blue-100 sm:mx-0 sm:h-10 sm:w-10">
|
|
20
|
+
<PencilIcon class="h-6 w-6 text-blue-600" aria-hidden="true" />
|
|
21
|
+
</div>
|
|
22
|
+
<div class="mt-3 text-center sm:ml-4 sm:mt-0 sm:text-left w-full space-y-1">
|
|
23
|
+
<DialogTitle as="h3" class="text-base font-semibold leading-6 text-gray-900">{{ title }}</DialogTitle>
|
|
24
|
+
<div>
|
|
25
|
+
<p class="text-gray-500 text-sm" v-if="dangerouslyUseHTMLString" v-html="message"></p>
|
|
26
|
+
<p class="text-gray-500 text-sm" v-else>{{ message }}</p>
|
|
27
|
+
</div>
|
|
28
|
+
<el-input :placeholder="inputPlaceholder"
|
|
29
|
+
v-model="form.inputModel"
|
|
30
|
+
:type="inputType"
|
|
31
|
+
@keyup.enter="handlerClose('confirm')"
|
|
32
|
+
:autofocus="true"
|
|
33
|
+
:show-password="inputType === 'password' && showPassword"
|
|
34
|
+
class="h-10"></el-input>
|
|
35
|
+
<div class="text-red-500 text-sm text-left" v-if="errorFields?.inputModel?.length">{{ errorFields.inputModel[0].message }}</div>
|
|
36
|
+
</div>
|
|
37
|
+
</div>
|
|
38
|
+
<div
|
|
39
|
+
:class="checkbox ? 'sm:justify-between' : 'sm:justify-end'"
|
|
40
|
+
class="mt-5 sm:mt-4 sm:flex">
|
|
41
|
+
<div class="sm:ml-14" v-if="checkbox">
|
|
42
|
+
<el-checkbox v-model="form.checkboxModel">{{ checkboxLabel }}</el-checkbox>
|
|
43
|
+
</div>
|
|
44
|
+
<div class="space-y-4 sm:space-y-0 sm:space-x-2">
|
|
45
|
+
<button type="button"
|
|
46
|
+
class="mt-3 inline-flex w-full justify-center rounded-md bg-white px-3 py-2 text-sm font-semibold text-gray-900 shadow-sm ring-1 ring-inset ring-gray-300 hover:bg-gray-50 sm:mt-0 sm:w-auto"
|
|
47
|
+
@click="handlerClose('cancel')">
|
|
48
|
+
{{ props.cancelButtonText }}
|
|
49
|
+
</button>
|
|
50
|
+
<button :disabled="!pass" type="button"
|
|
51
|
+
:class="pass ? '' : 'cursor-not-allowed opacity-50'"
|
|
52
|
+
class="inline-flex w-full justify-center rounded-md bg-blue-500 px-3 py-2 text-sm font-semibold text-white shadow-sm hover:bg-blue-400 sm:ml-3 sm:w-auto" @click="handlerClose('confirm')">
|
|
53
|
+
{{ confirmButtonText }}
|
|
54
|
+
</button>
|
|
55
|
+
</div>
|
|
56
|
+
</div>
|
|
57
|
+
</DialogPanel>
|
|
58
|
+
</TransitionChild>
|
|
59
|
+
</div>
|
|
60
|
+
</div>
|
|
61
|
+
</Dialog>
|
|
62
|
+
</TransitionRoot>
|
|
63
|
+
</template>
|
|
64
|
+
|
|
65
|
+
<script lang="ts" setup>
|
|
66
|
+
import {
|
|
67
|
+
Dialog,
|
|
68
|
+
DialogPanel,
|
|
69
|
+
DialogTitle,
|
|
70
|
+
TransitionChild,
|
|
71
|
+
TransitionRoot
|
|
72
|
+
} from "@headlessui/vue";
|
|
73
|
+
import { XMarkIcon, PencilIcon } from '@heroicons/vue/24/outline'
|
|
74
|
+
import { useAsyncValidator } from '@vueuse/integrations/useAsyncValidator'
|
|
75
|
+
import { Rules } from "async-validator";
|
|
76
|
+
import { ConfirmResult } from "./types";
|
|
77
|
+
import { ElCheckbox, ElInput } from "element-plus";
|
|
78
|
+
|
|
79
|
+
const props = defineProps({
|
|
80
|
+
show: {
|
|
81
|
+
type: Boolean,
|
|
82
|
+
default: false
|
|
83
|
+
},
|
|
84
|
+
title: {
|
|
85
|
+
type: String,
|
|
86
|
+
required: true,
|
|
87
|
+
},
|
|
88
|
+
message: {
|
|
89
|
+
type: String,
|
|
90
|
+
required: true,
|
|
91
|
+
},
|
|
92
|
+
confirmButtonText: {
|
|
93
|
+
type: String,
|
|
94
|
+
default: 'Confirm',
|
|
95
|
+
},
|
|
96
|
+
cancelButtonText: {
|
|
97
|
+
type: String,
|
|
98
|
+
default: 'Cancel',
|
|
99
|
+
},
|
|
100
|
+
checkbox: {
|
|
101
|
+
type: Boolean,
|
|
102
|
+
default: false,
|
|
103
|
+
},
|
|
104
|
+
checkboxLabel: {
|
|
105
|
+
type: String,
|
|
106
|
+
default: 'Remember me',
|
|
107
|
+
},
|
|
108
|
+
defaultChecked: {
|
|
109
|
+
type: Boolean,
|
|
110
|
+
default: false,
|
|
111
|
+
},
|
|
112
|
+
inputType: {
|
|
113
|
+
type: String,
|
|
114
|
+
default: 'text',
|
|
115
|
+
},
|
|
116
|
+
inputDefault: {
|
|
117
|
+
type: String,
|
|
118
|
+
default: ''
|
|
119
|
+
},
|
|
120
|
+
inputPlaceholder: {
|
|
121
|
+
type: String,
|
|
122
|
+
default: '请输入',
|
|
123
|
+
},
|
|
124
|
+
showPassword: {
|
|
125
|
+
type: Boolean,
|
|
126
|
+
default: true,
|
|
127
|
+
},
|
|
128
|
+
inputValidator: {
|
|
129
|
+
type: Function,
|
|
130
|
+
default: () => true,
|
|
131
|
+
},
|
|
132
|
+
inputErrorMessage: {
|
|
133
|
+
type: String,
|
|
134
|
+
default: 'input error',
|
|
135
|
+
},
|
|
136
|
+
onClose: {
|
|
137
|
+
type: Function,
|
|
138
|
+
default: () => {}
|
|
139
|
+
},
|
|
140
|
+
dangerouslyUseHTMLString: {
|
|
141
|
+
type: Boolean,
|
|
142
|
+
default: false,
|
|
143
|
+
}
|
|
144
|
+
})
|
|
145
|
+
|
|
146
|
+
|
|
147
|
+
// 表单数据和校验规则
|
|
148
|
+
const form = ref({ inputModel: props.inputDefault!, checkboxModel: props.defaultChecked! })
|
|
149
|
+
const rules:Rules = {
|
|
150
|
+
inputModel: {
|
|
151
|
+
type: 'string',
|
|
152
|
+
required: true,
|
|
153
|
+
message: props.inputErrorMessage
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
const { pass, errorFields } = useAsyncValidator(form, rules)
|
|
158
|
+
|
|
159
|
+
// 响应关闭事件
|
|
160
|
+
const emit = defineEmits(['update:show'])
|
|
161
|
+
const handlerClose = (type: 'cancel' | 'close' | 'confirm') => {
|
|
162
|
+
const result:ConfirmResult = {
|
|
163
|
+
checkbox: form.value.checkboxModel,
|
|
164
|
+
value: form.value.inputModel,
|
|
165
|
+
type
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
emit('update:show', false)
|
|
169
|
+
props.onClose!(result)
|
|
170
|
+
}
|
|
171
|
+
</script>
|
|
172
|
+
|
|
173
|
+
<style lang="scss">
|
|
174
|
+
.zfile-prompt-dialog {
|
|
175
|
+
position: relative;
|
|
176
|
+
z-index: 3000;
|
|
177
|
+
}
|
|
178
|
+
</style>
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
export interface ConfirmResult {
|
|
4
|
+
checkbox: boolean;
|
|
5
|
+
value: string;
|
|
6
|
+
type: 'cancel' | 'close' | 'confirm';
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export interface Props {
|
|
10
|
+
title?: string;
|
|
11
|
+
message?: string;
|
|
12
|
+
confirmButtonText?: string;
|
|
13
|
+
cancelButtonText?: string;
|
|
14
|
+
inputType?: "text" | "password";
|
|
15
|
+
inputPlaceholder?: string;
|
|
16
|
+
inputDefault?: string;
|
|
17
|
+
showPassword?: boolean;
|
|
18
|
+
checkbox?: boolean;
|
|
19
|
+
checkboxLabel?: string;
|
|
20
|
+
defaultChecked?: boolean;
|
|
21
|
+
inputValidator?: Function;
|
|
22
|
+
inputErrorMessage?: string;
|
|
23
|
+
dangerouslyUseHTMLString?: boolean;
|
|
24
|
+
}
|
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="editor">
|
|
3
|
+
<div class="main">
|
|
4
|
+
<codemirror
|
|
5
|
+
v-model="code"
|
|
6
|
+
:style="{
|
|
7
|
+
width: '100%',
|
|
8
|
+
height: config.height,
|
|
9
|
+
backgroundColor: '#fff',
|
|
10
|
+
color: '#333'
|
|
11
|
+
}"
|
|
12
|
+
placeholder="Please enter the code."
|
|
13
|
+
:extensions="extensions"
|
|
14
|
+
:autofocus="config.autofocus"
|
|
15
|
+
:disabled="config.readonly"
|
|
16
|
+
:indent-with-tab="config.indentWithTab"
|
|
17
|
+
:tab-size="config.tabSize"
|
|
18
|
+
@update="handleStateUpdate"
|
|
19
|
+
@ready="handleReady"
|
|
20
|
+
@focus="log('focus', $event)"
|
|
21
|
+
@blur="log('blur', $event)"
|
|
22
|
+
/>
|
|
23
|
+
</div>
|
|
24
|
+
<div class="divider"></div>
|
|
25
|
+
<div class="footer">
|
|
26
|
+
<div class="buttons" :class="{ 'invisible': config.readonly }">
|
|
27
|
+
<!-- <el-tooltip content="也可以使用快捷键 Ctrl/⌘ + S 保存" placement="top">
|
|
28
|
+
<button class="item" @click="saveFile">保存</button>
|
|
29
|
+
</el-tooltip> -->
|
|
30
|
+
</div>
|
|
31
|
+
<div class="infos">
|
|
32
|
+
<span class="item">空格: {{ config.tabSize }}</span>
|
|
33
|
+
<span class="item">总长度: {{ state.length }}</span>
|
|
34
|
+
<span class="item">行数: {{ state.lines }}</span>
|
|
35
|
+
<span class="item">光标: {{ state.cursor }}</span>
|
|
36
|
+
<span class="item">选中: {{ state.selected }}</span>
|
|
37
|
+
</div>
|
|
38
|
+
</div>
|
|
39
|
+
</div>
|
|
40
|
+
</template>
|
|
41
|
+
|
|
42
|
+
<script lang="ts" setup>
|
|
43
|
+
import { ref, computed, watch, onMounted, reactive } from 'vue'
|
|
44
|
+
import { EditorView, ViewUpdate } from '@codemirror/view'
|
|
45
|
+
import { Codemirror } from 'vue-codemirror'
|
|
46
|
+
import type { PropType } from "vue";
|
|
47
|
+
import type { ToolBarConfig } from "./types";
|
|
48
|
+
import { Compartment, EditorState } from "@codemirror/state";
|
|
49
|
+
const lineWrappingComp = new Compartment();
|
|
50
|
+
import { ElTooltip } from "element-plus";
|
|
51
|
+
import iconv from 'iconv-lite';
|
|
52
|
+
|
|
53
|
+
const props = defineProps({
|
|
54
|
+
fileName: {
|
|
55
|
+
type: String,
|
|
56
|
+
required: true
|
|
57
|
+
},
|
|
58
|
+
config: {
|
|
59
|
+
type: Object as PropType<ToolBarConfig>,
|
|
60
|
+
required: true
|
|
61
|
+
},
|
|
62
|
+
code: {
|
|
63
|
+
type: String,
|
|
64
|
+
required: true
|
|
65
|
+
},
|
|
66
|
+
theme: [Object, Array],
|
|
67
|
+
language: Function
|
|
68
|
+
})
|
|
69
|
+
|
|
70
|
+
const log = console.log
|
|
71
|
+
const code = ref(props.code)
|
|
72
|
+
const extensions = computed(() => {
|
|
73
|
+
const result = []
|
|
74
|
+
|
|
75
|
+
if (props.config.lineWrapping) {
|
|
76
|
+
result.push(lineWrappingComp.of(EditorView.lineWrapping))
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
if (props.language) {
|
|
80
|
+
result.push(props.language())
|
|
81
|
+
}
|
|
82
|
+
if (props.theme) {
|
|
83
|
+
result.push(props.theme)
|
|
84
|
+
}
|
|
85
|
+
return result
|
|
86
|
+
})
|
|
87
|
+
|
|
88
|
+
const cmView = ref<EditorView>()
|
|
89
|
+
const cmState = ref<EditorState>()
|
|
90
|
+
const handleReady = ({ view, state }: { view: EditorView, state: EditorState }) => {
|
|
91
|
+
cmView.value = view
|
|
92
|
+
cmState.value = state
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
const state = reactive({
|
|
96
|
+
lines: null as null | number,
|
|
97
|
+
cursor: null as null | number,
|
|
98
|
+
selected: null as null | number,
|
|
99
|
+
length: null as null | number
|
|
100
|
+
})
|
|
101
|
+
|
|
102
|
+
// 当编辑器状态更新时,更新选中、光标、长度等信息
|
|
103
|
+
const handleStateUpdate = (viewUpdate: ViewUpdate) => {
|
|
104
|
+
// selected
|
|
105
|
+
const ranges = viewUpdate.state.selection.ranges
|
|
106
|
+
state.selected = ranges.reduce((plus, range) => plus + range.to - range.from, 0)
|
|
107
|
+
state.cursor = ranges[0].anchor
|
|
108
|
+
// length
|
|
109
|
+
state.length = viewUpdate.state.doc.length
|
|
110
|
+
state.lines = viewUpdate.state.doc.lines
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
onMounted(() => {
|
|
114
|
+
watch(
|
|
115
|
+
() => props.code,
|
|
116
|
+
(_code) => {
|
|
117
|
+
code.value = _code
|
|
118
|
+
}
|
|
119
|
+
)
|
|
120
|
+
})
|
|
121
|
+
|
|
122
|
+
// vue use 监听保存快捷键
|
|
123
|
+
import { useEventListener } from '@vueuse/core'
|
|
124
|
+
useEventListener(window, 'keydown', (event) => {
|
|
125
|
+
if ((event.ctrlKey || event.metaKey) && event.key === 's') {
|
|
126
|
+
event.preventDefault();
|
|
127
|
+
// saveFile()
|
|
128
|
+
}
|
|
129
|
+
})
|
|
130
|
+
|
|
131
|
+
// 保存文件方法
|
|
132
|
+
// import useFileUpload from "~/composables/file/useFileUpload";
|
|
133
|
+
// const { silentUploadFile } = useFileUpload();
|
|
134
|
+
// const saveFile = () => {
|
|
135
|
+
// if (props.config?.disabled) {
|
|
136
|
+
// ElMessage.warning('只读状态下不允许保存文件');
|
|
137
|
+
// return;
|
|
138
|
+
// }
|
|
139
|
+
|
|
140
|
+
// const file = new File([iconv.encode(code.value, props.config.encoding)], props.fileName, { type: 'text/plain' });
|
|
141
|
+
// silentUploadFile(file)
|
|
142
|
+
// }
|
|
143
|
+
</script>
|
|
144
|
+
|
|
145
|
+
<style lang="scss" scoped>
|
|
146
|
+
@import '~/styles/code-editor-variables.scss';
|
|
147
|
+
.editor {
|
|
148
|
+
|
|
149
|
+
:deep(.cm-editor) {
|
|
150
|
+
@apply h-[50vh] sm:h-[60vh] lg:h-[65vh];
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
.divider {
|
|
154
|
+
height: 1px;
|
|
155
|
+
background-color: $border-color;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
.main {
|
|
159
|
+
display: flex;
|
|
160
|
+
width: 100%;
|
|
161
|
+
text-align: left;
|
|
162
|
+
.code {
|
|
163
|
+
width: 30%;
|
|
164
|
+
height: 100px;
|
|
165
|
+
margin: 0;
|
|
166
|
+
padding: 0.4em;
|
|
167
|
+
overflow: scroll;
|
|
168
|
+
border-left: 1px solid $border-color;
|
|
169
|
+
font-family: monospace;
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
.footer {
|
|
174
|
+
height: 3rem;
|
|
175
|
+
display: flex;
|
|
176
|
+
justify-content: space-between;
|
|
177
|
+
align-items: center;
|
|
178
|
+
font-size: 90%;
|
|
179
|
+
width: 100%;
|
|
180
|
+
@apply max-sm:flex-col;
|
|
181
|
+
|
|
182
|
+
.buttons {
|
|
183
|
+
@apply max-sm:w-full space-x-3;
|
|
184
|
+
.item {
|
|
185
|
+
display: inline-flex;
|
|
186
|
+
justify-content: center;
|
|
187
|
+
align-items: center;
|
|
188
|
+
background-color: transparent;
|
|
189
|
+
border: 1px dashed $border-color;
|
|
190
|
+
font-size: $font-size-small;
|
|
191
|
+
color: $text-secondary;
|
|
192
|
+
cursor: pointer;
|
|
193
|
+
.iconfont {
|
|
194
|
+
margin-left: $xs-gap;
|
|
195
|
+
}
|
|
196
|
+
&:hover {
|
|
197
|
+
color: $text-color;
|
|
198
|
+
border-color: $text-color;
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
.infos {
|
|
204
|
+
@apply max-sm:w-full space-x-3;
|
|
205
|
+
.item {
|
|
206
|
+
display: inline-block;
|
|
207
|
+
font-feature-settings: 'tnum';
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
</style>
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export default {
|
|
2
|
+
"UTF-8": "UTF-8",
|
|
3
|
+
"GB18030": "GB18030",
|
|
4
|
+
"GBK": "GBK",
|
|
5
|
+
"GB2312": "GB2312",
|
|
6
|
+
"UTF-16LE": "UTF-16LE",
|
|
7
|
+
"UTF-16BE": "UTF-16BE",
|
|
8
|
+
"UTF-32LE": "UTF-32LE",
|
|
9
|
+
"UTF-32BE": "UTF-32BE",
|
|
10
|
+
"UTF-7": "UTF-7",
|
|
11
|
+
"UTF-1": "UTF-1",
|
|
12
|
+
"UTF-EBCDIC": "UTF-EBCDIC",
|
|
13
|
+
"SCSU": "SCSU",
|
|
14
|
+
"BOCU-1": "BOCU-1",
|
|
15
|
+
"CP1250": "CP1250",
|
|
16
|
+
"CP1251": "CP1251",
|
|
17
|
+
"CP1252": "CP1252",
|
|
18
|
+
"CP1253": "CP1253",
|
|
19
|
+
"CP1254": "CP1254",
|
|
20
|
+
"CP1255": "CP1255",
|
|
21
|
+
"CP1256": "CP1256",
|
|
22
|
+
"CP1257": "CP1257",
|
|
23
|
+
"BIG5": "BIG5",
|
|
24
|
+
"Shift-JIS": "Shift-JIS",
|
|
25
|
+
"EUC-KR": "EUC-KR",
|
|
26
|
+
"TIS-620": "TIS-620"
|
|
27
|
+
}
|