From 3af96040e63520089c2c19cee80c71f2346ebe43 Mon Sep 17 00:00:00 2001 From: Ryan Wang Date: Mon, 5 Sep 2022 01:06:11 +0800 Subject: [PATCH] feat: add attachment management support (halo-dev/console#600) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit #### What type of PR is this? /kind feature /milestone 2.0 #### What this PR does / why we need it: 增加附件管理的功能,适配 https://github.com/halo-dev/halo/pull/2354 #### Which issue(s) this PR fixes: Fixes https://github.com/halo-dev/halo/issues/2330 #### Screenshots: None #### Special notes for your reviewer: todo list: - [x] 根据分组筛选附件列表。 - [x] 非图片文件支持显示占位图。 - [x] 完善选择附件组件。 - [ ] ~~附件引用关系查询。~~ #### Does this PR introduce a user-facing change? ```release-note None ``` --- package.json | 8 +- .../components/src/components/modal/Modal.vue | 11 +- packages/shared/package.json | 2 +- .../src/composables/use-setting-form.ts | 25 +- packages/shared/src/index.ts | 1 + .../shared/src/states/attachment-selector.ts | 21 + packages/shared/src/types/plugin.ts | 7 +- packages/shared/src/utils/api-client.ts | 18 + pnpm-lock.yaml | 114 ++- src/components/image/LazyImage.vue | 27 + src/components/upload/FilePondUpload.vue | 88 +++ .../contents/attachments/AttachmentList.vue | 720 ++++++++++++------ .../AttachmentAliOSSStrategyEditingModal.vue | 99 --- .../components/AttachmentDetailModal.vue | 332 ++++---- .../components/AttachmentFileTypeIcon.vue | 117 +++ .../AttachmentGroupEditingModal.vue | 100 ++- .../components/AttachmentGroupList.vue | 165 ++++ .../AttachmentLocalStrategyEditingModal.vue | 55 -- .../components/AttachmentPoliciesModal.vue | 233 ++++++ .../AttachmentPolicyEditingModal.vue | 213 ++++++ .../components/AttachmentSelectModal.vue | 78 -- .../components/AttachmentSelectorModal.vue | 100 +++ .../components/AttachmentStrategiesModal.vue | 154 ---- .../components/AttachmentUploadModal.vue | 117 ++- .../CoreSelectorProvider.vue | 205 +++++ .../UploadSelectorProvider.vue | 234 ++++++ .../composables/use-attachment-group.ts | 41 + .../composables/use-attachment-policy.ts | 42 + .../attachments/composables/use-attachment.ts | 214 ++++++ src/modules/contents/attachments/module.ts | 3 +- .../dashboard/widgets/QuickLinkWidget.vue | 48 +- src/modules/system/users/UserList.vue | 20 +- src/utils/image.ts | 15 + tsconfig.app.json | 3 +- vite.config.ts | 2 + 35 files changed, 2765 insertions(+), 867 deletions(-) create mode 100644 packages/shared/src/states/attachment-selector.ts create mode 100644 src/components/image/LazyImage.vue create mode 100644 src/components/upload/FilePondUpload.vue delete mode 100644 src/modules/contents/attachments/components/AttachmentAliOSSStrategyEditingModal.vue create mode 100644 src/modules/contents/attachments/components/AttachmentFileTypeIcon.vue create mode 100644 src/modules/contents/attachments/components/AttachmentGroupList.vue delete mode 100644 src/modules/contents/attachments/components/AttachmentLocalStrategyEditingModal.vue create mode 100644 src/modules/contents/attachments/components/AttachmentPoliciesModal.vue create mode 100644 src/modules/contents/attachments/components/AttachmentPolicyEditingModal.vue delete mode 100644 src/modules/contents/attachments/components/AttachmentSelectModal.vue create mode 100644 src/modules/contents/attachments/components/AttachmentSelectorModal.vue delete mode 100644 src/modules/contents/attachments/components/AttachmentStrategiesModal.vue create mode 100644 src/modules/contents/attachments/components/selector-providers/CoreSelectorProvider.vue create mode 100644 src/modules/contents/attachments/components/selector-providers/UploadSelectorProvider.vue create mode 100644 src/modules/contents/attachments/composables/use-attachment-group.ts create mode 100644 src/modules/contents/attachments/composables/use-attachment-policy.ts create mode 100644 src/modules/contents/attachments/composables/use-attachment.ts create mode 100644 src/utils/image.ts diff --git a/package.json b/package.json index 2d76a0cd7..beeea54ba 100644 --- a/package.json +++ b/package.json @@ -33,7 +33,7 @@ "@formkit/themes": "1.0.0-beta.10", "@formkit/vue": "1.0.0-beta.10", "@halo-dev/admin-shared": "workspace:*", - "@halo-dev/api-client": "^0.0.12", + "@halo-dev/api-client": "^0.0.13", "@halo-dev/components": "workspace:*", "@halo-dev/richtext-editor": "^0.0.0-alpha.5", "@tiptap/extension-character-count": "2.0.0-beta.31", @@ -44,12 +44,14 @@ "colorjs.io": "^0.4.0", "dayjs": "^1.11.5", "filepond": "^4.30.4", - "filepond-plugin-image-preview": "^4.6.11", "floating-vue": "2.0.0-beta.19", "lodash.clonedeep": "^4.5.0", "lodash.isequal": "^4.5.0", + "path-browserify": "^1.0.1", "pinia": "^2.0.20", + "pretty-bytes": "^6.0.0", "qs": "^6.11.0", + "unsplash-js": "^7.0.15", "uuid": "^8.3.2", "vue": "^3.2.37", "vue-filepond": "^7.0.3", @@ -60,6 +62,7 @@ }, "devDependencies": { "@changesets/cli": "^2.24.3", + "@iconify-json/vscode-icons": "^1.1.11", "@rushstack/eslint-patch": "^1.1.4", "@tailwindcss/aspect-ratio": "^0.4.0", "@types/jsdom": "^20.0.0", @@ -93,6 +96,7 @@ "tailwindcss-safe-area": "^0.2.2", "tailwindcss-themer": "^2.0.1", "typescript": "~4.7.4", + "unplugin-icons": "^0.14.8", "vite": "^3.0.9", "vite-compression-plugin": "^0.0.4", "vite-plugin-externals": "^0.5.1", diff --git a/packages/components/src/components/modal/Modal.vue b/packages/components/src/components/modal/Modal.vue index fa4d44d59..1340e9d3c 100644 --- a/packages/components/src/components/modal/Modal.vue +++ b/packages/components/src/components/modal/Modal.vue @@ -7,15 +7,19 @@ const props = withDefaults( visible?: boolean; title?: string; width?: number; + height?: string; fullscreen?: boolean; bodyClass?: string[]; + mountToBody?: boolean; }>(), { visible: false, title: undefined, width: 500, + height: undefined, fullscreen: false, bodyClass: undefined, + mountToBody: false, } ); @@ -36,6 +40,7 @@ const wrapperClasses = computed(() => { const contentStyles = computed(() => { return { maxWidth: props.width + "px", + height: props.height, }; }); @@ -56,7 +61,7 @@ watch( );