diff --git a/package.json b/package.json index 482e7f0..7c958b4 100644 --- a/package.json +++ b/package.json @@ -24,6 +24,7 @@ "dexie": "^4.2.1", "github-markdown-css": "^5.8.0", "localforage": "^1.10.0", + "lucide-vue-next": "^0.555.0", "markdown-it": "^14.1.0", "pinia": "^3.0.3", "pinia-plugin-persist": "^1.0.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 8799787..69c5728 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -32,6 +32,9 @@ importers: localforage: specifier: ^1.10.0 version: 1.10.0 + lucide-vue-next: + specifier: ^0.555.0 + version: 0.555.0(vue@3.5.13(typescript@5.5.3)) markdown-it: specifier: ^14.1.0 version: 14.1.0 @@ -3834,6 +3837,11 @@ packages: resolution: {integrity: sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==} engines: {node: '>=10'} + lucide-vue-next@0.555.0: + resolution: {integrity: sha512-7hczPsiMD/y+VNLpal5Q5Wv09kQxlHS0l/cM1xagrd+MA3i5umMm+PUXqllvsbgwAl3PHv27fo59h4PN02GM5A==} + peerDependencies: + vue: '>=3.0.1' + lz-string@1.5.0: resolution: {integrity: sha512-h5bgJWpxJNswbU7qCrV0tIKQCaS3blPDrqKWx+QxzuzL1zGUzij9XCWLrSLsJPu5t+eWA/ycetzYAO5IOMcWAQ==} hasBin: true @@ -9419,6 +9427,10 @@ snapshots: dependencies: yallist: 4.0.0 + lucide-vue-next@0.555.0(vue@3.5.13(typescript@5.5.3)): + dependencies: + vue: 3.5.13(typescript@5.5.3) + lz-string@1.5.0: {} magic-string@0.30.13: diff --git a/src/components.d.ts b/src/components.d.ts index 989871e..8b96095 100644 --- a/src/components.d.ts +++ b/src/components.d.ts @@ -13,6 +13,7 @@ declare module 'vue' { EditSeparateDialog: typeof import('./components/NumberSeparate/EditSeparateDialog.vue')['default'] HelloWorld: typeof import('./components/HelloWorld.vue')['default'] ImageSync: typeof import('./components/ImageSync/index.vue')['default'] + ImageUpload: typeof import('./components/ImageUpload/index.vue')['default'] Loading: typeof import('./components/Loading/index.vue')['default'] PageHeader: typeof import('./components/PageHeader/index.vue')['default'] PlayMusic: typeof import('./components/PlayMusic/index.vue')['default'] diff --git a/src/components/Dialog/index.vue b/src/components/Dialog/index.vue index a57bb97..4904201 100644 --- a/src/components/Dialog/index.vue +++ b/src/components/Dialog/index.vue @@ -1,13 +1,13 @@ @@ -33,12 +44,15 @@ const { title, desc, cancelText, submitText, submitFunc, cancelFunc = defaultCan - + {{ title }} - + {{ desc }} + + + diff --git a/src/components/ImageUpload/index.vue b/src/components/ImageUpload/index.vue new file mode 100644 index 0000000..9e22609 --- /dev/null +++ b/src/components/ImageUpload/index.vue @@ -0,0 +1,58 @@ + + + + + + + + + + 点击上传 + + + + + {{ originFileName }} + + + + + + + + + diff --git a/src/components/ImageUpload/type.ts b/src/components/ImageUpload/type.ts new file mode 100644 index 0000000..a562c82 --- /dev/null +++ b/src/components/ImageUpload/type.ts @@ -0,0 +1,5 @@ +export interface IFileData { + dataUrl: string + fileName: string + type: string +} diff --git a/src/views/Config/Global/ImageConfig/components/UploadDialog.vue b/src/views/Config/Global/ImageConfig/components/UploadDialog.vue new file mode 100644 index 0000000..fbe7ae2 --- /dev/null +++ b/src/views/Config/Global/ImageConfig/components/UploadDialog.vue @@ -0,0 +1,110 @@ + + + + + + {{ t('error.uploadFail') }} + + + {{ t('error.uploadSuccess') }} + + + {{ t('error.notImage') }} + + + + + + + + + + + + + diff --git a/src/views/Config/Global/ImageConfig/index.vue b/src/views/Config/Global/ImageConfig/index.vue index 950bffa..bc6f6da 100644 --- a/src/views/Config/Global/ImageConfig/index.vue +++ b/src/views/Config/Global/ImageConfig/index.vue @@ -2,51 +2,22 @@ import type { IImage } from '@/types/storeType' import localforage from 'localforage' import { storeToRefs } from 'pinia' -import { onMounted, ref, watch } from 'vue' +import { ref, watch } from 'vue' import { useI18n } from 'vue-i18n' import ImageSync from '@/components/ImageSync/index.vue' import PageHeader from '@/components/PageHeader/index.vue' import useStore from '@/store' -import { readFileData } from '@/utils/file' +import UploadDialog from './components/UploadDialog.vue' const { t } = useI18n() const globalConfig = useStore().globalConfig const { getImageList: localImageList } = storeToRefs(globalConfig) -const limitType = ref('image/*') const imgUploadToast = ref(0) // 0是不显示,1是成功,2是失败,3是不是图片 const imageDbStore = localforage.createInstance({ name: 'imgStore', }) -async function handleFileChange(e: Event) { - const isImage = /image*/.test(((e.target as HTMLInputElement).files as FileList)[0].type) - if (!isImage) { - imgUploadToast.value = 3 - return - } - const { dataUrl, fileName } = await readFileData(((e.target as HTMLInputElement).files as FileList)[0]) - imageDbStore.setItem(`${new Date().getTime().toString()}+${fileName}`, dataUrl) - .then(() => { - imgUploadToast.value = 1 - getImageDbStore() - }) - .catch(() => { - imgUploadToast.value = 2 - }) -} - -async function getImageDbStore() { - const keys = await imageDbStore.keys() - if (keys.length > 0) { - imageDbStore.iterate((value, key) => { - globalConfig.addImage({ - id: key, - name: key, - url: 'Storage', - }) - }) - } -} +const uploadVisible = ref(false) function removeImage(item: IImage) { if (item.url === 'Storage') { @@ -56,9 +27,6 @@ function removeImage(item: IImage) { } globalConfig.removeImage(item.id) } -onMounted(() => { - // getImageDbStore() -}) watch(() => imgUploadToast.value, (val) => { if (val !== 0) { setTimeout(() => { @@ -69,28 +37,14 @@ watch(() => imgUploadToast.value, (val) => { - - - {{ t('error.uploadFail') }} - - - {{ t('error.uploadSuccess') }} - - - {{ t('error.notImage') }} - - + - - {{ t('button.upload') }} + {{ t('button.upload') }} @@ -101,7 +55,6 @@ watch(() => imgUploadToast.value, (val) => { -
+
{{ desc }}
+ {{ originFileName }} +