refactor: use Electron instead of Tauri

This commit is contained in:
Acbox
2026-04-24 21:08:30 +08:00
parent e4aca0db13
commit f18f9a7231
86 changed files with 2159 additions and 5981 deletions
+64
View File
@@ -0,0 +1,64 @@
name: Electron CI
on:
push:
branches: ["main"]
paths:
- "apps/desktop/**"
- "apps/web/**"
- "packages/**"
- "pnpm-lock.yaml"
- ".github/workflows/electron-ci.yml"
pull_request:
branches: ["main"]
paths:
- "apps/desktop/**"
- "apps/web/**"
- "packages/**"
- "pnpm-lock.yaml"
- ".github/workflows/electron-ci.yml"
workflow_dispatch:
permissions:
contents: read
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
build:
name: Build (${{ matrix.platform }})
strategy:
fail-fast: false
matrix:
include:
- platform: macos-latest
- platform: ubuntu-22.04
- platform: windows-latest
runs-on: ${{ matrix.platform }}
timeout-minutes: 45
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v4
with:
version: 10
- uses: actions/setup-node@v4
with:
node-version: lts/*
cache: pnpm
- name: Install JS dependencies
run: pnpm install --frozen-lockfile
- name: Typecheck desktop
run: pnpm --filter @memohai/desktop typecheck
- name: Build desktop (unpacked smoke)
env:
CSC_IDENTITY_AUTO_DISCOVERY: "false"
run: pnpm --filter @memohai/desktop build:dir
+28 -74
View File
@@ -129,7 +129,7 @@ jobs:
gh release upload "$TAG_NAME" "${files[@]}" --clobber --repo "$GH_REPO"
desktop-build:
name: Build desktop ${{ matrix.target }}
name: Build desktop (${{ matrix.platform }})
runs-on: ${{ matrix.platform }}
timeout-minutes: 60
strategy:
@@ -137,19 +137,17 @@ jobs:
matrix:
include:
- platform: macos-latest
target: aarch64-apple-darwin
- platform: macos-latest
target: x86_64-apple-darwin
build_cmd: build:mac
- platform: ubuntu-22.04
target: x86_64-unknown-linux-gnu
build_cmd: build:linux
- platform: windows-latest
target: x86_64-pc-windows-msvc
build_cmd: build:win
env:
APPLE_CERTIFICATE: ${{ secrets.APPLE_CERTIFICATE }}
APPLE_CERTIFICATE_PASSWORD: ${{ secrets.APPLE_CERTIFICATE_PASSWORD }}
steps:
- uses: actions/checkout@v4
- name: Sync desktop version files
- name: Sync desktop version
shell: bash
run: |
set -euo pipefail
@@ -159,21 +157,9 @@ jobs:
const fs = require('fs');
const version = process.env.VERSION;
const packageJsonPath = 'apps/desktop/package.json';
const tauriConfPath = 'apps/desktop/src-tauri/tauri.conf.json';
const cargoTomlPath = 'apps/desktop/src-tauri/Cargo.toml';
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'));
packageJson.version = version;
fs.writeFileSync(packageJsonPath, `${JSON.stringify(packageJson, null, 2)}\n`);
const tauriConf = JSON.parse(fs.readFileSync(tauriConfPath, 'utf8'));
tauriConf.version = version;
fs.writeFileSync(tauriConfPath, `${JSON.stringify(tauriConf, null, 2)}\n`);
const cargoToml = fs
.readFileSync(cargoTomlPath, 'utf8')
.replace(/^version = ".*"$/m, `version = "${version}"`);
fs.writeFileSync(cargoTomlPath, cargoToml);
EOF
- uses: pnpm/action-setup@v4
with:
@@ -182,31 +168,15 @@ jobs:
with:
node-version: lts/*
cache: pnpm
- name: Install Rust stable
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- name: Rust cache
uses: swatinem/rust-cache@v2
with:
workspaces: apps/desktop/src-tauri -> target
- name: Install Linux dependencies
if: matrix.platform == 'ubuntu-22.04'
run: |
sudo apt-get update
sudo apt-get install -y \
libwebkit2gtk-4.1-dev \
libappindicator3-dev \
librsvg2-dev \
patchelf
- name: Install JS dependencies
run: pnpm install --frozen-lockfile
- name: Prepare macOS code signing
id: mac-signing
if: ${{ matrix.platform == 'macos-latest' && env.APPLE_CERTIFICATE != '' && env.APPLE_CERTIFICATE_PASSWORD != '' }}
shell: bash
run: |
set -euo pipefail
KEYCHAIN_PASSWORD="github-actions-${GITHUB_RUN_ID}-${GITHUB_RUN_ATTEMPT:-1}"
CSC_PATH="$RUNNER_TEMP/certificate.p12"
python3 - <<'EOF'
import base64
import os
@@ -215,46 +185,29 @@ jobs:
target = Path(os.environ["RUNNER_TEMP"]) / "certificate.p12"
target.write_bytes(base64.b64decode(os.environ["APPLE_CERTIFICATE"]))
EOF
security create-keychain -p "$KEYCHAIN_PASSWORD" build.keychain
security default-keychain -s build.keychain
security unlock-keychain -p "$KEYCHAIN_PASSWORD" build.keychain
security set-keychain-settings -t 3600 -u build.keychain
security import "$RUNNER_TEMP/certificate.p12" -k build.keychain -P "$APPLE_CERTIFICATE_PASSWORD" -T /usr/bin/codesign
security set-key-partition-list -S apple-tool:,apple:,codesign: -s -k "$KEYCHAIN_PASSWORD" build.keychain
curl -fsSL -o "$RUNNER_TEMP/DeveloperIDG2CA.cer" https://www.apple.com/certificateauthority/DeveloperIDG2CA.cer
security add-certificates -k build.keychain "$RUNNER_TEMP/DeveloperIDG2CA.cer"
security find-identity -v -p codesigning build.keychain
IDENTITY=$(security find-identity -v -p codesigning build.keychain | awk -F'"' '/Developer ID Application/ { print $2; exit }')
if [[ -z "$IDENTITY" ]]; then
echo "No Developer ID Application identity in build keychain"
exit 1
fi
echo "APPLE_SIGNING_IDENTITY=$IDENTITY" >> "$GITHUB_ENV"
echo "CSC_LINK=$CSC_PATH" >> "$GITHUB_ENV"
echo "CSC_KEY_PASSWORD=$APPLE_CERTIFICATE_PASSWORD" >> "$GITHUB_ENV"
echo "has_cert=true" >> "$GITHUB_OUTPUT"
- name: Build desktop bundles
shell: bash
run: |
set -euo pipefail
ARGS=(build --target "${{ matrix.target }}")
if [[ "${{ matrix.platform }}" == "windows-latest" ]]; then
VERSION="${RELEASE_TAG#v}"
NUMERIC_VERSION="${VERSION%%-*}"
NUMERIC_VERSION="${NUMERIC_VERSION%%+*}"
ARGS+=(--config "{\"bundle\":{\"windows\":{\"wix\":{\"version\":\"${NUMERIC_VERSION}\"}}}}")
fi
pnpm --filter @memohai/desktop tauri "${ARGS[@]}"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CSC_IDENTITY_AUTO_DISCOVERY: ${{ steps.mac-signing.outputs.has_cert == 'true' && 'true' || 'false' }}
run: pnpm --filter @memohai/desktop ${{ matrix.build_cmd }}
- name: Upload desktop artifacts
uses: actions/upload-artifact@v4
with:
name: desktop-${{ matrix.target }}
name: desktop-${{ matrix.platform }}
path: |
apps/desktop/src-tauri/target/${{ matrix.target }}/release/bundle/**/*.AppImage
apps/desktop/src-tauri/target/${{ matrix.target }}/release/bundle/**/*.app.tar.gz
apps/desktop/src-tauri/target/${{ matrix.target }}/release/bundle/**/*.deb
apps/desktop/src-tauri/target/${{ matrix.target }}/release/bundle/**/*.dmg
apps/desktop/src-tauri/target/${{ matrix.target }}/release/bundle/**/*.exe
apps/desktop/src-tauri/target/${{ matrix.target }}/release/bundle/**/*.msi
apps/desktop/src-tauri/target/${{ matrix.target }}/release/bundle/**/*.rpm
apps/desktop/src-tauri/target/${{ matrix.target }}/release/bundle/**/*.sig
apps/desktop/dist/**/*.AppImage
apps/desktop/dist/**/*.deb
apps/desktop/dist/**/*.rpm
apps/desktop/dist/**/*.dmg
apps/desktop/dist/**/*.zip
apps/desktop/dist/**/*.exe
apps/desktop/dist/**/*.msi
apps/desktop/dist/**/*.blockmap
apps/desktop/dist/**/latest*.yml
if-no-files-found: error
desktop-upload:
@@ -280,13 +233,14 @@ jobs:
shopt -s nullglob globstar
files=(
release-artifacts/desktop/**/*.AppImage
release-artifacts/desktop/**/*.app.tar.gz
release-artifacts/desktop/**/*.deb
release-artifacts/desktop/**/*.rpm
release-artifacts/desktop/**/*.dmg
release-artifacts/desktop/**/*.zip
release-artifacts/desktop/**/*.exe
release-artifacts/desktop/**/*.msi
release-artifacts/desktop/**/*.rpm
release-artifacts/desktop/**/*.sig
release-artifacts/desktop/**/*.blockmap
release-artifacts/desktop/**/latest*.yml
)
if [[ ${#files[@]} -eq 0 ]]; then
echo "No desktop artifacts found" >&2
-90
View File
@@ -1,90 +0,0 @@
name: Tauri CI
on:
push:
branches: ["main"]
paths:
- "apps/desktop/**"
- "apps/web/**"
- "packages/**"
- "pnpm-lock.yaml"
- ".github/workflows/tauri-ci.yml"
pull_request:
branches: ["main"]
paths:
- "apps/desktop/**"
- "apps/web/**"
- "packages/**"
- "pnpm-lock.yaml"
- ".github/workflows/tauri-ci.yml"
workflow_dispatch:
permissions:
contents: read
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
build:
name: Build (${{ matrix.platform }})
strategy:
fail-fast: false
matrix:
include:
- platform: macos-latest
target: aarch64-apple-darwin
- platform: macos-latest
target: x86_64-apple-darwin
- platform: ubuntu-22.04
target: x86_64-unknown-linux-gnu
- platform: windows-latest
target: x86_64-pc-windows-msvc
runs-on: ${{ matrix.platform }}
timeout-minutes: 60
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v4
with:
version: 10
- uses: actions/setup-node@v4
with:
node-version: lts/*
cache: pnpm
- name: Install Rust stable
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- name: Rust cache
uses: swatinem/rust-cache@v2
with:
workspaces: apps/desktop/src-tauri -> target
- name: Install Linux dependencies
if: matrix.platform == 'ubuntu-22.04'
run: |
sudo apt-get update
sudo apt-get install -y \
libwebkit2gtk-4.1-dev \
libappindicator3-dev \
librsvg2-dev \
patchelf
- name: Install JS dependencies
run: pnpm install --frozen-lockfile
- name: Build Tauri app
uses: tauri-apps/tauri-action@v0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
projectPath: apps/desktop
args: --target ${{ matrix.target }}
tauriScript: pnpm tauri
+13 -4
View File
@@ -40,7 +40,7 @@ Infrastructure dependencies:
- **Icons**: lucide-vue-next + `@memohai/icon` (brand/provider icons)
- **i18n**: vue-i18n
- **Markdown**: markstream-vue + Shiki + Mermaid + KaTeX
- **Desktop**: Tauri (wraps `@memohai/web`)
- **Desktop**: Electron + [electron-vite](https://electron-vite.github.io/) (thin shell whose renderer imports `@memohai/web`'s bootstrap)
- **Package Manager**: pnpm monorepo
### Browser Gateway (TypeScript)
@@ -169,7 +169,7 @@ Memoh/
│ │ ├── types/ # TypeScript type definitions
│ │ ├── storage.ts # Browser context storage
│ │ └── models.ts # Zod request schemas
│ ├── desktop/ # Tauri desktop app (@memohai/desktop, wraps @memohai/web)
│ ├── desktop/ # Electron desktop app (@memohai/desktop, electron-vite; renderer imports @memohai/web)
│ └── web/ # Main web app (@memohai/web, Vue 3) — see apps/web/AGENTS.md
├── packages/ # Shared TypeScript libraries
│ ├── ui/ # Shared UI component library (@memohai/ui)
@@ -235,8 +235,8 @@ Memoh/
| `mise run build-embedded-assets` | Build and stage embedded web assets |
| `mise run build-unified` | Build memoh CLI locally |
| `mise run bridge:build` | Rebuild bridge binary in dev container |
| `mise run desktop:dev` | Start Tauri desktop app in dev mode |
| `mise run desktop:build` | Build Tauri desktop app for release |
| `mise run desktop:dev` | Start Electron desktop app in dev mode (renderer reuses @memohai/web) |
| `mise run desktop:build` | Build Electron desktop app for release (electron-builder) |
| `mise run lint` | Run all linters (Go + ESLint) |
| `mise run lint:fix` | Run all linters with auto-fix |
| `mise run release` | Release new version (bumpp) |
@@ -310,6 +310,15 @@ Migrations live in `db/migrations/` and follow a dual-update convention:
- i18n via vue-i18n.
- See `apps/web/AGENTS.md` for detailed frontend conventions.
### Desktop App
- `apps/desktop/` is an [electron-vite](https://electron-vite.github.io/) project (`@memohai/desktop`).
- The renderer is intentionally a **thin shell**: `src/renderer/src/main.ts` is a single-line `import '@memohai/web/main'` that defers the full bootstrap (router, Pinia, api-client, `App.vue`) to `@memohai/web`.
- `@memohai/web`'s `package.json` exposes an `exports` map (`./main`, `./App.vue`, `./style.css`, `./*`) so downstream consumers can reuse web modules.
- `electron.vite.config.ts` mirrors `apps/web/vite.config.ts`: same `@` / `#` path aliases, same `/api` proxy (driven by `MEMOH_WEB_PROXY_TARGET` / `config.toml` via `@memohai/config`).
- Packaging is handled by `electron-builder` (config in `apps/desktop/electron-builder.yml`); output lands in `apps/desktop/dist/`.
- When desktop needs to diverge from the web experience, replace the re-export in `renderer/src/main.ts` with an inline copy of web's `main.ts` and customize from there — do **not** fork `apps/web` itself.
### Container / Workspace Management
- Each bot can have an isolated **workspace container** for file editing, command execution, and MCP tool hosting.
+11 -18
View File
@@ -1,24 +1,17 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*
node_modules
out
dist
dist-ssr
*.local
*.log
.DS_Store
.env
.env.*
!.env.example
# Editor directories and files
# bundle assets (icons etc.) — root .gitignore has `build/`, re-include here.
!build/
!build/**
# editor
.vscode/*
!.vscode/extensions.json
.idea
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
-7
View File
@@ -1,7 +0,0 @@
{
"recommendations": [
"Vue.volar",
"tauri-apps.tauri-vscode",
"rust-lang.rust-analyzer"
]
}
+30 -1
View File
@@ -1 +1,30 @@
# memohai/desktop
# @memohai/desktop
Memoh desktop application built with [electron-vite](https://electron-vite.github.io/).
The renderer is intentionally a thin shell — its `main.ts` imports `@memohai/web`'s own
bootstrap (router / Pinia / api-client / `App.vue`) so the desktop app runs the same
experience as the web app out of the box. Future desktop-only customization should
happen in this package (by replacing or composing parts of the `@memohai/web` surface),
not by forking the web app.
## Development
```bash
# from repo root
pnpm --filter @memohai/desktop dev
# or via mise
mise run desktop:dev
```
`MEMOH_WEB_PROXY_TARGET` overrides the backend that the renderer's `/api` proxy points
at (defaults to whatever `config.toml` / `conf/app.docker.toml` declares).
## Build
```bash
pnpm --filter @memohai/desktop build # full platform installer
pnpm --filter @memohai/desktop build:dir # unpacked app dir (CI smoke test)
```
Output goes to `apps/desktop/dist/`.

Before

Width:  |  Height:  |  Size: 38 KiB

After

Width:  |  Height:  |  Size: 38 KiB

Before

Width:  |  Height:  |  Size: 44 KiB

After

Width:  |  Height:  |  Size: 44 KiB

+48
View File
@@ -0,0 +1,48 @@
appId: ai.memoh.desktop
productName: Memoh
copyright: Copyright © 2026 Memoh
directories:
buildResources: build
output: dist
files:
- "!**/.vscode/*"
- "!src/*"
- "!electron.vite.config.{js,ts,mjs,cjs}"
- "!{.eslintrc.cjs,.eslintignore,.prettierignore,.prettierrc.yaml,dev-app-update.yml,CHANGELOG.md,README.md}"
- "!{.env,.env.*,.npmrc,pnpm-lock.yaml}"
- "!{tsconfig.json,tsconfig.node.json,tsconfig.web.json}"
asarUnpack:
- resources/**
mac:
category: public.app-category.productivity
target:
- target: dmg
arch: [arm64, x64]
- target: zip
arch: [arm64, x64]
icon: build/icon.icns
artifactName: ${productName}-${version}-${arch}.${ext}
notarize: false
linux:
category: Utility
target:
- target: AppImage
arch: [x64]
- target: deb
arch: [x64]
- target: rpm
arch: [x64]
maintainer: Memoh
icon: build/icon.png
artifactName: ${productName}-${version}-${arch}.${ext}
win:
target:
- target: nsis
arch: [x64]
icon: build/icon.ico
artifactName: ${productName}-${version}-${arch}-setup.${ext}
nsis:
oneClick: false
perMachine: false
allowToChangeInstallationDirectory: true
npmRebuild: false
+98
View File
@@ -0,0 +1,98 @@
import { defineConfig, externalizeDepsPlugin } from 'electron-vite'
import vue from '@vitejs/plugin-vue'
import tailwindcss from '@tailwindcss/vite'
import { createRequire } from 'node:module'
import { fileURLToPath } from 'node:url'
import { resolve } from 'node:path'
const require = createRequire(import.meta.url)
const defaultPort = 8082
const defaultHost = '127.0.0.1'
const defaultApiBaseUrl = process.env.VITE_API_URL ?? 'http://localhost:8080'
function resolveProxyTarget(command: 'build' | 'serve'): { port: number; host: string; baseUrl: string } {
const configuredProxyTarget = process.env.MEMOH_WEB_PROXY_TARGET?.trim()
const configuredPath = process.env.MEMOH_CONFIG_PATH?.trim() || process.env.CONFIG_PATH?.trim()
const configPath = configuredPath && configuredPath.length > 0 ? configuredPath : '../../config.toml'
let port = defaultPort
let host = defaultHost
let baseUrl = configuredProxyTarget || defaultApiBaseUrl
if (command !== 'build') {
try {
const { loadConfig, getBaseUrl } = require('@memohai/config') as {
loadConfig: (path: string) => { web?: { port?: number; host?: string } }
getBaseUrl: (config: unknown) => string
}
let config
try {
config = loadConfig(configPath)
} catch {
config = loadConfig('../../conf/app.docker.toml')
}
port = config.web?.port ?? defaultPort
host = config.web?.host ?? defaultHost
baseUrl = configuredProxyTarget || getBaseUrl(config)
} catch {
// fall back to env/default values when config.toml is unavailable.
}
}
return { port, host, baseUrl }
}
export default defineConfig(({ command }) => {
const { port, host, baseUrl } = resolveProxyTarget(command)
return {
main: {
plugins: [externalizeDepsPlugin()],
},
preload: {
plugins: [externalizeDepsPlugin()],
},
renderer: {
root: resolve(__dirname, 'src/renderer'),
// Reuse apps/web/public so absolute-path assets (e.g. /logo.svg) resolve
// when web modules are imported directly from the desktop renderer.
publicDir: resolve(__dirname, '../web/public'),
plugins: [vue(), tailwindcss()],
resolve: {
alias: {
'@renderer': fileURLToPath(new URL('./src/renderer/src', import.meta.url)),
// match apps/web/vite.config.ts aliases so imported web modules resolve correctly.
'@': fileURLToPath(new URL('../web/src', import.meta.url)),
'#': fileURLToPath(new URL('../../packages/ui/src', import.meta.url)),
},
},
optimizeDeps: {
entries: [
'src/renderer/src/main.ts',
'../web/src/main.ts',
'../web/src/pages/**/*.vue',
],
},
build: {
rollupOptions: {
input: {
index: resolve(__dirname, 'src/renderer/index.html'),
},
},
},
server: {
port,
host,
proxy: {
'/api': {
target: baseUrl,
changeOrigin: true,
rewrite: (path: string) => path.replace(/^\/api/, ''),
ws: true,
},
},
},
},
}
})
+31 -6
View File
@@ -3,16 +3,41 @@
"private": true,
"version": "0.7.1",
"type": "module",
"description": "Memoh Electron desktop application (thin shell reusing @memohai/web)",
"main": "./out/main/index.js",
"scripts": {
"dev": "tauri dev",
"build": "tauri build",
"tauri": "tauri"
"dev": "electron-vite dev",
"start": "electron-vite preview",
"build": "electron-vite build && electron-builder",
"build:dir": "electron-vite build && electron-builder --dir",
"build:unpack": "electron-vite build && electron-builder --dir",
"build:mac": "electron-vite build && electron-builder --mac",
"build:linux": "electron-vite build && electron-builder --linux",
"build:win": "electron-vite build && electron-builder --win",
"typecheck:node": "tsc --noEmit -p tsconfig.node.json --composite false",
"typecheck:web": "vue-tsc --noEmit -p tsconfig.web.json --composite false",
"typecheck": "pnpm run typecheck:node && pnpm run typecheck:web"
},
"dependencies": {
"@tauri-apps/api": "^2",
"@tauri-apps/plugin-opener": "^2"
"@electron-toolkit/preload": "^3.0.1",
"@electron-toolkit/utils": "^4.0.0",
"@memohai/icon": "workspace:*",
"@memohai/sdk": "workspace:*",
"@memohai/ui": "workspace:*",
"@memohai/web": "workspace:*"
},
"devDependencies": {
"@tauri-apps/cli": "^2"
"@electron-toolkit/tsconfig": "^1.0.1",
"@memohai/config": "workspace:*",
"@tailwindcss/vite": "^4.2.2",
"@types/node": "^24.10.1",
"@vitejs/plugin-vue": "^6.0.5",
"electron": "^34.5.0",
"electron-builder": "^26.0.12",
"electron-vite": "^4.0.0",
"typescript": "~5.9.3",
"vite": "^8.0.1",
"vue": "^3.5.24",
"vue-tsc": "^3.1.4"
}
}
-7
View File
@@ -1,7 +0,0 @@
# Generated by Cargo
# will have compiled files and executables
/target/
# Generated by Tauri
# will have schema files for capabilities auto-completion
/gen/schemas
-5471
View File
File diff suppressed because it is too large Load Diff
-25
View File
@@ -1,25 +0,0 @@
[package]
name = "desktop"
version = "0.1.0"
description = "A Tauri App"
authors = ["you"]
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[lib]
# The `_lib` suffix may seem redundant but it is necessary
# to make the lib name unique and wouldn't conflict with the bin name.
# This seems to be only an issue on Windows, see https://github.com/rust-lang/cargo/issues/8519
name = "desktop_lib"
crate-type = ["staticlib", "cdylib", "rlib"]
[build-dependencies]
tauri-build = { version = "2", features = [] }
[dependencies]
tauri = { version = "2", features = [] }
tauri-plugin-opener = "2"
serde = { version = "1", features = ["derive"] }
serde_json = "1"
-3
View File
@@ -1,3 +0,0 @@
fn main() {
tauri_build::build()
}
@@ -1,10 +0,0 @@
{
"$schema": "../gen/schemas/desktop-schema.json",
"identifier": "default",
"description": "Capability for the main window",
"windows": ["main"],
"permissions": [
"core:default",
"opener:default"
]
}
Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 33 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 37 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.0 KiB

@@ -1,5 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<foreground android:drawable="@mipmap/ic_launcher_foreground"/>
<background android:drawable="@color/ic_launcher_background"/>
</adaptive-icon>
Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 25 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 37 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 48 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 22 KiB

@@ -1,4 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="ic_launcher_background">#fff</color>
</resources>
Binary file not shown.

Before

Width:  |  Height:  |  Size: 982 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 42 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 18 KiB

-23
View File
@@ -1,23 +0,0 @@
use tauri::LogicalSize;
#[tauri::command]
fn resize_for_route(window: tauri::Window, route: String) {
let is_login = route == "/login";
if is_login {
let _ = window.set_min_size(None::<tauri::Size>);
let _ = window.set_size(tauri::Size::Logical(LogicalSize::new(480.0, 700.0)));
} else {
let _ = window.set_size(tauri::Size::Logical(LogicalSize::new(1280.0, 800.0)));
let _ = window.set_min_size(Some(tauri::Size::Logical(LogicalSize::new(960.0, 600.0))));
}
let _ = window.center();
}
#[cfg_attr(mobile, tauri::mobile_entry_point)]
pub fn run() {
tauri::Builder::default()
.plugin(tauri_plugin_opener::init())
.invoke_handler(tauri::generate_handler![resize_for_route])
.run(tauri::generate_context!())
.expect("error while running tauri application");
}
-6
View File
@@ -1,6 +0,0 @@
// Prevents additional console window on Windows in release, DO NOT REMOVE!!
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]
fn main() {
desktop_lib::run()
}
-35
View File
@@ -1,35 +0,0 @@
{
"$schema": "https://schema.tauri.app/config/2",
"productName": "Memoh",
"version": "0.1.0",
"identifier": "ai.memoh.desktop",
"build": {
"beforeDevCommand": "pnpm --filter @memohai/web exec vite --port 1420 --strictPort",
"devUrl": "http://localhost:1420",
"beforeBuildCommand": "pnpm --filter @memohai/web build",
"frontendDist": "../../web/dist"
},
"app": {
"windows": [
{
"title": "Memoh",
"width": 1280,
"height": 800
}
],
"security": {
"csp": null
}
},
"bundle": {
"active": true,
"targets": "all",
"icon": [
"icons/32x32.png",
"icons/128x128.png",
"icons/128x128@2x.png",
"icons/icon.icns",
"icons/icon.ico"
]
}
}
+62
View File
@@ -0,0 +1,62 @@
import { app, shell, BrowserWindow } from 'electron'
import { join } from 'node:path'
import { electronApp, optimizer, is } from '@electron-toolkit/utils'
const DEFAULT_WIDTH = 1280
const DEFAULT_HEIGHT = 800
const MIN_WIDTH = 960
const MIN_HEIGHT = 600
function createWindow(): BrowserWindow {
const window = new BrowserWindow({
width: DEFAULT_WIDTH,
height: DEFAULT_HEIGHT,
minWidth: MIN_WIDTH,
minHeight: MIN_HEIGHT,
show: false,
autoHideMenuBar: true,
title: 'Memoh',
webPreferences: {
preload: join(__dirname, '../preload/index.js'),
sandbox: false,
contextIsolation: true,
nodeIntegration: false,
},
})
window.on('ready-to-show', () => {
window.show()
if (is.dev) window.webContents.openDevTools({ mode: 'detach' })
})
window.webContents.setWindowOpenHandler(({ url }) => {
shell.openExternal(url)
return { action: 'deny' }
})
if (is.dev && process.env.ELECTRON_RENDERER_URL) {
window.loadURL(process.env.ELECTRON_RENDERER_URL)
} else {
window.loadFile(join(__dirname, '../renderer/index.html'))
}
return window
}
app.whenReady().then(() => {
electronApp.setAppUserModelId('ai.memoh.desktop')
app.on('browser-window-created', (_, window) => {
optimizer.watchWindowShortcuts(window)
})
createWindow()
app.on('activate', () => {
if (BrowserWindow.getAllWindows().length === 0) createWindow()
})
})
app.on('window-all-closed', () => {
if (process.platform !== 'darwin') app.quit()
})
+10
View File
@@ -0,0 +1,10 @@
import type { ElectronAPI } from '@electron-toolkit/preload'
declare global {
interface Window {
electron: ElectronAPI
api: Record<string, never>
}
}
export {}
+21
View File
@@ -0,0 +1,21 @@
import { contextBridge } from 'electron'
import { electronAPI } from '@electron-toolkit/preload'
// Renderer-facing API surface. Intentionally minimal for now — extend here when
// the desktop shell needs to expose native capabilities (window control, file
// dialogs, deep links, etc.).
const api = {}
if (process.contextIsolated) {
try {
contextBridge.exposeInMainWorld('electron', electronAPI)
contextBridge.exposeInMainWorld('api', api)
} catch (error) {
console.error(error)
}
} else {
// @ts-expect-error — fall-through for sandbox-less builds
window.electron = electronAPI
// @ts-expect-error — fall-through for sandbox-less builds
window.api = api
}
+12
View File
@@ -0,0 +1,12 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Memoh</title>
</head>
<body>
<div id="app"></div>
<script type="module" src="/src/main.ts"></script>
</body>
</html>
+7
View File
@@ -0,0 +1,7 @@
/// <reference types="vite/client" />
declare module '*.vue' {
import type { DefineComponent } from 'vue'
const component: DefineComponent<object, object, unknown>
export default component
}
+5
View File
@@ -0,0 +1,5 @@
// Thin desktop renderer entry — defers the full bootstrap (Pinia, router,
// i18n, api-client, App.vue) to @memohai/web. When the desktop shell needs
// to diverge, replace this import with an inline copy of web's main.ts and
// customize as needed.
import '@memohai/web/main'
+7
View File
@@ -0,0 +1,7 @@
{
"files": [],
"references": [
{ "path": "./tsconfig.node.json" },
{ "path": "./tsconfig.web.json" }
]
}
+14
View File
@@ -0,0 +1,14 @@
{
"extends": "@electron-toolkit/tsconfig/tsconfig.node.json",
"include": [
"electron.vite.config.ts",
"src/main/**/*",
"src/preload/**/*"
],
"compilerOptions": {
"composite": true,
"moduleResolution": "bundler",
"module": "esnext",
"types": ["node", "electron-vite/node"]
}
}
+17
View File
@@ -0,0 +1,17 @@
{
"extends": "@electron-toolkit/tsconfig/tsconfig.web.json",
"include": [
"src/renderer/src/**/*",
"src/renderer/src/**/*.vue",
"src/preload/*.d.ts"
],
"compilerOptions": {
"composite": true,
"baseUrl": ".",
"paths": {
"@renderer/*": ["src/renderer/src/*"],
"@/*": ["../web/src/*"],
"#/*": ["../../packages/ui/src/*"]
}
}
}
-1
View File
@@ -250,7 +250,6 @@ Both routes render the same `home/index.vue` component. The `home` route shows a
- All routes except `/login` and `/oauth/*` require `localStorage.getItem('token')`.
- Logged-in users accessing `/login` are redirected to `/`.
- Chunk load errors (dynamic import failures) trigger an automatic page reload.
- Tauri integration: `afterEach` hook calls `resize_for_route` via `@tauri-apps/api/core` when running inside Tauri.
## Layout System
+7 -3
View File
@@ -3,6 +3,13 @@
"private": true,
"version": "0.7.1",
"type": "module",
"exports": {
".": "./src/main.ts",
"./main": "./src/main.ts",
"./App.vue": "./src/App.vue",
"./style.css": "./src/style.css",
"./*": "./src/*"
},
"scripts": {
"dev": "vite",
"build": "vite build",
@@ -51,9 +58,6 @@
"vue-sonner": "^2.0.9",
"zod": "^4.3.5"
},
"optionalDependencies": {
"@tauri-apps/api": "^2"
},
"devDependencies": {
"@memohai/config": "workspace:*",
"@types/moment": "^2.13.0",
-8
View File
@@ -198,12 +198,4 @@ router.beforeEach((to) => {
return token ? true : { name: 'Login' }
})
router.afterEach(async (to) => {
if (!('__TAURI_INTERNALS__' in window)) return
try {
const { invoke } = await import('@tauri-apps/api/core')
invoke('resize_for_route', { route: to.path })
} catch { /* not in Tauri */ }
})
export default router
+5
View File
@@ -2,6 +2,11 @@
@import "tw-animate-css";
@import "@memohai/ui/style.css";
/* Explicit `@source` paths (relative to this CSS file) — Tailwind v4's
* auto-detection anchors on the Vite project root, so when a consumer
* (e.g. @memohai/desktop) imports this stylesheet from a different root,
* it needs these hints to still scan our templates. */
@source "./";
@source "../../../packages/ui/src";
@layer components {
+4 -6
View File
@@ -16,8 +16,6 @@ pnpm = "10"
sqlc = "latest"
# golangci-lint for Go linting
"golangci-lint" = "2.10.1"
# Rust stable toolchain (required by Tauri desktop app)
rust = "stable"
[task_config]
dir = "{{cwd}}"
@@ -203,12 +201,12 @@ echo ' Dev web UI will be available at http://localhost:18082'
"""
[tasks."desktop:dev"]
description = "Start Tauri desktop app in dev mode (wraps @memohai/web)"
description = "Start Electron desktop app in dev mode (renderer reuses @memohai/web)"
dir = "{{config_root}}/apps/desktop"
env = { MEMOH_WEB_PROXY_TARGET = "http://localhost:18080" }
run = "pnpm tauri dev"
run = "pnpm dev"
[tasks."desktop:build"]
description = "Build Tauri desktop app for release"
description = "Build Electron desktop app for release (electron-builder)"
dir = "{{config_root}}/apps/desktop"
run = "pnpm tauri build"
run = "pnpm build"
+1661 -173
View File
File diff suppressed because it is too large Load Diff
+4 -1
View File
@@ -4,4 +4,7 @@ packages:
- 'docs'
onlyBuiltDependencies:
- sqlite3
- sqlite3
- electron
- electron-winstaller
- esbuild