Files
xiaoyin-markdown/tools/screenshots/mock-api.js
T
Jidekin e4cf1db785 docs(site): 重出官网截图(2.6.3 界面:更新入口在状态栏、无工具条图标)
界面变了,截图跟着重出:
  · 更新入口从工具条图标改成状态栏右下角蓝色「检查更新」—— 新图里能看到
  · 工具条右上角不再有那个下载箭头图标

同时把样例文档里的过时内容换掉(原来写「体积从 152 MB 降到 1.6 MB」,
1.6MB 早就不对了),改成讲这周做的在线升级,数字只说「不再捆绑运行时」这种不会烂的表述。

四张图重压到 1600 宽 JPEG q88,合计 549KB。工具链见 tools/screenshots/README.md。
2026-11-20 10:45:09 +08:00

103 lines
3.5 KiB
JavaScript

/* 截图专用 mock:把 Windows 侧的文件/剪贴板接口换成假数据,
界面部分(index.html / style.css / app.js / markdown.js)全是仓库里的真实代码。 */
(function () {
const q = new URLSearchParams(location.search);
const theme = q.get('theme') || 'light';
const mode = q.get('mode') || 'split';
// app.js 自己用的状态键,预先写好,避免出现欢迎页
localStorage.setItem('md-editor-theme', theme);
localStorage.setItem('md-editor-mode', mode);
localStorage.setItem('md-editor-outline', '1');
localStorage.setItem('md-editor-sb', '0'); // 侧栏展开
localStorage.setItem('md-editor-dir', 'D:\\notes');
localStorage.setItem('md-editor-welcome-closed', '1');
const DOC = `# 周报 · 2026 第 47 周
本周主要在收尾 **小银 Markdown** 的在线升级,顺手把官网也改了一版。
## 这周做了什么
- 新增在线升级:状态栏右下角点「检查更新」就能装新版
- 安装包换成 Tauri,不再捆绑运行时
- 官网换成真实界面截图,配色参照 UU 远程
- 修掉 \`Ctrl+F\` 在长文档里的滚动抖动
## 待办
- [x] 交叉编译出 Windows 安装包
- [x] 装完 .md 默认用它打开
- [x] 在线升级跑通签名校验
- [ ] 补一段更新日志
- [ ] 录个 30 秒的演示视频
## 关键代码
\`\`\`js
// 检查 → 下载 → 覆盖安装 → 重启
const st = await invoke('check_update')
if (st.available) await invoke('install_update')
\`\`\`
## 常用快捷键
| 操作 | 快捷键 |
| --- | --- |
| 查找 | Ctrl + F |
| 保存 | Ctrl + S |
| 深色 / 浅色 | Ctrl + Shift + L |
> 下周把 README 补一节「用 Tauri 打包」,再录个演示视频。
`;
const TREE = [
{ name: '项目', path: 'D:\\notes\\项目', isDir: true },
{ name: '日记', path: 'D:\\notes\\日记', isDir: true },
{ name: '周报-2026-11-19.md', path: 'D:\\notes\\周报-2026-11-19.md', isDir: false },
{ name: '读书笔记.md', path: 'D:\\notes\\读书笔记.md', isDir: false },
{ name: '待办.txt', path: 'D:\\notes\\待办.txt', isDir: false },
];
const DOC_PATH = 'D:\\notes\\周报-2026-11-19.md';
const ok = (o) => Object.assign({ ok: true }, o || {});
const opened = () => ok({ path: DOC_PATH, name: '周报-2026-11-19.md', text: DOC, eol: '\n' });
window.api = {
// ——— 文件 ———
open: async () => opened(),
openPath: async () => opened(),
readFileText: async () => ok({ text: DOC, eol: '\n' }),
save: async () => ok({ path: DOC_PATH, name: '周报-2026-11-19.md' }),
dirOpen: async () => ok({ path: 'D:\\notes', name: 'notes', entries: TREE }),
dirRead: async (p) => ok({ path: p || 'D:\\notes', name: (p || '').split('\\').pop() || 'notes', entries: TREE }),
// ——— 窗口/标签 ———
getOpenMode: async () => ({ mode: 'tabs' }),
setOpenMode: async () => ok(),
newWindow: async () => ok(),
openNewWindow: async () => ok(),
closeWindow: async () => ok(),
syncDoc: async () => ok(),
setDirty: () => {},
// ——— 提示/对话框 ———
message: async () => 0,
reveal: async () => ok(),
revealPath: async () => ok(),
openExternal: async () => ok(),
// ——— 剪贴板 ———
copyFile: async () => ok(),
readClipboard: async () => '',
writeClipboard: async () => ok(),
// ——— 事件订阅(真实主进程里由 IPC 推来)———
onCommand: () => {},
onCloseConfirm: () => {},
onExport: () => {},
saveFinished: () => {},
exportDocs: async () => ok(),
};
})();