From 0aca3945e83424a3575c440c39032359071cd291 Mon Sep 17 00:00:00 2001 From: chengmingrui Date: Tue, 3 Jun 2025 17:17:02 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B9=B3=E5=8F=B0=E5=A2=9E=E5=8A=A0=E9=80=82?= =?UTF-8?q?=E9=85=8D=20=E5=93=81=E9=AB=98=E4=BA=91=E5=92=8C=E6=B5=B7?= =?UTF-8?q?=E4=BA=91=E5=92=8C=E5=8D=8E=E4=B8=BA=E4=BA=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .eslintrc.js | 53 ++++--- src/common/css/hack.scss | 15 +- src/filters/index.js | 68 ++++++--- src/main.ts | 21 +-- .../bsm-cache/cmdbServer/middleServer2.vue | 42 +++--- src/views/repository/component/selectHost.vue | 134 ++++++++---------- .../repository/component/selectServer.vue | 119 +++++++--------- src/views/resource-manage/host/host.vue | 79 ++++------- .../task/graph/targetServer/SelectServer.vue | 72 +++++----- tsconfig.json | 1 + 10 files changed, 275 insertions(+), 329 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index 400a293..46c1f74 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -1,29 +1,24 @@ -module.exports = { - root: true, - env: { - node: true - }, - extends: ['plugin:vue/essential', '@vue/standard', '@vue/typescript'], - rules: { - 'no-console': process.env.NODE_ENV === 'production' ? 'error' : 'off', - 'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off', - 'no-unused-vars': [ - 0, - { - vars: 'all', - args: 'none' - } - ], - semi: 0, - eqeqeq: 0, - 'one-var': 0, - camelcase: 0, - 'no-case-declarations': 0, - 'space-before-function-paren': 0, - 'vue/no-parsing-error': [2, { "x-invalid-end-tag": false }], - '@typescript-eslint/indent': ['error', 2] - }, - parserOptions: { - parser: '@typescript-eslint/parser' - } -}; +module.exports = { + root: true, + env: { + node: true, + }, + extends: ['plugin:vue/essential', '@vue/standard', '@vue/typescript'], + rules: { + 'no-console': process.env.NODE_ENV === 'production' ? 'error' : 'off', + 'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off', + 'no-unused-vars': [0, { vars: 'all', args: 'none' }], + semi: 0, + eqeqeq: 0, + 'one-var': 0, + camelcase: 0, + 'no-case-declarations': 0, + 'space-before-function-paren': 0, + 'vue/no-parsing-error': [2, { 'x-invalid-end-tag': false }], + '@typescript-eslint/indent': ['error', 2], + 'comma-dangle': ['error', 2], + }, + parserOptions: { + parser: '@typescript-eslint/parser', + }, +} diff --git a/src/common/css/hack.scss b/src/common/css/hack.scss index 0fb2df6..dce3361 100644 --- a/src/common/css/hack.scss +++ b/src/common/css/hack.scss @@ -1,10 +1,9 @@ -@media screen and(-ms-high-contrast:active), -(-ms-high-contrast:none) { - .el-table__header, - .el-table__body { - width: 100% !important; - } - /* .basic-form-item{ +@media screen and (-ms-high-contrast: active), (-ms-high-contrast: none) { + .el-table__header, + .el-table__body { + width: 100% !important; + } + /* .basic-form-item{ height: 32.76px; } */ -} \ No newline at end of file +} diff --git a/src/filters/index.js b/src/filters/index.js index 2a1f36b..2947a99 100644 --- a/src/filters/index.js +++ b/src/filters/index.js @@ -1,3 +1,5 @@ +import Vue from 'vue' + // 正反编译 export function booleanFilter(value) { const obj = { @@ -6,7 +8,7 @@ export function booleanFilter(value) { 1: '是', 0: '否', YES: '是', - NO: '否' + NO: '否', } return obj[value] || value } @@ -29,7 +31,10 @@ export function vmStatusFilter(status) { UNKNOWN: '已断开', UNKNOWNON: '已断开', UNKNOWNOFF: '已断开', - UNKNOWNSUSPEND: '已断开' + UNKNOWNSUSPEND: '已断开', + RECYCLING: '回收中', + MIGRATING: '迁移中', + FAULT_RESUMING: '故障恢复中', } return statusMap[status] || '未知' } @@ -95,7 +100,10 @@ export function vmStatusColorFilter(status) { DISABLED: 'danger', DEALLOCATEING: 'warning', PROTECTING: 'warning', - DOWN: 'info' + DOWN: 'info', + RECYCLING: 'warning', + MIGRATING: 'warning', + FAULT_RESUMING: 'warning', } return statusMap[status] || 'danger' } @@ -104,12 +112,12 @@ export function taskStatusFilter(value, type) { const statusMap = { DEVELOPING: '开发中', APPROVING: '发布中', - APPROVED: ' 已发布' + APPROVED: ' 已发布', } const colorMap = { DEVELOPING: 'normal', APPROVING: 'warning', - APPROVED: 'success' + APPROVED: 'success', } return type === 'color' ? colorMap[value] : statusMap[value] } @@ -123,7 +131,7 @@ export function taskTypeFilter(value) { RECOVERY: '文件恢复', HTTP: 'HTTP请求', DATABASE: '数据库', - POINT: '聚合节点' + POINT: '聚合节点', } return obj[value] } @@ -140,20 +148,20 @@ export function applyStatusFilter(value, type) { // }, APPROVED: { name: '已发布', - color: 'success' + color: 'success', }, DEVELOPING: { name: '开发中', - color: 'normal' + color: 'normal', }, UNAPPLY: { name: '未发布', - color: 'primary' + color: 'primary', }, CREATED: { name: '新创建', - color: 'normal' - } + color: 'normal', + }, } return obj[value] && obj[value][type] } @@ -162,48 +170,62 @@ export function taskExeStatusFilter(value, type = 'name') { const obj = { CREATED: { name: '未执行', - color: 'normal' + color: 'normal', }, NOREADY: { name: '已跳过', - color: 'warning' + color: 'warning', }, READY: { name: '准备中', - color: 'normal' + color: 'normal', }, WAITTING: { name: '等待执行', - color: 'primary' + color: 'primary', }, CANCELING: { name: '取消中', - color: 'primary' + color: 'primary', }, RUNNING: { name: '正在执行', - color: 'normal' + color: 'normal', }, SUCCESS: { name: '执行成功', - color: 'success' + color: 'success', }, SUSPENDED: { name: '已暂停', - color: 'warning' + color: 'warning', }, FAILED: { name: '执行失败', - color: 'danger' + color: 'danger', }, CANCELED: { name: '手动结束', - color: 'warning' + color: 'warning', }, EXCEPTION: { name: '执行异常', - color: 'danger' - } + color: 'danger', + }, } return obj[value] && obj[value][type] // 容错处理(初始化值不存在) } +const filters = { + booleanFilter, + vmStatusFilter, + vmStatusColorFilter, + taskStatusFilter, + taskTypeFilter, + applyStatusFilter, + taskExeStatusFilter, +} + +// 注册全局过滤器 +Object.keys(filters).forEach((key) => { + Vue.filter(key, filters[key]) +}) diff --git a/src/main.ts b/src/main.ts index 080a558..5b6b780 100644 --- a/src/main.ts +++ b/src/main.ts @@ -21,21 +21,22 @@ import './icons' import VueCompositionAPI from '@vue/composition-api' import rules from '@/validate/index' import actions from './shared/action' +import './filters' -Vue.use(ElementUI, { size: 'small' }); +Vue.use(ElementUI, { size: 'small' }) Vue.use(VueCompositionAPI) Vue.use(CmpElement, { rules }) Vue.use(CmpEcharts) Vue.config.productionTip = false let instance: any = null -function render(props:any) { - const { appPath = '', container } = props; +function render(props: any) { + const { appPath = '', container } = props instance = new Vue({ router, store, - render: h => h(App) - }).$mount(container ? container.querySelector('#app') : '#app'); + render: (h) => h(App), + }).$mount(container ? container.querySelector('#app') : '#app') store.commit('SET_APP_PATH', appPath) } if (!(window as any).__POWERED_BY_QIANKUN__) { @@ -48,8 +49,8 @@ export async function bootstrap() { } export async function mount(props: any) { - console.log('cop app mounted'); - const getStyle = window.getComputedStyle; + console.log('cop app mounted') + const getStyle = window.getComputedStyle // @ts-ignore // window.getComputedStyle = (element, property) => { // if (!element || element.nodeType === 9) return {}; @@ -57,10 +58,10 @@ export async function mount(props: any) { // }; render(props) actions.init(props, (state: any) => { - const { permissions, userData } = state; - userData && store.commit('SET_USERDATA', userData); + const { permissions, userData } = state + userData && store.commit('SET_USERDATA', userData) if (!store.getters.addRoutes && permissions) { - store.dispatch('permission/GenerateRoutes'); + store.dispatch('permission/GenerateRoutes') } }) } diff --git a/src/views/bsm-cache/cmdbServer/middleServer2.vue b/src/views/bsm-cache/cmdbServer/middleServer2.vue index 0dc7379..ce21263 100644 --- a/src/views/bsm-cache/cmdbServer/middleServer2.vue +++ b/src/views/bsm-cache/cmdbServer/middleServer2.vue @@ -83,9 +83,7 @@ @@ -110,36 +108,34 @@ export default { mixins: [show], props: { itemData: { - type: Object + type: Object, }, osCategory: { type: String, - default: '' + default: '', }, hasResource: { type: Boolean, - default: false - } + default: false, + }, }, data() { return { - vmStatusFilter, - vmStatusColorFilter, list: null, total: null, listQuery: { name: '', - privateIps: '' + privateIps: '', }, params: { page: 1, - rows: 10 + rows: 10, }, dialogServerVisible: false, vendorOptions: '', selectList: [], idList: [], - http: getResource + http: getResource, } }, created() { @@ -148,12 +144,12 @@ export default { computed: { path() { return this.$route.path - } + }, }, watch: { path(val) { this.http = val.includes('PatchDeploy') ? getHosts : getResource - } + }, }, methods: { clearCustomParams() { @@ -183,7 +179,7 @@ export default { this.listQuery = { name: '', privateIps: '', - vendorId: '' + vendorId: '', } this.params.page = 1 this.selectList = [] @@ -196,7 +192,7 @@ export default { host: data.host, username: data.user, password: data.pasd, - osCategory: data.category + osCategory: data.category, }) }) this.dialogServerVisible = true @@ -206,7 +202,7 @@ export default { this.$confirm('您确定要清空所选主机吗?', '提示', { confirmButtonText: '清空', confirmButtonClass: 'el-button--danger', - type: 'warning' + type: 'warning', }).then(() => { this.clearCustomParams() this.itemData.hostList = [] @@ -223,7 +219,7 @@ export default { }, getVendor() { getCloudVendor({ - simple: true + simple: true, }).then((data) => { if (data.success) { this.vendorOptions = data.data.rows @@ -305,7 +301,7 @@ export default { category: this.path.includes('PatchDeploy') ? '' : 'Computer', catalog: this.path.includes('PatchDeploy') ? 'Computer' : '', osCategory: this.osCategory, - vendorId: this.listQuery.vendorId + vendorId: this.listQuery.vendorId, }) this.getList() }, @@ -326,7 +322,7 @@ export default { pasd: data.password || getPassword(data), port: data.osCategory.toUpperCase() === 'WINDOWS' ? 5986 : 22, category: data.osCategory, - privateIps: this.path.includes('PatchDeploy') ? '' : data.privateIps + privateIps: this.path.includes('PatchDeploy') ? '' : data.privateIps, } if (data.paramsList) { tmp.paramsList = data.paramsList @@ -339,13 +335,13 @@ export default { this.itemData.resourceList = this.itemData.hostList.slice() this.itemData.resourceList.unshift({ id: 0, - rawName: '选择全部' + rawName: '选择全部', }) } this.clearCustomParams() this.dialogServerVisible = false - } - } + }, + }, } diff --git a/src/views/repository/component/selectServer.vue b/src/views/repository/component/selectServer.vue index 95f5c33..53d03a6 100644 --- a/src/views/repository/component/selectServer.vue +++ b/src/views/repository/component/selectServer.vue @@ -11,32 +11,24 @@ - - + @@ -57,22 +49,18 @@ - + - - + - - + - - + 搜索 @@ -82,24 +70,21 @@ - - +