From 74dcb767e66e85519d325fa4e95a87b1f58ab1bf Mon Sep 17 00:00:00 2001 From: vec Date: Sun, 7 Jan 2024 15:10:24 +0800 Subject: [PATCH] [add] better refresh thumb api --- dashboard/.eslintrc.js | 2 +- dashboard/package-lock.json | 23 +++- dashboard/package.json | 1 + dashboard/src/api/image.js | 14 +- .../dashboard/components/refresh-thumbs.vue | 120 ++++++++++++++++++ dashboard/src/views/dashboard/index.vue | 80 ++++++------ dashboard/src/views/member/detail.vue | 4 +- server/app/controller/admin/image.js | 65 +++++++--- server/app/middleware/error-handler.js | 8 +- server/app/router.js | 3 +- server/app/service/image.js | 47 ++++++- server/app/service/photo.js | 4 +- server/test/common.js | 14 ++ server/test/image-upload.test.js | 99 ++++++--------- 14 files changed, 349 insertions(+), 135 deletions(-) create mode 100644 dashboard/src/views/dashboard/components/refresh-thumbs.vue diff --git a/dashboard/.eslintrc.js b/dashboard/.eslintrc.js index ce1911c..8185f95 100755 --- a/dashboard/.eslintrc.js +++ b/dashboard/.eslintrc.js @@ -90,7 +90,7 @@ module.exports = { 'no-extend-native': 2, 'no-extra-bind': 2, 'no-extra-boolean-cast': 2, - 'no-extra-parens': [2, 'functions'], + 'no-extra-parens': [0], 'no-fallthrough': 2, 'no-floating-decimal': 2, 'no-func-assign': 2, diff --git a/dashboard/package-lock.json b/dashboard/package-lock.json index 15611d6..331c466 100644 --- a/dashboard/package-lock.json +++ b/dashboard/package-lock.json @@ -14286,6 +14286,14 @@ "tough-cookie": "~2.5.0", "tunnel-agent": "^0.6.0", "uuid": "^3.3.2" + }, + "dependencies": { + "uuid": { + "version": "3.4.0", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.4.0.tgz", + "integrity": "sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A==", + "dev": true + } } }, "request-promise-core": { @@ -17237,10 +17245,9 @@ "dev": true }, "uuid": { - "version": "3.4.0", - "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.4.0.tgz", - "integrity": "sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A==", - "dev": true + "version": "9.0.1", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-9.0.1.tgz", + "integrity": "sha512-b+1eJOlsR9K8HJpow9Ok3fiWOWSIcIzXodvv0rQjVoOVNpWMpxf1wZNpt4y9h10odCNrqnYp1OBzRktckBe3sA==" }, "validate-npm-package-license": { "version": "3.0.4", @@ -18199,6 +18206,14 @@ "requires": { "ansi-colors": "^3.0.0", "uuid": "^3.3.2" + }, + "dependencies": { + "uuid": { + "version": "3.4.0", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.4.0.tgz", + "integrity": "sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A==", + "dev": true + } } }, "webpack-merge": { diff --git a/dashboard/package.json b/dashboard/package.json index ff6d714..5cf940e 100644 --- a/dashboard/package.json +++ b/dashboard/package.json @@ -21,6 +21,7 @@ "nprogress": "0.2.0", "pad-left": "^2.1.0", "path-to-regexp": "2.4.0", + "uuid": "^9.0.1", "vue": "2.6.10", "vue-router": "3.0.6", "vuex": "3.1.0" diff --git a/dashboard/src/api/image.js b/dashboard/src/api/image.js index e46a7e1..394a5a5 100644 --- a/dashboard/src/api/image.js +++ b/dashboard/src/api/image.js @@ -1,8 +1,18 @@ import request from '@/utils/request' -export const refreshThumbs = () => +export const __AVATAR_THUMB_SIZE__ = 128 + +export const refreshThumb = (src, thumb_size) => + request({ + url: `admin/image/refresh-thumb`, + method: 'POST', + timeout: 0, + data: { src, thumb_size }, + }) + +export const getAllAvailablePhoto = () => request({ - url: 'admin/image/refresh-thumb', + url: `admin/image/available-photo`, method: 'GET', timeout: 0, }) diff --git a/dashboard/src/views/dashboard/components/refresh-thumbs.vue b/dashboard/src/views/dashboard/components/refresh-thumbs.vue new file mode 100644 index 0000000..8c3c255 --- /dev/null +++ b/dashboard/src/views/dashboard/components/refresh-thumbs.vue @@ -0,0 +1,120 @@ + + + + + diff --git a/dashboard/src/views/dashboard/index.vue b/dashboard/src/views/dashboard/index.vue index 70d58b2..fdb2692 100755 --- a/dashboard/src/views/dashboard/index.vue +++ b/dashboard/src/views/dashboard/index.vue @@ -1,64 +1,58 @@ diff --git a/dashboard/src/views/member/detail.vue b/dashboard/src/views/member/detail.vue index ddae164..9acd156 100644 --- a/dashboard/src/views/member/detail.vue +++ b/dashboard/src/views/member/detail.vue @@ -20,7 +20,7 @@ > @@ -44,6 +44,7 @@