Update Site source

This commit is contained in:
Codex committed 2026-09-25 21:49:02 -05:00
1 parent 997859434e
commit bcd4667205
2 files changed
+46 -4

No files matched your search

+35 -3
View File
@@ -4,7 +4,24 @@
const APP_VERSION = '1.1.0';
const appIds = ['today', 'timeline', 'museum', 'insights', 'profile', 'system'];
const zh = () => (typeof lang === 'function' ? lang() : 'en') === 'zh';
const copy = (en, cn) => (zh() ? cn : en);
// Add-on strings share the same catalogue as the desktop shell. Keeping
// this mapping here makes a new feature impossible to ship with a separate
// ad-hoc language mechanism.
const EXTRA_ZH = {
'DRAFT RESTORED':'草稿已恢复','BROWSER LANGUAGE':'浏览器语言',
'Detected: Chinese':'当前识别:中文','Detected: English':'当前识别:英语',
'AUTO':'跟随浏览器','SEARCH MEMORY ARCHIVE':'搜索记忆档案',
'Search titles, notes, moods…':'搜索标题、记录或天气…',
'ESC to close · click a result to open it':'按 Esc 关闭 · 点击结果即可打开',
'Untitled memory':'未命名记忆','No written note.':'尚未写下记录。',
'No memories found.':'没有找到记忆。','CLOUD SYNC PAUSED — CHANGES STAY ON THIS DEVICE':'云端同步暂停——更改仍保留在此设备',
'CLOUD SYNC READY':'云端同步已就绪','Move this browser’s Life OS to the cloud?':'将此浏览器的 Life OS 迁移到云端?',
'Your existing local records will become the first synced copy for this ChatGPT account.':'现有本地记录将成为这个 ChatGPT 账号的第一份云端同步数据。',
'MIGRATE & SYNC':'迁移并同步','START FRESH':'从空白开始','LOCAL LIFE OS MIGRATED':'本地 Life OS 已迁移',
'CLOUD LIFE OS RESTORED':'云端 Life OS 已恢复','CLOUD STORAGE UNAVAILABLE — LOCAL MODE ACTIVE':'云端存储暂不可用——已使用本地模式'
};
if (typeof ZH !== 'undefined') Object.assign(ZH, EXTRA_ZH);
const copy = (en, cn) => (typeof i18n === 'function' ? i18n(en, en) : (zh() ? cn : en));
function readDraft() {
try { return JSON.parse(localStorage.getItem(DRAFT_KEY)); } catch { return null; }
@@ -34,7 +51,8 @@
const actual = typeof browserLanguage === 'function' ? browserLanguage() : 'en';
const section = document.createElement('section');
section.id = 'lifeos-browser-language';
section.innerHTML = `<div class="eyebrow">${copy('BROWSER LANGUAGE', '浏览器语言')}</div><p class="sub">${copy(`Detected: ${actual === 'zh' ? 'Chinese' : 'English'}`, `当前识别:${actual === 'zh' ? '中文' : 'English'}`)}</p><div class="choices"><button class="chip ${state.languageMode !== 'manual' ? 'selected' : ''}" data-language="auto">${copy('AUTO', '跟随浏览器')}</button><button class="chip ${state.languageMode === 'manual' && state.language === 'en' ? 'selected' : ''}" data-language="en">ENGLISH</button><button class="chip ${state.languageMode === 'manual' && state.language === 'zh' ? 'selected' : ''}" data-language="zh">中文</button></div>`;
const detected = actual === 'zh' ? copy('Detected: Chinese', '当前识别:中文') : copy('Detected: English', '当前识别:英语');
section.innerHTML = `<div class="eyebrow">${copy('BROWSER LANGUAGE', '浏览器语言')}</div><p class="sub">${detected}</p><div class="choices"><button class="chip ${state.languageMode !== 'manual' ? 'selected' : ''}" data-language="auto">${copy('AUTO', '跟随浏览器')}</button><button class="chip ${state.languageMode === 'manual' && state.language === 'en' ? 'selected' : ''}" data-language="en">ENGLISH</button><button class="chip ${state.languageMode === 'manual' && state.language === 'zh' ? 'selected' : ''}" data-language="zh">中文</button></div>`;
section.querySelectorAll('button').forEach(button => button.addEventListener('click', () => setLanguage(button.dataset.language)));
[...settingsPanel.children].forEach(node => {
const label = node.querySelector?.('.eyebrow')?.textContent.trim();
@@ -89,6 +107,19 @@
if (next !== node.innerHTML) node.innerHTML = next;
});
}
function polishLocaleChrome() {
const panel = document.querySelector('#content-system .settings');
if (!panel) return;
const appearance = [...panel.querySelectorAll('section')].find(section => {
const label = section.querySelector('.eyebrow')?.textContent.trim();
return label === 'APPEARANCE' || label === '外观';
});
if (!appearance) return;
const labels = zh() ? ['深色', '浅色', '跟随系统'] : ['DARK', 'LIGHT', 'AUTO'];
appearance.querySelectorAll('.chip').forEach((button, index) => {
if (labels[index] && button.textContent !== labels[index]) button.textContent = labels[index];
});
}
function exportData() {
const data = { app: 'Life OS', version: APP_VERSION, schemaVersion: 1, exportedAt: new Date().toISOString(), profile: profile(), memories: mems(), museum: museum(), settings: settings() };
const link = document.createElement('a');
@@ -158,10 +189,11 @@
cloudStyle.textContent = `#lifeos-cloud-migration{position:fixed;inset:0;z-index:9000;background:#071008b8;display:grid;place-items:center;padding:20px}.lifeos-cloud-card{width:min(470px,100%);background:var(--panel);border:1px solid var(--line);border-radius:16px;padding:25px;box-shadow:var(--shadow)}.lifeos-cloud-card h2{margin:10px 0;font-size:25px;letter-spacing:-.04em}.lifeos-cloud-card p{color:var(--muted);line-height:1.65;margin:0 0 20px}`;
document.head.append(cloudStyle);
startCloudSync();
new MutationObserver(() => { wireToday(); wireLanguageControl(); polishSystemChrome(); }).observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ['title'] });
new MutationObserver(() => { wireToday(); wireLanguageControl(); polishSystemChrome(); polishLocaleChrome(); }).observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ['title'] });
wireToday();
wireLanguageControl();
polishSystemChrome();
polishLocaleChrome();
document.addEventListener('click', e => { if (e.target.closest('#content-today .primary')) clearDraftAfterSave(); });
document.addEventListener('click', e => {
if (e.target.closest('.launchitem')) document.querySelector('#launcher')?.classList.add('hidden');