Skip to content

Commit

Permalink
feat: 配置示例新增windows路径需求--story=119618143
Browse files Browse the repository at this point in the history
  • Loading branch information
q15971095971 committed Sep 30, 2024
1 parent 9d411e7 commit 726dd8a
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 8 deletions.
1 change: 1 addition & 0 deletions bcs-services/bcs-bscp/ui/src/i18n/en-us.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
1 change: 1 addition & 0 deletions bcs-services/bcs-bscp/ui/src/i18n/zh-cn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ export default {
文件own必须有读取权限: '文件own必须有读取权限',
最大长度1024个字符: '最大长度1024个字符',
'无效的路径,路径不符合Unix文件路径格式规范': '无效的路径,路径不符合Unix文件路径格式规范',
'无效的路径,路径不符合Unix或Windows文件路径格式规范': '无效的路径,路径不符合Unix或Windows文件路径格式规范',
最大长度200个字符: '最大长度200个字符',
请上传文件: '请上传文件',
'配置内容不能超过{size}M': '配置内容不能超过{size}M',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
ref="fileOptionRef"
label-name="服务标签"
:associate-config-show="true"
:dual-system-support="true"
@update-option-data="getOptionData" />
<div class="node-content">
<span class="node-label">{{ $t('示例预览') }}</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<info
class="icon-info"
v-bk-tooltips="{
content: $t('临时目录提示文案'),
content: tempDirToolTips,
placement: 'top',
}" />
</template>
Expand All @@ -34,8 +34,8 @@
placement: 'top',
}"
class="description-em"
@click="handleCopyText(`${formData.tempDir}/${spaceId}/${basicInfo?.serviceName.value}/files`)">
&nbsp;{{ `${formData.tempDir}/${spaceId}/${basicInfo?.serviceName.value}/files` }}&nbsp;
@click="handleCopyText(realPath)">
&nbsp;{{ realPath }}&nbsp;
</span>
</div>
</bk-form-item>
Expand Down Expand Up @@ -100,18 +100,20 @@
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,
labelName: '标签',
p2pShow: false,
httpConfigShow: false,
associateConfigShow: false,
dualSystemSupport: false,
},
);
Expand Down Expand Up @@ -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;
Expand All @@ -184,7 +193,7 @@
return isValid;
},
trigger: 'change',
message: t('无效的路径,路径不符合Unix文件路径格式规范'),
message: t(`无效的路径,路径不符合Unix${props.dualSystemSupport ? '或Windows' : ''}文件路径格式规范`),
},
],
httpConfigName: [
Expand Down Expand Up @@ -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(() => {
Expand Down

0 comments on commit 726dd8a

Please sign in to comment.