diff --git a/src/directive/directive.js b/src/directive/directive.js index 1c48cfef82faaa3c7aa1586545d9c47f8d93063b..e45305ae961e05b5c4ba7f90ed4e43d9d11289a7 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 c89cd4cee164011c13a4946aad29d6ed6bc5a80c..5290b4feb44e815ef4563dac178111ea43fcd54b 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 77ef6dea427308348daedd1326f543eda1922732..a21837cd3e63c32cd7edfd435fffb8e538a2e732 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 4808e57231c169021171ce8c0e91c2b94226d9e4..b58ef66c1dc986b6e21b0e949ecb87f20e61ac22 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 ea2565e7869d9344c083f34daa4861d5083fc401..93f25d5230ba12a83551d545aad2f11f9c97b7fe 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 4a4cc24523339855218f151afcdc8997dca13e3c..0bf59daef47bb01cd3210cd3e764c44bf637ee45 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(() => {