diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 6930def..e2aa696 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -116,7 +116,7 @@ jobs: run: | sudo apt-get update sudo apt-get install -y --no-install-recommends \ - fakeroot dpkg rpm libarchive-tools + fakeroot dpkg rpm libarchive-tools zsync squashfs-tools p7zip-full # Packaging consumes dist/, so it must exist before electron-builder runs. - name: Build app bundle @@ -150,6 +150,72 @@ jobs: # certificate never silently changes the output. CSC_IDENTITY_AUTO_DISCOVERY: 'false' + # electron-builder's AppImage writer does not embed update info and does + # not emit a zsync file, which AppImageHub/AppImageUpdate require. Rebuild + # the AppImage with appimagetool so both are present next to the asset. + - name: Add AppImage update information + if: matrix.platform == 'linux' + run: | + set -euo pipefail + APPIMAGE="$(find release -maxdepth 1 -name '*.AppImage' -print -quit)" + if [ -z "$APPIMAGE" ]; then + echo "::error::electron-builder produced no AppImage" + exit 1 + fi + NAME="$(basename "$APPIMAGE")" + case "${{ matrix.arch }}" in + x64) TARGET_ARCH=x86_64 ;; + arm64) TARGET_ARCH=aarch64 ;; + *) echo "::error::unsupported AppImage architecture"; exit 1 ;; + esac + # appimagetool is itself an AppImage, so run the build for the runner's + # architecture; ARCH selects the target runtime it embeds. + case "$(uname -m)" in + x86_64) TOOL_ARCH=x86_64 ;; + aarch64) TOOL_ARCH=aarch64 ;; + *) echo "::error::unsupported runner architecture"; exit 1 ;; + esac + # This is the suffix electron-builder put in the filename (x86_64 / + # arm64), not the runtime architecture appimagetool wants (x86_64 / + # aarch64); the update-information pattern must match the asset name. + BASE="${NAME%.AppImage}" + FILE_ARCH="${BASE##*-}" + + TOOL="/tmp/appimagetool-${TOOL_ARCH}.AppImage" + curl -fsSL -o "$TOOL" \ + "https://github.com/AppImage/appimagetool/releases/download/continuous/appimagetool-${TOOL_ARCH}.AppImage" + chmod +x "$TOOL" + + # Extract without executing the payload: the arm64 job runs on an x64 + # runner, so running the arm64 AppImage would fail with Exec format. + # `grep hsqs` also matches strings inside the runtime; use 7z, which + # reports the real SquashFS superblock offset. + OFFSET="$(7z l "$APPIMAGE" 2>/dev/null | sed -n 's/^Offset = //p' | head -n1)" || true + if [ -z "$OFFSET" ]; then + echo "::error::could not locate the SquashFS payload in $APPIMAGE" + exit 1 + fi + rm -rf release/squashfs-root + unsquashfs -o "$OFFSET" -d release/squashfs-root "$APPIMAGE" > /dev/null + # electron-builder's stage directory is 0700; appimagetool (rightly) + # refuses to ship an AppImage that other users cannot read. + chmod -R a+rX release/squashfs-root + chmod a+rx release/squashfs-root/AppRun + rm -f "$APPIMAGE" + REPO="${GITHUB_REPOSITORY}" + APPIMAGE_EXTRACT_AND_RUN=1 ARCH="$TARGET_ARCH" "$TOOL" --no-appstream \ + -u "gh-releases-zsync|${REPO%%/*}|${REPO##*/}|latest|ipatool-gui-*-${FILE_ARCH}.AppImage.zsync" \ + release/squashfs-root "$APPIMAGE" + rm -rf release/squashfs-root + + # appimagetool generates this when zsyncmake is installed; fall back + # to zsyncmake directly so a missing helper cannot silently drop it. + if [ ! -f "${APPIMAGE}.zsync" ]; then + zsyncmake -u "https://github.com/${GITHUB_REPOSITORY}/releases/download/${GITHUB_REF_NAME}/${NAME}.zsync" \ + -o "${APPIMAGE}.zsync" "$APPIMAGE" + fi + ls -lh "$APPIMAGE" "${APPIMAGE}.zsync" + # macOS: turn the unpacked .app into a single runnable archive. - name: Package the .app as a runnable tar.gz if: matrix.platform == 'mac' @@ -259,6 +325,7 @@ jobs: release/*.dmg release/*.app.tar.gz release/*.AppImage + release/*.zsync release/*.deb release/SHA256SUMS.txt if-no-files-found: error diff --git a/README.md b/README.md index 541162d..0bc403e 100644 --- a/README.md +++ b/README.md @@ -80,7 +80,7 @@ SmartScreen may warn about an unknown publisher — choose **Run anyway**. ### Linux -AppImage and deb packages for x64 / arm64. +AppImage (with a `.zsync` sidecar for AppImageUpdate) and deb packages for x64 / arm64. --- diff --git a/README_CN.md b/README_CN.md index 3472dc7..bc01ac2 100644 --- a/README_CN.md +++ b/README_CN.md @@ -71,7 +71,7 @@ SmartScreen 提示「未知发布者」属正常现象,选择「仍要运行 ### Linux -提供 AppImage 与 deb(x64 / arm64)。 +提供 AppImage(附带用于 AppImageUpdate 的 `.zsync`)与 deb(x64 / arm64)。 --- diff --git a/docs/architecture.md b/docs/architecture.md index 06e3d0e..68f60bd 100644 --- a/docs/architecture.md +++ b/docs/architecture.md @@ -55,7 +55,7 @@ - 全栈 TypeScript,主进程 / preload / 渲染进程共享类型与纯逻辑层,编译期即可发现 IPC 不一致; - 渲染层与其它方案同样是 webview,UI 流畅度没有差别; -- 打包产物覆盖 Windows(NSIS + 便携版)、macOS(dmg)、Linux(AppImage + deb)。 +- 打包产物覆盖 Windows(NSIS + 便携版)、macOS(dmg)、Linux(AppImage + `.zsync` + deb)。 > 若你更想要 Tauri/Wails 的体积,`src/shared/` 与 `src/main/` 的命令构建、输出解析、 > 队列与引擎逻辑均为平台无关的纯逻辑,可以较直接地移植到 Rust/Go 壳中。 @@ -270,7 +270,7 @@ Windows 产物未签名。 > macOS 在 CI 上产 **`.app.tar.gz` 运行包**(GitHub 的 macOS runner 无法运行 dmg 所需的 > `hdiutil attach`,会报 `Device not configured`,故用 `dir` target + tar); > 在真实 Mac 上 `npm run dist:mac` 仍会产 dmg 安装包。 -> 各平台产物:Windows = NSIS 安装包 + portable 运行包 + portable zip(均 x64);Linux = deb 安装包 + AppImage 运行包(x64 与 arm64 分开打包)。 +> 各平台产物:Windows = NSIS 安装包 + portable 运行包 + portable zip(均 x64);Linux = deb 安装包 + AppImage 运行包 + AppImage 的 `.zsync` 更新元数据(x64 与 arm64 分开打包)。 > > Draft 不是公开状态,仍需到 Releases 页手动点 Publish 才对外可见。 > 地下开发阶段只要不勾 `publish`,仓库对外不会留下任何 Release 痕迹。 diff --git a/electron-builder.yml b/electron-builder.yml index 894571b..db88261 100644 --- a/electron-builder.yml +++ b/electron-builder.yml @@ -112,7 +112,7 @@ linux: category: Utility synopsis: Desktop front-end for ipatool maintainer: ipatool-gui contributors - artifactName: ${name}-${version}-linux-${arch}.${ext} + artifactName: ${name}-${version}-${arch}.${ext} # mksquashfs then defaults to zlib, which the catalog's mount helper supports. compression: normal # ⚠️ Deliberately NO `arch:` here. Once a target declares its own arch list, diff --git a/package-lock.json b/package-lock.json index 9da0d21..8fda861 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "ipatool-gui", - "version": "0.3.1", + "version": "0.3.2", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "ipatool-gui", - "version": "0.3.1", + "version": "0.3.2", "license": "MIT", "devDependencies": { "@eslint/js": "9.39.2", diff --git a/package.json b/package.json index b9dec4c..071ae62 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "ipatool-gui", "productName": "IPATool GUI", - "version": "0.3.1", + "version": "0.3.2", "engines": { "node": ">=20.19" }, diff --git a/scripts/sha256sums.mjs b/scripts/sha256sums.mjs index 3a78eb1..01d6753 100644 --- a/scripts/sha256sums.mjs +++ b/scripts/sha256sums.mjs @@ -23,7 +23,7 @@ import path from 'node:path' import { pathToFileURL } from 'node:url' /** Artifact extensions that ship to users. Intermediate build output is skipped. */ -const ARTIFACT_SUFFIXES = ['.exe', '.dmg', '.app.tar.gz', '.AppImage', '.deb', '.zip'] +const ARTIFACT_SUFFIXES = ['.exe', '.dmg', '.app.tar.gz', '.AppImage', '.deb', '.zip', '.zsync'] export const MANIFEST_NAME = 'SHA256SUMS.txt' diff --git a/src/main/engine.ts b/src/main/engine.ts index 0d405e5..bd1db56 100644 --- a/src/main/engine.ts +++ b/src/main/engine.ts @@ -64,7 +64,7 @@ const REPO_WEB = `https://github.com/${IPATOOL_REPO}` * trick can answer (offline API, blocked mirror, ...). Installing a slightly old * ipatool beats failing to install any. */ -const FALLBACK_VERSION = '2.6.0' +const FALLBACK_VERSION = '2.8.1' interface GhAsset { name: string diff --git a/src/main/settings.ts b/src/main/settings.ts index f906053..f3a879b 100644 --- a/src/main/settings.ts +++ b/src/main/settings.ts @@ -59,7 +59,7 @@ export function defaultSettings(): Settings { notifyOnComplete: true, autoCheckUpdates: true, confirmCloseWhileDownloading: false, - lastEmail: '' + emailHistory: [] } } @@ -147,6 +147,21 @@ export function normalizeSettings(input: unknown): Settings { out.activeAccountId = accounts[0]?.id ?? '' } + // `lastEmail` was the pre-history field. Seed it first, then merge the saved + // list; dedupe case-insensitively so a legacy entry cannot appear twice. + const emails: string[] = [] + const seenEmails = new Set() + const addEmail = (value: unknown): void => { + if (typeof value !== 'string') return + const email = value.trim() + if (email === '' || seenEmails.has(email.toLowerCase())) return + seenEmails.add(email.toLowerCase()) + emails.push(email) + } + addEmail(raw.lastEmail) + for (const value of Array.isArray(raw.emailHistory) ? raw.emailHistory : []) addEmail(value) + out.emailHistory = emails.slice(0, 50) + return out } diff --git a/src/main/window.ts b/src/main/window.ts index dd4a9d5..88284b1 100644 --- a/src/main/window.ts +++ b/src/main/window.ts @@ -42,6 +42,7 @@ function titleBarOptions(): Electron.BrowserWindowConstructorOptions { export function createMainWindow(options: WindowOptions = {}): BrowserWindow { const dark = nativeTheme.shouldUseDarkColors + chromeModal = false const win = new BrowserWindow({ width: options.width ?? 1240, @@ -100,6 +101,10 @@ export function createMainWindow(options: WindowOptions = {}): BrowserWindow { win.on('maximize', () => win.webContents.send('window:maximized', true)) win.on('unmaximize', () => win.webContents.send('window:maximized', false)) + // Windows may repaint the caption strip while the window loses focus (a + // login request, a native dialog, ...). Re-apply the last known state when + // focus comes back instead of leaving a solid strip over an open modal. + win.on('focus', () => syncTitleBarOverlay(win)) if (DEV_URL) { void win.loadURL(DEV_URL) @@ -110,17 +115,26 @@ export function createMainWindow(options: WindowOptions = {}): BrowserWindow { return win } +/** + * Last modal state reported by the renderer. Theme/settings events call + * syncTitleBarOverlay() without an explicit state; they must not paint the + * caption strip back to opaque while a dialog is still open. + */ +let chromeModal = false + /** Keeps the Windows caption buttons in sync with the app theme. */ -export function syncTitleBarOverlay(win: BrowserWindow | null, modal = false): void { +export function syncTitleBarOverlay(win: BrowserWindow | null, modal?: boolean): void { if (!win || process.platform !== 'win32') return + if (typeof modal === 'boolean') chromeModal = modal + const dimmed = modal ?? chromeModal try { const dark = nativeTheme.shouldUseDarkColors // Modal scrim is a dark blur over the whole page, including the strip the // OS caption buttons sit on. A painted overlay color cannot show that blur, // so the strip stays transparent while a modal is open and lets the scrim // through; glyphs stay bright because the scrim is dark on both themes. - const color = modal ? 'rgba(0, 0, 0, 0)' : dark ? '#101014' : '#ffffff' - const symbolColor = modal + const color = dimmed ? 'rgba(0, 0, 0, 0)' : dark ? '#101014' : '#ffffff' + const symbolColor = dimmed ? dark ? '#e8e8ef' : '#ffffff' diff --git a/src/renderer/src/i18n/en.ts b/src/renderer/src/i18n/en.ts index 1d448b2..7622f63 100644 --- a/src/renderer/src/i18n/en.ts +++ b/src/renderer/src/i18n/en.ts @@ -122,7 +122,7 @@ export const en = { 'auth.passwordPlaceholder': 'Your Apple ID password', 'auth.submit': 'Sign in', 'auth.signingIn': 'Signing in…', - 'auth.remember': 'Remember this e-mail', + 'auth.emailHistoryDelete': 'Remove this e-mail', 'auth.2fa.title': 'Two-factor code required', 'auth.2fa.body': 'Apple sent a verification code to your trusted devices. Enter it below.', 'auth.2fa.placeholder': '6-digit code', @@ -296,6 +296,8 @@ export const en = { 'downloads.progress.remaining': '{eta} left', 'downloads.progress.done': 'Complete', 'downloads.resumeHint': 'Paused downloads keep their partial file and resume where they stopped.', + 'downloads.reloginRequired': 'Sign in again before downloading', + 'downloads.reloginHint': 'Use the same Apple ID; your queue and purchases are kept.', 'downloads.deletePartial.title': 'Discard the partial file?', 'downloads.deletePartial.body': 'The next attempt will start from zero bytes. Use this when Apple rejects the resume range (HTTP 416) after a long pause.', @@ -470,6 +472,9 @@ export const en = { 'toast.downloadStarted': 'Download started', 'toast.downloadDone': '{name} downloaded', 'toast.downloadFailed': '{name} failed', + 'toast.reloginRequired': 'Sign in again to enable downloads', + 'toast.reloginRequiredDetail': + 'ipatool 2.8.1 needs to provision this session for Store downloads. Sign in with the same Apple ID; your purchases and queue are kept.', 'toast.copied': 'Copied to clipboard', 'toast.saved': 'Saved', 'toast.settingsReset': 'Settings reset to defaults', diff --git a/src/renderer/src/i18n/zh.ts b/src/renderer/src/i18n/zh.ts index 670431d..b0b0918 100644 --- a/src/renderer/src/i18n/zh.ts +++ b/src/renderer/src/i18n/zh.ts @@ -118,7 +118,7 @@ export const zh: Dict = { 'auth.passwordPlaceholder': '你的 Apple ID 密码', 'auth.submit': '登录', 'auth.signingIn': '登录中…', - 'auth.remember': '记住这个邮箱', + 'auth.emailHistoryDelete': '删除这个邮箱', 'auth.2fa.title': '需要双重认证验证码', 'auth.2fa.body': 'Apple 已向你的受信任设备发送验证码,请输入。', 'auth.2fa.placeholder': '6 位验证码', @@ -287,6 +287,8 @@ export const zh: Dict = { 'downloads.progress.remaining': '剩余 {eta}', 'downloads.progress.done': '完成', 'downloads.resumeHint': '暂停会保留未完成文件,继续时从断点接着下。', + 'downloads.reloginRequired': '需要重新登录一次才能下载', + 'downloads.reloginHint': '用同一个 Apple ID 登录即可,队列和已购记录都会保留。', 'downloads.deletePartial.title': '丢弃未完成文件?', 'downloads.deletePartial.body': '下次将从 0 字节重新开始。当长时间暂停后 Apple 拒绝续传范围(HTTP 416)时使用。', 'downloads.deletePartial.confirm': '丢弃并重新下载', @@ -455,6 +457,9 @@ export const zh: Dict = { 'toast.downloadStarted': '开始下载', 'toast.downloadDone': '{name} 下载完成', 'toast.downloadFailed': '{name} 下载失败', + 'toast.reloginRequired': '需要重新登录一次才能下载', + 'toast.reloginRequiredDetail': + 'ipatool 2.8.1 需要为当前会话完成 Store AMD 初始化;用同一个 Apple ID 重新登录即可,已购记录和队列都会保留。', 'toast.copied': '已复制到剪贴板', 'toast.saved': '已保存', 'toast.settingsReset': '设置已恢复默认', diff --git a/src/renderer/src/pages/AuthModal.tsx b/src/renderer/src/pages/AuthModal.tsx index 1684918..c32c86f 100644 --- a/src/renderer/src/pages/AuthModal.tsx +++ b/src/renderer/src/pages/AuthModal.tsx @@ -1,8 +1,8 @@ -import { useEffect, useState } from 'react' +import { useEffect, useRef, useState } from 'react' import type { ReactNode } from 'react' import type { LoginResult, LoginStatus } from '@shared/types' import { useAppStore } from '@renderer/store/app' -import { useUiStore } from '@renderer/store/ui' +import { refreshChromeDimming, useUiStore } from '@renderer/store/ui' import { ErrorNotice } from '@renderer/components/ErrorNotice' import { Icon, Spinner } from '@renderer/components/Icon' import { Modal } from '@renderer/components/Modal' @@ -50,14 +50,15 @@ export function AuthModal(): ReactNode { const targetId = accounts.activeId const target = accounts.accounts.find((view) => view.id === targetId) - const [email, setEmail] = useState(settings.lastEmail) + const [email, setEmail] = useState('') const [password, setPassword] = useState('') const [code, setCode] = useState('') - const [remember, setRemember] = useState(Boolean(settings.lastEmail)) const [step, setStep] = useState('credentials') const [busy, setBusy] = useState(false) const [failure, setFailure] = useState<{ message: string; code: string | null } | null>(null) const [checking, setChecking] = useState(false) + const [showEmails, setShowEmails] = useState(false) + const emailBoxRef = useRef(null) // Reset transient state each time the dialog opens - and scrub the password // the moment it closes. The dialog stays mounted while hidden (Modal returns @@ -67,16 +68,36 @@ export function AuthModal(): ReactNode { if (!open) { setPassword('') setCode('') + setShowEmails(false) return } setStep('credentials') + setEmail('') setPassword('') setCode('') setFailure(null) setBusy(false) - setEmail(useAppStore.getState().settings.lastEmail) + setShowEmails(false) }, [open]) + // The custom suggestion panel is outside the input, so close it on an + // outside click instead of relying on input blur (clicking Delete would + // otherwise close the list before the click lands). + useEffect(() => { + if (!showEmails) return + const onMouseDown = (event: MouseEvent): void => { + if (!emailBoxRef.current?.contains(event.target as Node)) setShowEmails(false) + } + document.addEventListener('mousedown', onMouseDown) + return () => document.removeEventListener('mousedown', onMouseDown) + }, [showEmails]) + + const forgetEmail = async (value: string): Promise => { + await updateSettings({ + emailHistory: settings.emailHistory.filter((entry) => entry !== value) + }) + } + const submit = async (): Promise => { if (busy) return if (email.trim() === '' || password === '') return @@ -103,12 +124,22 @@ export function AuthModal(): ReactNode { return } finally { setBusy(false) + // Login runs through ipatool and can leave the OS caption strip repainted; + // the dialog is still open, so restore its transparent overlay. + refreshChromeDimming() } if (result.status === 'ok') { useAppStore.setState({ pendingAddRestoreId: null }) - if (remember) await updateSettings({ lastEmail: email.trim() }) - else if (settings.lastEmail) await updateSettings({ lastEmail: '' }) + const signedInEmail = email.trim() + await updateSettings({ + emailHistory: [ + signedInEmail, + ...settings.emailHistory.filter( + (entry) => entry.toLowerCase() !== signedInEmail.toLowerCase() + ) + ].slice(0, 50) + }) useAppStore.getState().setAccount(result.account) setOpen(false) toast({ kind: 'success', message: t('auth.success', { email: result.account?.email ?? email }) }) @@ -251,20 +282,79 @@ export function AuthModal(): ReactNode { > {step === 'credentials' ? ( <> -