@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,380 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="example" ref="codemirrorRef">
|
|
3
|
+
<!-- <toolbar
|
|
4
|
+
:config="config"
|
|
5
|
+
:themes="Object.keys(themes)"
|
|
6
|
+
:languages="Object.keys(languages)"
|
|
7
|
+
:encodings="encodings"
|
|
8
|
+
:disabled="config.disabled"
|
|
9
|
+
:readonly="config.readonly"
|
|
10
|
+
@encoding="ensureEncoding"
|
|
11
|
+
@language="ensureLanguageCode" /> -->
|
|
12
|
+
<div class="divider"></div>
|
|
13
|
+
<editor
|
|
14
|
+
v-if="modelValue"
|
|
15
|
+
:fileName="fileName"
|
|
16
|
+
:config="config"
|
|
17
|
+
:theme="currentTheme"
|
|
18
|
+
:language="currentLangCode"
|
|
19
|
+
:code="encodeModelValue" />
|
|
20
|
+
</div>
|
|
21
|
+
</template>
|
|
22
|
+
|
|
23
|
+
<script setup lang="ts">
|
|
24
|
+
import { ref, computed, reactive, onBeforeMount, onMounted, defineProps, onBeforeUnmount } from "vue";
|
|
25
|
+
import languageEncoding from "detect-file-encoding-and-language";
|
|
26
|
+
import languages from './languages'
|
|
27
|
+
import encodings from './encodings'
|
|
28
|
+
import themes from './themes'
|
|
29
|
+
import Toolbar from './toolbar.vue'
|
|
30
|
+
import Editor from './editor.vue'
|
|
31
|
+
import { ToolBarConfig } from "./types";
|
|
32
|
+
|
|
33
|
+
const config:ToolBarConfig = reactive({
|
|
34
|
+
disabled: false,
|
|
35
|
+
readonly: false,
|
|
36
|
+
indentWithTab: true,
|
|
37
|
+
tabSize: 4,
|
|
38
|
+
autofocus: true,
|
|
39
|
+
height: '60vh',
|
|
40
|
+
language: 'javascript',
|
|
41
|
+
encoding: 'UTF-8',
|
|
42
|
+
theme: 'default',
|
|
43
|
+
lineWrapping: true,
|
|
44
|
+
})
|
|
45
|
+
|
|
46
|
+
const langCodeMap = reactive(new Map<string, () => any>())
|
|
47
|
+
const currentLangCode = computed(() => langCodeMap.get(config.language)!)
|
|
48
|
+
const currentTheme = computed(() => {
|
|
49
|
+
return config.theme !== 'default' ? themes[config.theme] : void 0
|
|
50
|
+
})
|
|
51
|
+
|
|
52
|
+
const props = defineProps({
|
|
53
|
+
fileName: {
|
|
54
|
+
type: String,
|
|
55
|
+
required: true
|
|
56
|
+
},
|
|
57
|
+
modelValue: {
|
|
58
|
+
type: Blob,
|
|
59
|
+
required: true
|
|
60
|
+
},
|
|
61
|
+
language: {
|
|
62
|
+
type: String,
|
|
63
|
+
default: 'javascript'
|
|
64
|
+
},
|
|
65
|
+
readonly: {
|
|
66
|
+
type: Boolean,
|
|
67
|
+
default: false
|
|
68
|
+
}
|
|
69
|
+
})
|
|
70
|
+
|
|
71
|
+
config.readonly = props.readonly
|
|
72
|
+
|
|
73
|
+
// 编码后的 modelValue
|
|
74
|
+
const encodeModelValue = ref<string>('')
|
|
75
|
+
|
|
76
|
+
const ensureLanguageCode = async (targetLanguage: string) => {
|
|
77
|
+
config.language = targetLanguage
|
|
78
|
+
const delayPromise = () => new Promise((resolve) => window.setTimeout(resolve, 260))
|
|
79
|
+
if (langCodeMap.has(targetLanguage)) {
|
|
80
|
+
await delayPromise()
|
|
81
|
+
} else {
|
|
82
|
+
if (!languages[targetLanguage]) {
|
|
83
|
+
config.language = 'javascript'
|
|
84
|
+
targetLanguage = 'javascript'
|
|
85
|
+
}
|
|
86
|
+
const [result] = await Promise.all([languages[targetLanguage](), delayPromise()])
|
|
87
|
+
langCodeMap.set(targetLanguage, result.default)
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
const ensureEncoding = (encoding: string) => {
|
|
92
|
+
if (encoding) {
|
|
93
|
+
config.encoding = encoding
|
|
94
|
+
processEncoding(config.encoding)
|
|
95
|
+
} else {
|
|
96
|
+
languageEncoding(props.modelValue).then((fileInfo) => {
|
|
97
|
+
if (fileInfo.encoding && fileInfo.confidence.encoding && fileInfo.confidence.encoding > 0.5) {
|
|
98
|
+
// ElMessage.success(`检测到文件编码为 ${fileInfo.encoding}, 可能性为 ${fileInfo.confidence.encoding * 100}%`)
|
|
99
|
+
} else {
|
|
100
|
+
ElMessage.warning({
|
|
101
|
+
message: '自动检测文件编码未成功,将使用默认编码 UTF-8 打开.',
|
|
102
|
+
duration: 5000
|
|
103
|
+
})
|
|
104
|
+
fileInfo.encoding = 'UTF-8'
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
config.encoding = fileInfo.encoding || 'UTF-8'
|
|
108
|
+
processEncoding(config.encoding)
|
|
109
|
+
})
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
const processEncoding = (encoding: string) => {
|
|
114
|
+
let fd = new FileReader;
|
|
115
|
+
fd.onload = function () {
|
|
116
|
+
encodeModelValue.value = fd.result as string
|
|
117
|
+
}
|
|
118
|
+
fd.readAsText(props.modelValue, encoding);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
onBeforeMount(() => {
|
|
122
|
+
ensureLanguageCode(props.language!)
|
|
123
|
+
ensureEncoding('')
|
|
124
|
+
})
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
const useAutoHeight = () => {
|
|
128
|
+
const codemirrorRef = ref<HTMLElement | null>(null);
|
|
129
|
+
const editorHeight = ref<string>('');
|
|
130
|
+
|
|
131
|
+
// Function to calculate editor height
|
|
132
|
+
const calculateEditorHeight = () => {
|
|
133
|
+
const bodyHeight = codemirrorRef.value?.parentElement?.offsetHeight || 0;
|
|
134
|
+
const toolbarHeight = codemirrorRef.value?.querySelector('.toolbar')?.offsetHeight || 0;
|
|
135
|
+
const dividerHeight = 9;
|
|
136
|
+
const footerHeight = codemirrorRef.value?.querySelector('.footer')?.offsetHeight || 0;
|
|
137
|
+
editorHeight.value = `calc(${bodyHeight}px - ${toolbarHeight + (dividerHeight * 2) + footerHeight + 50}px)`;
|
|
138
|
+
};
|
|
139
|
+
|
|
140
|
+
// ResizeObserver to watch for changes in parent element size
|
|
141
|
+
let resizeObserver: ResizeObserver;
|
|
142
|
+
|
|
143
|
+
onMounted(() => {
|
|
144
|
+
calculateEditorHeight();
|
|
145
|
+
resizeObserver = new ResizeObserver(() => {
|
|
146
|
+
calculateEditorHeight();
|
|
147
|
+
});
|
|
148
|
+
if (codemirrorRef.value?.parentElement) {
|
|
149
|
+
resizeObserver.observe(codemirrorRef.value.parentElement);
|
|
150
|
+
}
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
onBeforeUnmount(() => {
|
|
154
|
+
if (resizeObserver && codemirrorRef.value?.parentElement) {
|
|
155
|
+
resizeObserver.unobserve(codemirrorRef.value.parentElement);
|
|
156
|
+
}
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
return {
|
|
160
|
+
codemirrorRef,
|
|
161
|
+
editorHeight
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
const { codemirrorRef, editorHeight } = useAutoHeight()
|
|
166
|
+
</script>
|
|
167
|
+
|
|
168
|
+
<style lang="scss" scoped>
|
|
169
|
+
@import '~/styles/code-editor-variables.scss';
|
|
170
|
+
|
|
171
|
+
.example {
|
|
172
|
+
.divider {
|
|
173
|
+
height: 1px;
|
|
174
|
+
background-color: $border-color;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
:deep(.cm-editor) {
|
|
178
|
+
height: v-bind('editorHeight');
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
.loading-box {
|
|
182
|
+
overflow: auto;
|
|
183
|
+
width: 100%;
|
|
184
|
+
min-height: 20rem;
|
|
185
|
+
max-height: 60rem;
|
|
186
|
+
/* loading height = view-height - layout-height - page-height */
|
|
187
|
+
/* navbar + banner + footer */
|
|
188
|
+
$layout-height: $navbar-height + $banner-height + $footbar-height;
|
|
189
|
+
/* single-card-gap * 2 + card-header + editor-header */
|
|
190
|
+
$page-height: 2rem * 2 + 3.2rem + 3rem;
|
|
191
|
+
/* editor-border * 2 */
|
|
192
|
+
height: calc(100vh - $layout-height - $page-height - 2px);
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
.toolbar {
|
|
196
|
+
display: grid;
|
|
197
|
+
grid-template-columns: repeat(1,minmax(0,1fr))
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
@media (min-width: 640px) {
|
|
201
|
+
.toolbar {
|
|
202
|
+
grid-template-columns:repeat(2,minmax(0,1fr))
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
@media (min-width: 768px) {
|
|
207
|
+
.toolbar {
|
|
208
|
+
grid-template-columns:repeat(3,minmax(0,1fr))
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
@media (min-width: 1280px) {
|
|
213
|
+
.toolbar {
|
|
214
|
+
grid-template-columns:repeat(5,minmax(0,1fr))
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
.toolbar .item {
|
|
219
|
+
margin-top: .25rem;
|
|
220
|
+
margin-bottom: .25rem;
|
|
221
|
+
display: -webkit-box;
|
|
222
|
+
display: flex
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
.toolbar .item>:not([hidden])~:not([hidden]) {
|
|
226
|
+
--tw-space-x-reverse: 0;
|
|
227
|
+
margin-right: calc(.25rem * var(--tw-space-x-reverse));
|
|
228
|
+
margin-left: calc(.25rem * calc(1 - var(--tw-space-x-reverse)))
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
@media (min-width: 640px) {
|
|
232
|
+
.toolbar .item {
|
|
233
|
+
max-width:80%
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
@media (min-width: 768px) {
|
|
238
|
+
.toolbar .item {
|
|
239
|
+
max-width:70%
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
@media (min-width: 1280px) {
|
|
244
|
+
.toolbar .item {
|
|
245
|
+
max-width:60%
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
.toolbar .item label {
|
|
250
|
+
white-space: nowrap
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
.editor .cm-editor {
|
|
254
|
+
height: 50vh
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
@media (min-width: 640px) {
|
|
258
|
+
.editor .cm-editor {
|
|
259
|
+
height:60vh
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
@media (min-width: 1024px) {
|
|
264
|
+
.editor .cm-editor {
|
|
265
|
+
height:65vh
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
.editor .divider {
|
|
270
|
+
height: 1px;
|
|
271
|
+
background-color: var(--theme-border)
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
.editor .main {
|
|
275
|
+
display: -webkit-box;
|
|
276
|
+
display: flex;
|
|
277
|
+
width: 100%
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
.editor .main .code {
|
|
281
|
+
width: 30%;
|
|
282
|
+
height: 100px;
|
|
283
|
+
margin: 0;
|
|
284
|
+
padding: .4em;
|
|
285
|
+
overflow: scroll;
|
|
286
|
+
border-left: 1px solid var(--theme-border);
|
|
287
|
+
font-family: monospace
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
.editor .footer {
|
|
291
|
+
height: 3rem;
|
|
292
|
+
display: -webkit-box;
|
|
293
|
+
display: flex;
|
|
294
|
+
-webkit-box-pack: justify;
|
|
295
|
+
justify-content: space-between;
|
|
296
|
+
-webkit-box-align: center;
|
|
297
|
+
align-items: center;
|
|
298
|
+
font-size: 90%;
|
|
299
|
+
width: 100%
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
@media not all and (min-width: 640px) {
|
|
303
|
+
.editor .footer {
|
|
304
|
+
-webkit-box-orient:vertical;
|
|
305
|
+
-webkit-box-direction: normal;
|
|
306
|
+
flex-direction: column
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
.editor .footer .buttons>:not([hidden])~:not([hidden]) {
|
|
311
|
+
--tw-space-x-reverse: 0;
|
|
312
|
+
margin-right: calc(.75rem * var(--tw-space-x-reverse));
|
|
313
|
+
margin-left: calc(.75rem * calc(1 - var(--tw-space-x-reverse)))
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
@media not all and (min-width: 640px) {
|
|
317
|
+
.editor .footer .buttons {
|
|
318
|
+
width:100%
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
.editor .footer .buttons .item {
|
|
323
|
+
display: -webkit-inline-box;
|
|
324
|
+
display: inline-flex;
|
|
325
|
+
-webkit-box-pack: center;
|
|
326
|
+
justify-content: center;
|
|
327
|
+
-webkit-box-align: center;
|
|
328
|
+
align-items: center;
|
|
329
|
+
background-color: transparent;
|
|
330
|
+
border: 1px dashed var(--theme-border);
|
|
331
|
+
font-size: 12px;
|
|
332
|
+
color: var(--text-secondary);
|
|
333
|
+
cursor: pointer
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
.editor .footer .buttons .item .iconfont {
|
|
337
|
+
margin-left: .309rem
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
.editor .footer .buttons .item:hover {
|
|
341
|
+
color: var(--text-color);
|
|
342
|
+
border-color: var(--text-color)
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
.editor .footer .infos>:not([hidden])~:not([hidden]) {
|
|
346
|
+
--tw-space-x-reverse: 0;
|
|
347
|
+
margin-right: calc(.75rem * var(--tw-space-x-reverse));
|
|
348
|
+
margin-left: calc(.75rem * calc(1 - var(--tw-space-x-reverse)))
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
@media not all and (min-width: 640px) {
|
|
352
|
+
.editor .footer .infos {
|
|
353
|
+
width:100%
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
.editor .footer .infos .item {
|
|
358
|
+
display: inline-block;
|
|
359
|
+
-webkit-font-feature-settings: "tnum";
|
|
360
|
+
font-feature-settings: "tnum"
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
.example .divider {
|
|
364
|
+
height: 1px;
|
|
365
|
+
background-color: var(--theme-border)
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
.example .cm-editor {
|
|
369
|
+
height: var(--51369a7c)
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
.example .loading-box {
|
|
373
|
+
overflow: auto;
|
|
374
|
+
width: 100%;
|
|
375
|
+
min-height: 20rem;
|
|
376
|
+
max-height: 60rem;
|
|
377
|
+
height: calc(100vh - 42.2rem - 2px)
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
</style>
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
const importers = import.meta.glob<string>('./lang-code/*/index.ts')
|
|
2
|
+
const languages: { [key in string]: () => any } = {}
|
|
3
|
+
Object.keys(importers).forEach((fileName) => {
|
|
4
|
+
const language = fileName.replace('./lang-code/', '').replace('/index.ts', '')
|
|
5
|
+
languages[language] = importers[fileName]
|
|
6
|
+
})
|
|
7
|
+
|
|
8
|
+
export default languages
|