From 3c606399e3741511843702f25c4892d88b738a56 Mon Sep 17 00:00:00 2001 From: GONGONGONG <506419689@qq.com> Date: Wed, 6 Sep 2023 14:18:18 +0800 Subject: [PATCH] =?UTF-8?q?feat:=202.0=20Proxy=20=E6=94=AF=E6=8C=81?= =?UTF-8?q?=E9=85=8D=E7=BD=AE=E4=B8=B4=E6=97=B6=E6=96=87=E4=BB=B6=E4=BC=A0?= =?UTF-8?q?=E8=BE=93=E8=B7=AF=E5=BE=84=20(closed=20#1757)=20(#1795)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/common/form-check.ts | 6 +++++ .../setup-table/install-input-type.vue | 5 +++- .../components/setup-table/install-table.vue | 26 ++++++++++++++----- frontend/src/types/config/config.ts | 1 + frontend/src/types/index.ts | 1 + .../cloud-manager-add/cloud-manager-setup.vue | 10 +++---- .../components/sideslider-content-edit.vue | 9 ++++--- .../src/views/cloud/config/netTableConfig.ts | 10 +++++-- .../gse-config/set-access-point/step-info.vue | 7 +++-- 9 files changed, 53 insertions(+), 22 deletions(-) diff --git a/frontend/src/common/form-check.ts b/frontend/src/common/form-check.ts index 54dbc08c7..7ba6d7c9b 100644 --- a/frontend/src/common/form-check.ts +++ b/frontend/src/common/form-check.ts @@ -137,3 +137,9 @@ export function regrLengthCheck(val, max = 32, min = 0) { const len = val.replace(/[\u0391-\uFFE5]/g, 'aa').length; return len >= min && len <= max; } + +export function osDirReplace(str: string, filler = '/'): string { + const value = str.trim().replace(/[/\\]+/ig, '/'); + const pathArr = value.split('/').filter((item: string) => !!item); + return pathArr.join(filler); +} diff --git a/frontend/src/components/setup-table/install-input-type.vue b/frontend/src/components/setup-table/install-input-type.vue index 7d318326f..9690964df 100644 --- a/frontend/src/components/setup-table/install-input-type.vue +++ b/frontend/src/components/setup-table/install-input-type.vue @@ -316,7 +316,10 @@ export default class InputType extends Mixins(emitter) { public handleBlur(value: IValue, event?: Event) { this.isFocus = false; this.handleEmitBlur(value, event); - this.dispatch('step-verify-input', 'verify-blur', this.inputValue); + // 优化 - 兼容需要对值做修改之后再进行校验情况 + this.$nextTick(() => { + this.dispatch('step-verify-input', 'verify-blur', this.inputValue); + }); } /** * 文件变更时事件 diff --git a/frontend/src/components/setup-table/install-table.vue b/frontend/src/components/setup-table/install-table.vue index 12614ef03..f00a59051 100644 --- a/frontend/src/components/setup-table/install-table.vue +++ b/frontend/src/components/setup-table/install-table.vue @@ -160,7 +160,7 @@ fileInfo: getCellFileInfo(row, config) }" @focus="handleCellFocus(arguments, { row, config, rowIndex, colIndex })" - @blur="handleCellBlur" + @blur="handleCellBlur(arguments, { row, config, rowIndex, colIndex })" @input="handleCellValueInput(arguments, row, config)" @change="handleCellValueChange(row, config)" @upload-change="handleCellUploadChange($event, row)"> @@ -195,6 +195,8 @@ import { Context } from 'vm'; import { IFileInfo, IKeysMatch, ISetupHead, ISetupRow, ITabelFliter, ISetupParent } from '@/types'; import { getDefaultConfig, passwordFillText } from '@/config/config'; import { splitCodeArr } from '@/common/regexp'; +import { IAp } from '@/types/config/config'; +import { ICloudSource } from '@/types/cloud/cloud'; interface IFilterRow { [key: string]: ITabelFliter @@ -239,6 +241,9 @@ export default class SetupTable extends Vue { @Prop({ type: String, default: '' }) private readonly localMark!: string; @Prop({ type: Function }) private readonly beforeDelete!: Function; @Prop({ type: Number }) private readonly bkCloudId!: number; + @Prop({ type: Array }) private readonly aps!: IAp[]; + @Prop({ type: Array }) private readonly clouds!: ICloudSource[]; + @Prop() private readonly arbitrary!: any; // 可以是任意值, 用来在config文件里做为必要的一些参数 @Ref('tableBody') private readonly tableBody!: any; @Ref('scrollPlace') private readonly scrollPlace!: any; @@ -269,10 +274,10 @@ export default class SetupTable extends Vue { return AgentStore.fetchPwd; } private get cloudList() { - return AgentStore.cloudList; + return this.clouds || AgentStore.cloudList; } private get apList() { - return AgentStore.apList; + return this.aps || AgentStore.apList; } private get channelList() { return AgentStore.channelList; @@ -386,7 +391,7 @@ export default class SetupTable extends Vue { private addPropToData(row: ISetupRow | any, config: ISetupHead) { const prop = config.prop as keyof ISetupRow; if (typeof config.getDefaultValue === 'function') { - row[prop] = config.getDefaultValue(row); + row[prop] = config.getDefaultValue.call(this, row); } else { row[prop] = isEmpty(row[prop]) && !isEmpty(config.default) ? config.default : row[prop]; } @@ -1076,7 +1081,7 @@ export default class SetupTable extends Vue { : new Array(`${row[config.prop]}`.length).fill('*') .join(''); } - private handleCellFocus(arg: any[], cell: { + public handleCellFocus(arg: any[], cell: { row: ISetupRow config: ISetupHead rowIndex: number @@ -1101,7 +1106,16 @@ export default class SetupTable extends Vue { } } } - private handleCellBlur() { + public handleCellBlur(arg: any[], cell: { + row: ISetupRow + config: ISetupHead + rowIndex: number + colIndex: number + }) { + const { row, config } = cell; + if (config.handleBlur) { + config.handleBlur(row, config); + } this.$set(this, 'focusRow', {}); this.popoverEl && this.popoverEl.tipsHide(); this.popoverEl = null; diff --git a/frontend/src/types/config/config.ts b/frontend/src/types/config/config.ts index d7bf76cfc..c6e74d0c4 100644 --- a/frontend/src/types/config/config.ts +++ b/frontend/src/types/config/config.ts @@ -60,6 +60,7 @@ export interface IAp extends IApParams { ap_type: string is_enabled: boolean is_default: boolean + file_cache_dirs: string // nginx_path: null | string } diff --git a/frontend/src/types/index.ts b/frontend/src/types/index.ts index e4f72b0f1..5b9768ae7 100644 --- a/frontend/src/types/index.ts +++ b/frontend/src/types/index.ts @@ -304,6 +304,7 @@ export interface ISetupHead { getCurrentType?: Function getDefaultValue?: Function handleValueChange?: Function + handleBlur?: Function } // 文件导入配置 diff --git a/frontend/src/views/cloud/cloud-manager-add/cloud-manager-setup.vue b/frontend/src/views/cloud/cloud-manager-add/cloud-manager-setup.vue index 64f6e3274..2c89e8bc4 100644 --- a/frontend/src/views/cloud/cloud-manager-add/cloud-manager-setup.vue +++ b/frontend/src/views/cloud/cloud-manager-add/cloud-manager-setup.vue @@ -33,6 +33,9 @@ :class="{ 'cloud-setup-table': isManual }" local-mark="proxy_setup`" :col-setting="false" + :aps="apList" + :bk-cloud-id="id" + :arbitrary="apId" :setup-info="formData.bkCloudSetupInfo" :key="net.active" :before-delete="handleBeforeDeleteRow" @@ -246,11 +249,6 @@ export default class CloudManagerSetup extends Mixins(formLabelMixin, FilterIpMi */ private initTableData() { const defaultAp = this.apList.find(item => item.is_default); - let dataPath = ''; - if (defaultAp) { - const { linux = {} } = defaultAp.agent_config || {}; - dataPath = linux.data_path; - } const table = []; const initRow = { inner_ip: '', @@ -259,7 +257,7 @@ export default class CloudManagerSetup extends Mixins(formLabelMixin, FilterIpMi auth_type: '', prove: '', retention: -1, - data_path: dataPath, + data_path: defaultAp?.file_cache_dirs || '', }; // 默认给两行数据 table.push({ ...initRow }); diff --git a/frontend/src/views/cloud/components/sideslider-content-edit.vue b/frontend/src/views/cloud/components/sideslider-content-edit.vue index 20bb8566b..b681ccf0b 100644 --- a/frontend/src/views/cloud/components/sideslider-content-edit.vue +++ b/frontend/src/views/cloud/components/sideslider-content-edit.vue @@ -71,7 +71,7 @@ required :desc="descDataPathTip" :rules="rules.path"> - +