mirror of
https://github.com/SilenceLurker/ST-Amily2-Chat-Optimisation.git
synced 2026-06-06 10:05:50 +00:00
Compare commits
3 Commits
1.7.7
...
e2b46fcd59
| Author | SHA1 | Date | |
|---|---|---|---|
| e2b46fcd59 | |||
| 5173133a69 | |||
| 5fe9b2a21c |
@@ -5,6 +5,13 @@ function insertRow(state, tableIndex, data) {
|
|||||||
log(`AI指令错误:尝试在不存在的表格索引 ${tableIndex} 中插入行。`, 'error');
|
log(`AI指令错误:尝试在不存在的表格索引 ${tableIndex} 中插入行。`, 'error');
|
||||||
return { state, changes: [] };
|
return { state, changes: [] };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 【安全检查】确保 data 是对象
|
||||||
|
if (typeof data !== 'object' || data === null) {
|
||||||
|
log(`AI指令错误:insertRow 的 data 参数必须是对象,实际收到: ${typeof data} (${data})`, 'error');
|
||||||
|
return { state, changes: [] };
|
||||||
|
}
|
||||||
|
|
||||||
const table = state[tableIndex];
|
const table = state[tableIndex];
|
||||||
const colCount = table.headers.length;
|
const colCount = table.headers.length;
|
||||||
const newRow = Array(colCount).fill('');
|
const newRow = Array(colCount).fill('');
|
||||||
@@ -28,6 +35,12 @@ function updateRow(state, tableIndex, rowIndex, data) {
|
|||||||
return { state, changes: [] };
|
return { state, changes: [] };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 【安全检查】确保 data 是对象
|
||||||
|
if (typeof data !== 'object' || data === null) {
|
||||||
|
log(`AI指令错误:updateRow 的 data 参数必须是对象,实际收到: ${typeof data} (${data})`, 'error');
|
||||||
|
return { state, changes: [] };
|
||||||
|
}
|
||||||
|
|
||||||
const table = state[tableIndex];
|
const table = state[tableIndex];
|
||||||
|
|
||||||
if (rowIndex >= table.rows.length) {
|
if (rowIndex >= table.rows.length) {
|
||||||
@@ -156,13 +169,21 @@ function parseValue(val) {
|
|||||||
try {
|
try {
|
||||||
return JSON.parse(val);
|
return JSON.parse(val);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
let fixedKeys = val.replace(/([{,]\s*)(\d+)(\s*:)/g, '$1"$2"$3');
|
||||||
try {
|
try {
|
||||||
let fixedVal = val.replace(/([{,]\s*)(\d+)(\s*:)/g, '$1"$2"$3');
|
return JSON.parse(fixedKeys);
|
||||||
fixedVal = fixedVal.replace(/'/g, '"');
|
|
||||||
|
|
||||||
return JSON.parse(fixedVal);
|
|
||||||
} catch (e2) {
|
} catch (e2) {
|
||||||
return val;
|
let fixedQuotes = fixedKeys.replace(/'/g, '"');
|
||||||
|
try {
|
||||||
|
return JSON.parse(fixedQuotes);
|
||||||
|
} catch (e3) {
|
||||||
|
let fixedAllKeys = val.replace(/([{,]\s*)([a-zA-Z0-9_]+)(\s*:)/g, '$1"$2"$3');
|
||||||
|
try {
|
||||||
|
return JSON.parse(fixedAllKeys);
|
||||||
|
} catch (e4) {
|
||||||
|
return val;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "Amily2号聊天优化助手",
|
"name": "Amily2号聊天优化助手",
|
||||||
"display_name": "Amily2号助手",
|
"display_name": "Amily2号助手",
|
||||||
"version": "1.7.6",
|
"version": "1.7.7",
|
||||||
"author": "Wx-2025",
|
"author": "Wx-2025",
|
||||||
"description": "一个拥有独立UI的智能引擎,正文优化、自动总结、记忆表格、rag向量、隐藏楼层、剧情推进等多功能整合。",
|
"description": "一个拥有独立UI的智能引擎,正文优化、自动总结、记忆表格、rag向量、隐藏楼层、剧情推进等多功能整合。",
|
||||||
"minSillyTavernVersion": "1.10.0",
|
"minSillyTavernVersion": "1.10.0",
|
||||||
@@ -47,5 +47,6 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user