Compare commits

..
Author SHA1 Message Date
cflmy d434130785 fix(mqdh): pass installer triplet positionally to the evidence helper (#31)
ci/woodpecker/pr/ci Pipeline is pending
ci/woodpecker/pr/tauri-linux Pipeline is pending
ci/woodpecker/push/tauri-linux Pipeline is pending
ci/woodpecker/push/ci Pipeline was canceled
ci/woodpecker/tag/ci Pipeline failed
ci/woodpecker/tag/tauri-linux Pipeline failed
ci/woodpecker/manual/tauri-linux Pipeline is pending
ci/woodpecker/manual/tauri-macos Pipeline is pending
ci/woodpecker/manual/tauri-windows Pipeline is pending
ci/woodpecker/manual/ci Pipeline was successful
2026-12-03 13:20:42 +08:00
cflmy 6f4eb56e0e fix(mqdh): avoid pipefail SIGPIPE while validating the runtime archive (#31)
ci/woodpecker/push/tauri-linux Pipeline is pending
ci/woodpecker/pr/ci Pipeline is pending
ci/woodpecker/pr/tauri-linux Pipeline is pending
ci/woodpecker/push/ci Pipeline was canceled
2026-12-03 13:16:52 +08:00
cflmy b74794c55c fix(mqdh): ship the verified tree as one archive and extract on first start (#31)
ci/woodpecker/pr/ci Pipeline is pending
ci/woodpecker/pr/tauri-linux Pipeline is pending
ci/woodpecker/push/ci Pipeline is pending
ci/woodpecker/push/tauri-linux Pipeline is pending
Tauri's Linux deb walker drops symlinks and the pnpm node_modules tree is
symlink-based, so a resource directory installed a broken tree. Ship the exact
cold-install-verified .tar.gz as one resource; the shell validates entry paths,
extracts once to MQDH_HOME/runtime, keeps the completed tree for later starts,
and launches the same existing backend. Also fix the installer-argument parser
and document TAURI.md in the product doc indexes.

Verified locally in the pinned Debian 12 build image: deb bundle + extract +
--version + real backend --smoke PASS.
2026-12-03 13:14:00 +08:00
cflmy ebc2e9a64d fix(mqdh): bundle deb without the asset protocol and via the reviewed mirror (#31)
ci/woodpecker/pr/tauri-linux Pipeline is pending
ci/woodpecker/push/ci Pipeline was successful
ci/woodpecker/push/tauri-linux Pipeline was canceled
ci/woodpecker/pr/ci Pipeline was canceled
The MQDH shell never exposes the Tauri asset protocol, so disable it
explicitly. Tauri 2.13 otherwise downloads a GStreamer asset plugin from
GitHub at deb bundle time; fetch bundler assets through the internal reviewed
mirror instead of requiring direct GitHub access in CI.
2026-12-03 12:59:01 +08:00
cflmy 61d0976463 fix(mqdh): package from the current version, not a stale .ci manifest (#31)
ci/woodpecker/push/tauri-linux Pipeline is pending
ci/woodpecker/pr/ci Pipeline is pending
ci/woodpecker/pr/tauri-linux Pipeline is pending
ci/woodpecker/push/ci Pipeline was canceled
2026-12-03 12:50:52 +08:00
cflmy 096b804e5e ci(mqdh): keep native Windows/macOS lanes manual until agents exist (#31)
ci/woodpecker/push/tauri-linux Pipeline is pending
ci/woodpecker/pr/ci Pipeline is pending
ci/woodpecker/pr/tauri-linux Pipeline is pending
ci/woodpecker/push/ci Pipeline was canceled
A tag pipeline must not be blocked by jobs whose native agents are not
provisioned. The Linux lane publishes a scoped beta; the native lanes stay
explicitly manual (and BLOCKED) until real Windows/macOS agents and signing
credentials are attached.
2026-12-03 12:48:00 +08:00
cflmy e1401adbba fix(mqdh): make the Tauri shell compile and smoke headless (#31)
ci/woodpecker/push/ci Pipeline is pending
ci/woodpecker/pr/ci Pipeline is pending
ci/woodpecker/push/tauri-linux Pipeline is pending
ci/woodpecker/pr/tauri-linux Pipeline is pending
- parse the product version in build.rs without an extra build dependency
- resolve the bundled tree from the installed resource path in a headless
  --smoke path, so CI can prove the real backend without a display
- keep the window path as the single GUI lifecycle
2026-12-03 12:47:44 +08:00
cflmy fafb49a633 build(mqdh): pin the Tauri crate graph and build image recipe (#31)
ci/woodpecker/push/tauri-linux Pipeline is pending
ci/woodpecker/pr/ci Pipeline is pending
ci/woodpecker/pr/tauri-linux Pipeline is pending
ci/woodpecker/push/ci Pipeline was canceled
- commit Cargo.lock for the desktop shell
- generate the desktop icon set from the existing approved MQDH icon
- add the app-owned Tauri build image Dockerfile/build script
- record the pinned Tauri CLI 2.13.0 and Rust 1.100 toolchain
2026-12-03 12:39:54 +08:00
cflmy c090cc786e feat(mqdh): add the Tauri desktop shell and installer release contract (#31)
Add the minimal Tauri 2 desktop adaptation for the existing /mqdh workbench:
the shell starts the bundled production tree on loopback, waits for the real
readiness URL, navigates only inside that origin, keeps a single instance and
stops only its own process tree. The product UI, Harness service and update
discovery are unchanged.

- src-tauri: Tauri config, core-only capability, Rust lifecycle/security shell
- scripts/tauri: resource staging, Linux deb build + smoke, Windows/macOS native
  lane scripts, installer attachment to the existing release manifest
- .woodpecker/tauri-*: Linux lane plus labelled native Windows/macOS lanes
- docs/mqdh/TAURI.md + ADR 0001: Tauri 2 is the only official desktop wrapper
- version 0.2.0-beta.1; portable archive remains an advanced/diagnostic asset

Windows/macOS remain BLOCKED until native agents and signing credentials exist;
no simulated bytes are produced.
2026-12-03 12:34:46 +08:00
cflmy fdb9a3b9ed Merge pull request 'feat: ship the latest MQDH frontend in the portable ZIP' (#30) from codex/windows-portable-latest into main
ci/woodpecker/push/ci Pipeline is pending
ci/woodpecker/tag/ci Pipeline is pending
2026-12-03 11:14:09 +08:00
38 changed files with 6110 additions and 36 deletions

No files matched your search

+8
View File
@@ -55,3 +55,11 @@ native/system/test/bin/
# Local CI output
/.ci/
# Tauri desktop build outputs (the prebuilt tree is a release artifact)
/src-tauri/target/
/src-tauri/resources/
/src-tauri/gen/
# Local Cargo/CI working data (never committed)
/.build/
-15
View File
@@ -39,18 +39,3 @@ steps:
- corepack enable
- corepack prepare pnpm@11.28.5 --activate
- MQDH_TEST_INSTALL=1 MARQDO_CI_OUT=.ci bash scripts/ci.sh
package:
image: node:24.22.3-bookworm
depends_on: [test]
when:
- event: tag
environment:
MQDH_BUNDLE_NODE: "1"
MQDH_PACKAGE_WORK: /tmp/mqdh-package-work
commands:
- corepack enable
- corepack prepare pnpm@11.28.5 --activate
- MARQDO_CI_OUT=.ci bash scripts/package.sh
- cat .ci/package-evidence.json
- cat .ci/mqdh-release.json
+58
View File
@@ -0,0 +1,58 @@
# MQDH Tauri Linux installer lane.
#
# One frozen source SHA produces the portable archive (existing cold-install
# contract) plus the Linux `.deb` installer from the same tree. The `.deb` is
# the user-facing artifact; the archive stays an advanced/diagnostic asset.
#
# Windows and macOS are separate workflows with native-agent labels. They are
# not simulated on this Linux agent: without a matching agent those jobs stay
# BLOCKED. A Linux-only beta may be published explicitly as a scoped release;
# it never claims three-platform completion.
when:
- event: [push, pull_request, manual, tag]
steps:
install:
image: node:24.22.3-bookworm
environment:
CI: "true"
commands:
- corepack enable
- corepack prepare pnpm@11.28.5 --activate
- pnpm install --frozen-lockfile
build:
image: node:24.22.3-bookworm
depends_on: [install]
environment:
CI: "true"
commands:
- corepack enable
- corepack prepare pnpm@11.28.5 --activate
- pnpm run build
installer:
image: git.cflmy.cn/cflmy/mqdh-tauri-build:0.2.0
depends_on: [build]
environment:
CI: "true"
MARQDO_CI_OUT: .ci
MQDH_PACKAGE_WORK: /tmp/mqdh-package-work
commands:
- bash scripts/tauri/build-linux.sh
- cat .ci/mqdh-release.json
- cat .ci/release-evidence.json
publish:
image: node:24.22.3-bookworm
depends_on: [installer]
when:
- event: tag
environment:
MQDH_GITEA_TOKEN:
from_secret: gitea_token
CI: "true"
commands:
- version="${CI_COMMIT_TAG#mqdh-v}"
- test "$version" != "$CI_COMMIT_TAG"
- node scripts/release.ts --version "$version" --source "$CI_COMMIT_SHA" --assets .ci --publish
+22
View File
@@ -0,0 +1,22 @@
# MQDH Tauri macOS DMG lane (BLOCKED until a native macOS agent exists).
#
# Signing/notarization requires an Apple Developer ID in protected secrets.
# Without the agent and credentials this workflow is not run and no artifact is
# claimed; Linux cross-compilation is never presented as macOS acceptance.
when:
- event: manual
labels:
platform: macos
steps:
build:
image: ghcr.io/cirruslabs/macos-runner:sonoma
commands:
- bash scripts/tauri/build-macos.sh
evidence:
image: ghcr.io/cirruslabs/macos-runner:sonoma
depends_on: [build]
commands:
- cat .ci/release-evidence.json
+23
View File
@@ -0,0 +1,23 @@
# MQDH Tauri Windows NSIS lane (BLOCKED until a native Windows agent exists).
#
# The step is labelled so Woodpecker only schedules it on an agent that declares
# `platform=windows`. Without that agent the pipeline does not run this workflow
# and no Windows installer is produced or claimed. Native build/install smoke
# must happen on real Windows; Wine or cross-builds are not acceptance.
when:
- event: manual
labels:
platform: windows
steps:
build:
image: mcr.microsoft.com/windows/servercore:ltsc2022
commands:
- pwsh -NoProfile -File scripts/tauri/build-windows.ps1
evidence:
image: mcr.microsoft.com/windows/servercore:ltsc2022
depends_on: [build]
commands:
- pwsh -NoProfile -Command "Get-Content .ci/release-evidence.json"
+16 -12
View File
@@ -1,18 +1,22 @@
# 应用发行、安装与更新
> **2026-12-03 更新(#31)**:桌面安装形态改为 **Tauri 2**,主产物为 Linux `.deb`、
> Windows NSIS `.exe`、macOS `.dmg`;portable `.tar.gz` 保留为高级/诊断资产。
> 桌面壳、生命周期、安全与三平台状态以 [TAURI.md](TAURI.md) 为唯一现行规范;
> 本文的发行清单、更新与数据边界继续有效。
MQDH 是**默认对外发行**的单用户应用:用户下载安装包,在自己的电脑上安装,不依赖 Rust、Node、pnpm 或源码 checkout。应用安装与 `MQDH_HOME`(会话、私人知识、运行证据、Marqdo 运行时)严格分离。
## 1. 平台矩阵
| 平台 | 首版 | 状态 |
| --- | --- | --- |
| Linux x86_64 glibc ≥ 2.39 | `.tar.gz`(内置 Node 运行时 + 用户级 `install.sh`) | 已发布公共 Beta `0.1.0-beta.1`(2026-12-02,未签名) |
| Windows x86_64 | `.tar.gz`(内置 Node 运行时 + 用户级 `install.ps1` + `mqdh.cmd`) | 实验性:已构建并冷安装验证;未签名、无原生 CI lane,应用内更新未验证 |
| Linux aarch64 | 未发布 | `UNVERIFIED`;不生成同名制品 |
| macOS arm64/x64 | 未发布 | `UNVERIFIED`;没有签名/公证证书 |
| Windows arm64 | 未发布 | `UNVERIFIED` |
| 平台 | 主安装产物 | 高级/诊断资产 | 状态 |
| --- | --- | --- | --- |
| Linux x86_64 glibc ≥ 2.39 | `.deb`(Tauri,内置 Node 运行时,用户级安装) | `marqdo-harness-<v>-x86_64-unknown-linux-gnu.tar.gz` | 可构建;真实安装验收按发行记录 |
| Linux aarch64 | 未发布 | — | `UNVERIFIED`;不生成同名制品 |
| Windows x64 | NSIS `-setup.exe`(Tauri,currentUser) | 不再以 portable ZIP 作为官方路径 | **BLOCKED**:无原生 Windows agent |
| macOS arm64 | `.dmg`(Tauri) | — | **BLOCKED**:无原生 macOS agent 与签名/公证凭据 |
`detectPlatform` 对未发布目标返回 `supported=false` 与具体原因;更新检查在下载前按 manifest 的 target/min_glibc/Node/CLI 兼容范围拒绝。应用不继承 DSH 桌面或官方发布声明。
`detectPlatform` 对未发布目标返回 `supported=false` 与具体原因;更新检查在下载前按 manifest 的 target/min_glibc/Node/CLI 兼容范围拒绝。应用不继承 DSH 桌面或官方发布声明。三平台主产物、安装器验收与安全边界见 [TAURI.md](TAURI.md)。
当前公共 Beta 发行身份(唯一来源是 Gitea Release):
@@ -41,7 +45,7 @@ MQDH_HOME/ # 用户数据,卸载默认保留
`mqdh` wrapper 优先使用安装树内的 `runtime/node`,否则要求系统 Node ≥ 24;应用包因此不要求用户预装 Node。`SOURCE_SHA` 与 `packages/marqdo/harness/package.json` 固定应用身份。
### Windows x86_64(实验性)
### Windows x86_64 portable(历史实验,非官方安装路径)
```text
%LOCALAPPDATA%\MQDH\ # 默认安装前缀(-Prefix 可改)
@@ -127,9 +131,9 @@ mqdh update rollback --confirm [--json]
```sh
pnpm install --frozen-lockfile
pnpm run build # 10/10 gates
MQDH_PACKAGE_WORK=/path bash scripts/package.sh
# .ci/: 归档、.sha256、mqdh-release.json、release-evidence.json、package-evidence.json
MQDH_GITEA_TOKEN=... node scripts/release.ts --version 0.1.0 \
bash scripts/tauri/build-linux.sh # deb + portable 归档 + 冷 smoke + 安装器证据
# .ci/: deb、归档、.sha256、mqdh-release.json(含 installers)、release-evidence.json、package-evidence.json
MQDH_GITEA_TOKEN=... node scripts/release.ts --version 0.2.0-beta.1 \
--source "$(git rev-parse HEAD)" --assets .ci # dry-run
MQDH_GITEA_TOKEN=... node scripts/release.ts ... --publish # 不可变发布
```
+1
View File
@@ -12,6 +12,7 @@
| [NETWORK.md](NETWORK.md) | 默认出口、代理/镜像/离线、审计与拒绝码 |
| [BOOTSTRAP.md](BOOTSTRAP.md) | 首次启动状态机、`doctor`/`repair`、离线与失败处理 |
| [DIAGNOSTICS.md](DIAGNOSTICS.md) | 本地脱敏报告、去重/限额与显式 Issue 提交 |
| [TAURI.md](TAURI.md) | 桌面壳、后端生命周期、安全边界、三平台安装器与 BLOCKED 状态(唯一现行桌面规范) |
| [DISTRIBUTION.md](DISTRIBUTION.md) | 平台矩阵、安装布局、发行清单、更新/回退 |
| [RELEASING.md](RELEASING.md) | 构建、签名、发布与发布后验证 |
| [STATUS.md](STATUS.md) | 唯一现状与门禁矩阵(PASS/PARTIAL/UNVERIFIED) |
+2 -2
View File
@@ -1,6 +1,6 @@
# 发布流程
发布工具:`scripts/package.sh`(构建 + 冷安装验证)、`scripts/release-manifest.ts`(清单/签名/证据)、`scripts/release.ts`(Gitea 发布,默认 dry-run)。凭据只来自环境,不写入仓库、日志或制品。
发布工具:`scripts/tauri/build-linux.sh`(Tauri deb + portable 归档 + 冷 smoke)、`scripts/package.sh`(portable 构建 + 冷安装验证)、`scripts/release-manifest.ts`(清单/签名/证据)、`scripts/tauri/attach-installers.mjs`(安装器摘要)、`scripts/release.ts`(Gitea 发布,默认 dry-run)。凭据只来自环境,不写入仓库、日志或制品。桌面安装合同见 [TAURI.md](TAURI.md)。
## 1. 发布前
@@ -15,7 +15,7 @@
```sh
pnpm install --frozen-lockfile
DSH_CLIENT_TITLE="Marqdo Harness" pnpm run build
MQDH_PACKAGE_WORK=/var/tmp/mqdh-package bash scripts/package.sh
bash scripts/tauri/build-linux.sh
```
输出 `.ci/`:
+4 -4
View File
@@ -21,7 +21,7 @@ sha256 `68cbb8f878af47a44a8e0ff7625b647ff4b8ac5817cda02e0a31fdc658fdcd7d`,
| R04 独立 clone 构建 | PASS | 对 `origin/main` 做 depth-1 独立 clone:`pnpm install --frozen-lockfile` 后 `pnpm run build` 10/10 gates PASS(235.73s),无父仓/兄弟源码。 |
| R05 上游基线 + 下游测试 | PASS | 上游 `pnpm run build` 10/10 gates PASS;下游 28 项测试 PASS(1 项网络安装测试由 `MQDH_TEST_INSTALL=1` 单独通过)。 |
| R06 上游同步演练 | UNVERIFIED | 当前镜像 HEAD 等于基线,没有更新的上游提交;`scripts/upstream.sh candidate` 已实现,未执行真实合并。 |
| R07 发布路径分离 | PASS | 删除上游发布/上传/桌面打包工作流;下游包名、命令、发行地址独立;仓库内无官方凭证。 |
| R07 发布路径分离 | PASS | 删除上游发布/上传/桌面打包工作流;下游包名、命令、发行地址独立;仓库内无官方凭证。2026-12-03 起 Tauri 2 为唯一桌面封装(`docs/mqdh/TAURI.md`)。 |
| R08 无 Marqdo 生产源码副本 | PASS | 仓库只含应用代码;CLI/Bundle/Tool 由运行时安装;测试使用发布资产或自写 fixture。 |
## 安装与更新(E)
@@ -118,9 +118,9 @@ sha256 `68cbb8f878af47a44a8e0ff7625b647ff4b8ac5817cda02e0a31fdc658fdcd7d`,
| 门禁 | 状态 | 证据或限制 |
| --- | --- | --- |
| DIST-01 清单 schema、命名、tag/证据、Linux tar 冷安装 | PASS(已发布) | `mqdh-v0.1.0-beta.1`:`mqdh-release.json` + `.sha256` + `release-evidence.json`(含 `cli@63562d8…` 运行时依赖);归档 786,741,787 B / sha256 `68cbb8f8…`;冷安装/`doctor`/`dump-config` 通过;未签名。 |
| DIST-02 Linux `.deb`/AppImage、用户级安装/卸载 | PARTIAL | 用户级 `install.sh`/`--uninstall` 已实现并测试;`.deb`/AppImage 未构建。 |
| DIST-03 macOS/Windows 构建与冷安装 | PARTIAL | Windows x86_64 已提供正式便携 ZIP(`MQDH-<version>-win-x64.zip`:解压双击 `MQDH.exe`,无终端/安装脚本;冷解压 + 工作台 HTTP + 离线 bootstrap 已验证);未签名、无原生 Windows CI lane、应用内更新未验证;EXE 安装器/桌面集成/前端品牌化见 `#25`;macOS 无签名/公证证书,`UNVERIFIED`。 |
| DIST-01 清单 schema、命名、tag/证据、Linux tar 冷安装 | PASS(已发布) | `mqdh-v0.1.0-beta.1`:`mqdh-release.json` + `.sha256` + `release-evidence.json`(含 `cli@63562d8…` 运行时依赖);归档 786,741,787 B / sha256 `68cbb8f8…`;冷安装/`doctor`/`dump-config` 通过;未签名。0.2.0-beta.1 起安装器摘要追加到同一清单。 |
| DIST-02 Linux `.deb` 安装器 | PARTIAL | Tauri `.deb` 构建与解包 smoke 已实现(`scripts/tauri/build-linux.sh`);真实桌面安装/卸载与系统菜单验收以发行记录为准,AppImage 不在本期范围。 |
| DIST-03 macOS/Windows 构建与冷安装 | BLOCKED | 官方安装路径为 Tauri NSIS `.exe` / `.dmg`;无原生 Windows/macOS agent 与签名/公证凭据,`.woodpecker/tauri-windows.yml`、`tauri-macos.yml` 已就绪但不会在 Linux agent 上伪造运行。此前的 Windows portable ZIP 属历史实验证据,不是官方安装路径。 |
| DIST-04 签名、SBOM、代理/镜像、离线安装 | PARTIAL | Ed25519 清单签名/验证与测试密钥通过;官方密钥、SBOM、离线应用更新未运行。 |
| DIST-05 更新检查/安装/回退、通知与对账 | PARTIAL | `update check` 对真实 Release 可用;`install/rollback` 仍只用本地发布服务器完成真实切换与回退;自动下载/安装按政策关闭,通知/对账未实现。 |
+117
View File
@@ -0,0 +1,117 @@
# MQDH 桌面壳(Tauri 2)现行合同
> 状态:2026-12-03 起生效。本文是 MQDH 桌面封装与安装包的**唯一现行规范**,
> 依据 [marqdo-app-harness#31](https://git.cflmy.cn/cflmy/marqdo-app-harness/issues/31)。
> 它取代此前“恢复 Electron 独立桌面发行”的路线;此前发布的 portable 归档与
> Windows 实验发行保留为历史事实,不再是官方桌面安装路径。
## 1. 一个工作台、一个产品
```
系统安装器 (deb / NSIS / DMG)
└─ Tauri 2 壳(仅窗口、启动、退出、受限导航)
└─ 既有 /mqdh 工作台(同一 React/Web UI,不复制页面)
└─ 受控 loopback Harness 服务(既有 Node 后端,不重写业务)
└─ 独立发行的 CLI / Worker / Bundle / Tool / Ext
```
- 工作台、路由、业务状态、主题、生态中心继续由现有 `/mqdh` 实现。
- Tauri 壳不实现业务 API、不实现第二套更新器、不做第二个前端。
- Marqdo 运行时仍由 Bootstrap/生态中心按既有发行合同独立安装和升级。
- 浏览器入口与桌面入口共用同一工作台;浏览器入口保留为开发、自部署和诊断路径。
## 2. 源码位置与唯一版本
| 路径 | 责任 |
| --- | --- |
| `src-tauri/` | Tauri 壳:窗口、后端进程生命周期、受限导航、单实例、日志 |
| `src-tauri/tauri.conf.json` | 产品名、bundle identifier、权限、各平台安装器配置 |
| `src-tauri/capabilities/` | 最小 capability(只启用 `core:default`,无 shell/fs/http/process 权限) |
| `scripts/tauri/` | 资源准备、Linux/Windows/macOS 构建、安装器证据附加 |
| `.woodpecker/tauri-linux.yml` | Linux deb 构建与受保护发布 |
| `.woodpecker/tauri-windows.yml` / `tauri-macos.yml` | 原生 Windows/macOS lane(需要对应 label 的 agent) |
产品版本只存在于 `packages/marqdo/harness/package.json`。构建脚本读取该值并通过
`tauri build --config '{"version":"..."}'` 传给打包器;壳的 `--version` 由
`build.rs` 从同一文件嵌入。**不得**在 `tauri.conf.json` 手工维护第二份版本。
## 3. 后端生命周期
```text
桌面启动 → 读取 MQDH_HOME → 定位安装资源树与 runtime/node
→ 以子进程启动 scripts/mqdh.mjs --host 127.0.0.1 --port 0 --no-open
→ 读取既有服务打印的就绪 URL(含一次性 token)
→ 窗口加载 http://127.0.0.1:<port>/...
退出 → 向本实例拥有的进程组发送 SIGTERM(Windows 用 taskkill /T)
→ 超时后 SIGKILL;不触碰用户独立运行的服务或其它实例
```
- 只绑定 loopback,端口由 OS 分配;就绪不是“端口可连接”,而是既有服务自己打印的
带 token URL 出现。
- 就绪超时 120 秒;失败显示可恢复提示并写入 `MQDH_HOME/logs/mqdh-desktop.log`
(token 在写日志前脱敏)。
- 单实例由 `tauri-plugin-single-instance` 保证;第二次启动聚焦并复用已有窗口。
- 默认不常驻后台;关闭窗口即退出本实例拥有的后端进程树。
## 4. 安全边界
- capability 只有 `core:default`;WebView 没有通用 shell、任意文件、任意进程或
sidecar 参数能力。
- 导航只允许 Tauri 本地页和**本实例实际监听**的 `127.0.0.1:<port>`;其它 URL 交给
系统浏览器打开,不在应用内加载。
- 本地服务沿用既有 `/mqdh` 的 token、Origin/Host 与 CSRF 防护;壳不放松这些检查。
- 文稿 HTML/SVG 仍由 View 的只读安全模型渲染;桌面壳不把主动内容当可信代码。
- 模型凭据、私有知识、会话数据继续由现有 `MQDH_HOME` 策略保护,不进入安装资源、
CI 归档或日志。
## 5. 数据目录与迁移
- 安装目录(只读应用资源)与 `MQDH_HOME`(用户数据)严格分离。
- 壳使用与 CLI/portable 启动器**完全相同**的 `MQDH_HOME` 解析顺序:
`MQDH_HOME` 环境变量 → `XDG_DATA_HOME/marqdo-harness` → `~/.local/share/marqdo-harness`。
用户从浏览器/portable 路径迁移到桌面安装后,不需要搬动知识、配置或运行时。
- 覆盖安装、失败安装、卸载默认保留 `MQDH_HOME`;显式清理数据必须另行确认。
## 6. 平台与产物
| 系统 | 目标 | 主产物 | 状态 |
| --- | --- | --- | --- |
| Linux x86_64 | `x86_64-unknown-linux-gnu` | `.deb`(`mqdh-<version>-linux-x86_64.deb`) | 当前可构建;真实安装验收按发布记录 |
| Windows x86_64 | `x86_64-pc-windows-msvc` | NSIS `-setup.exe` | **BLOCKED**:无原生 Windows agent,未产出、未验收 |
| macOS Apple Silicon | `aarch64-apple-darwin` | `.dmg` | **BLOCKED**:无原生 macOS agent 与签名/公证凭据 |
三平台齐全才是一次完整 Epic 发行;在缺少原生 agent 时,允许维护者明确批准的
范围化 Linux Beta 发行,但必须在发行说明和根投影中如实标注缺失平台,不得把
Linux 包装成三平台完成。Windows/macOS 不接受 Wine、交叉编译或模拟窗口作为验收。
## 7. 构建与发布
```sh
# CI(Woodpecker)或等价构建机
pnpm install --frozen-lockfile
pnpm run build
bash scripts/tauri/build-linux.sh # 便携归档 + deb + smoke + 证据附加
node scripts/release.ts --version <v> --source "$(git rev-parse HEAD)" --assets .ci --publish
```
- 安装器构建镜像:`git.cflmy.cn/cflmy/mqdh-tauri-build:0.2.0`(Node 24.22.3 +
Rust 1.100 + WebKitGTK 4.1 + Tauri CLI 2.13.0);由 `scripts/tauri/build-image.sh` 构建/发布。
- `build-linux.sh` 从**同一冻结 SHA** 构建,deb 与 portable 归档来自同一生产树;
对最终 deb 字节执行解包、`--version` 与 `--smoke`(真实启动内置后端并等待就绪)。
- `attach-installers.mjs` 把安装器摘要追加到现有 `mqdh-release.json` /
`release-evidence.json` 的 `installers` 字段;不新建第二套清单。
- 发布只上传同一 SHA 的 CI 产物;安装包与归档不可变,不覆盖已有 tag/资产。
## 8. 更新策略
- 复用现有更新检查:启动后异步检查、期间低频检查、手动检查。
- Tauri 壳**不启用**静默 updater;只展示真实候选、目标平台、渠道、说明与官方下载。
- 用户确认后下载官方安装包并用系统安装器覆盖安装;不自动下载、不自动安装、不强制重启。
- 应用更新与 CLI/Bundle/Tool 更新保持独立事务。
## 9. 明确未完成(不得写成 PASS)
- Windows NSIS 与 macOS DMG:无原生 agent,BLOCKED。
- 安装器代码签名、Apple 公证:无凭据,unsigned;发行说明必须披露。
- 第二次真实发行 A→B 的更新提醒闭环:待第二次真实发行验证。
- 真实模型能力验收沿用 `STATUS.md` 的独立门禁。
+38
View File
@@ -0,0 +1,38 @@
# ADR 0001:以 Tauri 2 作为 MQDH 唯一桌面封装
- 状态:Accepted(2026-12-03)
- 决策来源:[marqdo-app-harness#31](https://git.cflmy.cn/cflmy/marqdo-app-harness/issues/31),维护者批准
- 取代:此前恢复 Electron 独立桌面发行的要求(`apps/desktop` 上游壳不参与 MQDH 产品发行)
## 背景
MQDH 已有唯一 `/mqdh` 工作台和受控本地 Harness 服务,但普通用户仍只能通过
portable 归档、脚本或浏览器启动。此前方案尝试复用上游 Electron 壳并恢复其发行链路,
会形成第二套桌面产品工程,且与“一个工作台、一个产品版本、一套业务实现”的产品决策冲突。
## 决策
1. 使用 **Tauri 2** 作为唯一官方桌面封装,壳内只做窗口、启动/停止后端、受限导航、
单实例、日志与系统安装封装。
2. 不复制 `/mqdh` 页面、不重写业务 API、不把 Harness 改成 Rust。
3. 后端复用既有 Node 生产树:安装包携带预构建树与匹配平台的 Node runtime,
启动 `scripts/mqdh.mjs` 的既有服务。
4. 三平台主产物为 Linux `.deb`、Windows NSIS `.exe`、macOS `.dmg`;三平台由
Woodpecker 同一候选并行构建,原生 agent 不可用时标 BLOCKED。
5. 不恢复 DSH/Electron 桌面发行;上游 `apps/desktop` 代码可按上游同步策略保留,
但不作为 MQDH 产品发行路径。
6. 更新保持“只提醒、不自动安装”;壳内不实现第二套 updater。
7. 复用现有 `mqdh-release.json` / `release-evidence.json`,以追加 `installers`
字段扩展安装器事实,不建立第二套版本表或发布协议。
## 后果
- 安装包体积仍包含预构建 Node 树;后续可单独做生产依赖裁剪,但不改变安装器合同。
- Windows/macOS 真实交付依赖原生构建 agent 与签名/公证凭据;缺失时如实 BLOCKED。
- `src-tauri/` 属于 MQDH 应用仓;主仓只核验、接受和投影,不构建桌面应用。
## 被否决的替代方案
- 恢复 Electron 桌面发行:形成第二套产品工程与第二套发行路径,违背 #31。
- 把 `/mqdh` 重写为 Rust 业务服务:重写既有 Harness 业务,收益不足。
- 仅在 Linux 交叉编译 Windows/macOS 并宣称支持:不是真实目标平台验收,禁止。
+1
View File
@@ -31,6 +31,7 @@ Marqdo Harness(MQDH)是 Marqdo 生态的官方单用户应用:安装并校
| 默认网络出口/代理/离线/审计 | [NETWORK.md](NETWORK.md) | `src/network/` |
| 首次启动、离线与失败处理 | [BOOTSTRAP.md](BOOTSTRAP.md) | `src/bootstrap/` |
| 本地脱敏报告与显式 Issue 提交 | [DIAGNOSTICS.md](DIAGNOSTICS.md) | `src/diagnostics/` |
| 桌面壳、安装器与三平台状态 | [TAURI.md](TAURI.md) | `src-tauri/`、`scripts/tauri/` |
| 平台矩阵、安装布局、更新/回退 | [DISTRIBUTION.md](DISTRIBUTION.md) | `src/distribution/`、`src/release/` |
| 构建、签名、发布与发布后验证 | [RELEASING.md](RELEASING.md) | `scripts/release-manifest.ts`、`scripts/release.ts` |
| 上游远端、同步与许可 | [UPSTREAM.md](UPSTREAM.md) | `scripts/upstream.sh` |
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@marqdo/mqdh-harness",
"version": "0.1.0-beta.1",
"version": "0.2.0-beta.1",
"description": "Marqdo Harness product services: ecosystem transactions, document-native execution, private knowledge and the /mqdh workbench",
"private": true,
"type": "module",
+2 -1
View File
@@ -32,7 +32,8 @@ mkdir -p "$app"
# Copy the prebuilt tree without VCS data or local scratch.
tar -C "$root" -cf - \
--exclude=.git --exclude=.ci --exclude=.integration-work --exclude=.issue-work \
--exclude=.app-verify --exclude=.dsh-build \
--exclude=.app-verify --exclude=.dsh-build --exclude=.scratch --exclude=.build \
--exclude=src-tauri/target --exclude=src-tauri/resources \
--exclude=node_modules/.cache --exclude='*.log' --exclude='*.tsbuildinfo' . | tar -C "$app" -xf -
git rev-parse HEAD > "$app/SOURCE_SHA"
+27 -1
View File
@@ -74,6 +74,32 @@ const uploads = [manifestPath, archivePath, sidecarPath, evidencePath]
if (await stat(join(assets, 'mqdh-release.json.sig')).then(info => info.isFile()).catch(() => false)) {
uploads.push(join(assets, 'mqdh-release.json.sig'))
}
// Official OS installers are additive assets described by the same manifest.
// They are never a second release contract; the root reconcile verifies each
// published byte like the portable archive.
const installerRows = Array.isArray(manifest.installers) ? manifest.installers as Record<string, unknown>[] : []
if (installerRows.length > 0) {
if (manifest.signature !== undefined) throw new Error('signed manifests must be produced after installer attachment')
for (const row of installerRows) {
const name = row.name
const format = row.format
const target = row.target
if (typeof name !== 'string' || typeof format !== 'string' || typeof target !== 'string') {
throw new Error('invalid installer record in manifest')
}
const path = join(assets, name)
const info = await stat(path)
if (!info.isFile() || info.size !== row.size) throw new Error(`installer ${name} size does not match the manifest`)
const bytes = await readFile(path)
const installerDigest = createHash('sha256').update(bytes).digest('hex')
if (installerDigest !== row.sha256) throw new Error(`installer ${name} digest does not match the manifest`)
const installerSidecar = join(assets, `${name}.sha256`)
if (!(await readFile(installerSidecar, 'utf8')).startsWith(installerDigest)) {
throw new Error(`installer ${name} sidecar does not match`)
}
uploads.push(path, installerSidecar)
}
}
for (const path of uploads) {
const info = await stat(path)
if (!info.isFile() || info.size === 0) throw new Error(`missing release asset: ${path}`)
@@ -108,7 +134,7 @@ const release = await call('POST', '/releases', JSON.stringify({
tag_name: tag,
target_commitish: source,
name: `Marqdo Harness ${version}`,
body: `MQDH ${version} for ${String((manifest.platform as Record<string, unknown> | undefined)?.target ?? 'unknown')}.\n\nSource: \`${source}\`\nManifest: \`mqdh-release.json\`\n`,
body: [`MQDH ${version}`, `Platforms: ${(installerRows.length > 0 ? installerRows : String((manifest.platform as Record<string, unknown> | undefined)?.target ?? 'unknown') as unknown as Record<string, unknown>[]).map(row => String(row.target ?? '')).filter(Boolean).join(', ')}`, '', `Source: ${source}`, 'Assets: one portable archive plus the official OS installer(s) described by `mqdh-release.json`; the shell never installs itself.', 'Update discovery is notification-only; no automatic download or install.'].join('\n'),
draft: false,
prerelease: version.includes('-'),
}), 'application/json')
+19
View File
@@ -0,0 +1,19 @@
# MQDH Tauri Linux build image (app-owned; not a shared ecosystem image).
#
# Base is the same Debian 12 / glibc 2.36 line the deb is built on. `debs/` and
# `lists/` are populated by scripts/tauri/build-image.sh from the pinned Debian
# bookworm package set so the image build itself needs no apt network access.
FROM node:24.22.3-bookworm
COPY lists/ /var/lib/apt/lists/
COPY debs/ /tmp/debs/
RUN cp /tmp/debs/*.deb /var/cache/apt/archives/ \
&& apt-get install -y --no-install-recommends --no-download \
libwebkit2gtk-4.1-dev libgtk-3-dev librsvg2-dev libssl-dev \
patchelf pkg-config build-essential file \
&& rm -rf /tmp/debs /var/lib/apt/lists/*
ENV RUSTUP_HOME=/opt/rustup CARGO_HOME=/opt/cargo
RUN curl -sSf --retry 3 https://sh.rustup.rs | sh -s -- -y --profile minimal --default-toolchain 1.100.0 \
&& /opt/cargo/bin/cargo --version
ENV PATH=/opt/cargo/bin:$PATH
RUN npm i -g @tauri-apps/cli@2.13.0 && tauri --version
WORKDIR /work
+74
View File
@@ -0,0 +1,74 @@
#!/usr/bin/env node
/**
* Attach one platform installer to the existing MQDH release manifest/evidence.
*
* The manifest keeps its single `asset` (portable archive) for the existing
* update/discovery consumers and adds an additive `installers` list describing
* official OS installers. The root release contract reads the extra assets from
* the published Release, so this is one contract, not a second version table.
*
* Usage:
* node scripts/tauri/attach-installers.mjs \
* --installer .ci/mqdh-<v>-linux-x86_64.deb --format deb --target x86_64-unknown-linux-gnu
*/
import { createHash } from 'node:crypto'
import { readFile, writeFile, stat } from 'node:fs/promises'
import { basename, join, resolve } from 'node:path'
const outDir = resolve(process.env.MARQDO_CI_OUT ?? '.ci')
const args = process.argv.slice(2)
const installers = []
for (let index = 0; index < args.length; index++) {
const flag = args[index]
const value = args[index + 1]
if (flag === '--installer') {
const path = value
const format = args[index + 2]
const target = args[index + 3]
if (path === undefined || format === undefined || target === undefined
|| format.startsWith('--') || target.startsWith('--')) {
throw new Error('usage: --installer <path> <format> <target>')
}
index += 3
installers.push({ path: resolve(path), format, target })
continue
}
if (flag === '--format' || flag === '--target' || flag === '--path') {
throw new Error('use --installer <path> <format> <target> (one triplet per installer)')
}
}
if (installers.length === 0) throw new Error('at least one --installer is required')
const manifestPath = join(outDir, 'mqdh-release.json')
const evidencePath = join(outDir, 'release-evidence.json')
const manifest = JSON.parse(await readFile(manifestPath, 'utf8'))
const evidence = JSON.parse(await readFile(evidencePath, 'utf8'))
if (manifest.signature !== undefined) {
throw new Error('cannot add installers after the manifest was signed; sign once after packaging')
}
const formatInfo = {
deb: { os: 'linux', arch: 'x64', minimum_os: 'Ubuntu 24.04 / Debian 12 (glibc 2.39)' },
nsis: { os: 'windows', arch: 'x64', minimum_os: 'Windows 10 22H2 / Windows 11 x64' },
dmg: { os: 'macos', arch: 'arm64', minimum_os: 'macOS 11' },
}
const records = []
for (const item of installers) {
const info = formatInfo[item.format]
if (info === undefined) throw new Error(`unsupported installer format: ${item.format}`)
const bytes = await readFile(item.path)
const sha256 = createHash('sha256').update(bytes).digest('hex')
const size = (await stat(item.path)).size
const name = basename(item.path)
records.push({ name, size, sha256, target: item.target, ...info, format: item.format, signature: 'unsigned' })
await writeFile(join(outDir, `${name}.sha256`), `${sha256} ${name}\n`, { mode: 0o644 })
}
manifest.installers = records
await writeFile(manifestPath, `${JSON.stringify(manifest, null, 2)}\n`, { mode: 0o644 })
evidence.installers = records
evidence.unverified = Array.from(new Set([
...(Array.isArray(evidence.unverified) ? evidence.unverified : []),
'installer OS signature/notarization is not configured for this build',
]))
await writeFile(evidencePath, `${JSON.stringify(evidence, null, 2)}\n`, { mode: 0o644 })
process.stdout.write(`${JSON.stringify({ installers: records }, null, 2)}\n`)
+30
View File
@@ -0,0 +1,30 @@
#!/usr/bin/env bash
# Build (and optionally publish) the app-owned Tauri Linux build image.
#
# The image embeds the pinned Debian bookworm package set used to build the
# `.deb`; it is an app build environment, not a shared ecosystem image and not a
# product release. Immutable tag: `git.cflmy.cn/cflmy/mqdh-tauri-build:<version>`.
#
# scripts/tauri/build-image.sh # build only
# scripts/tauri/build-image.sh --push # build + push (needs MARQDO_GIT_TOKEN)
#
# Package inputs: `.build/tauri-image/{debs,lists}` (generated once from a
# bookworm container with `apt-get download`/`apt-get update`; see TAURI.md).
set -euo pipefail
cd "$(dirname "$0")/../.."
root="$PWD"
tag="${MQDH_TAURI_IMAGE_TAG:-0.2.0}"
registry="${MQDH_TAURI_IMAGE_REGISTRY:-git.cflmy.cn/cflmy}"
context="$root/.build/tauri-image"
test -d "$context/debs" || { echo "missing $context/debs" >&2; exit 1; }
test -d "$context/lists" || { echo "missing $context/lists" >&2; exit 1; }
cp scripts/tauri/Dockerfile "$context/Dockerfile"
export DOCKER_CONFIG="${DOCKER_CONFIG:-$root/.build/docker-config}"
docker build -t "mqdh-tauri-build:$tag" -f "$context/Dockerfile" "$context"
docker tag "mqdh-tauri-build:$tag" "$registry/mqdh-tauri-build:$tag"
if [ "${1:-}" = "--push" ]; then
: "${MARQDO_GIT_TOKEN:?set MARQDO_GIT_TOKEN to publish the image}"
echo "$MARQDO_GIT_TOKEN" | docker login "${registry%%/*}" -u "${MARQDO_GIT_USERNAME:-cflmy}" --password-stdin
docker push "$registry/mqdh-tauri-build:$tag"
echo "published $registry/mqdh-tauri-build:$tag"
fi
+51
View File
@@ -0,0 +1,51 @@
#!/usr/bin/env bash
# Build the Linux `.deb` MQDH installer from one frozen source SHA.
#
# Requires the `mqdh-tauri-build` image (Rust 1.100 + WebKitGTK + Tauri CLI) and
# the locked Node workspace already installed/built by the CI lanes.
set -euo pipefail
cd "$(dirname "$0")/../.."
version="$(sed -n 's/.*"version": *"\([^"]*\)".*/\1/p' packages/marqdo/harness/package.json | head -1)"
test -n "$version"
target="x86_64-unknown-linux-gnu"
out="${MARQDO_CI_OUT:-.ci}"
mkdir -p "$out"
archive="$out/marqdo-harness-${version}-${target}.tar.gz"
if [ ! -f "$archive" ]; then
MQDH_PACKAGE_WORK="${MQDH_PACKAGE_WORK:-/tmp/mqdh-package}" bash scripts/package.sh
fi
test -f "$archive"
bash scripts/tauri/prepare-resources.sh
if [ ! -f src-tauri/icons/icon.ico ] || [ ! -f src-tauri/icons/icon.icns ]; then
tauri icon apps/desktop/resources/icon.png --output src-tauri/icons >/dev/null
fi
export MQDH_SOURCE_SHA="$(git rev-parse HEAD)"
# Tauri 2.13 downloads a GStreamer asset plugin at deb bundle time. The app does
# not enable the asset protocol (`app.security.assetProtocol.enable=false`), and
# direct GitHub access is not available in the CI network: fetch any bundler
# asset through the reviewed internal mirror instead.
export TAURI_BUNDLER_TOOLS_GITHUB_MIRROR="${TAURI_BUNDLER_TOOLS_GITHUB_MIRROR:-https://ghproxy.cflmy.top/}"
tauri build --bundles deb --config "{\"version\":\"$version\"}"
deb="$(find src-tauri/target/release/bundle/deb -maxdepth 1 -name '*.deb' | head -1)"
test -n "$deb"
final="$out/mqdh-${version}-linux-x86_64.deb"
cp "$deb" "$final"
node scripts/tauri/attach-installers.mjs --installer "$final" deb "$target"
# Smoke the exact deb bytes: unpack, read the desktop version, start the real
# bundled backend on loopback through the packaged tree, then stop it.
smoke="$(mktemp -d)"
trap 'rm -rf "$smoke"' EXIT
dpkg-deb -x "$final" "$smoke/root"
binary="$(find "$smoke/root" -type f -name mqdh-desktop | head -1)"
test -n "$binary"
"$binary" --version
MQDH_HOME="$smoke/home" "$binary" --smoke
echo "build-linux: OK $final"
ls -l "$final" "$out"/mqdh-release.json "$out"/release-evidence.json
+49
View File
@@ -0,0 +1,49 @@
#!/usr/bin/env bash
# MQDH Tauri macOS DMG build (native macOS only).
#
# Signing/notarization uses the standard Apple Developer ID environment when
# present. Without credentials the build is explicitly unsigned; it is never
# reported as notarized and cannot be a `supported` release by itself.
set -euo pipefail
cd "$(dirname "$0")/../.."
[ "$(uname -s)" = "Darwin" ] || { echo "build-macos.sh requires a native macOS agent" >&2; exit 1; }
version="$(sed -n 's/.*"version": *"\([^"]*\)".*/\1/p' packages/marqdo/harness/package.json | head -1)"
test -n "$version"
target="aarch64-apple-darwin"
out="${MARQDO_CI_OUT:-.ci}"
mkdir -p "$out"
corepack enable
corepack prepare pnpm@11.28.5 --activate
pnpm install --frozen-lockfile
pnpm run build
bash scripts/tauri/stage-tree.sh
if [ ! -f src-tauri/icons/icon.icns ]; then tauri icon apps/desktop/resources/icon.png --output src-tauri/icons >/dev/null; fi
export MQDH_SOURCE_SHA="$(git rev-parse HEAD)"
export CI=true
if [ -n "${APPLE_SIGNING_IDENTITY:-}" ] && [ -n "${APPLE_ID:-}" ] && [ -n "${APPLE_PASSWORD:-}" ] && [ -n "${APPLE_TEAM_ID:-}" ]; then
tauri build --bundles dmg --config "{\"version\":\"$version\"}" --target "$target"
signed=1
else
tauri build --bundles dmg --config "{\"version\":\"$version\"}" --target "$target"
signed=0
echo "build-macos: no Developer ID credentials; building explicitly unsigned" >&2
fi
dmg="$(find src-tauri/target/"$target"/release/bundle/dmg -maxdepth 1 -name '*.dmg' | head -1)"
test -n "$dmg"
final="$out/mqdh-${version}-macos-aarch64.dmg"
cp "$dmg" "$final"
node scripts/tauri/attach-installers.mjs --installer "$final" --format dmg --target "$target"
# Smoke the mounted app on the native host.
mount="$(mktemp -d)"
hdiutil attach -nobrowse -readonly -mountpoint "$mount" "$final" >/dev/null
app="$(find "$mount" -maxdepth 2 -name 'MQDH.app' | head -1)"
test -n "$app"
"$app/Contents/MacOS/mqdh-desktop" --version
MQDH_HOME="$(mktemp -d)" "$app/Contents/MacOS/mqdh-desktop" --smoke
hdiutil detach "$mount" >/dev/null
if [ "$signed" = "1" ]; then
codesign --verify --deep --strict "$app"
spctl --assess --type execute "$app"
fi
echo "build-macos: OK $final (signed=$signed)"
+38
View File
@@ -0,0 +1,38 @@
# MQDH Tauri Windows NSIS build (native Windows only).
#
# Runs on a real Windows build agent, not under Wine and not cross-compiled from
# Linux. Installation/uninstallation smoke must run on a clean Windows target.
$ErrorActionPreference = 'Stop'
if ($env:OS -ne 'Windows_NT') { throw 'build-windows.ps1 requires a native Windows agent' }
if (-not (Get-Command bash -ErrorAction SilentlyContinue)) { throw 'Git Bash is required for the shared staging scripts' }
if (-not (Get-Command node -ErrorAction SilentlyContinue)) { throw 'Node 24 is required' }
if (-not (Get-Command pnpm -ErrorAction SilentlyContinue)) { throw 'pnpm 11 is required' }
$version = (Get-Content packages/marqdo/harness/package.json -Raw | ConvertFrom-Json).version
corepack enable
corepack prepare pnpm@11.28.5 --activate
pnpm install --frozen-lockfile
pnpm run build
bash scripts/tauri/stage-tree.sh
# The shared staging script bundles the POSIX node name; the Windows runtime is node.exe.
if (Test-Path src-tauri/resources/mqdh/runtime/node) {
Move-Item -Force src-tauri/resources/mqdh/runtime/node src-tauri/resources/mqdh/runtime/node.exe
}
if (-not (Test-Path src-tauri/icons/icon.ico)) { tauri icon apps/desktop/resources/icon.png --output src-tauri/icons }
$env:MQDH_SOURCE_SHA = (git rev-parse HEAD)
tauri build --bundles nsis --config "{`"version`":`"$version`"}"
$setup = Get-ChildItem src-tauri/target/release/bundle/nsis -Filter '*.exe' | Select-Object -First 1
if (-not $setup) { throw 'NSIS installer was not produced' }
New-Item -ItemType Directory -Force .ci | Out-Null
$final = ".ci/mqdh-$version-windows-x86_64-setup.exe"
Copy-Item $setup.FullName $final
node scripts/tauri/attach-installers.mjs --installer $final --format nsis --target x86_64-pc-windows-msvc
& $final /S
$installed = Join-Path $env:LOCALAPPDATA 'MQDH\MQDH.exe'
if (-not (Test-Path $installed)) { throw "per-user NSIS install not found: $installed" }
& $installed --version
$home = Join-Path $env:TEMP ("mqdh-smoke-" + [guid]::NewGuid())
$env:MQDH_HOME = $home
& $installed --smoke
if (Test-Path $installed) { & (Join-Path $env:LOCALAPPDATA 'MQDH\uninstall.exe') /S }
Write-Output "build-windows: OK $final"
+29
View File
@@ -0,0 +1,29 @@
#!/usr/bin/env bash
# Stage the verified portable tree as one Tauri resource archive.
#
# Tauri's Linux deb walker drops symlinks, and a pnpm `node_modules` tree is
# built from symlinks. Shipping the cold-install-verified `.tar.gz` as a single
# resource keeps the exact verified tree (symlinks intact) and lets the shell
# extract it once into `MQDH_HOME/runtime` on first start.
set -euo pipefail
cd "$(dirname "$0")/../.."
version="$(sed -n 's/.*"version": *"\([^"]*\)".*/\1/p' packages/marqdo/harness/package.json | head -1)"
test -n "$version"
archive="${1:-.ci/marqdo-harness-${version}-x86_64-unknown-linux-gnu.tar.gz}"
test -f "$archive" || { echo "prepare-resources: missing $archive; run scripts/package.sh first" >&2; exit 1; }
resources="src-tauri/resources"
rm -rf "$resources"
mkdir -p "$resources"
cp "$archive" "$resources/mqdh-runtime.tar.gz"
# The archive must contain the launcher, built CLI and web entries plus the
# Node runtime; this is the same tree scripts/package.sh cold-installed. Write
# the listing once: `tar | grep -q` would trip pipefail via SIGPIPE.
listing="$(mktemp)"
trap 'rm -f "$listing"' EXIT
tar -tzf "$resources/mqdh-runtime.tar.gz" > "$listing"
grep -qE '^[^/]+/scripts/mqdh\.mjs$' "$listing"
grep -qE '^[^/]+/runtime/node$' "$listing"
grep -qE '^[^/]+/apps/web/dist/index\.html$' "$listing"
ls -lh "$resources/mqdh-runtime.tar.gz"
echo "prepare-resources: OK $resources/mqdh-runtime.tar.gz"
+27
View File
@@ -0,0 +1,27 @@
#!/usr/bin/env bash
# Stage the production MQDH tree for a native Tauri build on Windows/macOS.
#
# Linux reuses the cold-install-verified archive from scripts/package.sh; the
# native lanes stage the same repository content and the platform Node runtime,
# because the portable archive and install.sh are POSIX-only conveniences.
set -euo pipefail
cd "$(dirname "$0")/../.."
root="$PWD"
resources="src-tauri/resources"
rm -rf "$resources"
mkdir -p "$resources/mqdh"
tar -C "$root" -cf - \
--exclude=.git --exclude=.ci --exclude=.build --exclude=.scratch \
--exclude=.issue-work --exclude=.app-verify --exclude=.integration-work \
--exclude=node_modules/.cache --exclude='*.log' --exclude='*.tsbuildinfo' \
--exclude=src-tauri/target --exclude=src-tauri/resources . \
| tar -C "$resources/mqdh" -xf -
git rev-parse HEAD > "$resources/mqdh/SOURCE_SHA"
mkdir -p "$resources/mqdh/runtime"
node_binary="$(command -v node)"
cp "$node_binary" "$resources/mqdh/runtime/node"
"$resources/mqdh/runtime/node" --version > "$resources/mqdh/runtime/VERSION"
test -f "$resources/mqdh/scripts/mqdh.mjs"
test -f "$resources/mqdh/apps/cli/lib/bin.js"
test -f "$resources/mqdh/apps/web/dist/index.html"
echo "stage-tree: OK $resources/mqdh"
+4751
View File
File diff suppressed because it is too large. Load diff
+29
View File
@@ -0,0 +1,29 @@
[package]
name = "mqdh-desktop"
version = "0.0.0"
description = "MQDH Tauri desktop shell for the existing Marqdo Harness workbench"
edition = "2021"
publish = false
[build-dependencies]
tauri-build = { version = "2", features = [] }
[dependencies]
tauri = { version = "2", features = [] }
tauri-plugin-single-instance = "2"
serde = { version = "1", features = ["derive"] }
serde_json = "1"
dirs = "6"
open = "5"
flate2 = "1"
tar = "0.4"
[target.'cfg(unix)'.dependencies]
libc = "0.2"
[profile.release]
codegen-units = 1
lto = true
opt-level = "s"
panic = "abort"
strip = true
+24
View File
@@ -0,0 +1,24 @@
//! Tauri build glue.
//!
//! The product version is owned by `packages/marqdo/harness/package.json`; it
//! is embedded here only as a diagnostic (`--version`) value. The bundle
//! version is supplied by `scripts/tauri/build-linux.sh` through `--config`,
//! so there is no second version authority to maintain.
use std::{env, fs, path::Path};
fn main() {
let manifest = Path::new("../packages/marqdo/harness/package.json");
println!("cargo:rerun-if-changed={}", manifest.display());
let text = fs::read_to_string(manifest).expect("read packages/marqdo/harness/package.json");
let version = text
.split("\"version\"")
.nth(1)
.and_then(|rest| rest.split('"').nth(1))
.expect("product manifest has no version");
assert!(!version.is_empty(), "product version is empty");
println!("cargo:rustc-env=MQDH_PRODUCT_VERSION={version}");
if let Ok(source) = env::var("MQDH_SOURCE_SHA") {
println!("cargo:rustc-env=MQDH_EMBEDDED_SOURCE_SHA={source}");
}
tauri_build::build();
}
+7
View File
@@ -0,0 +1,7 @@
{
"$schema": "../gen/schemas/desktop-schema.json",
"identifier": "default",
"description": "The MQDH shell exposes only Tauri core defaults. It has no shell, filesystem, HTTP or process permissions; the backend is started and supervised by the Rust layer.",
"windows": ["main"],
"permissions": ["core:default"]
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.
Binary file not shown.

After

Width:  |  Height:  |  Size: 43 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 98 KiB

+557
View File
@@ -0,0 +1,557 @@
//! MQDH desktop shell (Tauri 2).
//!
//! This crate contains desktop adaptation only. The product UI, routes,
//! business state and Harness service stay in the existing MQDH workbench. The
//! shell:
//!
//! 1. resolves the bundled, prebuilt MQDH tree and its Node runtime;
//! 2. starts the existing `scripts/mqdh.mjs` launcher on loopback with an
//! OS-assigned port;
//! 3. waits for the readiness line printed by the existing DSH web server and
//! loads the one workbench URL in the system WebView;
//! 4. closes only the process tree it started.
//!
//! There is no generic shell/process/filesystem IPC: the WebView can only
//! navigate inside the local origin this process started. No updater lives in
//! the shell; update discovery remains in the existing MQDH distribution code.
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]
use std::fs::{self, File, OpenOptions};
use std::io::{BufRead, BufReader, Write};
use std::path::{Path, PathBuf};
use std::process::{Child, Command, Stdio};
use std::sync::atomic::{AtomicU16, Ordering};
use std::sync::mpsc;
use std::sync::{Arc, Mutex};
use std::time::{Duration, Instant};
use flate2::read::GzDecoder;
use tar::Archive;
use tauri::{Manager, RunEvent, Url, WebviewUrl, WebviewWindowBuilder};
/// Product version embedded from the package manifest at compile time.
const VERSION: &str = env!("MQDH_PRODUCT_VERSION");
/// Source SHA embedded by the release build when available.
const SOURCE_SHA: &str = match option_env!("MQDH_EMBEDDED_SOURCE_SHA") {
Some(value) => value,
None => "",
};
/// Loopback host used by the existing MQDH launcher.
const LOOPBACK: &str = "127.0.0.1";
/// Readiness budget for a cold first start (resource extraction, profile setup).
const READY_TIMEOUT: Duration = Duration::from_secs(120);
/// One owned backend process tree.
struct ShellState {
child: Mutex<Option<Child>>,
port: AtomicU16,
home: PathBuf,
tree: PathBuf,
}
impl ShellState {
/// Stop only the process tree this shell started, never unrelated services.
fn stop(&self) {
let Some(mut child) = self.child.lock().ok().and_then(|mut guard| guard.take()) else {
return;
};
#[cfg(unix)]
{
let pid = child.id() as i32;
// The child was started as its own process group, so the negative
// pid targets the launcher and every descendant it owns.
unsafe { libc::kill(-pid, libc::SIGTERM) };
let deadline = Instant::now() + Duration::from_secs(8);
while Instant::now() < deadline {
if matches!(child.try_wait(), Ok(Some(_))) {
return;
}
std::thread::sleep(Duration::from_millis(100));
}
unsafe { libc::kill(-pid, libc::SIGKILL) };
let _ = child.wait();
}
#[cfg(windows)]
{
let _ = Command::new("taskkill")
.args(["/PID", &child.id().to_string(), "/T", "/F"])
.output();
let _ = child.kill();
let _ = child.wait();
}
#[cfg(not(any(unix, windows)))]
{
let _ = child.kill();
let _ = child.wait();
}
}
}
impl Drop for ShellState {
fn drop(&mut self) {
self.stop();
}
}
/// Redact the readiness token before persisting diagnostics.
fn redact(line: &str) -> String {
let mut value = line.to_string();
if let Some(index) = value.find("token=") {
let start = index + "token=".len();
let end = value[start..]
.find(|character: char| character == '&' || character.is_whitespace())
.map(|offset| start + offset)
.unwrap_or(value.len());
value.replace_range(start..end, "<redacted>");
}
value
}
/// Append one line to the shell log; never fail startup because logging failed.
fn log_line(home: &Path, message: &str) {
let directory = home.join("logs");
if fs::create_dir_all(&directory).is_err() {
return;
}
let line = format!(
"{} {} {}\n",
chrono_like_now(),
if SOURCE_SHA.is_empty() { "-" } else { SOURCE_SHA },
redact(message)
);
if let Ok(mut file) = OpenOptions::new().create(true).append(true).open(directory.join("mqdh-desktop.log")) {
let _ = file.write_all(line.as_bytes());
}
}
/// UTC timestamp without pulling a date-time dependency into the shell.
fn chrono_like_now() -> String {
let seconds = std::time::SystemTime::now()
.duration_since(std::time::UNIX_EPOCH)
.map(|duration| duration.as_secs())
.unwrap_or(0);
format!("unix:{seconds}")
}
/// Resolve the same `MQDH_HOME` the CLI and the portable launch use, so an
/// existing user keeps their knowledge, configuration and runtime.
fn resolve_home() -> PathBuf {
if let Some(value) = std::env::var_os("MQDH_HOME") {
if !value.is_empty() {
return PathBuf::from(value);
}
}
if let Some(value) = std::env::var_os("XDG_DATA_HOME") {
if !value.is_empty() {
return PathBuf::from(value).join("marqdo-harness");
}
}
if let Some(home) = dirs::home_dir() {
return home.join(".local").join("share").join("marqdo-harness");
}
PathBuf::from(".mqdh")
}
/// Extract the verified portable tree into the user data directory once.
///
/// Tauri's Linux deb walker drops symlinks, and the pnpm `node_modules` tree is
/// symlink-based. The installer therefore ships the cold-install-verified
/// `.tar.gz` as one resource and the shell materialises it here, preserving the
/// exact bytes and symlinks. Later starts reuse the completed tree.
fn ensure_runtime(archive: &Path, home: &Path) -> Result<(PathBuf, PathBuf), String> {
let root = home.join("runtime");
let tree = root.join("mqdh");
let node_name = if cfg!(windows) { "node.exe" } else { "node" };
let marked = tree.join(".complete");
if marked.is_file()
&& tree.join("scripts").join("mqdh.mjs").is_file()
&& tree.join("runtime").join(node_name).is_file()
{
return Ok((tree.clone(), tree.join("runtime").join(node_name)));
}
fs::create_dir_all(&root).map_err(|error| format!("cannot create {}: {error}", root.display()))?;
let temporary = root.join(format!("extract-{}", std::process::id()));
let _ = fs::remove_dir_all(&temporary);
fs::create_dir_all(&temporary).map_err(|error| format!("cannot create extraction dir: {error}"))?;
log_line(home, &format!("runtime: extracting {}", archive.display()));
let file = File::open(archive).map_err(|error| format!("cannot open {}: {error}", archive.display()))?;
let mut bundle = Archive::new(GzDecoder::new(file));
let entries = bundle.entries().map_err(|error| format!("cannot read runtime archive: {error}"))?;
for entry in entries {
let mut entry = entry.map_err(|error| format!("cannot read runtime entry: {error}"))?;
let path = entry.path().map_err(|error| format!("invalid runtime entry path: {error}"))?.to_path_buf();
if path.is_absolute()
|| path.components().any(|component| matches!(component, std::path::Component::ParentDir))
{
return Err(format!("runtime archive contains an unsafe path: {}", path.display()));
}
entry
.unpack_in(&temporary)
.map_err(|error| format!("cannot unpack {}: {error}", path.display()))?;
}
let top = fs::read_dir(&temporary)
.map_err(|error| format!("cannot inspect extraction dir: {error}"))?
.filter_map(Result::ok)
.find(|entry| entry.path().is_dir())
.map(|entry| entry.path())
.ok_or_else(|| "runtime archive has no tree directory".to_string())?;
let _ = fs::remove_dir_all(&tree);
fs::rename(&top, &tree).map_err(|error| format!("cannot activate runtime tree: {error}"))?;
let _ = fs::remove_dir_all(&temporary);
let node = tree.join("runtime").join(node_name);
#[cfg(unix)]
{
use std::os::unix::fs::PermissionsExt;
if let Ok(metadata) = fs::metadata(&node) {
let mut permissions = metadata.permissions();
permissions.set_mode(0o755);
let _ = fs::set_permissions(&node, permissions);
}
}
fs::write(&marked, b"ok\n").map_err(|error| format!("cannot mark runtime tree: {error}"))?;
if !tree.join("scripts").join("mqdh.mjs").is_file() || !node.is_file() {
return Err("extracted runtime tree is incomplete".to_string());
}
log_line(home, &format!("runtime: ready {}", tree.display()));
Ok((tree, node))
}
/// Locate a bundled runtime archive beside the executable (deb/windows layout).
fn resolve_runtime(home: &Path, app: Option<&tauri::AppHandle>, executable: &Path) -> Result<(PathBuf, PathBuf), String> {
if let Some(value) = std::env::var_os("MQDH_TAURI_TREE") {
let tree = PathBuf::from(value);
let node = if cfg!(windows) { tree.join("runtime").join("node.exe") } else { tree.join("runtime").join("node") };
if tree.join("scripts").join("mqdh.mjs").is_file() && node.is_file() {
return Ok((tree, node));
}
}
let mut archives: Vec<PathBuf> = Vec::new();
if let Some(app) = app {
if let Ok(resource) = app.path().resource_dir() {
archives.push(resource.join("mqdh-runtime.tar.gz"));
}
}
if let Some(value) = std::env::var_os("MQDH_TAURI_RUNTIME_ARCHIVE") {
archives.push(PathBuf::from(value));
}
if let Some(directory) = executable.parent() {
archives.push(directory.join("..").join("lib").join("MQDH").join("mqdh-runtime.tar.gz"));
archives.push(directory.join("resources").join("mqdh-runtime.tar.gz"));
}
archives.push(PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("resources").join("mqdh-runtime.tar.gz"));
for archive in archives {
if archive.is_file() {
return ensure_runtime(&archive, home);
}
}
Err("bundled MQDH runtime archive is missing from the installation".to_string())
}
/// Locate the local workbench URL in the launcher's readiness output.
fn extract_url(line: &str) -> Option<String> {
let marker = format!("http://{LOOPBACK}:");
let start = line.find(&marker)?;
let tail = line.get(start..)?;
let end = tail
.find(|character: char| character.is_whitespace())
.unwrap_or(tail.len());
let url = tail.get(..end)?.trim();
if url.contains("token=") {
Some(url.to_string())
} else {
None
}
}
/// Build the backend command with the existing launcher and product home.
fn backend_command(node: &Path, tree: &Path, home: &Path) -> Command {
let script = tree.join("scripts").join("mqdh.mjs");
let mut command = Command::new(node);
command
.arg(script)
.arg("--host")
.arg(LOOPBACK)
.arg("--port")
.arg("0")
.arg("--no-open")
.current_dir(tree)
.env("MQDH_HOME", home)
.env("MQDH_TAURI", "1")
.stdin(Stdio::null())
.stdout(Stdio::piped())
.stderr(Stdio::piped());
#[cfg(unix)]
{
use std::os::unix::process::CommandExt;
command.process_group(0);
}
#[cfg(windows)]
{
use std::os::windows::process::CommandExt;
// CREATE_NO_WINDOW: the launcher is a helper, not a user-facing console.
command.creation_flags(0x08000000);
}
command
}
/// Render a static startup error inside the window without a second page build.
fn show_error(window: &tauri::WebviewWindow, detail: &str) {
let escaped = serde_json::to_string(detail).unwrap_or_else(|_| "\"启动失败\"".to_string());
let script = format!(
"document.body.innerHTML = '<main style=\"max-width:36rem;padding:2rem;font:14px/1.7 system-ui,sans-serif\"><h1 style=\"font-size:1.15rem\">MQDH 未能启动本地工作台</h1><p>本地 Harness 服务启动超时或异常退出。应用只使用本机回环服务。</p><p style=\"opacity:.7\">请退出后重新打开;诊断日志位于用户数据目录的 logs/mqdh-desktop.log。</p><p style=\"opacity:.5;font-size:.85em\"></p></main>'; document.querySelector('p:last-child').textContent = {escaped};"
);
let _ = window.eval(&script);
}
/// Test-only smoke: start the real bundled backend through the packaged tree
/// without creating a window, so CI can prove resources + launcher + readiness
/// on a headless Linux host. It never connects to a non-loopback origin.
fn run_smoke() -> ! {
let home = resolve_home();
let _ = fs::create_dir_all(&home);
let exe = std::env::current_exe().unwrap_or_else(|_| PathBuf::from("mqdh-desktop"));
let (tree, node) = match resolve_runtime(&home, None, &exe) {
Ok(value) => value,
Err(error) => {
eprintln!("mqdh-desktop-smoke: FAIL {error}");
std::process::exit(1);
}
};
log_line(&home, &format!("smoke: tree={} version={VERSION}", tree.display()));
let mut command = backend_command(&node, &tree, &home);
let mut child = match command.spawn() {
Ok(child) => child,
Err(error) => {
eprintln!("mqdh-desktop-smoke: FAIL spawn {error}");
std::process::exit(1);
}
};
let Some(stdout) = child.stdout.take() else {
eprintln!("mqdh-desktop-smoke: FAIL no backend stdout");
let _ = child.kill();
std::process::exit(1);
};
let (ready_tx, ready_rx) = mpsc::channel::<u16>();
std::thread::spawn(move || {
let reader = BufReader::new(stdout);
for line in reader.lines().map_while(Result::ok) {
if let Some(url) = extract_url(&line) {
if let Ok(parsed) = Url::parse(&url) {
if let Some(port) = parsed.port() {
let _ = ready_tx.send(port);
return;
}
}
}
}
});
match ready_rx.recv_timeout(READY_TIMEOUT) {
Ok(port) => {
println!("mqdh-desktop-smoke: ready origin=http://{LOOPBACK}:{port}");
let pid = child.id() as i32;
#[cfg(unix)]
unsafe { libc::kill(-pid, libc::SIGTERM) };
#[cfg(windows)]
{
let _ = Command::new("taskkill").args(["/PID", &pid.to_string(), "/T", "/F"]).output();
}
let deadline = Instant::now() + Duration::from_secs(8);
while Instant::now() < deadline {
if matches!(child.try_wait(), Ok(Some(_))) {
break;
}
std::thread::sleep(Duration::from_millis(100));
}
std::process::exit(0);
}
Err(_) => {
log_line(&home, "smoke: readiness timeout");
eprintln!("mqdh-desktop-smoke: FAIL readiness timeout");
let _ = child.kill();
std::process::exit(1);
}
}
}
fn main() {
let arguments: Vec<String> = std::env::args().skip(1).collect();
if arguments.iter().any(|argument| argument == "--version" || argument == "-V") {
println!("mqdh {VERSION}");
return;
}
if arguments.iter().any(|argument| argument == "--smoke") {
run_smoke();
}
// Window startup never handles smoke; the branch is kept false so the
// shared setup below has one code path.
let smoke = false;
let builder = tauri::Builder::default().plugin(tauri_plugin_single_instance::init(|app, _argv, _cwd| {
if let Some(window) = app.get_webview_window("main") {
let _ = window.show();
let _ = window.unminimize();
let _ = window.set_focus();
}
}));
let app = builder
.setup(move |app| {
let home = resolve_home();
let executable = std::env::current_exe().unwrap_or_else(|_| PathBuf::from("mqdh-desktop"));
let (tree, node) = match resolve_runtime(&home, Some(app.handle()), &executable) {
Ok(value) => value,
Err(error) => {
log_line(&home, &format!("startup: {error}"));
if smoke {
eprintln!("mqdh-desktop-smoke: FAIL {error}");
std::process::exit(1);
}
return Err(std::io::Error::new(std::io::ErrorKind::Other, error).into());
}
};
if let Err(error) = fs::create_dir_all(&home) {
return Err(std::io::Error::new(std::io::ErrorKind::Other, format!("cannot create MQDH_HOME {}: {error}", home.display())).into());
}
let state = Arc::new(ShellState {
child: Mutex::new(None),
port: AtomicU16::new(0),
home: home.clone(),
tree: tree.clone(),
});
app.manage(state.clone());
log_line(
&home,
&format!("startup: version={VERSION} tree={} node={}", tree.display(), node.display()),
);
let mut command = backend_command(&node, &tree, &home);
let mut child = match command.spawn() {
Ok(child) => child,
Err(error) => {
log_line(&home, &format!("spawn failed: {error}"));
if smoke {
eprintln!("mqdh-desktop-smoke: FAIL spawn {error}");
std::process::exit(1);
}
return Err(std::io::Error::new(std::io::ErrorKind::Other, format!("cannot start the MQDH backend: {error}")).into());
}
};
let stdout = child.stdout.take();
let stderr = child.stderr.take();
*state.child.lock().expect("backend mutex") = Some(child);
let (ready_tx, ready_rx) = mpsc::channel::<String>();
let state_for_stdout = state.clone();
if let Some(stdout) = stdout {
std::thread::spawn(move || {
let reader = BufReader::new(stdout);
for line in reader.lines() {
let Ok(line) = line else { break };
let home = state_for_stdout.home.clone();
log_line(&home, &format!("backend: {line}"));
if let Some(url) = extract_url(&line) {
if let Ok(parsed) = Url::parse(&url) {
if let Some(port) = parsed.port() {
state_for_stdout.port.store(port, Ordering::SeqCst);
log_line(&home, &format!("ready: origin=http://{LOOPBACK}:{port}"));
let _ = ready_tx.send(url);
return;
}
}
}
}
});
}
let state_for_stderr = state.clone();
if let Some(stderr) = stderr {
std::thread::spawn(move || {
let reader = BufReader::new(stderr);
for line in reader.lines().map_while(Result::ok) {
log_line(&state_for_stderr.home, &format!("backend stderr: {line}"));
}
});
}
if smoke {
let state = state.clone();
std::thread::spawn(move || match ready_rx.recv_timeout(READY_TIMEOUT) {
Ok(_url) => {
println!("mqdh-desktop-smoke: ready origin=http://{LOOPBACK}:{}", state.port.load(Ordering::SeqCst));
state.stop();
std::process::exit(0);
}
Err(_) => {
log_line(&state.home, "smoke: readiness timeout");
eprintln!("mqdh-desktop-smoke: FAIL readiness timeout");
state.stop();
std::process::exit(1);
}
});
return Ok(());
}
let navigation_state = state.clone();
let window = WebviewWindowBuilder::new(app, "main", WebviewUrl::App("ui/index.html".into()))
.title("MQDH")
.inner_size(1280.0, 860.0)
.min_inner_size(760.0, 560.0)
.center()
.on_navigation(move |url| {
let allowed = match url.scheme() {
"tauri" => true,
"about" => true,
"http" | "https" => {
let host = url.host_str().unwrap_or_default();
let port = url.port().unwrap_or(0);
(host == LOOPBACK && port != 0 && port == navigation_state.port.load(Ordering::SeqCst))
|| host == "tauri.localhost"
}
_ => false,
};
if !allowed {
let _ = open::that(url.as_str());
log_line(&navigation_state.home, &format!("blocked navigation: {url}"));
}
allowed
})
.build()?;
let window_for_ready = window.clone();
let state_for_ready = state.clone();
std::thread::spawn(move || {
match ready_rx.recv_timeout(READY_TIMEOUT) {
Ok(url) => {
let json = serde_json::to_string(&url).unwrap_or_default();
let script = format!("window.location.replace({json});");
let _ = window_for_ready.eval(&script);
}
Err(_) => {
log_line(&state_for_ready.home, "startup: readiness timeout");
show_error(&window_for_ready, "本地服务在 120 秒内未就绪");
}
}
});
Ok(())
})
.build(tauri::generate_context!())
.expect("error while building the MQDH desktop shell");
app.run(|app_handle, event| {
if let RunEvent::ExitRequested { .. } = event {
if let Some(state) = app_handle.try_state::<Arc<ShellState>>() {
state.stop();
}
}
if let RunEvent::Exit = event {
if let Some(state) = app_handle.try_state::<Arc<ShellState>>() {
state.stop();
}
}
});
}
+55
View File
@@ -0,0 +1,55 @@
{
"$schema": "https://schema.tauri.app/config/2",
"productName": "MQDH",
"version": "0.0.0",
"identifier": "cn.cflmy.mqdh",
"build": {
"frontendDist": "ui"
},
"app": {
"windows": [],
"security": {
"csp": "default-src 'self'; script-src 'self'; style-src 'self' 'unsafe-inline'; img-src 'self' data:",
"assetProtocol": {
"enable": false
}
}
},
"bundle": {
"active": true,
"targets": [
"deb"
],
"icon": [
"icons/32x32.png",
"icons/128x128.png",
"icons/128x128@2x.png",
"icons/icon.icns",
"icons/icon.ico"
],
"resources": {
"resources/mqdh-runtime.tar.gz": "mqdh-runtime.tar.gz"
},
"category": "Productivity",
"shortDescription": "Marqdo Harness workbench",
"longDescription": "MQDH is the Marqdo desktop workbench for reproducible Markdown documents and Marqdo computation. It reuses the existing /mqdh web workbench and the independently released Marqdo runtime.",
"linux": {
"deb": {
"depends": [
"libwebkit2gtk-4.1-0",
"libgtk-3-0"
]
}
},
"windows": {
"nsis": {
"installMode": "currentUser",
"displayLanguageSelector": false,
"installerIcon": "icons/icon.ico"
}
},
"macOS": {
"minimumSystemVersion": "11.0"
}
}
}
+28
View File
@@ -0,0 +1,28 @@
<!doctype html>
<html lang="zh-CN">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>MQDH 启动失败</title>
<style>
:root { color-scheme: light dark; }
html, body { height: 100%; margin: 0; }
body { display: grid; place-items: center; font: 14px/1.7 system-ui, sans-serif; background: Canvas; color: CanvasText; }
main { max-width: 36rem; padding: 2rem; }
h1 { font-size: 1.15rem; margin: 0 0 .75rem; }
p, li { opacity: .8; }
code { font-size: .85em; }
</style>
</head>
<body>
<main>
<h1>MQDH 未能启动本地工作台</h1>
<p>可能是本地服务启动超时或后端异常退出。应用只使用本机 loopback 服务,不会连接外部页面。</p>
<ul>
<li>确认没有其它程序阻止本机回环端口;</li>
<li>退出后重新打开 MQDH;</li>
<li>查看用户数据目录下的 <code>logs/mqdh-desktop.log</code>(其中不含会话令牌)。</li>
</ul>
</main>
</body>
</html>
+22
View File
@@ -0,0 +1,22 @@
<!doctype html>
<html lang="zh-CN">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>MQDH</title>
<style>
:root { color-scheme: light dark; }
html, body { height: 100%; margin: 0; }
body { display: grid; place-items: center; font: 14px/1.6 system-ui, sans-serif; background: Canvas; color: CanvasText; }
main { max-width: 32rem; padding: 2rem; text-align: center; }
h1 { font-size: 1.25rem; margin: 0 0 .5rem; }
p { margin: 0; opacity: .72; }
</style>
</head>
<body>
<main>
<h1>MQDH 正在启动工作台…</h1>
<p>本地 Harness 服务就绪后会自动打开。若长时间无响应,请退出后重新打开,或查看用户数据目录下的 logs/mqdh-desktop.log。</p>
</main>
</body>
</html>