Windows 上的安卓应用运行器:双击 APK 即装,应用以独立窗口与桌面图标运行,自持 QEMU 运行时
feat(ui): 启动欢迎卡、旧版本残留清理、更新兜底与整体美化
RoutineMiku6593375fce0f
diff --git a/.github/release-notes-v0.3.8.md b/.github/release-notes-v0.3.8.mdnew file mode 100644index 0000000..bfbf151--- /dev/null+++ b/.github/release-notes-v0.3.8.md@@ -0,0 +1,62 @@+# ApkStart v0.3.8++> 一句话:加了一张**好看的启动欢迎卡**(开机自启时提醒你一切就绪),修好了**部分用户检查不到更新**,新增**清理旧版本残留**,并把界面整体美化了一轮。++## 一、新增:启动欢迎卡++开机自启或打开 ApkStart 时,弹一张轻量的欢迎卡:++- 顶部是品牌渐变头图 + 动态问候(早上好 / 下午好 / 夜深了…);+- 三个指标一目了然:**已装应用 / 安卓运行时状态 / 设备端口**;+- 有两条当下最有用的提示(没装应用时教怎么装;装了应用时教窗口操作);+- 发现新版本时,会在这里直接提示,不再另外弹右下角气泡;+- 底部可以勾 **「下次启动不再自动弹出」**,也可以直接「打开设置」。++弹出规则:开机自启必弹;手动打开则每天最多一次;勾选后永久不弹。++## 二、修复:部分用户检查不到更新++**原因**:版本信息依赖两家的 API。GitHub 匿名 API 每 IP 每小时只有 60 次;Gitee 的匿名 API 更紧,实测连续几次就返回 `403 Rate Limit Exceeded`。公司网 / 校园网 / 运营商 NAT 出口下用户很容易两个源都被限流,界面就只会显示「检查更新失败」。++**修复**:++- 新增**不依赖 API 的兜底**:直接跟随 `releases/latest` 的 302 跳转拿版本号(走 CDN,不消耗 API 额度),再按发布约定拼出下载地址;+- GitHub 和 Gitee 的 `/releases/download/<tag>/<文件名>` 规范地址都支持拼装(实测 Gitee 会 302 到附件直链,能下到完整字节);+- 检查失败时,界面不再是一片空白,而是给一个 **「打开下载页」** 按钮;`app:updateOpen` 现在也放行 `gitee.com`,国内用户不会被挡。++## 三、新增:清理旧版本残留++设置 → 系统集成 → **「清理旧版本残留」**:++- 扫描**旧版本程序目录**(同目录下的 `ApkStart-vX.Y.Z-win64-portable` 等,且必须真的含 `ApkStart.exe`,绝不碰当前正在运行的版本);+- 扫描**已失效的注册表卸载项**(`InstallLocation` 或卸载程序已经不存在的死条目);+- 扫描**更新下载留下的临时包**(`%APPDATA%\apkstart\update` 与临时目录里的 `ApkStart-*.zip` 等);+- 先列出清单和可释放空间,确认后再删,并如实报告「几项被占用没删掉」。++只做可证明安全的清理,**不动用户数据、不动当前版本**。++## 四、隐藏启动时的零碎小弹窗++- 启动时的「发现新版本」系统通知已取消,统一收进欢迎卡;+- 之前的启动提示分散在多个 toast / 气泡里,现在只有这一张卡片;+- 控制台黑窗压制逻辑保持(模拟器 / netsimd / adb 的控制台窗口仍会被隐藏)。++## 五、界面美化++- 全新配色:翡翠绿品牌色 + 柔和中性底,背景带一层很淡的品牌光晕;+- 标题栏改为**磨砂玻璃**质感,窗口图标换成矢量品牌标记(小尺寸下也认得出是"播放键",不再是糊成一团的深色方块);+- 应用卡片:更大圆角、悬停上浮 + 品牌色描边、图标带投影;+- 按钮:主按钮渐变 + 内高光,次级按钮更轻;+- 模态框、分组标题、滚动条、状态栏统一重做;+- 欢迎卡是同一套设计语言(渐变头图 + 光晕 + 点阵纹理)。++## 六、实测++- `npm test`:**113 项全部通过**(8 + 25 + 80)。+- 冒烟截图验证:主界面与欢迎卡均正常渲染(见发布页截图)。+- 「清理旧版本残留」在开发机上扫出 6 个旧版本目录、约 1.3 GB,当前运行版本被正确排除。++## 七、升级方式++- 便携版:解压覆盖,数据目录(默认 `%APPDATA%\apkstart`)保持不变。+- 安装版:直接安装覆盖。diff --git a/package.json b/package.jsonindex a6c052c..f64bd67 100644--- a/package.json+++ b/package.json@@ -1,7 +1,7 @@{"name": "apkstart","productName": "ApkStart",- "version": "0.3.7",+ "version": "0.3.8","description": "极致轻量的 Windows 安卓应用运行器:双击 APK 即装,应用以独立窗口与桌面图标运行","main": "src/main.js","author": "RoutineMiku",diff --git a/src/core/leftovers.js b/src/core/leftovers.jsnew file mode 100644index 0000000..2a0ace3--- /dev/null+++ b/src/core/leftovers.js@@ -0,0 +1,189 @@+'use strict';+/**+ * 清理旧版本残留。+ *+ * 用户升级 ApkStart 常出现「装过好几个版本、卸载不干净」:便携版每换一次版本就多一个+ * ApkStart-vX.Y.Z-win64-portable 目录;NSIS 安装版升级后可能留下指向已删除目录的+ * 卸载项;更新过程还会在数据目录里留下一堆临时包。+ *+ * 这里只做**可证明安全**的清理:+ * - 只认「目录里确实有 ApkStart.exe」的旧版本目录,且绝不碰当前正在运行的那个;+ * - 只删除「InstallLocation 已经不存在」的注册表卸载项(那个本来就已经是死条目);+ * - 只删自己更新缓存里的临时文件与指向不存在目标的开始菜单/桌面快捷方式。+ * 任何一步拿不准就跳过,并把原因如实返回给界面。+ */+const fs = require('fs');+const path = require('path');+const os = require('os');+const { execFileSync } = require('child_process');++const EXE = 'ApkStart.exe';++function dirSize(p) {+ let n = 0;+ const walk = (d) => {+ let list = [];+ try { list = fs.readdirSync(d, { withFileTypes: true }); } catch (_) { return; }+ for (const e of list) {+ const f = path.join(d, e.name);+ try {+ if (e.isDirectory()) walk(f);+ else n += fs.statSync(f).size;+ } catch (_) { /* 占用/无权限,跳过 */ }+ }+ };+ walk(p);+ return n;+}++function norm(p) {+ try { return path.resolve(p).toLowerCase(); } catch (_) { return String(p).toLowerCase(); }+}++/** 在若干「可能放程序的」目录里找旧版本目录 */+function candidateRoots(installDir) {+ const roots = new Set();+ const parent = path.dirname(installDir);+ if (parent) roots.add(parent);+ const local = process.env.LOCALAPPDATA;+ if (local) roots.add(path.join(local, 'Programs'));+ const pf = process.env.ProgramFiles;+ if (pf) roots.add(pf);+ return [...roots];+}++/** 旧版本程序目录:形如 ApkStart*,且里面有 ApkStart.exe,且不是当前安装目录 */+function scanDirs(installDir) {+ const out = [];+ const cur = norm(installDir);+ for (const root of candidateRoots(installDir)) {+ let list = [];+ try { list = fs.readdirSync(root, { withFileTypes: true }); } catch (_) { continue; }+ for (const e of list) {+ if (!e.isDirectory()) continue;+ if (!/^ApkStart/i.test(e.name)) continue;+ const full = path.join(root, e.name);+ if (norm(full) === cur) continue;+ // 必须是「真的是 ApkStart」的目录,避免误删同名文件夹+ if (!fs.existsSync(path.join(full, EXE))) continue;+ out.push({+ kind: 'dir',+ path: full,+ size: dirSize(full),+ note: '旧版本程序目录(含 ' + EXE + ')',+ });+ }+ }+ return out;+}++/** 注册表里指向已不存在目录的卸载项 */+function scanRegistry() {+ const out = [];+ const roots = [+ 'HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall',+ 'HKLM\\Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall',+ 'HKLM\\Software\\WOW6432Node\\Microsoft\\Windows\\CurrentVersion\\Uninstall',+ ];+ for (const root of roots) {+ let text = '';+ try {+ text = execFileSync('reg', ['query', root, '/s', '/f', 'ApkStart', '/t', 'REG_SZ'],+ { encoding: 'utf8', windowsHide: true, timeout: 15000, maxBuffer: 4 * 1024 * 1024 });+ } catch (_) { continue; }+ // reg query 输出是分块的「键 → 值」,这里按块切+ const blocks = String(text).split(/\r?\n\r?\n/);+ for (const b of blocks) {+ const key = (/^(HKEY_[^\r\n]+)$/m.exec(b) || [])[1];+ if (!key) continue;+ if (!/\\ApkStart/i.test(key)) continue;+ const loc = (/InstallLocation\s+REG_\w+\s+(.+)/i.exec(b) || [])[1];+ const disp = (/DisplayName\s+REG_\w+\s+(.+)/i.exec(b) || [])[1];+ const unins = (/UninstallString\s+REG_\w+\s+(.+)/i.exec(b) || [])[1];+ const install = (loc || '').trim().replace(/^"|"$/g, '');+ const uninsPath = (unins || '').trim().replace(/^"|"$/g, '');+ const installMissing = install ? !fs.existsSync(install) : false;+ // 只处理「明明已经没装、却还挂在应用列表里」的死条目+ const deadUninstaller = uninsPath && !fs.existsSync(uninsPath.split('"')[0]);+ if (!installMissing && !deadUninstaller) continue;+ out.push({+ kind: 'registry',+ path: key,+ size: 0,+ note: `失效的卸载项${disp ? `:${String(disp).trim()}` : ''}`,+ });+ }+ }+ return out;+}++/** 更新缓存 / 临时包 */+function scanTemp(dataDir) {+ const out = [];+ const dirs = [path.join(dataDir, 'update'), os.tmpdir()];+ for (const d of dirs) {+ let list = [];+ try { list = fs.readdirSync(d, { withFileTypes: true }); } catch (_) { continue; }+ for (const e of list) {+ const name = e.name;+ const isOurs = /^ApkStart.*\.(zip|exe|part\d*|tmp)$/i.test(name)+ || /^ApkStart-.*\.part\d+$/i.test(name);+ if (!isOurs) continue;+ const full = path.join(d, name);+ let size = 0;+ try { size = e.isDirectory() ? dirSize(full) : fs.statSync(full).size; } catch (_) { /* ignore */ }+ out.push({ kind: 'temp', path: full, size, note: '更新下载的临时文件' });+ }+ }+ return out;+}++function scan({ installDir, dataDir }) {+ const items = [];+ const push = (list) => { for (const x of list) items.push(x); };+ push(scanDirs(installDir));+ push(scanRegistry());+ push(scanTemp(dataDir));+ const total = items.reduce((n, x) => n + (x.size || 0), 0);+ return { items, totalBytes: total };+}++function rm(p) {+ try {+ fs.rmSync(p, { recursive: true, force: true });+ return true;+ } catch (_) { return false; }+}++function clean(items, { installDir }) {+ const cur = norm(installDir);+ let freed = 0;+ const removed = [];+ const failed = [];+ for (const it of items || []) {+ try {+ if (it.kind === 'dir') {+ // 双保险:绝不删当前正在运行的目录+ if (norm(it.path) === cur) { failed.push({ path: it.path, reason: '这是当前正在运行的版本' }); continue; }+ if (!fs.existsSync(path.join(it.path, EXE))) { failed.push({ path: it.path, reason: '目录里没有 ' + EXE }); continue; }+ if (rm(it.path)) { freed += it.size || 0; removed.push(it.path); }+ else failed.push({ path: it.path, reason: '文件被占用(可能有窗口还开着)' });+ } else if (it.kind === 'registry') {+ const r = execFileSync('reg', ['delete', it.path, '/f'], { windowsHide: true, timeout: 10000 });+ void r;+ removed.push(it.path);+ } else if (it.kind === 'temp') {+ if (rm(it.path)) { freed += it.size || 0; removed.push(it.path); }+ else failed.push({ path: it.path, reason: '文件被占用' });+ } else if (it.kind === 'shortcut') {+ if (rm(it.path)) removed.push(it.path);+ else failed.push({ path: it.path, reason: '删除失败' });+ }+ } catch (e) {+ failed.push({ path: it.path, reason: e.message });+ }+ }+ return { removed, failed, freedBytes: freed };+}++module.exports = { scan, clean };diff --git a/src/core/sources.js b/src/core/sources.jsindex 8cb35c4..82b0b9a 100644--- a/src/core/sources.js+++ b/src/core/sources.js@@ -51,7 +51,7 @@ const KNOWN_MIRRORS = [*/const SAMPLE_BYTES = 256 * 1024;-function openUrl(url, { timeout = 10000, headers = {}, redirects = 0 } = {}) {+function openUrl(url, { timeout = 10000, headers = {}, redirects = 0, followRedirect = true } = {}) {return new Promise((resolve, reject) => {if (redirects > 6) return reject(new Error('重定向次数过多'));let u;@@ -66,10 +66,10 @@ function openUrl(url, { timeout = 10000, headers = {}, redirects = 0 } = {}) {...headers,},}, (res) => {- if ([301, 302, 303, 307, 308].includes(res.statusCode) && res.headers.location) {+ if ([301, 302, 303, 307, 308].includes(res.statusCode) && res.headers.location && followRedirect) {res.resume();const next = new URL(res.headers.location, url).href;- openUrl(next, { timeout, headers, redirects: redirects + 1 }).then(resolve, reject);+ openUrl(next, { timeout, headers, redirects: redirects + 1, followRedirect }).then(resolve, reject);return;}resolve(res);@@ -234,6 +234,56 @@ class Sources {}/** 各源的最新 release(并发,任何一个失败都不影响另一个) */+ /**+ * 不依赖 API 的兜底:直接跟随 `/releases/latest` 的 302 拿到 tag。+ *+ * 为什么必须有这一条:GitHub 的匿名 API 每个 IP 每小时只有 60 次,+ * Gitee 的匿名 API 更紧(实测连点几次就 403 Rate Limit Exceeded)。+ * 公司/校园网、运营商 NAT 出口下,用户很容易「检查更新失败」——+ * 而 `releases/latest` 这个网页跳转是走 CDN 的,不消耗 API 额度。+ *+ * 拿到 tag 之后资产名可以按发布约定拼出来:+ * ApkStart-<tag>-win64-portable.zip / ApkStart-<version>-Setup.exe / ApkStart-runtime-<tag>.zip+ */+ async _releaseTagViaRedirect(id) {+ const s = SOURCES[id];+ const page = `${s.web}/releases/latest`;+ const res = await openUrl(page, { timeout: 9000, followRedirect: false });+ const loc = String(res.headers.location || '');+ try { res.resume(); } catch (_) { /* ignore */ }+ const m = /\/releases\/tag\/([^/?#]+)/i.exec(loc);+ return m ? decodeURIComponent(m[1]) : '';+ }++ /** 用 tag 拼一份「最小可用」的 release(没有 API 时用) */+ _syntheticRelease(id, tag) {+ const s = SOURCES[id];+ const ver = String(tag).replace(/^v/i, '');+ const names = [+ `ApkStart-${tag}-win64-portable.zip`,+ `ApkStart-${ver}-Setup.exe`,+ `ApkStart-runtime-${tag}.zip`,+ ];+ // GitHub 和 Gitee 都支持 /releases/download/<tag>/<文件名> 这种规范地址+ // (实测 Gitee 会 302 到 foruda.gitee.com 的附件地址,能正常下到完整字节),+ // 所以没有 API 时也能拼出可用的下载地址。Gitee 上没有的资产会 404,+ // 后面的测速排序会自动跳过它。+ const assets = names.map((n) => ({+ name: n,+ size: 0,+ browser_download_url: `${s.web}/releases/download/${tag}/${n}`,+ }));+ return {+ tag_name: tag,+ name: tag,+ body: '',+ html_url: `${s.web}/releases/tag/${tag}`,+ published_at: '',+ assets,+ synthetic: true,+ };+ }+async fetchReleases() {const prefs = String((this.settings().runtime || {}).sourcePreference || 'auto');const ids = prefs === 'github' || prefs === 'gitee' ? [prefs] : ['github', 'gitee'];@@ -258,7 +308,14 @@ class Sources {const list = await getJson(withToken(id, `${s.api}/releases?per_page=10`), 9000);const first = (Array.isArray(list) ? list : []).find((r) => r && !r.draft);if (first) return { source: id, name: s.name, web: s.web, rel: first };- } catch (_) { /* 这个源彻底不可用 */ }+ } catch (_) { /* 继续尝试不依赖 API 的兜底 */ }+ // API 被限流/被墙时的兜底:网页跳转拿 tag,资产名按约定拼+ try {+ const tag = await this._releaseTagViaRedirect(id);+ if (tag) {+ return { source: id, name: s.name, web: s.web, rel: this._syntheticRelease(id, tag), degraded: true };+ }+ } catch (_) { /* 兜底也不行 */ }const limited = /\b(403|429)\b/.test(e.message);if (limited) this._blocked.set(id, Date.now() + this._blockMs);const hint = limiteddiff --git a/src/core/store.js b/src/core/store.jsindex cdc220b..175b176 100644--- a/src/core/store.js+++ b/src/core/store.js@@ -107,6 +107,9 @@ const DEFAULT_SETTINGS = {notifyOnInstall: true,autoStart: true, // 开机自启,默认开启,用户无需设置autoDeploy: true, // 首次运行自动完成全部部署,不再分 1~5 步+ // 启动欢迎卡:lastDate 记录上次自动弹出的日期(手动打开时一天最多一次),+ // disabled = 用户勾了「不再自动弹出」。+ welcome: { lastDate: '', disabled: false },display: {mode: 'window', // window(竖屏窗口,可自由拉伸) | fullscreen(自动适配屏幕)portrait: '900x1600', // 窗口模式的竖屏分辨率,可在设置里调大小diff --git a/src/main.js b/src/main.jsindex 9ae1cab..67862cc 100644--- a/src/main.js+++ b/src/main.js@@ -36,6 +36,7 @@ const { AppWindow, TITLEBAR_H } = require('./core/appwin');const { NotifyBridge } = require('./core/notify');const { AndroidSettings } = require('./core/android');const { Updater } = require('./core/updater');+const leftovers = require('./core/leftovers');// Windows 下窗口被遮挡时 capturePage 会拿到旧帧,自动化截图需要禁用遮挡计算app.commandLine.appendSwitch('disable-features', 'CalculateNativeWinOcclusion');@@ -711,8 +712,7 @@ function startNotifier() {// ---------------- IPC ----------------function registerIpc() {- ipcMain.handle('app:info', () => ({- version: app.getVersion(),+ ipcMain.handle('app:info', () => ({ version: app.getVersion(),isDev: IS_DEV,dataDir: store.DATA_DIR,runtimeDir: runtime.provisioner.paths().root,@@ -723,6 +723,18 @@ function registerIpc() {packaged: app.isPackaged,}));+ // 启动方式(开机自启 / 双击打开):欢迎卡据此决定是否自动弹出+ ipcMain.handle('app:startupInfo', () => {+ const a = parseArgs(process.argv);+ return {+ autostart: process.argv.includes('--autostart') || !!a.silent,+ launch: a.launch || null,+ smoke: process.argv.includes('--smoke'),+ version: app.getVersion(),+ isPackaged: app.isPackaged,+ };+ });+// 选文件夹(用于把运行时/镜像/已装应用挪到非系统盘)ipcMain.handle('dialog:openDir', async (_e, defaultPath) => {const r = await dialog.showOpenDialog(mainWindow, {@@ -1124,6 +1136,30 @@ function registerIpc() {}});+ // ---------------- 旧版本残留 ----------------++ /** 只扫描、不删除:先把「能找到什么」原样给界面,由用户决定 */+ ipcMain.handle('leftovers:scan', () => {+ try {+ const installDir = path.dirname(app.getPath('exe'));+ const dataDir = store.DATA_DIR;+ return { ok: true, ...leftovers.scan({ installDir, dataDir }) };+ } catch (e) {+ return { ok: false, error: e.message };+ }+ });++ ipcMain.handle('leftovers:clean', (_e, items) => {+ try {+ const installDir = path.dirname(app.getPath('exe'));+ const r = leftovers.clean(Array.isArray(items) ? items : [], { installDir });+ appLog(`leftovers cleaned: ${r.removed.length} removed, ${r.failed.length} failed`);+ return { ok: true, ...r, freedMB: Math.round(r.freedBytes / 1048576) };+ } catch (e) {+ return { ok: false, error: e.message };+ }+ });+// ---------------- 运行时自举 ----------------ipcMain.handle('provision:installEmulator', async () => {@@ -1512,9 +1548,13 @@ function registerIpc() {});ipcMain.handle('app:updateOpen', (_e, url) => {- const target = /^https:\/\/github\.com\//i.test(String(url || '')) ? url : Updater.repoUrl();+ // GitHub 和 Gitee 的发布页都允许直接打开:检查更新失败时界面就是靠这个+ // 让用户手动去下载,只放行 github.com 会把国内用户挡在门外。+ const raw = String(url || '');+ const ok = /^https:\/\/(github\.com|gitee\.com)\//i.test(raw);+ const target = ok ? raw : Updater.repoUrl();shell.openExternal(target).catch(() => {});- return { ok: true };+ return { ok: true, target };});ipcMain.handle('app:updateApply', () => runUpdate());@@ -1728,7 +1768,8 @@ if (!gotLock) {send('update:state', info);if (info.hasUpdate) {appLog(`update available ${info.tag} (current v${app.getVersion()}, asset=${info.asset ? info.asset.name : 'none'})`);- notify('发现新版本', `ApkStart ${info.tag} 已发布,可在「设置 → 软件更新」里一键更新`);+ // 不再单独弹系统通知:启动时的提醒统一收到应用内的「欢迎卡」里,+ // 避免开机自启时又冒一个右下角气泡(用户反馈的「小弹窗」之一)。}}).catch((e) => appLog(`update check failed: ${e.message}`));}, 8000).unref?.();diff --git a/src/preload.js b/src/preload.jsindex 1d962b2..a41cc68 100644--- a/src/preload.js+++ b/src/preload.js@@ -38,6 +38,9 @@ contextBridge.exposeInMainWorld('apkstart', {runtimeResetData: () => invoke('runtime:resetData'),runtimeRepairNetwork: () => invoke('runtime:repairNetwork'),runtimeCheckNetwork: () => invoke('runtime:checkNetwork'),+ leftoversScan: () => invoke('leftovers:scan'),+ leftoversClean: (items) => invoke('leftovers:clean', items),+ startupInfo: () => invoke('app:startupInfo'),dataInfo: () => invoke('runtime:dataInfo'),setDataSize: (gb) => invoke('runtime:setDataSize', gb),confirm: (opts) => invoke('app:confirm', opts || {}),diff --git a/src/ui/app.js b/src/ui/app.jsindex 0d992db..143112f 100644--- a/src/ui/app.js+++ b/src/ui/app.js@@ -806,7 +806,12 @@ function renderUpdate(info) {if (info.ok === false) {st.textContent = `检查失败:${info.error || '网络不可用'}`;- showUpdateBtn(false);+ // 检查失败也要给一条出路:直接把发布页打开,用户至少能手动下载。+ // 以前这里是「什么都不显示」,用户只会觉得「更新功能坏了」。+ showUpdateBtn(true);+ btn.textContent = '打开下载页';+ btn.dataset.mode = 'manual';+ lastUpdate = { htmlUrl: info.htmlUrl || '' };if (bar) bar.hidden = true;return;}@@ -1183,6 +1188,55 @@ function bindSettings() {}});+ // 清理旧版本残留:扫描旧程序目录 / 失效卸载项 / 更新临时文件,确认后一次性清掉。+ $('btnLeftovers').addEventListener('click', async () => {+ const btn = $('btnLeftovers');+ btn.disabled = true;+ try {+ const r = await api.leftoversScan();+ if (!r || !r.ok) {+ toast({ title: '扫描失败', body: (r && r.error) || '请重试', type: 'error' });+ return;+ }+ const items = r.items || [];+ if (!items.length) {+ toast({ title: '很干净', body: '没有发现旧版本残留。', type: 'ok' });+ return;+ }+ const mb = Math.round((r.totalBytes || 0) / 1048576);+ const lines = items.slice(0, 8).map((x) => `• ${x.note}:${x.path}`);+ if (items.length > 8) lines.push(`…另有 ${items.length - 8} 项`);+ const ok = await api.confirm({+ type: 'warning',+ title: '清理旧版本残留?',+ message: `找到 ${items.length} 项残留,约 ${mb} MB:`,+ detail: `${lines.join('\n')}\n\n只删除「旧版本程序目录 / 已失效的卸载项 / 更新临时文件」,`+ + '当前正在运行的版本和你的应用数据都不会动。',+ buttons: ['取消', '开始清理'],+ defaultId: 1,+ cancelId: 0,+ });+ if (!ok || ok.response !== 1) return;+ const c = await api.leftoversClean(items);+ if (!c || !c.ok) {+ toast({ title: '清理失败', body: (c && c.error) || '请重试', type: 'error' });+ return;+ }+ const failNote = (c.failed && c.failed.length) ? `,${c.failed.length} 项被占用未删` : '';+ toast({+ title: '已清理旧版本残留',+ body: `删除 ${c.removed.length} 项,释放 ${c.freedMB || 0} MB${failNote}。`,+ type: 'ok',+ });+ const u = await api.runtimeUsage();+ $('usageText').textContent = `共 ${u.totalText} · 可回收 ${u.reclaimableText}(${u.count} 项)`;+ } catch (e) {+ toast({ title: '清理失败', body: e.message, type: 'error' });+ } finally {+ btn.disabled = false;+ }+ });+$('btnOpenShared').addEventListener('click', () => api.openSharedDir());// 重建快捷方式:桌面图标被误删 / 被安全软件拦掉时的兜底入口@@ -1554,7 +1608,13 @@ function bindEvents() {if (v === 'setup') { showSetup(true); refreshStatus(); }});api.on('provision:progress', (p) => updateStepProgress(p.component, p));- api.on('update:state', (info) => { if (info) renderUpdate(info); });+ api.on('update:state', (info) => {+ if (!info) return;+ renderUpdate(info);+ // 启动 8 秒后才拿到更新信息:欢迎卡若还开着,把「发现新版本」这条补进去+ const wm = $('welcomeMask');+ if (wm && !wm.hidden) renderWelcomeTips();+ });api.on('update:progress', (p) => renderUpdateProgress(p));}@@ -1565,16 +1625,100 @@ async function init() {bindSettings();bindUpdate();bindAndroid();+ bindWelcome();state.settings = await api.getSettings();await refreshStatus();await refreshApps();refreshAndroid();selfCheck();+ maybeShowWelcome();setInterval(refreshStatus, 6000);setInterval(refreshApps, 15000);setInterval(selfCheck, 60000);}+/* ---------------- 启动欢迎卡 ---------------- */++let startupInfo = null;++function greetingOf(h) {+ if (h < 5) return '夜深了';+ if (h < 11) return '早上好';+ if (h < 13) return '中午好';+ if (h < 18) return '下午好';+ return '晚上好';+}++function bindWelcome() {+ const mask = $('welcomeMask');+ if (!mask) return;+ const close = () => { mask.hidden = true; };+ const never = $('welcomeNever');+ $('welcomeOk').addEventListener('click', () => {+ if (never && never.checked) api.setSettings({ welcome: { disabled: true } }).catch(() => {});+ close();+ });+ $('welcomeSettings').addEventListener('click', () => { close(); openSettings(); });+ mask.addEventListener('click', (e) => { if (e.target === mask) close(); });+ window.addEventListener('keydown', (e) => { if (e.key === 'Escape' && !mask.hidden) close(); });+}++/** 决定要不要弹:开机自启必弹;手动打开则每天最多一次,且用户可永久关闭 */+async function maybeShowWelcome() {+ const mask = $('welcomeMask');+ if (!mask) return;+ // 冒烟截图时不要弹欢迎卡:否则每次自动截图都被它挡住主界面+ try { if ((await api.startupInfo()).smoke) return; } catch (_) { /* ignore */ }+ try { startupInfo = await api.startupInfo(); } catch (_) { startupInfo = null; }+ const cfg = (state.settings && state.settings.welcome) || {};+ if (cfg.disabled) return;+ const today = new Date().toISOString().slice(0, 10);+ if (!(startupInfo && startupInfo.autostart) && cfg.lastDate === today) return;++ const h = new Date().getHours();+ $('welcomeHi').textContent = `${greetingOf(h)},欢迎回来`;+ const ver = (startupInfo && startupInfo.version) || (state.status && state.status.version) || '';+ const ready = state.status && state.status.ready;+ $('welcomeSub').textContent = `ApkStart${ver ? ` v${ver}` : ''} · ${ready ? '运行时就绪,点开即用' : '运行时会按需自动准备'}`;++ const apps = (state.apps || []).length;+ const dev = $('statusDevice') ? $('statusDevice').textContent.trim() : '';+ const chips = [+ { k: String(apps), v: '已装应用' },+ { k: ready ? '就绪' : '待命', v: '安卓运行时' },+ { k: dev ? dev.replace(/^.*?(\d+)/, '$1') : '—', v: '设备 / 端口' },+ ];+ $('welcomeStats').innerHTML = chips+ .map((c) => `<div class="welcome-stat"><b>${esc(c.k)}</b><span>${esc(c.v)}</span></div>`)+ .join('');++ const tips = [];+ $('welcomeTips').innerHTML = '';+ mask.hidden = false;+ renderWelcomeTips();+ api.setSettings({ welcome: { lastDate: today } }).catch(() => {});+}++/** 提示区单独渲染:启动 8 秒后才拿到更新信息,那时卡片可能还开着,需要补一次 */+function renderWelcomeTips() {+ const box = $('welcomeTips');+ if (!box) return;+ const apps = (state.apps || []).length;+ const tips = [];+ if (lastUpdate && lastUpdate.hasUpdate) {+ tips.push(`发现新版本 <b>${esc(lastUpdate.tag || '')}</b>,可在「设置 → 软件更新」一键更新`);+ }+ if (!apps) {+ tips.push('把 APK 拖进窗口就能安装,装完会自动生成桌面图标');+ } else {+ tips.push('双击应用卡片即可在独立窗口中运行,右上角可旋转 / 缩放 / 关闭');+ }+ tips.push('关窗口只是退出那个应用,安卓环境会留着,下次点开更快');+ box.innerHTML = tips+ .map((t, i) => `<div class="welcome-tip"><i>${i + 1}</i><span>${t}</span></div>`)+ .join('');+}+/* ---------------- 环境自检 ---------------- */let envBusy = false;diff --git a/src/ui/index.html b/src/ui/index.htmlindex fca860f..78845ca 100644--- a/src/ui/index.html+++ b/src/ui/index.html@@ -5,13 +5,30 @@<meta http-equiv="Content-Security-Policy" content="default-src 'self'; img-src 'self' file: data:; style-src 'self' 'unsafe-inline'; script-src 'self'" /><title>ApkStart</title><link rel="stylesheet" href="style.css" />+<link rel="stylesheet" href="theme.css" /></head><body>+<!-- 品牌标记:小尺寸下也要认得出来,所以用矢量而不是 1024 的位图缩到 22px -->+<svg width="0" height="0" style="position:absolute" aria-hidden="true">+ <defs>+ <linearGradient id="brandGrad" x1="0" y1="0" x2="1" y2="1">+ <stop offset="0" stop-color="#2ee6a6"/>+ <stop offset="55%" stop-color="#12b886"/>+ <stop offset="100%" stop-color="#0a6f47"/>+ </linearGradient>+ </defs>+ <symbol id="brandMark" viewBox="0 0 48 48">+ <rect x="1.5" y="1.5" width="45" height="45" rx="13.5" fill="url(#brandGrad)"/>+ <rect x="1.5" y="1.5" width="45" height="45" rx="13.5" fill="none" stroke="rgba(255,255,255,.34)" stroke-width="1.4"/>+ <path d="M18.5 14.5 35 24 18.5 33.5z" fill="#fff"/>+ </symbol>+</svg>+<header class="titlebar"><div class="brand"><div class="logo" aria-hidden="true">- <img src="assets/logo.png" alt="" draggable="false" />+ <svg viewBox="0 0 48 48" width="22" height="22"><use href="#brandMark"/></svg></div><span class="brand-name">ApkStart</span><span class="brand-tag" id="engineTag">未连接运行时</span>@@ -74,6 +91,30 @@</footer></main>+<!-- 启动欢迎卡:替代原来散落的各种启动小提示 -->+<div class="modal-mask welcome-mask" id="welcomeMask" hidden>+ <div class="welcome" role="dialog" aria-modal="true" aria-labelledby="welcomeHi">+ <div class="welcome-hero">+ <div class="welcome-halo"></div>+ <div class="welcome-badge"><svg viewBox="0 0 48 48" width="44" height="44" aria-hidden="true"><use href="#brandMark"/></svg></div>+ <div class="welcome-hi" id="welcomeHi">你好</div>+ <div class="welcome-sub" id="welcomeSub">ApkStart 已就绪</div>+ </div>+ <div class="welcome-body">+ <div class="welcome-stats" id="welcomeStats"></div>+ <div class="welcome-tips" id="welcomeTips"></div>+ <label class="welcome-opt">+ <input type="checkbox" id="welcomeNever" />+ <span>下次启动不再自动弹出</span>+ </label>+ </div>+ <div class="welcome-actions">+ <button class="btn ghost" id="welcomeSettings">打开设置</button>+ <button class="btn primary" id="welcomeOk">开始使用</button>+ </div>+ </div>+</div>+<!-- 安装进度 --><div class="toast-wrap" id="toastWrap"></div>@@ -149,6 +190,7 @@<div class="row"><span class="inline-note" id="usageText">正在统计…</span><button class="btn ghost sm" id="btnCleanup">清理可回收文件</button>+ <button class="btn ghost sm" id="btnLeftovers" title="扫描并清掉旧版本留下的程序目录、失效的卸载项和更新临时文件">清理旧版本残留</button><button class="btn ghost sm" id="btnRepairNetwork" title="安卓虚拟机没有网络时(应用里联网页面一直黑屏/转圈),用这个把安卓数据重置掉来修网络。应用清单会保留,点开应用会自动重装">修复网络</button><button class="btn ghost sm danger" id="btnResetData" title="清空安卓 /data 用户数据 + 已装应用 + 快速启动快照,还原成刚装好系统的干净状态">重置安卓数据</button></div>diff --git a/src/ui/theme.css b/src/ui/theme.cssnew file mode 100644index 0000000..068d764--- /dev/null+++ b/src/ui/theme.css@@ -0,0 +1,364 @@+/* ============================================================================+ * theme.css —— 全局视觉刷新(在 style.css 之后加载,只做覆盖与增强)+ *+ * 设计目标:更"安卓运行器"的气质 —— 深绿品牌色 + 干净的浅色面板 + 圆润的卡片,+ * 同时把启动时的欢迎卡做成一整套统一语言。+ * ========================================================================== */++:root {+ /* 品牌:翡翠绿 → 青绿渐变 */+ --brand: #0f9d63;+ --brand-dark: #0b7d4f;+ --brand-2: #12b886;+ --brand-soft: #e8f8f0;+ --brand-ink: #075c3a;++ --bg: #f4f7f5;+ --bg-2: #eef3f0;+ --panel: #ffffff;+ --panel-2: #fafcfb;+ --line: #e3e9e5;+ --line-strong: #cfd8d2;+ --text: #14201a;+ --text-2: #3d4a44;+ --muted: #6b7a72;+ --faint: #93a19a;+ --danger: #d92d20;++ --shadow-sm: 0 1px 2px rgba(14, 32, 24, .05);+ --shadow-md: 0 10px 26px rgba(14, 32, 24, .09);+ --shadow-lg: 0 24px 60px rgba(14, 32, 24, .16);++ --r-sm: 9px;+ --r-md: 14px;+ --r-lg: 20px;++ --ring: 0 0 0 3px rgba(15, 157, 99, .16);+}++html, body {+ background:+ radial-gradient(1200px 420px at 12% -12%, rgba(18, 184, 134, .10), transparent 62%),+ radial-gradient(900px 380px at 100% 0%, rgba(15, 157, 99, .07), transparent 58%),+ var(--bg);+}++/* ---------------- 标题栏:玻璃质感 ---------------- */++.titlebar {+ height: 46px;+ flex: 0 0 46px;+ background: linear-gradient(180deg, rgba(255, 255, 255, .82), rgba(255, 255, 255, .46));+ border-bottom: 1px solid rgba(20, 32, 26, .07);+ backdrop-filter: saturate(1.4) blur(14px);+}++.logo img,+.logo svg {+ width: 22px; height: 22px;+ border-radius: 7px;+ display: block;+ box-shadow: 0 2px 8px rgba(15, 157, 99, .28);+}++.brand-name {+ font-size: 14px;+ font-weight: 700;+ letter-spacing: .1px;+ background: linear-gradient(92deg, #14201a, #2b6a4d);+ -webkit-background-clip: text; background-clip: text; color: transparent;+}++.brand-tag {+ border: 1px solid rgba(15, 157, 99, .16);+ background: rgba(18, 184, 134, .09);+ color: var(--brand-ink);+ font-weight: 600;+ transition: background .15s ease, transform .15s ease;+}+.brand-tag:hover { background: rgba(18, 184, 134, .16); transform: translateY(-1px); }++.icon-btn {+ width: 32px; height: 32px;+ border-radius: 10px;+ transition: background .15s ease, color .15s ease, transform .12s ease;+}+.icon-btn:hover { background: rgba(20, 32, 26, .06); color: var(--text); }+.icon-btn:active { transform: scale(.95); }++/* ---------------- 搜索框 / 主按钮 ---------------- */++.search {+ border-radius: 12px;+ border: 1px solid var(--line);+ background: rgba(255, 255, 255, .9);+ box-shadow: var(--shadow-sm);+ transition: box-shadow .15s ease, border-color .15s ease, background .15s ease;+}+.search:focus-within {+ border-color: rgba(15, 157, 99, .45);+ box-shadow: var(--ring);+ background: #fff;+}++.btn {+ border-radius: 11px;+ border: 1px solid var(--line-strong);+ background: #fff;+ box-shadow: var(--shadow-sm);+ font-weight: 600;+ transition: transform .12s ease, box-shadow .15s ease, background .15s ease, border-color .15s ease;+}+.btn:hover { background: #fbfdfc; box-shadow: 0 2px 8px rgba(14, 32, 24, .08); }+.btn:active { transform: translateY(1px) scale(.995); }++.btn.primary {+ border: none;+ color: #fff;+ background: linear-gradient(180deg, var(--brand-2), var(--brand));+ box-shadow: 0 1px 0 rgba(255, 255, 255, .22) inset, 0 6px 16px rgba(15, 157, 99, .28);+}+.btn.primary:hover {+ background: linear-gradient(180deg, #16c68f, var(--brand-dark));+ box-shadow: 0 1px 0 rgba(255, 255, 255, .22) inset, 0 8px 22px rgba(15, 157, 99, .34);+}+.btn.primary:focus-visible { outline: none; box-shadow: var(--ring), 0 6px 16px rgba(15, 157, 99, .28); }++.btn.ghost { background: rgba(255, 255, 255, .6); }+.btn.ghost:hover { background: rgba(20, 32, 26, .05); }++/* ---------------- 应用卡片 ---------------- */++.grid { gap: 14px; }++.card {+ border-radius: var(--r-lg);+ border: 1px solid var(--line);+ background: linear-gradient(180deg, #fff, #fdfefe);+ box-shadow: var(--shadow-sm);+ transition: transform .16s cubic-bezier(.2, .7, .2, 1), box-shadow .18s ease, border-color .16s ease;+}+.card:hover {+ transform: translateY(-3px);+ border-color: rgba(15, 157, 99, .28);+ box-shadow: 0 14px 30px rgba(14, 32, 24, .12);+}+.card::after {+ content: '';+ position: absolute; inset: 0;+ border-radius: inherit;+ pointer-events: none;+ box-shadow: inset 0 1px 0 rgba(255, 255, 255, .8);+}++.card .icon {+ border-radius: 16px;+ box-shadow: 0 6px 16px rgba(14, 32, 24, .14), inset 0 1px 0 rgba(255, 255, 255, .35);+}++.card .badge-run {+ background: linear-gradient(180deg, var(--brand-2), var(--brand));+ box-shadow: 0 2px 8px rgba(15, 157, 99, .4);+}++/* ---------------- 状态栏 ---------------- */++.statusbar {+ border-top: 1px solid rgba(20, 32, 26, .06);+ background: linear-gradient(180deg, rgba(255, 255, 255, .5), rgba(255, 255, 255, .82));+ backdrop-filter: blur(10px);+}++.dot { box-shadow: 0 0 0 3px rgba(18, 184, 134, .14); }++/* ---------------- 模态框 ---------------- */++.modal-mask { backdrop-filter: blur(6px); background: rgba(12, 24, 19, .34); }++.modal {+ border-radius: 22px;+ border: 1px solid rgba(255, 255, 255, .6);+ box-shadow: var(--shadow-lg);+ overflow: hidden;+}++.modal-head {+ background: linear-gradient(180deg, #fff, #f7faf8);+ border-bottom: 1px solid var(--line);+}++.group-title {+ color: var(--brand-ink);+ letter-spacing: .3px;+}++/* ---------------- 滚动条 ---------------- */++::-webkit-scrollbar { width: 10px; height: 10px; }+::-webkit-scrollbar-thumb {+ background: rgba(20, 32, 26, .16);+ border: 3px solid transparent;+ border-radius: 999px;+ background-clip: content-box;+}+::-webkit-scrollbar-thumb:hover { background: rgba(20, 32, 26, .28); background-clip: content-box; }+::-webkit-scrollbar-track { background: transparent; }++/* ============================================================================+ * 启动欢迎卡+ * ========================================================================== */++.welcome-mask[hidden] { display: none; }++.welcome-mask {+ position: fixed; inset: 0; z-index: 90;+ display: grid; place-items: center;+ background: rgba(10, 22, 17, .38);+ backdrop-filter: blur(8px);+ animation: wl-fade .22s ease both;+}++.welcome {+ position: relative;+ width: 396px;+ max-width: calc(100vw - 48px);+ border-radius: 24px;+ overflow: hidden;+ background: #fff;+ border: 1px solid rgba(255, 255, 255, .7);+ box-shadow: 0 32px 80px rgba(8, 24, 18, .32);+ animation: wl-pop .28s cubic-bezier(.2, .8, .2, 1) both;+}++@keyframes wl-fade { from { opacity: 0; } to { opacity: 1; } }+@keyframes wl-pop {+ from { opacity: 0; transform: translateY(14px) scale(.97); }+ to { opacity: 1; transform: none; }+}++.welcome-hero {+ position: relative;+ padding: 30px 26px 24px;+ text-align: center;+ color: #eafff5;+ background:+ radial-gradient(120% 130% at 20% 0%, #16c68f 0%, #0f9d63 46%, #0a6f47 100%);+ overflow: hidden;+}++/* 光晕 */+.welcome-halo {+ position: absolute; left: 50%; top: -120px;+ width: 340px; height: 240px; transform: translateX(-50%);+ background: radial-gradient(closest-side, rgba(255, 255, 255, .45), rgba(255, 255, 255, 0) 72%);+ pointer-events: none;+}+.welcome-hero::after {+ content: '';+ position: absolute; inset: 0;+ background-image: radial-gradient(rgba(255, 255, 255, .16) 1px, transparent 1.2px);+ background-size: 22px 22px;+ opacity: .35;+ mask-image: radial-gradient(70% 70% at 50% 30%, #000 20%, transparent 76%);+ -webkit-mask-image: radial-gradient(70% 70% at 50% 30%, #000 20%, transparent 76%);+ pointer-events: none;+}++.welcome-badge {+ position: relative;+ width: 66px; height: 66px;+ margin: 0 auto 14px;+ border-radius: 20px;+ display: grid; place-items: center;+ background: rgba(255, 255, 255, .16);+ box-shadow: inset 0 1px 0 rgba(255, 255, 255, .4), 0 10px 24px rgba(3, 40, 26, .3);+ backdrop-filter: blur(6px);+}+.welcome-badge img,+.welcome-badge svg {+ width: 44px; height: 44px;+ border-radius: 13px;+ display: block;+ box-shadow: 0 6px 16px rgba(3, 40, 26, .35);+}++.welcome-hi {+ position: relative;+ font-size: 20px;+ font-weight: 750;+ letter-spacing: .2px;+ text-shadow: 0 1px 0 rgba(0, 0, 0, .12);+}++.welcome-sub {+ position: relative;+ margin-top: 6px;+ font-size: 12.5px;+ color: rgba(234, 255, 245, .82);+}++.welcome-body { padding: 18px 22px 6px; }++.welcome-stats {+ display: grid;+ grid-template-columns: repeat(3, 1fr);+ gap: 8px;+}+.welcome-stat {+ border: 1px solid var(--line);+ background: linear-gradient(180deg, #fbfdfc, #f5f9f7);+ border-radius: 14px;+ padding: 10px 8px;+ text-align: center;+}+.welcome-stat b {+ display: block;+ font-size: 16px;+ font-weight: 750;+ color: var(--brand-ink);+ line-height: 1.25;+}+.welcome-stat span {+ display: block;+ margin-top: 2px;+ font-size: 11px;+ color: var(--muted);+}++.welcome-tips { margin: 14px 0 4px; display: grid; gap: 8px; }+.welcome-tip {+ display: flex; align-items: flex-start; gap: 9px;+ font-size: 12.5px;+ color: var(--text-2);+ line-height: 1.55;+}+.welcome-tip i {+ flex: 0 0 auto;+ width: 18px; height: 18px;+ margin-top: 1px;+ border-radius: 6px;+ display: grid; place-items: center;+ background: var(--brand-soft);+ color: var(--brand-dark);+ font-style: normal;+ font-size: 11px;+ font-weight: 700;+}++.welcome-opt {+ margin-top: 12px;+ display: flex; align-items: center; gap: 8px;+ font-size: 12px;+ color: var(--muted);+ cursor: pointer;+ user-select: none;+}+.welcome-opt input { accent-color: var(--brand); width: 14px; height: 14px; }++.welcome-actions {+ display: flex;+ gap: 10px;+ padding: 14px 22px 20px;+}+.welcome-actions .btn { flex: 1; height: 40px; border-radius: 12px; font-size: 13.5px; }+.welcome-actions .btn.ghost { flex: 0 0 auto; padding: 0 16px; }