fix: 修复IIFE语法错误,改用普通写法解析配置
This commit is contained in:
parent
b501d4e81c
commit
d9d6ce83f7
@ -192,26 +192,30 @@ const fetchStrategies = async () => {
|
|||||||
try {
|
try {
|
||||||
const response = await api.strategies.getStrategies();
|
const response = await api.strategies.getStrategies();
|
||||||
if (response.code === 200) {
|
if (response.code === 200) {
|
||||||
strategies.value = response.data.map(item => ({
|
strategies.value = response.data.map(item => {
|
||||||
id: item.id,
|
let parameters = {};
|
||||||
name: item.name,
|
if (item.config) {
|
||||||
desc: item.description,
|
|
||||||
type: item.type,
|
|
||||||
parameters: item.config ? (() => {
|
|
||||||
try {
|
try {
|
||||||
let config = JSON.parse(item.config);
|
let config = JSON.parse(item.config);
|
||||||
// 如果解析后还是字符串,再解析一次(处理双层转义)
|
// 如果解析后还是字符串,再解析一次(处理双层转义)
|
||||||
if (typeof config === 'string') {
|
if (typeof config === 'string') {
|
||||||
config = JSON.parse(config);
|
config = JSON.parse(config);
|
||||||
}
|
}
|
||||||
return config;
|
parameters = config;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error('解析策略配置失败:', e);
|
console.error('解析策略配置失败:', e);
|
||||||
return {};
|
parameters = {};
|
||||||
}
|
}
|
||||||
})(),
|
}
|
||||||
color: '#10B981'
|
return {
|
||||||
}));
|
id: item.id,
|
||||||
|
name: item.name,
|
||||||
|
desc: item.description,
|
||||||
|
type: item.type,
|
||||||
|
parameters: parameters,
|
||||||
|
color: '#10B981'
|
||||||
|
};
|
||||||
|
});
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('获取策略列表失败:', error);
|
console.error('获取策略列表失败:', error);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user