From f623b098a05cd88b71901af51aac138f752da3e1 Mon Sep 17 00:00:00 2001 From: Codex User Date: Tue, 8 Sep 2026 13:22:05 +0800 Subject: [PATCH] fix: make CMS content live and migrate to MySQL --- cms/admin/src/App.tsx | 51 +-- cms/server/.env.example | 15 + cms/server/package-lock.json | 500 +++++++--------------------- cms/server/package.json | 4 +- cms/server/src/db.js | 394 ++++------------------ cms/server/src/export-sqlite.js | 11 + cms/server/src/import-mysql.js | 19 ++ cms/server/src/index.js | 61 ++-- cms/server/src/migrate-sqlite.js | 27 ++ cms/server/src/seed.js | 36 +- src/components/Layout/GlobalCTA.tsx | 6 + src/pages/Ameba/index.tsx | 31 +- src/pages/Home/home.css | 2 + src/pages/Home/index.tsx | 35 +- src/pages/SelfCheck/index.tsx | 38 ++- src/services/cms.ts | 12 +- 16 files changed, 430 insertions(+), 812 deletions(-) create mode 100644 cms/server/.env.example create mode 100644 cms/server/src/export-sqlite.js create mode 100644 cms/server/src/import-mysql.js create mode 100644 cms/server/src/migrate-sqlite.js diff --git a/cms/admin/src/App.tsx b/cms/admin/src/App.tsx index 955a7e8..34b7716 100644 --- a/cms/admin/src/App.tsx +++ b/cms/admin/src/App.tsx @@ -3,19 +3,20 @@ import { useState, useEffect } from 'react' const API_BASE = '' // 同域,相对路径 const SIDEBAR = [ { key: 'config', label: '1 全局配置' }, - { key: 'home', label: '2 首页模块' }, - { key: 'ameba', label: '3 阿美巴页面' }, - { key: 'evolution', label: '4 企业进化' }, - { key: 'methods', label: '5 方法与能力' }, - { key: 'services', label: '6 产品服务' }, - { key: 'cases', label: '7 案例管理' }, - { key: 'articles', label: '8 认知观察' }, - { key: 'selfcheck', label: '9 自我对照' }, - { key: 'diag_q', label: '10 诊断问卷' }, - { key: 'diag_config', label: '11 诊断配置' }, - { key: 'diag_reports', label: '12 诊断记录' }, - { key: 'diag_leads', label: '13 留资统计' }, - { key: 'contact_leads', label: '14 咨询线索' }, + { key: 'texts', label: '2 全站文案' }, + { key: 'home', label: '3 首页模块' }, + { key: 'ameba', label: '4 阿美巴页面' }, + { key: 'evolution', label: '5 企业进化' }, + { key: 'methods', label: '6 方法与能力' }, + { key: 'services', label: '7 产品服务' }, + { key: 'cases', label: '8 案例管理' }, + { key: 'articles', label: '9 认知观察' }, + { key: 'selfcheck', label: '10 自我对照' }, + { key: 'diag_q', label: '11 诊断问卷' }, + { key: 'diag_config', label: '12 诊断配置' }, + { key: 'diag_reports', label: '13 诊断记录' }, + { key: 'diag_leads', label: '14 留资统计' }, + { key: 'contact_leads', label: '15 咨询线索' }, { key: 'password', label: '⚙ 修改密码' }, ] @@ -66,6 +67,7 @@ export default function App(){

{SIDEBAR.find(s=>s.key===cur)?.label}

内容与布局解耦 · 只改内容不改架构
{cur==='config' && } + {cur==='texts' && } {cur==='home' && } {cur==='ameba' && } {cur==='evolution' && } @@ -85,6 +87,17 @@ export default function App(){ ) } +function Texts({token}:{token:string}){ + const [list,setList]=useState([]) + useEffect(()=>{api('/api/cms/texts',token).then(j=>setList(j.data||[]))},[]) + const update=(i:number,key:string,value:any)=>{const n=[...list]; n[i]={...n[i],[key]:value}; setList(n)} + const save=()=>api('/api/cms/texts',token,{method:'PUT',body:JSON.stringify(list)}).then(j=>alert(j.msg||'保存成功')) + return

全站文案

这里的内容会覆盖首页、阿美巴页和全站行动区的默认文字。保存后刷新前台即可看到。

+ {list.map((it,i)=>