初始化项目基础结构

添加了完整的前后端开发环境配置,包括:
- 创建 .gitignore 文件忽略本地生成目录和环境文件
- 添加详细的 README.md 开发指南文档
- 配置 backend 目录结构和 FastAPI 应用基础框架
- 实现应用配置管理、健康检查和状态接口
- 设置 uv 依赖管理和虚拟环境配置
- 完成 CORS 中间件配置支持前端开发联调
This commit is contained in:
2026-08-27 11:19:36 +08:00
commit 08e4aeea0c
29 changed files with 3539 additions and 0 deletions
+95
View File
@@ -0,0 +1,95 @@
<script setup lang="ts">
import { onMounted, ref } from 'vue'
import { getServiceStatus, type ServiceStatus } from './api'
const service = ref<ServiceStatus | null>(null)
const error = ref('')
const loading = ref(false)
async function checkBackend() {
loading.value = true
error.value = ''
try {
service.value = await getServiceStatus()
} catch (reason) {
service.value = null
error.value = reason instanceof Error ? reason.message : '未知错误'
} finally {
loading.value = false
}
}
onMounted(checkBackend)
</script>
<template>
<main class="app-shell">
<aside class="sidebar">
<div class="brand">
<span class="brand-mark">N</span>
<span>Notes Agent</span>
</div>
<nav aria-label="主导航">
<button class="nav-item active" type="button">工作台</button>
<button class="nav-item" type="button" disabled>笔记</button>
<button class="nav-item" type="button" disabled>AI 助手</button>
<button class="nav-item" type="button" disabled>设置</button>
</nav>
<p class="sidebar-hint">Vue 3 + TypeScript</p>
</aside>
<section class="workspace">
<header>
<p class="eyebrow">LOCAL-FIRST AI NOTES</p>
<h1>项目基础壳子</h1>
<p class="subtitle">前端界面已经就绪并通过统一 API Client 检查 FastAPI 服务</p>
</header>
<div class="cards">
<article class="card hero-card">
<div>
<p class="card-label">AI Core</p>
<h2>后端连接状态</h2>
</div>
<div v-if="service" class="status-line success">
<span class="status-dot" />
<div>
<strong>服务正常</strong>
<p>{{ service.name }} · v{{ service.version }} · {{ service.environment }}</p>
</div>
</div>
<div v-else-if="error" class="status-line error">
<span class="status-dot" />
<div>
<strong>暂未连接</strong>
<p>{{ error }}</p>
</div>
</div>
<div v-else class="status-line">
<span class="status-dot" />
<p>正在检查服务</p>
</div>
<button class="primary-button" type="button" :disabled="loading" @click="checkBackend">
{{ loading ? '检查中' : '重新检查' }}
</button>
</article>
<article class="card">
<p class="card-label">FRONTEND</p>
<h2>Vue 3 + TypeScript</h2>
<p>使用 Vite 启动开发环境已配置后端代理</p>
</article>
<article class="card">
<p class="card-label">BACKEND</p>
<h2>FastAPI + Pydantic</h2>
<p>包含健康检查状态接口和自动 OpenAPI 文档</p>
</article>
</div>
</section>
</main>
</template>
+16
View File
@@ -0,0 +1,16 @@
export interface ServiceStatus {
name: string
version: string
environment: string
status: 'ok'
}
const apiBaseUrl = import.meta.env.VITE_API_BASE_URL ?? ''
export async function getServiceStatus(): Promise<ServiceStatus> {
const response = await fetch(`${apiBaseUrl}/api/status`)
if (!response.ok) {
throw new Error(`后端请求失败:HTTP ${response.status}`)
}
return response.json() as Promise<ServiceStatus>
}
+1
View File
@@ -0,0 +1 @@
/// <reference types="vite/client" />
+5
View File
@@ -0,0 +1,5 @@
import { createApp } from 'vue'
import App from './App.vue'
import './style.css'
createApp(App).mount('#app')
+70
View File
@@ -0,0 +1,70 @@
:root {
font-family: Inter, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
color: #20211f;
background: #f4f1e9;
font-synthesis: none;
text-rendering: optimizeLegibility;
--ink: #20211f;
--muted: #77776f;
--paper: #fffdf7;
--line: #dedbd0;
--accent: #e76f3d;
--success: #307b59;
}
* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; min-height: 100vh; }
button { font: inherit; }
.app-shell { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.sidebar {
display: flex; flex-direction: column; padding: 28px 20px;
color: #f8f5ed; background: #20211f;
}
.brand { display: flex; align-items: center; gap: 12px; margin-bottom: 48px; font-weight: 700; }
.brand-mark {
display: grid; place-items: center; width: 32px; height: 32px;
border-radius: 10px; color: #20211f; background: #f2c14e;
}
nav { display: grid; gap: 6px; }
.nav-item {
padding: 11px 14px; border: 0; border-radius: 8px; text-align: left;
color: #bcbdb7; background: transparent;
}
.nav-item.active { color: white; background: #343632; }
.nav-item:disabled { cursor: not-allowed; opacity: .55; }
.sidebar-hint { margin-top: auto; color: #8f918a; font-size: 13px; }
.workspace { padding: 64px clamp(28px, 6vw, 88px); }
.workspace header { max-width: 720px; margin-bottom: 42px; }
.eyebrow, .card-label { margin: 0 0 10px; color: var(--accent); font-size: 12px; font-weight: 800; letter-spacing: .14em; }
h1 { margin: 0; font-family: Georgia, "Noto Serif SC", serif; font-size: clamp(42px, 7vw, 76px); line-height: 1; letter-spacing: -.045em; }
.subtitle { max-width: 580px; margin: 20px 0 0; color: var(--muted); font-size: 17px; line-height: 1.7; }
.cards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; max-width: 960px; }
.card { min-height: 180px; padding: 28px; border: 1px solid var(--line); border-radius: 18px; background: var(--paper); box-shadow: 0 12px 40px rgb(46 43 36 / 6%); }
.hero-card { grid-column: 1 / -1; display: grid; grid-template-columns: 1fr auto; gap: 22px; align-items: center; }
.card h2 { margin: 0 0 12px; font-size: 21px; }
.card p { color: var(--muted); line-height: 1.6; }
.status-line { display: flex; align-items: center; gap: 12px; min-width: 250px; }
.status-line p { margin: 3px 0 0; font-size: 13px; }
.status-dot { width: 10px; height: 10px; border-radius: 50%; background: #aaa; box-shadow: 0 0 0 5px rgb(120 120 120 / 10%); }
.status-line.success .status-dot { background: var(--success); box-shadow: 0 0 0 5px rgb(48 123 89 / 12%); }
.status-line.error .status-dot { background: #b84737; box-shadow: 0 0 0 5px rgb(184 71 55 / 12%); }
.primary-button {
justify-self: end; padding: 10px 16px; border: 0; border-radius: 9px;
color: white; background: var(--ink); cursor: pointer;
}
.primary-button:disabled { cursor: wait; opacity: .6; }
@media (max-width: 720px) {
.app-shell { grid-template-columns: 1fr; }
.sidebar { min-height: auto; padding: 18px 20px; }
.brand { margin-bottom: 18px; }
nav { grid-template-columns: repeat(4, 1fr); }
.nav-item { padding: 9px 6px; text-align: center; font-size: 13px; }
.sidebar-hint { display: none; }
.workspace { padding-top: 42px; }
.cards { grid-template-columns: 1fr; }
.hero-card { display: grid; grid-column: auto; }
.primary-button { justify-self: start; }
}