diff --git a/web/src/app/Icon.vue b/web/src/app/Icon.vue index 35676e1..763941a 100644 --- a/web/src/app/Icon.vue +++ b/web/src/app/Icon.vue @@ -21,6 +21,7 @@ const paths = { user: 'M20 21v-2a4 4 0 0 0-4-4H8a4 4 0 0 0-4 4v2M12 11a4 4 0 1 0 0-8 4 4 0 0 0 0 8z', outline: 'M8 6h13M8 12h13M8 18h13M3 6h.01M3 12h.01M3 18h.01', command: 'M18 3a3 3 0 0 0-3 3v12a3 3 0 1 0 3-3H6a3 3 0 1 0 3 3V6a3 3 0 1 0-3 3h12a3 3 0 0 0 0-6z', + info: 'M12 22a10 10 0 1 0 0-20 10 10 0 0 0 0 20zM12 11v6M12 7h.01', } export type IconName = keyof typeof paths defineProps<{ name: IconName; size?: number }>() diff --git a/web/src/app/SettingsDialog.vue b/web/src/app/SettingsDialog.vue index 5f6fb7c..57dad56 100644 --- a/web/src/app/SettingsDialog.vue +++ b/web/src/app/SettingsDialog.vue @@ -20,8 +20,12 @@ const SECTIONS: { id: SettingsSection; title: string; icon: IconName }[] = [ { id: 'shares', title: '分享链接', icon: 'link' }, { id: 'tokens', title: 'API 令牌', icon: 'key' }, { id: 'trash', title: '回收站', icon: 'trash' }, + { id: 'about', title: '关于', icon: 'info' }, ] +const buildVersion = import.meta.env.DEV ? '开发版' : document.querySelector('meta[name="rawmark-version"]')?.content +if (!buildVersion) throw new Error('缺少应用构建版本信息') + // 编辑器内置的按键(不在命令注册表中) const EDITOR_KEYS = [ { title: '粗体', keys: 'Mod+B' }, @@ -177,6 +181,19 @@ async function changePassword() { + diff --git a/web/src/app/workspace.ts b/web/src/app/workspace.ts index 942cec5..2c470f4 100644 --- a/web/src/app/workspace.ts +++ b/web/src/app/workspace.ts @@ -30,7 +30,7 @@ export interface Tab { conflictRev?: string } -export type SettingsSection = 'appearance' | 'editor' | 'account' | 'shortcuts' | 'shares' | 'tokens' | 'trash' | 'plugins' +export type SettingsSection = 'appearance' | 'editor' | 'account' | 'shortcuts' | 'shares' | 'tokens' | 'trash' | 'plugins' | 'about' export interface Toast { id: number diff --git a/web/vite.config.ts b/web/vite.config.ts index eed2656..c9cf3be 100644 --- a/web/vite.config.ts +++ b/web/vite.config.ts @@ -22,8 +22,13 @@ export default defineConfig({ version.update(readFileSync(new URL('./public/' + name, import.meta.url))) files.push(name) } + const buildVersion = version.digest('hex').slice(0, 16) + const entry = bundle['index.html'] + if (!entry || entry.type !== 'asset' || typeof entry.source !== 'string') throw new Error('缺少应用入口 HTML,无法写入构建版本') + // 入口与离线外壳使用同一构建标识,旧页面仍显示其自身的版本。 + entry.source = entry.source.replace('', `\n `) const source = readFileSync(new URL('./src/service-worker.js', import.meta.url), 'utf8') - .replace('__VERSION__', version.digest('hex').slice(0, 16)) + .replace('__VERSION__', buildVersion) .replace('__PRECACHE__', JSON.stringify(files.map((name) => '/' + name))) this.emitFile({ type: 'asset', fileName: 'sw.js', source }) },