diff --git a/package.json b/package.json index d17ec14..274f998 100644 --- a/package.json +++ b/package.json @@ -8,6 +8,7 @@ }, "dependencies": { "axios": "^0.22.0", + "echarts": "^5.2.1", "element-plus": "^1.1.0-beta.19", "hyperdown": "^2.4.29", "moment": "^2.29.1", diff --git a/src/router.ts b/src/router.ts index 64f9175..4acdfa9 100644 --- a/src/router.ts +++ b/src/router.ts @@ -7,6 +7,7 @@ import SystemUser from './views/system/SystemUser.vue' import SystemRole from './views/system/SystemRole.vue' import SystemConfig from './views/system/SystemConfig.vue' import Article from './views/system/Article.vue' +import Statistics from './views/system/Statistics.vue' import Music from './views/api/Music.vue' import Hitokoto from './views/api/Hitokoto.vue' @@ -20,6 +21,7 @@ const routes: Array = [ { path: '/system/role', name: 'SystemRole', component: SystemRole }, { path: '/system/config', name: 'SystemConfig', component: SystemConfig }, { path: '/system/article', name: 'Article', component: Article }, + { path: '/system/statistics', name: 'Statistics', component: Statistics }, { path: '/api/music', name: 'Music', component: Music }, { path: '/api/hitokoto', name: 'Hitokoto', component: Hitokoto }, diff --git a/src/types.ts b/src/types.ts new file mode 100644 index 0000000..5d38dd3 --- /dev/null +++ b/src/types.ts @@ -0,0 +1,8 @@ +import { Vue } from 'vue-class-component' + +export type VForm = Vue & { + validate: (callback: (valid: boolean) => void) => void + resetValidation: () => boolean + reset: () => void + clearValidate: () => void +} \ No newline at end of file diff --git a/src/views/Login.vue b/src/views/Login.vue index a7530c6..947ad48 100644 --- a/src/views/Login.vue +++ b/src/views/Login.vue @@ -19,16 +19,15 @@ + diff --git a/src/views/system/SystemConfig.vue b/src/views/system/SystemConfig.vue index 4efda4e..55939c5 100644 --- a/src/views/system/SystemConfig.vue +++ b/src/views/system/SystemConfig.vue @@ -59,17 +59,16 @@ import { Options, Vue } from 'vue-class-component' import { AxiosResponse } from 'axios' import { ElButton, ElForm, ElFormItem, ElInput, ElTable, ElTableColumn, ElDialog, ElMessage, ElMessageBox } from 'element-plus' -import { ref } from 'vue' import moment from 'moment' import SystemConfigAdd from './SystemConfigAdd.vue' import { SystemConfigModel } from '../../model/system/system-config' +import { VForm } from '../../types' @Options({ name: 'SystemConfig', components: { ElButton, ElForm, ElFormItem, ElInput, ElTable, ElTableColumn, ElDialog, SystemConfigAdd } }) export default class SystemConfig extends Vue { - private readonly addForm: any = ref('addForm') modalLoading: boolean = false loading: boolean = false search: {name?:string} = {} @@ -111,7 +110,7 @@ export default class SystemConfig extends Vue { this.addModal = true } async save() { - this.addForm.$refs.configForm.validate(async (valid: boolean) => { + ((this.$refs.addForm as Vue).$refs.configForm as VForm).validate(async (valid: boolean) => { if(!valid) return this.modalLoading = true const { data } = await this.$http.post>('/api/system/config/save', this.formData) @@ -137,7 +136,7 @@ export default class SystemConfig extends Vue { } clearValidate() { this.$nextTick(() => { - this.addForm.$refs.configForm.clearValidate() + ((this.$refs.addForm as Vue).$refs.configForm as VForm).clearValidate() }) } /** diff --git a/src/views/system/SystemRole.vue b/src/views/system/SystemRole.vue index 0e48a8c..fc5b27a 100644 --- a/src/views/system/SystemRole.vue +++ b/src/views/system/SystemRole.vue @@ -97,14 +97,13 @@ import { Page } from '../../model/common.dto' import { SystemRoleModel } from '../../model/system/system-role' import { AxiosResponse } from 'axios' import { ElButton, ElForm, ElFormItem, ElInput, ElTable, ElTableColumn, ElTag, ElPagination, ElDialog, ElSelect, ElOption, ElMessage, ElMessageBox } from 'element-plus' -import { ref } from 'vue' +import { VForm } from '../../types' @Options({ name: 'SystemRole', components: { ElButton, ElForm, ElFormItem, ElInput, ElTable, ElTableColumn, ElTag, ElPagination, ElDialog, ElSelect, ElOption } }) export default class SystemRole extends BaseList { - private readonly roleForm: any = ref('roleForm') ruleValidate = { name: [ { required: true, message: '请输入角色名称', trigger: 'blur' } @@ -192,7 +191,7 @@ export default class SystemRole extends BaseList { }).catch(() => {}) } async save() { - this.roleForm.validate(async (valid: boolean) => { + (this.$refs.roleForm as VForm).validate(async (valid: boolean) => { if(!valid) return this.modalLoading = true const { data } = await this.$http.post>('/api/system/role/save', this.formData) @@ -204,7 +203,7 @@ export default class SystemRole extends BaseList { } clearValidate() { this.$nextTick(() => { - this.roleForm.clearValidate() + (this.$refs.roleForm as VForm).clearValidate() }) } } diff --git a/src/views/system/SystemUser.vue b/src/views/system/SystemUser.vue index e506681..ae7707a 100644 --- a/src/views/system/SystemUser.vue +++ b/src/views/system/SystemUser.vue @@ -77,14 +77,13 @@ import { SystemUserModel } from '../../model/system/system-user' import { SystemRoleModel } from '../../model/system/system-role' import { AxiosResponse } from 'axios' import { ElButton, ElForm, ElFormItem, ElInput, ElTable, ElTableColumn, ElPagination, ElDialog, ElSelect, ElOption, ElMessage, ElMessageBox } from 'element-plus' -import { ref } from 'vue' +import { VForm } from '../../types' @Options({ name: 'SystemUser', components: { ElButton, ElForm, ElFormItem, ElInput, ElTable, ElTableColumn, ElPagination, ElDialog, ElSelect, ElOption } }) export default class SystemUser extends BaseList { - private readonly userForm: any = ref('userForm') get ruleValidate() { return { username: [ @@ -148,8 +147,7 @@ export default class SystemUser extends BaseList { this.clearValidate() } async save() { - console.log(this.userForm) - this.userForm.validate(async (valid: boolean) => { + (this.$refs.userForm as VForm).validate(async (valid: boolean) => { if(!valid) return this.modalLoading = true const { data } = await this.$http.post>('/api/system/user/save', this.formData) @@ -178,7 +176,7 @@ export default class SystemUser extends BaseList { } clearValidate() { this.$nextTick(() => { - this.userForm.clearValidate() + (this.$refs.userForm as VForm).clearValidate() }) } } diff --git a/src/views/tool/SqlReplace.vue b/src/views/tool/SqlReplace.vue index 2598f72..174ab54 100644 --- a/src/views/tool/SqlReplace.vue +++ b/src/views/tool/SqlReplace.vue @@ -23,14 +23,12 @@