diff --git a/package.json b/package.json index f3f42d2..9a1517f 100644 --- a/package.json +++ b/package.json @@ -24,6 +24,8 @@ "pinia": "^2.1.7", "pinia-plugin-persistedstate": "^3.2.3", "uuid": "^10.0.0", + "v-viewer": "^3.0.13", + "viewerjs": "^1.11.6", "vue": "^3.4.29" }, "devDependencies": { diff --git a/src/layout/header/search/SearchPage.tsx b/src/layout/header/search/SearchPage.tsx index 906f9d4..d7180e5 100644 --- a/src/layout/header/search/SearchPage.tsx +++ b/src/layout/header/search/SearchPage.tsx @@ -11,7 +11,7 @@ import { Modal } from 'ant-design-vue' import useSearchConfigStore from './useSearchConfigStore' -import { EditOutlined, DeleteOutlined, PlusOutlined } from '@ant-design/icons-vue' +import { EditOutlined, DeleteOutlined, PlusOutlined, CheckOutlined } from '@ant-design/icons-vue' import asyncLoader from '@/utils/asyncLoader' const ImageUploader = asyncLoader(() => import('@/utils/ImageUploader')) const SearchItem = defineComponent({ @@ -188,7 +188,7 @@ export default defineComponent(() => { - diff --git a/src/main.css b/src/main.css index 00fd587..009ec79 100644 --- a/src/main.css +++ b/src/main.css @@ -39,6 +39,16 @@ body { position: relative; top: -3px; } +.ant-modal-content { + background-color: rgba(255, 255, 255, 0.9) !important; + backdrop-filter: blur(20px); +} +.ant-modal-header { + background-color: transparent !important; +} +.viewer-backdrop { + backdrop-filter: blur(10px); +} /* 滚动条样式 */ ::-webkit-scrollbar { diff --git a/src/utils/ImageUploader.tsx b/src/utils/ImageUploader.tsx index 31991ec..e7032a7 100644 --- a/src/utils/ImageUploader.tsx +++ b/src/utils/ImageUploader.tsx @@ -1,10 +1,12 @@ import { defineComponent } from 'vue' import { OhVueIcon, addIcons } from 'oh-vue-icons' -import { MdUpload } from 'oh-vue-icons/icons' +import { MdUpload, FaEye } from 'oh-vue-icons/icons' import { message } from 'ant-design-vue' import upload from './upload' +import 'viewerjs/dist/viewer.css' +import { api as showViewer } from 'v-viewer' -addIcons(MdUpload) +addIcons(MdUpload, FaEye) // !清 asyncLoader 加载使用 export default defineComponent({ @@ -39,7 +41,9 @@ export default defineComponent({ style="display:none" ref={(el) => (input = el as any)} onChange={(e) => { - const file: File | undefined = (e.target as any).files?.[0] + const el = e.target as any + const file: File | undefined = el.files?.[0] + el.value = '' if (!file) return console.log(file.size, props.size) if (file.size > props.size * 1000 * 1000) { @@ -47,13 +51,12 @@ export default defineComponent({ return } upload(file, 'test').then((res) => { - console.log(res) ctx.emit('update:value', res) }) }} />
- {!props.value && } + {props.value ? ( +
+
{ + e.stopPropagation() + showViewer({ + images: [props.value], + options: { + navbar: false, + toolbar: false + } + }) + }} + > + +
+
+ ) : ( + + )}
-
支持上传 .png, .jpeg, .jpg, .svg
+
支持上传 .png, .jpeg, .jpg, .svg
{' '} ) }