diff --git a/.dockerignore b/.dockerignore index 179b9691f..dc447948e 100644 --- a/.dockerignore +++ b/.dockerignore @@ -5,9 +5,6 @@ .vscode/ .DS_Store -# Tauri 构建产物(非常大) -BillNote_frontend/src-tauri/target -BillNote_frontend/src-tauri/bin # 运行时数据 backend/data diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml index d86736ead..af40f9d16 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.yml +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -17,7 +17,6 @@ body: - 后端 (backend/) - Web 前端 (BillNote_frontend/) - 浏览器插件 (BillNote_extension/) - - Tauri 桌面端 - 文档 / 其他 validations: required: true @@ -37,7 +36,6 @@ body: - 源码运行 - Docker (docker-compose.yml) - Docker GPU (docker-compose.gpu.yml) - - 桌面端安装包 (Tauri Release) - 其他 validations: required: true diff --git a/.github/ISSUE_TEMPLATE/feature_request.yml b/.github/ISSUE_TEMPLATE/feature_request.yml index 94c76bae1..0ef670a9e 100644 --- a/.github/ISSUE_TEMPLATE/feature_request.yml +++ b/.github/ISSUE_TEMPLATE/feature_request.yml @@ -31,7 +31,6 @@ body: - 后端 (backend/) - Web 前端 (BillNote_frontend/) - 浏览器插件 (BillNote_extension/) - - Tauri 桌面端 - 不确定 - type: textarea id: extra diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml deleted file mode 100644 index 909b5b20e..000000000 --- a/.github/workflows/main.yml +++ /dev/null @@ -1,163 +0,0 @@ -name: Build & Release Desktop App - -on: - push: - tags: - - 'v*' - workflow_dispatch: - -jobs: - build: - strategy: - matrix: - include: - - platform: macos-latest - target: universal-apple-darwin - - platform: windows-latest - target: x86_64-pc-windows-msvc - - runs-on: ${{ matrix.platform }} - - steps: - - name: Checkout Code - uses: actions/checkout@v4 - - # 设置 Python 环境(带 pip 缓存) - - name: Set up Python - uses: actions/setup-python@v5 - with: - python-version: '3.11' - cache: 'pip' - cache-dependency-path: backend/requirements.txt - - # 安装 Python 依赖并执行构建 - - name: Install Python dependencies & Build backend - shell: bash - run: | - python -m pip install --upgrade pip - pip install -r backend/requirements.txt - - if [ "$RUNNER_OS" = "Windows" ]; then - backend\\build.bat - else - chmod +x backend/build.sh - ./backend/build.sh - fi - - # 设置 pnpm - # 不能用 'latest':pnpm 11+ 要求 Node 22+,与下方 Node 20 不兼容(ERR_UNKNOWN_BUILTIN_MODULE)。 - # lockfile 是 pnpm 9 生成;统一 pin 到 9.15.0 - - name: Setup pnpm - uses: pnpm/action-setup@v4 - with: - version: '9.15.0' - - # 设置 Node 环境 - - name: Set up Node.js - uses: actions/setup-node@v4 - with: - node-version: '20' - - - name: Install frontend dependencies - working-directory: BillNote_frontend - run: pnpm install - - # 设置 Rust 环境 - - name: Set up Rust - uses: dtolnay/rust-toolchain@stable - - # Cargo 缓存 - - name: Cache Cargo - uses: actions/cache@v4 - with: - path: | - ~/.cargo/bin/ - ~/.cargo/registry/index/ - ~/.cargo/registry/cache/ - ~/.cargo/git/db/ - BillNote_frontend/src-tauri/target/ - key: ${{ runner.os }}-cargo-${{ hashFiles('BillNote_frontend/src-tauri/Cargo.lock') }} - restore-keys: ${{ runner.os }}-cargo- - - # 从 tag 注入版本号到 tauri.conf.json:Tauri 取该文件的静态 version 作为 - # 产物版本,不同步的话构建产物会恒为 conf 里写死的值(此前的 2.0.0)。 - # github.ref_name 形如 v2.3.2,去掉前缀 v。workflow_dispatch(无 tag)时跳过,保留静态值。 - - name: Sync version from tag - if: startsWith(github.ref, 'refs/tags/v') - working-directory: BillNote_frontend - shell: bash - run: | - VERSION="${GITHUB_REF_NAME#v}" - echo "Injecting version $VERSION into tauri.conf.json" - node -e "const f='src-tauri/tauri.conf.json'; const fs=require('fs'); const j=JSON.parse(fs.readFileSync(f,'utf8')); j.version=process.argv[1]; fs.writeFileSync(f, JSON.stringify(j,null,2)+'\n');" "$VERSION" - node -e "console.log('tauri.conf.json version =', require('./src-tauri/tauri.conf.json').version)" - - # 打包 Tauri 应用 - - name: Build Tauri App - working-directory: BillNote_frontend - run: pnpm tauri build - - # 收集产物到统一目录 - - name: Collect release artifacts - shell: bash - run: | - mkdir -p release-artifacts - BUNDLE_DIR="BillNote_frontend/src-tauri/target/release/bundle" - - # macOS: .dmg - find "$BUNDLE_DIR" -name "*.dmg" -exec cp {} release-artifacts/ \; 2>/dev/null || true - # Windows: .msi, .exe (NSIS) - find "$BUNDLE_DIR" -name "*.msi" -exec cp {} release-artifacts/ \; 2>/dev/null || true - find "$BUNDLE_DIR/nsis" -name "*.exe" -exec cp {} release-artifacts/ \; 2>/dev/null || true - - echo "=== Collected artifacts ===" - ls -lh release-artifacts/ - - # 生成 SHA256 校验和 - - name: Generate checksums - shell: bash - run: | - cd release-artifacts - sha256sum * > SHA256SUMS.txt 2>/dev/null || shasum -a 256 * > SHA256SUMS.txt - cat SHA256SUMS.txt - - # 上传产物(供 release job 使用) - - name: Upload artifacts - uses: actions/upload-artifact@v4 - with: - name: artifacts-${{ matrix.platform }} - path: release-artifacts/ - - # 创建 GitHub Release 并上传所有产物 - release: - needs: build - runs-on: ubuntu-latest - if: startsWith(github.ref, 'refs/tags/v') - permissions: - contents: write - - steps: - - name: Checkout Code - uses: actions/checkout@v4 - - # 下载所有平台的构建产物 - - name: Download all artifacts - uses: actions/download-artifact@v4 - with: - path: all-artifacts - merge-multiple: true - - - name: List all artifacts - run: | - echo "=== All release artifacts ===" - ls -lhR all-artifacts/ - - # 创建 Release 并上传产物 - - name: Create GitHub Release - uses: softprops/action-gh-release@v2 - with: - name: BiliNote ${{ github.ref_name }} - draft: false - prerelease: false - generate_release_notes: true - files: all-artifacts/* diff --git a/.github/workflows/release-web.yml b/.github/workflows/release-web.yml new file mode 100644 index 000000000..979b7d496 --- /dev/null +++ b/.github/workflows/release-web.yml @@ -0,0 +1,84 @@ +name: Release Web + +# Web 发布:打 v* tag 时构建前端静态产物(dist)并挂到对应 GitHub Release。 +# 后端镜像由 docker-build.yml 独立发布到 ghcr.io;两边的版本号都从 tag 推导。 +# 手动补发:Actions → Release Web → Run workflow(无 tag 时版本号落在 0.0.0)。 +on: + push: + tags: + - 'v*' + workflow_dispatch: + +permissions: + contents: write + +jobs: + build-web: + name: Build web bundle + runs-on: ubuntu-latest + defaults: + run: + working-directory: BillNote_frontend + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Resolve version + id: version + shell: bash + run: | + if [[ "$GITHUB_REF" == refs/tags/v* ]]; then + echo "value=${GITHUB_REF_NAME#v}" >> "$GITHUB_OUTPUT" + else + echo "value=0.0.0" >> "$GITHUB_OUTPUT" + fi + + - name: Setup pnpm + uses: pnpm/action-setup@v4 + with: + version: 10 + + - name: Setup Node + uses: actions/setup-node@v4 + with: + node-version: 20 + cache: pnpm + cache-dependency-path: BillNote_frontend/pnpm-lock.yaml + + - name: Install + run: pnpm install --frozen-lockfile + + - name: Build (VITE_APP_VERSION from tag) + env: + VITE_APP_VERSION: ${{ steps.version.outputs.value }} + run: pnpm build + + - name: Pack dist + shell: bash + run: | + VERSION="${{ steps.version.outputs.value }}" + tar -czf "bilinote-web-${VERSION}.tar.gz" -C dist . + ls -lh "bilinote-web-${VERSION}.tar.gz" + + - name: Upload build artifact + uses: actions/upload-artifact@v4 + with: + name: bilinote-web-${{ steps.version.outputs.value }} + path: BillNote_frontend/bilinote-web-*.tar.gz + if-no-files-found: error + + - name: Attach to GitHub Release + # 只在 tag 触发时挂 Release;workflow_dispatch 只留 artifact。 + if: startsWith(github.ref, 'refs/tags/') + uses: softprops/action-gh-release@v2 + with: + files: BillNote_frontend/bilinote-web-*.tar.gz + fail_on_unmatched_files: true + generate_release_notes: false + + - name: Print deploy hints + run: | + VERSION="${{ steps.version.outputs.value }}" + echo "Web bundle: bilinote-web-${VERSION}.tar.gz (static files, serve behind nginx)" + echo "Backend image: ghcr.io/${{ github.repository }}:${VERSION}" + echo "Self-host: docker compose up -d (repo root, backend + frontend + nginx)" diff --git a/.gitignore b/.gitignore index e2f2c4cc6..d3dca37ea 100644 --- a/.gitignore +++ b/.gitignore @@ -322,7 +322,6 @@ cython_debug/ /backend/config/* /backend/vector_db/ /BiliNote_frontend/.idea/* -/BiliNote_frontend/src-tauri/bin/ # FFmpeg 构建文件(不应该提交到仓库) ffmpeg*/ diff --git a/BillNote_extension/src/__tests__/tokens.test.ts b/BillNote_extension/src/__tests__/tokens.test.ts new file mode 100644 index 000000000..a2d20e350 --- /dev/null +++ b/BillNote_extension/src/__tests__/tokens.test.ts @@ -0,0 +1,60 @@ +import { readFileSync, readdirSync, statSync } from 'node:fs' +import { join } from 'node:path' +import { describe, expect, it } from 'vitest' + +// The extension mirrors BillNote_frontend/src/ember/tokens.css by hand (no +// shared package), so the numbers are pinned here: a rename or a palette edit +// that forgets one side would otherwise drift silently. +const SRC = join(__dirname, '..') +const TOKENS = readFileSync(join(SRC, 'styles/tokens.css'), 'utf8') + +function sourceFiles(dir: string): string[] { + return readdirSync(dir).flatMap((entry) => { + const path = join(dir, entry) + if (statSync(path).isDirectory()) return sourceFiles(path) + return /\.(vue|ts|css)$/.test(entry) && !path.endsWith('tokens.css') && !path.includes('__tests__') ? [path] : [] + }) +} + +describe('extension design tokens', () => { + it('uses the 021 canonical names, not the legacy ones', () => { + expect(TOKENS).toContain('--accent:') + expect(TOKENS).toContain('--ink-muted:') + expect(TOKENS).not.toContain('--primary:') + expect(TOKENS).not.toMatch(/--ink-mute:/) + }) + + it('defines the full palette in both themes', () => { + const light = TOKENS.slice(0, TOKENS.indexOf('.dark {')) + const dark = TOKENS.slice(TOKENS.indexOf('.dark {'), TOKENS.indexOf('@media')) + const names = (css: string) => [...css.matchAll(/--([a-z-]+):/g)].map(m => m[1]) + const lightNames = new Set(names(light)) + // .dark redefines colours only; every name it sets must already exist in :root. + for (const name of names(dark)) expect(lightNames.has(name)).toBe(true) + for (const core of ['canvas', 'surface', 'raised', 'ink', 'ink-soft', 'ink-muted', 'line', 'line-strong', 'accent', 'accent-soft', 'on-accent', 'success', 'warning', 'danger', 'info']) { + expect(lightNames.has(core)).toBe(true) + expect(names(dark)).toContain(core) + } + expect(light).toContain('#f4f6f7') + expect(dark).toContain('#111719') + }) + + it('keeps the shared motion ladder', () => { + expect(TOKENS).toMatch(/--dur-press:\s*120ms/) + expect(TOKENS).toMatch(/--dur-hover:\s*160ms/) + expect(TOKENS).toMatch(/--dur-popover:\s*180ms/) + expect(TOKENS).toMatch(/--dur-menu:\s*200ms/) + expect(TOKENS).toMatch(/--dur-panel:\s*260ms/) + expect(TOKENS).toMatch(/--dur-page:\s*300ms/) + }) + + it('has no hardcoded colour outside tokens.css', () => { + const offenders = sourceFiles(SRC).filter(file => /#[0-9a-f]{6}\b/i.test(readFileSync(file, 'utf8'))) + expect(offenders).toEqual([]) + }) + + it('gives touch pointers 44px targets', () => { + expect(TOKENS).toMatch(/@media \(pointer: coarse\)/) + expect(TOKENS).toMatch(/min-height:\s*2\.75rem/) + }) +}) diff --git a/BillNote_extension/src/components/MarkdownView.vue b/BillNote_extension/src/components/MarkdownView.vue index a492703f9..60f70557f 100644 --- a/BillNote_extension/src/components/MarkdownView.vue +++ b/BillNote_extension/src/components/MarkdownView.vue @@ -25,20 +25,11 @@ function download() { - - diff --git a/BillNote_extension/src/components/PlatformBadge.vue b/BillNote_extension/src/components/PlatformBadge.vue index d8500fffa..252fcb11e 100644 --- a/BillNote_extension/src/components/PlatformBadge.vue +++ b/BillNote_extension/src/components/PlatformBadge.vue @@ -5,16 +5,10 @@ import { PLATFORM_LABELS } from '~/logic/platform' const props = defineProps<{ platform: Platform | null }>() -const colorMap: Record = { - bilibili: 'bg-pink-100 text-pink-700', -} - -const cls = computed(() => (props.platform ? colorMap[props.platform] : 'bg-gray-100 text-gray-500')) +const cls = computed(() => (props.platform ? 'tag' : 'tag text-ink-muted')) const label = computed(() => (props.platform ? PLATFORM_LABELS[props.platform] : '未识别')) diff --git a/BillNote_extension/src/components/TaskProgress.vue b/BillNote_extension/src/components/TaskProgress.vue index d905ba19e..fee3f033c 100644 --- a/BillNote_extension/src/components/TaskProgress.vue +++ b/BillNote_extension/src/components/TaskProgress.vue @@ -1,42 +1,36 @@ diff --git a/BillNote_extension/src/composables/__tests__/useBackendHealth.test.ts b/BillNote_extension/src/composables/__tests__/useBackendHealth.test.ts new file mode 100644 index 000000000..631843171 --- /dev/null +++ b/BillNote_extension/src/composables/__tests__/useBackendHealth.test.ts @@ -0,0 +1,55 @@ +import { defineComponent, h } from 'vue' +import { mount } from '@vue/test-utils' +import { beforeEach, describe, expect, it, vi } from 'vitest' +import { useBackendHealth } from '../useBackendHealth' + +vi.mock('~/logic/storage', () => ({ + settings: { value: { backendUrl: 'http://localhost:8483' } }, + settingsReady: Promise.resolve(), +})) + +function mountProbe() { + let api: ReturnType | undefined + const Comp = defineComponent({ + setup() { + api = useBackendHealth(60_000) + return () => h('div') + }, + }) + const wrapper = mount(Comp) + return { wrapper, api: api! } +} + +const flush = () => new Promise(r => setTimeout(r, 0)) + +describe('useBackendHealth', () => { + beforeEach(() => { + vi.restoreAllMocks() + }) + + it('marks the backend ok on a 2xx sys_check', async () => { + vi.stubGlobal('fetch', vi.fn().mockResolvedValue(new Response('{}', { status: 200 }))) + const { wrapper, api } = mountProbe() + await flush() + expect(api.state.value).toBe('ok') + wrapper.unmount() + }) + + it('marks the backend down on a non-2xx response', async () => { + vi.stubGlobal('fetch', vi.fn().mockResolvedValue(new Response('nope', { status: 503 }))) + const { wrapper, api } = mountProbe() + await flush() + expect(api.state.value).toBe('down') + expect(api.detail.value).toContain('503') + wrapper.unmount() + }) + + it('marks the backend down when the request throws', async () => { + vi.stubGlobal('fetch', vi.fn().mockRejectedValue(new Error('connect ECONNREFUSED'))) + const { wrapper, api } = mountProbe() + await flush() + expect(api.state.value).toBe('down') + expect(api.detail.value).toContain('ECONNREFUSED') + wrapper.unmount() + }) +}) diff --git a/BillNote_extension/src/composables/useBackendHealth.ts b/BillNote_extension/src/composables/useBackendHealth.ts new file mode 100644 index 000000000..c34c8ddc9 --- /dev/null +++ b/BillNote_extension/src/composables/useBackendHealth.ts @@ -0,0 +1,46 @@ +import { onMounted, onUnmounted, ref } from 'vue' +import { settings, settingsReady } from '~/logic/storage' + +export type BackendState = 'checking' | 'ok' | 'down' + +/** + * Reachability probe for the configured backend. The popup and the side panel + * are useless when the backend is not running, and both used to render an empty + * shell with no explanation — so both surfaces show an explicit "后端不可用" + * state instead of an empty result. + */ +export function useBackendHealth(intervalMs = 15000) { + const state = ref('checking') + const detail = ref('') + let timer: ReturnType | null = null + + async function probe() { + await settingsReady + const base = (settings.value?.backendUrl || 'http://localhost:8483').replace(/\/$/, '') + const controller = new AbortController() + const timeout = setTimeout(() => controller.abort(), 4000) + try { + const res = await fetch(`${base}/api/sys_check`, { signal: controller.signal }) + state.value = res.ok ? 'ok' : 'down' + detail.value = res.ok ? '' : `HTTP ${res.status}` + } + catch (e) { + state.value = 'down' + detail.value = (e as Error).message + } + finally { + clearTimeout(timeout) + } + } + + onMounted(() => { + probe() + timer = setInterval(probe, intervalMs) + }) + onUnmounted(() => { + if (timer) + clearInterval(timer) + }) + + return { state, detail, probe } +} diff --git a/BillNote_extension/src/logic/task-status-label.ts b/BillNote_extension/src/logic/task-status-label.ts new file mode 100644 index 000000000..b7cd8f13b --- /dev/null +++ b/BillNote_extension/src/logic/task-status-label.ts @@ -0,0 +1,21 @@ +import type { TaskStatus } from './types' + +export const STAGE_LABELS: Record = { + PENDING: '排队中', + PARSING: '解析中', + DOWNLOADING: '下载中', + TRANSCRIBING: '转写中', + SUMMARIZING: '总结中', + FORMATTING: '格式化', + SAVING: '保存中', + SUCCESS: '完成', + FAILED: '失败', +} + +export function statusIcon(status: TaskStatus): string { + return status === 'SUCCESS' ? '✓' : status === 'FAILED' ? '✕' : '◔' +} + +export function statusLabel(status: TaskStatus): string { + return STAGE_LABELS[status] ?? status +} diff --git a/BillNote_extension/src/options/Options.vue b/BillNote_extension/src/options/Options.vue index b37f4bdeb..2b01b9b8d 100644 --- a/BillNote_extension/src/options/Options.vue +++ b/BillNote_extension/src/options/Options.vue @@ -6,12 +6,14 @@ import TranscriberPage from './pages/Transcriber.vue' import DownloaderPage from './pages/Downloader.vue' import MonitorPage from './pages/Monitor.vue' +// Text-only nav: the emoji icons clashed with the graphite/teal palette and +// carried no information the labels do not already carry. const TABS = [ - { id: 'general', label: '通用', icon: '⚙️', component: GeneralPage }, - { id: 'providers', label: '模型供应商', icon: '🧠', component: ProvidersPage }, - { id: 'transcriber', label: '音频转写配置', icon: '🎙️', component: TranscriberPage }, - { id: 'downloader', label: '下载配置', icon: '🍪', component: DownloaderPage }, - { id: 'monitor', label: '部署监控', icon: '📊', component: MonitorPage }, + { id: 'general', label: '通用', component: GeneralPage }, + { id: 'providers', label: '模型供应商', component: ProvidersPage }, + { id: 'transcriber', label: '音频转写配置', component: TranscriberPage }, + { id: 'downloader', label: '下载配置', component: DownloaderPage }, + { id: 'monitor', label: '部署监控', component: MonitorPage }, ] as const const activeTab = ref('general') @@ -19,25 +21,28 @@ const ActiveComponent = computed(() => TABS.find(t => t.id === activeTab.value)? - - diff --git a/BillNote_extension/src/options/pages/Downloader.vue b/BillNote_extension/src/options/pages/Downloader.vue index 550081a76..704de438f 100644 --- a/BillNote_extension/src/options/pages/Downloader.vue +++ b/BillNote_extension/src/options/pages/Downloader.vue @@ -76,7 +76,7 @@ onMounted(() => {

下载配置

-

+

每平台的 cookie 写入后端 (config/downloader.json);下载时由对应 downloader 读取注入 yt-dlp。

@@ -94,9 +94,9 @@ onMounted(() => {

{{ PLATFORM_LABELS[p] }}

已配置 - 未配置 + 未配置