From 8462e2c5863b4cc3ec8acf9bb1f31892929978e3 Mon Sep 17 00:00:00 2001 From: vec Date: Mon, 8 Jan 2024 18:06:37 +0800 Subject: [PATCH] [add] Dashboard Home statistic --- dashboard/package-lock.json | 6 +- dashboard/package.json | 2 +- dashboard/src/api/statistic.js | 7 + dashboard/src/main.js | 5 +- .../dashboard/components/refresh-thumbs.vue | 53 ++++---- dashboard/src/views/dashboard/index.vue | 121 ++++++++++++++++-- server/.eslintrc | 3 +- server/app/controller/admin/statistic.js | 77 +++++++++++ server/app/router.js | 2 + server/package-lock.json | 9 ++ server/package.json | 5 +- server/test/common.js | 11 ++ 12 files changed, 248 insertions(+), 53 deletions(-) create mode 100644 dashboard/src/api/statistic.js create mode 100644 server/app/controller/admin/statistic.js diff --git a/dashboard/package-lock.json b/dashboard/package-lock.json index 331c466..2024a6b 100644 --- a/dashboard/package-lock.json +++ b/dashboard/package-lock.json @@ -5759,9 +5759,9 @@ "dev": true }, "element-ui": { - "version": "2.15.4", - "resolved": "https://registry.npmjs.org/element-ui/-/element-ui-2.15.4.tgz", - "integrity": "sha512-b9Tlc6NjygcHv3QNzfPPDQvyAmLdbjQR7q1FMypqFKjowpQzlaL3zlNZ4jrpm0stEBWLeHVIT733z/i6F3o+cA==", + "version": "2.15.14", + "resolved": "https://registry.npmjs.org/element-ui/-/element-ui-2.15.14.tgz", + "integrity": "sha512-2v9fHL0ZGINotOlRIAJD5YuVB8V7WKxrE9Qy7dXhRipa035+kF7WuU/z+tEmLVPBcJ0zt8mOu1DKpWcVzBK8IA==", "requires": { "async-validator": "~1.8.1", "babel-helper-vue-jsx-merge-props": "^2.0.0", diff --git a/dashboard/package.json b/dashboard/package.json index 5cf940e..e1d43a7 100644 --- a/dashboard/package.json +++ b/dashboard/package.json @@ -15,7 +15,7 @@ }, "dependencies": { "axios": "0.21.1", - "element-ui": "^2.15.4", + "element-ui": "^2.15.14", "js-cookie": "2.2.0", "normalize.css": "7.0.0", "nprogress": "0.2.0", diff --git a/dashboard/src/api/statistic.js b/dashboard/src/api/statistic.js new file mode 100644 index 0000000..89a21f8 --- /dev/null +++ b/dashboard/src/api/statistic.js @@ -0,0 +1,7 @@ +import request from '@/utils/request' + +export const getStatistic = () => + request({ + url: `admin/statistic`, + method: 'GET', + }) diff --git a/dashboard/src/main.js b/dashboard/src/main.js index 369623e..62da0d0 100755 --- a/dashboard/src/main.js +++ b/dashboard/src/main.js @@ -29,9 +29,10 @@ if (process.env.NODE_ENV === 'production') { } // set ElementUI lang to EN -Vue.use(ElementUI, { locale }) +// Vue.use(ElementUI, { locale }) // 如果想要中文版 element-ui,按如下方式声明 -// Vue.use(ElementUI) +Vue.use(ElementUI) +console.log('ElementUI', ElementUI) Vue.config.productionTip = false diff --git a/dashboard/src/views/dashboard/components/refresh-thumbs.vue b/dashboard/src/views/dashboard/components/refresh-thumbs.vue index 8c3c255..2146df4 100644 --- a/dashboard/src/views/dashboard/components/refresh-thumbs.vue +++ b/dashboard/src/views/dashboard/components/refresh-thumbs.vue @@ -1,16 +1,17 @@ @@ -21,6 +22,10 @@ import { getList as getMemberList } from '@/api/member' const initProgress = () => ({ total: 0, success: 0, failure: 0 }) export default { + props: { + showButton: { type: Boolean, default: true } + }, + data: () => ({ ...initProgress(), processing: false, @@ -74,35 +79,21 @@ export default { } } }, - async refreshThumbsConfirm() { - const confirm = await this.confirm('', `你确定要刷新吗?`, { - confirmButtonClass: 'el-button--warning', - }) - if (!confirm) { return } - try { - this.processing = true - await this.refreshThumbs() - if (this.failure === 0) { - this.$emit('success', `所有缩略图已刷新`) + async refreshThumbsConfirmProcessing() { + if (this.processing === false) { + try { + this.processing = true + await this.refreshThumbs() + if (this.failure === 0) { + this.$emit('success', `所有缩略图已刷新`) + } + } catch (err) { + this.$emit('error', '刷新缓存失败', err) + } finally { + this.processing = false } - } catch (err) { - this.$emit('error', '刷新缓存失败', err) - } finally { - this.processing = false } }, - - async confirm(title, content, appendOpt = {}) { - const opt = Object.assign({ - confirmButtonText: '确定', - cancelButtonText: '取消', - confirmButtonClass: 'el-button--warning', - showClose: false, - }, appendOpt) - return this.$confirm(content, title, opt) - .then(() => true) - .catch(() => false) - }, } } diff --git a/dashboard/src/views/dashboard/index.vue b/dashboard/src/views/dashboard/index.vue index fdb2692..80ac474 100755 --- a/dashboard/src/views/dashboard/index.vue +++ b/dashboard/src/views/dashboard/index.vue @@ -1,17 +1,81 @@