上下文感知读取光标附近的文本交给 AI,选中文字时改走单独的编辑指令 Prompt; 识别纠错在历史记录里回放并修正原文,提交前需用户确认、30 天内可撤回。 另有 AI 整理的托盘开关与快捷键、应用规则拖动排序、麦克风设备提示, 以及录音保留期与麦克风静音误报两处修复。
69 lines
2.3 KiB
TypeScript
69 lines
2.3 KiB
TypeScript
/// <reference types="vitest" />
|
||
import { defineConfig } from 'vite'
|
||
import react from '@vitejs/plugin-react'
|
||
import path from 'path'
|
||
import fs from 'fs'
|
||
|
||
const host = process.env.TAURI_DEV_HOST
|
||
const defaultServerUrl = process.env.SAYIT_DEFAULT_SERVER_URL || 'https://sayitapp.site'
|
||
|
||
// 从 tauri.conf.json 读取版本号
|
||
const tauriConf = JSON.parse(
|
||
fs.readFileSync(path.resolve(__dirname, 'src-tauri/tauri.conf.json'), 'utf-8')
|
||
)
|
||
// SAYIT_FAKE_APP_VERSION:只为「在真机上测自动更新」存在。
|
||
// 把前端自报的版本压低(如 0.1.5),线上 manifest 的 0.1.6 就成了"新版本",
|
||
// 整条链路(检查 → 下载 → SHA-512 校验 → 提醒图标 → 安装)都能真跑一遍,
|
||
// 不用先发一个假包上去。发版前必须测自更新(见 .kiro/steering/pitfalls.md #3),
|
||
// 而更新器的改动没法用自己验证自己,这个口子是那道验证的入口。
|
||
// 正式构建不会设这个变量;设了会打一行醒目的警告。
|
||
const fakeVersion = process.env.SAYIT_FAKE_APP_VERSION
|
||
if (fakeVersion) {
|
||
console.warn(`\n[vite] SAYIT_FAKE_APP_VERSION=${fakeVersion} — 应用会自报这个版本(真实版本 ${tauriConf.version})。仅用于测更新,别拿来打包。\n`)
|
||
}
|
||
const appVersion = fakeVersion || tauriConf.version || '0.0.0'
|
||
|
||
export default defineConfig({
|
||
define: {
|
||
__SAYIT_DEFAULT_SERVER_URL__: JSON.stringify(defaultServerUrl),
|
||
__APP_VERSION__: JSON.stringify(appVersion),
|
||
},
|
||
plugins: [react()],
|
||
resolve: {
|
||
alias: {
|
||
'@': path.resolve(__dirname, './src'),
|
||
},
|
||
},
|
||
// Vite options tailored for Tauri development
|
||
clearScreen: false,
|
||
server: {
|
||
port: 1420,
|
||
strictPort: true,
|
||
host: host || false,
|
||
hmr: host ? { protocol: 'ws', host, port: 1421 } : undefined,
|
||
watch: {
|
||
ignored: ['**/src-tauri/**'],
|
||
},
|
||
},
|
||
test: {
|
||
globals: true,
|
||
environment: 'node',
|
||
include: ['src/**/*.test.ts'],
|
||
},
|
||
build: {
|
||
// 生产构建移除 console.log 和 debugger(保留 console.warn/error)
|
||
minify: 'esbuild',
|
||
rollupOptions: {
|
||
input: {
|
||
main: path.resolve(__dirname, 'index.html'),
|
||
overlay: path.resolve(__dirname, 'overlay.html'),
|
||
trayMenu: path.resolve(__dirname, 'tray-menu.html'),
|
||
},
|
||
},
|
||
},
|
||
esbuild: {
|
||
drop: ['debugger'],
|
||
pure: ['console.log'],
|
||
},
|
||
})
|