From 7fc9ccfe500a8b15157b5e834ab08565c1557ba2 Mon Sep 17 00:00:00 2001 From: Codex Date: Wed, 14 Oct 2026 17:06:35 +0900 Subject: [PATCH] feat(today): add persistent focus timer --- CHANGELOG.md | 8 ++++++++ README.md | 2 +- package.json | 2 +- public/addons.js | 2 +- public/backup.js | 2 +- public/i18n-renderers.js | 30 +++++++++++++++++++++++++++--- public/index.html | 2 +- public/locales/ar.json | 15 +++++++++++++++ public/locales/en.json | 15 +++++++++++++++ public/locales/es.json | 15 +++++++++++++++ public/locales/fr.json | 15 +++++++++++++++ public/locales/ja.json | 15 +++++++++++++++ public/locales/ru.json | 15 +++++++++++++++ public/locales/zh-CN.json | 15 +++++++++++++++ public/locales/zh-HK.json | 15 +++++++++++++++ public/locales/zh-MO.json | 15 +++++++++++++++ public/locales/zh-TW.json | 15 +++++++++++++++ public/service-worker.js | 2 +- public/system-navigation.js | 2 +- public/terminal-app.js | 4 ++-- scripts/build.mjs | 2 +- scripts/test-workbench.mjs | 17 ++++++++++++++--- scripts/validate.mjs | 2 +- 23 files changed, 210 insertions(+), 17 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fa32e82..59b9990 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,14 @@ 本项目按 `v主版本.次版本.修订版本` 标记应用版本;按需创建 Git tag。下列内容以对应提交和已发布功能为准。 +## v1.28.0 — 2026-10-14 + +- 今日工作台新增专注计时器,可关联当前待办并选择 25 或 50 分钟。 +- 支持暂停、继续和重置;计时依据结束时间计算,刷新页面或短暂离开后仍能恢复准确进度。 +- 完成的专注轮次保留最近 100 条,并显示当天完成数量;旧任务完成后仍保留本轮名称。 +- 专注计时状态仅保存在当前设备,重置 Life OS 数据时一并清除。 +- 增加计时器开始、暂停、恢复、重置、过期结算及重复结算防护测试。 + ## v1.27.0 — 2026-10-13 - 今日页面新增工作台,集中展示今天到期和逾期数量、最多六条当前待办及三个近期目标。 diff --git a/README.md b/README.md index 8c9bc0b..d5ba510 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ 以桌面操作系统为交互方式的个人记录网站。用 App 记录日常、管理目标与待办,并沿时间线回看已经留下的内容。 -在线站点:[Life OS](https://life-os-personal-desktop.biss0.chatgpt.site) · 当前应用版本:**v1.27.0** · [更新日志](CHANGELOG.md) +在线站点:[Life OS](https://life-os-personal-desktop.biss0.chatgpt.site) · 当前应用版本:**v1.28.0** · [更新日志](CHANGELOG.md) ## 功能 diff --git a/package.json b/package.json index cfaf321..63998a9 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "life-os", - "version": "1.27.0", + "version": "1.28.0", "private": true, "type": "module", "scripts": { diff --git a/public/addons.js b/public/addons.js index 82c0e97..31502b9 100644 --- a/public/addons.js +++ b/public/addons.js @@ -3,7 +3,7 @@ const DRAFT_KEY = 'lifeos_today_draft_v1'; const localDay = () => { const d = new Date(); return `${d.getFullYear()}-${String(d.getMonth()+1).padStart(2,'0')}-${String(d.getDate()).padStart(2,'0')}`; }; const escapeHtml = value => String(value || '').replace(/[&<>"']/g, char => ({ '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' }[char])); - const APP_VERSION = '1.27.0'; + const APP_VERSION = '1.28.0'; window.LifeOSVersion = APP_VERSION; const appIds = ['today', 'timeline', 'museum', 'insights', 'profile', 'tasks', 'calendar', 'system', 'browser', 'terminal', 'database']; const t = (key, values) => LifeI18n.t(key, values); diff --git a/public/backup.js b/public/backup.js index 6ab4694..17baf69 100644 --- a/public/backup.js +++ b/public/backup.js @@ -22,7 +22,7 @@ const stored = records(); return { app: 'Life OS', - version: window.LifeOSVersion || '1.27.0', + version: window.LifeOSVersion || '1.28.0', schemaVersion: BACKUP_SCHEMA, exportedAt: new Date().toISOString(), profile: json('lifeos_profile', {}), diff --git a/public/i18n-renderers.js b/public/i18n-renderers.js index 270fd21..ad9950e 100644 --- a/public/i18n-renderers.js +++ b/public/i18n-renderers.js @@ -73,9 +73,30 @@ const goals=board.goals.filter(item=>!item.done && item.targetDate).sort((a,b)=>a.targetDate.localeCompare(b.targetDate)).slice(0,3); return {date,due,overdue,focus,goals}; }; + const FOCUS_TIMER_KEY='lifeos_focus_timer_v1'; + let focusTimerInterval=null; + const focusTimerDefault=()=>({mode:'idle',taskId:'',taskTitle:'',durationSec:1500,remainingSec:1500,endsAt:0,completed:[]}); + const focusTimerRead=()=>{try{const value=JSON.parse(localStorage.getItem(FOCUS_TIMER_KEY)||'{}'),duration=[1500,3000].includes(Number(value.durationSec))?Number(value.durationSec):1500,mode=['idle','running','paused'].includes(value.mode)?value.mode:'idle';return{...focusTimerDefault(),...value,mode,durationSec:duration,remainingSec:Math.max(0,Math.min(Number(value.remainingSec)||duration,duration)),endsAt:Number(value.endsAt)||0,completed:Array.isArray(value.completed)?value.completed.slice(-100):[]};}catch{return focusTimerDefault();}}; + const focusTimerSave=state=>localStorage.setItem(FOCUS_TIMER_KEY,JSON.stringify(state)); + const focusTimerRemaining=(state,now=Date.now())=>state.mode==='running'?Math.max(0,Math.ceil((state.endsAt-now)/1000)):state.remainingSec; + const focusTimerClock=seconds=>`${String(Math.floor(seconds/60)).padStart(2,'0')}:${String(seconds%60).padStart(2,'0')}`; + const focusTimerFinish=state=>{const finished={...state,mode:'idle',remainingSec:state.durationSec,endsAt:0,completed:[...state.completed,{id:`focus_${crypto.randomUUID()}`,date:day(),taskId:state.taskId,taskTitle:state.taskTitle,durationSec:state.durationSec,completedAt:new Date().toISOString()}].slice(-100)};focusTimerSave(finished);toast(t('focus.done'));return finished;}; + const focusTimerMarkup=tasks=>{ + let state=focusTimerRead(),remaining=focusTimerRemaining(state);if(state.mode==='running'&&!remaining){state=focusTimerFinish(state);remaining=state.remainingSec;} + const known=tasks.some(task=>task.id===state.taskId),todayRounds=state.completed.filter(item=>item.date===day()).length,progress=Math.round((1-remaining/state.durationSec)*100); + const options=[``,...tasks.map(task=>``),...(!known&&state.taskId?[``]:[])]; + return `
${t('focus.label')}
${t('focus.title')}
${t('focus.rounds',{count:todayRounds})}
${focusTimerClock(remaining)}
${state.mode==='idle'?``:state.mode==='running'?``:``}
`; + }; + const focusTimerRefresh=()=>{const card=document.querySelector('.focus-timer');if(!card)return;card.outerHTML=focusTimerMarkup(workbenchData().focus);focusTimerMount();}; + const focusTimerTick=()=>{const state=focusTimerRead();if(state.mode!=='running')return;const remaining=focusTimerRemaining(state);if(!remaining){focusTimerFinish(state);focusTimerRefresh();return;}const clock=document.querySelector('#focus-timer-clock'),progress=document.querySelector('#focus-timer-progress');if(clock)clock.textContent=focusTimerClock(remaining);if(progress)progress.style.width=`${Math.round((1-remaining/state.durationSec)*100)}%`;}; + const focusTimerMount=()=>{if(focusTimerInterval){clearInterval(focusTimerInterval);focusTimerInterval=null;}const state=focusTimerRead();if(state.mode==='running'){focusTimerTick();focusTimerInterval=setInterval(focusTimerTick,1000);}}; + window.startFocusTimer=()=>{const task=document.querySelector('#focus-timer-task'),length=document.querySelector('#focus-timer-length'),duration=Number(length?.value)||1500,selected=task?.selectedOptions?.[0];focusTimerSave({...focusTimerDefault(),mode:'running',taskId:task?.value||'',taskTitle:task?.value?(selected?.textContent||''):'',durationSec:duration,remainingSec:duration,endsAt:Date.now()+duration*1000,completed:focusTimerRead().completed});focusTimerRefresh();}; + window.pauseFocusTimer=()=>{const state=focusTimerRead();if(state.mode!=='running')return;focusTimerSave({...state,mode:'paused',remainingSec:focusTimerRemaining(state),endsAt:0});focusTimerRefresh();}; + window.resumeFocusTimer=()=>{const state=focusTimerRead();if(state.mode!=='paused')return;focusTimerSave({...state,mode:'running',endsAt:Date.now()+state.remainingSec*1000});focusTimerRefresh();}; + window.resetFocusTimer=()=>{const state=focusTimerRead();focusTimerSave({...state,mode:'idle',remainingSec:state.durationSec,endsAt:0});focusTimerRefresh();}; const workbenchMarkup = () => { const data=workbenchData(); - return `

${t('workbench.title')}

${data.due.length}${t('workbench.dueToday')}
${data.overdue.length}${t('workbench.overdue')}
${data.focus.length ? data.focus.map(task=>`
`).join('') : `

${t('workbench.empty')}

`}
${data.goals.length ? `
${t('workbench.goals')}
${data.goals.map(goal=>``).join('')}
` : ''}
`; + return `

${t('workbench.title')}

${data.due.length}${t('workbench.dueToday')}
${data.overdue.length}${t('workbench.overdue')}
${focusTimerMarkup(data.focus)}
${data.focus.length ? data.focus.map(task=>`
`).join('') : `

${t('workbench.empty')}

`}
${data.goals.length ? `
${t('workbench.goals')}
${data.goals.map(goal=>``).join('')}
` : ''}
`; }; const captureWorkbenchDraft = () => { const container=document.querySelector('#content-today'); @@ -106,7 +127,7 @@ originalToday(container); const date = todayTargetDate || day(), moments = mems().filter(item => item.date === date && item.kind === 'moment'); if(todayMetadataDraft?.date===date)todayMetadataDraft.values.forEach(([id,value])=>{const node=container.querySelector?.('#'+id);if(node)node.value=value;}); - if(date===day())container.insertAdjacentHTML('afterbegin',workbenchMarkup()); + if(date===day()){container.insertAdjacentHTML('afterbegin',workbenchMarkup());focusTimerMount();} container.insertAdjacentHTML('beforeend', `
${t('moments.label')}

${t('moments.count', { count:moments.length })}

${moments.length ? `
${moments.map(item => ``).join('')}
` : `

${t('moments.empty')}

`}
`); }; const quickButton = document.createElement('button'); @@ -120,6 +141,9 @@ const workbenchStyle=document.createElement('style'); workbenchStyle.textContent=`.today-workbench{padding-bottom:22px;margin-bottom:22px;border-bottom:1px solid var(--line)}.today-workbench header{display:flex;align-items:center;justify-content:space-between;gap:12px}.today-workbench h2{font-size:22px;letter-spacing:-.02em;margin:0}.today-workbench .text-link{font-size:14px}.workbench-counts{display:flex;gap:28px;margin:15px 0}.workbench-counts>div{display:flex;align-items:center;gap:9px}.workbench-counts strong{font-size:26px;color:var(--accent)}.workbench-counts span{font-size:14px;color:var(--muted)}.workbench-add{display:flex;gap:8px}.workbench-add input{flex:1;min-width:0;padding:10px;border:1px solid var(--line);border-radius:9px;background:var(--panel2);font-size:16px}.workbench-add button{font-size:14px;letter-spacing:0;flex:none}.workbench-list{display:grid;gap:6px;margin-top:12px}.workbench-task{display:flex;gap:10px;align-items:center;padding:10px;border:1px solid var(--line);border-radius:9px;background:var(--panel2)}.workbench-check{width:36px;height:36px;border:1px solid var(--line);border-radius:8px;background:transparent;font-size:24px;flex:none}.workbench-task-copy{flex:1;min-width:0;border:0;background:transparent;text-align:start;display:grid;gap:5px}.workbench-task-copy strong{font-size:14px;overflow-wrap:anywhere}.workbench-task-copy small{font-size:12px;color:var(--muted)}.workbench-goals{margin-top:16px;display:grid;gap:7px}.workbench-goals button{display:flex;justify-content:space-between;gap:14px;padding:10px;border:1px solid var(--line);border-radius:9px;background:transparent;text-align:start}.workbench-goals strong{font-size:14px;overflow-wrap:anywhere}.workbench-goals small{font-size:12px;color:var(--muted);flex:none}#workbench-error{color:#eea27d;font-size:14px;margin:7px 0 0}@media(max-width:650px){.workbench-counts{gap:18px}.today-workbench h2{font-size:20px}}`; document.head.append(workbenchStyle); + const focusStyle=document.createElement('style'); + focusStyle.textContent=`.focus-timer{margin:4px 0 18px;padding:15px;border:1px solid var(--line);border-radius:12px;background:color-mix(in srgb,var(--accent) 8%,var(--panel2))}.focus-timer-head{display:flex;align-items:flex-start;justify-content:space-between;gap:12px}.focus-timer-head .eyebrow{margin-bottom:4px}.focus-timer-head>div>strong{font-size:16px}.focus-timer-head>span{color:var(--muted);font-size:12px}.focus-timer-clock{margin:14px 0 7px;font:600 38px 'DM Mono';letter-spacing:-.06em}.focus-timer-progress{height:5px;border-radius:9px;background:var(--line);overflow:hidden}.focus-timer-progress i{display:block;height:100%;border-radius:inherit;background:var(--accent);transition:width .3s linear}.focus-timer-controls{display:grid;grid-template-columns:minmax(0,1fr) 140px;gap:8px;margin-top:13px}.focus-timer-controls label{display:grid;gap:5px;color:var(--muted);font-size:11px}.focus-timer-controls select{width:100%;min-width:0;padding:9px;border:1px solid var(--line);border-radius:8px;background:var(--panel);color:var(--ink)}.focus-timer-controls select:disabled{opacity:.72}.focus-timer-actions{display:flex;gap:8px;margin-top:11px}.focus-timer-actions button{font-size:12px;letter-spacing:.04em}@media(max-width:650px){.focus-timer-controls{grid-template-columns:1fr}.focus-timer-clock{font-size:34px}}`; + document.head.append(focusStyle); window.timeline = container => { const all = mems(), tags = [...new Set(all.flatMap(item => item.tags || []))].sort((a,b) => a.localeCompare(b)); const query = window.timelineQuery || '', selectedTag = window.timelineTag || ''; @@ -243,7 +267,7 @@ } rootModal().innerHTML = ''; toast('feedback.restoring'); setTimeout(() => { renderAll(); toast('feedback.restored'); }, 500); }; - window.resetConfirm = () => { rootModal().innerHTML = ``; }; + window.resetConfirm = () => { rootModal().innerHTML = ``; }; window.toast = key => { const message = key.includes('.') ? t(key) : key; const node = document.createElement('div'); node.className = 'toast'; node.textContent = message; document.body.append(node); setTimeout(() => node.remove(), 2000); }; window.minWin = id => { const windowNode = windows[id]; if (!windowNode) return; windowNode.classList.add('min'); if (activeWindow === id) { activeWindow = Object.keys(windows).find(key => key !== id && !windows[key].classList.contains('min')) || null; if (activeWindow) focus(windows[activeWindow]); } renderTaskbar(); toast('feedback.minimized'); }; const memoryStyle = document.createElement('style'); diff --git a/public/index.html b/public/index.html index 19acb77..40fd5c1 100644 --- a/public/index.html +++ b/public/index.html @@ -25,4 +25,4 @@ function profileApp(c){let p=profile(),a=mems(),common=Object.entries(a.reduce(( function today(c){let m=mems().find(x=>x.date===day());if(todayDraft===null){selectedMood=m?.mood||'cloudy';selectedEnergy=m?.energy||3}let f=m||filmFor(selectedMood,selectedEnergy),text=todayDraft===null?(m?.text||''):todayDraft,cWeek=new Date().toLocaleDateString(LifeI18n.locale(),{weekday:'long'}).toUpperCase();c.innerHTML=`
${cWeek}

${fmtDate(day()).replace(/^[^,]+, /,'')}

${i18n('How was your day?')}

`}function rerenderToday(){let old=document.querySelector('#entry');todayDraft=old?old.value:todayDraft||'';window.today(document.querySelector('#content-today'));let entry=document.querySelector('#entry');entry?.focus();entry?.setSelectionRange(entry.value.length,entry.value.length)} function systemApp(c){let s=settings(),bytes=new Blob([JSON.stringify({mems:mems(),museum:museum(),profile:profile()})]).size;let rec=s.lastBackup&&(Date.now()-new Date(s.lastBackup)>12096e5);c.innerHTML=`
SYSTEM SETTINGS

System, local and yours.

APPEARANCE
${['dark','light','auto'].map(x=>``).join('')}
LANGUAGE
DATA
STORAGE

Local Storage
${mems().length} memories · ${museum().length} museum items · Approx. ${Math.ceil(bytes/1024)} KB

DATA STORAGE

Your data is stored locally in this browser.
Create regular backups to prevent data loss.

${s.lastBackup?'LAST BACKUP · '+fmtDate(s.lastBackup.slice(0,10)):'LAST BACKUP · NEVER'} ${rec?'
BACKUP RECOMMENDED':''}

VERSION

Life OS
Version ${window.LifeOSVersion||'1.18.1'} · Schema v2

`}function theme(x){let s=settings();s.theme=x;save('lifeos_settings',s);init();renderAll()}function exportData(){let data={app:'Life OS',version:window.LifeOSVersion||'1.18.1',schemaVersion:1,exportedAt:new Date().toISOString(),profile:profile(),memories:mems(),museum:museum(),settings:settings()};let a=document.createElement('a');a.href=URL.createObjectURL(new Blob([JSON.stringify(data,null,2)],{type:'application/json'}));a.download='life-os-backup-'+day()+'.json';a.click();let s=settings();s.lastBackup=new Date().toISOString();save('lifeos_settings',s);renderAll();toast('BACKUP CREATED')}function readImport(el){let f=el.files[0];if(!f)return;let r=new FileReader;r.onload=()=>{try{let d=JSON.parse(r.result);if(d.app!=='Life OS'||![1,2,3].includes(d.schemaVersion)||!Array.isArray(d.memories)||!Array.isArray(d.museum))throw 0;importData=d;importPreview()}catch{toast('INVALID BACKUP FILE')}};r.readAsText(f)}function importPreview(){let d=importData;modal.innerHTML=``}function replaceConfirm(){modal.innerHTML=``}function applyImport(mode){let d=importData;if(mode==='replace'){save('lifeos_memories',d.memories);save('lifeos_museum',d.museum);save('lifeos_profile',d.profile||{});save('lifeos_settings',d.settings||{})}else{let a=mems(), ids=new Set(a.map(x=>x.id)),dates=new Set(a.map(x=>x.date));save('lifeos_memories',[...a,...d.memories.filter(x=>!ids.has(x.id)&&!dates.has(x.date))]);let mu=museum(),mi=new Set(mu.map(x=>x.id));save('lifeos_museum',[...mu,...d.museum.filter(x=>!mi.has(x.id))])}modal.innerHTML='';toast('RESTORING SYSTEM...');setTimeout(()=>{renderAll();toast('SYSTEM RESTORED')},500)}function resetConfirm(){modal.innerHTML=``}function toast(t){let x=document.createElement('div');x.className='toast';x.textContent=t;document.body.append(x);setTimeout(()=>x.remove(),2000)} window.renderIcons=renderIcons;window.renderAll=renderAll;window.toast=toast; - + diff --git a/public/locales/ar.json b/public/locales/ar.json index a60b663..f5acf76 100644 --- a/public/locales/ar.json +++ b/public/locales/ar.json @@ -10,6 +10,21 @@ "goals": "أهداف قادمة", "error": "تعذرت الإضافة. تحقق من العنوان." }, + "focus": { + "label": "تركيز", + "title": "مؤقت التركيز", + "task": "المهمة", + "noTask": "من دون مهمة مرتبطة", + "length": "المدة", + "minutes25": "25 دقيقة", + "minutes50": "50 دقيقة", + "start": "بدء", + "pause": "إيقاف مؤقت", + "resume": "متابعة", + "reset": "إعادة ضبط", + "rounds": "{count} جلسات اليوم", + "done": "اكتملت جلسة التركيز" + }, "trash": { "title": "سلة المحذوفات", "hint": "تبقى الذكريات واللحظات والمهام والأهداف حتى استعادتها أو حذفها.", diff --git a/public/locales/en.json b/public/locales/en.json index d134d2b..e9a6093 100644 --- a/public/locales/en.json +++ b/public/locales/en.json @@ -10,6 +10,21 @@ "goals": "UPCOMING GOALS", "error": "Could not add the task. Check the title and try again." }, + "focus": { + "label": "FOCUS", + "title": "Focus timer", + "task": "Task", + "noTask": "No linked task", + "length": "Length", + "minutes25": "25 minutes", + "minutes50": "50 minutes", + "start": "START", + "pause": "PAUSE", + "resume": "RESUME", + "reset": "RESET", + "rounds": "{count} rounds today", + "done": "Focus round complete" + }, "trash": { "title": "RECYCLE BIN", "hint": "Memories, moments, tasks and goals stay here until restored or permanently deleted.", diff --git a/public/locales/es.json b/public/locales/es.json index ea4c69b..d2cddea 100644 --- a/public/locales/es.json +++ b/public/locales/es.json @@ -10,6 +10,21 @@ "goals": "PRÓXIMOS OBJETIVOS", "error": "No se pudo añadir. Comprueba el título." }, + "focus": { + "label": "CONCENTRACIÓN", + "title": "Temporizador de concentración", + "task": "Tarea", + "noTask": "Sin tarea vinculada", + "length": "Duración", + "minutes25": "25 minutos", + "minutes50": "50 minutos", + "start": "INICIAR", + "pause": "PAUSAR", + "resume": "CONTINUAR", + "reset": "REINICIAR", + "rounds": "{count} sesiones hoy", + "done": "Sesión de concentración completada" + }, "trash": { "title": "PAPELERA", "hint": "Recuerdos, momentos, tareas y objetivos permanecen aquí hasta restaurarlos o eliminarlos.", diff --git a/public/locales/fr.json b/public/locales/fr.json index c0a0612..498a427 100644 --- a/public/locales/fr.json +++ b/public/locales/fr.json @@ -10,6 +10,21 @@ "goals": "OBJECTIFS À VENIR", "error": "Impossible d’ajouter la tâche. Vérifiez le titre." }, + "focus": { + "label": "CONCENTRATION", + "title": "Minuteur de concentration", + "task": "Tâche", + "noTask": "Aucune tâche liée", + "length": "Durée", + "minutes25": "25 minutes", + "minutes50": "50 minutes", + "start": "DÉMARRER", + "pause": "PAUSE", + "resume": "REPRENDRE", + "reset": "RÉINITIALISER", + "rounds": "{count} sessions aujourd’hui", + "done": "Session de concentration terminée" + }, "trash": { "title": "CORBEILLE", "hint": "Souvenirs, instants, tâches et objectifs restent ici jusqu’à restauration ou suppression.", diff --git a/public/locales/ja.json b/public/locales/ja.json index 46f60c9..171b019 100644 --- a/public/locales/ja.json +++ b/public/locales/ja.json @@ -10,6 +10,21 @@ "goals": "近い目標", "error": "追加できませんでした。タイトルを確認してください。" }, + "focus": { + "label": "集中", + "title": "集中タイマー", + "task": "タスク", + "noTask": "タスクに関連付けない", + "length": "時間", + "minutes25": "25分", + "minutes50": "50分", + "start": "開始", + "pause": "一時停止", + "resume": "再開", + "reset": "リセット", + "rounds": "今日 {count} ラウンド完了", + "done": "集中ラウンドが完了しました" + }, "trash": { "title": "ごみ箱", "hint": "記憶、瞬間、タスク、目標は復元または完全削除するまで残ります。", diff --git a/public/locales/ru.json b/public/locales/ru.json index bcc5633..fd83e38 100644 --- a/public/locales/ru.json +++ b/public/locales/ru.json @@ -10,6 +10,21 @@ "goals": "БЛИЖАЙШИЕ ЦЕЛИ", "error": "Не удалось добавить. Проверьте заголовок." }, + "focus": { + "label": "ФОКУС", + "title": "Таймер фокуса", + "task": "Задача", + "noTask": "Без связанной задачи", + "length": "Длительность", + "minutes25": "25 минут", + "minutes50": "50 минут", + "start": "НАЧАТЬ", + "pause": "ПАУЗА", + "resume": "ПРОДОЛЖИТЬ", + "reset": "СБРОСИТЬ", + "rounds": "Сегодня завершено: {count}", + "done": "Сеанс фокуса завершён" + }, "trash": { "title": "КОРЗИНА", "hint": "Записи, моменты, задачи и цели остаются до восстановления или удаления.", diff --git a/public/locales/zh-CN.json b/public/locales/zh-CN.json index 942cbf8..ec9e02e 100644 --- a/public/locales/zh-CN.json +++ b/public/locales/zh-CN.json @@ -10,6 +10,21 @@ "goals": "近期目标", "error": "未能添加待办,请检查标题后重试。" }, + "focus": { + "label": "专注", + "title": "专注计时器", + "task": "关联待办", + "noTask": "不关联待办", + "length": "时长", + "minutes25": "25 分钟", + "minutes50": "50 分钟", + "start": "开始", + "pause": "暂停", + "resume": "继续", + "reset": "重置", + "rounds": "今天已完成 {count} 轮", + "done": "本轮专注已完成" + }, "trash": { "title": "回收站", "hint": "记忆、瞬间、任务和目标保留在这里,直到恢复或永久删除。", diff --git a/public/locales/zh-HK.json b/public/locales/zh-HK.json index 901dde7..a220b33 100644 --- a/public/locales/zh-HK.json +++ b/public/locales/zh-HK.json @@ -10,6 +10,21 @@ "goals": "近期目標", "error": "未能新增待辦,請檢查標題後重試。" }, + "focus": { + "label": "專注", + "title": "專注計時器", + "task": "關聯待辦", + "noTask": "不關聯待辦", + "length": "時長", + "minutes25": "25 分鐘", + "minutes50": "50 分鐘", + "start": "開始", + "pause": "暫停", + "resume": "繼續", + "reset": "重設", + "rounds": "今天已完成 {count} 輪", + "done": "本輪專注已完成" + }, "trash": { "title": "回收站", "hint": "記憶、瞬間、任務和目標保留在這裡,直到恢復或永久刪除。", diff --git a/public/locales/zh-MO.json b/public/locales/zh-MO.json index 44b833e..88fc365 100644 --- a/public/locales/zh-MO.json +++ b/public/locales/zh-MO.json @@ -10,6 +10,21 @@ "goals": "近期目標", "error": "未能新增待辦,請檢查標題後重試。" }, + "focus": { + "label": "專注", + "title": "專注計時器", + "task": "關聯待辦", + "noTask": "不關聯待辦", + "length": "時長", + "minutes25": "25 分鐘", + "minutes50": "50 分鐘", + "start": "開始", + "pause": "暫停", + "resume": "繼續", + "reset": "重設", + "rounds": "今天已完成 {count} 輪", + "done": "本輪專注已完成" + }, "trash": { "title": "回收站", "hint": "記憶、瞬間、任務和目標保留在這裡,直到恢復或永久刪除。", diff --git a/public/locales/zh-TW.json b/public/locales/zh-TW.json index 2fa0808..df0afcf 100644 --- a/public/locales/zh-TW.json +++ b/public/locales/zh-TW.json @@ -10,6 +10,21 @@ "goals": "近期目標", "error": "未能新增待辦,請檢查標題後重試。" }, + "focus": { + "label": "專注", + "title": "專注計時器", + "task": "關聯待辦", + "noTask": "不關聯待辦", + "length": "時長", + "minutes25": "25 分鐘", + "minutes50": "50 分鐘", + "start": "開始", + "pause": "暫停", + "resume": "繼續", + "reset": "重設", + "rounds": "今天已完成 {count} 輪", + "done": "本輪專注已完成" + }, "trash": { "title": "回收站", "hint": "記憶、瞬間、任務和目標保留在這裡,直到還原或永久刪除。", diff --git a/public/service-worker.js b/public/service-worker.js index 20957e5..bdbc170 100644 --- a/public/service-worker.js +++ b/public/service-worker.js @@ -1,4 +1,4 @@ -const CACHE = 'life-os-shell-v1.27.0'; +const CACHE = 'life-os-shell-v1.28.0'; const SHELL = [ '/', '/index.html', '/manifest.webmanifest', '/life-os-icon.svg', '/local-db-worker.js', '/sqlite3.mjs', '/sqlite3.wasm' diff --git a/public/system-navigation.js b/public/system-navigation.js index 04abd9f..5e3db5d 100644 --- a/public/system-navigation.js +++ b/public/system-navigation.js @@ -27,7 +27,7 @@ shell.innerHTML = `
${t('settings')}

${t(active)}

${active === 'home' ? `

${t('homeHint')}

` : ''}
`; const view = shell.querySelector('.system-settings-view'); if (active === 'home') { - view.innerHTML = `
${t('device')}

${t('deviceHint')}

${t('version', { version: window.LifeOSVersion || '1.27.0' })}
${t('quickSettings')}
${['appearance', 'notifications', 'language', 'data'].map(id => `
${navigationButton(id, true)}

${t(`${id}Hint`)}

`).join('')}
`; + view.innerHTML = `
${t('device')}

${t('deviceHint')}

${t('version', { version: window.LifeOSVersion || '1.28.0' })}
${t('quickSettings')}
${['appearance', 'notifications', 'language', 'data'].map(id => `
${navigationButton(id, true)}

${t(`${id}Hint`)}

`).join('')}
`; } else { const group = document.createElement('div'); group.className = 'settings system-settings-group'; diff --git a/public/terminal-app.js b/public/terminal-app.js index 1079926..0109067 100644 --- a/public/terminal-app.js +++ b/public/terminal-app.js @@ -150,7 +150,7 @@ return { message: new Intl.DateTimeFormat(LifeI18n.locale(), options).format(new Date()) }; } if (kind === 'uptime') { if (verb) throw new Error('usage'); const seconds = Math.floor((Date.now() - startedAt) / 1000); return { message: t('uptime', { minutes: Math.floor(seconds / 60), seconds: seconds % 60 }) }; } - if (kind === 'version') { if (verb) throw new Error('usage'); return { message: `Life OS v${window.LifeOSVersion || '1.27.0'}` }; } + if (kind === 'version') { if (verb) throw new Error('usage'); return { message: `Life OS v${window.LifeOSVersion || '1.28.0'}` }; } if (kind === 'status') { if (verb) throw new Error('usage'); const data = board(); return { message: t('status', { memories: mems().length, goals: data.goals.length, tasks: data.tasks.length }) }; } if (kind === 'apps') { if (verb) throw new Error('usage'); return { message: Object.keys(APPS).map(id => `${id} — ${LifeI18n.t(`app.${id}`)}`).join('\n') }; } if (kind === 'history') { if (verb) throw new Error('usage'); return { message: history.slice(-20).map((entry,index) => `${index + 1}. ${entry}`).join('\n') || t('empty') }; } @@ -235,7 +235,7 @@ }; window.terminalApp = node => { if (node.querySelector('.terminal-shell') && node.dataset.terminalLocale === lang()) { output(node); return; } - if (!welcomed) { lines.unshift({ value: t('welcome', { version: window.LifeOSVersion || '1.27.0' }), kind: 'system' }); welcomed = true; } + if (!welcomed) { lines.unshift({ value: t('welcome', { version: window.LifeOSVersion || '1.28.0' }), kind: 'system' }); welcomed = true; } node.dataset.terminalLocale = lang(); node.innerHTML = `
Life OS / ${t('title')}${t('hint')}
`; output(node); composer(node, Boolean(compose)); diff --git a/scripts/build.mjs b/scripts/build.mjs index 620dd3f..394a769 100644 --- a/scripts/build.mjs +++ b/scripts/build.mjs @@ -13,7 +13,7 @@ const [rawIndexHtml, addonsJs, backupJs, bootGuardJs, localDbJs, localDbWorkerJs readFile(new URL("../node_modules/@sqlite.org/sqlite-wasm/dist/sqlite3.wasm", import.meta.url)), text("i18n.js"), text("tasks.js"), text("calendar.js"), text("notifications.js"), text("i18n-renderers.js"), text("desktop-personalization.js"), text("desktop-widgets.js"), text("system-navigation.js"), text("browser-app.js"), text("data-actions.js"), text("terminal-app.js"), text("db-admin.js"), text("manifest.webmanifest"), text("service-worker.js"), text("life-os-icon.svg"), readFile(new URL("../public/locales/en.json", import.meta.url), "utf8"), readFile(new URL("../public/locales/zh-CN.json", import.meta.url), "utf8") ]); -const release = "1.27.0"; +const release = "1.28.0"; const localeEnJs = `window.LifeOSLocales=window.LifeOSLocales||{};window.LifeOSLocales.en=${localeEn};`; const localeZhJs = `window.LifeOSLocales=window.LifeOSLocales||{};window.LifeOSLocales['zh-CN']=${localeZh};`; const extraLocaleCodes = ['zh-HK', 'zh-MO', 'zh-TW', 'ar', 'fr', 'ru', 'es', 'ja']; diff --git a/scripts/test-workbench.mjs b/scripts/test-workbench.mjs index a321aa4..9ec52a1 100644 --- a/scripts/test-workbench.mjs +++ b/scripts/test-workbench.mjs @@ -10,16 +10,19 @@ let state={tasksBoard:{goals:[{id:'goal',title:'Upcoming',targetDate:'2026-10-20 {id:'trash',title:'Trash',dueDate:'2026-10-13',trashedAt:'2026-10-13',done:false} ]}}; const fields=Object.fromEntries([['entry','Draft note'],['memory-title','Draft title'],['memory-tags','private, study'],['memory-place','Library'],['memory-task','due']].map(([k,v])=>['#'+k,{value:v}])); +const timerTask={value:'due',selectedOptions:[{textContent:'Due'}]},timerLength={value:'1500'}; const container={querySelector:selector=>fields[selector]||null}; +const storage=new Map(); const ctx=vm.createContext({sys:()=>structuredClone(state),mems:()=>[],museum:()=>[],save:(key,value)=>{if(key==='lifeos_system')state=structuredClone(value);},day:()=> '2026-10-13',crypto:globalThis.crypto, - document:{querySelector:selector=>selector==='#content-today'?container:null},todayDraft:null,todayTitleDraft:null,todayTargetDate:null, + localStorage:{getItem:key=>storage.get(key)||null,setItem:(key,value)=>storage.set(key,value),removeItem:key=>storage.delete(key)}, + document:{querySelector:selector=>selector==='#content-today'?container:selector==='#focus-timer-task'?timerTask:selector==='#focus-timer-length'?timerLength:null},todayDraft:null,todayTitleDraft:null,todayTargetDate:null, renderAll:()=>{for(const field of Object.values(fields))field.value='';},t:key=>key,short:v=>v,esc:v=>String(v||''),escAttr:v=>String(v||''),toast(){} }); ctx.window=ctx; vm.runInContext(readFileSync(new URL('../public/data-actions.js',import.meta.url),'utf8'),ctx); const source=readFileSync(new URL('../public/i18n-renderers.js',import.meta.url),'utf8'); const start=source.indexOf(' const workbenchData ='); -vm.runInContext('let todayMetadataDraft=null;'+source.slice(start,source.indexOf(' window.today = container => {',start))+'\nwindow.WorkbenchTest={data:workbenchData,markup:workbenchMarkup};',ctx); +vm.runInContext('let todayMetadataDraft=null;'+source.slice(start,source.indexOf(' window.today = container => {',start))+'\nwindow.WorkbenchTest={data:workbenchData,markup:workbenchMarkup,focusMarkup:focusTimerMarkup,focusRead:focusTimerRead};',ctx); const data=ctx.WorkbenchTest.data(); assert.equal(data.due.length,1);assert.equal(data.overdue.length,1); assert.deepEqual(Array.from(data.focus,item=>item.id),['overdue','due','no-date']); @@ -31,4 +34,12 @@ assert.equal(ctx.todayDraft,'Draft note');assert.equal(ctx.todayTitleDraft,'Draf assert.equal(fields['#memory-tags'].value,'private, study');assert.equal(fields['#memory-place'].value,'Library'); ctx.completeWorkbenchTask('due');assert.equal(state.tasksBoard.tasks.find(item=>item.id==='due').done,true); assert.ok(state.tasksBoard.tasks.some(item=>item.id==='later'),'future tasks remain intact'); -console.log('Life OS workbench filtering, quick actions and diary metadata preservation valid'); +ctx.startFocusTimer();let timer=ctx.WorkbenchTest.focusRead(); +assert.equal(timer.mode,'running');assert.equal(timer.taskId,'due');assert.equal(timer.durationSec,1500); +ctx.pauseFocusTimer();timer=ctx.WorkbenchTest.focusRead();assert.equal(timer.mode,'paused');assert.ok(timer.remainingSec>0); +ctx.resumeFocusTimer();assert.equal(ctx.WorkbenchTest.focusRead().mode,'running'); +ctx.resetFocusTimer();assert.equal(ctx.WorkbenchTest.focusRead().mode,'idle'); +storage.set('lifeos_focus_timer_v1',JSON.stringify({...timer,mode:'running',endsAt:Date.now()-1000,completed:[]})); +ctx.WorkbenchTest.focusMarkup([]);assert.equal(ctx.WorkbenchTest.focusRead().completed.length,1); +ctx.WorkbenchTest.focusMarkup([]);assert.equal(ctx.WorkbenchTest.focusRead().completed.length,1,'expired timer completes only once'); +console.log('Life OS workbench, focus timer lifecycle and diary draft preservation valid'); diff --git a/scripts/validate.mjs b/scripts/validate.mjs index 9a1687c..d3a5743 100644 --- a/scripts/validate.mjs +++ b/scripts/validate.mjs @@ -285,7 +285,7 @@ assert.ok(command('date').message.length > 8); assert.ok(command('time').message.includes(':')); assert.ok(command('datetime').message.length > 12); assert.equal(command('uptime').message, 'terminal.uptime'); -assert.equal(command('version').message, 'Life OS v1.27.0'); +assert.equal(command('version').message, 'Life OS v1.28.0'); assert.equal(command('status').message, 'terminal.status'); assert.match(command('apps').message, /calendar/); assert.equal(command('echo "hello Life OS"').message, 'hello Life OS');