Merge branch 'test' into prod
This commit is contained in:
commit
def791ff59
12 files changed
+353
-38
No files matched your search
@@ -88,7 +88,6 @@ PLM_ORACLE_PORT=1521
|
||||
PLM_ORACLE_SID=orcl
|
||||
PLM_ORACLE_USERNAME=PLM
|
||||
PLM_ORACLE_PASSWORD=PLM
|
||||
ORACLE_CLIENT_LIB_DIR=oracle_client\instantclient_19_30
|
||||
|
||||
# SRM SQL Server Configuration
|
||||
SRM_SQLSERVER_HOST=192.168.55.106
|
||||
|
||||
@@ -180,6 +180,7 @@ class TestingConfig(Config):
|
||||
config = {
|
||||
'development': DevelopmentConfig,
|
||||
'test': TestingConfig,
|
||||
'testing': TestingConfig, # alias for create_app('testing') in pytest
|
||||
'production': ProductionConfig,
|
||||
'default': DevelopmentConfig,
|
||||
}
|
||||
@@ -195,11 +195,11 @@ WHERE c002001 = ?
|
||||
return str(value)
|
||||
|
||||
@classmethod
|
||||
def _format_quota(cls, value) -> str:
|
||||
def _format_quota(cls, value, unit: str = "天") -> str:
|
||||
formatted = cls._format_number(value)
|
||||
if formatted == "暂无数据":
|
||||
return formatted
|
||||
return f"{formatted}天"
|
||||
return f"{formatted}{unit}"
|
||||
|
||||
@staticmethod
|
||||
def _resolve_response_year(record: dict | None, requested_year: int | None) -> str:
|
||||
@@ -210,13 +210,13 @@ WHERE c002001 = ?
|
||||
return str(datetime.now().year)
|
||||
|
||||
@classmethod
|
||||
def _render_table_row(cls, index: int, title: str, record: dict | None, requested_year: int | None) -> str:
|
||||
def _render_table_row(cls, index: int, title: str, record: dict | None, requested_year: int | None, quota_unit: str = "天") -> str:
|
||||
response_year = cls._resolve_response_year(record, requested_year)
|
||||
if not record:
|
||||
return f"| {index} | {title} | {response_year} | 暂无数据 | 暂无数据 | 暂无数据 |"
|
||||
total = cls._format_quota(record.get('total_hours'))
|
||||
used = cls._format_quota(record.get('used_hours'))
|
||||
remaining = cls._format_quota(record.get('remaining_hours'))
|
||||
total = cls._format_quota(record.get('total_hours'), quota_unit)
|
||||
used = cls._format_quota(record.get('used_hours'), quota_unit)
|
||||
remaining = cls._format_quota(record.get('remaining_hours'), "小时")
|
||||
return f"| {index} | {title} | {response_year} | {total} | {used} | {remaining} |"
|
||||
|
||||
@classmethod
|
||||
@@ -249,7 +249,7 @@ WHERE c002001 = ?
|
||||
sections.append(cls._render_table_row(index, "年假", annual_record, requested_year))
|
||||
index += 1
|
||||
if leave_type in ("childcare", "all"):
|
||||
sections.append(cls._render_table_row(index, "育儿假", childcare_record, requested_year))
|
||||
sections.append(cls._render_table_row(index, "育儿假", childcare_record, requested_year, "小时"))
|
||||
index += 1
|
||||
|
||||
sections.extend(
|
||||
|
||||
@@ -35,3 +35,4 @@ lxml==6.0.2
|
||||
typer==0.17.4
|
||||
croniter
|
||||
pyyaml
|
||||
minio>=7.2.0
|
||||
+40
-10
@@ -4,43 +4,73 @@ backend/worker_kb.py
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import logging
|
||||
import os
|
||||
import sys
|
||||
import time
|
||||
|
||||
from app import create_app
|
||||
from app.services.knowledge_cleaning.queue_service import process_next_clean_job
|
||||
|
||||
_LOG_FORMAT = '%(asctime)s %(levelname)s [kb-worker] %(message)s'
|
||||
_LOG_DATEFMT = '%Y-%m-%d %H:%M:%S'
|
||||
|
||||
|
||||
def _configure_logging() -> logging.Logger:
|
||||
logger = logging.getLogger('kb-worker')
|
||||
if logger.handlers:
|
||||
return logger
|
||||
handler = logging.StreamHandler(sys.stdout)
|
||||
handler.setFormatter(logging.Formatter(_LOG_FORMAT, datefmt=_LOG_DATEFMT))
|
||||
logger.addHandler(handler)
|
||||
logger.setLevel(logging.INFO)
|
||||
logger.propagate = False
|
||||
return logger
|
||||
|
||||
|
||||
def _resolve_config_name() -> str:
|
||||
"""Keep the worker aligned with container/runtime environment selection."""
|
||||
explicit = os.getenv('APP_CONFIG')
|
||||
if explicit:
|
||||
return explicit.strip().lower()
|
||||
"""Keep the worker aligned with container/runtime environment selection.
|
||||
|
||||
flask_env = os.getenv('FLASK_ENV', 'production').strip().lower()
|
||||
Note: ``FLASK_ENV=test`` / ``ENV_NAME=test`` mean the *test deployment* host
|
||||
(``.env.test``), not pytest. Use ``production`` so DATABASE_URL from env_file
|
||||
is honored. ``testing`` is only for in-memory unit tests (``TestingConfig``).
|
||||
"""
|
||||
explicit = (os.getenv('APP_CONFIG') or '').strip().lower()
|
||||
if explicit:
|
||||
if explicit in ('testing', 'test'):
|
||||
# Allow explicit pytest-style config only when APP_CONFIG is set;
|
||||
# never infer this from FLASK_ENV=test on deploy hosts.
|
||||
return 'test'
|
||||
return explicit
|
||||
|
||||
env_name = (os.getenv('ENV_NAME') or os.getenv('FLASK_ENV') or 'production').strip().lower()
|
||||
mapping = {
|
||||
'dev': 'development',
|
||||
'development': 'development',
|
||||
'test': 'testing',
|
||||
'testing': 'testing',
|
||||
# Deploy env files: test/prod hosts use real DB via ProductionConfig
|
||||
'test': 'production',
|
||||
'env': 'production',
|
||||
'prod': 'production',
|
||||
'production': 'production',
|
||||
# Pytest-only aliases (not used on deploy unless APP_CONFIG forces it)
|
||||
'testing': 'test',
|
||||
}
|
||||
return mapping.get(flask_env, 'production')
|
||||
return mapping.get(env_name, 'production')
|
||||
|
||||
|
||||
def main():
|
||||
log = _configure_logging()
|
||||
app = create_app(_resolve_config_name())
|
||||
poll_seconds = float(app.config.get('KB_WORKER_POLL_SECONDS', 2))
|
||||
|
||||
with app.app_context():
|
||||
print(f'[kb-worker] started, poll_seconds={poll_seconds}')
|
||||
log.info('started, poll_seconds=%s', poll_seconds)
|
||||
while True:
|
||||
processed, message = process_next_clean_job()
|
||||
if not processed:
|
||||
time.sleep(poll_seconds)
|
||||
continue
|
||||
print(f'[kb-worker] processed job: {message}')
|
||||
log.info('processed job: %s', message)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
+16
-15
@@ -36,9 +36,9 @@ services:
|
||||
# 数据库连接 (在环境变量中配置)
|
||||
- DATABASE_URL=${DATABASE_URL}
|
||||
- FLASK_APP=${FLASK_APP:-run.py}
|
||||
- FLASK_ENV=${FLASK_ENV:-production}
|
||||
- ORACLE_CLIENT_LIB_DIR=${ORACLE_CLIENT_LIB_DIR:-/app/oracle_client/instantclient_19_31}
|
||||
- LD_LIBRARY_PATH=${ORACLE_CLIENT_LIB_DIR}:/app/oracle_client
|
||||
- FLASK_ENV=${FLASK_ENV}
|
||||
- ORACLE_CLIENT_LIB_DIR=${ORACLE_CLIENT_LIB_DIR}
|
||||
- LD_LIBRARY_PATH=${ORACLE_CLIENT_LIB_DIR}
|
||||
- REDIS_URL=${REDIS_URL:-redis://kb-redis:6379/0}
|
||||
- KB_STORAGE_ROOT=${KB_STORAGE_ROOT:-/app/data/kb}
|
||||
- KB_TASK_EXECUTION_MODE=${KB_TASK_EXECUTION_MODE:-worker}
|
||||
@@ -62,8 +62,8 @@ services:
|
||||
hxops-kb-worker:
|
||||
image: ${BACKEND_IMAGE:-hxops-backend:local}
|
||||
build:
|
||||
context: ./backend
|
||||
dockerfile: Dockerfile
|
||||
context: .
|
||||
dockerfile: backend/Dockerfile
|
||||
args:
|
||||
PYTHON_BASE_IMAGE: ${PYTHON_BASE_IMAGE:-python:3.12-slim-bookworm}
|
||||
PIP_INDEX_URL: ${PIP_INDEX_URL:-https://mirrors.aliyun.com/pypi/simple}
|
||||
@@ -77,16 +77,17 @@ services:
|
||||
- ${COMPOSE_SHARED_ENV_BASENAME:-.env.shared}
|
||||
- ${COMPOSE_ENV_BASENAME:-.env.dev}
|
||||
environment:
|
||||
DATABASE_URL:
|
||||
SECRET_KEY:
|
||||
FLASK_APP: ${FLASK_APP:-run.py}
|
||||
FLASK_ENV: ${FLASK_ENV:-production}
|
||||
ORACLE_CLIENT_LIB_DIR: ${ORACLE_CLIENT_LIB_DIR:-/app/oracle_client/instantclient_19_31}
|
||||
LD_LIBRARY_PATH: ${ORACLE_CLIENT_LIB_DIR}:/app/oracle_client
|
||||
REDIS_URL: ${REDIS_URL:-redis://kb-redis:6379/0}
|
||||
KB_STORAGE_ROOT: ${KB_STORAGE_ROOT:-/app/data/kb}
|
||||
KB_TASK_EXECUTION_MODE: ${KB_TASK_EXECUTION_MODE:-worker}
|
||||
KB_WORKER_POLL_SECONDS: ${KB_WORKER_POLL_SECONDS:-2}
|
||||
# 勿写空键 DATABASE_URL:/SECRET_KEY:,会覆盖 env_file 导致 worker 启动即退出
|
||||
- DATABASE_URL=${DATABASE_URL}
|
||||
- SECRET_KEY=${SECRET_KEY}
|
||||
- FLASK_APP=${FLASK_APP:-run.py}
|
||||
- FLASK_ENV=${FLASK_ENV}
|
||||
- ORACLE_CLIENT_LIB_DIR=${ORACLE_CLIENT_LIB_DIR}
|
||||
- LD_LIBRARY_PATH=${ORACLE_CLIENT_LIB_DIR}
|
||||
- REDIS_URL=${REDIS_URL:-redis://kb-redis:6379/0}
|
||||
- KB_STORAGE_ROOT=${KB_STORAGE_ROOT:-/app/data/kb}
|
||||
- KB_TASK_EXECUTION_MODE=${KB_TASK_EXECUTION_MODE:-worker}
|
||||
- KB_WORKER_POLL_SECONDS=${KB_WORKER_POLL_SECONDS:-2}
|
||||
extra_hosts:
|
||||
- "host.docker.internal:host-gateway"
|
||||
volumes:
|
||||
|
||||
@@ -106,7 +106,7 @@ docker compose ps
|
||||
预期:
|
||||
|
||||
- `hxops-backend` 为 `Up`
|
||||
- `hxops-kb-worker` 为 `Up`
|
||||
- `hxops-kb-worker` 为 `Up`(与 backend 共用镜像;Jenkins/`deploy_compose.sh` 在后端变更时会一并重建)
|
||||
- `hxops-frontend` 为 `Up`
|
||||
|
||||
若启用了 `kb-redis` profile,则额外确认:
|
||||
|
||||
@@ -86,7 +86,7 @@ hxops/
|
||||
采用 **本地开发 -> Gitee -> Jenkins -> 服务器 `deploy_compose.sh`**:
|
||||
|
||||
1. **本地开发**: 改代码后 `git push` 到对应分支(`dev` / `test` / `prod` 等)。
|
||||
2. **Jenkins**: 在目标机 `git fetch/checkout` 后执行 `scripts/deploy_compose.sh <env>`,按变更增量重建 `hxops-frontend` / `hxops-backend`,并跑 `flask db upgrade` 与健康检查。
|
||||
2. **Jenkins**: 在目标机 `git fetch/checkout` 后执行 `scripts/deploy_compose.sh <env>`,按变更增量重建 `hxops-frontend` / `hxops-backend` / `hxops-kb-worker`(后端变更时 worker 与 backend 同镜像一并重建),并跑 `flask db upgrade` 与健康检查。
|
||||
3. **环境配置**: 仓库根目录 `.env.shared` + `.env.dev|test|prod`(见 `docs/env_loading_priority.md`)。
|
||||
|
||||
## 5. 🗄️ 核心数据模型 (Database Models)
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
|
||||
> 目标:在**明亮 / 暗黑**主题下,页面背景、文字、边框、按钮、卡片、布局间距保持一致;新页面默认符合规范,旧页面按阶段迁移。
|
||||
|
||||
> **AI / 日常编码实操准则(铁律、控件选型、Prompt 片段)** → [UI_CODING_GUIDELINES.md](./UI_CODING_GUIDELINES.md)
|
||||
|
||||
---
|
||||
|
||||
## 1. 总体架构
|
||||
@@ -152,6 +154,31 @@ colors: {
|
||||
| `.btn-ghost` | 图标/工具栏 |
|
||||
| `.btn-danger` | 删除、退出等 |
|
||||
| `.btn-icon` | 正方形图标按钮(顶栏、侧栏折叠) |
|
||||
| `.btn-sm` / `.btn-lg` | 尺寸变体 |
|
||||
| `.btn-segment` / `.btn-segment--active` | **已废弃**,改用 `segment-item`(见 UI 准则 §3) |
|
||||
|
||||
### 3.1.1 分段切换(单选,非操作按钮)
|
||||
|
||||
| 类名 | 用途 |
|
||||
|------|------|
|
||||
| `.segment-control` + `--cols-2/3/4` / `--fit` | 容器布局 |
|
||||
| `.segment-item` / `.segment-item--active` | 选项(细边框 + brand 选中态) |
|
||||
|
||||
### 3.1.2 顶栏语言 / 主题
|
||||
|
||||
| 组件或类 | 用途 |
|
||||
|----------|------|
|
||||
| `ThemeToggleButton` | 亮暗切换(圆形容器) |
|
||||
| `LocaleToggleButton` | 语言图标 + 固定四项菜单 |
|
||||
| `.header-locale-menu` | 语言下拉面板 |
|
||||
|
||||
### 3.1.3 弹窗(通用)
|
||||
|
||||
| 类名 | 用途 |
|
||||
|------|------|
|
||||
| `.dialog-overlay` / `.dialog-panel` | 遮罩 + 面板 |
|
||||
| `.dialog-header` / `.dialog-body` / `.dialog-footer` | 结构分区 |
|
||||
| `.admin-modal-*` | Admin 专用(与 dialog 二选一,逐步统一) |
|
||||
|
||||
### 3.2 表单
|
||||
|
||||
@@ -0,0 +1,255 @@
|
||||
# HXOps UI 编码准则(AI / 人工通用)
|
||||
|
||||
> **用途**:新功能、改版、修 UI 时必读。给 AI 写需求时,可将本文 **§0 Prompt 片段** 与 **§1 铁律** 一并粘贴进任务说明。
|
||||
> **架构详解**:见 [DESIGN_SYSTEM.md](./DESIGN_SYSTEM.md)。
|
||||
> **样式实现**:`frontend/src/styles/tokens.css`、`utilities.css`、`components-ds.css`、`style.css`。
|
||||
|
||||
---
|
||||
|
||||
## 0. 给 AI 的任务 Prompt 片段(可直接复制)
|
||||
|
||||
```text
|
||||
请严格遵循 docs/UI_CODING_GUIDELINES.md:
|
||||
|
||||
1. 颜色只用 L1 语义类(bg-page / bg-surface / text-primary / border-default 等),禁止 dark: 双色、禁止 bg-white/slate/gray 作结构色、禁止 text-[#hex]。
|
||||
2. 操作按钮只用 L2:btn-primary / btn-secondary / btn-ghost / btn-danger;禁止手写 rounded-xl border px-4 仿按钮。
|
||||
3. 单选切换(主题、语言菜单项、Cron 频率、反馈类型等)用 segment-control + segment-item,禁止用 btn-primary 或原生 select 做切换。
|
||||
4. 弹窗用 dialog-overlay + dialog-panel(或 Admin 的 admin-modal-*),禁止 fixed inset-0 bg-black/40 手写遮罩。
|
||||
5. 顶栏语言用 LocaleToggleButton;菜单四项固定文案:简体中文 / 繁體中文 / English / ไทย(禁止 t() 翻译菜单标签)。
|
||||
6. 主题切换用 ThemeToggleButton(圆形容器);语言图标无外圈,与侧栏底栏图标同风格。
|
||||
7. 最小 diff,匹配现有组件;改完 npm run build。
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 1. 铁律(违反即需改)
|
||||
|
||||
### 1.1 必须(MUST)
|
||||
|
||||
| # | 规则 |
|
||||
|---|------|
|
||||
| M1 | 结构色只来自 **L1 语义 class** 或 L2 组件(内部已绑变量) |
|
||||
| M2 | 主题亮暗靠 `html.dark` + CSS 变量,**不写** `dark:bg-*` / `dark:text-*` |
|
||||
| M3 | 可点击主/次操作 → **`.btn-*`** |
|
||||
| M4 | 多选一(非提交动作)→ **`.segment-control` + `.segment-item`** |
|
||||
| M5 | 模态框 → **`.dialog-*`** 或 **`.admin-modal-*`** |
|
||||
| M6 | 文本框/下拉(表单字段)→ **`.input-field`** / **`.select-field`** |
|
||||
| M7 | 页面根在 **`page-shell`** 或 L3 布局(`MarketingShell` / `ChatShell` / `MinimalShell`)内 |
|
||||
| M8 | 语言切换复用 **`LocaleToggleButton`**,选项文案 **固定四种语言名**(见 §5.3) |
|
||||
|
||||
### 1.2 禁止(MUST NOT)
|
||||
|
||||
| # | 规则 |
|
||||
|---|------|
|
||||
| X1 | `bg-white`、`bg-gray-*`、`bg-slate-*`、`text-slate-*` 作为页面/卡片/表单**结构色** |
|
||||
| X2 | `text-[#...]`、`bg-[#...]`(登录营销区 `data-surface="marketing"` 除外,须注释 `design-system:exception`) |
|
||||
| X3 | 同一元素 `bg-x` + `dark:bg-y` |
|
||||
| X4 | 用 **`btn-primary` / 粗边框独立块** 做「选中项切换」(那是操作按钮,不是分段控件) |
|
||||
| X5 | 用 **原生 `<select>`** 做顶栏/侧栏图标旁语言切换(易双箭头、高度不齐) |
|
||||
| X6 | 语言菜单用 **`t('workspace.lang.*')`** 当标签(切到 English 会变成 Simplified Chinese 等) |
|
||||
| X7 | 在 `views/*.vue` 复制一长串 Tailwind 当「新按钮样式」 |
|
||||
| X8 | 无必要地新增 `html.dark .xxx !important` 补丁(应改 L1/L2) |
|
||||
|
||||
### 1.3 允许例外(须注释)
|
||||
|
||||
- 登录页 Hero 渐变、背景图、玻璃卡片 `bg-white/90`
|
||||
- Markdown `prose`、代码高亮里的 `slate`/`emerald`
|
||||
- 调度日志 `pre` 等代码块 → 用 **`.admin-pre-block`** / **`.admin-pre-block--sql`**
|
||||
|
||||
---
|
||||
|
||||
## 2. 三层职责(选型前先对号入座)
|
||||
|
||||
```
|
||||
L3 布局 → 整页骨架、顶栏/侧栏槽位(layouts/*.vue)
|
||||
L2 组件 → 按钮、输入、卡片、弹窗、分段切换(components-ds.css + style.css)
|
||||
L1 令牌 → 颜色/边框/阴影(tokens.css → utilities.css)
|
||||
```
|
||||
|
||||
**向下约束**:View 里只组合 L2/L3,不发明新的「结构色」Tailwind 串。
|
||||
|
||||
---
|
||||
|
||||
## 3. 交互控件选型表(最重要)
|
||||
|
||||
| 用户意图 | 用什么 | 不要用 |
|
||||
|----------|--------|--------|
|
||||
| 提交、保存、创建、删除 | `btn-primary` / `btn-danger` | 裸 `button` + 一堆 class |
|
||||
| 取消、关闭次要操作 | `btn-secondary` / `btn-ghost` | `input-field` 当按钮 |
|
||||
| 主题 / 语言 / Cron 频率 / 反馈类型 等 **N 选 1** | `segment-control` + `segment-item` | `btn-primary`、并排 `btn-segment` 仿按钮 |
|
||||
| 2 个短标签(数据库/API) | `segment-control--fit` + `--sm` | 共用灰底轨道把选项粘成一条 |
|
||||
| 3 个选项(反馈类型、个人中心主题) | `segment-control--cols-3` | `flex` + 间隙很大的独立蓝底按钮 |
|
||||
| 4 个等分(Cron) | `segment-control--cols-4` + `--sm` | `grid` + 手写 `border-blue-300 bg-blue-50` |
|
||||
| 表单里选语言/负责人 | `input-field` + `select` 或 `select-field` | `LocaleToggleButton` |
|
||||
| 顶栏/Chat 底栏切换界面语言 | `LocaleToggleButton` | 顶栏 `<select>` |
|
||||
| 顶栏切换亮暗 | `ThemeToggleButton` | 手写 moon 按钮无统一尺寸 |
|
||||
| 通用业务弹窗 | `dialog-overlay` + `dialog-panel` + header/body/footer | `bg-slate-900/40` + 自写圆角盒子 |
|
||||
| Admin 大表单弹窗 | `admin-modal-overlay` + `admin-modal-panel` | 与 `dialog-*` 混用两套除非迁移中 |
|
||||
| 删除确认 | `DeleteConfirmDialog` | 自写红色弹窗 |
|
||||
| 全局提示 | `LevelMessageDialog` / `alert-ds` | 手写 hex 色 alert |
|
||||
|
||||
### 3.1 分段切换(segment-control)视觉约定
|
||||
|
||||
与个人中心「主题」一致:
|
||||
|
||||
- **未选中**:`border`(1px)+ `bg-surface` + `text-secondary`
|
||||
- **选中**:`border-brand-500` + `bg-brand-50` + `text-brand-700`(暗色见 `components-ds.css`)
|
||||
- **禁止**:`border-2`、灰底轨道粘在一起、选中态用实心 `btn-primary` 蓝按钮
|
||||
|
||||
布局修饰符:
|
||||
|
||||
| 类名 | 场景 |
|
||||
|------|------|
|
||||
| `segment-control--cols-2` | 两列等分 |
|
||||
| `segment-control--cols-3` | 三列等分(主题、反馈类型) |
|
||||
| `segment-control--cols-4` | 四列;小屏 2 列(Cron) |
|
||||
| `segment-control--fit` | 工具栏 2 个短标签,宽度随内容 |
|
||||
| `segment-control--sm` / `--md` | 字号与内边距 |
|
||||
|
||||
---
|
||||
|
||||
## 4. 颜色与排版
|
||||
|
||||
### 4.1 语义色(模板中优先)
|
||||
|
||||
- 背景:`bg-page`、`bg-surface`、`bg-surface-soft`、`bg-surface-strong`
|
||||
- 文字:`text-primary`、`text-secondary`、`text-muted`
|
||||
- 边框:`border-default`、`border-subtle`
|
||||
- 遮罩:`bg-overlay`(勿用 `bg-black/40`、`bg-slate-900/40`)
|
||||
|
||||
### 4.2 品牌与状态
|
||||
|
||||
- 强调操作:`brand-600` / `brand-700`(按钮、链接)
|
||||
- 成功/警告/错误:优先 L2 `alert-*` 或 `--status-*` 令牌
|
||||
|
||||
### 4.3 排版
|
||||
|
||||
- 页面标题:`page-title` 或 `section-title`
|
||||
- 表单标签:`label-field`
|
||||
- 区块间距:`section-gap`、`form-stack`
|
||||
|
||||
---
|
||||
|
||||
## 5. 顶栏与语言/主题
|
||||
|
||||
### 5.1 登录页 / 营销顶栏(`MarketingShell` #tools)
|
||||
|
||||
```vue
|
||||
<ThemeToggleButton />
|
||||
<LocaleToggleButton />
|
||||
```
|
||||
|
||||
- 主题:**圆形容器** `theme-toggle-btn--inline`(h-8 / md:h-9)
|
||||
- 语言:**仅图标** `header-locale-btn`,**无外圈**;点击展开 `header-locale-menu`
|
||||
|
||||
### 5.2 Chat 侧栏底栏
|
||||
|
||||
图标行:`LayoutGrid`(Agent)· 主题(Sun/Moon)· **`LocaleToggleButton variant="sidebar"`** · 反馈 · 工作台
|
||||
|
||||
- **禁止**在用户头像下拉里再放语言 `<select>`
|
||||
- 侧栏菜单向上展开:`header-locale-menu--sidebar`
|
||||
|
||||
### 5.3 语言菜单固定文案(不可 i18n)
|
||||
|
||||
| value | 显示(始终不变) |
|
||||
|-------|------------------|
|
||||
| `zh-CN` | 简体中文 |
|
||||
| `zh-TW` | 繁體中文 |
|
||||
| `en` | English |
|
||||
| `th` | ไทย |
|
||||
|
||||
实现:仅改 `LocaleToggleButton.vue` 内 `LOCALE_PICKER_OPTIONS` 常量。
|
||||
|
||||
### 5.4 已登录工作台顶栏
|
||||
|
||||
复用 `AppHeaderTools.vue`:`ThemeToggleButton` + `LocaleToggleButton`。
|
||||
|
||||
---
|
||||
|
||||
## 6. 弹窗结构(复制骨架)
|
||||
|
||||
```vue
|
||||
<div class="dialog-overlay z-50 items-center" @click.self="close">
|
||||
<div class="dialog-panel max-w-md">
|
||||
<div class="dialog-header">
|
||||
<h3 class="section-title">标题</h3>
|
||||
<button type="button" class="btn-icon-ds" @click="close"><X /></button>
|
||||
</div>
|
||||
<div class="dialog-body form-stack">…</div>
|
||||
<div class="dialog-footer">
|
||||
<button type="button" class="btn-secondary">取消</button>
|
||||
<button type="button" class="btn-primary">确定</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
```
|
||||
|
||||
**表单配置项**(如「创建后启用」)放在 **`dialog-body` 内**,不要与 footer 操作按钮同一行。
|
||||
|
||||
---
|
||||
|
||||
## 7. 场景速查
|
||||
|
||||
| 场景 | 布局 | 要点 |
|
||||
|------|------|------|
|
||||
| 未登录登录 | `MarketingShell` | 营销区玻璃卡可例外;工具在 shell #tools |
|
||||
| 已登录 Workspace | `page-shell` + `ws-*` | 侧栏 `ws-nav-btn` |
|
||||
| Admin | `page-shell` + `admin-*` | 表头 `bg-surface-soft`;大弹窗 `admin-modal-*` |
|
||||
| KB 工作台 | `page-shell` + `kb-ws-*` | 弹窗 `dialog-overlay` |
|
||||
| Chat | `ChatShell` | 侧栏 `chat-*`;底栏语言见 §5.2 |
|
||||
| 重置密码 | `MinimalShell` | `btn-primary` + `input-field` |
|
||||
|
||||
---
|
||||
|
||||
## 8. 文件与复用
|
||||
|
||||
| 需求 | 应修改/新增 |
|
||||
|------|-------------|
|
||||
| 新颜色令牌 | `styles/tokens.css` + `utilities.css` |
|
||||
| 新通用 UI 块 | `styles/components-ds.css`(L2) |
|
||||
| 新全页骨架 | `layouts/*.vue`(L3) |
|
||||
| 语言切换 | 仅 `components/LocaleToggleButton.vue` |
|
||||
| 主题切换 | 仅 `components/ThemeToggleButton.vue` |
|
||||
| 业务弹窗组件 | `components/*Dialog*.vue`,内部用 `dialog-*` |
|
||||
|
||||
**原则**:同一交互一种组件,不在多个 View 各写一套样式。
|
||||
|
||||
---
|
||||
|
||||
## 9. PR / AI 交付自检清单
|
||||
|
||||
- [ ] `npm run build` 通过
|
||||
- [ ] 亮/暗色各看一眼主路径
|
||||
- [ ] 无新增 `dark:` 结构色、无 `bg-white`/`slate`/`gray` 结构色(例外已注释)
|
||||
- [ ] 按钮/切换/弹窗符合 §3 选型表
|
||||
- [ ] 语言菜单文案固定为四种(§5.3)
|
||||
- [ ] 未扩大 scope(不顺手改无关页面)
|
||||
- [ ] 若新增 L2 类,在本文或 DESIGN_SYSTEM 补一行说明
|
||||
|
||||
---
|
||||
|
||||
## 10. 常见错误(本项目已踩坑)
|
||||
|
||||
1. **分段控件做成实心蓝按钮** → 像「提交」,不像切换。
|
||||
2. **segment 外加粗边框 + 灰底轨道** → 三项粘成一条。应 `--cols-N` 或 `--fit` + 细 border。
|
||||
3. **顶栏语言用 `<select>`** → 双箭头、高度与主题钮不一致。
|
||||
4. **语言菜单 `t()` 翻译** → 切英文后菜单变英文。
|
||||
5. **弹窗底部塞配置 checkbox** → 应进 body,footer 仅操作钮。
|
||||
6. **PowerShell 批量替换** → 破坏 `:class`、压成单行;改 UI 优先小范围手工 + 构建验证。
|
||||
|
||||
---
|
||||
|
||||
## 11. 参考索引
|
||||
|
||||
| 文件 | 内容 |
|
||||
|------|------|
|
||||
| `docs/DESIGN_SYSTEM.md` | 令牌表、阶段迁移、目录结构 |
|
||||
| `frontend/src/styles/components-ds.css` | L2 权威列表(segment、dialog、admin、chat、header-locale) |
|
||||
| `frontend/src/components/LocaleToggleButton.vue` | 语言图标 + 固定菜单 |
|
||||
| `frontend/src/components/ThemeToggleButton.vue` | 主题按钮 |
|
||||
| `frontend/src/components/GeneralFeedbackDialog.vue` | dialog + segment 示例 |
|
||||
| `frontend/src/views/WorkspaceView.vue` | 个人中心 `segment-control--cols-3` 主题 |
|
||||
|
||||
---
|
||||
|
||||
*版本:2026-05-27 · 与仓库实现对齐;变更 L2 时请同步更新 §3、§5。*
|
||||
@@ -1,4 +1,4 @@
|
||||
import { createI18n } from 'vue-i18n';
|
||||
import { createI18n } from 'vue-i18n';
|
||||
|
||||
const messages = {
|
||||
'en': {
|
||||
|
||||
@@ -141,12 +141,13 @@ if [[ "${FRONTEND_CHANGED}" == "true" ]]; then
|
||||
services+=("hxops-frontend")
|
||||
fi
|
||||
if [[ "${BACKEND_CHANGED}" == "true" ]]; then
|
||||
services+=("hxops-backend")
|
||||
# 知识库清洗与 backend 共用镜像;仅重建 backend 时 worker 会继续跑旧容器/旧代码
|
||||
services+=("hxops-backend" "hxops-kb-worker")
|
||||
fi
|
||||
|
||||
# 如果只是部署配置变更(如 compose/env/脚本),但前后端代码未改,则两边都更新
|
||||
if [[ ${#services[@]} -eq 0 && "${DEPLOY_CONFIG_CHANGED}" == "true" ]]; then
|
||||
services=("hxops-frontend" "hxops-backend")
|
||||
services=("hxops-frontend" "hxops-backend" "hxops-kb-worker")
|
||||
fi
|
||||
|
||||
# 无变更则直接跳过,避免无意义重启
|
||||
|
||||
Reference in new issue
Block a user