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