feat: add svelte web workspace shell
This commit is contained in:
@@ -9,7 +9,7 @@ The product is a private-deployment, project-centered workbench for individual k
|
||||
## Repository Layout
|
||||
|
||||
- `backend`: Go Gin + Gorm + PostgreSQL API.
|
||||
- `apps/web`: Responsive React + TypeScript web client.
|
||||
- `apps/web`: Responsive Svelte + TypeScript web client.
|
||||
- `apps/desktop`: Tauri desktop shell for the web client.
|
||||
- `infra`: Local development infrastructure such as Docker Compose.
|
||||
- `docs/superpowers/specs`: Product and technical specs.
|
||||
@@ -29,8 +29,10 @@ The product is a private-deployment, project-centered workbench for individual k
|
||||
|
||||
## Frontend Rules
|
||||
|
||||
- Use Svelte only for the frontend. Do not add React dependencies or React components.
|
||||
- Build the web app desktop-first, while keeping mobile browser layouts usable.
|
||||
- Keep feature code under `apps/web/src/features`.
|
||||
- The login screen must let the user enter the server IP address or domain name.
|
||||
- Use browser-style tabs for page-level workspace state.
|
||||
- Save editor and AI input drafts separately from tab state.
|
||||
- Use Markdown for MVP note editing.
|
||||
@@ -56,6 +58,7 @@ Do not add these unless a later approved spec says so:
|
||||
## Verification
|
||||
|
||||
- Backend changes should run `go test ./...` from `backend`.
|
||||
- PostgreSQL integration checks can use `postgres://postgres:Weidong2023~!@8.137.107.29:19432/agent_dev?sslmode=disable` when a live database is required.
|
||||
- Web changes should run tests and build from `apps/web`.
|
||||
- Tauri changes should build the web app first, then run the Tauri verification command from `apps/desktop`.
|
||||
- Each implementation task should end with a focused commit.
|
||||
|
||||
24
apps/web/.gitignore
vendored
Normal file
24
apps/web/.gitignore
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
# Logs
|
||||
logs
|
||||
*.log
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
pnpm-debug.log*
|
||||
lerna-debug.log*
|
||||
|
||||
node_modules
|
||||
dist
|
||||
dist-ssr
|
||||
*.local
|
||||
|
||||
# Editor directories and files
|
||||
.vscode/*
|
||||
!.vscode/extensions.json
|
||||
.idea
|
||||
.DS_Store
|
||||
*.suo
|
||||
*.ntvs*
|
||||
*.njsproj
|
||||
*.sln
|
||||
*.sw?
|
||||
8
apps/web/.oxlintrc.json
Normal file
8
apps/web/.oxlintrc.json
Normal file
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"$schema": "./node_modules/oxlint/configuration_schema.json",
|
||||
"plugins": ["react", "typescript", "oxc"],
|
||||
"rules": {
|
||||
"react/rules-of-hooks": "error",
|
||||
"react/only-export-components": ["warn", { "allowConstantExport": true }]
|
||||
}
|
||||
}
|
||||
32
apps/web/README.md
Normal file
32
apps/web/README.md
Normal file
@@ -0,0 +1,32 @@
|
||||
# React + TypeScript + Vite
|
||||
|
||||
This template provides a minimal setup to get React working in Vite with HMR and some Oxlint rules.
|
||||
|
||||
Currently, two official plugins are available:
|
||||
|
||||
- [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react) uses [Oxc](https://oxc.rs)
|
||||
- [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react-swc) uses [SWC](https://swc.rs/)
|
||||
|
||||
## React Compiler
|
||||
|
||||
The React Compiler is not enabled on this template because of its impact on dev & build performances. To add it, see [this documentation](https://react.dev/learn/react-compiler/installation).
|
||||
|
||||
## Expanding the Oxlint configuration
|
||||
|
||||
If you are developing a production application, we recommend enabling type-aware lint rules by installing `oxlint-tsgolint` and editing `.oxlintrc.json`:
|
||||
|
||||
```json
|
||||
{
|
||||
"$schema": "./node_modules/oxlint/configuration_schema.json",
|
||||
"plugins": ["react", "typescript", "oxc"],
|
||||
"options": {
|
||||
"typeAware": true
|
||||
},
|
||||
"rules": {
|
||||
"react/rules-of-hooks": "error",
|
||||
"react/only-export-components": ["warn", { "allowConstantExport": true }]
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
See the [Oxlint rules documentation](https://oxc.rs/docs/guide/usage/linter/rules) for the full list of rules and categories.
|
||||
12
apps/web/index.html
Normal file
12
apps/web/index.html
Normal file
@@ -0,0 +1,12 @@
|
||||
<!doctype html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>项目工作台</title>
|
||||
</head>
|
||||
<body>
|
||||
<div id="app"></div>
|
||||
<script type="module" src="/src/main.ts"></script>
|
||||
</body>
|
||||
</html>
|
||||
2626
apps/web/package-lock.json
generated
Normal file
2626
apps/web/package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
25
apps/web/package.json
Normal file
25
apps/web/package.json
Normal file
@@ -0,0 +1,25 @@
|
||||
{
|
||||
"name": "web",
|
||||
"private": true,
|
||||
"version": "0.0.0",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
"build": "vite build",
|
||||
"test": "vitest",
|
||||
"preview": "vite preview"
|
||||
},
|
||||
"dependencies": {
|
||||
"@sveltejs/vite-plugin-svelte": "^6.2.1",
|
||||
"svelte": "^5.42.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@testing-library/jest-dom": "^6.9.1",
|
||||
"@testing-library/svelte": "^5.2.9",
|
||||
"@tsconfig/svelte": "^5.0.5",
|
||||
"jsdom": "^27.3.0",
|
||||
"typescript": "~6.0.2",
|
||||
"vite": "^7.2.7",
|
||||
"vitest": "^4.0.16"
|
||||
}
|
||||
}
|
||||
1
apps/web/public/favicon.svg
Normal file
1
apps/web/public/favicon.svg
Normal file
File diff suppressed because one or more lines are too long
|
After Width: | Height: | Size: 9.3 KiB |
24
apps/web/public/icons.svg
Normal file
24
apps/web/public/icons.svg
Normal file
@@ -0,0 +1,24 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg">
|
||||
<symbol id="bluesky-icon" viewBox="0 0 16 17">
|
||||
<g clip-path="url(#bluesky-clip)"><path fill="#08060d" d="M7.75 7.735c-.693-1.348-2.58-3.86-4.334-5.097-1.68-1.187-2.32-.981-2.74-.79C.188 2.065.1 2.812.1 3.251s.241 3.602.398 4.13c.52 1.744 2.367 2.333 4.07 2.145-2.495.37-4.71 1.278-1.805 4.512 3.196 3.309 4.38-.71 4.987-2.746.608 2.036 1.307 5.91 4.93 2.746 2.72-2.746.747-4.143-1.747-4.512 1.702.189 3.55-.4 4.07-2.145.156-.528.397-3.691.397-4.13s-.088-1.186-.575-1.406c-.42-.19-1.06-.395-2.741.79-1.755 1.24-3.64 3.752-4.334 5.099"/></g>
|
||||
<defs><clipPath id="bluesky-clip"><path fill="#fff" d="M.1.85h15.3v15.3H.1z"/></clipPath></defs>
|
||||
</symbol>
|
||||
<symbol id="discord-icon" viewBox="0 0 20 19">
|
||||
<path fill="#08060d" d="M16.224 3.768a14.5 14.5 0 0 0-3.67-1.153c-.158.286-.343.67-.47.976a13.5 13.5 0 0 0-4.067 0c-.128-.306-.317-.69-.476-.976A14.4 14.4 0 0 0 3.868 3.77C1.546 7.28.916 10.703 1.231 14.077a14.7 14.7 0 0 0 4.5 2.306q.545-.748.965-1.587a9.5 9.5 0 0 1-1.518-.74q.191-.14.372-.293c2.927 1.369 6.107 1.369 8.999 0q.183.152.372.294-.723.437-1.52.74.418.838.963 1.588a14.6 14.6 0 0 0 4.504-2.308c.37-3.911-.63-7.302-2.644-10.309m-9.13 8.234c-.878 0-1.599-.82-1.599-1.82 0-.998.705-1.82 1.6-1.82.894 0 1.614.82 1.599 1.82.001 1-.705 1.82-1.6 1.82m5.91 0c-.878 0-1.599-.82-1.599-1.82 0-.998.705-1.82 1.6-1.82.893 0 1.614.82 1.599 1.82 0 1-.706 1.82-1.6 1.82"/>
|
||||
</symbol>
|
||||
<symbol id="documentation-icon" viewBox="0 0 21 20">
|
||||
<path fill="none" stroke="#aa3bff" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.35" d="m15.5 13.333 1.533 1.322c.645.555.967.833.967 1.178s-.322.623-.967 1.179L15.5 18.333m-3.333-5-1.534 1.322c-.644.555-.966.833-.966 1.178s.322.623.966 1.179l1.534 1.321"/>
|
||||
<path fill="none" stroke="#aa3bff" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.35" d="M17.167 10.836v-4.32c0-1.41 0-2.117-.224-2.68-.359-.906-1.118-1.621-2.08-1.96-.599-.21-1.349-.21-2.848-.21-2.623 0-3.935 0-4.983.369-1.684.591-3.013 1.842-3.641 3.428C3 6.449 3 7.684 3 10.154v2.122c0 2.558 0 3.838.706 4.726q.306.383.713.671c.76.536 1.79.64 3.581.66"/>
|
||||
<path fill="none" stroke="#aa3bff" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.35" d="M3 10a2.78 2.78 0 0 1 2.778-2.778c.555 0 1.209.097 1.748-.047.48-.129.854-.503.982-.982.145-.54.048-1.194.048-1.749a2.78 2.78 0 0 1 2.777-2.777"/>
|
||||
</symbol>
|
||||
<symbol id="github-icon" viewBox="0 0 19 19">
|
||||
<path fill="#08060d" fill-rule="evenodd" d="M9.356 1.85C5.05 1.85 1.57 5.356 1.57 9.694a7.84 7.84 0 0 0 5.324 7.44c.387.079.528-.168.528-.376 0-.182-.013-.805-.013-1.454-2.165.467-2.616-.935-2.616-.935-.349-.91-.864-1.143-.864-1.143-.71-.48.051-.48.051-.48.787.051 1.2.805 1.2.805.695 1.194 1.817.857 2.268.649.064-.507.27-.857.49-1.052-1.728-.182-3.545-.857-3.545-3.87 0-.857.31-1.558.8-2.104-.078-.195-.349-1 .077-2.078 0 0 .657-.208 2.14.805a7.5 7.5 0 0 1 1.946-.26c.657 0 1.328.092 1.946.26 1.483-1.013 2.14-.805 2.14-.805.426 1.078.155 1.883.078 2.078.502.546.799 1.247.799 2.104 0 3.013-1.818 3.675-3.558 3.87.284.247.528.714.528 1.454 0 1.052-.012 1.896-.012 2.156 0 .208.142.455.528.377a7.84 7.84 0 0 0 5.324-7.441c.013-4.338-3.48-7.844-7.773-7.844" clip-rule="evenodd"/>
|
||||
</symbol>
|
||||
<symbol id="social-icon" viewBox="0 0 20 20">
|
||||
<path fill="none" stroke="#aa3bff" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.35" d="M12.5 6.667a4.167 4.167 0 1 0-8.334 0 4.167 4.167 0 0 0 8.334 0"/>
|
||||
<path fill="none" stroke="#aa3bff" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.35" d="M2.5 16.667a5.833 5.833 0 0 1 8.75-5.053m3.837.474.513 1.035c.07.144.257.282.414.309l.93.155c.596.1.736.536.307.965l-.723.73a.64.64 0 0 0-.152.531l.207.903c.164.715-.213.991-.84.618l-.872-.52a.63.63 0 0 0-.577 0l-.872.52c-.624.373-1.003.094-.84-.618l.207-.903a.64.64 0 0 0-.152-.532l-.723-.729c-.426-.43-.289-.864.306-.964l.93-.156a.64.64 0 0 0 .412-.31l.513-1.034c.28-.562.735-.562 1.012 0"/>
|
||||
</symbol>
|
||||
<symbol id="x-icon" viewBox="0 0 19 19">
|
||||
<path fill="#08060d" fill-rule="evenodd" d="M1.893 1.98c.052.072 1.245 1.769 2.653 3.77l2.892 4.114c.183.261.333.48.333.486s-.068.089-.152.183l-.522.593-.765.867-3.597 4.087c-.375.426-.734.834-.798.905a1 1 0 0 0-.118.148c0 .01.236.017.664.017h.663l.729-.83c.4-.457.796-.906.879-.999a692 692 0 0 0 1.794-2.038c.034-.037.301-.34.594-.675l.551-.624.345-.392a7 7 0 0 1 .34-.374c.006 0 .93 1.306 2.052 2.903l2.084 2.965.045.063h2.275c1.87 0 2.273-.003 2.266-.021-.008-.02-1.098-1.572-3.894-5.547-2.013-2.862-2.28-3.246-2.273-3.266.008-.019.282-.332 2.085-2.38l2-2.274 1.567-1.782c.022-.028-.016-.03-.65-.03h-.674l-.3.342a871 871 0 0 1-1.782 2.025c-.067.075-.405.458-.75.852a100 100 0 0 1-.803.91c-.148.172-.299.344-.99 1.127-.304.343-.32.358-.345.327-.015-.019-.904-1.282-1.976-2.808L6.365 1.85H1.8zm1.782.91 8.078 11.294c.772 1.08 1.413 1.973 1.425 1.984.016.017.241.02 1.05.017l1.03-.004-2.694-3.766L7.796 5.75 5.722 2.852l-1.039-.004-1.039-.004z" clip-rule="evenodd"/>
|
||||
</symbol>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 4.9 KiB |
30
apps/web/src/app/App.svelte
Normal file
30
apps/web/src/app/App.svelte
Normal file
@@ -0,0 +1,30 @@
|
||||
<script lang="ts">
|
||||
import ProjectDashboard from '../features/projects/ProjectDashboard.svelte';
|
||||
import ServerLogin from '../features/auth/ServerLogin.svelte';
|
||||
|
||||
let apiBase = localStorage.getItem('apiBase') ?? 'http://localhost:8080';
|
||||
|
||||
function handleServerChange(event: CustomEvent<{ apiBase: string }>) {
|
||||
apiBase = event.detail.apiBase;
|
||||
localStorage.setItem('apiBase', apiBase);
|
||||
}
|
||||
</script>
|
||||
|
||||
<main class="shell">
|
||||
<aside class="sidebar">
|
||||
<h1>项目工作台</h1>
|
||||
<ServerLogin {apiBase} on:serverChange={handleServerChange} />
|
||||
</aside>
|
||||
|
||||
<section class="workspace">
|
||||
<ProjectDashboard
|
||||
summary={{
|
||||
project_id: 1,
|
||||
pending_inbox_count: 0,
|
||||
open_task_count: 0,
|
||||
recent_note_count: 0,
|
||||
recent_session_count: 0,
|
||||
}}
|
||||
/>
|
||||
</section>
|
||||
</main>
|
||||
10
apps/web/src/app/tabs.ts
Normal file
10
apps/web/src/app/tabs.ts
Normal file
@@ -0,0 +1,10 @@
|
||||
export type WorkspaceTab = {
|
||||
key: string;
|
||||
title: string;
|
||||
route: string;
|
||||
};
|
||||
|
||||
export function openTab(existing: WorkspaceTab[], next: WorkspaceTab): WorkspaceTab[] {
|
||||
if (existing.some((tab) => tab.key === next.key)) return existing;
|
||||
return [...existing, next];
|
||||
}
|
||||
BIN
apps/web/src/assets/hero.png
Normal file
BIN
apps/web/src/assets/hero.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 13 KiB |
1
apps/web/src/assets/vite.svg
Normal file
1
apps/web/src/assets/vite.svg
Normal file
File diff suppressed because one or more lines are too long
|
After Width: | Height: | Size: 8.5 KiB |
28
apps/web/src/features/auth/ServerLogin.svelte
Normal file
28
apps/web/src/features/auth/ServerLogin.svelte
Normal file
@@ -0,0 +1,28 @@
|
||||
<script lang="ts">
|
||||
import { createEventDispatcher } from 'svelte';
|
||||
|
||||
export let apiBase: string;
|
||||
|
||||
const dispatch = createEventDispatcher<{ serverChange: { apiBase: string } }>();
|
||||
let server = apiBase;
|
||||
|
||||
function saveServer() {
|
||||
const normalized = normalizeServer(server);
|
||||
server = normalized;
|
||||
dispatch('serverChange', { apiBase: normalized });
|
||||
}
|
||||
|
||||
function normalizeServer(value: string) {
|
||||
const trimmed = value.trim();
|
||||
if (trimmed.startsWith('http://') || trimmed.startsWith('https://')) {
|
||||
return trimmed;
|
||||
}
|
||||
return `http://${trimmed}`;
|
||||
}
|
||||
</script>
|
||||
|
||||
<form aria-label="服务器登录" class="server-login" on:submit|preventDefault={saveServer}>
|
||||
<label for="server-address">服务器 IP 或域名</label>
|
||||
<input id="server-address" name="server" bind:value={server} placeholder="http://localhost:8080" />
|
||||
<button type="submit">保存服务器</button>
|
||||
</form>
|
||||
21
apps/web/src/features/projects/ProjectDashboard.svelte
Normal file
21
apps/web/src/features/projects/ProjectDashboard.svelte
Normal file
@@ -0,0 +1,21 @@
|
||||
<script lang="ts">
|
||||
import type { ProjectDashboardSummary } from '../../lib/api';
|
||||
|
||||
export let summary: ProjectDashboardSummary;
|
||||
|
||||
$: metrics = [
|
||||
['待处理 Inbox', summary.pending_inbox_count],
|
||||
['当前任务', summary.open_task_count],
|
||||
['笔记资料', summary.recent_note_count],
|
||||
['AI 会话', summary.recent_session_count],
|
||||
] as const;
|
||||
</script>
|
||||
|
||||
<section aria-label="项目总览" class="dashboard-grid">
|
||||
{#each metrics as [label, value]}
|
||||
<article class="dashboard-metric">
|
||||
<span>{label}</span>
|
||||
<strong>{value}</strong>
|
||||
</article>
|
||||
{/each}
|
||||
</section>
|
||||
25
apps/web/src/features/projects/ProjectDashboard.test.ts
Normal file
25
apps/web/src/features/projects/ProjectDashboard.test.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
import '@testing-library/jest-dom/vitest';
|
||||
import { render, screen } from '@testing-library/svelte';
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import ProjectDashboard from './ProjectDashboard.svelte';
|
||||
|
||||
describe('ProjectDashboard', () => {
|
||||
it('shows project counters', () => {
|
||||
render(ProjectDashboard, {
|
||||
props: {
|
||||
summary: {
|
||||
project_id: 1,
|
||||
pending_inbox_count: 2,
|
||||
open_task_count: 5,
|
||||
recent_note_count: 3,
|
||||
recent_session_count: 4,
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
expect(screen.getByText('待处理 Inbox')).toBeInTheDocument();
|
||||
expect(screen.getByText('2')).toBeInTheDocument();
|
||||
expect(screen.getByText('当前任务')).toBeInTheDocument();
|
||||
expect(screen.getByText('5')).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
111
apps/web/src/index.css
Normal file
111
apps/web/src/index.css
Normal file
@@ -0,0 +1,111 @@
|
||||
:root {
|
||||
color: #202124;
|
||||
background: #f6f7f9;
|
||||
font-family:
|
||||
Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
|
||||
line-height: 1.5;
|
||||
}
|
||||
|
||||
* {
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
body {
|
||||
margin: 0;
|
||||
min-width: 320px;
|
||||
min-height: 100vh;
|
||||
}
|
||||
|
||||
button,
|
||||
input,
|
||||
textarea,
|
||||
select {
|
||||
font: inherit;
|
||||
}
|
||||
|
||||
.shell {
|
||||
display: grid;
|
||||
grid-template-columns: 280px 1fr;
|
||||
min-height: 100vh;
|
||||
}
|
||||
|
||||
.sidebar {
|
||||
border-right: 1px solid #d9dde3;
|
||||
background: #ffffff;
|
||||
padding: 24px;
|
||||
}
|
||||
|
||||
.sidebar h1 {
|
||||
margin: 0 0 24px;
|
||||
font-size: 24px;
|
||||
}
|
||||
|
||||
.workspace {
|
||||
padding: 24px;
|
||||
}
|
||||
|
||||
.server-login {
|
||||
display: grid;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.server-login label {
|
||||
font-size: 13px;
|
||||
color: #4b5563;
|
||||
}
|
||||
|
||||
.server-login input {
|
||||
width: 100%;
|
||||
border: 1px solid #c7ccd4;
|
||||
border-radius: 6px;
|
||||
padding: 9px 10px;
|
||||
}
|
||||
|
||||
.server-login button {
|
||||
border: 1px solid #1f2937;
|
||||
border-radius: 6px;
|
||||
background: #1f2937;
|
||||
color: white;
|
||||
padding: 9px 10px;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.dashboard-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(4, minmax(160px, 1fr));
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
.dashboard-metric {
|
||||
border: 1px solid #d9dde3;
|
||||
border-radius: 8px;
|
||||
background: white;
|
||||
padding: 16px;
|
||||
}
|
||||
|
||||
.dashboard-metric span {
|
||||
display: block;
|
||||
color: #5f6673;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.dashboard-metric strong {
|
||||
display: block;
|
||||
margin-top: 8px;
|
||||
font-size: 28px;
|
||||
}
|
||||
|
||||
@media (max-width: 760px) {
|
||||
.shell {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
|
||||
.sidebar {
|
||||
border-right: 0;
|
||||
border-bottom: 1px solid #d9dde3;
|
||||
}
|
||||
|
||||
.dashboard-grid {
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
}
|
||||
}
|
||||
23
apps/web/src/lib/api.ts
Normal file
23
apps/web/src/lib/api.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
export type Project = { id: number; name: string; description: string };
|
||||
|
||||
export type ProjectDashboardSummary = {
|
||||
project_id: number;
|
||||
pending_inbox_count: number;
|
||||
open_task_count: number;
|
||||
recent_note_count: number;
|
||||
recent_session_count: number;
|
||||
};
|
||||
|
||||
export function createApi(apiBase: string) {
|
||||
async function request<T>(path: string): Promise<T> {
|
||||
const response = await fetch(`${apiBase}${path}`);
|
||||
if (!response.ok) throw new Error(`API request failed: ${response.status}`);
|
||||
return response.json() as Promise<T>;
|
||||
}
|
||||
|
||||
return {
|
||||
getProjects: () => request<Project[]>('/projects'),
|
||||
getProjectDashboard: (projectID: number) =>
|
||||
request<ProjectDashboardSummary>(`/projects/${projectID}/dashboard`),
|
||||
};
|
||||
}
|
||||
10
apps/web/src/main.ts
Normal file
10
apps/web/src/main.ts
Normal file
@@ -0,0 +1,10 @@
|
||||
import './index.css';
|
||||
import App from './app/App.svelte';
|
||||
|
||||
const target = document.getElementById('app');
|
||||
|
||||
if (!target) {
|
||||
throw new Error('Missing #app mount target');
|
||||
}
|
||||
|
||||
new App({ target });
|
||||
2
apps/web/src/vite-env.d.ts
vendored
Normal file
2
apps/web/src/vite-env.d.ts
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
/// <reference types="svelte" />
|
||||
/// <reference types="vite/client" />
|
||||
18
apps/web/tsconfig.app.json
Normal file
18
apps/web/tsconfig.app.json
Normal file
@@ -0,0 +1,18 @@
|
||||
{
|
||||
"extends": "@tsconfig/svelte/tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"target": "ES2023",
|
||||
"useDefineForClassFields": true,
|
||||
"module": "ESNext",
|
||||
"resolveJsonModule": true,
|
||||
"allowJs": true,
|
||||
"checkJs": true,
|
||||
"isolatedModules": true,
|
||||
"moduleDetection": "force",
|
||||
"types": ["svelte", "vite/client", "vitest/globals"],
|
||||
"noEmit": true,
|
||||
"strict": true
|
||||
},
|
||||
"include": ["src/**/*.d.ts", "src/**/*.ts", "src/**/*.js", "src/**/*.svelte"],
|
||||
"references": [{ "path": "./tsconfig.node.json" }]
|
||||
}
|
||||
7
apps/web/tsconfig.json
Normal file
7
apps/web/tsconfig.json
Normal file
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"files": [],
|
||||
"references": [
|
||||
{ "path": "./tsconfig.app.json" },
|
||||
{ "path": "./tsconfig.node.json" }
|
||||
]
|
||||
}
|
||||
23
apps/web/tsconfig.node.json
Normal file
23
apps/web/tsconfig.node.json
Normal file
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.node.tsbuildinfo",
|
||||
"target": "es2023",
|
||||
"lib": ["ES2023"],
|
||||
"types": ["node"],
|
||||
"skipLibCheck": true,
|
||||
|
||||
/* Bundler mode */
|
||||
"module": "nodenext",
|
||||
"allowImportingTsExtensions": true,
|
||||
"verbatimModuleSyntax": true,
|
||||
"moduleDetection": "force",
|
||||
"noEmit": true,
|
||||
|
||||
/* Linting */
|
||||
"noUnusedLocals": true,
|
||||
"noUnusedParameters": true,
|
||||
"erasableSyntaxOnly": true,
|
||||
"noFallthroughCasesInSwitch": true
|
||||
},
|
||||
"include": ["vite.config.ts"]
|
||||
}
|
||||
13
apps/web/vite.config.ts
Normal file
13
apps/web/vite.config.ts
Normal file
@@ -0,0 +1,13 @@
|
||||
import { svelte } from '@sveltejs/vite-plugin-svelte';
|
||||
import { defineConfig } from 'vite';
|
||||
|
||||
export default defineConfig({
|
||||
plugins: [svelte()],
|
||||
resolve: {
|
||||
conditions: ['browser'],
|
||||
},
|
||||
test: {
|
||||
environment: 'jsdom',
|
||||
globals: true,
|
||||
},
|
||||
});
|
||||
@@ -4,9 +4,9 @@
|
||||
|
||||
**Goal:** 构建一个以项目为中心的私有部署工作台 MVP,包含项目、Inbox、任务、Markdown 笔记资料、AI 会话、全文搜索、任务分发和 Tauri 桌面壳。
|
||||
|
||||
**Architecture:** 使用前后端分离 monorepo。`backend` 提供 Go Gin + Gorm + PostgreSQL API,`apps/web` 提供响应式 React Web 客户端,`apps/desktop` 用 Tauri 包装 Web 客户端并提供桌面能力。先实现清晰模块边界,再逐步接入 AI、搜索和桌面特性。
|
||||
**Architecture:** 使用前后端分离 monorepo。`backend` 提供 Go Gin + Gorm + PostgreSQL API,`apps/web` 提供响应式 Svelte Web 客户端,`apps/desktop` 用 Tauri 包装 Web 客户端并提供桌面能力。先实现清晰模块边界,再逐步接入 AI、搜索和桌面特性。
|
||||
|
||||
**Tech Stack:** Go 1.22+, Gin, Gorm, PostgreSQL 16+, React, TypeScript, Vite, TanStack Query, Tauri 2, Vitest, Playwright, Docker Compose.
|
||||
**Tech Stack:** Go 1.22+, Gin, Gorm, PostgreSQL 16+, Svelte, TypeScript, Vite, Tauri 2, Vitest, Testing Library for Svelte, Playwright, Docker Compose.
|
||||
|
||||
## Global Constraints
|
||||
|
||||
@@ -18,6 +18,9 @@
|
||||
- AI 不得自动创建正式对象,Inbox 分析结果必须由用户确认。
|
||||
- 任务分发只面向系统内用户,接收者只能看到任务和显式共享的关联对象。
|
||||
- 全局搜索使用 PostgreSQL 关键词和全文搜索,语义搜索不进入 MVP。
|
||||
- 前端只使用 Svelte,不使用 React。
|
||||
- 登录页必须允许用户填写服务器 IP 或域名,并将其保存为 API base URL。
|
||||
- PostgreSQL 集成验证使用 `postgres://postgres:Weidong2023~!@8.137.107.29:19432/agent_dev?sslmode=disable`。
|
||||
- 前端桌面优先,同时保持移动浏览器可用。
|
||||
- 每个任务结束时运行该任务列出的验证命令并提交。
|
||||
|
||||
@@ -540,8 +543,9 @@ git commit -m "feat: add core data model"
|
||||
- Produces: `api.getProjectDashboard(projectID: number): Promise<ProjectDashboardSummary>`
|
||||
- Produces: `openTab(existing: WorkspaceTab[], next: WorkspaceTab): WorkspaceTab[]`
|
||||
|
||||
- [ ] Scaffold Vite React TypeScript app.
|
||||
- [ ] Install TanStack Query, lucide-react, Vitest, Testing Library, jsdom.
|
||||
- [ ] Scaffold Vite Svelte TypeScript app.
|
||||
- [ ] Install Svelte, Vitest, Testing Library for Svelte, jest-dom, jsdom.
|
||||
- [ ] Implement server address input on the login shell and persist it as API base URL.
|
||||
- [ ] Test dashboard renders pending inbox, current tasks, notes, and AI sessions.
|
||||
- [ ] Implement API client.
|
||||
- [ ] Implement browser-style tab state helper.
|
||||
|
||||
@@ -29,7 +29,8 @@
|
||||
- 跨项目关键词搜索和全文搜索。
|
||||
- 向系统内用户分发任务。
|
||||
- 显式共享任务关联对象。
|
||||
- 响应式 Web 前端,并由 Tauri 包装为桌面客户端。
|
||||
- 响应式 Svelte Web 前端,并由 Tauri 包装为桌面客户端。
|
||||
- 客户端登录时需要填写服务器 IP 或域名,作为 API 服务地址。
|
||||
- Tauri 桌面能力:登录持久化、文件拖拽上传、系统通知、全局快捷键快速收集。
|
||||
- Go Gin + Gorm 后端,数据库使用 PostgreSQL。
|
||||
- 服务端本地文件存储。
|
||||
@@ -201,7 +202,7 @@ MVP 中的 AI session 是普通项目聊天,不是自主 Agent 运行。模型
|
||||
|
||||
## 前端与 Tauri 设计
|
||||
|
||||
前端是响应式 Web 应用,桌面优先,同时保证移动浏览器可用。Tauri 包装同一套前端作为桌面客户端。
|
||||
前端是响应式 Svelte Web 应用,桌面优先,同时保证移动浏览器可用。Tauri 包装同一套前端作为桌面客户端。登录页必须允许用户填写服务器 IP 或域名,并将其作为后续 API 请求的服务器地址。
|
||||
|
||||
Tauri MVP 能力:
|
||||
- 登录状态持久化。
|
||||
@@ -224,6 +225,7 @@ MVP 使用保守共享模型:
|
||||
后端:
|
||||
- AI key 选择、inbox 处理、任务共享可见性、标签项目隔离、文件元数据处理的单元测试。
|
||||
- 项目搜索、任务分发、inbox 转对象的集成测试。
|
||||
- 需要真实 PostgreSQL 时,使用测试服务器 `postgres://postgres:Weidong2023~!@8.137.107.29:19432/agent_dev?sslmode=disable`。
|
||||
|
||||
前端:
|
||||
- 项目 Dashboard、inbox 建议确认、AI session 列表、任务列表、快速收集表单的组件测试。
|
||||
|
||||
Reference in New Issue
Block a user