feat: attachment management support sorting (#694)

#### 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/2705

#### Which issue(s) this PR fixes:

Fixes https://github.com/halo-dev/halo/issues/2627

#### Special notes for your reviewer:

/cc @halo-dev/sig-halo-console 

测试方式:

1. Halo 需要切换到 https://github.com/halo-dev/halo/pull/2705 分支。
2. Console 需要 `pnpm install`
3. 上传若干附件,检查排序筛选之后的结果是否符合预期。

#### Does this PR introduce a user-facing change?

```release-note
附件管理支持排序筛选
```
pull/688/head^2
Ryan Wang 2022-11-17 10:50:22 +08:00 committed by GitHub
parent d8a8d96708
commit 1b8805a340
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 134 additions and 96 deletions

View File

@ -32,7 +32,7 @@
"@formkit/themes": "^1.0.0-beta.11",
"@formkit/vue": "^1.0.0-beta.11",
"@formkit/utils": "^1.0.0-beta.11",
"@halo-dev/api-client": "^0.0.46",
"@halo-dev/api-client": "^0.0.47",
"@halo-dev/components": "workspace:*",
"@halo-dev/console-shared": "workspace:*",
"@halo-dev/richtext-editor": "^0.0.0-alpha.11",

View File

@ -12,7 +12,7 @@ importers:
'@formkit/themes': ^1.0.0-beta.11
'@formkit/utils': ^1.0.0-beta.11
'@formkit/vue': ^1.0.0-beta.11
'@halo-dev/api-client': ^0.0.46
'@halo-dev/api-client': ^0.0.47
'@halo-dev/components': workspace:*
'@halo-dev/console-shared': workspace:*
'@halo-dev/richtext-editor': ^0.0.0-alpha.11
@ -106,7 +106,7 @@ importers:
'@formkit/themes': 1.0.0-beta.12-e579559_tailwindcss@3.2.4
'@formkit/utils': 1.0.0-beta.12-e579559
'@formkit/vue': 1.0.0-beta.12-e579559_ior6jr3fpijijuwpr34w2i25va
'@halo-dev/api-client': 0.0.46
'@halo-dev/api-client': 0.0.47
'@halo-dev/components': link:packages/components
'@halo-dev/console-shared': link:packages/shared
'@halo-dev/richtext-editor': 0.0.0-alpha.11_vue@3.2.45
@ -158,8 +158,8 @@ importers:
'@types/qs': 6.9.7
'@types/randomstring': 1.1.8
'@types/uuid': 8.3.4
'@vitejs/plugin-vue': 3.2.0_vite@3.2.3+vue@3.2.45
'@vitejs/plugin-vue-jsx': 2.1.1_vite@3.2.3+vue@3.2.45
'@vitejs/plugin-vue': 3.2.0_vite@3.2.4+vue@3.2.45
'@vitejs/plugin-vue-jsx': 2.1.1_vite@3.2.4+vue@3.2.45
'@vitest/ui': 0.25.2
'@vue/compiler-sfc': 3.2.45
'@vue/eslint-config-prettier': 7.0.0_mbd4zptqpjbepwpyh2zbtslqey
@ -185,13 +185,13 @@ importers:
tailwindcss-themer: 2.0.2_tailwindcss@3.2.4
typescript: 4.7.4
unplugin-icons: 0.14.13_@vue+compiler-sfc@3.2.45
vite: 3.2.3_ajklay5k626t46b6fyghkbup3i
vite: 3.2.4_ajklay5k626t46b6fyghkbup3i
vite-compression-plugin: 0.0.4
vite-plugin-externals: 0.5.1_vite@3.2.3
vite-plugin-html: 3.2.0_vite@3.2.3
vite-plugin-pwa: 0.13.3_vite@3.2.3
vite-plugin-static-copy: 0.11.1_vite@3.2.3
vite-plugin-vue-setup-extend: 0.4.0_vite@3.2.3
vite-plugin-externals: 0.5.1_vite@3.2.4
vite-plugin-html: 3.2.0_vite@3.2.4
vite-plugin-pwa: 0.13.3_vite@3.2.4
vite-plugin-static-copy: 0.11.1_vite@3.2.4
vite-plugin-vue-setup-extend: 0.4.0_vite@3.2.4
vitest: 0.25.2_yvjtz2v2subkwifqvesh2o4s3u
vue-tsc: 1.0.9_typescript@4.7.4
@ -214,14 +214,14 @@ importers:
vite-plugin-dts: ^1.7.0
dependencies:
'@codemirror/commands': 6.1.2
'@codemirror/lang-css': 6.0.1_@codemirror+view@6.5.0
'@codemirror/lang-css': 6.0.1_@codemirror+view@6.5.1
'@codemirror/lang-html': 6.1.3
'@codemirror/lang-javascript': 6.1.1
'@codemirror/lang-json': 6.0.1
'@codemirror/language': 6.3.0
'@codemirror/legacy-modes': 6.2.0
'@codemirror/state': 6.1.3
'@codemirror/view': 6.5.0
'@codemirror/state': 6.1.4
'@codemirror/view': 6.5.1
codemirror: 6.0.1
devDependencies:
'@histoire/plugin-vue': 0.11.7_histoire@0.11.7
@ -1680,7 +1680,7 @@ packages:
prettier: 2.7.1
dev: true
/@codemirror/autocomplete/6.3.0_mwoofy5nwd5ooq5wffj5igwo2a:
/@codemirror/autocomplete/6.3.0_jwojl5dpod7rvijk5u3kpl7n2q:
resolution: {integrity: sha512-4jEvh3AjJZTDKazd10J6ZsCIqaYxDMCeua5ouQxY8hlFIml+nr7le0SgBhT3SIytFBmdzPK3AUhXGuW3T79nVg==}
peerDependencies:
'@codemirror/language': ^6.0.0
@ -1688,8 +1688,8 @@ packages:
'@codemirror/view': ^6.0.0
dependencies:
'@codemirror/language': 6.3.0
'@codemirror/state': 6.1.3
'@codemirror/view': 6.5.0
'@codemirror/state': 6.1.4
'@codemirror/view': 6.5.1
'@lezer/common': 1.0.1
dev: false
@ -1697,16 +1697,16 @@ packages:
resolution: {integrity: sha512-sO3jdX1s0pam6lIdeSJLMN3DQ6mPEbM4yLvyKkdqtmd/UDwhXA5+AwFJ89rRXm6vTeOXBsE5cAmlos/t7MJdgg==}
dependencies:
'@codemirror/language': 6.3.0
'@codemirror/state': 6.1.3
'@codemirror/view': 6.5.0
'@codemirror/state': 6.1.4
'@codemirror/view': 6.5.1
'@lezer/common': 1.0.1
/@codemirror/lang-css/6.0.1_@codemirror+view@6.5.0:
/@codemirror/lang-css/6.0.1_@codemirror+view@6.5.1:
resolution: {integrity: sha512-rlLq1Dt0WJl+2epLQeAsfqIsx3lGu4HStHCJu95nGGuz2P2fNugbU3dQYafr2VRjM4eMC9HviI6jvS98CNtG5w==}
dependencies:
'@codemirror/autocomplete': 6.3.0_mwoofy5nwd5ooq5wffj5igwo2a
'@codemirror/autocomplete': 6.3.0_jwojl5dpod7rvijk5u3kpl7n2q
'@codemirror/language': 6.3.0
'@codemirror/state': 6.1.3
'@codemirror/state': 6.1.4
'@lezer/css': 1.0.1
transitivePeerDependencies:
- '@codemirror/view'
@ -1715,12 +1715,12 @@ packages:
/@codemirror/lang-html/6.1.3:
resolution: {integrity: sha512-LmtIElopGK6bBfddAyjBitS6hz8nFr/PVUtvqmfomXlHB4m+Op2d5eGk/X9/CSby6Y8NqXXkGa3yDd9lfJ6Qlg==}
dependencies:
'@codemirror/autocomplete': 6.3.0_mwoofy5nwd5ooq5wffj5igwo2a
'@codemirror/lang-css': 6.0.1_@codemirror+view@6.5.0
'@codemirror/autocomplete': 6.3.0_jwojl5dpod7rvijk5u3kpl7n2q
'@codemirror/lang-css': 6.0.1_@codemirror+view@6.5.1
'@codemirror/lang-javascript': 6.1.1
'@codemirror/language': 6.3.0
'@codemirror/state': 6.1.3
'@codemirror/view': 6.5.0
'@codemirror/state': 6.1.4
'@codemirror/view': 6.5.1
'@lezer/common': 1.0.1
'@lezer/html': 1.0.1
dev: false
@ -1728,11 +1728,11 @@ packages:
/@codemirror/lang-javascript/6.1.1:
resolution: {integrity: sha512-F4+kiuC5d5dUSJmff96tJQwpEXs/tX/4bapMRnZWW6bHKK1Fx6MunTzopkCUWRa9bF87GPmb9m7Qtg7Yv8f3uQ==}
dependencies:
'@codemirror/autocomplete': 6.3.0_mwoofy5nwd5ooq5wffj5igwo2a
'@codemirror/autocomplete': 6.3.0_jwojl5dpod7rvijk5u3kpl7n2q
'@codemirror/language': 6.3.0
'@codemirror/lint': 6.0.0
'@codemirror/state': 6.1.3
'@codemirror/view': 6.5.0
'@codemirror/state': 6.1.4
'@codemirror/view': 6.5.1
'@lezer/common': 1.0.1
'@lezer/javascript': 1.0.2
dev: false
@ -1746,8 +1746,8 @@ packages:
/@codemirror/language/6.3.0:
resolution: {integrity: sha512-6jOE5DEt6sKD46SXhn3xPbBehn+l48ACcA6Uxs2k+E2YNH9XGF5WdGMTYr2DlggfK4h0QZBK6zEb5S7lkTriWA==}
dependencies:
'@codemirror/state': 6.1.3
'@codemirror/view': 6.5.0
'@codemirror/state': 6.1.4
'@codemirror/view': 6.5.1
'@lezer/common': 1.0.1
'@lezer/highlight': 1.1.1
'@lezer/lr': 1.2.3
@ -1762,34 +1762,34 @@ packages:
/@codemirror/lint/6.0.0:
resolution: {integrity: sha512-nUUXcJW1Xp54kNs+a1ToPLK8MadO0rMTnJB8Zk4Z8gBdrN0kqV7uvUraU/T2yqg+grDNR38Vmy/MrhQN/RgwiA==}
dependencies:
'@codemirror/state': 6.1.3
'@codemirror/view': 6.5.0
'@codemirror/state': 6.1.4
'@codemirror/view': 6.5.1
crelt: 1.0.5
/@codemirror/search/6.2.1:
resolution: {integrity: sha512-Q1JgUSBjQZRPIddlXzad/AVDigdhriLxQNFyP0gfrDTq6LDHNhr95U/tW3bpVssGenkaLzujtu/7XoK4kyvL3g==}
dependencies:
'@codemirror/state': 6.1.3
'@codemirror/view': 6.5.0
'@codemirror/state': 6.1.4
'@codemirror/view': 6.5.1
crelt: 1.0.5
dev: false
/@codemirror/state/6.1.3:
resolution: {integrity: sha512-0Rn7vadZ6EgHaKdIOwyhBWLdPDh1JM5USYqXjxwrvpmTKWu4wQ77twgAYEg1MU282XcrnV4ZqFf+00bu6UPCyg==}
/@codemirror/state/6.1.4:
resolution: {integrity: sha512-g+3OJuRylV5qsXuuhrc6Cvs1NQluNioepYMM2fhnpYkNk7NgX+j0AFuevKSVKzTDmDyt9+Puju+zPdHNECzCNQ==}
/@codemirror/theme-one-dark/6.1.0:
resolution: {integrity: sha512-AiTHtFRu8+vWT9wWUWDM+cog6ZwgivJogB1Tm/g40NIpLwph7AnmxrSzWfvJN5fBVufsuwBxecQCNmdcR5D7Aw==}
dependencies:
'@codemirror/language': 6.3.0
'@codemirror/state': 6.1.3
'@codemirror/view': 6.5.0
'@codemirror/state': 6.1.4
'@codemirror/view': 6.5.1
'@lezer/highlight': 1.1.1
dev: true
/@codemirror/view/6.5.0:
resolution: {integrity: sha512-dapE7AywjyYoHBHn4n+wCRKFqMEmYZHHlfyoSO+e1P6MK4az1wg9t7mfwbdI9mXuBzmPBX7NmU3Xmq+qmxDOLw==}
/@codemirror/view/6.5.1:
resolution: {integrity: sha512-xBKP8N3AXOs06VcKvIuvIQoUlGs7Hb78ftJWahLaRX909jKPMgGxR5XjvrawzTTZMSTU3DzdjDNPwG6fPM/ypQ==}
dependencies:
'@codemirror/state': 6.1.3
'@codemirror/state': 6.1.4
style-mod: 4.0.0
w3c-keyname: 2.2.6
@ -1974,8 +1974,8 @@ packages:
- windicss
dev: false
/@halo-dev/api-client/0.0.46:
resolution: {integrity: sha512-K2tuCv3OmYzaz9h6X5nVZbghDSd09AawORNAcoi3KuE/Uzi0n5OldO72AuJmVFxtbZqGIHt//CdBSE+cCFq08Q==}
/@halo-dev/api-client/0.0.47:
resolution: {integrity: sha512-O5Yw7TDpTElCOTKPz98yeaixh5SdfPZ63qOSZlFqO//F3tAvegpjq1ZYHMblJfP1Q/P9GioZB9YYebzzv8PC4g==}
dev: false
/@halo-dev/richtext-editor/0.0.0-alpha.11_vue@3.2.45:
@ -2057,9 +2057,9 @@ packages:
'@codemirror/lang-json': 6.0.1
'@codemirror/language': 6.3.0
'@codemirror/lint': 6.0.0
'@codemirror/state': 6.1.3
'@codemirror/state': 6.1.4
'@codemirror/theme-one-dark': 6.1.0
'@codemirror/view': 6.5.0
'@codemirror/view': 6.5.1
'@histoire/vendors': 0.11.7
dev: true
@ -3402,7 +3402,7 @@ packages:
'@uppy/provider-views': 3.0.2_@uppy+core@3.0.4
'@uppy/status-bar': 3.0.1_@uppy+core@3.0.4
'@uppy/thumbnail-generator': 3.0.2_@uppy+core@3.0.4
'@uppy/utils': 5.1.0
'@uppy/utils': 5.1.1
classnames: 2.3.2
is-shallow-equal: 1.0.1
lodash.debounce: 4.0.8
@ -3437,7 +3437,7 @@ packages:
'@uppy/core': ^3.0.2
dependencies:
'@uppy/core': 3.0.4
'@uppy/utils': 5.1.0
'@uppy/utils': 5.1.1
preact: 10.11.2
dev: false
@ -3461,7 +3461,7 @@ packages:
'@uppy/core': ^3.0.4
dependencies:
'@uppy/core': 3.0.4
'@uppy/utils': 5.1.0
'@uppy/utils': 5.1.1
classnames: 2.3.2
preact: 10.11.2
dev: false
@ -3489,7 +3489,7 @@ packages:
'@uppy/core': ^3.0.2
dependencies:
'@uppy/core': 3.0.4
'@uppy/utils': 5.1.0
'@uppy/utils': 5.1.1
exifr: 7.1.3
dev: false
@ -3499,8 +3499,8 @@ packages:
lodash.throttle: 4.1.1
dev: false
/@uppy/utils/5.1.0:
resolution: {integrity: sha512-kja/HZl115VDMQkS7OjxJvGBN06eOCUEIkln1G95M2YFBBgJZLrzjuVh8zSUFPfj33x6AYlv6FKjES1L+SVx/w==}
/@uppy/utils/5.1.1:
resolution: {integrity: sha512-uoI+PcIVQboky0ZbN4PQeK1seZnnJocomzeK7blId9HKJ6QNgZLf2ibk2CQuQxrOuNsWhgrhs5uLO5Si0oM0Yw==}
dependencies:
lodash.throttle: 4.1.1
dev: false
@ -3548,7 +3548,7 @@ packages:
nanoid: 4.0.0
dev: false
/@vitejs/plugin-vue-jsx/2.1.1_vite@3.2.3+vue@3.2.45:
/@vitejs/plugin-vue-jsx/2.1.1_vite@3.2.4+vue@3.2.45:
resolution: {integrity: sha512-JgDhxstQlwnHBvZ1BSnU5mbmyQ14/t5JhREc6YH5kWyu2QdAAOsLF6xgHoIWarj8tddaiwFrNzLbWJPudpXKYA==}
engines: {node: ^14.18.0 || >=16.0.0}
peerDependencies:
@ -3558,20 +3558,20 @@ packages:
'@babel/core': 7.20.2
'@babel/plugin-transform-typescript': 7.20.2_@babel+core@7.20.2
'@vue/babel-plugin-jsx': 1.1.1_@babel+core@7.20.2
vite: 3.2.3_ajklay5k626t46b6fyghkbup3i
vite: 3.2.4_ajklay5k626t46b6fyghkbup3i
vue: 3.2.45
transitivePeerDependencies:
- supports-color
dev: true
/@vitejs/plugin-vue/3.2.0_vite@3.2.3+vue@3.2.45:
/@vitejs/plugin-vue/3.2.0_vite@3.2.4+vue@3.2.45:
resolution: {integrity: sha512-E0tnaL4fr+qkdCNxJ+Xd0yM31UwMkQje76fsDVBBUCoGOUPexu2VDUYHL8P4CwV+zMvWw6nlRw19OnRKmYAJpw==}
engines: {node: ^14.18.0 || >=16.0.0}
peerDependencies:
vite: ^3.0.0
vue: ^3.2.25
dependencies:
vite: 3.2.3_ajklay5k626t46b6fyghkbup3i
vite: 3.2.4_ajklay5k626t46b6fyghkbup3i
vue: 3.2.45
dev: true
@ -4462,13 +4462,13 @@ packages:
/codemirror/6.0.1:
resolution: {integrity: sha512-J8j+nZ+CdWmIeFIGXEFbFPtpiYacFMDR8GlHK3IyHQJMCaVRfGx9NT+Hxivv1ckLWPvNdZqndbr/7lVhrf/Svg==}
dependencies:
'@codemirror/autocomplete': 6.3.0_mwoofy5nwd5ooq5wffj5igwo2a
'@codemirror/autocomplete': 6.3.0_jwojl5dpod7rvijk5u3kpl7n2q
'@codemirror/commands': 6.1.2
'@codemirror/language': 6.3.0
'@codemirror/lint': 6.0.0
'@codemirror/search': 6.2.1
'@codemirror/state': 6.1.3
'@codemirror/view': 6.5.0
'@codemirror/state': 6.1.4
'@codemirror/view': 6.5.1
dev: false
/color-convert/1.9.3:
@ -9094,7 +9094,7 @@ packages:
debug: 4.3.4
mlly: 0.5.16
pathe: 0.2.0
vite: 3.2.3
vite: 3.2.4
transitivePeerDependencies:
- '@types/node'
- less
@ -9124,7 +9124,7 @@ packages:
- supports-color
dev: true
/vite-plugin-externals/0.5.1_vite@3.2.3:
/vite-plugin-externals/0.5.1_vite@3.2.4:
resolution: {integrity: sha512-HvRFG5y9wXoJUG9FSbSp9ikOiJRh7EzN6tJC5oIOcEj+19GUw9Z1NNCPFtAmX75Ajcr10FdELKNmuXS3lExkcg==}
peerDependencies:
vite: '>=2.0.0'
@ -9133,10 +9133,10 @@ packages:
es-module-lexer: 0.4.1
fs-extra: 10.1.0
magic-string: 0.25.9
vite: 3.2.3_ajklay5k626t46b6fyghkbup3i
vite: 3.2.4_ajklay5k626t46b6fyghkbup3i
dev: true
/vite-plugin-html/3.2.0_vite@3.2.3:
/vite-plugin-html/3.2.0_vite@3.2.4:
resolution: {integrity: sha512-2VLCeDiHmV/BqqNn5h2V+4280KRgQzCFN47cst3WiNK848klESPQnzuC3okH5XHtgwHH/6s1Ho/YV6yIO0pgoQ==}
peerDependencies:
vite: '>=2.0.0'
@ -9153,10 +9153,10 @@ packages:
html-minifier-terser: 6.1.0
node-html-parser: 5.4.2
pathe: 0.2.0
vite: 3.2.3_ajklay5k626t46b6fyghkbup3i
vite: 3.2.4_ajklay5k626t46b6fyghkbup3i
dev: true
/vite-plugin-pwa/0.13.3_vite@3.2.3:
/vite-plugin-pwa/0.13.3_vite@3.2.4:
resolution: {integrity: sha512-cjWXpZ7slAY14OKz7M8XdgTIi9wjf6OD6NkhiMAc+ogxnbUrecUwLdRtfGPCPsN2ftut5gaN1jTghb11p6IQAA==}
peerDependencies:
vite: ^3.1.0
@ -9166,7 +9166,7 @@ packages:
fast-glob: 3.2.12
pretty-bytes: 6.0.0
rollup: 2.79.1
vite: 3.2.3_ajklay5k626t46b6fyghkbup3i
vite: 3.2.4_ajklay5k626t46b6fyghkbup3i
workbox-build: 6.5.4
workbox-window: 6.5.4
transitivePeerDependencies:
@ -9174,7 +9174,7 @@ packages:
- supports-color
dev: true
/vite-plugin-static-copy/0.11.1_vite@3.2.3:
/vite-plugin-static-copy/0.11.1_vite@3.2.4:
resolution: {integrity: sha512-SPNxP/6Sj4rdPSZnuacIdJr1nHaF8YDnu2RWWVurQSv8I+tXrdoOU5r3Xsw/5mVrOtK84LhD4HsZ8tAG1epJ7Q==}
engines: {node: ^14.18.0 || >=16.0.0}
peerDependencies:
@ -9184,21 +9184,21 @@ packages:
fast-glob: 3.2.12
fs-extra: 10.1.0
picocolors: 1.0.0
vite: 3.2.3_ajklay5k626t46b6fyghkbup3i
vite: 3.2.4_ajklay5k626t46b6fyghkbup3i
dev: true
/vite-plugin-vue-setup-extend/0.4.0_vite@3.2.3:
/vite-plugin-vue-setup-extend/0.4.0_vite@3.2.4:
resolution: {integrity: sha512-WMbjPCui75fboFoUTHhdbXzu4Y/bJMv5N9QT9a7do3wNMNHHqrk+Tn2jrSJU0LS5fGl/EG+FEDBYVUeWIkDqXQ==}
peerDependencies:
vite: '>=2.0.0'
dependencies:
'@vue/compiler-sfc': 3.2.45
magic-string: 0.25.9
vite: 3.2.3_ajklay5k626t46b6fyghkbup3i
vite: 3.2.4_ajklay5k626t46b6fyghkbup3i
dev: true
/vite/3.2.3:
resolution: {integrity: sha512-h8jl1TZ76eGs3o2dIBSsvXDLb1m/Ec1iej8ZMdz+PsaFUsftZeWe2CZOI3qogEsMNaywc17gu0q6cQDzh/weCQ==}
/vite/3.2.4:
resolution: {integrity: sha512-Z2X6SRAffOUYTa+sLy3NQ7nlHFU100xwanq1WDwqaiFiCe+25zdxP1TfCS5ojPV2oDDcXudHIoPnI1Z/66B7Yw==}
engines: {node: ^14.18.0 || >=16.0.0}
hasBin: true
peerDependencies:
@ -9230,8 +9230,8 @@ packages:
fsevents: 2.3.2
dev: true
/vite/3.2.3_ajklay5k626t46b6fyghkbup3i:
resolution: {integrity: sha512-h8jl1TZ76eGs3o2dIBSsvXDLb1m/Ec1iej8ZMdz+PsaFUsftZeWe2CZOI3qogEsMNaywc17gu0q6cQDzh/weCQ==}
/vite/3.2.4_ajklay5k626t46b6fyghkbup3i:
resolution: {integrity: sha512-Z2X6SRAffOUYTa+sLy3NQ7nlHFU100xwanq1WDwqaiFiCe+25zdxP1TfCS5ojPV2oDDcXudHIoPnI1Z/66B7Yw==}
engines: {node: ^14.18.0 || >=16.0.0}
hasBin: true
peerDependencies:
@ -9302,7 +9302,7 @@ packages:
tinybench: 2.3.1
tinypool: 0.3.0
tinyspy: 1.0.2
vite: 3.2.3_ajklay5k626t46b6fyghkbup3i
vite: 3.2.4_ajklay5k626t46b6fyghkbup3i
transitivePeerDependencies:
- less
- sass

View File

@ -27,7 +27,7 @@ import AttachmentDetailModal from "./components/AttachmentDetailModal.vue";
import AttachmentUploadModal from "./components/AttachmentUploadModal.vue";
import AttachmentPoliciesModal from "./components/AttachmentPoliciesModal.vue";
import AttachmentGroupList from "./components/AttachmentGroupList.vue";
import { onMounted, ref, watch } from "vue";
import { computed, onMounted, ref, watch } from "vue";
import type { Attachment, Group, Policy, User } from "@halo-dev/api-client";
import { formatDatetime } from "@/utils/date";
import prettyBytes from "pretty-bytes";
@ -55,9 +55,38 @@ const { groups, handleFetchGroups } = useFetchAttachmentGroup({
const selectedGroup = ref<Group>();
// Filter
interface SortItem {
label: string;
value: string;
}
const SortItems: SortItem[] = [
{
label: "较近上传",
value: "creationTimestamp,desc",
},
{
label: "较晚上传",
value: "creationTimestamp,asc",
},
{
label: "文件大小降序",
value: "size,desc",
},
{
label: "文件大小升序",
value: "size,asc",
},
];
const selectedPolicy = ref<Policy>();
const selectedUser = ref<User>();
const keyword = ref<string>("");
const selectedSortItem = ref<SortItem>();
const selectedSortItemValue = computed(() => {
return selectedSortItem.value?.value;
});
function handleSelectPolicy(policy: Policy | undefined) {
selectedPolicy.value = policy;
@ -69,6 +98,11 @@ function handleSelectUser(user: User | undefined) {
handleFetchAttachments();
}
function handleSortItemChange(sortItem?: SortItem) {
selectedSortItem.value = sortItem;
handleFetchAttachments();
}
const {
attachments,
selectedAttachment,
@ -90,6 +124,7 @@ const {
policy: selectedPolicy,
user: selectedUser,
keyword: keyword,
sort: selectedSortItemValue,
});
const handleMove = async (group: Group) => {
@ -288,6 +323,7 @@ onMounted(() => {
>
<FormKit
v-model="keyword"
outer-class="!p-0"
placeholder="输入关键词搜索"
type="text"
@keyup.enter="handleFetchAttachments()"
@ -322,6 +358,21 @@ onMounted(() => {
@click="handleSelectUser(undefined)"
/>
</div>
<div
v-if="selectedSortItem"
class="group flex cursor-pointer items-center justify-center gap-1 rounded-full bg-gray-200 px-2 py-1 hover:bg-gray-300"
>
<span
class="text-xs text-gray-600 group-hover:text-gray-900"
>
排序{{ selectedSortItem.label }}
</span>
<IconCloseCircle
class="h-4 w-4 text-gray-600"
@click="handleSortItemChange()"
/>
</div>
</div>
<VSpace v-else>
<VButton type="danger" @click="handleDeleteInBatch">
@ -441,28 +492,13 @@ onMounted(() => {
<div class="w-72 p-4">
<ul class="space-y-1">
<li
v-for="(sortItem, index) in SortItems"
:key="index"
v-close-popper
class="flex cursor-pointer items-center rounded px-3 py-2 text-sm text-gray-600 hover:bg-gray-100 hover:text-gray-900"
@click="handleSortItemChange(sortItem)"
>
<span class="truncate">较近上传</span>
</li>
<li
v-close-popper
class="flex cursor-pointer items-center rounded px-3 py-2 text-sm text-gray-600 hover:bg-gray-100 hover:text-gray-900"
>
<span class="truncate">较晚上传</span>
</li>
<li
v-close-popper
class="flex cursor-pointer items-center rounded px-3 py-2 text-sm text-gray-600 hover:bg-gray-100 hover:text-gray-900"
>
<span class="truncate">文件大小降序</span>
</li>
<li
v-close-popper
class="flex cursor-pointer items-center rounded px-3 py-2 text-sm text-gray-600 hover:bg-gray-100 hover:text-gray-900"
>
<span class="truncate">文件大小升序</span>
<span class="truncate">{{ sortItem.label }}</span>
</li>
</ul>
</div>

View File

@ -46,8 +46,9 @@ export function useAttachmentControl(filterOptions?: {
group?: Ref<Group | undefined>;
user?: Ref<User | undefined>;
keyword?: Ref<string | undefined>;
sort?: Ref<string | undefined>;
}): useAttachmentControlReturn {
const { user, policy, group, keyword } = filterOptions || {};
const { user, policy, group, keyword, sort } = filterOptions || {};
const attachments = ref<AttachmentList>({
page: 1,
@ -79,6 +80,7 @@ export function useAttachmentControl(filterOptions?: {
uploadedBy: user?.value?.metadata.name,
page: attachments.value.page,
size: attachments.value.size,
sort: [sort?.value as string].filter(Boolean),
});
attachments.value = data;