From 377c28c57049d453108f9da41b168e1fdb64d7e1 Mon Sep 17 00:00:00 2001 From: tk Date: Fri, 20 Dec 2024 18:47:38 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=F0=9F=90=9B=20=E6=A0=B7=E5=BC=8F?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/frontend/admin/package.json | 2 +- .../src/components/scIconSelect/index.vue | 2 +- .../admin/src/components/scTable/index.vue | 18 +-- .../admin/src/layout/components/search.vue | 9 +- .../admin/src/layout/components/tasks.vue | 117 ++++++++---------- .../admin/src/layout/components/userbar.vue | 95 +++++++------- src/frontend/admin/src/main.js | 2 + src/frontend/admin/src/style/fix.scss | 4 + .../admin/src/utils/passiveEventListener.js | 77 ++++++++++++ .../components/components/chart-pie.vue | 3 - .../admin/src/views/sys/job/all/save.vue | 6 +- .../admin/src/views/sys/role/index.vue | 2 +- .../admin/src/views/sys/role/save.vue | 2 +- .../admin/src/views/sys/user/index.vue | 13 +- 14 files changed, 218 insertions(+), 134 deletions(-) create mode 100644 src/frontend/admin/src/utils/passiveEventListener.js diff --git a/src/frontend/admin/package.json b/src/frontend/admin/package.json index 6fd1ba59..c3e48ac6 100644 --- a/src/frontend/admin/package.json +++ b/src/frontend/admin/package.json @@ -36,7 +36,7 @@ "prettier-plugin-organize-attributes": "1.0.0", "sass": "1.82.0", "terser": "5.37.0", - "vite": "6.0.3" + "vite": "5.1.8" }, "browserslist": [ "> 1%", diff --git a/src/frontend/admin/src/components/scIconSelect/index.vue b/src/frontend/admin/src/components/scIconSelect/index.vue index 29b0f67e..b8a62cfc 100644 --- a/src/frontend/admin/src/components/scIconSelect/index.vue +++ b/src/frontend/admin/src/components/scIconSelect/index.vue @@ -39,7 +39,7 @@ diff --git a/src/frontend/admin/src/components/scTable/index.vue b/src/frontend/admin/src/components/scTable/index.vue index 5a7bab3c..ba7e1aae 100644 --- a/src/frontend/admin/src/components/scTable/index.vue +++ b/src/frontend/admin/src/components/scTable/index.vue @@ -55,11 +55,11 @@ :page-size="scPageSize" :page-sizes="pageSizes" :pager-count="pagerCount" - :small="true" :total="total" @current-change="paginationChange" @update:page-size="pageSizeChange" - background> + background + size="small">
- {{ $t('大') }} - {{ $t('正常') }} - {{ $t('小') }} + {{ $t('大') }} + {{ $t('正常') }} + {{ $t('小') }} @@ -232,6 +232,7 @@ export default { fieldFilter, }, props: { + dblClickDisable: { type: Boolean, default: false }, vue: { type: Object }, contextMenus: { type: Array }, contextOpers: { type: Array, default: ['copy', 'add', 'view', 'edit', 'del'] }, @@ -309,7 +310,7 @@ export default { }, data() { return { - pagerCount: 10, + pagerCount: 11, current: { row: null, column: null, @@ -338,7 +339,7 @@ export default { } }, mounted() { - this.pagerCount = document.body.clientWidth < 1000 ? 3 : 10 + this.pagerCount = document.body.clientWidth < 1000 ? 3 : 11 //判断是否开启自定义列 if (this.column) { this.getCustomColumn() @@ -363,6 +364,9 @@ export default { }, methods: { dbClick(row) { + if (this.dblClickDisable) { + return + } if (this.vue.dialog) { this.vue.dialog.save = { mode: 'view', row: { id: row.id } } } diff --git a/src/frontend/admin/src/layout/components/search.vue b/src/frontend/admin/src/layout/components/search.vue index 9517c898..b5650dd3 100644 --- a/src/frontend/admin/src/layout/components/search.vue +++ b/src/frontend/admin/src/layout/components/search.vue @@ -48,7 +48,6 @@ export default { data() { return { cursor: { - position: 0, index: 0, }, input: '', @@ -59,7 +58,6 @@ export default { }, watch: { result() { - this.cursor.position = 0 this.cursor.index = 0 }, }, @@ -86,12 +84,15 @@ export default { return } if (e.keyCode === 40) { - this.cursor.index = Math.abs(++this.cursor.position % this.result.length) + this.cursor.index = ++this.cursor.index % this.result.length e.preventDefault() return } if (e.keyCode === 38) { - this.cursor.index = Math.abs(--this.cursor.position % this.result.length) + this.cursor.index = --this.cursor.index % this.result.length + if (this.cursor.index < 0) { + this.cursor.index += this.result.length + } e.preventDefault() return } diff --git a/src/frontend/admin/src/layout/components/tasks.vue b/src/frontend/admin/src/layout/components/tasks.vue index afd91ea6..771a2e0e 100644 --- a/src/frontend/admin/src/layout/components/tasks.vue +++ b/src/frontend/admin/src/layout/components/tasks.vue @@ -1,13 +1,41 @@ - +
{{ job.httpStatusCode.toUpperCase().slice(0, 2) }} @@ -32,15 +66,8 @@

-
- {{ job.responseBody }} -
-
- +
+ {{ job.responseBody }}
@@ -52,6 +79,7 @@ v-for="job in jobs" :class="`user-bar-jobs-item ${job.lastStatusCode === 'oK' ? '' : 'alert'}`" :key="job.id" + @click="dialog.jobSave = { mode: 'view', row: { id: job.id }, tabId: 'record' }" shadow="hover">
@@ -72,13 +100,6 @@ >{{ $t('空闲') }}
-
- -
@@ -86,37 +107,6 @@ - -
- - {{ $t('异常日志') }} - -
- -
- - {{ $t('作业管理') }} - -
-
import { defineAsyncComponent } from 'vue' +import scPageHeader from '@/components/scPageHeader' const jobSaveDialog = defineAsyncComponent(() => import('@/views/sys/job/all/save.vue')) const jobRecordSaveDialog = defineAsyncComponent(() => import('@/views/sys/job/record/save.vue')) @@ -144,6 +135,7 @@ export default { }, }, components: { + scPageHeader, jobSaveDialog, jobRecordSaveDialog, }, @@ -170,6 +162,7 @@ export default { value: true, operator: 'eq', }, + pageSize: 10, }), this.$API.sys_job.pagedQueryRecord.post({ dynamicFilter: { @@ -204,6 +197,7 @@ export default { operator: 'greaterThan', value: this.failJobViewTime, }, + pageSize: 10, }), ]) @@ -229,6 +223,7 @@ export default { \ No newline at end of file diff --git a/src/frontend/admin/src/layout/components/userbar.vue b/src/frontend/admin/src/layout/components/userbar.vue index 499b9552..02b7345c 100644 --- a/src/frontend/admin/src/layout/components/userbar.vue +++ b/src/frontend/admin/src/layout/components/userbar.vue @@ -74,7 +74,7 @@ - + @@ -100,49 +100,7 @@ export default { this.user = this.$GLOBAL.user let res = await this.$API.sys_sitemsg.unreadCount.post() this.unreadCnt = res.data - - if (this.$GLOBAL.permissions.some((x) => x === '*/*/*' || x === 'sys/job/userbar')) { - res = await this.$API.sys_job.countRecord.post({ - dynamicFilter: { - filters: [ - { - field: 'createdTime', - operator: 'dateRange', - value: [ - this.$TOOL.data.get('APP_SET_FAIL_JOB_VIEW_TIME') ?? this.$TOOL.dateFormat(new Date(), 'yyyy-MM-dd'), - this.$TOOL.dateFormat(new Date(), 'yyyy-MM-dd hh:mm:ss'), - ], - }, - { - logic: 'or', - filters: [ - { - field: 'httpStatusCode', - operator: 'range', - value: '300,399', - }, - { - field: 'httpStatusCode', - operator: 'range', - value: '400,499', - }, - { - field: 'httpStatusCode', - operator: 'range', - value: '500,599', - }, - { - field: 'httpStatusCode', - operator: 'range', - value: '900,999', - }, - ], - }, - ], - }, - }) - this.failJobCnt = res.data - } + await this.getFailJobsCnt() }, data() { return { @@ -160,6 +118,55 @@ export default { } }, methods: { + async getFailJobsCnt() { + if (this.$GLOBAL.permissions.some((x) => x === '*/*/*' || x === 'sys/job/userbar')) { + const res = await this.$API.sys_job.countRecord.post({ + dynamicFilter: { + filters: [ + { + field: 'createdTime', + operator: 'dateRange', + value: [ + this.$TOOL.data.get('APP_SET_FAIL_JOB_VIEW_TIME') ?? this.$TOOL.dateFormat(new Date(), 'yyyy-MM-dd'), + this.$TOOL.dateFormat(new Date(), 'yyyy-MM-dd hh:mm:ss'), + ], + }, + { + logic: 'or', + filters: [ + { + field: 'httpStatusCode', + operator: 'range', + value: '300,399', + }, + { + field: 'httpStatusCode', + operator: 'range', + value: '400,499', + }, + { + field: 'httpStatusCode', + operator: 'range', + value: '500,599', + }, + { + field: 'httpStatusCode', + operator: 'range', + value: '900,999', + }, + ], + }, + ], + }, + }) + this.failJobCnt = res.data + } + }, + taskClose() { + setTimeout(() => { + this.getFailJobsCnt() + }, 2000) + }, clearData(fullClear) { const loading = this.$loading() this.$TOOL.cookie.clear() diff --git a/src/frontend/admin/src/main.js b/src/frontend/admin/src/main.js index 1c49d1fc..10ac8dda 100644 --- a/src/frontend/admin/src/main.js +++ b/src/frontend/admin/src/main.js @@ -8,12 +8,14 @@ import router from './router' import store from './store' import App from './App.vue' import preload from '@/utils/preload' +import passiveEventListener from '@/utils/passiveEventListener' const app = createApp(App) app.use(ElementPlus) app.use(store) app.use(i18n) app.use(global) +app.use(passiveEventListener) preload.install(app).then(() => { app.use(router) diff --git a/src/frontend/admin/src/style/fix.scss b/src/frontend/admin/src/style/fix.scss index 2d278401..c4cc1a74 100644 --- a/src/frontend/admin/src/style/fix.scss +++ b/src/frontend/admin/src/style/fix.scss @@ -332,4 +332,8 @@ .el-collapse-item__header { color: var(--el-text-color-regular); +} + +.adminui-header .el-drawer__header { + margin-bottom: 0; } \ No newline at end of file diff --git a/src/frontend/admin/src/utils/passiveEventListener.js b/src/frontend/admin/src/utils/passiveEventListener.js new file mode 100644 index 00000000..5a9b3562 --- /dev/null +++ b/src/frontend/admin/src/utils/passiveEventListener.js @@ -0,0 +1,77 @@ +export default { + install() { + const eventListenerOptionsSupported = () => { + let supported = false + + try { + const opts = Object.defineProperty({}, 'passive', { + get() { + supported = true + }, + }) + + window.addEventListener('test', null, opts) + window.removeEventListener('test', null, opts) + } catch (e) {} + + return supported + } + + const defaultOptions = { + passive: true, + capture: false, + } + const supportedPassiveTypes = [ + 'scroll', + 'wheel', + 'touchstart', + 'touchmove', + 'touchenter', + 'touchend', + 'touchleave', + 'mouseout', + 'mouseleave', + 'mouseup', + 'mousedown', + 'mousemove', + 'mouseenter', + 'mousewheel', + 'mouseover', + ] + const getDefaultPassiveOption = (passive, eventName) => { + if (passive !== undefined) return passive + + return supportedPassiveTypes.indexOf(eventName) === -1 ? false : defaultOptions.passive + } + + const getWritableOptions = (options) => { + const passiveDescriptor = Object.getOwnPropertyDescriptor(options, 'passive') + + return passiveDescriptor && passiveDescriptor.writable !== true && passiveDescriptor.set === undefined + ? Object.assign({}, options) + : options + } + + const overwriteAddEvent = (superMethod) => { + EventTarget.prototype.addEventListener = function (type, listener, options) { + const usesListenerOptions = typeof options === 'object' && options !== null + const useCapture = usesListenerOptions ? options.capture : options + + options = usesListenerOptions ? getWritableOptions(options) : {} + options.passive = getDefaultPassiveOption(options.passive, type) + options.capture = useCapture === undefined ? defaultOptions.capture : useCapture + + superMethod.call(this, type, listener, options) + } + + EventTarget.prototype.addEventListener._original = superMethod + } + + const supportsPassive = eventListenerOptionsSupported() + + if (supportsPassive) { + const addEvent = EventTarget.prototype.addEventListener + overwriteAddEvent(addEvent) + } + }, +} \ No newline at end of file diff --git a/src/frontend/admin/src/views/home/widgets/components/components/chart-pie.vue b/src/frontend/admin/src/views/home/widgets/components/components/chart-pie.vue index 62f9f224..0467a79f 100644 --- a/src/frontend/admin/src/views/home/widgets/components/components/chart-pie.vue +++ b/src/frontend/admin/src/views/home/widgets/components/components/chart-pie.vue @@ -44,9 +44,6 @@ export default { show: true, alignTo: 'labelLine', formatter: '{b} {d}%', - textStyle: { - textBorderColor: 'transparent', - }, }, radius: this.api[i++].radius, type: 'pie', diff --git a/src/frontend/admin/src/views/sys/job/all/save.vue b/src/frontend/admin/src/views/sys/job/all/save.vue index bee68927..0c13fae0 100644 --- a/src/frontend/admin/src/views/sys/job/all/save.vue +++ b/src/frontend/admin/src/views/sys/job/all/save.vue @@ -45,7 +45,9 @@ :theme="this.$TOOL.data.get('APP_SET_DARK') || this.$CONFIG.APP_SET_DARK ? 'github_dark' : 'github'" lang="json" style="height: 10rem; width: 100%" /> - {{ $t('JSON 格式化') }} + {{ $t('JSON 格式化') }} + - {{ $t('JSON 格式化') }} + {{ $t('JSON 格式化') }} diff --git a/src/frontend/admin/src/views/sys/role/index.vue b/src/frontend/admin/src/views/sys/role/index.vue index 8b9d711a..1b03e8fa 100644 --- a/src/frontend/admin/src/views/sys/role/index.vue +++ b/src/frontend/admin/src/views/sys/role/index.vue @@ -137,7 +137,7 @@ diff --git a/src/frontend/admin/src/views/sys/role/save.vue b/src/frontend/admin/src/views/sys/role/save.vue index 3c5196c3..e3b371e1 100644 --- a/src/frontend/admin/src/views/sys/role/save.vue +++ b/src/frontend/admin/src/views/sys/role/save.vue @@ -79,7 +79,7 @@ :theme="this.$TOOL.data.get('APP_SET_DARK') || this.$CONFIG.APP_SET_DARK ? 'github_dark' : 'github'" lang="json" style="height: 30rem; width: 100%" /> - {{ $t('JSON 格式化') }} diff --git a/src/frontend/admin/src/views/sys/user/index.vue b/src/frontend/admin/src/views/sys/user/index.vue index 6bfcd774..6b28976c 100644 --- a/src/frontend/admin/src/views/sys/user/index.vue +++ b/src/frontend/admin/src/views/sys/user/index.vue @@ -189,6 +189,12 @@ export default { }, }, async created() { + if (this.roleId) { + this.query.filter.roleId = this.roleId + } + if (this.deptId) { + this.query.filter.deptId = this.deptId + } const res = await this.$API.sys_dept.query.post({}) this.deptTree = [ @@ -198,13 +204,6 @@ export default { children: res.data, }, ] - - if (this.roleId) { - this.query.filter.roleId = this.roleId - } - if (this.deptId) { - this.query.filter.deptId = this.deptId - } }, data() { return {