From 726dd8a44321da56b50a78b1da6e6d88bf73a95a Mon Sep 17 00:00:00 2001 From: q15971095971 <764419406@qq.com> Date: Mon, 30 Sep 2024 18:04:10 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E9=85=8D=E7=BD=AE=E7=A4=BA=E4=BE=8B?= =?UTF-8?q?=E6=96=B0=E5=A2=9Ewindows=E8=B7=AF=E5=BE=84=E9=9C=80=E6=B1=82--?= =?UTF-8?q?story=3D119618143?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bcs-services/bcs-bscp/ui/src/i18n/en-us.ts | 1 + bcs-services/bcs-bscp/ui/src/i18n/zh-cn.ts | 1 + .../components/content/node-mana-example.vue | 1 + .../client/example/components/form-option.vue | 46 +++++++++++++++---- 4 files changed, 41 insertions(+), 8 deletions(-) diff --git a/bcs-services/bcs-bscp/ui/src/i18n/en-us.ts b/bcs-services/bcs-bscp/ui/src/i18n/en-us.ts index a086b2931a..2f6788635e 100644 --- a/bcs-services/bcs-bscp/ui/src/i18n/en-us.ts +++ b/bcs-services/bcs-bscp/ui/src/i18n/en-us.ts @@ -163,6 +163,7 @@ export default { 文件own必须有读取权限: 'The file owner must have read permission', 最大长度1024个字符: 'Maximum length of 1024 characters', '无效的路径,路径不符合Unix文件路径格式规范': 'Invalid path, the path does not comply with the Unix file path format specification', + '无效的路径,路径不符合Unix或Windows文件路径格式规范': 'Invalid path, the path does not conform to Unix or Windows file path format specifications', 最大长度200个字符: 'Maximum length of 200 characters', 请上传文件: 'Please upload the file', '配置内容不能超过{size}M': 'Configuration content cannot exceed {size}M', diff --git a/bcs-services/bcs-bscp/ui/src/i18n/zh-cn.ts b/bcs-services/bcs-bscp/ui/src/i18n/zh-cn.ts index e7935ce150..b0f2e3b71c 100644 --- a/bcs-services/bcs-bscp/ui/src/i18n/zh-cn.ts +++ b/bcs-services/bcs-bscp/ui/src/i18n/zh-cn.ts @@ -163,6 +163,7 @@ export default { 文件own必须有读取权限: '文件own必须有读取权限', 最大长度1024个字符: '最大长度1024个字符', '无效的路径,路径不符合Unix文件路径格式规范': '无效的路径,路径不符合Unix文件路径格式规范', + '无效的路径,路径不符合Unix或Windows文件路径格式规范': '无效的路径,路径不符合Unix或Windows文件路径格式规范', 最大长度200个字符: '最大长度200个字符', 请上传文件: '请上传文件', '配置内容不能超过{size}M': '配置内容不能超过{size}M', diff --git a/bcs-services/bcs-bscp/ui/src/views/space/client/example/components/content/node-mana-example.vue b/bcs-services/bcs-bscp/ui/src/views/space/client/example/components/content/node-mana-example.vue index 81e6a42c73..aa8550ce51 100644 --- a/bcs-services/bcs-bscp/ui/src/views/space/client/example/components/content/node-mana-example.vue +++ b/bcs-services/bcs-bscp/ui/src/views/space/client/example/components/content/node-mana-example.vue @@ -4,6 +4,7 @@ ref="fileOptionRef" label-name="服务标签" :associate-config-show="true" + :dual-system-support="true" @update-option-data="getOptionData" />
{{ $t('示例预览') }} diff --git a/bcs-services/bcs-bscp/ui/src/views/space/client/example/components/form-option.vue b/bcs-services/bcs-bscp/ui/src/views/space/client/example/components/form-option.vue index cdccc23182..e112ee07ea 100644 --- a/bcs-services/bcs-bscp/ui/src/views/space/client/example/components/form-option.vue +++ b/bcs-services/bcs-bscp/ui/src/views/space/client/example/components/form-option.vue @@ -19,7 +19,7 @@ @@ -34,8 +34,8 @@ placement: 'top', }" class="description-em" - @click="handleCopyText(`${formData.tempDir}/${spaceId}/${basicInfo?.serviceName.value}/files`)"> -  {{ `${formData.tempDir}/${spaceId}/${basicInfo?.serviceName.value}/files` }}  + @click="handleCopyText(realPath)"> +  {{ realPath }} 
@@ -100,11 +100,12 @@ const props = withDefaults( defineProps<{ - directoryShow?: boolean; + directoryShow?: boolean; // 临时目录 labelName?: string; - p2pShow?: boolean; - httpConfigShow?: boolean; - associateConfigShow?: boolean; + p2pShow?: boolean; // p2p网络加速(Sidecar容器) + httpConfigShow?: boolean; // 配置项名称(Python SDK、http(s)接口调用) + associateConfigShow?: boolean; // 配置文件筛选功能(所有文件型) + dualSystemSupport?: boolean; // Unix与windows双系统支持(节点管理插件与文件型命令行工具) }>(), { directoryShow: true, @@ -112,6 +113,7 @@ p2pShow: false, httpConfigShow: false, associateConfigShow: false, + dualSystemSupport: false, }, ); @@ -167,6 +169,13 @@ { required: true, validator: (value: string) => { + // Unix与Windows双路径判断 + if (props.dualSystemSupport) { + if (isWindowsPath.value) { + return true; + } + } + // 单Unix路径判断 // 必须为绝对路径, 且不能以/结尾 if (!value.startsWith('/') || value.endsWith('/')) { return false; @@ -184,7 +193,7 @@ return isValid; }, trigger: 'change', - message: t('无效的路径,路径不符合Unix文件路径格式规范'), + message: t(`无效的路径,路径不符合Unix${props.dualSystemSupport ? '或Windows' : ''}文件路径格式规范`), }, ], httpConfigName: [ @@ -223,8 +232,29 @@ return rules.tempDir.every((ruleItem) => ruleItem.validator(formData.value.tempDir)); }); + // 验证是否windows路径 + const isWindowsPath = computed(() => { + return /^[a-zA-Z]:\\(?:[^\\/:*?"<>|\r\n]+\\)*[^\\/:*?"<>|\r\n]+$/.test(formData.value.tempDir); + }); + + // 真实路径 + const realPath = computed(() => { + if (isWindowsPath.value) { + return `${formData.value.tempDir}\\${spaceId.value}\\${basicInfo?.serviceName.value}\\files`; + } + return `${formData.value.tempDir}/${spaceId.value}/${basicInfo?.serviceName.value}/files`; + }); + + const tempDirToolTips = computed(() => { + if (isWindowsPath.value) { + return t('临时目录提示文案').replaceAll('/', '\\'); + } + return t('临时目录提示文案'); + }); + watch(formData.value, () => { sendAll(); + // tempDirPathType(formData.value.tempDir); }); onMounted(() => {