mirror of
https://github.com/SilenceLurker/ST-Amily2-Chat-Optimisation.git
synced 2026-06-06 15:55:50 +00:00
Update bindings.js
This commit is contained in:
@@ -2,7 +2,7 @@ import { extension_settings, getContext } from "/scripts/extensions.js";
|
|||||||
import { characters, this_chid, getRequestHeaders, saveSettingsDebounced, eventSource, event_types } from "/script.js";
|
import { characters, this_chid, getRequestHeaders, saveSettingsDebounced, eventSource, event_types } from "/script.js";
|
||||||
import { defaultSettings, extensionName, saveSettings } from "../utils/settings.js";
|
import { defaultSettings, extensionName, saveSettings } from "../utils/settings.js";
|
||||||
import { pluginAuthStatus, activatePluginAuthorization, getPasswordForDate } from "../utils/auth.js";
|
import { pluginAuthStatus, activatePluginAuthorization, getPasswordForDate } from "../utils/auth.js";
|
||||||
import { fetchModels } from "../core/api.js";
|
import { fetchModels, testApiConnection } from "../core/api.js";
|
||||||
import { getJqyhApiSettings, testJqyhApiConnection, fetchJqyhModels } from '../core/api/JqyhApi.js';
|
import { getJqyhApiSettings, testJqyhApiConnection, fetchJqyhModels } from '../core/api/JqyhApi.js';
|
||||||
import { safeLorebooks, safeCharLorebooks, safeLorebookEntries, isTavernHelperAvailable } from "../core/tavernhelper-compatibility.js";
|
import { safeLorebooks, safeCharLorebooks, safeLorebookEntries, isTavernHelperAvailable } from "../core/tavernhelper-compatibility.js";
|
||||||
|
|
||||||
@@ -421,6 +421,15 @@ function bindAmily2ModalWorldBookSettings() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function bindModalEvents() {
|
export function bindModalEvents() {
|
||||||
|
const refreshButton = document.getElementById('amily2_refresh_models');
|
||||||
|
if (refreshButton && !document.getElementById('amily2_test_api_connection')) {
|
||||||
|
const testButton = document.createElement('button');
|
||||||
|
testButton.id = 'amily2_test_api_connection';
|
||||||
|
testButton.className = 'menu_button interactable';
|
||||||
|
testButton.innerHTML = '<i class="fas fa-plug"></i> 测试连接';
|
||||||
|
refreshButton.insertAdjacentElement('afterend', testButton);
|
||||||
|
}
|
||||||
|
|
||||||
initializePlotOptimizationBindings();
|
initializePlotOptimizationBindings();
|
||||||
bindAmily2ModalWorldBookSettings();
|
bindAmily2ModalWorldBookSettings();
|
||||||
|
|
||||||
@@ -530,7 +539,7 @@ export function bindModalEvents() {
|
|||||||
.off("click.amily2.actions")
|
.off("click.amily2.actions")
|
||||||
.on(
|
.on(
|
||||||
"click.amily2.actions",
|
"click.amily2.actions",
|
||||||
"#amily2_refresh_models, #amily2_test, #amily2_fix_now",
|
"#amily2_refresh_models, #amily2_test_api_connection, #amily2_test, #amily2_fix_now",
|
||||||
async function () {
|
async function () {
|
||||||
if (!pluginAuthStatus.authorized) return;
|
if (!pluginAuthStatus.authorized) return;
|
||||||
const button = $(this);
|
const button = $(this);
|
||||||
@@ -544,13 +553,16 @@ export function bindModalEvents() {
|
|||||||
const models = await fetchModels();
|
const models = await fetchModels();
|
||||||
if (models.length > 0) {
|
if (models.length > 0) {
|
||||||
setAvailableModels(models);
|
setAvailableModels(models);
|
||||||
localStorage.setItem(
|
localStorage.setItem(
|
||||||
"cached_models_amily2",
|
"cached_models_amily2",
|
||||||
JSON.stringify(models),
|
JSON.stringify(models),
|
||||||
);
|
);
|
||||||
populateModelDropdown();
|
populateModelDropdown();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case "amily2_test_api_connection":
|
||||||
|
await testApiConnection();
|
||||||
|
break;
|
||||||
case "amily2_test":
|
case "amily2_test":
|
||||||
await testReplyChecker();
|
await testReplyChecker();
|
||||||
break;
|
break;
|
||||||
|
|||||||
Reference in New Issue
Block a user