Update story-summary modules
This commit is contained in:
@@ -358,8 +358,8 @@
|
||||
postMsg('ANCHOR_GENERATE');
|
||||
};
|
||||
|
||||
$('btn-anchor-clear').onclick = () => {
|
||||
if (confirm('清空所有记忆锚点?(L0 向量也会一并清除)')) {
|
||||
$('btn-anchor-clear').onclick = async () => {
|
||||
if (await showConfirm('清空锚点', '清空所有记忆锚点?(L0 向量也会一并清除)')) {
|
||||
postMsg('ANCHOR_CLEAR');
|
||||
}
|
||||
};
|
||||
@@ -375,6 +375,7 @@
|
||||
};
|
||||
|
||||
$('btn-test-vector-api').onclick = () => {
|
||||
saveConfig(); // 先保存新 Key 到 localStorage
|
||||
postMsg('VECTOR_TEST_ONLINE', {
|
||||
provider: 'siliconflow',
|
||||
config: {
|
||||
@@ -391,8 +392,10 @@
|
||||
postMsg('VECTOR_GENERATE', { config: getVectorConfig() });
|
||||
};
|
||||
|
||||
$('btn-clear-vectors').onclick = () => {
|
||||
if (confirm('确定清空所有向量数据?')) postMsg('VECTOR_CLEAR');
|
||||
$('btn-clear-vectors').onclick = async () => {
|
||||
if (await showConfirm('清空向量', '确定清空所有向量数据?')) {
|
||||
postMsg('VECTOR_CLEAR');
|
||||
}
|
||||
};
|
||||
|
||||
$('btn-cancel-vectors').onclick = () => postMsg('VECTOR_CANCEL_GENERATE');
|
||||
@@ -955,6 +958,43 @@
|
||||
postMsg('FULLSCREEN_CLOSED');
|
||||
}
|
||||
|
||||
/**
|
||||
* 显示通用确认弹窗
|
||||
* @returns {Promise<boolean>}
|
||||
*/
|
||||
function showConfirm(title, message, okText = '执行', cancelText = '取消') {
|
||||
return new Promise(resolve => {
|
||||
const modal = $('confirm-modal');
|
||||
const titleEl = $('confirm-title');
|
||||
const msgEl = $('confirm-message');
|
||||
const okBtn = $('confirm-ok');
|
||||
const cancelBtn = $('confirm-cancel');
|
||||
const closeBtn = $('confirm-close');
|
||||
const backdrop = $('confirm-backdrop');
|
||||
|
||||
titleEl.textContent = title;
|
||||
msgEl.textContent = message;
|
||||
okBtn.textContent = okText;
|
||||
cancelBtn.textContent = cancelText;
|
||||
|
||||
const close = (result) => {
|
||||
modal.classList.remove('active');
|
||||
okBtn.onclick = null;
|
||||
cancelBtn.onclick = null;
|
||||
closeBtn.onclick = null;
|
||||
backdrop.onclick = null;
|
||||
resolve(result);
|
||||
};
|
||||
|
||||
okBtn.onclick = () => close(true);
|
||||
cancelBtn.onclick = () => close(false);
|
||||
closeBtn.onclick = () => close(false);
|
||||
backdrop.onclick = () => close(false);
|
||||
|
||||
modal.classList.add('active');
|
||||
});
|
||||
}
|
||||
|
||||
function renderArcsEditor(arcs) {
|
||||
const list = arcs?.length ? arcs : [{ name: '', trajectory: '', progress: 0, moments: [] }];
|
||||
const es = $('editor-struct');
|
||||
@@ -1526,7 +1566,11 @@
|
||||
};
|
||||
|
||||
// Main actions
|
||||
$('btn-clear').onclick = () => postMsg('REQUEST_CLEAR');
|
||||
$('btn-clear').onclick = async () => {
|
||||
if (await showConfirm('清空数据', '确定要清空本聊天的所有总结、关键词及人物关系数据吗?此操作不可撤销。')) {
|
||||
postMsg('REQUEST_CLEAR');
|
||||
}
|
||||
};
|
||||
$('btn-generate').onclick = () => {
|
||||
const btn = $('btn-generate');
|
||||
if (!localGenerating) {
|
||||
@@ -1640,42 +1684,34 @@
|
||||
|
||||
bindEvents();
|
||||
|
||||
// === EASTER EGG: 连续点击标题「总结」5 次切换新野兽派主题(localStorage 持久化)===
|
||||
// === THEME SWITCHER ===
|
||||
(function () {
|
||||
const STORAGE_KEY = 'xb-theme-alt';
|
||||
const CSS_A = 'story-summary.css';
|
||||
const CSS_B = 'story-summary-a.css';
|
||||
const CSS_MAP = { default: 'story-summary.css', dark: 'story-summary.css', neo: 'story-summary-a.css', 'neo-dark': 'story-summary-a.css' };
|
||||
const link = document.querySelector('link[rel="stylesheet"]');
|
||||
if (!link) return;
|
||||
const sel = document.getElementById('theme-select');
|
||||
if (!link || !sel) return;
|
||||
|
||||
// 启动时:根据持久化状态设置 CSS
|
||||
if (localStorage.getItem(STORAGE_KEY) === '1') {
|
||||
link.setAttribute('href', CSS_B);
|
||||
function applyTheme(theme) {
|
||||
if (!CSS_MAP[theme]) return;
|
||||
link.setAttribute('href', CSS_MAP[theme]);
|
||||
document.documentElement.setAttribute('data-theme', (theme === 'dark' || theme === 'neo-dark') ? 'dark' : '');
|
||||
}
|
||||
|
||||
// 点击计数器
|
||||
let clickCount = 0, clickTimer = null;
|
||||
const trigger = document.querySelector('h1 span');
|
||||
if (!trigger) return;
|
||||
// 启动时恢复主题
|
||||
const saved = localStorage.getItem(STORAGE_KEY) || 'default';
|
||||
applyTheme(saved);
|
||||
sel.value = saved;
|
||||
|
||||
trigger.style.cursor = 'default';
|
||||
trigger.addEventListener('click', function () {
|
||||
clickCount++;
|
||||
clearTimeout(clickTimer);
|
||||
clickTimer = setTimeout(() => { clickCount = 0; }, 2000);
|
||||
|
||||
if (clickCount >= 5) {
|
||||
clickCount = 0;
|
||||
clearTimeout(clickTimer);
|
||||
const isAlt = localStorage.getItem(STORAGE_KEY) === '1';
|
||||
const next = isAlt ? CSS_A : CSS_B;
|
||||
localStorage.setItem(STORAGE_KEY, isAlt ? '0' : '1');
|
||||
link.setAttribute('href', next);
|
||||
console.log(`[Easter Egg] Theme toggled → ${next}`);
|
||||
}
|
||||
// 下拉框切换
|
||||
sel.addEventListener('change', function () {
|
||||
const theme = sel.value;
|
||||
applyTheme(theme);
|
||||
localStorage.setItem(STORAGE_KEY, theme);
|
||||
console.log(`[Theme] Switched → ${theme} (${CSS_MAP[theme]})`);
|
||||
});
|
||||
})();
|
||||
// === END EASTER EGG ===
|
||||
// === END THEME SWITCHER ===
|
||||
|
||||
// Notify parent
|
||||
postMsg('FRAME_READY');
|
||||
|
||||
Reference in New Issue
Block a user