Merge branch 'dev' into test

This commit is contained in:
sophie committed 2026-05-27 16:07:45 +08:00
commit eae9886ece
38 files changed
+3950 -3305

No files matched your search

+393
View File
@@ -0,0 +1,393 @@
# HXOps 前端三层设计系统方案
> 目标:在**明亮 / 暗黑**主题下,页面背景、文字、边框、按钮、卡片、布局间距保持一致;新页面默认符合规范,旧页面按阶段迁移。
---
## 1. 总体架构
```
┌─────────────────────────────────────────────────────────────┐
│ L3 布局壳 Layout(PageShell / AppShell / ChatShell) │
│ 决定:全页结构、顶栏高度、侧栏宽度、主区内边距 │
├─────────────────────────────────────────────────────────────┤
│ L2 组件类 Components(.btn / .card / .input-field / …) │
│ 决定:按钮、表单、卡片、徽章、弹层等可复用 UI 块 │
├─────────────────────────────────────────────────────────────┤
│ L1 设计令牌 Tokens(CSS 变量,:root + html.dark) │
│ 决定:颜色、阴影、圆角基数;亮暗只改变量,不写 dark: │
└─────────────────────────────────────────────────────────────┘
```
**核心原则**
| 原则 | 说明 |
|------|------|
| 单一色源 | 页面背景/文字/边框只来自 L1 变量(通过语义 class 引用) |
| 亮暗自动 | 组件与布局**不写** `dark:bg-*`,切换 `html.dark` 即可 |
| 向下约束 | L3 只能用 L2;L2 只能用 L1;禁止页面内 `text-[#hex]` |
| 例外登记 | 登录 Hero 渐变、Agent 图标等允许 `data-surface="marketing"` |
**与现有代码的关系**
- 保留:`useTheme`、`ThemeToggleButton`、`tailwind darkMode: 'class'`、`brand` 色阶
- 演进:逐步减少 `style.css` 中 `html.dark .bg-white !important` 补丁(迁移完成后删除)
- 统一字体:`tailwind.config.js` 的 `sans` 与 `style.css` 的 `html` 字体一致(见 §1.1)
### 1.1 字体(一次性对齐)
```js
// tailwind.config.js — 与 style.css 一致
fontFamily: {
sans: ['"PingFang SC"', '"Microsoft YaHei"', '"Segoe UI"', 'system-ui', 'sans-serif'],
},
```
---
## 2. L1 设计令牌(Tokens)
### 2.1 文件职责
| 文件 | 职责 |
|------|------|
| `frontend/src/styles/tokens.css` | 仅定义 `:root` / `html.dark` 变量(从 `style.css` 拆出) |
| `frontend/src/styles/utilities.css` | 语义 utility(`bg-page`、`text-primary` …) |
| `frontend/src/style.css` | `@import` 上述文件 + Tailwind + L2 组件类 |
### 2.2 语义令牌表(亮 / 暗)
| 令牌 | 明亮 | 暗黑 | 用途 |
|------|------|------|------|
| `--bg-page` | `#f8fafc` | `#020617` | 全页背景 |
| `--bg-surface` | `#ffffff` | `#0b1220` | 卡片、顶栏、主面板 |
| `--bg-surface-soft` | `#f8fafc` | `#0f172a` | 次级区域、表头、侧栏项 hover 底 |
| `--bg-surface-strong` | `#f1f5f9` | `#1e293b` | 输入框、禁用底、ghost hover |
| `--text-primary` | `#0f172a` | `#f8fafc` | 标题、强调正文 |
| `--text-secondary` | `#334155` | `#cbd5e1` | 正文 |
| `--text-muted` | `#64748b` | `#94a3b8` | 说明、占位、次要标签 |
| `--border-default` | `#e2e8f0` | `#334155` | 卡片、分割线、输入框边框 |
| `--border-subtle` | `#f1f5f9` | `#1e293b` | 弱分割 |
| `--overlay-soft` | `rgba(15,23,42,.4)` | `rgba(2,6,23,.72)` | 遮罩 |
| `--shadow-elevated` | 见现 `style.css` | 见现 `style.css` | 浮层、下拉 |
| `--glow-accent` | 见现 `style.css` | 见现 `style.css` | 玻璃面板、强调卡片 |
| `--focus-ring` | `rgba(14,165,233,.35)` | `rgba(56,189,248,.4)` | focus 环 |
**状态色(新增,供 Message / Badge / 表单校验)**
| 令牌 | 明亮背景 | 暗黑背景 | 前景 |
|------|----------|----------|------|
| `--status-success-bg` | `#eef8e8` | `rgba(34,197,94,.12)` | `--status-success-fg` |
| `--status-info-bg` | `#eaf4ff` | `rgba(56,189,248,.12)` | `--status-info-fg` |
| `--status-warning-bg` | `#fff8e8` | `rgba(250,204,21,.12)` | `--status-warning-fg` |
| `--status-error-bg` | `#fff1f0` | `rgba(239,68,68,.12)` | `--status-error-fg` |
品牌色继续使用 Tailwind `brand-50` … `brand-950`(不纳入 CSS 变量,避免重复维护)。
### 2.3 语义 Utility(L1 对外 API)
模板中**只允许**以下类表示「结构色」,禁止 `bg-white dark:bg-slate-900` 等成对写法:
```css
/* utilities.css — 示例 */
.bg-page { background-color: var(--bg-page); }
.bg-surface { background-color: var(--bg-surface); }
.bg-surface-soft { background-color: var(--bg-surface-soft); }
.bg-surface-strong{ background-color: var(--bg-surface-strong); }
.text-primary { color: var(--text-primary); }
.text-secondary { color: var(--text-secondary); }
.text-muted { color: var(--text-muted); }
.border-default { border-color: var(--border-default); }
.border-subtle { border-color: var(--border-subtle); }
.shadow-elevated { box-shadow: var(--shadow-elevated); }
```
**允许保留的 Tailwind 用法**
- 布局:`flex`、`grid`、`gap-*`、`p-*`、`max-w-*`
- 品牌:`bg-brand-600`、`text-brand-600`、`ring-brand-500`
- 状态:`.alert-success` 等 L2 类(内部用 `--status-*`)
### 2.4 Tailwind 扩展(可选,与变量对齐)
```js
// tailwind.config.js
colors: {
surface: {
page: 'var(--bg-page)',
DEFAULT: 'var(--bg-surface)',
soft: 'var(--bg-surface-soft)',
strong: 'var(--bg-surface-strong)',
},
content: {
primary: 'var(--text-primary)',
secondary: 'var(--text-secondary)',
muted: 'var(--text-muted)',
},
line: {
DEFAULT: 'var(--border-default)',
subtle: 'var(--border-subtle)',
},
},
```
团队二选一:**语义 class**(`bg-page`)或 **Tailwind 别名**(`bg-surface-page`),项目内只选一种,本文档默认 **语义 class**。
---
## 3. L2 组件类(Components)
在 `style.css` 的 `@layer components` 中维护;所有组件类**只引用 L1 变量 + brand 色**,不写 `dark:`。
### 3.1 按钮
| 类名 | 用途 |
|------|------|
| `.btn` | 基类:圆角 `rounded-xl`、过渡、对齐 |
| `.btn-primary` | 主操作:`brand-600` 背景(亮暗共用色阶) |
| `.btn-secondary` | 次要:`bg-surface` + `border-default` |
| `.btn-ghost` | 图标/工具栏 |
| `.btn-danger` | 删除、退出等 |
| `.btn-icon` | 正方形图标按钮(顶栏、侧栏折叠) |
### 3.2 表单
| 类名 | 用途 |
|------|------|
| `.input-field` | 文本输入、textarea(已有,改为变量驱动背景/边框) |
| `.select-field` | `<select>` 与 input 视觉一致 |
| `.label-field` | 表单标签:`text-xs font-semibold text-secondary uppercase` |
### 3.3 表面 / 卡片
| 类名 | 用途 |
|------|------|
| `.card` | 标准卡片:`bg-surface` + `border-default` + `rounded-2xl` + `shadow-soft` |
| `.card-interactive` | 可点击卡片:在 `.card` 上增加 hover 阴影 |
| `.surface-panel` | 区块容器(无 hover),用于 Admin 主内容区 |
| `.glass-panel` | 侧栏/浮层毛玻璃(已有,保持变量阴影) |
### 3.4 反馈
| 类名 | 用途 |
|------|------|
| `.alert-success` / `.alert-info` / `.alert-warning` / `.alert-error` | 替代 `LevelMessageDialog` 内 hex |
| `.badge` | 已有,补充 `badge-success` 等(可选) |
### 3.5 排版
| 类名 | 用途 |
|------|------|
| `.page-title` | `text-2xl font-bold text-primary` |
| `.section-title` | `text-lg font-semibold text-primary` |
| `.section-desc` | `text-sm text-muted` |
### 3.6 间距(移动端已有,扩展为全端)
| 类名 | 用途 |
|------|------|
| `.page-shell` | `min-h-screen bg-page text-secondary` |
| `.page-shell-mobile` | 水平内边距 `px-3 md:px-8`(已有) |
| `.section-gap` | 区块间距 `mb-6 md:mb-8` |
| `.card-padding` | 卡片内边距 `p-4 sm:p-6` |
### 3.7 Chat 专用(保留命名空间)
| 类名 | 用途 |
|------|------|
| `.chat-composer-shell` | 已有 |
| `.chat-composer-textarea` | 已有 |
| `.chat-history-item` | 历史列表项 active/hover(从 ChatView 抽离) |
---
## 4. L3 布局壳(Layout)
新建目录:`frontend/src/layouts/`
### 4.1 布局类型与路由映射
| 布局组件 | 使用页面 | 结构 |
|----------|----------|------|
| `MarketingShell` | 未登录 `/workspace` 登录区 | 全屏背景 + 居中卡片,顶栏固定语言/主题 |
| `AppShell` | 已登录 Workspace、KbWorkspace、Admin | 可选顶栏 + 主内容 `page-shell-mobile` |
| `ChatShell` | `/chat/:agentId` | 左栏历史 + 右主区(Chat 特化,但颜色仍走 L1) |
| `MinimalShell` | ResetPassword | 居中单卡,`max-w-md` |
### 4.2 `AppShell.vue` 规范(Admin / KB / Workspace _logged-in_)
```vue
<!-- 结构约定 -->
<div class="page-shell flex min-h-screen flex-col">
<header class="app-header"> <!-- h-14, bg-surface/80, border-b border-default, sticky -->
<slot name="header-left" />
<slot name="header-right" /> <!-- ThemeToggle + 语言 -->
</header>
<div class="flex flex-1 overflow-hidden">
<aside v-if="$slots.sidebar" class="app-sidebar"> <!-- w-64 / 折叠 w-16 -->
<slot name="sidebar" />
</aside>
<main class="flex-1 overflow-auto page-shell-mobile py-6">
<slot />
</main>
</div>
</div>
```
**尺寸令牌(L3 常量,写死在 layout 或 CSS 变量)**
| 名称 | 值 |
|------|-----|
| `--header-height` | `3.5rem` (56px) |
| `--sidebar-width` | `16rem` |
| `--sidebar-collapsed-width` | `4rem` |
| `--content-max-width` | `80rem`(营销/表单页) |
### 4.3 `ChatShell.vue`
- 外壳:`page-shell` + `flex h-screen overflow-hidden`
- 侧栏:`glass-panel` + `bg-surface` + `border-default`
- 主区:`bg-surface`(替代 `bg-white dark:bg-slate-950`)
- 顶栏(移动端):高度与 `AppShell` 的 `--header-height` 一致
### 4.4 路由层挂载(推荐)
```ts
// router/index.ts — 概念
{
path: '/admin',
component: () => import('../layouts/AppShell.vue'),
children: [{ path: '', component: AdminView }],
}
```
短期可不改路由:在各 View 根节点外包一层对应 Shell;中期再改为嵌套路由。
### 4.5 顶栏右侧统一工具区
抽组件 `layouts/AppHeaderTools.vue`:
- `ThemeToggleButton`
- 语言 `<select class="select-field select-field--compact">`
Workspace 未登录、Admin、KB 共用,避免三处各写一套样式。
---
## 5. 页面迁移对照
| 页面 | L3 布局 | L1/L2 改造要点 |
|------|---------|----------------|
| `WorkspaceView` 未登录 | `MarketingShell` | 登录卡用 `.card`;Hero 渐变保留为 `data-surface="marketing"` |
| `WorkspaceView` 已登录 | `AppShell` | `text-[#1b2b49]` → `text-primary`;Agent 卡用 `.card-interactive` |
| `ChatView` | `ChatShell` | 侧栏/主区改语义色;按钮对齐 `.btn-*` |
| `AdminView` | `AppShell` + sidebar slot | `gray-*` → 语义色;表头 `bg-surface-soft` |
| `KbWorkspaceView` | `AppShell` | 与 Admin 卡片圆角/边框一致 |
| `ResetPasswordView` | `MinimalShell` | 已用 `btn-primary`,补 `bg-page` |
| `LevelMessageDialog` | — | `STYLE_MAP` → `.alert-*` |
---
## 6. 实施阶段(建议 4 周,可并行 Review)
### Phase 0 — 基础设施(1–2 天)
- [ ] 新增 `tokens.css`、`utilities.css`,从 `style.css` 迁出变量
- [ ] 补全 `--status-*` 与语义 utility
- [ ] 统一 `tailwind.config.js` 字体
- [ ] 新增 `.alert-*`、`.app-header` 等 L2 类
- [ ] 本文档作为 PR Review 检查清单
### Phase 1 — 布局壳(2–3 天)
- [ ] 实现 `AppShell`、`MarketingShell`、`MinimalShell`、`AppHeaderTools`
- [ ] `ResetPasswordView`、`KbWorkspaceView` 接入(改动面小)
- [ ] `LevelMessageDialog` 改用 `.alert-*`
### Phase 2 — 工作台与管理端(3–5 天)
- [ ] `WorkspaceView` 已登录区接入 `AppShell` + 语义色
- [ ] `AdminView` 根布局 + 消灭 `gray-*` / 无暗色 hex
- [ ] 删除已覆盖的 `html.dark` 补丁(分批,每 PR 跑亮/暗目视)
### Phase 3 — Chat(3–5 天)
- [ ] `ChatShell` 抽离
- [ ] composer / 历史列表 L2 类
- [ ] 减少 ChatView 内 `dark:` 数量目标:**0**(仅保留 markdown/prose 等特殊区)
### Phase 4 — 收尾与门禁
- [ ] ESLint / Stylelint 可选:`no-restricted-syntax` 禁止 `dark:bg-`、`text-[#`(warning 先行)
- [ ] 删除冗余 `html.dark !important` 块
- [ ] 截图回归:亮/暗 × 桌面/移动 × 5 条主路径
---
## 7. 开发规范(Review Checklist)
**必须**
- [ ] 页面根节点有 `page-shell` 或处于 L3 布局内
- [ ] 背景/文字/边框使用 L1 语义类,无 `dark:` 颜色对
- [ ] 按钮/输入/卡片使用 L2 类名
- [ ] 新弹窗、Message 使用 `.alert-*` 或 `LevelMessageDialog`
**禁止**
- [ ] `bg-white`、`bg-gray-50`、`text-slate-800` 等作为**页面结构色**(品牌色除外)
- [ ] `text-[#xxxx]`、`bg-[#xxxx]`(`data-surface="marketing"` 除外)
- [ ] 同一元素 `bg-x dark:bg-y`
**例外(需注释 `// design-system:exception`)**
- 登录页品牌渐变、背景图
- 第三方 iframe、Markdown prose(可用 `@tailwindcss/typography` + 变量覆盖)
---
## 8. 目录结构(目标态)
```
frontend/src/
├── styles/
│ ├── tokens.css # L1 变量
│ └── utilities.css # L1 语义 class
├── style.css # Tailwind + L2 components + dark 补丁(逐步缩减)
├── layouts/
│ ├── AppShell.vue
│ ├── ChatShell.vue
│ ├── MarketingShell.vue
│ ├── MinimalShell.vue
│ └── AppHeaderTools.vue
├── components/ # 业务组件,遵守 L2
└── views/ # 只写内容与 slot,不写全页骨架色
```
---
## 9. 验收标准(Done Definition)
1. **亮暗切换**:在 Workspace / Chat / Admin / KB 四条路径切换主题,无「白块」「黑字 on 黑底」、无未适配 hex。
2. **色源唯一**:`rg "dark:(bg|text|border)-" frontend/src/views` 行数较基线下降 ≥ 80%。
3. **结构一致**:Admin 与 KB 顶栏高度、主区内边距、卡片圆角一致。
4. **组件复用**:新建表单页只引用 `.input-field` + `.btn-primary`,不复制 Tailwind 串。
---
## 10. 与当前仓库的对照(基线)
| 项目 | 现状 | 目标 |
|------|------|------|
| 主题切换 | `useTheme` + `html.dark` | 保持 |
| 色板定义 | `style.css` 变量已有 | 拆文件 + 状态色 + 语义 utility |
| 页面用法 | 大量 `dark:` + slate/gray 混用 | 仅 L1 语义类 |
| 布局 | 每 View 自建 | L3 四种 Shell |
| 补丁 | ~79 条 `html.dark !important` | 迁移后删除 |
---
*文档版本:2026-05-27 · 维护:前端 PR 附带亮/暗截图即视为遵循本规范。*
-4
View File
@@ -90,10 +90,6 @@ git config core.hooksPath .githooks
chmod +x .githooks/pre-commit .githooks/pre-push
```
### 3.3 方式 C:hxops_menu 菜单
在 Git Bash 中运行 `hxops_menu.sh`,选择 **`hook`** 或 **`43`**,确认安装。
---
## 4. 验证是否生效
@@ -14,29 +14,31 @@
#### 5.2.1 Docker Compose 编排 (`docker-compose.yml`)
我们定义了两个核心服务:
1. **hxops-backend**:
- 基于 `python:3.12-slim` 构建。
- 运行 Gunicorn + Gevent,监听 5000 端口。
- 通过 `extra_hosts` 访问宿主机数据库 (`192.168.100.230:5432`)。
- 基于 `python:3.12-slim` 构建(仓库根 `context` + `backend/Dockerfile`)。
- 运行 Gunicorn + Gevent;宿主机映射端口见 `docker-compose.yml`(当前为 `5052`)。
- 通过 `env_file` 加载 `.env.shared` 与 `.env.<ENV_NAME>`(见 `docs/env_loading_priority.md`)。
- 通过 `extra_hosts` 访问宿主机上的外部数据库等服务。
2. **hxops-frontend**:
- 基于 `nginx:alpine` 构建。
- 托管 Vue 打包后的 `dist` 目录。
- 监听 80 端口,映射到宿主机 8888。
- 配置了反向代理,将 `/api/` 转发至 `hxops-backend:5000`。
- 多阶段构建:Node 打 `dist`,Nginx 托管静态资源。
- 容器内 80 端口,宿主机映射为 `8890`(或由前置 `nginx-gateway` 反代)。
- 将 `/api/` 转发至 `hxops-backend`。
3. **hxops-kb-worker**(按需): 知识库清洗/同步 worker,与 backend 共用镜像与 env 配置。
```yaml
# docker-compose.yml 关键片段
# docker-compose.yml 关键片段(示意)
services:
hxops-backend:
build: ./backend
environment:
- DATABASE_URL=postgresql://postgres:***@192.168.100.230:5432/hxops_prod
env_file:
- .env.shared
- .env.prod # dev/test/prod 由 COMPOSE_ENV_BASENAME 切换
ports:
- "5052:5052"
extra_hosts:
- "host.docker.internal:host-gateway"
hxops-frontend:
build: ./frontend
ports:
- "8888:80"
- "8890:80"
depends_on:
- hxops-backend
```
@@ -53,11 +55,14 @@ location /api/ {
}
```
#### 5.2.3 自动化部署脚本 (`scripts/deploy.sh`)
脚本已重写以适配 Docker 流程:
1. **拉取代码**: `git pull origin super`。
2. **构建与启动**: `docker compose up -d --build --remove-orphans`。
3. **数据库迁移**: 等待容器启动后,通过 `docker compose exec` 在后端容器内执行 `flask db upgrade`。
#### 5.2.3 自动化部署脚本 (`scripts/deploy_compose.sh`)
当前标准部署入口(Jenkins 与服务器手工均使用此脚本):
1. **环境选择**: 参数 `dev` / `test` / `prod`,对应 `.env.dev`、`.env.test`、`.env.prod` 与 `.env.shared`。
2. **增量构建**: 按变更仅重建 `hxops-frontend` / `hxops-backend`(或由 Jenkins 传入镜像标签走预构建模式)。
3. **数据库迁移**: 在后端容器内执行 `flask --app manage.py db upgrade`。
4. **健康检查**: 调用 `scripts/healthcheck.sh`。
已废弃、不再维护:`scripts/deploy.sh`、根目录 `deploy.sh`、`deploy_docker_rsync.sh` 及 rsync 手工同步脚本。
### 5.3 部署操作日志 (Operations Log)
@@ -81,36 +86,36 @@ location /api/ {
# 编排前后端服务及网络
# 文件路径: docker-compose.yml
# 5. 更新部署脚本
# 适配 Docker 命令
# 文件路径: scripts/deploy.sh
# 5. 部署脚本(现行)
# 文件路径: scripts/deploy_compose.sh、scripts/healthcheck.sh
```
#### 5.3.2 代码提交
将所有配置文件提交至 `super` 分支,作为服务器部署的单一真实源。
#### 5.3.2 代码提交与 CI
日常通过 Gitee 推送触发 Jenkins;流水线在目标机 `git fetch/checkout` 后执行 `deploy_compose.sh`。
```bash
git add scripts/deploy.sh docker-compose.yml frontend/nginx.conf backend/Dockerfile frontend/Dockerfile
git commit -m "feat: Implement containerized deployment with frontend/backend separation"
git push origin super
git add scripts/deploy_compose.sh scripts/healthcheck.sh docker-compose.yml \
frontend/nginx.conf backend/Dockerfile frontend/Dockerfile .env.shared .env.prod
git commit -m "chore: align deployment with compose env profiles"
git push origin <branch>
```
### 5.4 服务器端执行指引
请管理员登录服务器 (`192.168.100.230`) 执行以下命令完成首次部署:
**推荐**:由 Jenkins 按分支部署到 dev/test/prod 主机(见仓库根 `Jenkinsfile`)。
**手工应急**(SSH 登录目标机,代码已与远端分支一致时):
```bash
# 1. 进入项目目录
cd /data/ai-platform/hxops
cd /data/ai-platform/hxops # 以实际 DEPLOY_ROOT 为准
# 2. 赋予脚本执行权限
chmod +x scripts/deploy.sh
chmod +x scripts/deploy_compose.sh scripts/healthcheck.sh
# 3. 执行部署
./scripts/deploy.sh
# 示例:生产环境全量重建前后端
./scripts/deploy_compose.sh prod true true true
```
预期输出:
- Docker 镜像开始构建(前端及后端)。
- 容器 `hxops-backend` 和 `hxops-frontend` 启动。
- 数据库迁移自动执行成功。
- 访问 `http://192.168.100.230:8888` 即可看到全新的 AI 门户。
预期结果:
- 按变更构建并启动 `hxops-backend`、`hxops-frontend`(及 worker 若已启用)。
- `flask db upgrade` 与健康检查通过。
- 经网关或直连访问前端(例如宿主机 `8890`,或现网 `nginx-gateway` 的 `8881`)。
+11 -20
View File
@@ -54,7 +54,7 @@ hxops/
│ │ └── i18n.ts # 国际化配置
│ └── vite.config.ts # Vite 配置
├── scripts/ # 运维与自动化脚本
│ ├── deploy.sh # 服务器部署脚本 (核心)
│ ├── deploy_compose.sh # Docker Compose 部署(Jenkins / 服务器)
│ ├── nginx.conf # Nginx 生产配置
│ └── supervisord.conf # Supervisor 配置
└── docs/ # 项目文档
@@ -83,20 +83,11 @@ hxops/
- 存储用户、应用配置及审计日志。
### 4.2 CI/CD 工作流
采用 **本地开发 -> Gitee 托管 -> 服务器拉取** 的流程:
采用 **本地开发 -> Gitee -> Jenkins -> 服务器 `deploy_compose.sh`**:
1. **本地开发 (Local)**:
- 代码修改 -> `git push origin super`。
- 仓库: `https://gitee.com/justop/hxops.git`
2. **服务器部署 (Server)**:
- 服务器 IP: `192.168.100.230`
- 执行脚本: `scripts/deploy.sh`
- 自动化步骤:
- 拉取最新代码 (`git pull`).
- 前端构建 (`npm install && npm run build`).
- 后端更新 (`pip install && flask db upgrade`).
- 服务重启 (`supervisorctl restart`).
1. **本地开发**: 改代码后 `git push` 到对应分支(`dev` / `test` / `prod` 等)。
2. **Jenkins**: 在目标机 `git fetch/checkout` 后执行 `scripts/deploy_compose.sh <env>`,按变更增量重建 `hxops-frontend` / `hxops-backend`,并跑 `flask db upgrade` 与健康检查。
3. **环境配置**: 仓库根目录 `.env.shared` + `.env.dev|test|prod`(见 `docs/env_loading_priority.md`)。
## 5. 🗄️ 核心数据模型 (Database Models)
@@ -128,12 +119,12 @@ npm run dev
### 服务器运维
```bash
# 一键部署
./scripts/deploy.sh
# 与 Jenkins 相同的 Compose 部署(示例:生产)
./scripts/deploy_compose.sh prod true true true
# 查看容器状态
docker compose ps
# 查看后端日志
tail -f /opt/hxops/backend/logs/app.log
# 重启服务
sudo supervisorctl restart hxops-backend
docker compose logs -f hxops-backend
```
+19 -4
View File
@@ -5,7 +5,12 @@ import { watch, onMounted, onBeforeUnmount } from 'vue';
import { useTheme } from './composables/useTheme';
import LevelMessageDialog from './components/LevelMessageDialog.vue';
import { useGlobalMessageDialog } from './composables/useGlobalMessageDialog';
import { getAuthHeaders, clearAuthUser } from './utils/auth';
import { useRouter } from 'vue-router';
import { getAuthHeaders, logoutAuth } from './utils/auth';
const router = useRouter();
const PUBLIC_PATHS = ['/', '/workspace', '/casdoor-callback', '/reset-password'];
const { locale } = useI18n();
const { themePreference, initTheme, setThemePreference } = useTheme();
@@ -58,14 +63,23 @@ watch(themePreference, (newTheme) => {
const onUnauthorized = () => {
showMessageDialog('error', '认证已过期或无效,请重新登录');
clearAuthUser();
if (window.location.pathname !== '/') {
window.location.href = '/';
logoutAuth();
};
const onLogout = (event: Event) => {
const detail = (event as CustomEvent<{ remote?: boolean }>).detail;
if (detail?.remote) {
showMessageDialog('info', '您已在其他标签页退出登录');
}
const path = router.currentRoute.value.path;
if (!PUBLIC_PATHS.includes(path)) {
router.push('/workspace');
}
};
onMounted(async () => {
window.addEventListener('hxops:unauthorized', onUnauthorized as EventListener);
window.addEventListener('hxops:logout', onLogout as EventListener);
initTheme();
@@ -90,6 +104,7 @@ onMounted(async () => {
onBeforeUnmount(() => {
window.removeEventListener('hxops:unauthorized', onUnauthorized as EventListener);
window.removeEventListener('hxops:logout', onLogout as EventListener);
});
</script>
@@ -3,9 +3,7 @@ import { computed, onBeforeUnmount, watch } from 'vue';
import { useI18n } from 'vue-i18n';
interface Props {
// 由父组件控制显隐,使用 v-model 统一管理弹框状态。
modelValue: boolean;
// title/message 支持外部按场景透传,不传时走 i18n 默认值。
title?: string;
message?: string;
confirmText?: string;
@@ -39,7 +37,6 @@ const closeDialog = () => {
};
const handleCancel = () => {
// 先抛出 cancel 事件,方便父组件做状态回滚,再关闭弹框。
emit('cancel');
closeDialog();
};
@@ -57,7 +54,6 @@ const handleEscKey = (event: KeyboardEvent) => {
watch(
() => props.modelValue,
(visible) => {
// 关键点:弹框打开时监听 ESC,关闭后及时解绑,避免全局事件泄漏。
if (visible) {
document.addEventListener('keydown', handleEscKey);
return;
@@ -77,29 +73,29 @@ onBeforeUnmount(() => {
<Transition name="delete-dialog-fade">
<div
v-if="modelValue"
class="fixed inset-0 z-[100] bg-black/45 flex items-center justify-center p-4"
class="dialog-overlay items-center"
@click.self="handleCancel"
>
<div class="delete-dialog-container w-full max-w-[416px] rounded-lg bg-white shadow-[0_6px_16px_0_rgba(0,0,0,0.08),0_3px_6px_-4px_rgba(0,0,0,0.12),0_9px_28px_8px_rgba(0,0,0,0.05)] px-6 pt-7 pb-5">
<div class="dialog-panel max-w-[416px] rounded-lg px-6 pt-7 pb-5">
<div class="flex items-start gap-3">
<span class="delete-dialog-icon" aria-hidden="true">!</span>
<span class="dialog-icon-warning" aria-hidden="true">!</span>
<div class="min-w-0">
<h3 class="text-[16px] leading-6 font-semibold text-[rgba(0,0,0,0.88)]">
<h3 class="text-base font-semibold leading-6 text-primary">
{{ resolvedTitle }}
</h3>
<p class="mt-3 text-[14px] leading-[22px] text-[rgba(0,0,0,0.65)] whitespace-pre-line">
<p class="section-desc mt-3 whitespace-pre-line">
{{ resolvedMessage }}
</p>
</div>
</div>
<div class="mt-6 flex justify-end gap-2">
<button type="button" class="delete-dialog-btn cancel" @click="handleCancel">
<button type="button" class="btn-secondary btn-sm" @click="handleCancel">
{{ resolvedCancelText }}
</button>
<button
type="button"
class="delete-dialog-btn confirm"
class="btn-danger btn-sm"
:disabled="confirmLoading"
@click="handleConfirm"
>
@@ -113,60 +109,6 @@ onBeforeUnmount(() => {
</template>
<style scoped>
.delete-dialog-icon {
width: 22px;
height: 22px;
border-radius: 9999px;
background: #faad14;
color: #fff;
font-size: 14px;
line-height: 1;
font-weight: 600;
display: inline-flex;
align-items: center;
justify-content: center;
flex-shrink: 0;
margin-top: 2px;
}
.delete-dialog-btn {
min-width: 66px;
height: 32px;
border-radius: 6px;
font-size: 14px;
line-height: 1;
font-weight: 400;
padding: 4px 15px;
transition: all 0.2s ease;
}
.delete-dialog-btn.cancel {
color: rgba(0, 0, 0, 0.88);
background: #fff;
border: 1px solid #d9d9d9;
}
.delete-dialog-btn.cancel:hover {
border-color: #4096ff;
color: #4096ff;
}
.delete-dialog-btn.confirm {
color: #fff;
background: #1677ff;
border: 1px solid #1677ff;
}
.delete-dialog-btn.confirm:hover {
background: #4096ff;
border-color: #4096ff;
}
.delete-dialog-btn:disabled {
opacity: 0.6;
cursor: not-allowed;
}
.delete-dialog-fade-enter-active,
.delete-dialog-fade-leave-active {
transition: opacity 0.18s ease;
@@ -178,17 +120,9 @@ onBeforeUnmount(() => {
}
@media (max-width: 768px) {
.delete-dialog-container {
.dialog-panel {
max-width: 94vw;
padding: 20px 16px 16px;
}
.delete-dialog-icon {
margin-top: 1px;
}
.delete-dialog-btn {
min-width: 62px;
}
}
</style>
+24 -24
View File
@@ -417,29 +417,29 @@ watch(
</script>
<template>
<div v-if="modelValue && file" class="fixed inset-0 z-[80] flex items-center justify-center bg-black/50 dark:bg-slate-950/70 backdrop-blur-sm p-4">
<div class="bg-white dark:bg-slate-900 rounded-2xl shadow-xl w-full max-w-5xl h-[85vh] flex flex-col overflow-hidden border border-slate-200 dark:border-slate-700">
<div class="px-6 py-4 border-b border-slate-200 dark:border-slate-700 flex items-start justify-between gap-4">
<div v-if="modelValue && file" class="dialog-overlay dialog-overlay--z80 items-center">
<div class="dialog-panel max-w-5xl h-[85vh] overflow-hidden">
<div class="dialog-header dialog-header--compact items-start">
<div class="min-w-0">
<div class="text-sm font-medium text-slate-500 dark:text-slate-400 tracking-wide">{{ t('filePreview.title') }}</div>
<div class="mt-1 font-semibold text-slate-900 dark:text-slate-100 break-words">{{ file.name }}</div>
<button type="button" @click="downloadFile" :disabled="isDownloading" class="mt-2 inline-flex items-center justify-center px-3 py-1.5 text-xs font-medium rounded-lg bg-brand-50 text-brand-700 hover:bg-brand-100 border border-brand-200 dark:bg-brand-900/30 dark:text-brand-300 dark:border-brand-800 transition-colors disabled:opacity-50 disabled:cursor-not-allowed">
<div class="label-field tracking-wide">{{ t('filePreview.title') }}</div>
<div class="mt-1 font-semibold text-primary break-words">{{ file.name }}</div>
<button type="button" @click="downloadFile" :disabled="isDownloading" class="btn-secondary btn-sm mt-2 inline-flex border-brand-200 text-brand-700 hover:bg-brand-50 disabled:opacity-50 disabled:cursor-not-allowed">
<svg v-if="!isDownloading" xmlns="http://www.w3.org/2000/svg" class="h-4 w-4 mr-1.5" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2">
<path stroke-linecap="round" stroke-linejoin="round" d="M4 16v1a3 3 0 003 3h10a3 3 0 003-3v-1m-4-4l-4 4m0 0l-4-4m4 4V4" />
</svg>
<svg v-else class="animate-spin -ml-1 mr-2 h-4 w-4 text-brand-700 dark:text-brand-300" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24">
<svg v-else class="animate-spin -ml-1 mr-2 h-4 w-4 text-brand-700" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24">
<circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4"></circle>
<path class="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"></path>
</svg>
{{ isDownloading ? t('filePreview.downloading') : t('filePreview.download') }}
</button>
</div>
<button type="button" @click="close" class="shrink-0 whitespace-nowrap inline-flex items-center justify-center px-4 py-2 rounded-xl border border-slate-200 dark:border-slate-700 text-slate-600 dark:text-slate-300 bg-white/80 dark:bg-slate-900/80 hover:bg-slate-100 dark:hover:bg-slate-800">{{ t('common.close') }}</button>
<button type="button" class="btn-secondary shrink-0" @click="close">{{ t('common.close') }}</button>
</div>
<div class="flex-1 overflow-auto p-4 bg-slate-50 dark:bg-slate-950">
<div v-if="isLoading" class="text-sm text-slate-500 dark:text-slate-400">{{ t('common.loading') }}</div>
<div v-else-if="error" class="text-sm text-red-600 bg-red-50 border border-red-200 rounded-lg p-3">
<div class="dialog-preview-body">
<div v-if="isLoading" class="text-sm text-muted">{{ t('common.loading') }}</div>
<div v-else-if="error" class="alert-ds alert-error text-sm">
<template v-if="previewTooLarge">
{{ t('filePreview.tooLarge') }}
</template>
@@ -449,14 +449,14 @@ watch(
</div>
<div
v-else-if="resolvedMode === 'markdown'"
class="prose prose-sm max-w-none bg-white dark:bg-slate-900 border border-slate-200 dark:border-slate-700 rounded-lg p-5"
class="prose prose-sm max-w-none dialog-preview-frame p-5"
v-html="markdownHtml"
></div>
<div
v-else-if="resolvedMode === 'sheet' && excelPreview"
class="h-full rounded-lg border border-slate-200 dark:border-slate-700 bg-white dark:bg-slate-900 p-4 overflow-auto"
class="dialog-preview-frame h-full p-4 overflow-auto"
>
<div class="mb-3 text-xs text-slate-500 dark:text-slate-400">
<div class="mb-3 text-xs text-muted">
Sheet: {{ excelPreview.sheet_name }} | Rows: {{ excelPreview.rows.length }}
<span v-if="excelPreview.truncated"> (truncated)</span>
</div>
@@ -466,7 +466,7 @@ watch(
<th
v-for="(col, i) in excelPreview.columns"
:key="`h-${i}`"
class="sticky top-0 bg-slate-100 dark:bg-slate-800 border border-slate-200 dark:border-slate-700 px-2 py-1 text-left font-semibold"
class="sticky top-0 bg-surface-soft border border-default px-2 py-1 text-left font-semibold text-secondary"
>
{{ col }}
</th>
@@ -477,7 +477,7 @@ watch(
<td
v-for="(cell, ci) in row"
:key="`c-${ri}-${ci}`"
class="border border-slate-200 dark:border-slate-700 px-2 py-1 align-top whitespace-pre-wrap break-words"
class="border border-default px-2 py-1 align-top whitespace-pre-wrap break-words text-secondary"
>
{{ cell }}
</td>
@@ -487,7 +487,7 @@ watch(
</div>
<div
v-else-if="resolvedMode === 'office' && officeKind"
class="h-full rounded-lg border border-slate-200 dark:border-slate-700 bg-white dark:bg-slate-900 p-2 overflow-auto"
class="dialog-preview-frame h-full p-2 overflow-auto"
>
<VueOfficeDocx
v-if="officeKind === 'docx'"
@@ -500,12 +500,12 @@ watch(
style="height: 100%; width: 100%;"
/>
</div>
<div v-else-if="resolvedMode === 'image'" class="h-full flex items-center justify-center bg-white dark:bg-slate-900 border border-slate-200 dark:border-slate-700 rounded-lg p-2">
<div v-else-if="resolvedMode === 'image'" class="dialog-preview-frame h-full flex items-center justify-center p-2">
<img :src="imageSrc" :alt="file.name" class="max-w-full max-h-full object-contain" />
</div>
<div
v-else-if="['pdf', 'doc', 'ppt', 'pptx'].includes(ext) && officeObjectUrl"
class="h-full rounded-lg border border-slate-200 dark:border-slate-700 bg-white dark:bg-slate-900 overflow-hidden"
class="dialog-preview-frame h-full overflow-hidden"
>
<iframe
:src="officeObjectUrl"
@@ -515,12 +515,12 @@ watch(
</div>
<div
v-else-if="needsOfficeFallback"
class="h-full rounded-lg border border-slate-200 dark:border-slate-700 bg-white dark:bg-slate-900 p-6"
class="dialog-preview-frame h-full p-6"
>
<!-- Graceful fallback for private/non-HTTPS Office links:
show actions instead of an empty iframe. -->
<div class="text-sm text-slate-700 dark:text-slate-200 font-semibold">Preview not available for this file URL</div>
<div class="mt-2 text-sm text-slate-500 dark:text-slate-400">
<div class="text-sm font-semibold text-secondary">Preview not available for this file URL</div>
<div class="mt-2 text-sm text-muted">
This Office file uses a private or non-HTTPS link, so online preview cannot render it.
</div>
<div class="mt-4 flex gap-3">
@@ -528,7 +528,7 @@ watch(
type="button"
@click="downloadFile"
:disabled="isDownloading"
class="px-4 py-2 rounded-lg bg-brand-600 text-white text-sm hover:bg-brand-700 disabled:opacity-50 disabled:cursor-not-allowed inline-flex items-center"
class="btn-primary btn-sm inline-flex"
>
<svg v-if="isDownloading" class="animate-spin -ml-1 mr-2 h-4 w-4 text-white" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24">
<circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4"></circle>
@@ -541,7 +541,7 @@ watch(
<iframe
v-else
:src="iframeSrc"
class="w-full h-full min-h-[480px] bg-white dark:bg-slate-900 rounded-lg border border-slate-200 dark:border-slate-700"
class="dialog-preview-frame w-full h-full min-h-[480px]"
allow="clipboard-read; clipboard-write"
></iframe>
</div>
@@ -118,34 +118,34 @@ const submitFeedback = async () => {
<template>
<div
v-if="modelValue"
class="fixed inset-0 z-[80] flex items-start justify-center overflow-y-auto bg-black/40 p-3 backdrop-blur-sm sm:items-center sm:p-4"
class="dialog-overlay dialog-overlay--z80"
>
<div class="flex max-h-[92vh] w-full max-w-2xl flex-col rounded-2xl border border-transparent bg-white shadow-2xl dark:border-slate-700 dark:bg-slate-900">
<div class="flex items-center justify-between border-b border-gray-100 px-5 pb-4 pt-5 dark:border-slate-800 sm:px-8 sm:pb-4 sm:pt-7">
<h3 class="text-2xl font-bold text-gray-900 dark:text-slate-100">{{ t('feedback.title') }}</h3>
<div class="dialog-panel max-w-2xl max-h-[92vh]">
<div class="dialog-header">
<h3 class="section-title text-2xl">{{ t('feedback.title') }}</h3>
<button
@click="closeDialog"
class="rounded-lg p-1.5 text-gray-400 transition-colors hover:bg-gray-100 hover:text-gray-600 dark:text-slate-500 dark:hover:bg-slate-800 dark:hover:text-slate-300"
type="button"
class="btn-icon-ds"
aria-label="Close"
@click="closeDialog"
>
<X class="h-5 w-5" />
</button>
</div>
<div class="space-y-5 overflow-y-auto px-5 py-5 sm:px-8">
<div class="dialog-body space-y-5">
<div class="space-y-1.5">
<label class="block text-sm font-semibold text-gray-600 dark:text-slate-400">{{ t('feedback.labels.type') }}</label>
<div class="flex flex-wrap gap-3">
<label class="label-field block">{{ t('feedback.labels.type') }}</label>
<div class="segment-control segment-control--chips segment-control--md" role="radiogroup" :aria-label="t('feedback.labels.type')">
<button
v-for="item in typeOptions"
:key="item"
type="button"
role="radio"
:aria-checked="selectedType === item"
class="segment-item"
:class="selectedType === item ? 'segment-item--active' : ''"
@click="selectedType = item"
class="rounded-xl border px-4 py-2.5 text-base font-medium transition-colors"
:class="
selectedType === item
? 'border-blue-500 bg-blue-50 text-blue-700 dark:border-brand-500 dark:bg-brand-500/15 dark:text-brand-300'
: 'border-gray-200 bg-gray-50 text-gray-700 hover:bg-gray-100 dark:border-slate-600 dark:bg-slate-800/80 dark:text-slate-300 dark:hover:border-slate-500 dark:hover:bg-slate-700/80'
"
>
{{ item }}
</button>
@@ -153,44 +153,45 @@ const submitFeedback = async () => {
</div>
<div class="space-y-1.5">
<label class="block text-sm font-semibold text-gray-600 dark:text-slate-400">{{ t('feedback.labels.module') }}</label>
<select
v-model="selectedModule"
class="w-full rounded-xl border border-gray-200 bg-gray-50 px-4 py-3 text-base text-gray-900 shadow-sm outline-none transition-all focus:border-blue-500 focus:bg-white focus:ring-2 focus:ring-blue-500/20 dark:border-slate-600 dark:bg-slate-800 dark:text-slate-200 dark:focus:border-brand-500 dark:focus:bg-slate-800 dark:focus:ring-brand-500/20"
>
<label class="label-field block">{{ t('feedback.labels.module') }}</label>
<select v-model="selectedModule" class="input-field text-base">
<option v-for="item in moduleOptions" :key="item" :value="item">{{ item }}</option>
</select>
</div>
<div class="space-y-1.5">
<label class="block text-sm font-semibold text-gray-600 dark:text-slate-400">{{ t('feedback.labels.content') }}<span class="ml-0.5 text-red-500 dark:text-red-400">*</span></label>
<label class="label-field block">
{{ t('feedback.labels.content') }}<span class="ml-0.5 text-red-500">*</span>
</label>
<textarea
v-model="content"
rows="5"
maxlength="2000"
class="w-full resize-none rounded-xl border border-gray-200 bg-gray-50 px-4 py-3 text-base text-gray-900 shadow-sm outline-none transition-all placeholder:text-gray-400 focus:border-blue-500 focus:bg-white focus:ring-2 focus:ring-blue-500/20 dark:border-slate-600 dark:bg-slate-800 dark:text-slate-200 dark:placeholder:text-slate-500 dark:focus:border-brand-500 dark:focus:bg-slate-800 dark:focus:ring-brand-500/20"
class="input-field resize-none text-base"
:placeholder="t('feedback.placeholder.content')"
/>
<div class="mt-2 flex items-center justify-between">
<div v-if="error" class="text-base text-red-600 dark:text-red-400">{{ error }}</div>
<div v-else class="text-base text-gray-400"> </div>
<div class="text-base text-gray-400 dark:text-slate-500">{{ content.length }}/2000</div>
<div v-if="error" class="text-base text-red-600">{{ error }}</div>
<div v-else class="text-base text-muted"> </div>
<div class="text-base text-muted">{{ content.length }}/2000</div>
</div>
</div>
</div>
<div class="flex justify-end gap-3 rounded-b-2xl border-t border-gray-100 bg-white px-5 py-4 dark:border-slate-800 dark:bg-slate-900 sm:px-8">
<div class="dialog-footer">
<button
@click="closeDialog"
class="rounded-xl px-5 py-2.5 text-base font-medium text-gray-600 transition-colors hover:bg-gray-100 dark:text-slate-400 dark:hover:bg-slate-800 dark:hover:text-slate-200"
type="button"
class="btn-ghost"
:disabled="submitting"
@click="closeDialog"
>
{{ t('feedback.cancel') }}
</button>
<button
@click="submitFeedback"
class="inline-flex items-center justify-center gap-2 rounded-xl bg-blue-600 px-5 py-2.5 text-base font-medium text-white shadow-md shadow-blue-200 transition-all hover:bg-blue-700 active:scale-95 disabled:cursor-not-allowed disabled:opacity-70 dark:bg-brand-600 dark:shadow-none dark:hover:bg-brand-500"
type="button"
class="btn-primary"
:disabled="!canSubmit"
@click="submitFeedback"
>
<MessageSquareText class="h-5 w-5" />
{{ submitting ? t('feedback.submitting') : t('feedback.submit') }}
+15 -42
View File
@@ -5,15 +5,12 @@ import { Check, Info, AlertTriangle, XCircle, X } from 'lucide-vue-next';
type MessageLevel = 'success' | 'info' | 'warning' | 'error';
interface Props {
// 父组件通过 v-model 控制弹框显隐。
modelValue: boolean;
// 消息级别决定配色和图标。
level?: MessageLevel;
title?: string;
message?: string;
closeOnMask?: boolean;
closeOnEsc?: boolean;
// 自动关闭时长(毫秒):<= 0 表示不自动关闭。
autoCloseMs?: number;
}
@@ -31,30 +28,14 @@ const emit = defineEmits<{
(e: 'close'): void;
}>();
const STYLE_MAP: Record<MessageLevel, { panel: string; iconWrap: string; icon: string }> = {
success: {
panel: 'bg-[#eef8e8] border-[#b7e2a7]',
iconWrap: 'border-[#52c41a]',
icon: 'text-[#52c41a]',
},
info: {
panel: 'bg-[#eaf4ff] border-[#9fcbff]',
iconWrap: 'border-[#1677ff]',
icon: 'text-[#1677ff]',
},
warning: {
panel: 'bg-[#fff8e8] border-[#ffd88a]',
iconWrap: 'border-[#faad14]',
icon: 'text-[#faad14]',
},
error: {
panel: 'bg-[#fff1f0] border-[#ffb3b0]',
iconWrap: 'border-[#ff4d4f]',
icon: 'text-[#ff4d4f]',
},
const ALERT_CLASS: Record<MessageLevel, string> = {
success: 'alert-ds alert-success',
info: 'alert-ds alert-info',
warning: 'alert-ds alert-warning',
error: 'alert-ds alert-error',
};
const ICON_MAP: Record<MessageLevel, any> = {
const ICON_MAP: Record<MessageLevel, typeof Check> = {
success: Check,
info: Info,
warning: AlertTriangle,
@@ -68,7 +49,7 @@ const DEFAULT_TITLE_MAP: Record<MessageLevel, string> = {
error: 'Error',
};
const resolvedStyle = computed(() => STYLE_MAP[props.level]);
const panelClass = computed(() => ALERT_CLASS[props.level]);
const resolvedIcon = computed(() => ICON_MAP[props.level]);
const resolvedTitle = computed(() => props.title || DEFAULT_TITLE_MAP[props.level]);
const resolvedMessage = computed(() => props.message || '');
@@ -109,7 +90,6 @@ watch(
}
document.addEventListener('keydown', handleEscKey);
// 关键点:弹框可见时只要内容变化,也会重新计时自动关闭。
if (props.autoCloseMs > 0) {
autoCloseTimer = setTimeout(() => {
closeDialog();
@@ -129,16 +109,16 @@ onBeforeUnmount(() => {
<Transition name="level-dialog-fade">
<div
v-if="modelValue"
class="fixed inset-0 z-[110] bg-black/40 flex items-center justify-center p-4"
class="dialog-overlay dialog-overlay--z110 items-center"
@click.self="handleMaskClose"
>
<div
class="level-dialog-panel w-full max-w-[430px] rounded-2xl border shadow-[0_14px_28px_rgba(0,0,0,0.14)] px-9 py-8 relative"
:class="resolvedStyle.panel"
class="level-dialog-panel w-full max-w-[430px] rounded-2xl border shadow-elevated px-9 py-8 relative"
:class="panelClass"
>
<button
type="button"
class="absolute top-4 right-4 w-8 h-8 inline-flex items-center justify-center rounded-full text-slate-500 hover:text-slate-700 hover:bg-black/5 transition-colors"
class="btn-icon-ds absolute top-4 right-4"
@click="closeDialog"
aria-label="close dialog"
>
@@ -146,18 +126,15 @@ onBeforeUnmount(() => {
</button>
<div class="flex items-start gap-4 pr-8 min-h-0">
<span
class="w-8 h-8 rounded-full border-2 inline-flex items-center justify-center shrink-0 mt-0.5"
:class="resolvedStyle.iconWrap"
>
<component :is="resolvedIcon" class="w-4 h-4" :class="resolvedStyle.icon" />
<span class="inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-full border-2 border-current mt-0.5">
<component :is="resolvedIcon" class="h-4 w-4" />
</span>
<div class="min-w-0 w-full">
<h3 class="text-[16px] leading-6 font-semibold text-slate-800">
<h3 class="text-base font-semibold leading-6">
{{ resolvedTitle }}
</h3>
<p class="level-dialog-message mt-3 text-[14px] leading-8 text-slate-700 whitespace-pre-line break-words">
<p class="level-dialog-message mt-3 text-sm leading-7 whitespace-pre-line break-words opacity-90">
{{ resolvedMessage }}
</p>
</div>
@@ -197,10 +174,6 @@ onBeforeUnmount(() => {
padding: 20px 18px;
}
.level-dialog-panel p {
line-height: 1.75;
}
.level-dialog-message {
max-height: 52vh;
}
+20 -20
View File
@@ -26,21 +26,21 @@ onMounted(() => {
</script>
<template>
<div class="mt-6 rounded-2xl border border-slate-200 bg-white p-5 dark:border-slate-700 dark:bg-slate-800">
<div class="admin-table-section mt-6 p-5">
<div class="mb-4 flex items-center justify-between">
<h3 class="text-lg font-semibold text-slate-900 dark:text-slate-100">{{ t('scheduleRuns.title') }}</h3>
<button class="rounded-lg border border-slate-300 px-3 py-1.5 text-sm text-slate-700 transition-colors hover:bg-slate-50 dark:border-slate-600 dark:text-slate-300 dark:hover:bg-slate-700" @click="loadRuns">
<h3 class="section-title">{{ t('scheduleRuns.title') }}</h3>
<button type="button" class="btn-secondary btn-sm" @click="loadRuns">
{{ t('scheduleRuns.refresh') }}
</button>
</div>
<p class="mb-3 text-xs text-slate-500 dark:text-slate-400">{{ t('scheduleRuns.tip') }}</p>
<div v-if="isLoading" class="py-6 text-sm text-slate-500 dark:text-slate-400">{{ t('scheduleRuns.loading') }}</div>
<div v-else-if="error" class="py-6 text-sm text-rose-500 dark:text-rose-400">{{ error }}</div>
<div v-else-if="runs.length === 0" class="py-6 text-sm text-slate-400 dark:text-slate-500">{{ t('scheduleRuns.empty') }}</div>
<div v-else class="overflow-x-auto">
<table class="w-full min-w-[920px] text-sm">
<p class="section-desc mb-3">{{ t('scheduleRuns.tip') }}</p>
<div v-if="isLoading" class="py-6 text-sm text-muted">{{ t('scheduleRuns.loading') }}</div>
<div v-else-if="error" class="py-6 text-sm text-rose-500">{{ error }}</div>
<div v-else-if="runs.length === 0" class="py-6 text-sm text-muted">{{ t('scheduleRuns.empty') }}</div>
<div v-else class="admin-table-wrap">
<table class="admin-table min-w-[920px] text-sm">
<thead>
<tr class="border-b border-slate-200 text-left text-slate-500 dark:border-slate-700 dark:text-slate-400">
<tr>
<th class="px-2 py-2">{{ t('scheduleRuns.columns.runNo') }}</th>
<th class="px-2 py-2">{{ t('scheduleRuns.columns.schedule') }}</th>
<th class="px-2 py-2">{{ t('scheduleRuns.columns.start') }}</th>
@@ -53,17 +53,17 @@ onMounted(() => {
</tr>
</thead>
<tbody>
<tr v-for="run in runs" :key="run.id" class="border-b border-slate-100 text-slate-700 dark:border-slate-700 dark:text-slate-300">
<td class="px-2 py-2">{{ run.run_no }}</td>
<td class="px-2 py-2">{{ run.schedule_name || '-' }}</td>
<td class="px-2 py-2">{{ run.started_at || '-' }}</td>
<td class="px-2 py-2">{{ run.finished_at || '-' }}</td>
<td class="px-2 py-2">{{ run.status }}</td>
<td class="px-2 py-2">{{ run.total_count }}</td>
<td class="px-2 py-2">{{ run.success_count }}</td>
<td class="px-2 py-2">{{ run.failed_count }}</td>
<tr v-for="run in runs" :key="run.id">
<td class="px-2 py-2 text-secondary">{{ run.run_no }}</td>
<td class="px-2 py-2 text-secondary">{{ run.schedule_name || '-' }}</td>
<td class="px-2 py-2 text-secondary">{{ run.started_at || '-' }}</td>
<td class="px-2 py-2 text-secondary">{{ run.finished_at || '-' }}</td>
<td class="px-2 py-2 text-secondary">{{ run.status }}</td>
<td class="px-2 py-2 text-secondary">{{ run.total_count }}</td>
<td class="px-2 py-2 text-secondary">{{ run.success_count }}</td>
<td class="px-2 py-2 text-secondary">{{ run.failed_count }}</td>
<td class="px-2 py-2">
<a class="text-brand-600 hover:underline dark:text-brand-400" :href="workspaceRunExcelUrl(run.id)" target="_blank">{{ t('scheduleRuns.viewExcel') }}</a>
<a class="text-brand-600 hover:underline" :href="workspaceRunExcelUrl(run.id)" target="_blank">{{ t('scheduleRuns.viewExcel') }}</a>
</td>
</tr>
</tbody>
@@ -14,17 +14,18 @@ const { appliedTheme, toggleLightDark } = useTheme();
const isDarkTheme = computed(() => appliedTheme.value === 'dark');
const buttonClass = computed(() =>
props.floating
? 'fixed bottom-5 right-5 z-[70] h-11 w-11 rounded-full bg-white/90 dark:bg-slate-900/90 backdrop-blur-md shadow-lg border border-slate-200 dark:border-slate-700 text-slate-600 dark:text-slate-300 hover:text-slate-900 dark:hover:text-slate-100 hover:shadow-xl flex items-center justify-center transition-all'
: 'h-8 w-8 md:h-9 md:w-9 rounded-full bg-white/80 dark:bg-slate-900/80 backdrop-blur-md shadow-sm border border-slate-200 dark:border-slate-700 text-slate-600 dark:text-slate-300 hover:text-slate-900 dark:hover:text-slate-100 hover:shadow-md flex items-center justify-center transition-all'
? 'theme-toggle-btn theme-toggle-btn--floating'
: 'theme-toggle-btn theme-toggle-btn--inline'
);
</script>
<template>
<button
@click="toggleLightDark"
type="button"
:class="buttonClass"
:title="isDarkTheme ? (t('theme.switchToLight') || 'Switch to light mode') : (t('theme.switchToDark') || 'Switch to dark mode')"
:aria-label="isDarkTheme ? (t('theme.switchToLight') || 'Switch to light mode') : (t('theme.switchToDark') || 'Switch to dark mode')"
@click="toggleLightDark"
>
<Sun v-if="isDarkTheme" class="w-4 h-4 md:w-5 md:h-5" />
<Moon v-else class="w-4 h-4 md:w-5 md:h-5" />
+29 -29
View File
@@ -25,52 +25,52 @@ watch(() => props.open, (open) => {
</script>
<template>
<div v-if="open" class="fixed inset-0 z-50 flex items-center justify-center bg-slate-950/35 px-4 py-8 backdrop-blur-sm" @click="close">
<div class="w-full max-w-4xl rounded-3xl border border-slate-200 bg-white p-6 shadow-xl dark:border-slate-700 dark:bg-slate-900" @click.stop>
<div v-if="open" class="dialog-overlay" @click="close">
<div class="dialog-panel max-w-4xl p-6" @click.stop>
<div class="flex items-center justify-between gap-4">
<div>
<h3 class="text-xl font-bold text-slate-900 dark:text-slate-100">{{ t('kbDifyHealth.title') }}</h3>
<p class="mt-1 text-sm text-slate-500 dark:text-slate-400">{{ t('kbDifyHealth.subtitle') }}</p>
<h3 class="section-title text-xl">{{ t('kbDifyHealth.title') }}</h3>
<p class="section-desc mt-1">{{ t('kbDifyHealth.subtitle') }}</p>
</div>
<div class="flex items-center gap-3">
<button class="rounded-2xl border border-slate-200 px-3 py-2 text-sm text-slate-600 hover:bg-slate-50 dark:border-slate-700 dark:text-slate-300 dark:hover:bg-slate-800" @click="loadHealth">
<button type="button" class="btn-secondary btn-sm" @click="loadHealth">
{{ t('common.refresh') }}
</button>
<button class="rounded-2xl border border-slate-200 px-3 py-2 text-sm text-slate-600 hover:bg-slate-50 dark:border-slate-700 dark:text-slate-300 dark:hover:bg-slate-800" @click="close">
<button type="button" class="btn-secondary btn-sm" @click="close">
{{ t('common.close') }}
</button>
</div>
</div>
<div v-if="loading" class="py-16 text-center text-sm text-slate-400">{{ t('kbDifyHealth.loading') }}</div>
<div v-if="loading" class="py-16 text-center text-sm text-muted">{{ t('kbDifyHealth.loading') }}</div>
<div v-else-if="payload" class="mt-6 grid gap-4 md:grid-cols-2 xl:grid-cols-3">
<div class="rounded-2xl border border-slate-200 px-4 py-4 dark:border-slate-700">
<div class="text-xs font-semibold uppercase tracking-[0.18em] text-slate-400">Dify API</div>
<div class="mt-3 text-2xl font-semibold text-slate-900 dark:text-slate-100">{{ payload.api.reachable ? t('kbDifyHealth.reachable') : t('kbDifyHealth.unreachable') }}</div>
<div class="mt-2 break-all text-xs text-slate-500 dark:text-slate-400">{{ payload.dify_base_url || t('kbDifyHealth.notConfigured') }}</div>
<div class="dialog-stat-card">
<div class="label-field">Dify API</div>
<div class="mt-3 text-2xl font-semibold text-primary">{{ payload.api.reachable ? t('kbDifyHealth.reachable') : t('kbDifyHealth.unreachable') }}</div>
<div class="mt-2 break-all text-xs text-muted">{{ payload.dify_base_url || t('kbDifyHealth.notConfigured') }}</div>
</div>
<div class="rounded-2xl border border-slate-200 px-4 py-4 dark:border-slate-700">
<div class="text-xs font-semibold uppercase tracking-[0.18em] text-slate-400">{{ t('kbDifyHealth.datasetCount') }}</div>
<div class="mt-3 text-2xl font-semibold text-slate-900 dark:text-slate-100">{{ payload.api.dataset_count ?? '--' }}</div>
<div class="mt-2 text-xs text-slate-500 dark:text-slate-400">{{ t('kbDifyHealth.configured') }}{{ payload.dify_api_configured ? t('common.yes') : t('common.no') }}</div>
<div class="dialog-stat-card">
<div class="label-field">{{ t('kbDifyHealth.datasetCount') }}</div>
<div class="mt-3 text-2xl font-semibold text-primary">{{ payload.api.dataset_count ?? '--' }}</div>
<div class="mt-2 text-xs text-muted">{{ t('kbDifyHealth.configured') }}{{ payload.dify_api_configured ? t('common.yes') : t('common.no') }}</div>
</div>
<div class="rounded-2xl border border-slate-200 px-4 py-4 dark:border-slate-700">
<div class="text-xs font-semibold uppercase tracking-[0.18em] text-slate-400">{{ t('kbDifyHealth.boundGroups') }}</div>
<div class="mt-3 text-2xl font-semibold text-slate-900 dark:text-slate-100">{{ payload.local_sync_health.dataset_bound_groups }}</div>
<div class="mt-2 text-xs text-slate-500 dark:text-slate-400">{{ t('kbDifyHealth.localSyncRecords') }}{{ payload.local_sync_health.sync_records }}</div>
<div class="dialog-stat-card">
<div class="label-field">{{ t('kbDifyHealth.boundGroups') }}</div>
<div class="mt-3 text-2xl font-semibold text-primary">{{ payload.local_sync_health.dataset_bound_groups }}</div>
<div class="mt-2 text-xs text-muted">{{ t('kbDifyHealth.localSyncRecords') }}{{ payload.local_sync_health.sync_records }}</div>
</div>
<div class="rounded-2xl border border-slate-200 px-4 py-4 dark:border-slate-700">
<div class="text-xs font-semibold uppercase tracking-[0.18em] text-slate-400">{{ t('kbDifyHealth.syncingVersions') }}</div>
<div class="mt-3 text-2xl font-semibold text-slate-900 dark:text-slate-100">{{ payload.local_sync_health.syncing_versions }}</div>
<div class="dialog-stat-card">
<div class="label-field">{{ t('kbDifyHealth.syncingVersions') }}</div>
<div class="mt-3 text-2xl font-semibold text-primary">{{ payload.local_sync_health.syncing_versions }}</div>
</div>
<div class="rounded-2xl border border-slate-200 px-4 py-4 dark:border-slate-700">
<div class="text-xs font-semibold uppercase tracking-[0.18em] text-slate-400">{{ t('kbDifyHealth.syncedVersions') }}</div>
<div class="mt-3 text-2xl font-semibold text-slate-900 dark:text-slate-100">{{ payload.local_sync_health.synced_versions }}</div>
<div class="dialog-stat-card">
<div class="label-field">{{ t('kbDifyHealth.syncedVersions') }}</div>
<div class="mt-3 text-2xl font-semibold text-primary">{{ payload.local_sync_health.synced_versions }}</div>
</div>
<div class="rounded-2xl border border-slate-200 px-4 py-4 dark:border-slate-700">
<div class="text-xs font-semibold uppercase tracking-[0.18em] text-slate-400">{{ t('kbDifyHealth.pendingSyncJobs') }}</div>
<div class="mt-3 text-2xl font-semibold text-slate-900 dark:text-slate-100">{{ payload.local_sync_health.pending_sync_jobs }}</div>
<div class="mt-2 text-xs text-rose-500" v-if="payload.api.error">{{ payload.api.error }}</div>
<div class="dialog-stat-card">
<div class="label-field">{{ t('kbDifyHealth.pendingSyncJobs') }}</div>
<div class="mt-3 text-2xl font-semibold text-primary">{{ payload.local_sync_health.pending_sync_jobs }}</div>
<div v-if="payload.api.error" class="mt-2 text-xs text-rose-500">{{ payload.api.error }}</div>
</div>
</div>
</div>
@@ -49,44 +49,44 @@ watch(() => props.open, (open) => {
</script>
<template>
<div v-if="open" class="fixed inset-0 z-50 flex items-center justify-center bg-slate-950/35 px-4 py-8 backdrop-blur-sm" @click="close">
<div class="w-full max-w-3xl rounded-3xl border border-slate-200 bg-white p-6 shadow-xl dark:border-slate-700 dark:bg-slate-900" @click.stop>
<div v-if="open" class="dialog-overlay" @click="close">
<div class="dialog-panel max-w-3xl p-6" @click.stop>
<div class="flex items-center justify-between gap-4">
<div>
<h3 class="text-xl font-bold text-slate-900 dark:text-slate-100">{{ t('kbDifySettings.title') }}</h3>
<p class="mt-1 text-sm text-slate-500 dark:text-slate-400">{{ t('kbDifySettings.subtitle') }}</p>
<h3 class="section-title text-xl">{{ t('kbDifySettings.title') }}</h3>
<p class="section-desc mt-1">{{ t('kbDifySettings.subtitle') }}</p>
</div>
<button class="rounded-2xl border border-slate-200 px-3 py-2 text-sm text-slate-600 hover:bg-slate-50 dark:border-slate-700 dark:text-slate-300 dark:hover:bg-slate-800" @click="close">
<button type="button" class="btn-secondary btn-sm" @click="close">
{{ t('common.close') }}
</button>
</div>
<div v-if="loading" class="py-16 text-center text-sm text-slate-400">{{ t('kbDifySettings.loading') }}</div>
<div v-else class="mt-6 grid gap-4 md:grid-cols-2">
<div v-if="loading" class="py-16 text-center text-sm text-muted">{{ t('kbDifySettings.loading') }}</div>
<div v-else class="mt-6 grid gap-4 md:grid-cols-2 form-stack">
<label class="space-y-2 md:col-span-2">
<span class="text-sm font-medium text-slate-600 dark:text-slate-300">Dify Base URL</span>
<span class="label-field block">Dify Base URL</span>
<input v-model="form.DIFY_API_BASE" class="input-field" placeholder="https://api.dify.ai/v1" />
</label>
<label class="space-y-2 md:col-span-2">
<span class="text-sm font-medium text-slate-600 dark:text-slate-300">Dify API Key</span>
<span class="label-field block">Dify API Key</span>
<input v-model="form.DIFY_API_KEY" class="input-field" placeholder="app-..." />
</label>
<label class="space-y-2">
<span class="text-sm font-medium text-slate-600 dark:text-slate-300">Permission</span>
<span class="label-field block">Permission</span>
<select v-model="form.KB_DIFY_PERMISSION" class="input-field">
<option value="only_me">only_me</option>
<option value="all_team_members">all_team_members</option>
</select>
</label>
<label class="space-y-2">
<span class="text-sm font-medium text-slate-600 dark:text-slate-300">Indexing Technique</span>
<span class="label-field block">Indexing Technique</span>
<select v-model="form.KB_DIFY_INDEXING_TECHNIQUE" class="input-field">
<option value="high_quality">high_quality</option>
<option value="economy">economy</option>
</select>
</label>
<label class="space-y-2">
<span class="text-sm font-medium text-slate-600 dark:text-slate-300">Search Method</span>
<span class="label-field block">Search Method</span>
<select v-model="form.KB_DIFY_SEARCH_METHOD" class="input-field">
<option value="semantic_search">semantic_search</option>
<option value="hybrid_search">hybrid_search</option>
@@ -94,7 +94,7 @@ watch(() => props.open, (open) => {
</select>
</label>
<label class="space-y-2">
<span class="text-sm font-medium text-slate-600 dark:text-slate-300">Doc Form</span>
<span class="label-field block">Doc Form</span>
<select v-model="form.KB_DIFY_DOC_FORM" class="input-field">
<option value="text_model">text_model</option>
</select>
@@ -102,10 +102,10 @@ watch(() => props.open, (open) => {
</div>
<div class="mt-6 flex justify-end gap-3">
<button class="rounded-2xl border border-slate-200 px-4 py-2.5 text-sm font-medium text-slate-700 hover:bg-slate-50 dark:border-slate-700 dark:text-slate-200 dark:hover:bg-slate-800" @click="close">
<button type="button" class="btn-secondary" @click="close">
{{ t('common.cancel') }}
</button>
<button class="rounded-2xl bg-brand-600 px-4 py-2.5 text-sm font-medium text-white hover:bg-brand-700 disabled:cursor-not-allowed disabled:opacity-60" :disabled="saving" @click="save">
<button type="button" class="btn-primary" :disabled="saving" @click="save">
{{ saving ? t('kbDifySettings.saving') : t('kbDifySettings.save') }}
</button>
</div>
+45 -42
View File
@@ -156,23 +156,23 @@ defineExpose({ loadData });
<template>
<div class="animate-fade-in-up">
<div class="flex flex-col gap-4 border-b border-gray-100 bg-white px-8 py-6 dark:border-slate-700 dark:bg-slate-900 lg:flex-row lg:items-start lg:justify-between">
<div class="kb-admin-header">
<div class="min-w-0 flex-1">
<h2 class="text-xl font-bold text-gray-900 dark:text-slate-100">{{ t('kbAdmin.title') }}</h2>
<p class="mt-1 text-sm text-gray-500 dark:text-slate-400">
<h2 class="text-xl font-bold text-primary">{{ t('kbAdmin.title') }}</h2>
<p class="section-desc mt-1">
{{ t('kbAdmin.subtitle') }}
</p>
</div>
<div class="flex w-full shrink-0 flex-col gap-2 sm:w-auto sm:flex-row sm:items-center sm:justify-end">
<div
class="inline-flex w-full items-stretch divide-x divide-slate-200 overflow-hidden rounded-xl border border-slate-200 bg-slate-50 dark:divide-slate-600 dark:border-slate-600 dark:bg-slate-800/80 sm:w-auto"
class="kb-admin-toolbar"
role="toolbar"
:aria-label="t('kbAdmin.toolbar')"
>
<button
type="button"
class="kb-admin-toolbar-btn"
@click="settingsDialogOpen = true"
class="inline-flex flex-1 items-center justify-center gap-1.5 px-3 py-2.5 text-sm font-medium text-slate-700 transition-colors hover:bg-white dark:text-slate-200 dark:hover:bg-slate-700 sm:flex-none sm:px-4"
:title="t('kbAdmin.difySettings')"
>
<Settings class="h-4 w-4 shrink-0" />
@@ -180,8 +180,8 @@ defineExpose({ loadData });
</button>
<button
type="button"
class="kb-admin-toolbar-btn"
@click="healthDialogOpen = true"
class="inline-flex flex-1 items-center justify-center gap-1.5 px-3 py-2.5 text-sm font-medium text-slate-700 transition-colors hover:bg-white dark:text-slate-200 dark:hover:bg-slate-700 sm:flex-none sm:px-4"
:title="t('kbAdmin.healthCheck')"
>
<Activity class="h-4 w-4 shrink-0" />
@@ -190,8 +190,8 @@ defineExpose({ loadData });
</div>
<button
type="button"
class="btn-primary inline-flex w-full items-center justify-center gap-2 px-5 py-2.5 text-sm sm:w-auto"
@click="router.push('/kb/workspace')"
class="inline-flex w-full items-center justify-center gap-2 rounded-xl bg-blue-600 px-5 py-2.5 text-sm font-medium text-white shadow-lg shadow-blue-200 transition-colors hover:bg-blue-700 sm:w-auto"
>
<Wrench class="h-4 w-4 shrink-0" />
<span class="whitespace-nowrap">{{ t('kbAdmin.goWorkspace') }}</span>
@@ -199,25 +199,25 @@ defineExpose({ loadData });
</div>
</div>
<div class="grid grid-cols-1 gap-6 bg-white p-8 dark:bg-slate-900 xl:grid-cols-[420px_minmax(0,1fr)]">
<section class="rounded-2xl border border-slate-200 p-6 dark:border-slate-700">
<div class="kb-admin-body">
<section class="kb-admin-section">
<div class="mb-5 flex items-center gap-3">
<div class="flex h-10 w-10 items-center justify-center rounded-2xl bg-brand-50 text-brand-600 dark:bg-brand-500/10">
<div class="flex h-10 w-10 items-center justify-center rounded-2xl bg-brand-50 text-brand-600">
<FolderPlus class="h-5 w-5" />
</div>
<div>
<h3 class="text-lg font-semibold text-slate-900 dark:text-slate-100">{{ formTitle }}</h3>
<p class="text-sm text-slate-500 dark:text-slate-400">{{ formDescription }}</p>
<h3 class="section-title">{{ formTitle }}</h3>
<p class="section-desc">{{ formDescription }}</p>
</div>
</div>
<div class="space-y-4">
<div>
<label class="mb-2 block text-sm font-medium text-slate-600 dark:text-slate-300">{{ t('kbAdmin.form.groupName') }}</label>
<label class="label-field mb-2 block">{{ t('kbAdmin.form.groupName') }}</label>
<input v-model="form.name" class="input-field" :placeholder="t('kbAdmin.form.groupNamePlaceholder')" />
</div>
<div>
<label class="mb-2 block text-sm font-medium text-slate-600 dark:text-slate-300">{{ t('kbAdmin.form.groupDesc') }}</label>
<label class="label-field mb-2 block">{{ t('kbAdmin.form.groupDesc') }}</label>
<textarea
v-model="form.description"
rows="4"
@@ -225,21 +225,21 @@ defineExpose({ loadData });
:placeholder="t('kbAdmin.form.groupDescPlaceholder')"
/>
</div>
<div class="flex flex-wrap items-center justify-end gap-2 border-t border-slate-100 pt-4 dark:border-slate-700">
<div class="flex flex-wrap items-center justify-end gap-2 border-t border-subtle pt-4">
<button
type="button"
class="btn-primary inline-flex items-center gap-1.5 px-5 py-2 text-sm disabled:cursor-not-allowed disabled:opacity-60"
@click="handleCreateGroup"
:disabled="isSubmitting"
class="inline-flex items-center gap-1.5 rounded-xl bg-blue-600 px-5 py-2 text-sm font-medium text-white shadow-md shadow-blue-200 transition-colors hover:bg-blue-700 disabled:cursor-not-allowed disabled:opacity-60"
>
<FolderPlus v-if="!isSubmitting" class="h-4 w-4 shrink-0" />
{{ submitText }}
</button>
<button
v-if="editingGroupId"
@click="resetForm"
type="button"
class="inline-flex items-center gap-1.5 rounded-xl border border-slate-200 px-4 py-2 text-sm font-medium text-slate-700 transition-colors hover:bg-slate-50 dark:border-slate-700 dark:text-slate-200 dark:hover:bg-slate-800"
class="btn-secondary inline-flex items-center gap-1.5 px-4 py-2 text-sm"
@click="resetForm"
>
<X class="h-4 w-4 shrink-0" />
{{ t('kbAdmin.form.cancelEdit') }}
@@ -248,7 +248,7 @@ defineExpose({ loadData });
<p
v-if="feedback"
class="text-sm"
:class="feedbackType === 'error' ? 'text-rose-500' : 'text-emerald-600 dark:text-emerald-400'"
:class="feedbackType === 'error' ? 'text-rose-500' : 'text-emerald-600'"
>
{{ feedback }}
</p>
@@ -256,44 +256,46 @@ defineExpose({ loadData });
</section>
<div class="space-y-6">
<section class="rounded-2xl border border-slate-200 p-6 dark:border-slate-700">
<section class="kb-admin-section">
<div class="mb-4 flex items-center justify-between">
<h3 class="text-lg font-semibold text-slate-900 dark:text-slate-100">{{ t('kbAdmin.groupsTitle') }}</h3>
<span class="text-xs text-slate-400">{{ isRefreshing ? t('common.loading') : '/api/kb/groups' }}</span>
<h3 class="section-title">{{ t('kbAdmin.groupsTitle') }}</h3>
<span class="text-xs text-muted">{{ isRefreshing ? t('common.loading') : '/api/kb/groups' }}</span>
</div>
<div v-if="groups.length === 0" class="rounded-2xl border border-dashed border-slate-200 px-4 py-10 text-center text-sm text-slate-400 dark:border-slate-700">
<div v-if="groups.length === 0" class="kb-admin-empty">
{{ t('kbAdmin.groupsEmpty') }}
</div>
<div v-else class="grid grid-cols-1 gap-3 md:grid-cols-2">
<div
v-for="group in groups"
:key="group.id"
class="rounded-2xl border border-slate-200 px-4 py-4 dark:border-slate-700"
class="kb-admin-card"
>
<div class="flex items-start justify-between gap-3">
<div class="min-w-0">
<div class="font-semibold text-slate-900 dark:text-slate-100">{{ group.name }}</div>
<div class="mt-1 text-sm text-slate-500 dark:text-slate-400">{{ group.description || t('kbAdmin.noDescription') }}</div>
<div class="font-semibold text-primary">{{ group.name }}</div>
<div class="mt-1 text-sm text-muted">{{ group.description || t('kbAdmin.noDescription') }}</div>
</div>
<div class="rounded-full bg-slate-100 px-2.5 py-1 text-xs font-medium text-slate-600 dark:bg-slate-800 dark:text-slate-300">
<div class="kb-admin-badge">
{{ t('kbAdmin.documentCount', { count: group.document_count ?? 0 }) }}
</div>
</div>
<div class="mt-4 flex flex-wrap items-center justify-between gap-3">
<div class="text-xs text-slate-400">
<div class="text-xs text-muted">
{{ t('kbAdmin.updatedAt') }}{{ group.updated_at || '--' }}
</div>
<div class="flex items-center gap-2">
<button
type="button"
class="btn-secondary inline-flex items-center gap-1 px-3 py-2 text-xs"
@click="handleEditGroup(group)"
class="inline-flex items-center gap-1 rounded-xl border border-slate-200 px-3 py-2 text-xs font-medium text-slate-600 transition-colors hover:bg-slate-50 dark:border-slate-700 dark:text-slate-300 dark:hover:bg-slate-800"
>
<Pencil class="h-3.5 w-3.5" />
{{ t('common.edit') }}
</button>
<button
type="button"
class="inline-flex items-center gap-1 rounded-xl border border-rose-200 px-3 py-2 text-xs font-medium text-rose-600 transition-colors hover:bg-rose-50"
@click="handleDeleteGroup(group)"
class="inline-flex items-center gap-1 rounded-xl border border-rose-200 px-3 py-2 text-xs font-medium text-rose-600 transition-colors hover:bg-rose-50 dark:border-rose-500/30 dark:text-rose-400 dark:hover:bg-rose-500/10"
>
<Trash2 class="h-3.5 w-3.5" />
{{ t('common.delete') }}
@@ -304,40 +306,41 @@ defineExpose({ loadData });
</div>
</section>
<section class="rounded-2xl border border-slate-200 p-6 dark:border-slate-700">
<section class="kb-admin-section">
<div class="mb-4 flex items-center justify-between">
<h3 class="text-lg font-semibold text-slate-900 dark:text-slate-100">{{ t('kbAdmin.jobsTitle') }}</h3>
<span class="text-xs text-slate-400">/api/kb/jobs</span>
<h3 class="section-title">{{ t('kbAdmin.jobsTitle') }}</h3>
<span class="text-xs text-muted">/api/kb/jobs</span>
</div>
<div v-if="jobs.length === 0" class="rounded-2xl border border-dashed border-slate-200 px-4 py-10 text-center text-sm text-slate-400 dark:border-slate-700">
<div v-if="jobs.length === 0" class="kb-admin-empty">
{{ t('kbAdmin.jobsEmpty') }}
</div>
<div v-else class="space-y-3">
<div
v-for="job in jobs"
:key="job.id"
class="rounded-2xl border border-slate-200 px-4 py-4 dark:border-slate-700"
class="kb-admin-card"
>
<div class="flex items-start justify-between gap-3">
<div class="min-w-0">
<div class="font-semibold text-slate-900 dark:text-slate-100">{{ job.job_type }}</div>
<div class="mt-1 text-sm text-slate-500 dark:text-slate-400">{{ job.created_at || '--' }}</div>
<div class="mt-2 text-sm text-slate-500 dark:text-slate-400">
<div class="font-semibold text-primary">{{ job.job_type }}</div>
<div class="mt-1 text-sm text-muted">{{ job.created_at || '--' }}</div>
<div class="mt-2 text-sm text-muted">
{{ job.message || t('kbAdmin.noJobMessage') }}
</div>
<div class="mt-2 text-xs text-slate-400">
<div class="mt-2 text-xs text-muted">
{{ t('kbAdmin.jobMeta', { docId: job.document_id ?? '--', versionId: job.document_version_id ?? '--', progress: job.progress ?? 0 }) }}
</div>
</div>
<span class="rounded-full bg-slate-100 px-2.5 py-1 text-xs font-medium text-slate-600 dark:bg-slate-800 dark:text-slate-300">
<span class="kb-admin-badge">
{{ job.status }}
</span>
</div>
<div class="mt-3 flex justify-end" v-if="['clean', 'sync_dify'].includes(job.job_type) && job.status !== 'success'">
<div v-if="['clean', 'sync_dify'].includes(job.job_type) && job.status !== 'success'" class="mt-3 flex justify-end">
<button
type="button"
class="inline-flex items-center gap-1 rounded-xl border border-brand-200 px-3 py-2 text-xs font-medium text-brand-700 transition-colors hover:bg-brand-50 disabled:cursor-not-allowed disabled:opacity-60"
@click="handleRunJob(job)"
:disabled="runningJobId === job.id"
class="inline-flex items-center gap-1 rounded-xl border border-brand-200 px-3 py-2 text-xs font-medium text-brand-700 transition-colors hover:bg-brand-50 disabled:cursor-not-allowed disabled:opacity-60 dark:border-brand-500/30 dark:text-brand-300 dark:hover:bg-brand-500/10"
>
<Play class="h-3.5 w-3.5" />
{{ runningJobId === job.id ? t('kbAdmin.running') : t('kbAdmin.runJob') }}
+5 -2
View File
@@ -1,5 +1,4 @@
import { createI18n } from 'vue-i18n';
import { createI18n } from 'vue-i18n';
const messages = {
'en': {
@@ -1266,6 +1265,7 @@ const messages = {
leaveBalanceTableUsed: 'Used',
leaveBalanceTableRemaining: 'Remaining',
leaveBalanceContactHr: 'If needed, please contact HR to confirm leave data.',
durationExceedsBalance: '{label} requested duration ({requested}) exceeds remaining balance ({remaining}), cannot submit.',
leaveConfirmPrompt: 'Please confirm the following leave information before submitting to OA.',
oaLeaveSubmitFailed: 'OA leave submission failed, please try again later.',
leaveSubmitFailedPrefix: 'Leave submission failed: {error}',
@@ -2699,6 +2699,7 @@ const messages = {
leaveBalanceTableUsed: '已休',
leaveBalanceTableRemaining: '当前剩余',
leaveBalanceContactHr: '如有疑问,请联系人事部门确认假期数据。',
durationExceedsBalance: '{label}申请时长({requested})超出剩余额度({remaining}),无法提交。',
leaveConfirmPrompt: '请确认以下请假信息,确认无误后再提交到 OA。',
oaLeaveSubmitFailed: 'OA 请假提交失败,请稍后重试。',
leaveSubmitFailedPrefix: '请假单提交失败:{error}',
@@ -3991,6 +3992,7 @@ const messages = {
leaveBalanceTableUsed: '已休',
leaveBalanceTableRemaining: '目前剩餘',
leaveBalanceContactHr: '如有疑問,請聯繫人事部門確認假期資料。',
durationExceedsBalance: '{label}申請時長({requested})超出剩餘額度({remaining}),無法提交。',
leaveConfirmPrompt: '請確認以下請假資訊,確認無誤後再提交到 OA。',
oaLeaveSubmitFailed: 'OA 請假提交失敗,請稍後重試。',
leaveSubmitFailedPrefix: '請假單提交失敗:{error}',
@@ -5200,6 +5202,7 @@ const messages = {
leaveBalanceTableUsed: 'ใช้ไปแล้ว',
leaveBalanceTableRemaining: 'คงเหลือปัจจุบัน',
leaveBalanceContactHr: 'หากมีข้อสงสัย โปรดติดต่อฝ่ายบุคคลเพื่อตรวจสอบข้อมูลวันลา',
durationExceedsBalance: '{label}ระยะเวลาที่ขอ({requested})เกินยอดคงเหลือ({remaining}) ไม่สามารถส่งได้',
leaveConfirmPrompt: 'โปรดยืนยันข้อมูลการลาพนักงานก่อนส่งไปยัง OA',
oaLeaveSubmitFailed: 'ส่งคำขอลา OA ไม่สำเร็จ กรุณาลองใหม่อีกครั้ง',
leaveSubmitFailedPrefix: 'ส่งใบลาล้มเหลว: {error}',
+18
View File
@@ -0,0 +1,18 @@
<script setup lang="ts">
import { useI18n } from 'vue-i18n';
import ThemeToggleButton from '../components/ThemeToggleButton.vue';
const { locale } = useI18n();
</script>
<template>
<div class="flex items-center gap-2">
<ThemeToggleButton />
<select v-model="locale" class="select-field-ds">
<option value="zh-CN">简体中文</option>
<option value="zh-TW">繁體</option>
<option value="en">English</option>
<option value="th">ไทย</option>
</select>
</div>
</template>
+63
View File
@@ -0,0 +1,63 @@
<script setup lang="ts">
import { ref } from 'vue';
import { PanelLeftClose, PanelLeftOpen } from 'lucide-vue-next';
import AppHeaderTools from './AppHeaderTools.vue';
withDefaults(
defineProps<{
title?: string;
subtitle?: string;
collapsibleSidebar?: boolean;
}>(),
{
title: '',
subtitle: '',
collapsibleSidebar: true,
}
);
const sidebarCollapsed = ref(false);
</script>
<template>
<div class="page-shell flex min-h-screen flex-col">
<header class="app-header">
<div class="flex min-w-0 items-center gap-3">
<button
v-if="collapsibleSidebar"
type="button"
class="btn-icon-ds hidden md:inline-flex"
:aria-label="sidebarCollapsed ? 'Expand sidebar' : 'Collapse sidebar'"
@click="sidebarCollapsed = !sidebarCollapsed"
>
<PanelLeftOpen v-if="sidebarCollapsed" class="h-5 w-5" />
<PanelLeftClose v-else class="h-5 w-5" />
</button>
<div class="min-w-0">
<slot name="header-brand">
<div v-if="title" class="truncate text-sm font-bold text-primary">{{ title }}</div>
<div v-if="subtitle" class="truncate text-xs text-muted">{{ subtitle }}</div>
</slot>
</div>
</div>
<div class="flex items-center gap-3">
<slot name="header-actions" />
<AppHeaderTools />
</div>
</header>
<div class="flex min-h-0 flex-1">
<aside
v-if="$slots.sidebar"
class="app-sidebar hidden md:block transition-[width] duration-200"
:class="sidebarCollapsed ? 'app-sidebar--collapsed' : ''"
>
<slot name="sidebar" :collapsed="sidebarCollapsed" />
</aside>
<main class="min-w-0 flex-1 overflow-y-auto page-shell-mobile py-6">
<slot />
</main>
</div>
</div>
</template>
+13
View File
@@ -0,0 +1,13 @@
<script setup lang="ts">
/** L3 — 对话页:侧栏 + 主区,颜色走 L1 令牌 */
</script>
<template>
<div class="relative flex h-screen overflow-hidden bg-page text-secondary">
<slot name="overlay" />
<slot name="sidebar" />
<div class="relative z-10 flex h-full w-full flex-1 flex-col overflow-hidden bg-surface">
<slot />
</div>
</div>
</template>
+14
View File
@@ -0,0 +1,14 @@
<script setup lang="ts">
/** L3 — 登录 / 营销页布局 */
</script>
<template>
<div class="page-shell min-h-screen">
<div v-if="$slots.tools" class="fixed top-4 right-4 z-50 flex items-center gap-2">
<slot name="tools" />
</div>
<main class="mx-auto max-w-7xl page-shell-mobile pb-12">
<slot />
</main>
</div>
</template>
+17
View File
@@ -0,0 +1,17 @@
<script setup lang="ts">
/** L3 — 单卡居中页(重置密码等) */
withDefaults(
defineProps<{
maxWidth?: string;
}>(),
{ maxWidth: '28rem' }
);
</script>
<template>
<div class="page-shell flex min-h-screen items-center justify-center p-4">
<div class="card w-full shadow-elevated p-8 md:p-10" :style="{ maxWidth }">
<slot />
</div>
</div>
</template>
+5 -1
View File
@@ -4,7 +4,11 @@ import App from './App.vue'
import router from './router'
import i18n from './i18n'
import { config } from './config'
import { refreshAccessToken, getAuthToken } from './utils/auth'
import { refreshAccessToken, getAuthToken, initAuthSync } from './utils/auth'
import { initAgentTabSync } from './utils/agentTabs'
initAuthSync();
initAgentTabSync();
// Set document title from config
document.title = config.appTitle || 'AI工作台';
+103 -106
View File
@@ -1,24 +1,12 @@
@import './styles/tokens.css';
@import './styles/utilities.css';
@import './styles/components-ds.css';
@tailwind base;
@tailwind components;
@tailwind utilities;
@layer base {
:root {
--bg-page: #f8fafc;
--bg-surface: #ffffff;
--bg-surface-soft: #f8fafc;
--bg-surface-strong: #f1f5f9;
--text-primary: #0f172a;
--text-secondary: #334155;
--text-muted: #64748b;
--border-default: #e2e8f0;
--border-subtle: #f1f5f9;
--overlay-soft: rgba(15, 23, 42, 0.4);
--shadow-elevated: 0 8px 30px -12px rgba(15, 23, 42, 0.2);
--glow-accent: 0 0 0 1px rgba(14, 165, 233, 0.18), 0 16px 40px -22px rgba(14, 165, 233, 0.45);
}
html {
font-family: 'PingFang SC', 'Microsoft YaHei', 'Segoe UI', 'Helvetica Neue', Arial, system-ui, sans-serif;
-webkit-font-smoothing: antialiased;
@@ -28,35 +16,14 @@
}
html.dark {
color-scheme: dark;
--bg-page: #020617;
--bg-surface: #0b1220;
--bg-surface-soft: #0f172a;
--bg-surface-strong: #1e293b;
--text-primary: #f8fafc;
--text-secondary: #cbd5e1;
--text-muted: #94a3b8;
--border-default: #334155;
--border-subtle: #1e293b;
--overlay-soft: rgba(2, 6, 23, 0.72);
--shadow-elevated: 0 12px 30px -16px rgba(2, 6, 23, 0.85);
--glow-accent: 0 0 0 1px rgba(56, 189, 248, 0.28), 0 20px 44px -24px rgba(56, 189, 248, 0.5);
background-color: var(--bg-page);
color: var(--text-secondary);
}
h1, h2, h3, h4, h5, h6 {
font-family: 'PingFang SC', 'Microsoft YaHei', 'Segoe UI Semibold', 'Segoe UI', 'Helvetica Neue', Arial, sans-serif;
@apply tracking-tight font-semibold text-slate-900;
}
html.dark h1,
html.dark h2,
html.dark h3,
html.dark h4,
html.dark h5,
html.dark h6 {
@apply text-slate-100;
@apply tracking-tight font-semibold;
color: var(--text-primary);
}
body {
@@ -82,23 +49,105 @@
}
.btn-secondary {
@apply btn bg-white text-slate-700 border border-slate-200 hover:bg-slate-50 hover:border-slate-300 shadow-sm;
@apply btn shadow-sm;
background-color: var(--bg-surface);
border: 1px solid var(--border-default);
color: var(--text-secondary);
}
.btn-secondary:hover {
background-color: var(--bg-surface-soft);
color: var(--text-primary);
}
.btn-ghost {
@apply btn bg-transparent text-slate-600 hover:bg-slate-100 hover:text-slate-900 shadow-none;
@apply btn shadow-none;
background-color: transparent;
color: var(--text-secondary);
}
.btn-ghost:hover {
background-color: var(--bg-surface-strong);
color: var(--text-primary);
}
.btn-danger {
@apply btn bg-red-50 text-red-600 hover:bg-red-100 border border-transparent;
@apply btn border border-transparent;
background-color: var(--status-error-bg);
color: var(--status-error-fg);
}
.btn-danger:hover {
filter: brightness(0.95);
}
.btn-sm {
@apply px-3 py-1.5 text-sm rounded-lg gap-1.5;
}
.btn-lg {
@apply px-6 py-3 text-base rounded-xl gap-2;
}
.btn-primary.btn-sm,
.btn-secondary.btn-sm,
.btn-ghost.btn-sm,
.btn-danger.btn-sm {
@apply px-3 py-1.5 text-sm rounded-lg;
}
.btn-primary.btn-lg,
.btn-secondary.btn-lg {
@apply px-6 py-3 text-base rounded-xl;
}
.select-field {
@apply input-field cursor-pointer;
appearance: auto;
}
.label-field {
@apply text-xs font-semibold uppercase tracking-wider;
color: var(--text-secondary);
}
.section-gap {
@apply space-y-6;
}
.form-stack {
@apply space-y-4;
}
/* @deprecated — use .segment-control + .segment-item (components-ds.css) */
.btn-segment {
@apply segment-item;
}
.btn-segment--active {
@apply segment-item--active;
}
.input-field {
@apply w-full px-4 py-3 rounded-xl border border-slate-200 bg-white text-slate-900 placeholder-slate-400 focus:border-brand-500 focus:ring-2 focus:ring-brand-500/20 outline-none transition-all duration-200;
@apply w-full px-4 py-3 rounded-xl outline-none transition-all duration-200;
border: 1px solid var(--border-default);
background-color: var(--bg-surface);
color: var(--text-primary);
}
.input-field::placeholder {
color: var(--text-muted);
}
.input-field:focus {
border-color: #0ea5e9;
box-shadow: 0 0 0 3px var(--focus-ring);
}
.card {
@apply bg-white rounded-2xl border border-slate-100 shadow-soft hover:shadow-lg transition-all duration-300 dark:bg-slate-800 dark:border-slate-700;
@apply rounded-2xl shadow-soft hover:shadow-lg transition-all duration-300;
background-color: var(--bg-surface);
border: 1px solid var(--border-default);
}
/* Mobile-first layout tokens for consistent spacing and density. */
@@ -128,21 +177,20 @@
.glass-panel {
@apply backdrop-blur-xl border;
background: rgba(255, 255, 255, 0.68);
border-color: rgba(148, 163, 184, 0.26);
background: var(--glass-panel-bg);
border-color: var(--glass-panel-border);
box-shadow: var(--glow-accent);
}
/* Keep chat composer border and fill visually consistent in light/dark themes. */
.chat-composer-shell {
background-image: linear-gradient(180deg, rgba(255, 255, 255, 0.97) 0%, rgba(248, 250, 252, 0.97) 100%);
box-shadow: 0 14px 28px -20px rgba(15, 23, 42, 0.38);
background-image: var(--chat-composer-gradient);
box-shadow: var(--chat-composer-shadow);
background-clip: padding-box;
}
.chat-composer-shell:focus-within {
transform: translateY(-1px);
box-shadow: 0 16px 34px -22px rgba(14, 165, 233, 0.45);
box-shadow: var(--chat-composer-shadow-focus);
}
.chat-composer-textarea {
@@ -164,57 +212,14 @@
.chat-composer-textarea::selection {
background-color: rgba(14, 165, 233, 0.2);
}
}
@layer components {
html.dark .btn-secondary {
background-color: var(--bg-surface-strong);
border-color: var(--border-default);
color: var(--text-secondary);
html.dark .chat-composer-textarea {
caret-color: #67e8f9;
}
html.dark .btn-secondary:hover {
background-color: var(--bg-surface-soft);
border-color: #475569;
color: var(--text-primary);
html.dark .chat-composer-textarea::selection {
background-color: rgba(56, 189, 248, 0.25);
}
html.dark .btn-ghost {
color: var(--text-secondary);
}
html.dark .btn-ghost:hover {
background-color: var(--bg-surface-strong);
color: var(--text-primary);
}
html.dark .btn-danger {
background-color: rgba(239, 68, 68, 0.12);
color: #fca5a5;
}
html.dark .btn-danger:hover {
background-color: rgba(239, 68, 68, 0.2);
}
html.dark .glass-panel {
background: rgba(2, 6, 23, 0.66);
border-color: rgba(71, 85, 105, 0.5);
}
html.dark .chat-composer-shell {
background-image: linear-gradient(180deg, rgba(15, 23, 42, 0.92) 0%, rgba(10, 16, 30, 0.92) 100%);
box-shadow: 0 18px 36px -28px rgba(2, 6, 23, 0.96);
}
html.dark .chat-composer-textarea {
background-color: transparent !important;
caret-color: #67e8f9;
}
html.dark .chat-composer-textarea::selection {
background-color: rgba(56, 189, 248, 0.25);
}
}
/* Custom Scrollbar */
@@ -241,6 +246,8 @@ html.dark #app {
color: var(--text-secondary);
}
/* Legacy shim — maps unmigrated Tailwind color utilities to L1 tokens. Remove as views finish migration. */
html.dark .bg-white {
background-color: var(--bg-surface) !important;
}
@@ -325,16 +332,6 @@ html.dark .ring-1 {
--tw-ring-color: rgba(148, 163, 184, 0.3);
}
html.dark .input-field {
background-color: var(--bg-surface-soft) !important;
border-color: var(--border-default) !important;
color: var(--text-primary) !important;
}
html.dark .input-field::placeholder {
color: var(--text-muted) !important;
}
html.dark input:not([type="checkbox"]):not([type="radio"]),
html.dark textarea,
html.dark select {
+863
View File
@@ -0,0 +1,863 @@
/**
* L2 Design System components — token-driven, no dark: color pairs.
*/
@layer components {
.page-shell {
min-height: 100vh;
background-color: var(--bg-page);
color: var(--text-secondary);
}
.page-title {
font-size: 1.5rem;
line-height: 2rem;
font-weight: 700;
color: var(--text-primary);
}
.section-title {
font-size: 1.125rem;
line-height: 1.75rem;
font-weight: 600;
color: var(--text-primary);
}
.section-desc {
font-size: 0.875rem;
line-height: 1.25rem;
color: var(--text-muted);
}
.input-field-ds { @apply input-field; }
.select-field-ds { @apply select-field; }
.card-ds { @apply card; }
.card-ds-interactive {
@apply card;
}
.card-ds-interactive:hover {
box-shadow: var(--shadow-elevated);
border-color: rgba(14, 165, 233, 0.35);
}
.card-padding {
padding: 1rem;
}
@media (min-width: 640px) {
.card-padding {
padding: 1.5rem;
}
}
.surface-panel {
background-color: var(--bg-surface);
border: 1px solid var(--border-default);
border-radius: 1rem;
}
/* Aliases — prefer .btn-secondary / .btn-ghost in style.css */
.btn-secondary-ds { @apply btn-secondary; }
.btn-ghost-ds { @apply btn-ghost; }
.btn-icon-ds {
display: inline-flex;
align-items: center;
justify-content: center;
width: 2.25rem;
height: 2.25rem;
border-radius: 0.75rem;
color: var(--text-muted);
transition: background-color 0.2s, color 0.2s;
}
.btn-icon-ds:hover {
background-color: var(--bg-surface-strong);
color: var(--text-primary);
}
.alert-ds {
display: flex;
gap: 0.75rem;
padding: 1rem 1.25rem;
border-radius: 0.75rem;
border: 1px solid;
font-size: 0.875rem;
}
.alert-success {
background-color: var(--status-success-bg);
border-color: var(--status-success-border);
color: var(--status-success-fg);
}
.alert-info {
background-color: var(--status-info-bg);
border-color: var(--status-info-border);
color: var(--status-info-fg);
}
.alert-warning {
background-color: var(--status-warning-bg);
border-color: var(--status-warning-border);
color: var(--status-warning-fg);
}
.alert-error {
background-color: var(--status-error-bg);
border-color: var(--status-error-border);
color: var(--status-error-fg);
}
.app-header {
display: flex;
align-items: center;
justify-content: space-between;
height: var(--header-height);
padding-left: 1rem;
padding-right: 1rem;
border-bottom: 1px solid var(--border-default);
background-color: color-mix(in srgb, var(--bg-surface) 88%, transparent);
backdrop-filter: blur(12px);
position: sticky;
top: 0;
z-index: 30;
}
.app-sidebar {
width: var(--sidebar-width);
flex-shrink: 0;
border-right: 1px solid var(--border-default);
background-color: var(--bg-surface);
overflow-y: auto;
}
.app-sidebar--collapsed {
width: var(--sidebar-collapsed-width);
}
.sidebar-nav-item {
display: flex;
align-items: center;
gap: 0.75rem;
padding: 0.625rem 1rem;
margin: 0 0.5rem;
border-radius: 0.75rem;
font-size: 0.875rem;
font-weight: 500;
color: var(--text-muted);
transition: background-color 0.15s, color 0.15s;
}
.sidebar-nav-item:hover {
background-color: var(--bg-surface-soft);
color: var(--text-secondary);
}
.sidebar-nav-item--active {
background-color: color-mix(in srgb, #0ea5e9 12%, var(--bg-surface-soft));
color: #0284c7;
}
html.dark .sidebar-nav-item--active {
color: #7dd3fc;
}
.token-swatch {
border-radius: 0.75rem;
border: 1px solid var(--border-default);
overflow: hidden;
}
.token-swatch__color {
height: 3.5rem;
}
.token-swatch__meta {
padding: 0.5rem 0.75rem;
background-color: var(--bg-surface);
border-top: 1px solid var(--border-subtle);
}
.shell-preview {
border: 1px dashed var(--border-default);
border-radius: 1rem;
overflow: hidden;
background-color: var(--bg-page);
}
.shell-preview__chrome {
height: 2rem;
background-color: var(--bg-surface-strong);
border-bottom: 1px solid var(--border-default);
display: flex;
align-items: center;
padding: 0 0.5rem;
gap: 0.25rem;
}
.shell-preview__dot {
width: 0.5rem;
height: 0.5rem;
border-radius: 9999px;
background-color: var(--border-default);
}
/* Admin — data tables (token-driven, no dark: pairs) */
.admin-table-section {
background-color: var(--bg-surface);
border: 1px solid var(--border-default);
@apply rounded-2xl shadow-sm overflow-hidden animate-fade-in;
}
.admin-table-wrap {
@apply overflow-x-auto;
}
.admin-table-header {
@apply px-8 py-6 border-b border-default flex justify-between items-center;
background-color: var(--bg-surface);
}
.admin-table-header--stacked {
@apply flex-col md:flex-row items-start md:items-center gap-4;
}
.admin-table-filters {
@apply px-8 py-4 border-b border-subtle gap-4;
background-color: var(--bg-surface-soft);
}
.admin-table-filters--inline {
@apply flex flex-wrap p-4 rounded-xl border border-default shadow-sm;
background-color: var(--bg-surface);
}
.admin-table {
@apply w-full text-left;
}
.admin-table thead {
background-color: var(--bg-surface-soft);
border-bottom: 1px solid var(--border-subtle);
}
.admin-table thead th {
@apply font-semibold text-muted uppercase tracking-wider;
}
.admin-table tbody tr {
border-top: 1px solid var(--border-subtle);
transition: background-color 0.15s ease;
}
.admin-table tbody tr:hover {
background-color: var(--bg-surface-soft);
}
.admin-table-empty {
@apply py-12 text-center text-sm text-muted;
}
.admin-table-filter-input {
@apply px-3 py-2 rounded-lg border text-sm outline-none transition;
border-color: var(--border-default);
background-color: var(--bg-surface);
color: var(--text-primary);
}
.admin-table-filter-input:focus {
border-color: #0ea5e9;
box-shadow: 0 0 0 2px var(--focus-ring);
}
.admin-table-sticky-head {
background-color: var(--bg-surface-soft);
}
.admin-table-sticky-cell {
background-color: var(--bg-surface);
}
.admin-report-table-wrap {
@apply overflow-x-auto rounded-2xl border border-default shadow-elevated;
background-color: var(--bg-surface);
}
.admin-report-table thead {
@apply sticky top-0 text-xs uppercase tracking-wider;
background: linear-gradient(
to right,
var(--bg-surface-strong),
color-mix(in srgb, var(--bg-surface-soft) 75%, #0ea5e9 25%)
);
color: var(--text-secondary);
}
.admin-report-table thead th {
@apply font-semibold border-b border-default align-top;
}
.admin-report-table tbody tr {
border-top: 1px solid var(--border-subtle);
transition: background-color 0.15s ease;
}
.admin-report-table tbody tr:nth-child(odd) {
background-color: var(--bg-surface);
}
.admin-report-table tbody tr:nth-child(even) {
background-color: color-mix(in srgb, var(--bg-surface-soft) 65%, transparent);
}
.admin-report-table tbody tr:hover {
background-color: color-mix(in srgb, #0ea5e9 8%, var(--bg-surface-soft));
}
.admin-report-table tbody td {
@apply text-sm border-b border-subtle align-top;
color: var(--text-secondary);
}
.admin-report-filter-input {
@apply w-full px-2 py-1 text-xs border rounded outline-none font-normal normal-case;
border-color: var(--border-default);
background-color: var(--bg-surface);
color: var(--text-primary);
}
.admin-report-filter-input:focus {
border-color: #0ea5e9;
box-shadow: 0 0 0 1px var(--focus-ring);
}
/* Admin — reports module shell */
.admin-report-section {
@apply relative rounded-3xl border border-default shadow-elevated overflow-hidden animate-fade-in;
background-color: var(--bg-surface);
background-image: linear-gradient(
145deg,
var(--bg-surface) 0%,
var(--bg-surface-soft) 55%,
color-mix(in srgb, var(--bg-surface-soft) 88%, #0ea5e9 12%) 100%
);
}
.admin-report-toolbar {
@apply px-6 md:px-8 py-5 border-b border-default flex flex-col gap-4 lg:flex-row lg:items-center lg:justify-between sticky top-0 z-10;
background-color: color-mix(in srgb, var(--bg-surface) 92%, transparent);
backdrop-filter: blur(12px);
}
.admin-report-badge {
@apply inline-flex items-center rounded-full border border-default px-3 py-1 text-xs font-medium;
background-color: var(--bg-surface-soft);
color: var(--text-secondary);
}
.admin-report-badge--info {
border-color: color-mix(in srgb, #0ea5e9 30%, var(--border-default));
background-color: color-mix(in srgb, #0ea5e9 10%, var(--bg-surface-soft));
color: var(--text-secondary);
}
.admin-report-badge--indigo {
border-color: color-mix(in srgb, #6366f1 30%, var(--border-default));
background-color: color-mix(in srgb, #6366f1 10%, var(--bg-surface-soft));
color: var(--text-secondary);
}
.admin-report-panel {
@apply p-4 md:p-5 rounded-2xl border border-default shadow-sm;
background-color: var(--bg-surface);
}
.admin-report-setting-chip {
@apply flex items-center gap-2 px-3 py-2 rounded-lg border border-default text-xs;
background-color: var(--bg-surface-soft);
color: var(--text-secondary);
}
.admin-report-sort-row {
@apply grid grid-cols-12 items-center gap-2 text-xs p-2 border border-default rounded-lg;
background-color: var(--bg-surface);
}
.admin-report-col-chip {
@apply flex items-center justify-between gap-2 px-2 py-1.5 rounded-lg border border-default;
background-color: var(--bg-surface-soft);
}
.admin-report-header-btn {
@apply text-left transition-colors text-secondary hover:text-brand-600;
}
.admin-report-page-btn {
@apply rounded-lg border border-default px-2.5 py-1.5 text-xs text-secondary transition-colors;
}
.admin-report-page-btn:hover:not(:disabled) {
background-color: var(--bg-surface-soft);
}
.admin-report-page-btn--active {
@apply border-brand-600 bg-brand-600 text-white;
}
.admin-report-page-btn--active:hover {
background-color: #0284c7;
}
.admin-report-page-btn:disabled {
@apply opacity-40 cursor-not-allowed;
}
.admin-nav-btn {
@apply px-4 py-3 text-left text-sm font-medium rounded-xl transition-all flex items-center gap-3 relative overflow-hidden whitespace-nowrap flex-shrink-0;
color: var(--text-muted);
}
.admin-nav-btn:hover:not(.admin-nav-btn--active) {
background-color: var(--bg-surface-soft);
color: var(--text-primary);
}
.admin-nav-btn--active {
background-color: color-mix(in srgb, #0ea5e9 12%, var(--bg-surface-soft));
color: #0284c7;
box-shadow: 0 1px 2px 0 rgb(0 0 0 / 0.05);
}
html.dark .admin-nav-btn--active {
color: #7dd3fc;
box-shadow: none;
outline: 1px solid color-mix(in srgb, #0ea5e9 25%, transparent);
outline-offset: -1px;
}
.admin-nav-subitem {
@apply w-full text-left px-4 py-2 text-xs font-medium rounded-lg transition-colors flex items-center gap-2;
color: var(--text-muted);
}
.admin-nav-subitem:hover:not(.admin-nav-subitem--active) {
background-color: var(--bg-surface-soft);
color: var(--text-secondary);
}
.admin-nav-subitem--active {
background-color: color-mix(in srgb, #0ea5e9 12%, var(--bg-surface-soft));
color: #0284c7;
}
html.dark .admin-nav-subitem--active {
color: #7dd3fc;
}
.admin-form-panel {
@apply px-8 py-8 border-b border-default bg-surface;
}
.admin-side-card {
@apply card p-6 h-fit;
}
.admin-panel {
@apply rounded-2xl border border-default bg-surface shadow-sm;
}
.admin-panel-lg {
@apply rounded-3xl border border-default bg-surface shadow-sm;
}
.admin-panel-padding {
@apply p-6;
}
.admin-stat-tile {
@apply rounded-2xl bg-surface-soft px-4 py-3;
}
.admin-modal-overlay {
@apply fixed inset-0 z-50 flex items-start sm:items-center justify-center p-3 sm:p-4 overflow-y-auto bg-overlay backdrop-blur-sm;
}
.admin-modal-panel {
@apply card w-full shadow-elevated flex flex-col;
}
.admin-modal-header {
@apply px-5 sm:px-8 pt-5 sm:pt-7 pb-4 border-b border-default flex justify-between items-start shrink-0;
}
.admin-modal-body {
@apply px-5 sm:px-8 py-5 space-y-5 overflow-y-auto flex-1;
}
.admin-modal-footer {
@apply px-5 sm:px-8 py-4 border-t border-default flex justify-end gap-3 bg-surface rounded-b-2xl shrink-0;
}
.admin-modal-footer--muted {
background-color: var(--bg-surface-soft);
}
.admin-dropdown {
@apply absolute z-20 mt-2 max-h-64 overflow-auto rounded-xl border border-default bg-surface shadow-elevated;
}
.admin-code-block {
@apply p-3 rounded-lg border border-default text-sm font-mono break-all;
background-color: var(--bg-surface-soft);
color: var(--text-secondary);
}
.admin-pre-block {
@apply mt-1 max-h-[200px] overflow-auto whitespace-pre-wrap rounded-lg border border-default p-2 font-mono text-[10px];
background-color: var(--bg-surface-strong);
color: var(--text-secondary);
}
.admin-pre-block--sql {
@apply mt-1 max-h-none overflow-auto whitespace-pre-wrap rounded-lg border border-default p-3 font-mono text-xs text-emerald-600;
background-color: var(--bg-surface-strong);
}
html.dark .admin-pre-block--sql {
color: #6ee7b7;
}
.admin-checkbox {
@apply w-4 h-4 cursor-pointer rounded border-default text-brand-600 focus:ring-brand-500;
}
.admin-checkbox-lg {
@apply w-5 h-5 cursor-pointer rounded border-default text-blue-600 focus:ring-blue-500;
}
/* Segment control — toggle / single-choice (not action buttons) */
.segment-control {
@apply inline-flex max-w-full flex-wrap gap-2;
}
/* 2–3 个短选项:独立细边框芯片 */
.segment-control--chips {
@apply gap-2;
}
/* 等分宽、独立细边框(如 Cron 四选一)— 无共用轨道 */
.segment-control--chips-equal {
@apply flex w-full flex-nowrap gap-2;
}
.segment-control--chips-equal .segment-item {
@apply min-w-0 flex-1 justify-center text-center;
}
.segment-item {
@apply shrink-0 cursor-pointer whitespace-nowrap rounded-xl border px-3 py-2 text-sm font-semibold transition-colors duration-200;
color: var(--text-secondary);
background-color: var(--bg-surface);
border-color: var(--border-default);
box-shadow: none;
}
.segment-item:hover:not(.segment-item--active) {
color: var(--text-primary);
background-color: var(--bg-surface-soft);
}
.segment-item--active {
color: #0284c7;
background-color: color-mix(in srgb, #0ea5e9 12%, var(--bg-surface));
border-color: color-mix(in srgb, #0ea5e9 38%, var(--border-default));
}
html.dark .segment-item--active {
color: #7dd3fc;
background-color: color-mix(in srgb, #0ea5e9 20%, var(--bg-surface));
border-color: color-mix(in srgb, #38bdf8 45%, var(--border-default));
}
.segment-control--sm .segment-item {
@apply px-3 py-1.5 text-xs;
}
.segment-control--md .segment-item {
@apply px-4 py-2.5 text-sm;
}
/* @deprecated — use .segment-control + .segment-item */
.btn-segment-group {
@apply segment-control segment-control--chips segment-control--sm;
}
.btn-segment-group .btn-segment {
@apply segment-item;
border: none;
border-radius: 0.5rem;
box-shadow: none;
}
.btn-segment-group .btn-segment.btn-segment--active {
@apply segment-item--active;
}
/* KB admin panel (embedded in AdminView) */
.kb-admin-header {
@apply flex flex-col gap-4 border-b border-default bg-surface px-8 py-6 lg:flex-row lg:items-start lg:justify-between;
}
.kb-admin-toolbar {
@apply inline-flex w-full items-stretch divide-x divide-subtle overflow-hidden rounded-xl border border-default sm:w-auto;
background-color: var(--bg-surface-soft);
}
.kb-admin-toolbar-btn {
@apply inline-flex flex-1 items-center justify-center gap-1.5 px-3 py-2.5 text-sm font-medium transition-colors sm:flex-none sm:px-4;
color: var(--text-secondary);
}
.kb-admin-toolbar-btn:hover {
background-color: var(--bg-surface);
color: var(--text-primary);
}
.kb-admin-body {
@apply grid grid-cols-1 gap-6 bg-surface p-8 xl:grid-cols-[420px_minmax(0,1fr)];
}
.kb-admin-section {
@apply admin-panel p-6;
}
.kb-admin-card {
@apply admin-panel px-4 py-4;
}
.kb-admin-empty {
@apply rounded-2xl border border-dashed px-4 py-10 text-center text-sm text-muted;
border-color: var(--border-default);
background-color: var(--bg-surface-soft);
}
.kb-admin-badge {
@apply rounded-full bg-surface-soft px-2.5 py-1 text-xs font-medium text-secondary shrink-0;
}
/* Chat — L2 */
.chat-sidebar-btn {
@apply flex w-full items-center justify-center gap-2 rounded-xl border border-default bg-surface-soft py-3 text-sm font-medium text-secondary shadow-sm transition-colors hover-surface-strong;
}
.chat-sidebar-btn-icon {
@apply flex h-10 w-10 shrink-0 items-center justify-center rounded-xl bg-surface-soft text-secondary shadow-sm transition-colors hover-surface-strong;
}
.chat-history-item {
@apply relative flex w-full items-center justify-between rounded-lg transition-colors hover-surface-soft;
}
.chat-history-item--active {
background-color: color-mix(in srgb, #0ea5e9 12%, var(--bg-surface-soft));
}
.chat-history-link {
@apply flex-1 truncate px-3 py-2.5 text-left text-sm pr-8 text-secondary;
}
.chat-history-link--active {
@apply font-medium text-brand-700;
}
html.dark .chat-history-link--active {
color: #7dd3fc;
}
.chat-dropdown {
@apply absolute z-50 rounded-xl border border-default bg-surface py-1 shadow-elevated;
}
.chat-msg-assistant {
@apply w-full rounded-2xl border border-default bg-surface px-6 py-4 text-[15px] leading-relaxed text-primary shadow-sm;
}
.chat-agent-panel {
@apply mb-4 rounded-2xl border border-default p-3;
background-color: color-mix(in srgb, var(--bg-surface-soft) 85%, transparent);
}
.chat-icon-muted {
@apply text-muted transition-colors hover:text-secondary;
}
/* Workspace logged-in — L3 main + L2 nav (reuse admin-nav rhythm) */
.ws-main {
@apply min-w-0 section-gap bg-page page-shell-mobile md:py-8 lg:px-8;
}
.ws-nav-btn {
@apply flex w-full items-center gap-3 rounded-2xl px-4 py-3 text-left text-[15px] font-medium transition-all;
color: var(--text-secondary);
}
.ws-nav-btn:hover:not(.ws-nav-btn--active) {
background-color: var(--bg-surface-soft);
color: var(--text-primary);
}
.ws-nav-btn--active {
background-color: color-mix(in srgb, #0ea5e9 12%, var(--bg-surface-soft));
color: #0284c7;
box-shadow: 0 1px 2px 0 rgb(0 0 0 / 0.05);
}
html.dark .ws-nav-btn--active {
color: #7dd3fc;
outline: 1px solid color-mix(in srgb, #0ea5e9 25%, transparent);
outline-offset: -1px;
}
.ws-nav-btn--danger {
@apply text-red-500 hover:bg-red-50 hover:text-red-600;
}
html.dark .ws-nav-btn--danger {
@apply text-red-400 hover:bg-red-950/40 hover:text-red-300;
}
.ws-card {
@apply admin-panel-lg px-6 py-6 shadow-sm md:px-8;
}
.ws-history-card {
@apply w-full admin-panel p-3 text-left transition-colors hover:border-brand-300;
background-color: var(--bg-surface);
}
.ws-history-card:hover {
background-color: color-mix(in srgb, #0ea5e9 8%, var(--bg-surface));
}
/* Shared dialogs — app-wide (Dify, delete confirm, feedback, file preview) */
.dialog-overlay {
@apply fixed inset-0 flex items-start sm:items-center justify-center p-3 sm:p-4 overflow-y-auto bg-overlay backdrop-blur-sm;
z-index: 100;
}
.dialog-overlay--z80 {
z-index: 80;
}
.dialog-overlay--z110 {
z-index: 110;
}
.dialog-panel {
@apply card w-full shadow-elevated flex flex-col;
}
.dialog-header {
@apply flex items-center justify-between gap-4 border-b border-default shrink-0 px-5 py-4 sm:px-8 sm:pt-7 sm:pb-4;
}
.dialog-header--compact {
@apply px-6 py-4;
}
.dialog-body {
@apply overflow-y-auto flex-1 px-5 py-5 sm:px-8 form-stack;
}
.dialog-body--flush {
@apply px-0 py-0;
}
.dialog-footer {
@apply flex justify-end gap-3 border-t border-default shrink-0 px-5 py-4 sm:px-8 rounded-b-2xl;
background-color: var(--bg-surface);
}
.dialog-stat-card {
@apply admin-panel px-4 py-4;
}
.dialog-preview-body {
@apply flex-1 overflow-auto p-4 bg-page;
}
.dialog-preview-frame {
@apply bg-surface border border-default rounded-lg;
}
.dialog-icon-warning {
@apply inline-flex h-[22px] w-[22px] shrink-0 items-center justify-center rounded-full text-sm font-semibold leading-none mt-0.5;
background-color: var(--status-warning-bg);
color: var(--status-warning-fg);
border: 1px solid var(--status-warning-border);
}
.theme-toggle-btn {
@apply flex items-center justify-center rounded-full border border-default backdrop-blur-md transition-all text-muted hover:text-primary hover:shadow-md;
background-color: color-mix(in srgb, var(--bg-surface) 88%, transparent);
}
.theme-toggle-btn--inline {
@apply h-8 w-8 md:h-9 md:w-9 shadow-sm;
}
.theme-toggle-btn--floating {
@apply fixed bottom-5 right-5 z-[70] h-11 w-11 shadow-lg hover:shadow-xl;
}
/* KB Workspace */
.kb-ws-section {
@apply admin-panel-lg p-6;
}
.kb-ws-card {
@apply admin-panel p-4 transition-colors h-full min-h-[260px] flex flex-col;
}
.kb-ws-card--interactive {
@apply kb-ws-card cursor-pointer hover:border-brand-300;
}
.kb-ws-stat-grid {
@apply mb-6 grid grid-cols-2 gap-3 admin-panel-lg p-4 md:grid-cols-4 xl:grid-cols-7;
}
.kb-ws-stat-tile {
@apply admin-stat-tile text-center transition-colors;
}
.kb-ws-group-list-btn {
@apply w-full admin-panel px-4 py-4 text-left transition-all;
}
.kb-ws-group-list-btn--active {
border-color: color-mix(in srgb, #0ea5e9 40%, var(--border-default));
background-color: color-mix(in srgb, #0ea5e9 10%, var(--bg-surface-soft));
color: #0284c7;
}
html.dark .kb-ws-group-list-btn--active {
color: #7dd3fc;
}
.kb-ws-badge-count {
@apply kb-admin-badge;
}
.kb-ws-icon-btn {
@apply btn-icon-ds rounded-2xl border border-default;
}
.kb-ws-tooltip {
@apply pointer-events-none absolute left-0 top-8 z-10 hidden w-80 admin-panel px-4 py-3 text-sm text-muted shadow-elevated group-hover:block;
}
}
+99
View File
@@ -0,0 +1,99 @@
/**
* L1 Design Tokens — single source for light/dark colors.
* Toggle theme via html.dark (useTheme); do not duplicate values in components.
*/
:root {
/* Surfaces */
--bg-page: #f8fafc;
--bg-surface: #ffffff;
--bg-surface-soft: #f8fafc;
--bg-surface-strong: #f1f5f9;
/* Text */
--text-primary: #0f172a;
--text-secondary: #334155;
--text-muted: #64748b;
/* Borders & effects */
--border-default: #e2e8f0;
--border-subtle: #f1f5f9;
--overlay-soft: rgba(15, 23, 42, 0.4);
--shadow-elevated: 0 8px 30px -12px rgba(15, 23, 42, 0.2);
--glow-accent: 0 0 0 1px rgba(14, 165, 233, 0.18), 0 16px 40px -22px rgba(14, 165, 233, 0.45);
--focus-ring: rgba(14, 165, 233, 0.35);
/* Status — backgrounds & foregrounds */
--status-success-bg: #eef8e8;
--status-success-border: #b7e2a7;
--status-success-fg: #389e0d;
--status-info-bg: #eaf4ff;
--status-info-border: #9fcbff;
--status-info-fg: #1677ff;
--status-warning-bg: #fff8e8;
--status-warning-border: #ffd88a;
--status-warning-fg: #d48806;
--status-error-bg: #fff1f0;
--status-error-border: #ffb3b0;
--status-error-fg: #cf1322;
/* L3 layout constants */
--header-height: 3.5rem;
--sidebar-width: 16rem;
--sidebar-collapsed-width: 4rem;
--content-max-width: 80rem;
/* Spacing rhythm (L2/L3 reference — prefer semantic classes over raw gap-*) */
--space-page-x: 1rem;
--space-page-x-md: 2rem;
--space-section: 1.5rem;
--space-section-lg: 2rem;
--space-card: 1.5rem;
--space-form: 1rem;
--radius-control: 0.75rem;
--radius-surface: 1rem;
--glass-panel-bg: rgba(255, 255, 255, 0.68);
--glass-panel-border: rgba(148, 163, 184, 0.26);
--chat-composer-gradient: linear-gradient(180deg, rgba(255, 255, 255, 0.97) 0%, rgba(248, 250, 252, 0.97) 100%);
--chat-composer-shadow: 0 14px 28px -20px rgba(15, 23, 42, 0.38);
--chat-composer-shadow-focus: 0 16px 34px -22px rgba(14, 165, 233, 0.45);
}
html.dark {
color-scheme: dark;
--bg-page: #020617;
--bg-surface: #0b1220;
--bg-surface-soft: #0f172a;
--bg-surface-strong: #1e293b;
--text-primary: #f8fafc;
--text-secondary: #cbd5e1;
--text-muted: #94a3b8;
--border-default: #334155;
--border-subtle: #1e293b;
--overlay-soft: rgba(2, 6, 23, 0.72);
--shadow-elevated: 0 12px 30px -16px rgba(2, 6, 23, 0.85);
--glow-accent: 0 0 0 1px rgba(56, 189, 248, 0.28), 0 20px 44px -24px rgba(56, 189, 248, 0.5);
--focus-ring: rgba(56, 189, 248, 0.4);
--status-success-bg: rgba(34, 197, 94, 0.12);
--status-success-border: rgba(34, 197, 94, 0.35);
--status-success-fg: #86efac;
--status-info-bg: rgba(56, 189, 248, 0.12);
--status-info-border: rgba(56, 189, 248, 0.35);
--status-info-fg: #7dd3fc;
--status-warning-bg: rgba(250, 204, 21, 0.12);
--status-warning-border: rgba(250, 204, 21, 0.35);
--status-warning-fg: #fde047;
--status-error-bg: rgba(239, 68, 68, 0.12);
--status-error-border: rgba(239, 68, 68, 0.35);
--status-error-fg: #fca5a5;
--glass-panel-bg: rgba(2, 6, 23, 0.66);
--glass-panel-border: rgba(71, 85, 105, 0.5);
--chat-composer-gradient: linear-gradient(180deg, rgba(15, 23, 42, 0.92) 0%, rgba(10, 16, 30, 0.92) 100%);
--chat-composer-shadow: 0 18px 36px -28px rgba(2, 6, 23, 0.96);
--chat-composer-shadow-focus: 0 16px 34px -22px rgba(56, 189, 248, 0.45);
}
+27
View File
@@ -0,0 +1,27 @@
/**
* L1 semantic utilities — use these instead of bg-white dark:bg-slate-900 pairs.
*/
@layer utilities {
.bg-page { background-color: var(--bg-page); }
.bg-surface { background-color: var(--bg-surface); }
.bg-surface-soft { background-color: var(--bg-surface-soft); }
.bg-surface-strong { background-color: var(--bg-surface-strong); }
.text-primary { color: var(--text-primary); }
.text-secondary { color: var(--text-secondary); }
.text-muted { color: var(--text-muted); }
.border-default { border-color: var(--border-default); }
.border-subtle { border-color: var(--border-subtle); }
.shadow-elevated { box-shadow: var(--shadow-elevated); }
.bg-overlay { background-color: var(--overlay-soft); }
.hover-surface-soft:hover { background-color: var(--bg-surface-soft); }
.hover-surface-strong:hover { background-color: var(--bg-surface-strong); }
.divide-subtle > :not([hidden]) ~ :not([hidden]) {
border-color: var(--border-subtle);
}
}
+53
View File
@@ -0,0 +1,53 @@
const agentWindowName = (agentId: number): string => `hxops_agent_${agentId}`;
const isBlankWindow = (win: Window): boolean => {
try {
const href = win.location.href;
return href === 'about:blank' || href.endsWith('about:blank');
} catch {
return true;
}
};
/** Mark this browser tab as the chat window for an agent (used by window.open target name). */
export const registerOpenAgentId = (agentId: number | null): void => {
if (agentId && Number.isFinite(agentId) && agentId > 0) {
window.name = agentWindowName(agentId);
return;
}
if (window.name.startsWith('hxops_agent_')) {
window.name = '';
}
};
/** App startup hook (kept for compatibility). */
export const initAgentTabSync = (): void => {
// Named-window focus does not require background listeners.
};
/**
* Focus an existing same-agent tab without reload, or open a new one.
*
* Per HTML: window.open('', target) focuses an existing named window and
* ignores the URL, so the page is not refreshed.
*/
export const openAgentChatTab = (url: string, agentId: number): void => {
const target = agentWindowName(agentId);
const existing = window.open('', target);
if (!existing || existing.closed) {
const opened = window.open(url, target);
opened?.focus();
return;
}
existing.focus();
if (isBlankWindow(existing)) {
try {
existing.location.href = url;
} catch {
window.open(url, target);
}
}
};
+74 -1
View File
@@ -58,13 +58,86 @@ export const saveAuthUser = (user: AuthUser, remember = false): void => {
}
};
export const clearAuthUser = (): void => {
const AUTH_LOGOUT_KEY = 'hxops_auth_logout';
const AUTH_BC_NAME = 'hxops_auth';
let _authBroadcast: BroadcastChannel | null = null;
let _authSyncInitialized = false;
const clearAuthStorage = (): void => {
localStorage.removeItem('hxops_user');
sessionStorage.removeItem('hxops_user');
sessionStorage.removeItem('hxops_wecom_state');
sessionStorage.removeItem('hxops_casdoor_state');
};
const broadcastLogout = (): void => {
try {
localStorage.setItem(AUTH_LOGOUT_KEY, String(Date.now()));
localStorage.removeItem(AUTH_LOGOUT_KEY);
} catch {
// ignore quota / private mode errors
}
try {
if (!_authBroadcast) {
_authBroadcast = new BroadcastChannel(AUTH_BC_NAME);
}
_authBroadcast.postMessage({ type: 'logout', ts: Date.now() });
} catch {
// BroadcastChannel may be unavailable
}
};
const dispatchLogout = (detail: Record<string, unknown> = {}): void => {
window.dispatchEvent(new CustomEvent('hxops:logout', { detail }));
};
const handleRemoteLogout = (): void => {
if (!getStoredAuthUser()) return;
clearAuthStorage();
dispatchLogout({ remote: true });
};
/** Clear credentials and notify other tabs in the same browser. */
export const logoutAuth = (): void => {
clearAuthStorage();
broadcastLogout();
dispatchLogout({ source: 'local' });
};
export const clearAuthUser = (): void => {
logoutAuth();
};
/** Listen for logout in other tabs (storage + BroadcastChannel). */
export const initAuthSync = (): void => {
if (_authSyncInitialized) return;
_authSyncInitialized = true;
window.addEventListener('storage', (event: StorageEvent) => {
if (event.key === 'hxops_user' && event.newValue === null && event.oldValue != null) {
handleRemoteLogout();
return;
}
if (event.key === AUTH_LOGOUT_KEY && event.newValue != null) {
handleRemoteLogout();
}
});
try {
if (!_authBroadcast) {
_authBroadcast = new BroadcastChannel(AUTH_BC_NAME);
}
_authBroadcast.onmessage = (event: MessageEvent) => {
if (event.data?.type === 'logout') {
handleRemoteLogout();
}
};
} catch {
// ignore
}
};
let _refreshing: Promise<string | null> | null = null;
export const refreshAccessToken = async (): Promise<string | null> => {
+20
View File
@@ -0,0 +1,20 @@
const STORAGE_KEY = 'hxops_last_chat_agent_id';
export function getLastChatAgentId(fallback = 16): number {
try {
const raw = sessionStorage.getItem(STORAGE_KEY);
const id = Number(raw);
return Number.isFinite(id) && id > 0 ? id : fallback;
} catch {
return fallback;
}
}
export function setLastChatAgentId(agentId: number): void {
if (!Number.isFinite(agentId) || agentId <= 0) return;
try {
sessionStorage.setItem(STORAGE_KEY, String(agentId));
} catch {
// ignore storage failures
}
}
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
+44 -45
View File
@@ -2,6 +2,7 @@
import { ref } from 'vue';
import { useRoute, useRouter } from 'vue-router';
import { Lock, AlertCircle, CheckCircle } from 'lucide-vue-next';
import MinimalShell from '../layouts/MinimalShell.vue';
const route = useRoute();
const router = useRouter();
@@ -19,17 +20,17 @@ const handleReset = async () => {
status.value = 'error';
return;
}
if (password.value !== confirmPassword.value) {
message.value = 'Passwords do not match';
status.value = 'error';
return;
}
isLoading.value = true;
status.value = 'idle';
message.value = '';
try {
const res = await fetch('/api/user/reset-password-confirm', {
method: 'POST',
@@ -39,7 +40,7 @@ const handleReset = async () => {
new_password: password.value
})
});
const data = await res.json();
if (res.ok) {
status.value = 'success';
@@ -51,7 +52,7 @@ const handleReset = async () => {
status.value = 'error';
message.value = data.error || 'Failed to reset password';
}
} catch (e) {
} catch {
status.value = 'error';
message.value = 'Network error occurred';
} finally {
@@ -61,46 +62,44 @@ const handleReset = async () => {
</script>
<template>
<div class="min-h-screen bg-slate-50 dark:bg-slate-950 flex items-center justify-center p-4">
<div class="max-w-md w-full bg-white dark:bg-slate-900 rounded-3xl shadow-xl p-8 md:p-10 border border-slate-100 dark:border-slate-700">
<div class="text-center mb-8">
<div class="w-12 h-12 bg-brand-100 rounded-xl mx-auto flex items-center justify-center text-brand-600 mb-4">
<Lock class="w-6 h-6" />
</div>
<h2 class="text-2xl font-bold text-slate-900 dark:text-slate-100">Reset Password</h2>
<p class="text-slate-500 dark:text-slate-400 text-sm mt-2">Enter your new password below</p>
</div>
<div v-if="status === 'success'" class="bg-green-50 text-green-700 p-4 rounded-xl flex items-start gap-3 mb-6">
<CheckCircle class="w-5 h-5 shrink-0 mt-0.5" />
<div>{{ message }}</div>
</div>
<div v-if="status === 'error'" class="bg-red-50 text-red-700 p-4 rounded-xl flex items-start gap-3 mb-6">
<AlertCircle class="w-5 h-5 shrink-0 mt-0.5" />
<div>{{ message }}</div>
</div>
<form v-if="status !== 'success'" @submit.prevent="handleReset" class="space-y-5">
<div>
<label class="text-xs font-semibold text-slate-700 uppercase ml-1">New Password</label>
<input v-model="password" type="password" class="input-field" placeholder="Enter new password" required />
</div>
<div>
<label class="text-xs font-semibold text-slate-700 uppercase ml-1">Confirm Password</label>
<input v-model="confirmPassword" type="password" class="input-field" placeholder="Confirm new password" required />
</div>
<button type="submit" :disabled="isLoading" class="btn-primary w-full py-3 flex justify-center items-center gap-2">
<div v-if="isLoading" class="animate-spin rounded-full h-4 w-4 border-2 border-white/30 border-t-white"></div>
<span>{{ isLoading ? 'Resetting...' : 'Reset Password' }}</span>
</button>
</form>
<div class="mt-6 text-center">
<router-link to="/" class="text-sm font-medium text-slate-500 dark:text-slate-400 hover:text-slate-700 dark:hover:text-slate-200">Back to Login</router-link>
<MinimalShell>
<div class="text-center mb-8">
<div class="w-12 h-12 bg-brand-100 rounded-xl mx-auto flex items-center justify-center text-brand-600 mb-4">
<Lock class="w-6 h-6" />
</div>
<h2 class="page-title">Reset Password</h2>
<p class="section-desc mt-2">Enter your new password below</p>
</div>
</div>
<div v-if="status === 'success'" class="alert-ds alert-success mb-6">
<CheckCircle class="w-5 h-5 shrink-0" />
<div>{{ message }}</div>
</div>
<div v-if="status === 'error'" class="alert-ds alert-error mb-6">
<AlertCircle class="w-5 h-5 shrink-0" />
<div>{{ message }}</div>
</div>
<form v-if="status !== 'success'" @submit.prevent="handleReset" class="space-y-5">
<div>
<label class="label-field mb-1.5 block">New Password</label>
<input v-model="password" type="password" class="input-field" placeholder="Enter new password" required />
</div>
<div>
<label class="label-field mb-1.5 block">Confirm Password</label>
<input v-model="confirmPassword" type="password" class="input-field" placeholder="Confirm new password" required />
</div>
<button type="submit" :disabled="isLoading" class="btn-primary w-full py-3 flex justify-center items-center gap-2">
<div v-if="isLoading" class="animate-spin rounded-full h-4 w-4 border-2 border-white/30 border-t-white"></div>
<span>{{ isLoading ? 'Resetting...' : 'Reset Password' }}</span>
</button>
</form>
<div class="mt-6 text-center">
<router-link to="/" class="text-sm font-medium text-muted hover:text-secondary">Back to Login</router-link>
</div>
</MinimalShell>
</template>
File diff suppressed because it is too large. Load diff
+1 -1
View File
@@ -12,7 +12,7 @@ export default {
theme: {
extend: {
fontFamily: {
sans: ['Inter', ...defaultTheme.fontFamily.sans],
sans: ['"PingFang SC"', '"Microsoft YaHei"', '"Segoe UI"', 'system-ui', ...defaultTheme.fontFamily.sans],
},
colors: {
brand: {
-781
View File
@@ -1,781 +0,0 @@
#!/usr/bin/env bash
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
if git -C "${SCRIPT_DIR}" rev-parse --show-toplevel >/dev/null 2>&1; then
ROOT_DIR="$(git -C "${SCRIPT_DIR}" rev-parse --show-toplevel)"
elif git -C "${SCRIPT_DIR}/.." rev-parse --show-toplevel >/dev/null 2>&1; then
ROOT_DIR="$(git -C "${SCRIPT_DIR}/.." rev-parse --show-toplevel)"
else
ROOT_DIR="${SCRIPT_DIR}"
fi
RUN_DIR="${ROOT_DIR}/.run"
BACKEND_DIR="${ROOT_DIR}/backend"
FRONTEND_DIR="${ROOT_DIR}/frontend"
BACKEND_PORT=5052
FRONTEND_PORT=8881
DB_PORT=5432
DB_DATA_DIR="/opt/homebrew/var/postgresql@18"
DB_BIN="/opt/homebrew/opt/postgresql@18/bin/postgres"
mkdir -p "${RUN_DIR}"
is_listening() {
local port="$1"
lsof -nP -iTCP:"${port}" -sTCP:LISTEN >/dev/null 2>&1
}
get_lan_ip() {
local ip=""
for iface in en0 en1; do
ip="$(ipconfig getifaddr "${iface}" 2>/dev/null || true)"
if [[ -n "${ip}" ]]; then
echo "${ip}"
return 0
fi
done
ip="$(ifconfig 2>/dev/null | awk '/inet / && $2 != "127.0.0.1" {print $2; exit}')"
if [[ -n "${ip}" ]]; then
echo "${ip}"
fi
}
print_access_links() {
local lan_ip
lan_ip="$(get_lan_ip || true)"
echo "== 访问链接 =="
echo "前端(本机): http://127.0.0.1:${FRONTEND_PORT}"
echo "后端(本机): http://127.0.0.1:${BACKEND_PORT}"
if [[ -n "${lan_ip}" ]]; then
echo "前端(局域网): http://${lan_ip}:${FRONTEND_PORT}"
echo "后端(局域网): http://${lan_ip}:${BACKEND_PORT}"
fi
}
start_project() {
echo "=== 启动 HXOPS 项目 ==="
if is_listening "${DB_PORT}"; then
echo "[数据库] 端口 ${DB_PORT} 已在监听,跳过启动。"
else
echo "[数据库] 正在启动..."
nohup env LC_ALL="en_US.UTF-8" "${DB_BIN}" -D "${DB_DATA_DIR}" > "${RUN_DIR}/postgres.log" 2>&1 &
echo $! > "${RUN_DIR}/postgres.pid"
sleep 2
if is_listening "${DB_PORT}"; then
echo "[数据库] 启动成功,端口 ${DB_PORT}。"
else
echo "[数据库] 启动失败,请查看日志: ${RUN_DIR}/postgres.log"
return 1
fi
fi
if is_listening "${BACKEND_PORT}"; then
echo "[后端] 端口 ${BACKEND_PORT} 已在监听,跳过启动。"
else
echo "[后端] 正在启动..."
(
cd "${BACKEND_DIR}"
source venv/bin/activate
nohup python3 run.py > "${RUN_DIR}/backend.log" 2>&1 &
echo $! > "${RUN_DIR}/backend.pid"
)
sleep 2
if is_listening "${BACKEND_PORT}"; then
echo "[后端] 启动成功,端口 ${BACKEND_PORT}。"
else
echo "[后端] 启动失败,请查看日志: ${RUN_DIR}/backend.log"
return 1
fi
fi
if is_listening "${FRONTEND_PORT}"; then
echo "[前端] 端口 ${FRONTEND_PORT} 已在监听,跳过启动。"
else
echo "[前端] 正在启动..."
(
cd "${FRONTEND_DIR}"
nohup npm run dev > "${RUN_DIR}/frontend.log" 2>&1 &
echo $! > "${RUN_DIR}/frontend.pid"
)
sleep 3
if is_listening "${FRONTEND_PORT}"; then
echo "[前端] 启动成功,端口 ${FRONTEND_PORT}。"
else
echo "[前端] 启动失败,请查看日志: ${RUN_DIR}/frontend.log"
return 1
fi
fi
print_access_links
echo "日志目录: ${RUN_DIR}"
}
kill_by_pid_file() {
local name="$1"
local pid_file="$2"
if [[ ! -f "${pid_file}" ]]; then
echo "[${name}] 未找到 PID 文件,跳过。"
return
fi
local pid
pid="$(cat "${pid_file}")"
if [[ -z "${pid}" ]] || ! kill -0 "${pid}" >/dev/null 2>&1; then
echo "[${name}] PID ${pid:-<empty>} 不存在,清理 PID 文件。"
rm -f "${pid_file}"
return
fi
echo "[${name}] 正在停止进程 PID=${pid}..."
kill "${pid}" >/dev/null 2>&1 || true
for _ in {1..10}; do
if ! kill -0 "${pid}" >/dev/null 2>&1; then
break
fi
sleep 0.5
done
if kill -0 "${pid}" >/dev/null 2>&1; then
echo "[${name}] 进程未退出,执行强制停止 PID=${pid}。"
kill -9 "${pid}" >/dev/null 2>&1 || true
fi
rm -f "${pid_file}"
echo "[${name}] 已停止。"
}
kill_by_port_if_needed() {
local name="$1"
local port="$2"
local pids
pids="$(lsof -ti tcp:${port} 2>/dev/null || true)"
if [[ -z "${pids}" ]]; then
return
fi
echo "[${name}] 检测到端口 ${port} 仍有进程: ${pids},尝试终止..."
for pid in ${pids}; do
kill "${pid}" >/dev/null 2>&1 || true
done
sleep 1
pids="$(lsof -ti tcp:${port} 2>/dev/null || true)"
if [[ -n "${pids}" ]]; then
for pid in ${pids}; do
kill -9 "${pid}" >/dev/null 2>&1 || true
done
fi
}
stop_project() {
echo "=== 关闭 HXOPS 项目 ==="
kill_by_pid_file "后端" "${RUN_DIR}/backend.pid"
kill_by_pid_file "前端" "${RUN_DIR}/frontend.pid"
kill_by_port_if_needed "后端" "${BACKEND_PORT}"
kill_by_port_if_needed "前端" "${FRONTEND_PORT}"
kill_by_pid_file "数据库" "${RUN_DIR}/postgres.pid"
kill_by_port_if_needed "数据库" "${DB_PORT}"
echo "关闭完成。"
}
push_gitee() {
echo "=== 上传代码到 Gitee ==="
if ! git -C "${ROOT_DIR}" rev-parse --is-inside-work-tree >/dev/null 2>&1; then
echo "当前目录不是 Git 仓库,已退出。"
return 1
fi
local remote_url
remote_url="$(git -C "${ROOT_DIR}" remote get-url origin 2>/dev/null || true)"
if [[ -z "${remote_url}" ]]; then
echo "未找到 origin 远程仓库,请先配置后再上传。"
return 1
fi
if [[ "${remote_url}" != *"gitee.com"* ]]; then
echo "警告: 当前 origin 不是 Gitee: ${remote_url}"
read -r -p "仍要继续 push 到 origin 吗? (y/N): " force_push
if [[ ! "${force_push}" =~ ^[Yy]$ ]]; then
echo "已取消。"
return 0
fi
fi
local branch
branch="$(git -C "${ROOT_DIR}" rev-parse --abbrev-ref HEAD)"
local migration_check_script="${BACKEND_DIR}/scripts/ci_check_migrations.sh"
if [[ -x "${migration_check_script}" ]]; then
echo "== 提交前检查: 数据库结构一致性 =="
(
cd "${BACKEND_DIR}"
"${migration_check_script}"
) || {
echo "检查未通过,已阻止 commit/push。"
echo "请先修复 models/migrations/database 不一致问题后重试。"
return 1
}
else
echo "警告: 未找到可执行检查脚本 ${migration_check_script},跳过结构检查。"
fi
if [[ -n "$(git -C "${ROOT_DIR}" status --porcelain)" ]]; then
git -C "${ROOT_DIR}" add -A
read -r -p "请输入提交说明(留空使用默认): " commit_msg
if [[ -z "${commit_msg:-}" ]]; then
commit_msg="chore: update $(date '+%Y-%m-%d %H:%M:%S')"
fi
if [[ -n "$(git -C "${ROOT_DIR}" diff --cached --name-only)" ]]; then
git -C "${ROOT_DIR}" commit -m "${commit_msg}"
fi
else
echo "工作区无变更,将直接 push 当前分支。"
fi
echo "推送分支: ${branch} -> origin/${branch}"
git -C "${ROOT_DIR}" push origin "${branch}"
echo "上传完成。"
}
show_status() {
echo "== 项目服务状态 =="
if command -v docker >/dev/null 2>&1 && docker compose version >/dev/null 2>&1; then
local compose_table
compose_table="$(docker compose -p hxops ps --format 'table {{.Name}}\t{{.Image}}\t{{.Command}}\t{{.Service}}\t{{.CreatedAt}}\t{{.State}}\t{{.Publishers}}' 2>/dev/null || true)"
if [[ -n "${compose_table}" ]]; then
echo "${compose_table}"
else
printf "%-16s %-22s %-24s %-16s %-12s %-12s %-s\n" \
"NAME" "IMAGE" "COMMAND" "SERVICE" "CREATED" "STATUS" "PORTS"
printf "%-16s %-22s %-24s %-16s %-12s %-12s %-s\n" \
"hxops-backend" "hxops-hxops-backend" "\"python3 run.py\"" "hxops-backend" "-" \
"$(is_listening "${BACKEND_PORT}" && echo "Up" || echo "Down")" \
"0.0.0.0:${BACKEND_PORT}->${BACKEND_PORT}/tcp, [::]:${BACKEND_PORT}->${BACKEND_PORT}/tcp"
printf "%-16s %-22s %-24s %-16s %-12s %-12s %-s\n" \
"hxops-frontend" "hxops-hxops-frontend" "\"npm run dev\"" "hxops-frontend" "-" \
"$(is_listening "${FRONTEND_PORT}" && echo "Up" || echo "Down")" \
"0.0.0.0:${FRONTEND_PORT}->${FRONTEND_PORT}/tcp, [::]:${FRONTEND_PORT}->${FRONTEND_PORT}/tcp"
fi
else
printf "%-16s %-22s %-24s %-16s %-12s %-12s %-s\n" \
"NAME" "IMAGE" "COMMAND" "SERVICE" "CREATED" "STATUS" "PORTS"
printf "%-16s %-22s %-24s %-16s %-12s %-12s %-s\n" \
"hxops-backend" "hxops-hxops-backend" "\"python3 run.py\"" "hxops-backend" "-" \
"$(is_listening "${BACKEND_PORT}" && echo "Up" || echo "Down")" \
"0.0.0.0:${BACKEND_PORT}->${BACKEND_PORT}/tcp, [::]:${BACKEND_PORT}->${BACKEND_PORT}/tcp"
printf "%-16s %-22s %-24s %-16s %-12s %-12s %-s\n" \
"hxops-frontend" "hxops-hxops-frontend" "\"npm run dev\"" "hxops-frontend" "-" \
"$(is_listening "${FRONTEND_PORT}" && echo "Up" || echo "Down")" \
"0.0.0.0:${FRONTEND_PORT}->${FRONTEND_PORT}/tcp, [::]:${FRONTEND_PORT}->${FRONTEND_PORT}/tcp"
fi
echo "=== 当前状态 ==="
if is_listening "${DB_PORT}"; then
echo "数据库: 运行中 (端口 ${DB_PORT})"
else
echo "数据库: 未运行"
fi
if is_listening "${BACKEND_PORT}"; then
echo "后端: 运行中 (端口 ${BACKEND_PORT})"
else
echo "后端: 未运行"
fi
if is_listening "${FRONTEND_PORT}"; then
echo "前端: 运行中 (端口 ${FRONTEND_PORT})"
else
echo "前端: 未运行"
fi
print_access_links
}
show_dev_open_ports() {
echo "=== 开发服务端口扫描(排除 macOS 常规系统服务) ==="
echo "说明: 仅显示当前用户 ${USER} 打开的 TCP 监听端口。"
echo ""
printf "%-20s %-8s %-24s\n" "进程名" "PID" "监听地址"
printf "%-20s %-8s %-24s\n" "--------------------" "--------" "------------------------"
local output
output="$(
lsof -nP -iTCP -sTCP:LISTEN 2>/dev/null \
| awk -v user="${USER}" '
function ignored(cmd) {
return (cmd ~ /^(ControlCe|rapportd|cfprefsd|trustd|sharingd|identitys)$/)
}
NR > 1 && $3 == user {
if (ignored($1)) next
endpoint = $(NF-1)
key = $1 "|" $2 "|" endpoint
if (!seen[key]++) {
printf "%-20s %-8s %-24s\n", $1, $2, endpoint
}
}
'
)"
if [[ -z "${output}" ]]; then
echo "未发现当前用户启动的监听端口。"
return
fi
echo "${output}"
}
show_non_system_open_ports() {
echo "=== 非系统端口扫描(全量监听端口 - macOS 系统服务) ==="
echo "说明: 扫描所有 TCP 监听端口,过滤系统进程后按服务分组展示。"
local rows
rows="$(
lsof -nP -iTCP -sTCP:LISTEN 2>/dev/null \
| awk '
NR > 1 {
cmd = $1
pid = $2
user = $3
endpoint = $(NF-1)
key = pid "|" endpoint
if (!seen[key]++) {
print pid "\t" user "\t" cmd "\t" endpoint
}
}
'
)"
if [[ -z "${rows}" ]]; then
echo "未发现监听端口。"
return
fi
local tmp_dir
tmp_dir="$(mktemp -d)"
trap 'rm -rf "${tmp_dir}"' RETURN
local f_openclaw="${tmp_dir}/openclaw.txt"
local f_hxops="${tmp_dir}/hxops.txt"
local f_central="${tmp_dir}/central.txt"
local f_erp="${tmp_dir}/erp.txt"
local f_pg="${tmp_dir}/pg.txt"
local f_other="${tmp_dir}/other.txt"
touch "${f_openclaw}" "${f_hxops}" "${f_central}" "${f_erp}" "${f_pg}" "${f_other}"
local matched=0
while IFS=$'\t' read -r pid user cmd endpoint; do
[[ -z "${pid}" ]] && continue
local full_cmd bin_path
full_cmd="$(ps -p "${pid}" -o command= 2>/dev/null || true)"
bin_path="${full_cmd%% *}"
# 过滤典型系统账号与系统二进制路径
if [[ "${user}" == _* ]]; then
continue
fi
if [[ "${bin_path}" == /System/* || "${bin_path}" == /usr/libexec/* ]]; then
continue
fi
# 过滤常见 macOS 系统守护进程
case "${cmd}" in
launchd|syslogd|mDNSResponder|distnoted|notifyd|powerd|configd|kernelmanagerd|airportd|\
cfprefsd|sharingd|trustd|identityservicesd|ControlCe|rapportd|runningboardd|\
UserEventAgent|logd|securityd|opendirectoryd)
continue
;;
esac
local port group target_file
port="${endpoint##*:}"
if [[ "${port}" == "18789" || "${cmd}" == "DingTalk" ]]; then
group="openclaw"
target_file="${f_openclaw}"
elif [[ "${port}" == "8881" ]]; then
group="hxops"
target_file="${f_hxops}"
elif [[ "${port}" == "8891" ]]; then
group="Central-Auth-Core"
target_file="${f_central}"
elif [[ "${port}" == "8892" ]]; then
group="ERP-Data-Agent"
target_file="${f_erp}"
elif [[ "${port}" == "5432" ]]; then
group="postgresql"
target_file="${f_pg}"
else
group="其它服务"
target_file="${f_other}"
fi
printf "%-20s %-10s %-8s %-24s %-18s\n" "${cmd}" "${user}" "${pid}" "${endpoint}" "${port}" >> "${target_file}"
matched=1
done <<< "${rows}"
if [[ "${matched}" -eq 0 ]]; then
echo "未发现非系统监听端口。"
return
fi
print_group() {
local title="$1"
local file="$2"
[[ ! -s "${file}" ]] && return
echo ""
echo "[$title]"
printf "%-20s %-10s %-8s %-24s %-18s\n" "进程名" "用户" "PID" "监听地址" "端口"
printf "%-20s %-10s %-8s %-24s %-18s\n" "--------------------" "----------" "--------" "------------------------" "------------------"
cat "${file}"
}
print_group "openclaw" "${f_openclaw}"
print_group "hxops" "${f_hxops}"
print_group "Central-Auth-Core" "${f_central}"
print_group "ERP-Data-Agent" "${f_erp}"
print_group "postgresql" "${f_pg}"
print_group "其它服务" "${f_other}"
}
show_local_changes_detail() {
echo "=== 本地改动详情(相对上游分支 @{u}) ==="
if ! git -C "${ROOT_DIR}" rev-parse --is-inside-work-tree >/dev/null 2>&1; then
echo "当前目录不是 Git 仓库。"
return 1
fi
local branch upstream
branch="$(git -C "${ROOT_DIR}" rev-parse --abbrev-ref HEAD)"
upstream="$(git -C "${ROOT_DIR}" rev-parse --abbrev-ref --symbolic-full-name '@{u}' 2>/dev/null || true)"
if [[ -z "${upstream}" ]]; then
echo "当前分支 ${branch} 未设置上游分支,无法执行: git diff --stat @{u}.."
echo "可先执行: git branch --set-upstream-to origin/${branch} ${branch}"
return 1
fi
echo "当前分支: ${branch}"
echo "上游分支: ${upstream}"
echo ""
echo "== 统计(git diff --stat @{u}..) =="
git -C "${ROOT_DIR}" -c color.ui=always diff --stat --color=always '@{u}..' || true
local tracked_files
tracked_files="$(git -C "${ROOT_DIR}" diff --name-only '@{u}..' || true)"
if [[ -z "${tracked_files}" ]]; then
echo ""
echo "当前相对 ${upstream} 没有改动。"
return 0
fi
echo ""
echo "== 文件改动内容(彩色) =="
while IFS= read -r f; do
[[ -z "${f}" ]] && continue
echo ""
echo "---- ${f} ----"
git -C "${ROOT_DIR}" -c color.ui=always diff --color=always '@{u}..' -- "${f}" || true
done <<< "${tracked_files}"
}
show_remote_branch_changes_detail() {
echo "=== 远端分支改动详情(仅远端新增) ==="
if ! git -C "${ROOT_DIR}" rev-parse --is-inside-work-tree >/dev/null 2>&1; then
echo "当前目录不是 Git 仓库。"
return 1
fi
local current_branch target_branch remote_ref
current_branch="$(git -C "${ROOT_DIR}" rev-parse --abbrev-ref HEAD)"
read -r -p "请输入远端分支名(默认 ${current_branch}): " target_branch
target_branch="${target_branch:-${current_branch}}"
remote_ref="origin/${target_branch}"
if ! git -C "${ROOT_DIR}" fetch origin "${target_branch}" --prune >/dev/null 2>&1; then
echo "警告: 拉取 origin/${target_branch} 失败,尝试使用本地已缓存的远端引用继续。"
fi
if ! git -C "${ROOT_DIR}" show-ref --verify --quiet "refs/remotes/${remote_ref}"; then
echo "未找到本地远端引用 ${remote_ref}。"
echo "请先确认分支存在,或手动执行: git fetch origin ${target_branch}"
return 1
fi
local remote_numstat remote_files
remote_numstat="$(git -C "${ROOT_DIR}" diff --numstat HEAD..${remote_ref} || true)"
remote_files="$(git -C "${ROOT_DIR}" diff --name-only HEAD..${remote_ref} || true)"
if [[ -z "${remote_files}" ]]; then
echo "远端分支相对本地 HEAD 没有新增改动。"
return 0
fi
echo "== 远端相对本地的文件与行数统计 =="
printf "%-10s %-10s %s\n" "ADDED" "DELETED" "FILE"
printf "%-10s %-10s %s\n" "----------" "----------" "------------------------------"
echo "${remote_numstat}" | awk '{printf "%-10s %-10s %s\n", $1, $2, $3}'
echo ""
echo "== 远端新增提交(HEAD..${remote_ref}) =="
git -C "${ROOT_DIR}" log --oneline --decorate HEAD..${remote_ref} | sed -n '1,200p'
echo ""
echo "== 远端每个文件改动内容(HEAD..${remote_ref}) =="
while IFS= read -r f; do
[[ -z "${f}" ]] && continue
echo ""
echo "---- ${f} ----"
git -C "${ROOT_DIR}" diff --no-color HEAD..${remote_ref} -- "${f}" || true
done <<< "${remote_files}"
}
show_local_remote_compare() {
echo "=== 本地与远端差异对比(直观) ==="
if ! git -C "${ROOT_DIR}" rev-parse --is-inside-work-tree >/dev/null 2>&1; then
echo "当前目录不是 Git 仓库。"
return 1
fi
local current_branch target_branch remote_ref
current_branch="$(git -C "${ROOT_DIR}" rev-parse --abbrev-ref HEAD)"
read -r -p "请输入远端分支名(默认 ${current_branch}): " target_branch
target_branch="${target_branch:-${current_branch}}"
remote_ref="origin/${target_branch}"
if ! git -C "${ROOT_DIR}" fetch origin "${target_branch}" --prune >/dev/null 2>&1; then
echo "警告: 拉取 origin/${target_branch} 失败,尝试使用本地已缓存的远端引用继续。"
fi
if ! git -C "${ROOT_DIR}" show-ref --verify --quiet "refs/remotes/${remote_ref}"; then
echo "未找到本地远端引用 ${remote_ref}。"
echo "请先确认分支存在,或手动执行: git fetch origin ${target_branch}"
return 1
fi
local ahead behind
read -r ahead behind < <(git -C "${ROOT_DIR}" rev-list --left-right --count HEAD...${remote_ref})
echo "对比分支: HEAD vs ${remote_ref}"
echo "本地领先: ${ahead} 个提交"
echo "远端领先: ${behind} 个提交"
echo ""
echo "== 本地独有提交(${remote_ref}..HEAD) =="
git -C "${ROOT_DIR}" log --oneline --decorate "${remote_ref}..HEAD" | sed -n '1,120p'
echo ""
echo "== 远端独有提交(HEAD..${remote_ref}) =="
git -C "${ROOT_DIR}" log --oneline --decorate "HEAD..${remote_ref}" | sed -n '1,120p'
echo ""
echo "== 双向文件统计(git diff --stat HEAD...${remote_ref}) =="
git -C "${ROOT_DIR}" diff --stat HEAD..."${remote_ref}" || true
echo ""
echo "== 本地相对远端的改动(${remote_ref}..HEAD) =="
git -C "${ROOT_DIR}" diff --stat "${remote_ref}..HEAD" || true
echo ""
echo "== 远端相对本地的改动(HEAD..${remote_ref}) =="
git -C "${ROOT_DIR}" diff --stat "HEAD..${remote_ref}" || true
}
show_all_branches_info() {
echo "=== 分支总览(本地 + 远端) ==="
if ! git -C "${ROOT_DIR}" rev-parse --is-inside-work-tree >/dev/null 2>&1; then
echo "当前目录不是 Git 仓库。"
return 1
fi
local current_branch local_default remote_default
current_branch="$(git -C "${ROOT_DIR}" rev-parse --abbrev-ref HEAD 2>/dev/null || echo '-')"
local_default="$(git -C "${ROOT_DIR}" symbolic-ref --short refs/heads/main 2>/dev/null || true)"
if [[ -z "${local_default}" ]]; then
local_default="$(git -C "${ROOT_DIR}" symbolic-ref --short refs/heads/master 2>/dev/null || true)"
fi
remote_default="$(git -C "${ROOT_DIR}" symbolic-ref --quiet --short refs/remotes/origin/HEAD 2>/dev/null || true)"
if ! git -C "${ROOT_DIR}" fetch origin --prune >/dev/null 2>&1; then
echo "警告: fetch origin 失败,将基于当前本地缓存的远端分支信息展示。"
fi
echo "== 本地分支 =="
echo "当前分支: ${current_branch}"
if [[ -n "${local_default}" ]]; then
echo "本地默认分支(按 main/master 识别): ${local_default}"
else
echo "本地默认分支: 未识别(可按团队约定确认)"
fi
git -C "${ROOT_DIR}" branch -vv
echo ""
echo "== 远端分支(origin) =="
if [[ -n "${remote_default}" ]]; then
echo "远端默认分支: ${remote_default}"
else
echo "远端默认分支: 未识别(可执行 git remote set-head origin -a 后重试)"
fi
git -C "${ROOT_DIR}" branch -r
}
run_schema_drift_check() {
echo "=== 检查数据库结构与 SQLAlchemy 模型是否一致 ==="
local python_bin="${BACKEND_DIR}/venv/bin/python3"
local check_script="${BACKEND_DIR}/scripts/check_schema_drift.py"
if [[ ! -x "${python_bin}" ]]; then
echo "未找到 Python: ${python_bin}"
return 1
fi
if [[ ! -f "${check_script}" ]]; then
echo "未找到检查脚本: ${check_script}"
return 1
fi
(
cd "${BACKEND_DIR}"
"${python_bin}" "scripts/check_schema_drift.py"
)
}
run_ci_migration_check() {
echo "=== 运行 CI 同款 migration 漂移检查 ==="
local check_script="${BACKEND_DIR}/scripts/ci_check_migrations.sh"
if [[ ! -x "${check_script}" ]]; then
echo "未找到可执行脚本: ${check_script}"
echo "可先执行: chmod +x ${check_script}"
return 1
fi
(
cd "${BACKEND_DIR}"
"${check_script}"
)
}
install_precommit_hook() {
echo "=== 安装 Git Hooks(pre-commit + pre-push)==="
local install_script="${ROOT_DIR}/scripts/install_git_hooks.sh"
if [[ ! -x "${install_script}" ]]; then
echo "未找到可执行脚本: ${install_script}"
echo "可先执行: chmod +x ${install_script}"
return 1
fi
(
cd "${ROOT_DIR}"
"${install_script}"
)
}
show_help() {
cat <<'HELP'
可输入的指令与结果:
start 或 1 -> 启动项目(数据库+后端+前端)
stop 或 2 -> 关闭项目(后端+前端+数据库)
push 或 3 -> 提交并上传到 Gitee(origin)
status或 4 -> 查看服务运行状态
ports 或 5 -> 扫描当前用户开启的开发服务端口
allports或 6 -> 扫描所有非系统监听端口(应用/自装服务)
localchg或 31 -> 查看本地改了哪些文件/多少行/逐文件改动
remotechg或 32 -> 只查看远端分支改了哪些文件/多少行/逐文件改动
compare 或 33 -> 直观对比本地与远端差异(领先提交、双向改动)
branches或 34 -> 查看本地所有分支及默认分支、远端所有分支及默认分支
dbdrift或 41 -> 检查当前数据库结构与 SQLAlchemy 模型是否一致
migci 或 42 -> 运行 CI 同款迁移一致性检查(空库升级+漂移检测)
hook 或 43 -> 安装 Git Hooks(models+migration / frontend vue-tsc / push 前 build)
help 或 9 -> 再次显示本帮助
help -> 再次显示本帮助
exit 或 0 -> 退出脚本
HELP
}
confirm_and_run() {
local label="$1"
local fn_name="$2"
read -r -p "确认执行【${label}】? (y/N): " confirm
if [[ "${confirm}" =~ ^[Yy]$ ]]; then
"${fn_name}"
else
echo "已取消【${label}】。"
fi
}
main_loop() {
echo "===== HXOPS 单脚本控制台 ====="
show_help
while true; do
echo ""
read -r -p "请输入指令: " cmd
case "${cmd}" in
1|start)
confirm_and_run "启动项目" start_project
;;
2|stop)
confirm_and_run "关闭项目" stop_project
;;
3|push)
confirm_and_run "上传到 Gitee" push_gitee
;;
4|status)
show_status
;;
5|ports|scan)
show_dev_open_ports
;;
6|allports)
show_non_system_open_ports
;;
31|localchg)
show_local_changes_detail
;;
32|remotechg)
show_remote_branch_changes_detail
;;
33|compare)
show_local_remote_compare
;;
34|branches)
show_all_branches_info
;;
41|dbdrift)
run_schema_drift_check
;;
42|migci)
confirm_and_run "CI同款迁移一致性检查" run_ci_migration_check
;;
43|hook)
confirm_and_run "安装 Git Hooks" install_precommit_hook
;;
9|help)
show_help
;;
0|exit|quit)
echo "已退出。"
exit 0
;;
"")
echo "请输入有效指令,输入 help 可查看可用命令。"
;;
*)
echo "未知指令: ${cmd},输入 help 可查看可用命令。"
;;
esac
done
}
main_loop
-267
View File
@@ -1,267 +0,0 @@
#!/usr/bin/env bash
set -euo pipefail
SCRIPT_DIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)"
cd "${SCRIPT_DIR}"
PROJECT_SERVICES=("hxops-backend" "hxops-frontend")
PUBLIC_SERVICES=("shared-postgres" "shared-redis")
resolve_compose_cmd() {
if command -v docker-compose >/dev/null 2>&1; then
COMPOSE_CMD="docker-compose"
elif docker compose version >/dev/null 2>&1; then
COMPOSE_CMD="docker compose"
else
echo "❌ 未找到 docker-compose 或 docker compose 命令"
exit 1
fi
}
container_exists() {
docker ps -a --format '{{.Names}}' | grep -Fxq "$1"
}
container_running() {
docker ps --format '{{.Names}}' | grep -Fxq "$1"
}
get_host_ip() {
local ip=""
ip="$( (ip route get 1.1.1.1 2>/dev/null || true) | awk '{for (i = 1; i <= NF; i++) if ($i == "src") {print $(i+1); exit}}' )"
if [[ -z "${ip}" ]]; then
ip="$( (hostname -I 2>/dev/null || true) | awk '{print $1}' )"
fi
if [[ -z "${ip}" ]]; then
ip="127.0.0.1"
fi
echo "${ip}"
}
get_mapped_port() {
local container="$1"
local cport="$2"
local raw
raw="$(docker port "${container}" "${cport}" 2>/dev/null || true)"
echo "${raw}" | head -n 1 | awk -F: '{print $NF}'
}
tcp_port_open() {
local host="$1"
local port="$2"
if command -v timeout >/dev/null 2>&1; then
timeout 1 bash -c ">/dev/tcp/${host}/${port}" >/dev/null 2>&1
else
bash -c ">/dev/tcp/${host}/${port}" >/dev/null 2>&1
fi
}
http_probe_code() {
local url="$1"
if ! command -v curl >/dev/null 2>&1; then
echo "curl-missing"
return 0
fi
local code
code="$(curl -sS -m 3 -o /dev/null -w '%{http_code}' "${url}" 2>/dev/null || true)"
if [[ -z "${code}" ]]; then
code="failed"
fi
echo "${code}"
}
start_public_services() {
echo "== 启动公共服务(数据库/Redis)=="
for name in "${PUBLIC_SERVICES[@]}"; do
if container_exists "${name}"; then
if container_running "${name}"; then
echo " ${name}: 已运行"
else
echo " ${name}: 启动中"
docker start "${name}" >/dev/null
echo " ${name}: 已启动"
fi
else
echo " ${name}: 未找到容器(跳过)"
fi
done
}
start_all_services() {
resolve_compose_cmd
start_public_services
echo "== 启动项目服务(前后端)=="
${COMPOSE_CMD} up -d
echo "✅ 项目服务已启动"
}
stop_project_services() {
resolve_compose_cmd
echo "== 停止项目前后端服务(不影响数据库/Redis)=="
${COMPOSE_CMD} stop "${PROJECT_SERVICES[@]}"
echo "✅ 项目前后端已停止"
}
run_deploy() {
if [[ -x "./deploy.sh" ]]; then
./deploy.sh
elif [[ -f "./deploy.sh" ]]; then
bash ./deploy.sh
else
echo "❌ 未找到 deploy.sh"
return 1
fi
}
show_public_service_status() {
echo "== 公共服务状态 =="
for name in "${PUBLIC_SERVICES[@]}"; do
if container_exists "${name}"; then
status="$(docker inspect -f '{{.State.Status}}' "${name}")"
health="$(docker inspect -f '{{if .State.Health}}{{.State.Health.Status}}{{else}}none{{end}}' "${name}")"
echo " ${name}: status=${status}, health=${health}"
else
echo " ${name}: not-found"
fi
done
}
check_dependency_service() {
local label="$1"
local name="$2"
local cport="$3"
if ! container_exists "${name}"; then
echo " ${label}(${name}): not-found"
return 0
fi
local status health mapped_port tcp_state
status="$(docker inspect -f '{{.State.Status}}' "${name}")"
health="$(docker inspect -f '{{if .State.Health}}{{.State.Health.Status}}{{else}}none{{end}}' "${name}")"
mapped_port="$(get_mapped_port "${name}" "${cport}")"
if [[ -n "${mapped_port}" ]]; then
if tcp_port_open "127.0.0.1" "${mapped_port}"; then
tcp_state="ok"
else
tcp_state="failed"
fi
echo " ${label}(${name}): status=${status}, health=${health}, host_port=${mapped_port}, tcp=${tcp_state}"
else
echo " ${label}(${name}): status=${status}, health=${health}, host_port=none(仅容器网络)"
fi
}
show_dependency_checks() {
echo "== 依赖服务检查 =="
check_dependency_service "数据库" "shared-postgres" "5432/tcp"
check_dependency_service "Redis" "shared-redis" "6379/tcp"
}
check_nginx_mapping() {
local label="$1"
local name="$2"
local cport="$3"
if ! container_exists "${name}"; then
echo " ${label}(${name}:${cport}): not-found"
return 0
fi
local mapped_port
mapped_port="$(get_mapped_port "${name}" "${cport}")"
if [[ -z "${mapped_port}" ]]; then
echo " ${label}(${name}:${cport}): no-host-mapping"
return 0
fi
if tcp_port_open "127.0.0.1" "${mapped_port}"; then
echo " ${label}(${name}:${cport}): host_port=${mapped_port}, tcp=ok"
else
echo " ${label}(${name}:${cport}): host_port=${mapped_port}, tcp=failed"
fi
}
show_nginx_port_checks() {
echo "== Nginx 对外端口检查 =="
check_nginx_mapping "网关入口" "nginx-gateway" "8881/tcp"
check_nginx_mapping "前端直连" "hxops-frontend" "80/tcp"
}
show_entry_urls() {
local host_ip gateway_port frontend_port backend_port
host_ip="$(get_host_ip)"
gateway_port="$(get_mapped_port "nginx-gateway" "8881/tcp")"
frontend_port="$(get_mapped_port "hxops-frontend" "80/tcp")"
backend_port="$(get_mapped_port "hxops-backend" "5052/tcp")"
echo "== 网站入口地址 =="
if [[ -n "${gateway_port}" ]]; then
local gateway_url
gateway_url="http://${host_ip}:${gateway_port}/"
echo " 主入口(网关): ${gateway_url} [HTTP $(http_probe_code "${gateway_url}")]"
else
echo " 主入口(网关): nginx-gateway:8881 未映射到宿主机"
fi
if [[ -n "${frontend_port}" ]]; then
local frontend_url
frontend_url="http://${host_ip}:${frontend_port}/"
echo " 前端直连: ${frontend_url} [HTTP $(http_probe_code "${frontend_url}")]"
else
echo " 前端直连: hxops-frontend:80 未映射到宿主机"
fi
if [[ -n "${backend_port}" ]]; then
local backend_url
backend_url="http://${host_ip}:${backend_port}/api/agents"
echo " 后端API示例: ${backend_url} [HTTP $(http_probe_code "${backend_url}")]"
else
echo " 后端API示例: hxops-backend:5052 未映射到宿主机"
fi
}
check_service_status() {
resolve_compose_cmd
echo "== 项目服务状态 =="
${COMPOSE_CMD} ps
show_public_service_status
show_dependency_checks
show_nginx_port_checks
show_entry_urls
}
show_help() {
cat <<'EOF'
可用命令:
1 启动项目所有服务(含公共服务:数据库/Redis)
2 停止项目前后端服务(不含数据库与Redis)
3 执行部署脚本 deploy.sh
4 检查项目/依赖服务状态、Nginx端口与网站入口
9 显示命令帮助
0 退出脚本
EOF
}
main_loop() {
show_help
while true; do
echo
read -r -p "请输入选项 [1/2/3/4/9/0]: " choice
case "${choice}" in
1) start_all_services ;;
2) stop_project_services ;;
3) run_deploy ;;
4) check_service_status ;;
9) show_help ;;
0) echo "退出"; exit 0 ;;
*) echo "无效选项:${choice}" ;;
esac
done
}
main_loop
+1 -1
View File
@@ -1,5 +1,5 @@
#!/usr/bin/env bash
# Jenkins / 本地 CI 同款前端生产构建(与 deploy.sh、frontend/Dockerfile 一致)
# Jenkins / 本地 CI 同款前端生产构建(与 frontend/Dockerfile 多阶段构建一致)
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
-78
View File
@@ -1,78 +0,0 @@
#!/bin/bash
set -e
# ==============================================================================
# 容器化自动部署脚本 (Docker Deploy Script)
# ==============================================================================
# 用途: 在服务器上执行,基于 Docker Compose 更新并重启服务。
# 架构: 前后端分离双容器模式 (hxops-frontend + hxops-backend)
# ==============================================================================
echo "=== 开始容器化部署流程 [$(date)] ==="
# 1. 配置参数
# ------------------------------------------------------------------------------
PROJECT_DIR="/data/ai-platform/hxops"
BRANCH="super"
ORACLE_CLIENT_DIR="${PROJECT_DIR}/oracle_client"
check_oracle_client() {
if [ ! -d "$ORACLE_CLIENT_DIR" ]; then
echo "错误: 未找到 Oracle Instant Client 目录: $ORACLE_CLIENT_DIR"
echo "请先在项目根目录准备 oracle_client,并确保 docker-compose 能挂载到 /app/oracle_client。"
exit 1
fi
if ! find "$ORACLE_CLIENT_DIR" \( -iname "oci.dll" -o -iname "libclntsh.so" -o -iname "libclntsh.dylib" -o -type d -name "instantclient_*" \) | grep -q .; then
echo "错误: Oracle Instant Client 目录存在,但未发现可用客户端文件: $ORACLE_CLIENT_DIR"
echo "请确认目录中包含 Instant Client 解压内容,例如 instantclient_* / oci.dll / libclntsh.so。"
exit 1
fi
}
# 2. 更新代码
# ------------------------------------------------------------------------------
echo ">>> [1/4] 拉取最新代码..."
if [ ! -d "$PROJECT_DIR" ]; then
echo "项目目录不存在,正在克隆..."
mkdir -p $(dirname "$PROJECT_DIR")
git clone -b $BRANCH https://gitee.com/justop/hxops.git $PROJECT_DIR
else
cd $PROJECT_DIR
echo "当前目录: $(pwd)"
git fetch origin
git reset --hard origin/$BRANCH
fi
# 3. 环境准备
# ------------------------------------------------------------------------------
echo ">>> [2/4] 检查 Docker 环境..."
if ! command -v docker &> /dev/null; then
echo "错误: 未找到 Docker。请先安装 Docker。"
exit 1
fi
echo ">>> [2.5/4] 检查 Oracle Instant Client..."
check_oracle_client
# 4. 构建与启动容器
# ------------------------------------------------------------------------------
echo ">>> [3/4] 重建并启动容器..."
# --build: 强制重新构建镜像 (确保获取最新代码/依赖)
# -d: 后台运行
# --remove-orphans: 清理未定义的孤儿容器
docker compose up -d --build --remove-orphans
# 5. 后置操作
# ------------------------------------------------------------------------------
echo ">>> [4/4] 执行数据库迁移..."
# 等待后端容器启动 (简单的健康检查等待)
echo "等待后端服务就绪..."
sleep 5
# 在 hxops-backend 容器内执行数据库迁移
docker compose exec -T hxops-backend flask db upgrade
echo "=== 部署完成 [$(date)] ==="
echo "容器状态:"
docker compose ps