mirror of
https://github.com/Cola-Echo/memory-manager-concurrent.git
synced 2026-06-06 04:15:52 +00:00
fix: 兼容新版 SillyTavern 的 extensionSettings API 并修复总结世界书渲染崩溃
1. 将 window.extension_settings 替换为 getExtensionSettings() - 新版 SillyTavern 已废弃 window.extension_settings 全局变量 - 改用 SillyTavern.getContext().extensionSettings(通过已有的 getExtensionSettings helper) - 影响文件: table-filler.js, mode-manager.js, service-interceptor.js, independent-template-modal.js 2. 修复总结世界书未配置时自动拆分导致的渲染崩溃 - renderSummaryPartsUI 中 getSummaryConfig() 在未配置时会 throw - 导致整个世界书列表渲染失败,自动拆分开关也无法显示 - 改为安全读取 config?.summaryConfigs?.[book.name],未配置时显示"未配置"状态
This commit is contained in:
2
dist/index.js
vendored
2
dist/index.js
vendored
File diff suppressed because one or more lines are too long
@@ -5,6 +5,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import Logger from "@core/logger";
|
import Logger from "@core/logger";
|
||||||
|
import { getExtensionSettings } from "@core/sillytavern-api";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 调用模式枚举
|
* 调用模式枚举
|
||||||
@@ -142,7 +143,7 @@ function checkInterceptMode() {
|
|||||||
];
|
];
|
||||||
|
|
||||||
for (const key of possibleKeys) {
|
for (const key of possibleKeys) {
|
||||||
if (window.extension_settings?.[key]) {
|
if (getExtensionSettings()?.[key]) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -168,8 +169,8 @@ export function isSecondaryApiMode() {
|
|||||||
|
|
||||||
let amilySettings = null;
|
let amilySettings = null;
|
||||||
for (const key of possibleKeys) {
|
for (const key of possibleKeys) {
|
||||||
if (window.extension_settings?.[key]) {
|
if (getExtensionSettings()?.[key]) {
|
||||||
amilySettings = window.extension_settings[key];
|
amilySettings = getExtensionSettings()[key];
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -208,8 +209,8 @@ export function getAmily2FillingModeName() {
|
|||||||
|
|
||||||
let amilySettings = null;
|
let amilySettings = null;
|
||||||
for (const key of possibleKeys) {
|
for (const key of possibleKeys) {
|
||||||
if (window.extension_settings?.[key]) {
|
if (getExtensionSettings()?.[key]) {
|
||||||
amilySettings = window.extension_settings[key];
|
amilySettings = getExtensionSettings()[key];
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import Logger from "@core/logger";
|
import Logger from "@core/logger";
|
||||||
|
import { getExtensionSettings } from "@core/sillytavern-api";
|
||||||
import { getTableFillerConfig, isTableFillerEnabled } from "@config/config-manager";
|
import { getTableFillerConfig, isTableFillerEnabled } from "@config/config-manager";
|
||||||
import { splitTablesFromMessages, mergeResults } from "./table-splitter";
|
import { splitTablesFromMessages, mergeResults } from "./table-splitter";
|
||||||
import { ParallelExecutor } from "./parallel-executor";
|
import { ParallelExecutor } from "./parallel-executor";
|
||||||
@@ -41,7 +42,7 @@ function getSTContext() {
|
|||||||
|
|
||||||
// 尝试从 extension 模块获取
|
// 尝试从 extension 模块获取
|
||||||
try {
|
try {
|
||||||
const extensions = window.extension_settings;
|
const extensions = getExtensionSettings();
|
||||||
if (extensions) {
|
if (extensions) {
|
||||||
// 尝试从任一扩展获取 context
|
// 尝试从任一扩展获取 context
|
||||||
for (const key in extensions) {
|
for (const key in extensions) {
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import Logger from "@core/logger";
|
import Logger from "@core/logger";
|
||||||
|
import { getExtensionSettings } from "@core/sillytavern-api";
|
||||||
import {
|
import {
|
||||||
getTableFillerConfig,
|
getTableFillerConfig,
|
||||||
isTableFillerEnabled,
|
isTableFillerEnabled,
|
||||||
@@ -45,7 +46,7 @@ async function getAmily2TableNames() {
|
|||||||
try {
|
try {
|
||||||
// 方法1:直接从 extension_settings 获取预设中的表格定义(最可靠)
|
// 方法1:直接从 extension_settings 获取预设中的表格定义(最可靠)
|
||||||
const amilyExtName = "ST-Amily2-Chat-Optimisation";
|
const amilyExtName = "ST-Amily2-Chat-Optimisation";
|
||||||
const settings = window.extension_settings?.[amilyExtName];
|
const settings = getExtensionSettings()?.[amilyExtName];
|
||||||
|
|
||||||
if (settings) {
|
if (settings) {
|
||||||
log.debug("找到 Amily2 扩展设置,检查表格定义...");
|
log.debug("找到 Amily2 扩展设置,检查表格定义...");
|
||||||
@@ -140,9 +141,9 @@ async function getAmily2TableNames() {
|
|||||||
|
|
||||||
// 方法5:遍历所有 extension_settings 找 Amily2 相关
|
// 方法5:遍历所有 extension_settings 找 Amily2 相关
|
||||||
log.debug("遍历所有扩展设置查找 Amily2...");
|
log.debug("遍历所有扩展设置查找 Amily2...");
|
||||||
for (const key in window.extension_settings || {}) {
|
for (const key in getExtensionSettings() || {}) {
|
||||||
if (key.toLowerCase().includes('amily')) {
|
if (key.toLowerCase().includes('amily')) {
|
||||||
const extSettings = window.extension_settings[key];
|
const extSettings = getExtensionSettings()[key];
|
||||||
log.debug(`检查扩展 ${key}:`, Object.keys(extSettings || {}));
|
log.debug(`检查扩展 ${key}:`, Object.keys(extSettings || {}));
|
||||||
|
|
||||||
// 深度搜索 tables
|
// 深度搜索 tables
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import Logger from "@core/logger";
|
import Logger from "@core/logger";
|
||||||
|
import { getExtensionSettings } from "@core/sillytavern-api";
|
||||||
import {
|
import {
|
||||||
setIndependentTemplate,
|
setIndependentTemplate,
|
||||||
deleteIndependentTemplate,
|
deleteIndependentTemplate,
|
||||||
@@ -32,7 +33,7 @@ async function getAmily2TableNames() {
|
|||||||
try {
|
try {
|
||||||
// 复用 table-filler.js 中的获取逻辑
|
// 复用 table-filler.js 中的获取逻辑
|
||||||
const amilyExtName = "ST-Amily2-Chat-Optimisation";
|
const amilyExtName = "ST-Amily2-Chat-Optimisation";
|
||||||
const settings = window.extension_settings?.[amilyExtName];
|
const settings = getExtensionSettings()?.[amilyExtName];
|
||||||
|
|
||||||
if (settings?.global_table_preset?.tables) {
|
if (settings?.global_table_preset?.tables) {
|
||||||
const tables = settings.global_table_preset.tables;
|
const tables = settings.global_table_preset.tables;
|
||||||
|
|||||||
@@ -368,8 +368,8 @@ function renderSummaryPartsUI(book, config) {
|
|||||||
|
|
||||||
// 获取已保存的Part配置
|
// 获取已保存的Part配置
|
||||||
const savedPartConfigs = getSummaryPartConfigs(book.name);
|
const savedPartConfigs = getSummaryPartConfigs(book.name);
|
||||||
// 获取原总结世界书配置(Part 1 复用)
|
// 获取原总结世界书配置(Part 1 复用),未配置时不报错
|
||||||
const originalSummaryConfig = getSummaryConfig(book.name);
|
const originalSummaryConfig = config?.summaryConfigs?.[book.name] || null;
|
||||||
|
|
||||||
// 构建已保存配置的映射(用于模糊匹配)
|
// 构建已保存配置的映射(用于模糊匹配)
|
||||||
const savedConfigsMap = {};
|
const savedConfigsMap = {};
|
||||||
|
|||||||
Reference in New Issue
Block a user