packServer/backend/app/model/doc_category.js
liufumingren 78cee0fe1a feat(doc): 首页登录分流 + 文档站(简易 CMS / 静态 HTML / sitemap)
- 首页:`/` 未登录原地显示登录页(不再跳 /login),已登录直接进 `/dashboard`;
  看板路由由 `/` 迁到 `/dashboard`,侧边栏「首页」与无权限回跳同步;
  桌面端「工具 → 打开配置页」的 `/?token=` 免登录仍然可用
- 文档站:`/doc/**` 由后端整站生成静态 HTML(顶部分类 tab 全局切换、左侧栏目 → 内容页、
  右侧本页目录);`/sitemap.txt` 新链接追加到末尾,下架 / 删除的会被清理
- 平台管理 · 文档管理(`/admin/doc`):分类 / 栏目 / 内容页(Markdown)简易 CMS,
  内容页有编辑表单与列表,保存后自动重生成目录与静态页面
- 登录页右下角、顶栏(登录后)、看板右上角新增进入文档站的链接
- 部署:nginx 模板为 `/doc`、`/doc/`、`/sitemap.txt` 增加反代(否则会落到 SPA 回退);
  Vite dev server 增加同名代理;`middleware/frontend.js` 排除这些路径
- 登录页插画改为内联 SVG(沿用工作区已有的未提交改动)
- 测试:新增 Markdown 渲染单测;后端 218 个用例通过,前端 typecheck / build 通过

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-11-07 20:33:46 +08:00

29 lines
1.2 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

'use strict';
/**
* 文档分类(doc_categories)
*
* 一行 = 文档站顶部的一个 tab(「快速开始」「设备接入」「常见问题」…)。
* - `code`:URL 片段(`/doc/<code>/`),**创建后不能改**(改了旧链接就失效)
* - `status`:1 展示 0 隐藏(隐藏后不生成页面,也不再进 sitemap)
* - `sort`:tab 顺序(小的在前)
*/
module.exports = (app) => {
const { BIGINT, STRING, TINYINT, INTEGER } = app.Sequelize;
const DocCategory = app.model.define('doc_category', {
id: { type: BIGINT.UNSIGNED, primaryKey: true, autoIncrement: true, comment: '主键' },
code: { type: STRING(32), allowNull: false, unique: true, comment: 'URL 片段(/doc/<code>/)' },
name: { type: STRING(64), allowNull: false, comment: '分类名称(tab 文案)' },
description: { type: STRING(255), allowNull: true, comment: '分类说明(可选)' },
sort: { type: INTEGER.UNSIGNED, allowNull: false, defaultValue: 0, comment: '排序(小的在前)' },
status: { type: TINYINT.UNSIGNED, allowNull: false, defaultValue: 1, comment: '状态:1 展示 0 隐藏' },
}, {
tableName: 'doc_categories',
paranoid: true,
comment: '文档分类表',
});
return DocCategory;
};