From 636a74500d2e7f01dad55fb0a06b9a929d33e4d2 Mon Sep 17 00:00:00 2001 From: Dong Xia Date: Mon, 30 Dec 2024 14:07:31 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E8=87=AA=E5=AE=9A=E4=B9=89?= =?UTF-8?q?=E5=8A=A0=E8=BD=BD=E6=8C=87=E4=BB=A4=EF=BC=8C=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=E5=8A=A0=E8=BD=BD=E5=8A=A8=E7=94=BB=E5=8D=A1=E9=A1=BF=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/directive/directive.js | 150 ++-- src/main.js | 76 +- src/pages/404/index.vue | 72 +- src/pages/audit/components/index.vue | 88 +- src/pages/repository/package/index.vue | 1106 ++++++++++++------------ src/pages/upgrade/index.vue | 17 +- 6 files changed, 742 insertions(+), 767 deletions(-) diff --git a/src/directive/directive.js b/src/directive/directive.js index 1c48cfe..e45305a 100644 --- a/src/directive/directive.js +++ b/src/directive/directive.js @@ -1,85 +1,65 @@ -const CUSTOMIZE_CLASS_NAME = 'customize'; -let formElementCache; - -function checkValue(el, binding) { - if (!formElementCache) { - formElementCache = document.getElementsByClassName('table-form')[0]; - if (!formElementCache) { - console.error('Element with class "table-form" not found'); - return; - } - } - - if (!binding.value) { - el.classList.add(CUSTOMIZE_CLASS_NAME); - formElementCache['validate'] = () => { - return false; - } - } else { - el.classList.remove(CUSTOMIZE_CLASS_NAME); - formElementCache['validate'] = () => { - return true; - } - } -} - -let validator = { - inserted: function(el, binding) { - checkValue(el, binding) - }, - update: function(el, binding) { - checkValue(el, binding) - } -} - - -function isBoolean(value) { - return typeof value === 'boolean'; -} - -let cachedCanvasId = null; - -/** - * 控制加载状态的显示与隐藏 - * @param {boolean} value - 是否显示加载状态 - * @param {function} [onError] - 错误处理回调函数 - */ -function loading(value, onError) { - if (!isBoolean(value)) { - const error = new Error(`Expected a Boolean value but got one ${typeof value}`); - console.error(error); - if (onError && typeof onError === 'function') { - onError(error); - } - return; - } - if (!cachedCanvasId) { - cachedCanvasId = document.getElementById('canvas-box'); - } - cachedCanvasId.style.display = value ? 'block' : 'none'; -} - -let waiting = { - inserted: function(el, binding) { - loading(binding.value.value) - let waitingText = document.getElementById('waiting-text') - binding.value.text && (waitingText.innerText = binding.value.text) - /* - * 参数详解: - * upTime 上移的时间 - * downTime 下落的时间 - * beatHeight 上移高度 - * isAuth 是否自动 - * isRotate 是否旋转 - */ - window.$(waitingText).beatText({ isAuth: true, beatHeight: '1em', isRotate: false, upTime: 100, downTime: 100 }) - }, - update: function(el, binding) { - loading(binding.value.value) - let waitingText = document.getElementById('waiting-text') - binding.value.text && (waitingText.innerText = binding.value.text) - window.$(waitingText).beatText({ isAuth: true, beatHeight: '1em', isRotate: false, upTime: 100, downTime: 100 }) - } -} - -export { validator, waiting } \ No newline at end of file +function checkValue(el, binding) { + const oldClassName = 'ant-row ant-form-item' + if (binding.value === '' || !binding.value) { + el.className = oldClassName + ' customize' + document.getElementsByClassName('table-form')[0]['validate'] = () => { + return false + } + } else { + el.className = oldClassName + document.getElementsByClassName('table-form')[0]['validate'] = () => { + return true + } + } +} + +let validator = { + inserted: function(el, binding) { + checkValue(el, binding) + }, + update: function(el, binding) { + checkValue(el, binding) + } +} + +// 根据值确定loading动画是否显示 +function loading(value) { + // 参数类型判断 + let type = typeof value + if (type !== 'boolean') { + // 抛出错误信息,用于提示开发人员 + console.error(new Error(`Expected a Boolean value but got one ${type}`)) + } + let canvasId = document.getElementById('canvas-box') + // eslint-disable-next-line no-extra-boolean-cast + if (!!value) { // 类型强转换,防止出现异常 + canvasId.style.display = 'block' + } else { + canvasId.style.display = 'none' + } +} + +let waiting = { + inserted: function(el, binding) { + loading(binding.value.value) + let waitingText = document.getElementById('waiting-text') + binding.value.text && (waitingText.innerText = binding.value.text) + /* + * 参数详解: + * upTime 上移的时间 + * downTime 下落的时间 + * beatHeight 上移高度 + * isAuth 是否自动 + * isRotate 是否旋转 + */ + window.$(waitingText).beatText({ isAuth: true, beatHeight: '1em', isRotate: false, upTime: 100, downTime: 100 }) + }, + update: function(el, binding) { + loading(binding.value.value) + let waitingText = document.getElementById('waiting-text') + binding.value.text && (waitingText.innerText = binding.value.text) + window.$(waitingText).beatText({ isAuth: true, beatHeight: '1em', isRotate: false, upTime: 100, downTime: 100 }) + } +} + +export { validator, waiting } diff --git a/src/main.js b/src/main.js index c89cd4c..5290b4f 100644 --- a/src/main.js +++ b/src/main.js @@ -1,37 +1,39 @@ -import Vue from 'vue' -import App from './App.vue' - -import Antd from 'ant-design-vue' -import 'ant-design-vue/dist/antd.css' -import './assets/reset.css' -import './assets/index.scss' -import { Tree, Progress, Loading } from 'element-ui' -import 'element-ui/lib/theme-chalk/index.css' - -import router from './router' -import store from './store' -import './router/auth' -import { validator, waiting } from '@/directive/directive' -import VueDraggableResizable from 'vue-draggable-resizable' -import CustomTable from '@/components/custom-table' - -window.routerBase = window.routerBase === '' ? '' : window.routerBase - -Vue.config.productionTip = false -Vue.prototype.$loading = Loading -Vue.directive('validator', validator) -Vue.use(Antd) -Vue.use(Tree) -Vue.use(Progress) -Vue.component('VueDraggableResizable', VueDraggableResizable) -Vue.directive('waiting', waiting) -Vue.component('CustomTable', CustomTable) - -new Vue({ - router, - store, - data: { - eventHub: new Vue() - }, - render: (h) => h(App) -}).$mount('#app') +import Vue from 'vue' +import App from './App.vue' + +import Antd from 'ant-design-vue' +import 'ant-design-vue/dist/antd.css' +import './assets/reset.css' +import './assets/index.scss' +import { Tree, Progress, Loading } from 'element-ui' +import 'element-ui/lib/theme-chalk/index.css' + +import router from './router' +import store from './store' +import './router/auth' +import { validator, waiting } from '@/directive/directive' +import VueDraggableResizable from 'vue-draggable-resizable' +import CustomTable from '@/components/custom-table' + +// debug routerBase +window.routerBase = window.routerBase === '' ? '' : window.routerBase + +Vue.config.productionTip = false +Vue.prototype.$loading = Loading +Vue.directive('validator', validator) +Vue.use(Antd) +Vue.use(Tree) +Vue.use(Progress) +Vue.component('VueDraggableResizable', VueDraggableResizable) +Vue.directive('waiting', waiting) +// 全局注册二次封装的表格 +Vue.component('CustomTable', CustomTable) + +new Vue({ + router, + store, + data: { + eventHub: new Vue() + }, + render: (h) => h(App) +}).$mount('#app') diff --git a/src/pages/404/index.vue b/src/pages/404/index.vue index 77ef6de..a21837c 100644 --- a/src/pages/404/index.vue +++ b/src/pages/404/index.vue @@ -1,36 +1,36 @@ - - - - - + + + + + diff --git a/src/pages/audit/components/index.vue b/src/pages/audit/components/index.vue index 4808e57..b58ef66 100644 --- a/src/pages/audit/components/index.vue +++ b/src/pages/audit/components/index.vue @@ -1,44 +1,44 @@ - - - - - \ No newline at end of file + + + + + diff --git a/src/pages/repository/package/index.vue b/src/pages/repository/package/index.vue index ea2565e..93f25d5 100644 --- a/src/pages/repository/package/index.vue +++ b/src/pages/repository/package/index.vue @@ -1,553 +1,553 @@ - - - - - + + + + + diff --git a/src/pages/upgrade/index.vue b/src/pages/upgrade/index.vue index 4a4cc24..0bf59da 100644 --- a/src/pages/upgrade/index.vue +++ b/src/pages/upgrade/index.vue @@ -224,7 +224,7 @@ export default { fetchTable() { this.loading = true return new Promise((resolve, reject) => { - const params = { + nodePkgOp({ pkgName: this.tableQuery.packageName, nodeName: this.tableQuery.nodeName, startTime: this.tableQuery.timeRange?.[0], @@ -232,18 +232,11 @@ export default { success: this.tableQuery.upgradeRes === '' ? '' : Boolean(this.tableQuery.upgradeRes), opType: this.tableQuery.opType, ...this.listQuery - } - if (!params.pkgName || !params.nodeName || !params.startTime || !params.endTime) { - reject(new Error('Invalid input parameters')) - return - } - nodePkgOp(params) + }) .then(res => { - if(res && res.code === 200) { - this.upgradeList = res?.data?.list || [] - this.total = +res?.data?.total || 0 - resolve(res) - } + this.upgradeList = res?.data?.list || [] + this.total = +res?.data?.total || 0 + resolve(res) }) .catch(err => reject(err)) .finally(() => { -- Gitee