feat(系统设置): 资源池命名调整&穿梭框组件调整&请求携带本地语言
This commit is contained in:
parent
e1d62bf8c8
commit
896a58a5eb
|
@ -6,6 +6,7 @@ import { isString } from '@/utils/is';
|
|||
import { getToken } from '@/utils/auth';
|
||||
import { setObjToUrlParams, deepMerge } from '@/utils';
|
||||
import { useI18n } from '@/hooks/useI18n';
|
||||
import useLocale from '@/locale/useLocale';
|
||||
import { joinTimestamp } from './helper';
|
||||
|
||||
import type { AxiosResponse } from 'axios';
|
||||
|
@ -110,10 +111,17 @@ const transform: AxiosTransform = {
|
|||
*/
|
||||
requestInterceptors: (config) => {
|
||||
// 请求之前处理config
|
||||
const { currentLocale } = useLocale();
|
||||
const token = getToken();
|
||||
if (token && (config as Recordable)?.requestOptions?.withToken !== false) {
|
||||
const { sessionId, csrfToken } = token;
|
||||
(config as Recordable).headers = { 'X-AUTH-TOKEN': sessionId, 'CSRF-TOKEN': csrfToken };
|
||||
|
||||
(config as Recordable).headers = {
|
||||
...config.headers,
|
||||
'X-AUTH-TOKEN': sessionId,
|
||||
'CSRF-TOKEN': csrfToken,
|
||||
'Accept-Language': currentLocale.value,
|
||||
};
|
||||
}
|
||||
return config;
|
||||
},
|
||||
|
|
|
@ -5,12 +5,12 @@
|
|||
:data="transferData"
|
||||
show-search
|
||||
>
|
||||
<template #source="{ data: tData, selectedKeys, onSelect }">
|
||||
<template #source="{ selectedKeys, onSelect }">
|
||||
<a-tree
|
||||
:checkable="true"
|
||||
checked-strategy="child"
|
||||
:checked-keys="selectedKeys"
|
||||
:data="getTreeData(tData)"
|
||||
:data="getTreeData()"
|
||||
block-node
|
||||
@check="onSelect"
|
||||
/>
|
||||
|
@ -96,9 +96,7 @@
|
|||
/**
|
||||
* 获取树结构数据,根据穿梭框过滤的数据获取
|
||||
*/
|
||||
const getTreeData = (data: TransferDataItem[]) => {
|
||||
const values = data.map((item) => item[props.treeFiled.key]);
|
||||
|
||||
const getTreeData = () => {
|
||||
const travel = (_treeData: TreeDataItem[]) => {
|
||||
const treeDataSource: TreeDataItem[] = [];
|
||||
_treeData.forEach((item) => {
|
||||
|
@ -111,7 +109,7 @@
|
|||
Array.isArray(itemChildren) &&
|
||||
itemChildren.length > 0 &&
|
||||
itemChildren?.every((child: TreeDataItem) => innerTarget.value.includes(child[props.treeFiled.key]));
|
||||
if (!allSelected && !innerTarget.value.includes(itemKey) && (itemChildren || values.includes(itemKey))) {
|
||||
if (!allSelected && !innerTarget.value.includes(itemKey)) {
|
||||
// 非选中父节点时,需要判断每个子节点是否已经在右侧的选中的数组内,不在才渲染到左侧
|
||||
treeDataSource.push({
|
||||
title: itemTitle,
|
||||
|
|
|
@ -53,6 +53,7 @@ async function changeLocale(locale: LocaleType) {
|
|||
loadLocalePool.push(locale);
|
||||
|
||||
setI18nLanguage(locale);
|
||||
window.location.reload();
|
||||
return locale;
|
||||
}
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ export interface TestResourceDTO {
|
|||
nodesList: NodesListItem[]; // node资源
|
||||
ip: string; // k8s ip
|
||||
token: string; // k8s token
|
||||
nameSpaces: string; // k8s 命名空间
|
||||
namespace: string; // k8s 命名空间
|
||||
concurrentNumber: number; // k8s 最大并发数
|
||||
podThreads: number; // k8s 单pod最大线程数
|
||||
jobDefinition: string; // k8s job自定义模板
|
||||
|
|
|
@ -235,14 +235,14 @@
|
|||
/>
|
||||
</a-form-item>
|
||||
<a-form-item
|
||||
:label="t('system.resourcePool.testResourceDTO.nameSpaces')"
|
||||
field="testResourceDTO.nameSpaces"
|
||||
:label="t('system.resourcePool.testResourceDTO.namespace')"
|
||||
field="testResourceDTO.namespace"
|
||||
class="form-item"
|
||||
:rules="[{ required: true, message: t('system.resourcePool.testResourceDTO.nameSpacesRequired') }]"
|
||||
asterisk-position="end"
|
||||
>
|
||||
<a-input
|
||||
v-model:model-value="form.testResourceDTO.nameSpaces"
|
||||
v-model:model-value="form.testResourceDTO.namespace"
|
||||
:placeholder="t('system.resourcePool.testResourceDTO.nameSpacesPlaceholder')"
|
||||
:max-length="250"
|
||||
class="mr-[8px] flex-1"
|
||||
|
@ -379,7 +379,7 @@
|
|||
nodesList: [] as NodesListItem[],
|
||||
ip: '',
|
||||
token: '',
|
||||
nameSpaces: '',
|
||||
namespace: '',
|
||||
jobDefinition: job,
|
||||
deployName: '',
|
||||
orgIds: [] as string[],
|
||||
|
@ -483,7 +483,7 @@
|
|||
// 是否显示K8S资源配置信息
|
||||
const isShowK8SResources = computed(() => form.value.type === 'Kubernetes' && isShowTypeItem.value);
|
||||
// 是否填写了命名空间
|
||||
const isFillNameSpaces = computed(() => form.value.testResourceDTO.nameSpaces?.trim() !== '');
|
||||
const isFillNameSpaces = computed(() => form.value.testResourceDTO.namespace?.trim() !== '');
|
||||
// 是否填写了命名空间及Deploy Name
|
||||
const isFillNameSpacesAndDeployName = computed(
|
||||
() => isFillNameSpaces.value && form.value.testResourceDTO.deployName?.trim() !== ''
|
||||
|
@ -630,7 +630,7 @@
|
|||
function downloadYaml(type: YamlType) {
|
||||
let name = '';
|
||||
let yamlStr = '';
|
||||
const { nameSpaces, deployName } = form.value.testResourceDTO;
|
||||
const { namespace, deployName } = form.value.testResourceDTO;
|
||||
// 镜像内的版本号需要去掉尾部的 -xxx
|
||||
const apiImage = `registry.cn-qingdao.aliyuncs.com/metersphere/task-runner:${appStore.version.substring(
|
||||
0,
|
||||
|
@ -639,15 +639,15 @@
|
|||
switch (type) {
|
||||
case 'role':
|
||||
name = 'Role.yml';
|
||||
yamlStr = getYaml('role', '', nameSpaces, '');
|
||||
yamlStr = getYaml('role', '', namespace, '');
|
||||
break;
|
||||
case 'Deployment':
|
||||
name = 'Deployment.yml';
|
||||
yamlStr = getYaml('Deployment', deployName, nameSpaces, apiImage);
|
||||
yamlStr = getYaml('Deployment', deployName, namespace, apiImage);
|
||||
break;
|
||||
case 'DaemonSet':
|
||||
name = 'Daemonset.yml';
|
||||
yamlStr = getYaml('DaemonSet', deployName, nameSpaces, apiImage);
|
||||
yamlStr = getYaml('DaemonSet', deployName, namespace, apiImage);
|
||||
break;
|
||||
default:
|
||||
throw new Error('文件类型不在可选范围');
|
||||
|
@ -673,7 +673,7 @@
|
|||
const {
|
||||
ip,
|
||||
token, // k8s token
|
||||
nameSpaces, // k8s 命名空间
|
||||
namespace, // k8s 命名空间
|
||||
concurrentNumber, // k8s 最大并发数
|
||||
podThreads, // k8s 单pod最大线程数
|
||||
jobDefinition, // k8s job自定义模板
|
||||
|
@ -694,7 +694,7 @@
|
|||
? {
|
||||
ip,
|
||||
token,
|
||||
nameSpaces,
|
||||
namespace,
|
||||
concurrentNumber,
|
||||
podThreads,
|
||||
deployName: isCheckedAPI.value ? deployName : null, // 勾选了接口测试才需要传
|
||||
|
|
|
@ -264,7 +264,7 @@
|
|||
const {
|
||||
ip,
|
||||
token, // k8s token
|
||||
nameSpaces, // k8s 命名空间
|
||||
namespace, // k8s 命名空间
|
||||
concurrentNumber, // k8s 最大并发数
|
||||
podThreads, // k8s 单pod最大线程数
|
||||
deployName, // k8s api测试部署名称
|
||||
|
@ -298,8 +298,8 @@
|
|||
value: token,
|
||||
},
|
||||
{
|
||||
label: t('system.resourcePool.testResourceDTO.nameSpaces'),
|
||||
value: nameSpaces,
|
||||
label: t('system.resourcePool.testResourceDTO.namespace'),
|
||||
value: namespace,
|
||||
},
|
||||
{
|
||||
label: t('system.resourcePool.testResourceDTO.deployName'),
|
||||
|
|
|
@ -94,7 +94,7 @@ export default {
|
|||
'system.resourcePool.testResourceDTO.token': 'Token',
|
||||
'system.resourcePool.testResourceDTO.tokenRequired': 'Please fill in the Token',
|
||||
'system.resourcePool.testResourceDTO.tokenPlaceholder': 'Please fill in the Token',
|
||||
'system.resourcePool.testResourceDTO.nameSpaces': 'NameSpaces',
|
||||
'system.resourcePool.testResourceDTO.namespace': 'NameSpaces',
|
||||
'system.resourcePool.testResourceDTO.nameSpacesRequired': 'Please fill in the namespace',
|
||||
'system.resourcePool.testResourceDTO.nameSpacesPlaceholder':
|
||||
'To use the K8S resource pool, you need to deploy the Role.yaml file',
|
||||
|
|
|
@ -91,7 +91,7 @@ export default {
|
|||
'system.resourcePool.testResourceDTO.token': 'Token',
|
||||
'system.resourcePool.testResourceDTO.tokenRequired': 'Token 不能为空',
|
||||
'system.resourcePool.testResourceDTO.tokenPlaceholder': '请输入 Token',
|
||||
'system.resourcePool.testResourceDTO.nameSpaces': '命名空间',
|
||||
'system.resourcePool.testResourceDTO.namespace': '命名空间',
|
||||
'system.resourcePool.testResourceDTO.nameSpacesRequired': '命名空间不能为空',
|
||||
'system.resourcePool.testResourceDTO.nameSpacesPlaceholder': '使用K8S资源池需要部署Role.yaml文件',
|
||||
'system.resourcePool.testResourceDTO.deployName': 'Deploy Name',
|
||||
|
|
Loading…
Reference in New Issue