[{"data":1,"prerenderedAt":6636},["ShallowReactive",2],{"navigation":3,"/document/ai-sdk/application/persistence":2747,"/document/ai-sdk/application/persistence-surround":6633},[4],{"title":5,"path":6,"stem":7,"children":8,"page":50},"Document","/document","document",[9,51,119,152,210,266,311,348,369,410,455,488,528,569,596,620,644,676,711,742,773,805,842,874,910,940,975,1011,1047,1086,1156,1244,1276,1307,1338,1366,1443,1483,1515,1555,1592,1624,1656,1753,1839,1912,1970,2112,2166,2205,2274,2328,2402,2473,2513,2571,2633,2692],{"title":10,"path":11,"stem":12,"children":13,"page":50},"Html5","/document/html5","document/01.html5",[14,42],{"title":15,"path":16,"stem":17,"children":18,"icon":41},"指南","/document/html5/guide","document/01.html5/01.guide/01.index",[19,21,25,29,33,37],{"title":20,"path":16,"stem":17},"HTML 入门教程",{"title":22,"path":23,"stem":24},"常用标签详解","/document/html5/guide/tag","document/01.html5/01.guide/02.tag",{"title":26,"path":27,"stem":28},"布局与语义标签","/document/html5/guide/layout","document/01.html5/01.guide/03.layout",{"title":30,"path":31,"stem":32},"表单设计与用户输入","/document/html5/guide/form","document/01.html5/01.guide/04.form",{"title":34,"path":35,"stem":36},"多媒体与 HTML5 新特性","/document/html5/guide/html5","document/01.html5/01.guide/05.html5",{"title":38,"path":39,"stem":40},"Web 标准与 HTML 编写规范","/document/html5/guide/web","document/01.html5/01.guide/06.web","i-lucide-code",{"title":43,"path":44,"stem":45,"children":46,"icon":49},"考核","/document/html5/examine","document/01.html5/02.examine/01.index",[47],{"title":48,"path":44,"stem":45},"HTML5 知识测验","i-lucide-clipboard-check",false,{"title":52,"path":53,"stem":54,"children":55,"page":50},"Css","/document/css","document/02.css",[56,75,100,113],{"title":57,"path":58,"stem":59,"children":60,"icon":50},"启航","/document/css/guide","document/02.css/01.guide/01.index",[61,63,67,71],{"title":62,"path":58,"stem":59},"CSS 基础入门教程",{"title":64,"path":65,"stem":66},"文本与盒子样式详解","/document/css/guide/styles","document/02.css/01.guide/02.styles",{"title":68,"path":69,"stem":70},"选择器与权重机制","/document/css/guide/selected","document/02.css/01.guide/03.selected",{"title":72,"path":73,"stem":74},"盒模型详解","/document/css/guide/box","document/02.css/01.guide/04.box",{"title":76,"icon":50,"path":77,"stem":78,"children":79,"page":50},"布局","/document/css/layout","document/02.css/02.layout",[80,84,88,92,96],{"title":81,"path":82,"stem":83},"网页布局三剑客详解","/document/css/layout/policy","document/02.css/02.layout/01.policy",{"title":85,"path":86,"stem":87},"Position 定位详解","/document/css/layout/position","document/02.css/02.layout/02.position",{"title":89,"path":90,"stem":91},"Flexbox 布局入门指南","/document/css/layout/flex","document/02.css/02.layout/03.flex",{"title":93,"path":94,"stem":95},"Grid 布局入门指南","/document/css/layout/grid","document/02.css/02.layout/04.grid",{"title":97,"path":98,"stem":99},"响应式设计指南","/document/css/layout/relative","document/02.css/02.layout/05.relative",{"title":101,"icon":50,"path":102,"stem":103,"children":104,"page":50},"使用技巧","/document/css/skill","document/02.css/03.skill",[105,109],{"title":106,"path":107,"stem":108},"CSS 动画全解析","/document/css/skill/animation","document/02.css/03.skill/01.animation",{"title":110,"path":111,"stem":112},"CSS 使用技巧全攻略","/document/css/skill/skill","document/02.css/03.skill/02.skill",{"title":43,"path":114,"stem":115,"children":116,"icon":49},"/document/css/examine","document/02.css/04.examine/01.index",[117],{"title":118,"path":114,"stem":115},"CSS 知识测验",{"title":120,"path":121,"stem":122,"children":123,"page":50},"Git","/document/git","document/03.git",[124,146],{"title":57,"path":125,"stem":126,"children":127,"icon":50},"/document/git/guide","document/03.git/01.guide/01.index",[128,130,134,138,142],{"title":129,"path":125,"stem":126},"Git 入门指南",{"title":131,"path":132,"stem":133},"Git 安装与初体验","/document/git/guide/install","document/03.git/01.guide/02.install",{"title":135,"path":136,"stem":137},"常用 Git 命令详解","/document/git/guide/command","document/03.git/01.guide/03.command",{"title":139,"path":140,"stem":141},"Git 分支管理全解析","/document/git/guide/branch","document/03.git/01.guide/04.branch",{"title":143,"path":144,"stem":145},"使用 GitHub 轻松托管和管理代码","/document/git/guide/github","document/03.git/01.guide/05.github",{"title":43,"path":147,"stem":148,"children":149,"icon":49},"/document/git/examine","document/03.git/02.examine/01.index",[150],{"title":151,"path":147,"stem":148},"Git 知识测验",{"title":153,"path":154,"stem":155,"children":156,"page":50},"Js Base","/document/js-base","document/04.js-base",[157,187,204],{"title":15,"path":158,"stem":159,"children":160,"icon":41},"/document/js-base/guide","document/04.js-base/01.guide/01.index",[161,163,167,171,175,179,183],{"title":162,"path":158,"stem":159},"JavaScript 基础快速入门",{"title":164,"path":165,"stem":166},"搞懂变量与数据类型","/document/js-base/guide/variable","document/04.js-base/01.guide/02.variable",{"title":168,"path":169,"stem":170},"JavaScript 运算符详解","/document/js-base/guide/operator","document/04.js-base/01.guide/03.operator",{"title":172,"path":173,"stem":174},"条件判断与循环语句","/document/js-base/guide/flow","document/04.js-base/01.guide/04.flow",{"title":176,"path":177,"stem":178},"深入理解 JavaScript 函数","/document/js-base/guide/function","document/04.js-base/01.guide/05.function",{"title":180,"path":181,"stem":182},"对象数组的创建与操作","/document/js-base/guide/object","document/04.js-base/01.guide/06.object",{"title":184,"path":185,"stem":186},"Math 和 Date 用法详解","/document/js-base/guide/math","document/04.js-base/01.guide/07.math",{"title":188,"icon":41,"path":189,"stem":190,"children":191,"page":50},"浏览器","/document/js-base/browser","document/04.js-base/02.browser",[192,196,200],{"title":193,"path":194,"stem":195},"DOM 操作入门与实战","/document/js-base/browser/dom","document/04.js-base/02.browser/01.dom",{"title":197,"path":198,"stem":199},"浏览器 BOM 基础知识","/document/js-base/browser/bom","document/04.js-base/02.browser/02.bom",{"title":201,"path":202,"stem":203},"JavaScript 事件处理机制","/document/js-base/browser/event","document/04.js-base/02.browser/03.event",{"title":43,"path":205,"stem":206,"children":207,"icon":49},"/document/js-base/examine","document/04.js-base/03.examine/01.index",[208],{"title":209,"path":205,"stem":206},"JavaScript 基础 知识测验",{"title":211,"path":212,"stem":213,"children":214,"page":50},"Js Advanced","/document/js-advanced","document/05.js-advanced",[215,234,252],{"title":216,"path":217,"stem":218,"children":219,"icon":41},"JavaScript 原理","/document/js-advanced/guide","document/05.js-advanced/01.guide/01.index",[220,222,226,230],{"title":221,"path":217,"stem":218},"JavaScript 是怎么运行的？",{"title":223,"path":224,"stem":225},"深入理解函数和作用域","/document/js-advanced/guide/function","document/05.js-advanced/01.guide/02.function",{"title":227,"path":228,"stem":229},"深入理解 this 指向","/document/js-advanced/guide/this","document/05.js-advanced/01.guide/03.this",{"title":231,"path":232,"stem":233},"浅拷贝与深拷贝详解","/document/js-advanced/guide/copy","document/05.js-advanced/01.guide/04.copy",{"title":235,"icon":236,"path":237,"stem":238,"children":239,"page":50},"编程范式","i-lucide-shapes","/document/js-advanced/program","document/05.js-advanced/02.program",[240,244,248],{"title":241,"path":242,"stem":243},"面向对象编程（OOP）","/document/js-advanced/program/object","document/05.js-advanced/02.program/01.object",{"title":245,"path":246,"stem":247},"函数式编程入门","/document/js-advanced/program/fp","document/05.js-advanced/02.program/02.fp",{"title":249,"path":250,"stem":251},"防抖和节流详解","/document/js-advanced/program/debounce","document/05.js-advanced/02.program/03.debounce",{"title":253,"icon":254,"path":255,"stem":256,"children":257,"page":50},"浏览器相关特性","i-lucide-monitor","/document/js-advanced/browser","document/05.js-advanced/03.browser",[258,262],{"title":259,"path":260,"stem":261},"浏览器缓存入门指南","/document/js-advanced/browser/cache","document/05.js-advanced/03.browser/01.cache",{"title":263,"path":264,"stem":265},"Web 存储机制深度剖析","/document/js-advanced/browser/storage","document/05.js-advanced/03.browser/02.storage",{"title":267,"path":268,"stem":269,"children":270,"page":50},"Es6","/document/es6","document/06.es6",[271,305],{"title":216,"path":272,"stem":273,"children":274,"icon":41},"/document/es6/guide","document/06.es6/01.guide/01.index",[275,277,281,285,289,293,297,301],{"title":276,"path":272,"stem":273},"ES6 入门指南",{"title":278,"path":279,"stem":280},"变量声明：let 与 const","/document/es6/guide/const","document/06.es6/01.guide/02.const",{"title":282,"path":283,"stem":284},"箭头函数的用法与特点","/document/es6/guide/arrow","document/06.es6/01.guide/03.arrow",{"title":286,"path":287,"stem":288},"字符串、对象与数组的新特性","/document/es6/guide/enhance","document/06.es6/01.guide/04.enhance",{"title":290,"path":291,"stem":292},"Map 和 Set 的使用方式","/document/es6/guide/set","document/06.es6/01.guide/05.set",{"title":294,"path":295,"stem":296},"Promise 实现异步流程控制","/document/es6/guide/promise","document/06.es6/01.guide/06.promise",{"title":298,"path":299,"stem":300},"ESM 模块化语法解析","/document/es6/guide/esm","document/06.es6/01.guide/07.esm",{"title":302,"path":303,"stem":304},"Class 的定义与继承机制","/document/es6/guide/class","document/06.es6/01.guide/08.class",{"title":43,"path":306,"stem":307,"children":308,"icon":49},"/document/es6/examine","document/06.es6/02.examine/01.index",[309],{"title":310,"path":306,"stem":307},"ES6 知识测验",{"title":312,"path":313,"stem":314,"children":315,"page":50},"Js Algorithms","/document/js-algorithms","document/07.js-algorithms",[316,342],{"title":15,"path":317,"stem":318,"children":319,"icon":41},"/document/js-algorithms/guide","document/07.js-algorithms/01.guide/01.index",[320,322,326,330,334,338],{"title":321,"path":317,"stem":318},"什么是数据结构和算法？",{"title":323,"path":324,"stem":325},"时间和空间复杂度","/document/js-algorithms/guide/complexity","document/07.js-algorithms/01.guide/02.complexity",{"title":327,"path":328,"stem":329},"数据结构","/document/js-algorithms/guide/structure","document/07.js-algorithms/01.guide/03.structure",{"title":331,"path":332,"stem":333},"算法","/document/js-algorithms/guide/algorithms","document/07.js-algorithms/01.guide/04.algorithms",{"title":335,"path":336,"stem":337},"算法思想","/document/js-algorithms/guide/heuristic","document/07.js-algorithms/01.guide/05.heuristic",{"title":339,"path":340,"stem":341},"深度优先与广度优先搜索","/document/js-algorithms/guide/search","document/07.js-algorithms/01.guide/06.search",{"title":43,"path":343,"stem":344,"children":345,"icon":49},"/document/js-algorithms/examine","document/07.js-algorithms/02.examine/01.index",[346],{"title":347,"path":343,"stem":344},"JavaScript 数据结构与算法 知识测验",{"title":349,"path":350,"stem":351,"children":352,"page":50},"Automation","/document/automation","document/08.automation",[353,363],{"title":15,"path":354,"stem":355,"children":356,"icon":41},"/document/automation/guide","document/08.automation/01.guide/01.index",[357,359],{"title":358,"path":354,"stem":355},"什么是前端工程化？",{"title":360,"path":361,"stem":362},"开始搭建工程化项目","/document/automation/guide/start","document/08.automation/01.guide/02.start",{"title":43,"path":364,"stem":365,"children":366,"icon":49},"/document/automation/examine","document/08.automation/02.examine/01.index",[367],{"title":368,"path":364,"stem":365},"前端工程化 知识测验",{"title":370,"path":371,"stem":372,"children":373,"page":50},"Webpack","/document/webpack","document/09.webpack",[374,404],{"title":15,"path":375,"stem":376,"children":377,"icon":41},"/document/webpack/guide","document/09.webpack/01.guide/01.index",[378,380,384,388,392,396,400],{"title":379,"path":375,"stem":376},"Webpack 初识",{"title":381,"path":382,"stem":383},"搭建 Webpack 项目","/document/webpack/guide/start","document/09.webpack/01.guide/02.start",{"title":385,"path":386,"stem":387},"Loader 加载器","/document/webpack/guide/loader","document/09.webpack/01.guide/03.loader",{"title":389,"path":390,"stem":391},"Plugin 插件","/document/webpack/guide/plugin","document/09.webpack/01.guide/04.plugin",{"title":393,"path":394,"stem":395},"HMR 热更新与开发模式","/document/webpack/guide/dev","document/09.webpack/01.guide/05.dev",{"title":397,"path":398,"stem":399},"性能优化配置","/document/webpack/guide/optimize","document/09.webpack/01.guide/06.optimize",{"title":401,"path":402,"stem":403},"webpack 生产环境构建全攻略","/document/webpack/guide/production","document/09.webpack/01.guide/07.production",{"title":43,"path":405,"stem":406,"children":407,"icon":49},"/document/webpack/examine","document/09.webpack/02.examine/01.index",[408],{"title":409,"path":405,"stem":406},"Webpack 知识测验",{"title":411,"path":412,"stem":413,"children":414,"page":50},"Scss","/document/scss","document/10.scss",[415,449],{"title":15,"path":416,"stem":417,"children":418,"icon":41},"/document/scss/guide","document/10.scss/01.guide/01.index",[419,421,425,429,433,437,441,445],{"title":420,"path":416,"stem":417},"什么是 SCSS？",{"title":422,"path":423,"stem":424},"SCSS 入门语法基础","/document/scss/guide/syntax","document/10.scss/01.guide/02.syntax",{"title":426,"path":427,"stem":428},"开始编写 Scss 项目","/document/scss/guide/start","document/10.scss/01.guide/03.start",{"title":430,"path":431,"stem":432},"Scss 模块导入方式","/document/scss/guide/import","document/10.scss/01.guide/04.import",{"title":434,"path":435,"stem":436},"Mixin 与函数详解","/document/scss/guide/mixin","document/10.scss/01.guide/05.mixin",{"title":438,"path":439,"stem":440},"Scss 继承、占位符技巧","/document/scss/guide/extend","document/10.scss/01.guide/06.extend",{"title":442,"path":443,"stem":444},"SCSS 流程控制与逻辑语法","/document/scss/guide/flow","document/10.scss/01.guide/07.flow",{"title":446,"path":447,"stem":448},"SCSS 内置函数","/document/scss/guide/function","document/10.scss/01.guide/08.function",{"title":43,"path":450,"stem":451,"children":452,"icon":49},"/document/scss/examine","document/10.scss/02.examine/01.index",[453],{"title":454,"path":450,"stem":451},"SCSS 知识测验",{"title":456,"path":457,"stem":458,"children":459,"page":50},"Eslint","/document/eslint","document/11.eslint",[460,482],{"title":15,"path":461,"stem":462,"children":463,"icon":41},"/document/eslint/guide","document/11.eslint/01.guide/01.index",[464,466,470,474,478],{"title":465,"path":461,"stem":462},"ESLint 是什么？",{"title":467,"path":468,"stem":469},"ESLint 安装与运行详解","/document/eslint/guide/install","document/11.eslint/01.guide/02.install",{"title":471,"path":472,"stem":473},"ESLint  规则介绍","/document/eslint/guide/rule","document/11.eslint/01.guide/03.rule",{"title":475,"path":476,"stem":477},"集成 ESLint 到 Webpack","/document/eslint/guide/webpack","document/11.eslint/01.guide/04.webpack",{"title":479,"path":480,"stem":481},"Plugins 和 Extends 使用","/document/eslint/guide/plugins","document/11.eslint/01.guide/05.plugins",{"title":43,"path":483,"stem":484,"children":485,"icon":49},"/document/eslint/examine","document/11.eslint/02.examine/01.index",[486],{"title":487,"path":483,"stem":484},"ESLint 知识测验",{"title":489,"path":490,"stem":491,"children":492,"page":50},"Axios","/document/axios","document/12.axios",[493,503,522],{"title":15,"path":494,"stem":495,"children":496,"icon":41},"/document/axios/guide","document/12.axios/01.guide/01.index",[497,499],{"title":498,"path":494,"stem":495},"HTTP 协议与网络请求",{"title":500,"path":501,"stem":502},"使用 JavaScript 发起请求","/document/axios/guide/get","document/12.axios/01.guide/02.get",{"title":504,"path":505,"stem":506,"children":507,"icon":41},"axios 插件","/document/axios/axios","document/12.axios/02.axios/01.index",[508,510,514,518],{"title":509,"path":505,"stem":506},"Axios 入门",{"title":511,"path":512,"stem":513},"Axios 请求基础全面讲解","/document/axios/axios/start","document/12.axios/02.axios/02.start",{"title":515,"path":516,"stem":517},"Axios 高级使用技巧","/document/axios/axios/advenced","document/12.axios/02.axios/03.advenced",{"title":519,"path":520,"stem":521},"CORS 跨域解决方案","/document/axios/axios/cors","document/12.axios/02.axios/04.cors",{"title":43,"path":523,"stem":524,"children":525,"icon":49},"/document/axios/examine","document/12.axios/03.examine/01.index",[526],{"title":527,"path":523,"stem":524},"Axios 知识测验",{"title":529,"path":530,"stem":531,"children":532,"page":50},"Typescript","/document/typescript","document/13.typescript",[533,563],{"title":15,"path":534,"stem":535,"children":536,"icon":41},"/document/typescript/guide","document/13.typescript/01.guide/01.index",[537,539,543,547,551,555,559],{"title":538,"path":534,"stem":535},"TypeScript 简介与入门",{"title":540,"path":541,"stem":542},"类型系统基础","/document/typescript/guide/base","document/13.typescript/01.guide/02.base",{"title":544,"path":545,"stem":546},"类型组合与类型保护","/document/typescript/guide/compose","document/13.typescript/01.guide/03.compose",{"title":548,"path":549,"stem":550},"类与面向对象编程","/document/typescript/guide/class","document/13.typescript/01.guide/04.class",{"title":552,"path":553,"stem":554},"泛型与类型复用","/document/typescript/guide/generic","document/13.typescript/01.guide/05.generic",{"title":556,"path":557,"stem":558},"项目进阶与配置实战","/document/typescript/guide/config","document/13.typescript/01.guide/06.config",{"title":560,"path":561,"stem":562},"第三方库类型支持与声明","/document/typescript/guide/declare","document/13.typescript/01.guide/07.declare",{"title":43,"path":564,"stem":565,"children":566,"icon":49},"/document/typescript/examine","document/13.typescript/02.examine/01.index",[567],{"title":568,"path":564,"stem":565},"TypeScript 知识测验",{"title":570,"path":571,"stem":572,"children":573,"page":50},"Vue2","/document/vue2","document/14.vue2",[574],{"title":15,"path":575,"stem":576,"children":577,"icon":41},"/document/vue2/guide","document/14.vue2/01.guide/01.index",[578,580,584,588,592],{"title":579,"path":575,"stem":576},"Vue 2 入门与安装",{"title":581,"path":582,"stem":583},"模板语法与指令详解","/document/vue2/guide/directive","document/14.vue2/01.guide/02.directive",{"title":585,"path":586,"stem":587},"组件化开发基础","/document/vue2/guide/component","document/14.vue2/01.guide/03.component",{"title":589,"path":590,"stem":591},"计算属性与监听器","/document/vue2/guide/reactive","document/14.vue2/01.guide/04.reactive",{"title":593,"path":594,"stem":595},"生命周期钩子解析","/document/vue2/guide/hooks","document/14.vue2/01.guide/05.hooks",{"title":597,"path":598,"stem":599,"children":600,"page":50},"Router","/document/router","document/15.router",[601],{"title":602,"path":603,"stem":604,"children":605,"icon":41},"Vue Router 路由","/document/router/guide","document/15.router/01.guide/01.index",[606,608,612,616],{"title":607,"path":603,"stem":604},"Vue Router 入门",{"title":609,"path":610,"stem":611},"路由核心功能详解","/document/router/guide/routing","document/15.router/01.guide/02.routing",{"title":613,"path":614,"stem":615},"路由守卫钩子和元信息","/document/router/guide/hook","document/15.router/01.guide/03.hook",{"title":617,"path":618,"stem":619},"路由优化与懒加载","/document/router/guide/optimize","document/15.router/01.guide/04.optimize",{"title":621,"path":622,"stem":623,"children":624,"page":50},"Vuex","/document/vuex","document/16.vuex",[625],{"title":626,"path":627,"stem":628,"children":629,"icon":41},"Vuex 状态管理器","/document/vuex/guide","document/16.vuex/01.guide/01.index",[630,632,636,640],{"title":631,"path":627,"stem":628},"为什么要使用 Vuex？",{"title":633,"path":634,"stem":635},"快速上手 Vuex","/document/vuex/guide/start","document/16.vuex/01.guide/02.start",{"title":637,"path":638,"stem":639},"深入理解 Vuex 核心功能","/document/vuex/guide/core","document/16.vuex/01.guide/03.core",{"title":641,"path":642,"stem":643},"模块化与进阶用法","/document/vuex/guide/module","document/16.vuex/01.guide/04.module",{"title":645,"path":646,"stem":647,"children":648,"page":50},"Element Ui","/document/element-ui","document/17.element-ui",[649],{"title":650,"path":651,"stem":652,"children":653,"icon":41},"Element UI 组件库","/document/element-ui/guide","document/17.element-ui/01.guide/01.index",[654,656,660,664,668,672],{"title":655,"path":651,"stem":652},"Element UI 初体验",{"title":657,"path":658,"stem":659},"常用组件快速上手","/document/element-ui/guide/quickstart","document/17.element-ui/01.guide/02.quickstart",{"title":661,"path":662,"stem":663},"布局与结构类组件","/document/element-ui/guide/layout","document/17.element-ui/01.guide/03.layout",{"title":665,"path":666,"stem":667},"自定义组件样式","/document/element-ui/guide/style","document/17.element-ui/01.guide/04.style",{"title":669,"path":670,"stem":671},"组件封装与复用","/document/element-ui/guide/component","document/17.element-ui/01.guide/05.component",{"title":673,"path":674,"stem":675},"自定义主题色与深色模式","/document/element-ui/guide/theme","document/17.element-ui/01.guide/06.theme",{"title":677,"path":678,"stem":679,"children":680,"page":50},"Vue3","/document/vue3","document/18.vue3",[681],{"title":677,"path":682,"stem":683,"children":684,"icon":41},"/document/vue3/guide","document/18.vue3/01.guide/01.index",[685,687,691,695,699,703,707],{"title":686,"path":682,"stem":683},"Vue 3 概览与生态升级",{"title":688,"path":689,"stem":690},"组合式 API 入门指南","/document/vue3/guide/composition","document/18.vue3/01.guide/02.composition",{"title":692,"path":693,"stem":694},"组合式 API 逻辑抽离","/document/vue3/guide/composable","document/18.vue3/01.guide/03.composable",{"title":696,"path":697,"stem":698},"模板语法及新特性","/document/vue3/guide/features","document/18.vue3/01.guide/04.features",{"title":700,"path":701,"stem":702},"TypeScript 开发支持","/document/vue3/guide/typescript","document/18.vue3/01.guide/05.typescript",{"title":704,"path":705,"stem":706},"响应式系统原理与进阶 API","/document/vue3/guide/reactive","document/18.vue3/01.guide/06.reactive",{"title":708,"path":709,"stem":710},"Vue Router 4 路由实战","/document/vue3/guide/vue-router","document/18.vue3/01.guide/07.vue-router",{"title":712,"path":713,"stem":714,"children":715,"page":50},"Pinia","/document/pinia","document/19.pinia",[716],{"title":712,"path":717,"stem":718,"children":719,"icon":41},"/document/pinia/guide","document/19.pinia/01.guide/01.index",[720,722,726,730,734,738],{"title":721,"path":717,"stem":718},"Pinia 简介与安装",{"title":723,"path":724,"stem":725},"Store 三大核心","/document/pinia/guide/store","document/19.pinia/01.guide/02.store",{"title":727,"path":728,"stem":729},"在组件中使用 Store","/document/pinia/guide/usage","document/19.pinia/01.guide/03.usage",{"title":731,"path":732,"stem":733},"State 修改与响应式细节","/document/pinia/guide/state","document/19.pinia/01.guide/04.state",{"title":735,"path":736,"stem":737},"Action 与异步操作","/document/pinia/guide/action","document/19.pinia/01.guide/05.action",{"title":739,"path":740,"stem":741},"组合、TypeScript 与插件","/document/pinia/guide/advanced","document/19.pinia/01.guide/06.advanced",{"title":743,"path":744,"stem":745,"children":746,"page":50},"Vite","/document/vite","document/20.vite",[747],{"title":743,"path":748,"stem":749,"children":750,"icon":41},"/document/vite/guide","document/20.vite/01.guide/01.index",[751,753,757,761,765,769],{"title":752,"path":748,"stem":749},"Vite 简介与安装",{"title":754,"path":755,"stem":756},"基础配置","/document/vite/guide/config","document/20.vite/01.guide/02.config",{"title":758,"path":759,"stem":760},"常用插件","/document/vite/guide/plugins","document/20.vite/01.guide/03.plugins",{"title":762,"path":763,"stem":764},"环境变量与模式","/document/vite/guide/env","document/20.vite/01.guide/04.env",{"title":766,"path":767,"stem":768},"依赖预构建","/document/vite/guide/optimize-deps","document/20.vite/01.guide/05.optimize-deps",{"title":770,"path":771,"stem":772},"构建与部署","/document/vite/guide/build-deploy","document/20.vite/01.guide/06.build-deploy",{"title":774,"path":775,"stem":776,"children":777,"page":50},"Nuxt","/document/nuxt","document/21.nuxt",[778],{"title":779,"path":780,"stem":781,"children":782,"icon":41},"Nuxt.js","/document/nuxt/guide","document/21.nuxt/01.guide/01.index",[783,785,789,793,797,801],{"title":784,"path":780,"stem":781},"Nuxt.js 简介与安装",{"title":786,"path":787,"stem":788},"目录约定与自动导入","/document/nuxt/guide/directory-and-auto-imports","document/21.nuxt/01.guide/02.directory-and-auto-imports",{"title":790,"path":791,"stem":792},"文件路由与导航","/document/nuxt/guide/routing","document/21.nuxt/01.guide/03.routing",{"title":794,"path":795,"stem":796},"数据获取","/document/nuxt/guide/data-fetching","document/21.nuxt/01.guide/04.data-fetching",{"title":798,"path":799,"stem":800},"状态管理","/document/nuxt/guide/state-management","document/21.nuxt/01.guide/05.state-management",{"title":802,"path":803,"stem":804},"配置与部署","/document/nuxt/guide/config-and-deploy","document/21.nuxt/01.guide/06.config-and-deploy",{"title":806,"path":807,"stem":808,"children":809,"page":50},"Npm","/document/npm","document/22.npm",[810],{"title":811,"path":812,"stem":813,"children":814,"icon":841},"NPM","/document/npm/guide","document/22.npm/01.guide/01.index",[815,817,821,825,829,833,837],{"title":816,"path":812,"stem":813},"NPM 入门",{"title":818,"path":819,"stem":820},"package.json 详解","/document/npm/guide/package-json","document/22.npm/01.guide/02.package-json",{"title":822,"path":823,"stem":824},"安装命令与版本","/document/npm/guide/install-commands","document/22.npm/01.guide/03.install-commands",{"title":826,"path":827,"stem":828},"scripts 与 npx","/document/npm/guide/scripts-and-npx","document/22.npm/01.guide/04.scripts-and-npx",{"title":830,"path":831,"stem":832},"发布包与镜像源","/document/npm/guide/publish-and-registry","document/22.npm/01.guide/05.publish-and-registry",{"title":834,"path":835,"stem":836},"lock 文件与清理","/document/npm/guide/lock-and-clean","document/22.npm/01.guide/06.lock-and-clean",{"title":838,"path":839,"stem":840},"Yarn 与 pnpm","/document/npm/guide/yarn-and-pnpm","document/22.npm/01.guide/07.yarn-and-pnpm","i-simple-icons-npm",{"title":843,"icon":844,"path":845,"stem":846,"children":847,"page":50},"Handlebars","i-simple-icons-handlebarsdotjs","/document/handlebars","document/23.handlebars",[848],{"title":849,"path":850,"stem":851,"children":852},"Handlebars 简介","/document/handlebars/guide","document/23.handlebars/01.guide/01.index",[853,854,858,862,866,870],{"title":849,"path":850,"stem":851},{"title":855,"path":856,"stem":857},"基本语法","/document/handlebars/guide/syntax","document/23.handlebars/01.guide/02.syntax",{"title":859,"path":860,"stem":861},"内置辅助函数","/document/handlebars/guide/builtins","document/23.handlebars/01.guide/03.builtins",{"title":863,"path":864,"stem":865},"模板复用","/document/handlebars/guide/partials","document/23.handlebars/01.guide/04.partials",{"title":867,"path":868,"stem":869},"自定义 Helpers","/document/handlebars/guide/helpers","document/23.handlebars/01.guide/05.helpers",{"title":871,"path":872,"stem":873},"预编译与运行时","/document/handlebars/guide/runtime","document/23.handlebars/01.guide/06.runtime",{"title":875,"icon":876,"path":877,"stem":878,"children":879,"page":50},"Plop","i-simple-icons-nodedotjs","/document/plop","document/24.plop",[880],{"title":881,"path":882,"stem":883,"children":884},"Plop 简介","/document/plop/guide","document/24.plop/01.guide/01.index",[885,886,890,894,898,902,906],{"title":881,"path":882,"stem":883},{"title":887,"path":888,"stem":889},"第一个生成器","/document/plop/guide/plopfile","document/24.plop/01.guide/02.plopfile",{"title":891,"path":892,"stem":893},"交互式询问","/document/plop/guide/prompts","document/24.plop/01.guide/03.prompts",{"title":895,"path":896,"stem":897},"核心动作","/document/plop/guide/actions","document/24.plop/01.guide/04.actions",{"title":899,"path":900,"stem":901},"模板文件组织","/document/plop/guide/templates","document/24.plop/01.guide/05.templates",{"title":903,"path":904,"stem":905},"Helper 扩展","/document/plop/guide/helpers","document/24.plop/01.guide/06.helpers",{"title":907,"path":908,"stem":909},"组件生成实战","/document/plop/guide/practice","document/24.plop/01.guide/07.practice",{"title":911,"icon":912,"path":913,"stem":914,"children":915,"page":50},"Rollup","i-simple-icons-rollupdotjs","/document/rollup","document/25.rollup",[916],{"title":917,"path":918,"stem":919,"children":920},"Rollup 简介","/document/rollup/guide","document/25.rollup/01.guide/01.index",[921,922,925,929,932,936],{"title":917,"path":918,"stem":919},{"title":754,"path":923,"stem":924},"/document/rollup/guide/config","document/25.rollup/01.guide/02.config",{"title":926,"path":927,"stem":928},"输出格式","/document/rollup/guide/formats","document/25.rollup/01.guide/03.formats",{"title":758,"path":930,"stem":931},"/document/rollup/guide/plugins","document/25.rollup/01.guide/04.plugins",{"title":933,"path":934,"stem":935},"Tree Shaking","/document/rollup/guide/tree-shaking","document/25.rollup/01.guide/05.tree-shaking",{"title":937,"path":938,"stem":939},"打包工具库实战","/document/rollup/guide/library","document/25.rollup/01.guide/06.library",{"title":941,"icon":876,"path":942,"stem":943,"children":944,"page":50},"Snabbdom","/document/snabbdom","document/26.snabbdom",[945],{"title":946,"path":947,"stem":948,"children":949},"Snabbdom 简介","/document/snabbdom/guide","document/26.snabbdom/01.guide/01.index",[950,951,955,959,963,967,971],{"title":946,"path":947,"stem":948},{"title":952,"path":953,"stem":954},"h 函数","/document/snabbdom/guide/h","document/26.snabbdom/01.guide/02.h",{"title":956,"path":957,"stem":958},"模块机制","/document/snabbdom/guide/modules","document/26.snabbdom/01.guide/03.modules",{"title":960,"path":961,"stem":962},"patch 渲染与更新","/document/snabbdom/guide/patch","document/26.snabbdom/01.guide/04.patch",{"title":964,"path":965,"stem":966},"key 的作用","/document/snabbdom/guide/key","document/26.snabbdom/01.guide/05.key",{"title":968,"path":969,"stem":970},"Diff 原理","/document/snabbdom/guide/diff","document/26.snabbdom/01.guide/06.diff",{"title":972,"path":973,"stem":974},"手写迷你虚拟 DOM","/document/snabbdom/guide/practice","document/26.snabbdom/01.guide/07.practice",{"title":976,"icon":977,"path":978,"stem":979,"children":980,"page":50},"Vercel","i-simple-icons-vercel","/document/vercel","document/27.vercel",[981],{"title":982,"path":983,"stem":984,"children":985},"Vercel 简介","/document/vercel/guide","document/27.vercel/01.guide/01.index",[986,987,991,995,999,1003,1007],{"title":982,"path":983,"stem":984},{"title":988,"path":989,"stem":990},"Vercel CLI","/document/vercel/guide/cli","document/27.vercel/01.guide/02.cli",{"title":992,"path":993,"stem":994},"项目设置与环境变量","/document/vercel/guide/settings","document/27.vercel/01.guide/03.settings",{"title":996,"path":997,"stem":998},"预览部署与回滚","/document/vercel/guide/preview","document/27.vercel/01.guide/04.preview",{"title":1000,"path":1001,"stem":1002},"自定义域名","/document/vercel/guide/domain","document/27.vercel/01.guide/05.domain",{"title":1004,"path":1005,"stem":1006},"vercel.json 配置","/document/vercel/guide/vercel-json","document/27.vercel/01.guide/06.vercel-json",{"title":1008,"path":1009,"stem":1010},"Serverless Functions","/document/vercel/guide/serverless","document/27.vercel/01.guide/07.serverless",{"title":1012,"icon":1013,"path":1014,"stem":1015,"children":1016,"page":50},"ECharts","i-simple-icons-apacheecharts","/document/echarts","document/28.echarts",[1017],{"title":1018,"path":1019,"stem":1020,"children":1021},"ECharts 简介","/document/echarts/guide","document/28.echarts/01.guide/01.index",[1022,1023,1027,1031,1035,1039,1043],{"title":1018,"path":1019,"stem":1020},{"title":1024,"path":1025,"stem":1026},"核心配置项","/document/echarts/guide/option","document/28.echarts/01.guide/02.option",{"title":1028,"path":1029,"stem":1030},"常用图表类型","/document/echarts/guide/charts","document/28.echarts/01.guide/03.charts",{"title":1032,"path":1033,"stem":1034},"样式与主题","/document/echarts/guide/style","document/28.echarts/01.guide/04.style",{"title":1036,"path":1037,"stem":1038},"交互与事件","/document/echarts/guide/interaction","document/28.echarts/01.guide/05.interaction",{"title":1040,"path":1041,"stem":1042},"动态数据","/document/echarts/guide/data","document/28.echarts/01.guide/06.data",{"title":1044,"path":1045,"stem":1046},"Vue3 实战","/document/echarts/guide/vue","document/28.echarts/01.guide/07.vue",{"title":1048,"icon":1049,"path":1050,"stem":1051,"children":1052,"page":50},"D3","i-simple-icons-d3dotjs","/document/d3","document/29.d3",[1053],{"title":1054,"path":1055,"stem":1056,"children":1057},"D3 简介","/document/d3/guide","document/29.d3/01.guide/01.index",[1058,1059,1063,1067,1071,1075,1079,1083],{"title":1054,"path":1055,"stem":1056},{"title":1060,"path":1061,"stem":1062},"选择集与数据绑定","/document/d3/guide/selection","document/29.d3/01.guide/02.selection",{"title":1064,"path":1065,"stem":1066},"比例尺","/document/d3/guide/scale","document/29.d3/01.guide/03.scale",{"title":1068,"path":1069,"stem":1070},"坐标轴","/document/d3/guide/axis","document/29.d3/01.guide/04.axis",{"title":1072,"path":1073,"stem":1074},"图形生成器","/document/d3/guide/shape","document/29.d3/01.guide/05.shape",{"title":1076,"path":1077,"stem":1078},"过渡动画","/document/d3/guide/transition","document/29.d3/01.guide/06.transition",{"title":1080,"path":1081,"stem":1082},"交互与缩放","/document/d3/guide/interaction","document/29.d3/01.guide/07.interaction",{"title":1044,"path":1084,"stem":1085},"/document/d3/guide/vue","document/29.d3/01.guide/08.vue",{"title":1087,"icon":1088,"path":1089,"stem":1090,"children":1091,"page":50},"Three.js","i-simple-icons-threedotjs","/document/threejs","document/30.threejs",[1092,1106,1128,1146],{"title":1093,"path":1094,"stem":1095,"children":1096,"icon":1088},"Three.js 基础入门","/document/threejs/basics","document/30.threejs/01.basics/01.index",[1097,1098,1102],{"title":1093,"path":1094,"stem":1095},{"title":1099,"path":1100,"stem":1101},"物体变换","/document/threejs/basics/transform","document/30.threejs/01.basics/02.transform",{"title":1103,"path":1104,"stem":1105},"相机与视角","/document/threejs/basics/camera-controls","document/30.threejs/01.basics/03.camera-controls",{"title":1107,"icon":1108,"path":1109,"stem":1110,"children":1111,"page":50},"创建和组织三维场景","i-lucide-boxes","/document/threejs/scene","document/30.threejs/02.scene",[1112,1116,1120,1124],{"title":1113,"path":1114,"stem":1115},"Geometry 与 Mesh","/document/threejs/scene/geometry","document/30.threejs/02.scene/04.geometry",{"title":1117,"path":1118,"stem":1119},"材质与灯光","/document/threejs/scene/material-light","document/30.threejs/02.scene/05.material-light",{"title":1121,"path":1122,"stem":1123},"纹理与颜色空间","/document/threejs/scene/texture","document/30.threejs/02.scene/06.texture",{"title":1125,"path":1126,"stem":1127},"场景树与对象管理","/document/threejs/scene/scene-graph","document/30.threejs/02.scene/07.scene-graph",{"title":1129,"icon":1130,"path":1131,"stem":1132,"children":1133,"page":50},"模型、动画与交互","i-lucide-orbit","/document/threejs/model-interaction","document/30.threejs/03.model-interaction",[1134,1138,1142],{"title":1135,"path":1136,"stem":1137},"模型加载","/document/threejs/model-interaction/model-loading","document/30.threejs/03.model-interaction/08.model-loading",{"title":1139,"path":1140,"stem":1141},"动画循环","/document/threejs/model-interaction/animation-loop","document/30.threejs/03.model-interaction/09.animation-loop",{"title":1143,"path":1144,"stem":1145},"射线拾取与交互","/document/threejs/model-interaction/raycast-interaction","document/30.threejs/03.model-interaction/10.raycast-interaction",{"title":1147,"icon":1148,"path":1149,"stem":1150,"children":1151,"page":50},"工程化与性能","i-lucide-gauge","/document/threejs/engineering","document/30.threejs/04.engineering",[1152],{"title":1153,"path":1154,"stem":1155},"渲染器与性能","/document/threejs/engineering/renderer-performance","document/30.threejs/04.engineering/11.renderer-performance",{"title":1157,"icon":876,"path":1158,"stem":1159,"children":1160,"page":50},"Node.js 核心基础","/document/nodejs","document/32.nodejs",[1161,1176,1187,1222,1237],{"title":1162,"path":1163,"stem":1164,"children":1165},"Node.js 入门与运行环境","/document/nodejs/guide","document/32.nodejs/01.guide/01.index",[1166,1168,1172],{"title":1167,"path":1163,"stem":1164},"Node.js 简介与应用场景",{"title":1169,"path":1170,"stem":1171},"环境搭建","/document/nodejs/guide/setup","document/32.nodejs/01.guide/02.setup",{"title":1173,"path":1174,"stem":1175},"程序运行方式","/document/nodejs/guide/running","document/32.nodejs/01.guide/03.running",{"title":1177,"path":1178,"stem":1179,"children":1180},"Node.js 模块系统","/document/nodejs/modules","document/32.nodejs/02.modules/01.index",[1181,1183],{"title":1182,"path":1178,"stem":1179},"ESM 与 CommonJS",{"title":1184,"path":1185,"stem":1186},"模块加载机制","/document/nodejs/modules/loading","document/32.nodejs/02.modules/02.loading",{"title":1188,"path":1189,"stem":1190,"children":1191},"Node.js 核心内置模块","/document/nodejs/core","document/32.nodejs/03.core/01.index",[1192,1194,1198,1202,1206,1210,1214,1218],{"title":1193,"path":1189,"stem":1190},"path 路径处理",{"title":1195,"path":1196,"stem":1197},"fs 文件与目录","/document/nodejs/core/file-system","document/32.nodejs/03.core/02.file-system",{"title":1199,"path":1200,"stem":1201},"fs/promises 异步文件操作","/document/nodejs/core/fs-promises","document/32.nodejs/03.core/03.fs-promises",{"title":1203,"path":1204,"stem":1205},"Buffer 与字符编码","/document/nodejs/core/buffer","document/32.nodejs/03.core/04.buffer",{"title":1207,"path":1208,"stem":1209},"process 进程对象","/document/nodejs/core/process","document/32.nodejs/03.core/05.process",{"title":1211,"path":1212,"stem":1213},"events 事件模块","/document/nodejs/core/events","document/32.nodejs/03.core/06.events",{"title":1215,"path":1216,"stem":1217},"URL 与查询参数","/document/nodejs/core/url-query","document/32.nodejs/03.core/07.url-query",{"title":1219,"path":1220,"stem":1221},"crypto 常用能力","/document/nodejs/core/crypto","document/32.nodejs/03.core/08.crypto",{"title":1223,"path":1224,"stem":1225,"children":1226},"Node.js 异步 I/O 与运行机制","/document/nodejs/async","document/32.nodejs/04.async/01.index",[1227,1229,1233],{"title":1228,"path":1224,"stem":1225},"单线程与非阻塞 I/O",{"title":1230,"path":1231,"stem":1232},"事件循环","/document/nodejs/async/event-loop","document/32.nodejs/04.async/02.event-loop",{"title":1234,"path":1235,"stem":1236},"异步任务调度","/document/nodejs/async/scheduling","document/32.nodejs/04.async/03.scheduling",{"title":1238,"path":1239,"stem":1240,"children":1241},"Node.js Stream 与数据处理","/document/nodejs/streams","document/32.nodejs/05.streams/01.index",[1242],{"title":1243,"path":1239,"stem":1240},"Stream 数据处理",{"title":1245,"icon":1246,"path":1247,"stem":1248,"children":1249,"page":50},"Express","i-simple-icons-express","/document/express","document/33.express",[1250],{"title":1251,"path":1252,"stem":1253,"children":1254},"Express 简介","/document/express/guide","document/33.express/01.guide/01.index",[1255,1256,1260,1264,1268,1272],{"title":1251,"path":1252,"stem":1253},{"title":1257,"path":1258,"stem":1259},"路由","/document/express/guide/routing","document/33.express/01.guide/02.routing",{"title":1261,"path":1262,"stem":1263},"中间件","/document/express/guide/middleware","document/33.express/01.guide/03.middleware",{"title":1265,"path":1266,"stem":1267},"请求与响应","/document/express/guide/request-response","document/33.express/01.guide/04.request-response",{"title":1269,"path":1270,"stem":1271},"错误处理","/document/express/guide/error-handling","document/33.express/01.guide/05.error-handling",{"title":1273,"path":1274,"stem":1275},"RESTful 实战","/document/express/guide/restful-api","document/33.express/01.guide/06.restful-api",{"title":1277,"icon":1278,"path":1279,"stem":1280,"children":1281,"page":50},"Koa","i-simple-icons-koa","/document/koa","document/34.koa",[1282],{"title":1283,"path":1284,"stem":1285,"children":1286},"Koa 简介","/document/koa/guide","document/34.koa/01.guide/01.index",[1287,1288,1292,1296,1299,1303],{"title":1283,"path":1284,"stem":1285},{"title":1289,"path":1290,"stem":1291},"Context 上下文","/document/koa/guide/context","document/34.koa/01.guide/02.context",{"title":1293,"path":1294,"stem":1295},"中间件与洋葱模型","/document/koa/guide/middleware","document/34.koa/01.guide/03.middleware",{"title":1257,"path":1297,"stem":1298},"/document/koa/guide/routing","document/34.koa/01.guide/04.routing",{"title":1300,"path":1301,"stem":1302},"请求体与错误处理","/document/koa/guide/body-and-error","document/34.koa/01.guide/05.body-and-error",{"title":1304,"path":1305,"stem":1306},"RESTful 接口实战","/document/koa/guide/restful-api","document/34.koa/01.guide/06.restful-api",{"title":1308,"icon":1309,"path":1310,"stem":1311,"children":1312,"page":50},"Egg.js","i-lucide-egg","/document/egg","document/35.egg",[1313],{"title":1314,"path":1315,"stem":1316,"children":1317},"Egg.js 简介","/document/egg/guide","document/35.egg/01.guide/01.index",[1318,1319,1323,1327,1331,1335],{"title":1314,"path":1315,"stem":1316},{"title":1320,"path":1321,"stem":1322},"路由与 Controller","/document/egg/guide/router-controller","document/35.egg/01.guide/02.router-controller",{"title":1324,"path":1325,"stem":1326},"Service 业务逻辑","/document/egg/guide/service","document/35.egg/01.guide/03.service",{"title":1328,"path":1329,"stem":1330},"配置与中间件","/document/egg/guide/config-middleware","document/35.egg/01.guide/04.config-middleware",{"title":1332,"path":1333,"stem":1334},"插件与扩展","/document/egg/guide/plugin-extend","document/35.egg/01.guide/05.plugin-extend",{"title":1304,"path":1336,"stem":1337},"/document/egg/guide/restful-api","document/35.egg/01.guide/06.restful-api",{"title":1339,"icon":1340,"path":1341,"stem":1342,"children":1343,"page":50},"Docker","i-simple-icons-docker","/document/docker","document/36.docker",[1344],{"title":1345,"path":1346,"stem":1347,"children":1348},"Docker 简介","/document/docker/guide","document/36.docker/01.guide/01.index",[1349,1350,1354,1358,1362],{"title":1345,"path":1346,"stem":1347},{"title":1351,"path":1352,"stem":1353},"镜像与容器","/document/docker/guide/image-container","document/36.docker/01.guide/02.image-container",{"title":1355,"path":1356,"stem":1357},"数据卷","/document/docker/guide/volume","document/36.docker/01.guide/03.volume",{"title":1359,"path":1360,"stem":1361},"Dockerfile","/document/docker/guide/dockerfile","document/36.docker/01.guide/04.dockerfile",{"title":1363,"path":1364,"stem":1365},"Docker Compose","/document/docker/guide/docker-compose","document/36.docker/01.guide/05.docker-compose",{"title":1367,"icon":1368,"path":1369,"stem":1370,"children":1371,"page":50},"MySQL","i-simple-icons-mysql","/document/mysql","document/37.mysql",[1372,1387,1406,1421,1432],{"title":1373,"path":1374,"stem":1375,"children":1376},"基础入门","/document/mysql/guide","document/37.mysql/01.guide/01.index",[1377,1379,1383],{"title":1378,"path":1374,"stem":1375},"MySQL 入门",{"title":1380,"path":1381,"stem":1382},"建库与增删改","/document/mysql/guide/crud","document/37.mysql/01.guide/02.crud",{"title":1384,"path":1385,"stem":1386},"类型与约束","/document/mysql/guide/data-type","document/37.mysql/01.guide/03.data-type",{"title":1388,"path":1389,"stem":1390,"children":1391},"查询与统计","/document/mysql/query","document/37.mysql/02.query/01.index",[1392,1394,1398,1402],{"title":1393,"path":1389,"stem":1390},"条件查询与分页",{"title":1395,"path":1396,"stem":1397},"分组与统计","/document/mysql/query/aggregate","document/37.mysql/02.query/02.aggregate",{"title":1399,"path":1400,"stem":1401},"多表关联","/document/mysql/query/join","document/37.mysql/02.query/03.join",{"title":1403,"path":1404,"stem":1405},"子查询与分组排名","/document/mysql/query/subqueries","document/37.mysql/02.query/04.subqueries",{"title":1407,"path":1408,"stem":1409,"children":1410},"表设计与事务","/document/mysql/reliability","document/37.mysql/03.reliability/01.index",[1411,1413,1417],{"title":1412,"path":1408,"stem":1409},"关系设计",{"title":1414,"path":1415,"stem":1416},"事务与回滚","/document/mysql/reliability/transactions","document/37.mysql/03.reliability/02.transactions",{"title":1418,"path":1419,"stem":1420},"并发与锁","/document/mysql/reliability/concurrency","document/37.mysql/03.reliability/03.concurrency",{"title":1422,"path":1423,"stem":1424,"children":1425},"索引与性能","/document/mysql/performance","document/37.mysql/04.performance/01.index",[1426,1428],{"title":1427,"path":1423,"stem":1424},"索引设计",{"title":1429,"path":1430,"stem":1431},"执行计划与优化","/document/mysql/performance/explain","document/37.mysql/04.performance/02.explain",{"title":1433,"path":1434,"stem":1435,"children":1436},"项目接入与维护","/document/mysql/engineering","document/37.mysql/05.engineering/01.index",[1437,1439],{"title":1438,"path":1434,"stem":1435},"Node.js 接入",{"title":1440,"path":1441,"stem":1442},"备份与恢复","/document/mysql/engineering/backup","document/37.mysql/05.engineering/02.backup",{"title":1444,"icon":1445,"path":1446,"stem":1447,"children":1448,"page":50},"MongoDB","i-simple-icons-mongodb","/document/mongodb","document/38.mongodb",[1449],{"title":1450,"path":1451,"stem":1452,"children":1453},"MongoDB 简介","/document/mongodb/guide","document/38.mongodb/01.guide/01.index",[1454,1455,1459,1463,1467,1471,1475,1479],{"title":1450,"path":1451,"stem":1452},{"title":1456,"path":1457,"stem":1458},"增删改查","/document/mongodb/guide/crud","document/38.mongodb/01.guide/02.crud",{"title":1460,"path":1461,"stem":1462},"条件查询","/document/mongodb/guide/query","document/38.mongodb/01.guide/03.query",{"title":1464,"path":1465,"stem":1466},"文档与数据类型","/document/mongodb/guide/document","document/38.mongodb/01.guide/04.document",{"title":1468,"path":1469,"stem":1470},"Node.js 操作 MongoDB","/document/mongodb/guide/nodejs","document/38.mongodb/01.guide/05.nodejs",{"title":1472,"path":1473,"stem":1474},"Mongoose","/document/mongodb/guide/mongoose","document/38.mongodb/01.guide/06.mongoose",{"title":1476,"path":1477,"stem":1478},"索引","/document/mongodb/guide/optimize","document/38.mongodb/01.guide/07.optimize",{"title":1480,"path":1481,"stem":1482},"聚合管道","/document/mongodb/guide/aggregate","document/38.mongodb/01.guide/08.aggregate",{"title":1484,"icon":1485,"path":1486,"stem":1487,"children":1488,"page":50},"GraphQL","i-simple-icons-graphql","/document/graphql","document/39.graphql",[1489],{"title":1490,"path":1491,"stem":1492,"children":1493},"GraphQL 简介","/document/graphql/guide","document/39.graphql/01.guide/01.index",[1494,1495,1499,1503,1507,1511],{"title":1490,"path":1491,"stem":1492},{"title":1496,"path":1497,"stem":1498},"类型系统","/document/graphql/guide/schema","document/39.graphql/01.guide/02.schema",{"title":1500,"path":1501,"stem":1502},"查询进阶","/document/graphql/guide/query","document/39.graphql/01.guide/03.query",{"title":1504,"path":1505,"stem":1506},"Mutation 增删改","/document/graphql/guide/mutation","document/39.graphql/01.guide/04.mutation",{"title":1508,"path":1509,"stem":1510},"Express 集成","/document/graphql/guide/express","document/39.graphql/01.guide/05.express",{"title":1512,"path":1513,"stem":1514},"前端调用","/document/graphql/guide/client","document/39.graphql/01.guide/06.client",{"title":1516,"icon":1517,"path":1518,"stem":1519,"children":1520,"page":50},"Vue2 源码","i-simple-icons-vuedotjs","/document/source-vue2","document/40.source-vue2",[1521],{"title":1522,"path":1523,"stem":1524,"children":1525},"Vue2 源码简介","/document/source-vue2/guide","document/40.source-vue2/01.guide/01.index",[1526,1527,1531,1535,1539,1543,1547,1551],{"title":1522,"path":1523,"stem":1524},{"title":1528,"path":1529,"stem":1530},"初始化流程","/document/source-vue2/guide/init","document/40.source-vue2/01.guide/02.init",{"title":1532,"path":1533,"stem":1534},"响应式原理","/document/source-vue2/guide/reactive","document/40.source-vue2/01.guide/03.reactive",{"title":1536,"path":1537,"stem":1538},"Dep 与 Watcher","/document/source-vue2/guide/dep-watcher","document/40.source-vue2/01.guide/04.dep-watcher",{"title":1540,"path":1541,"stem":1542},"异步更新与 nextTick","/document/source-vue2/guide/nexttick","document/40.source-vue2/01.guide/05.nexttick",{"title":1544,"path":1545,"stem":1546},"虚拟 DOM 与 patch","/document/source-vue2/guide/vnode-patch","document/40.source-vue2/01.guide/06.vnode-patch",{"title":1548,"path":1549,"stem":1550},"模板编译","/document/source-vue2/guide/compile","document/40.source-vue2/01.guide/07.compile",{"title":1552,"path":1553,"stem":1554},"computed 与 watch 原理","/document/source-vue2/guide/computed-watch","document/40.source-vue2/01.guide/08.computed-watch",{"title":1556,"icon":1517,"path":1557,"stem":1558,"children":1559,"page":50},"Vue3 源码","/document/source-vue3","document/41.source-vue3",[1560],{"title":1561,"path":1562,"stem":1563,"children":1564},"Vue3 源码简介","/document/source-vue3/guide","document/41.source-vue3/01.guide/01.index",[1565,1566,1570,1574,1578,1582,1586,1589],{"title":1561,"path":1562,"stem":1563},{"title":1567,"path":1568,"stem":1569},"创建与挂载","/document/source-vue3/guide/create-app","document/41.source-vue3/01.guide/02.create-app",{"title":1571,"path":1572,"stem":1573},"Proxy 响应式","/document/source-vue3/guide/reactive","document/41.source-vue3/01.guide/03.reactive",{"title":1575,"path":1576,"stem":1577},"effect 与依赖收集","/document/source-vue3/guide/effect","document/41.source-vue3/01.guide/04.effect",{"title":1579,"path":1580,"stem":1581},"ref 与 computed","/document/source-vue3/guide/ref-computed","document/41.source-vue3/01.guide/05.ref-computed",{"title":1583,"path":1584,"stem":1585},"调度器与 nextTick","/document/source-vue3/guide/scheduler-nexttick","document/41.source-vue3/01.guide/06.scheduler-nexttick",{"title":1544,"path":1587,"stem":1588},"/document/source-vue3/guide/vnode-patch","document/41.source-vue3/01.guide/07.vnode-patch",{"title":1548,"path":1590,"stem":1591},"/document/source-vue3/guide/compile","document/41.source-vue3/01.guide/08.compile",{"title":1593,"icon":1594,"path":1595,"stem":1596,"children":1597,"page":50},"性能优化","i-lucide-zap","/document/performance","document/42.performance",[1598],{"title":1599,"path":1600,"stem":1601,"children":1602},"性能优化简介","/document/performance/guide","document/42.performance/01.guide/01.index",[1603,1604,1608,1612,1616,1620],{"title":1599,"path":1600,"stem":1601},{"title":1605,"path":1606,"stem":1607},"加载优化","/document/performance/guide/loading","document/42.performance/01.guide/02.loading",{"title":1609,"path":1610,"stem":1611},"渲染优化","/document/performance/guide/rendering","document/42.performance/01.guide/03.rendering",{"title":1613,"path":1614,"stem":1615},"缓存策略","/document/performance/guide/cache","document/42.performance/01.guide/04.cache",{"title":1617,"path":1618,"stem":1619},"构建产物优化","/document/performance/guide/build","document/42.performance/01.guide/05.build",{"title":1621,"path":1622,"stem":1623},"性能指标与工具","/document/performance/guide/metrics","document/42.performance/01.guide/06.metrics",{"title":1625,"icon":1626,"path":1627,"stem":1628,"children":1629,"page":50},"前端监控","i-lucide-activity","/document/monitor","document/43.monitor",[1630],{"title":1631,"path":1632,"stem":1633,"children":1634},"前端监控简介","/document/monitor/guide","document/43.monitor/01.guide/01.index",[1635,1636,1640,1644,1648,1652],{"title":1631,"path":1632,"stem":1633},{"title":1637,"path":1638,"stem":1639},"错误采集","/document/monitor/guide/error","document/43.monitor/01.guide/02.error",{"title":1641,"path":1642,"stem":1643},"埋点与上报","/document/monitor/guide/tracking","document/43.monitor/01.guide/03.tracking",{"title":1645,"path":1646,"stem":1647},"性能数据上报","/document/monitor/guide/performance-data","document/43.monitor/01.guide/04.performance-data",{"title":1649,"path":1650,"stem":1651},"Sentry 实践","/document/monitor/guide/sentry","document/43.monitor/01.guide/05.sentry",{"title":1653,"path":1654,"stem":1655},"日志与告警","/document/monitor/guide/logging","document/43.monitor/01.guide/06.logging",{"title":1657,"icon":1658,"path":1659,"stem":1660,"children":1661},"Electron：从入门到桌面应用交付","i-simple-icons-electron","/document/electron","document/44.electron/课程规划",[1662,1678,1696,1714,1731],{"title":1663,"path":1664,"stem":1665,"children":1666,"icon":1677},"基础架构","/document/electron/guide","document/44.electron/01.guide/01.index",[1667,1669,1673],{"title":1668,"path":1664,"stem":1665},"Electron 简介",{"title":1670,"path":1671,"stem":1672},"主进程、渲染进程与 preload","/document/electron/guide/process-model","document/44.electron/01.guide/02.process-model",{"title":1674,"path":1675,"stem":1676},"Electron 与 Vue 集成","/document/electron/guide/vue-integration","document/44.electron/01.guide/03.vue-integration","i-lucide-layers",{"title":1679,"icon":1680,"path":1681,"stem":1682,"children":1683,"page":50},"核心开发","i-lucide-code-2","/document/electron/core","document/44.electron/02.core",[1684,1688,1692],{"title":1685,"path":1686,"stem":1687},"创建窗口与应用生命周期","/document/electron/core/window-lifecycle","document/44.electron/02.core/04.window-lifecycle",{"title":1689,"path":1690,"stem":1691},"IPC 通信与接口设计","/document/electron/core/ipc-design","document/44.electron/02.core/05.ipc-design",{"title":1693,"path":1694,"stem":1695},"本地文件与系统交互","/document/electron/core/filesystem-system","document/44.electron/02.core/06.filesystem-system",{"title":1697,"icon":1698,"path":1699,"stem":1700,"children":1701,"page":50},"桌面能力与安全","i-lucide-monitor-cog","/document/electron/desktop","document/44.electron/03.desktop",[1702,1706,1710],{"title":1703,"path":1704,"stem":1705},"桌面端安全基础","/document/electron/desktop/security","document/44.electron/03.desktop/07.security",{"title":1707,"path":1708,"stem":1709},"菜单、托盘与多窗口","/document/electron/desktop/window-menu-tray","document/44.electron/03.desktop/08.window-menu-tray",{"title":1711,"path":1712,"stem":1713},"会话、网络与本地存储","/document/electron/desktop/session-storage","document/44.electron/03.desktop/09.session-storage",{"title":1715,"icon":1148,"path":1716,"stem":1717,"children":1718,"page":50},"资源、性能与导出","/document/electron/stability","document/44.electron/04.stability",[1719,1723,1727],{"title":1720,"path":1721,"stem":1722},"自定义协议、资源加载与深链接","/document/electron/stability/protocol-loading","document/44.electron/04.stability/10.protocol-loading",{"title":1724,"path":1725,"stem":1726},"耗时任务与性能排查","/document/electron/stability/tasks-performance","document/44.electron/04.stability/11.tasks-performance",{"title":1728,"path":1729,"stem":1730},"PDF 打印与报告导出","/document/electron/stability/pdf-report","document/44.electron/04.stability/12.pdf-report",{"title":1732,"icon":1733,"path":1734,"stem":1735,"children":1736,"page":50},"交付与实战","i-lucide-rocket","/document/electron/delivery","document/44.electron/05.delivery",[1737,1741,1745,1749],{"title":1738,"path":1739,"stem":1740},"应用打包与自动更新","/document/electron/delivery/package-update","document/44.electron/05.delivery/13.package-update",{"title":1742,"path":1743,"stem":1744},"桌面应用签名与公证","/document/electron/delivery/code-signing","document/44.electron/05.delivery/14.code-signing",{"title":1746,"path":1747,"stem":1748},"测试、监控与发布","/document/electron/delivery/test-monitor-release","document/44.electron/05.delivery/15.test-monitor-release",{"title":1750,"path":1751,"stem":1752},"实战：桌面资料管理工具","/document/electron/delivery/project-file-manager","document/44.electron/05.delivery/16.project-file-manager",{"title":1754,"icon":1755,"path":1756,"stem":1757,"children":1758,"page":50},"WebGIS","i-lucide-map","/document/webgis","document/45.webgis",[1759,1766,1779,1793,1811,1825],{"title":1760,"path":1761,"stem":1762,"children":1763,"icon":1755},"WebGIS 基础认知","/document/webgis/guide","document/45.webgis/01.guide/01.index",[1764],{"title":1765,"path":1761,"stem":1762},"WebGIS 全景",{"title":1767,"icon":236,"path":1768,"stem":1769,"children":1770,"page":50},"空间数据基础","/document/webgis/spatial","document/45.webgis/02.spatial",[1771,1775],{"title":1772,"path":1773,"stem":1774},"矢量与栅格","/document/webgis/spatial/vector-and-raster","document/45.webgis/02.spatial/02.vector-and-raster",{"title":1776,"path":1777,"stem":1778},"GeoJSON 与常见格式","/document/webgis/spatial/geojson-and-formats","document/45.webgis/02.spatial/03.geojson-and-formats",{"title":1780,"icon":1781,"path":1782,"stem":1783,"children":1784,"page":50},"坐标与地图投影","i-lucide-compass","/document/webgis/coordinate","document/45.webgis/03.coordinate",[1785,1789],{"title":1786,"path":1787,"stem":1788},"CRS 与地图投影","/document/webgis/coordinate/coordinate-reference-systems","document/45.webgis/03.coordinate/04.coordinate-reference-systems",{"title":1790,"path":1791,"stem":1792},"坐标转换与偏移","/document/webgis/coordinate/coordinate-offset","document/45.webgis/03.coordinate/05.coordinate-offset",{"title":1794,"icon":1795,"path":1796,"stem":1797,"children":1798,"page":50},"瓦片与地图服务","i-lucide-grid-2x2","/document/webgis/tiles","document/45.webgis/04.tiles",[1799,1803,1807],{"title":1800,"path":1801,"stem":1802},"地图瓦片","/document/webgis/tiles/map-tiles","document/45.webgis/04.tiles/06.map-tiles",{"title":1804,"path":1805,"stem":1806},"栅格与矢量瓦片","/document/webgis/tiles/raster-and-vector-tiles","document/45.webgis/04.tiles/07.raster-and-vector-tiles",{"title":1808,"path":1809,"stem":1810},"地图服务与 OGC","/document/webgis/tiles/map-services","document/45.webgis/04.tiles/08.map-services",{"title":1812,"icon":1813,"path":1814,"stem":1815,"children":1816,"page":50},"空间查询与分析","i-lucide-search","/document/webgis/analysis","document/45.webgis/05.analysis",[1817,1821],{"title":1818,"path":1819,"stem":1820},"空间查询与空间关系","/document/webgis/analysis/spatial-relationships","document/45.webgis/05.analysis/09.spatial-relationships",{"title":1822,"path":1823,"stem":1824},"距离、面积与空间分析","/document/webgis/analysis/distance-and-analysis","document/45.webgis/05.analysis/10.distance-and-analysis",{"title":1826,"icon":1827,"path":1828,"stem":1829,"children":1830,"page":50},"GIS 数据工程","i-lucide-database","/document/webgis/engineering","document/45.webgis/06.engineering",[1831,1835],{"title":1832,"path":1833,"stem":1834},"GIS 数据处理与清洗","/document/webgis/engineering/data-cleaning","document/45.webgis/06.engineering/11.data-cleaning",{"title":1836,"path":1837,"stem":1838},"海量数据展示","/document/webgis/engineering/large-data-display","document/45.webgis/06.engineering/12.large-data-display",{"title":1840,"icon":1841,"path":1842,"stem":1843,"children":1844,"page":50},"Mapbox GL JS","i-simple-icons-mapbox","/document/mapbox-gl-js","document/46.mapbox-gl-js",[1845,1860,1886],{"title":1846,"path":1847,"stem":1848,"children":1849,"icon":1755},"地图基础","/document/mapbox-gl-js/start","document/46.mapbox-gl-js/01.start/01.index",[1850,1852,1856],{"title":1851,"path":1847,"stem":1848},"Mapbox GL JS 入门",{"title":1853,"path":1854,"stem":1855},"初始化与视角控制","/document/mapbox-gl-js/start/view-control","document/46.mapbox-gl-js/01.start/02.view-control",{"title":1857,"path":1858,"stem":1859},"地图事件与基础控件","/document/mapbox-gl-js/start/events-controls","document/46.mapbox-gl-js/01.start/03.events-controls",{"title":1861,"icon":1862,"path":1863,"stem":1864,"children":1865,"page":50},"数据与样式","i-lucide-layers-3","/document/mapbox-gl-js/data","document/46.mapbox-gl-js/02.data",[1866,1870,1874,1878,1882],{"title":1867,"path":1868,"stem":1869},"Source 与 Layer","/document/mapbox-gl-js/data/source-layer","document/46.mapbox-gl-js/02.data/04.source-layer",{"title":1871,"path":1872,"stem":1873},"GeoJSON 点线面","/document/mapbox-gl-js/data/geojson-features","document/46.mapbox-gl-js/02.data/05.geojson-features",{"title":1875,"path":1876,"stem":1877},"样式与表达式","/document/mapbox-gl-js/data/style-expressions","document/46.mapbox-gl-js/02.data/06.style-expressions",{"title":1879,"path":1880,"stem":1881},"Marker、Popup 与 Symbol","/document/mapbox-gl-js/data/marker-popup-symbol","document/46.mapbox-gl-js/02.data/07.marker-popup-symbol",{"title":1883,"path":1884,"stem":1885},"加载瓦片服务","/document/mapbox-gl-js/data/tile-services","document/46.mapbox-gl-js/02.data/08.tile-services",{"title":1887,"icon":1888,"path":1889,"stem":1890,"children":1891,"page":50},"业务交互","i-lucide-map-pinned","/document/mapbox-gl-js/business","document/46.mapbox-gl-js/03.business",[1892,1896,1900,1904,1908],{"title":1893,"path":1894,"stem":1895},"查询与高亮","/document/mapbox-gl-js/business/query-highlight","document/46.mapbox-gl-js/03.business/08.query-highlight",{"title":1897,"path":1898,"stem":1899},"筛选与图层管理","/document/mapbox-gl-js/business/filter-layers","document/46.mapbox-gl-js/03.business/09.filter-layers",{"title":1901,"path":1902,"stem":1903},"点聚合","/document/mapbox-gl-js/business/clusters","document/46.mapbox-gl-js/03.business/10.clusters",{"title":1905,"path":1906,"stem":1907},"绘制、编辑与测量","/document/mapbox-gl-js/business/draw-measure","document/46.mapbox-gl-js/03.business/11.draw-measure",{"title":1909,"path":1910,"stem":1911},"接入 Three.js","/document/mapbox-gl-js/business/three-in-mapbox","document/46.mapbox-gl-js/03.business/12.three-in-mapbox",{"title":1913,"icon":1862,"path":1914,"stem":1915,"children":1916,"page":50},"deck.gl","/document/deck-gl","document/47.deck-gl",[1917,1932,1949],{"title":1918,"path":1919,"stem":1920,"children":1921},"deck.gl 基础入门","/document/deck-gl/basics","document/47.deck-gl/01.basics/01.index",[1922,1924,1928],{"title":1923,"path":1919,"stem":1920},"deck.gl 简介",{"title":1925,"path":1926,"stem":1927},"Layer、Data 与 Accessor","/document/deck-gl/basics/layer-data-accessor","document/47.deck-gl/01.basics/02.layer-data-accessor",{"title":1929,"path":1930,"stem":1931},"常用基础图层","/document/deck-gl/basics/common-layers","document/47.deck-gl/01.basics/03.common-layers",{"title":1933,"path":1934,"stem":1935,"children":1936,"page":50},"地图交互与 Mapbox 集成","/document/deck-gl/interaction-mapbox","document/47.deck-gl/02.interaction-mapbox",[1937,1941,1945],{"title":1938,"path":1939,"stem":1940},"拾取与 Tooltip","/document/deck-gl/interaction-mapbox/picking-tooltip","document/47.deck-gl/02.interaction-mapbox/04.picking-tooltip",{"title":1942,"path":1943,"stem":1944},"坐标与单位","/document/deck-gl/interaction-mapbox/coordinates-units","document/47.deck-gl/02.interaction-mapbox/05.coordinates-units",{"title":1946,"path":1947,"stem":1948},"deck.gl 与 Mapbox","/document/deck-gl/interaction-mapbox/mapbox-integration","document/47.deck-gl/02.interaction-mapbox/06.mapbox-integration",{"title":1950,"path":1951,"stem":1952,"children":1953,"page":50},"动态数据与专题可视化","/document/deck-gl/dynamic-thematic","document/47.deck-gl/03.dynamic-thematic",[1954,1958,1962,1966],{"title":1955,"path":1956,"stem":1957},"Layer 更新与动态数据","/document/deck-gl/dynamic-thematic/layer-updates","document/47.deck-gl/03.dynamic-thematic/07.layer-updates",{"title":1959,"path":1960,"stem":1961},"聚合与专题地图","/document/deck-gl/dynamic-thematic/aggregation-thematic","document/47.deck-gl/03.dynamic-thematic/08.aggregation-thematic",{"title":1963,"path":1964,"stem":1965},"时间序列与轨迹动画","/document/deck-gl/dynamic-thematic/trips-animation","document/47.deck-gl/03.dynamic-thematic/09.trips-animation",{"title":1967,"path":1968,"stem":1969},"瓦片与大规模空间数据","/document/deck-gl/dynamic-thematic/tiles-large-data","document/47.deck-gl/03.dynamic-thematic/10.tiles-large-data",{"title":1971,"icon":876,"path":1972,"stem":1973,"children":1974,"page":50},"HTTP 与后端开发基础","/document/nodejs-backend","document/48.nodejs-backend",[1975,1995,2014,2033,2052,2071,2086,2101],{"title":1976,"path":1977,"stem":1978,"children":1979,"icon":1994},"后端开发基础认知","/document/nodejs-backend/guide","document/48.nodejs-backend/01.guide/01.index",[1980,1982,1986,1990],{"title":1981,"path":1977,"stem":1978},"前端与后端的区别",{"title":1983,"path":1984,"stem":1985},"HTTP / HTTPS 核心原理","/document/nodejs-backend/guide/http-https","document/48.nodejs-backend/01.guide/02.http-https",{"title":1987,"path":1988,"stem":1989},"Cookie、Session 与浏览器同源策略","/document/nodejs-backend/guide/cookies-origin","document/48.nodejs-backend/01.guide/03.cookies-origin",{"title":1991,"path":1992,"stem":1993},"从浏览器发起请求到服务端返回数据的完整过程","/document/nodejs-backend/guide/request-lifecycle","document/48.nodejs-backend/01.guide/04.request-lifecycle","i-lucide-book-open",{"title":1996,"path":1997,"stem":1998,"children":1999,"icon":1994},"Node.js HTTP 服务开发","/document/nodejs-backend/http","document/48.nodejs-backend/02.http/01.index",[2000,2002,2006,2010],{"title":2001,"path":1997,"stem":1998},"使用原生 Node.js 创建 HTTP 服务器",{"title":2003,"path":2004,"stem":2005},"HTTP 请求解析","/document/nodejs-backend/http/request","document/48.nodejs-backend/02.http/02.request",{"title":2007,"path":2008,"stem":2009},"HTTP 响应处理","/document/nodejs-backend/http/response","document/48.nodejs-backend/02.http/03.response",{"title":2011,"path":2012,"stem":2013},"路由匹配与请求处理流程","/document/nodejs-backend/http/routing","document/48.nodejs-backend/02.http/04.routing",{"title":2015,"path":2016,"stem":2017,"children":2018,"icon":1994},"RESTful API 接口设计","/document/nodejs-backend/api","document/48.nodejs-backend/03.api/01.index",[2019,2021,2025,2029],{"title":2020,"path":2016,"stem":2017},"RESTful API 设计规范与 HTTP 请求方法",{"title":2022,"path":2023,"stem":2024},"接口参数校验与数据格式规范","/document/nodejs-backend/api/validation","document/48.nodejs-backend/03.api/02.validation",{"title":2026,"path":2027,"stem":2028},"统一响应格式、错误码与异常处理","/document/nodejs-backend/api/errors","document/48.nodejs-backend/03.api/03.errors",{"title":2030,"path":2031,"stem":2032},"API 版本管理、分页、筛选、排序与接口文档","/document/nodejs-backend/api/query-contract","document/48.nodejs-backend/03.api/04.query-contract",{"title":2034,"path":2035,"stem":2036,"children":2037,"icon":1994},"身份认证与权限控制","/document/nodejs-backend/auth","document/48.nodejs-backend/04.auth/01.index",[2038,2040,2044,2048],{"title":2039,"path":2035,"stem":2036},"身份认证与权限授权",{"title":2041,"path":2042,"stem":2043},"Session、JWT 与 Token 认证机制","/document/nodejs-backend/auth/session-jwt","document/48.nodejs-backend/04.auth/02.session-jwt",{"title":2045,"path":2046,"stem":2047},"Access Token、Refresh Token 与登录状态管理","/document/nodejs-backend/auth/token-lifecycle","document/48.nodejs-backend/04.auth/03.token-lifecycle",{"title":2049,"path":2050,"stem":2051},"RBAC 权限模型与接口级权限控制","/document/nodejs-backend/auth/rbac","document/48.nodejs-backend/04.auth/04.rbac",{"title":2053,"path":2054,"stem":2055,"children":2056,"icon":1994},"后端安全与风险防护","/document/nodejs-backend/security","document/48.nodejs-backend/05.security/01.index",[2057,2059,2063,2067],{"title":2058,"path":2054,"stem":2055},"CORS 跨域机制与跨域请求处理",{"title":2060,"path":2061,"stem":2062},"XSS、CSRF、SQL 注入与常见 Web 安全风险","/document/nodejs-backend/security/web-risks","document/48.nodejs-backend/05.security/02.web-risks",{"title":2064,"path":2065,"stem":2066},"密码安全","/document/nodejs-backend/security/passwords","document/48.nodejs-backend/05.security/03.passwords",{"title":2068,"path":2069,"stem":2070},"接口防护","/document/nodejs-backend/security/request-protection","document/48.nodejs-backend/05.security/04.request-protection",{"title":2072,"path":2073,"stem":2074,"children":2075,"icon":1994},"后端工程化与架构设计","/document/nodejs-backend/architecture","document/48.nodejs-backend/06.architecture/01.index",[2076,2078,2082],{"title":2077,"path":2073,"stem":2074},"后端项目目录结构与分层架构设计",{"title":2079,"path":2080,"stem":2081},"Controller、Service、Repository 的职责划分","/document/nodejs-backend/architecture/layers","document/48.nodejs-backend/06.architecture/02.layers",{"title":2083,"path":2084,"stem":2085},"环境变量、配置管理、日志与统一异常处理","/document/nodejs-backend/architecture/configuration-logging","document/48.nodejs-backend/06.architecture/03.configuration-logging",{"title":2087,"path":2088,"stem":2089,"children":2090,"icon":1994},"常见后端业务场景","/document/nodejs-backend/business","document/48.nodejs-backend/07.business/01.index",[2091,2093,2097],{"title":2092,"path":2088,"stem":2089},"文件上传、下载与静态资源访问",{"title":2094,"path":2095,"stem":2096},"邮件、验证码与第三方服务接口集成","/document/nodejs-backend/business/integrations","document/48.nodejs-backend/07.business/02.integrations",{"title":2098,"path":2099,"stem":2100},"WebSocket、SSE 与实时消息通信","/document/nodejs-backend/business/realtime","document/48.nodejs-backend/07.business/03.realtime",{"title":2102,"path":2103,"stem":2104,"children":2105,"icon":1994},"接口测试与部署基础","/document/nodejs-backend/delivery","document/48.nodejs-backend/08.delivery/01.index",[2106,2108],{"title":2107,"path":2103,"stem":2104},"使用 Postman / Apifox 调试接口与 Node.js 接口自动化测试",{"title":2109,"path":2110,"stem":2111},"Node.js 服务部署入门","/document/nodejs-backend/delivery/deployment","document/48.nodejs-backend/08.delivery/02.deployment",{"title":2113,"icon":2114,"path":2115,"stem":2116,"children":2117,"page":50},"Redis","i-simple-icons-redis","/document/redis","document/50.redis",[2118,2133,2148,2159],{"title":2119,"path":2120,"stem":2121,"children":2122},"Redis 基础与数据结构","/document/redis/guide","document/50.redis/01.guide/01.index",[2123,2125,2129],{"title":2124,"path":2120,"stem":2121},"简介与 Node.js 集成",{"title":2126,"path":2127,"stem":2128},"核心数据类型与常用操作","/document/redis/guide/data-types","document/50.redis/01.guide/02.data-types",{"title":2130,"path":2131,"stem":2132},"Key 管理与过期时间","/document/redis/guide/keys-expiration","document/50.redis/01.guide/03.keys-expiration",{"title":2134,"path":2135,"stem":2136,"children":2137},"Redis 核心机制","/document/redis/mechanisms","document/50.redis/02.mechanisms/01.index",[2138,2140,2144],{"title":2139,"path":2135,"stem":2136},"原子操作、事务与 Pipeline",{"title":2141,"path":2142,"stem":2143},"内存管理与淘汰策略","/document/redis/mechanisms/memory-eviction","document/50.redis/02.mechanisms/02.memory-eviction",{"title":2145,"path":2146,"stem":2147},"持久化机制","/document/redis/mechanisms/persistence","document/50.redis/02.mechanisms/03.persistence",{"title":2149,"path":2150,"stem":2151,"children":2152},"Redis 在 Node.js 中的应用","/document/redis/applications","document/50.redis/03.applications/01.index",[2153,2155],{"title":2154,"path":2150,"stem":2151},"实现数据缓存",{"title":2156,"path":2157,"stem":2158},"缓存常见问题与解决方案","/document/redis/applications/cache-protection","document/50.redis/03.applications/02.cache-protection",{"title":2160,"path":2161,"stem":2162,"children":2163},"Redis 生产实践","/document/redis/production","document/50.redis/04.production/01.index",[2164],{"title":2165,"path":2161,"stem":2162},"连接管理、安全与性能排查",{"title":2167,"icon":2168,"path":2169,"stem":2170,"children":2171,"page":50},"BullMQ","i-lucide-list-todo","/document/bullmq","document/51.bullmq",[2172,2183,2198],{"title":2173,"path":2174,"stem":2175,"children":2176},"BullMQ 基础","/document/bullmq/guide","document/51.bullmq/01.guide/01.index",[2177,2179],{"title":2178,"path":2174,"stem":2175},"简介与快速入门",{"title":2180,"path":2181,"stem":2182},"Queue、Worker 与 Job","/document/bullmq/guide/queue-worker-job","document/51.bullmq/01.guide/02.queue-worker-job",{"title":2184,"path":2185,"stem":2186,"children":2187},"任务调度与管理","/document/bullmq/scheduling","document/51.bullmq/02.scheduling/01.index",[2188,2190,2194],{"title":2189,"path":2185,"stem":2186},"延迟任务与定时任务",{"title":2191,"path":2192,"stem":2193},"任务并发与速率限制","/document/bullmq/scheduling/concurrency-rate-limiting","document/51.bullmq/02.scheduling/02.concurrency-rate-limiting",{"title":2195,"path":2196,"stem":2197},"任务状态、进度与事件监听","/document/bullmq/scheduling/status-progress-events","document/51.bullmq/02.scheduling/03.status-progress-events",{"title":2199,"path":2200,"stem":2201,"children":2202},"任务可靠性","/document/bullmq/reliability","document/51.bullmq/03.reliability/01.index",[2203],{"title":2204,"path":2200,"stem":2201},"任务失败重试与异常处理",{"title":2206,"icon":2207,"path":2208,"stem":2209,"children":2210,"page":50},"RabbitMQ","i-simple-icons-rabbitmq","/document/rabbitmq","document/52.rabbitmq",[2211,2229,2244,2263],{"title":1373,"path":2212,"stem":2213,"children":2214},"/document/rabbitmq/guide","document/52.rabbitmq/01.guide/01.index",[2215,2217,2221,2225],{"title":2216,"path":2212,"stem":2213},"RabbitMQ 简介",{"title":2218,"path":2219,"stem":2220},"安装与连接","/document/rabbitmq/guide/environment","document/52.rabbitmq/01.guide/02.environment",{"title":2222,"path":2223,"stem":2224},"发送和接收一条消息","/document/rabbitmq/guide/first-message","document/52.rabbitmq/01.guide/03.first-message",{"title":2226,"path":2227,"stem":2228},"消息正文与属性","/document/rabbitmq/guide/message-format","document/52.rabbitmq/01.guide/04.message-format",{"title":2230,"path":2231,"stem":2232,"children":2233},"交换机与路由","/document/rabbitmq/routing","document/52.rabbitmq/02.routing/01.index",[2234,2236,2240],{"title":2235,"path":2231,"stem":2232},"交换机与发布订阅",{"title":2237,"path":2238,"stem":2239},"Direct 交换机的精确路由","/document/rabbitmq/routing/direct","document/52.rabbitmq/02.routing/02.direct",{"title":2241,"path":2242,"stem":2243},"Topic 交换机的通配符路由","/document/rabbitmq/routing/topic","document/52.rabbitmq/02.routing/03.topic",{"title":2245,"path":2246,"stem":2247,"children":2248},"消息可靠性","/document/rabbitmq/reliability","document/52.rabbitmq/03.reliability/01.index",[2249,2251,2255,2259],{"title":2250,"path":2246,"stem":2247},"消息处理与消费确认",{"title":2252,"path":2253,"stem":2254},"发布确认与消息退回","/document/rabbitmq/reliability/publisher-confirms","document/52.rabbitmq/03.reliability/02.publisher-confirms",{"title":2256,"path":2257,"stem":2258},"队列与消息持久化","/document/rabbitmq/reliability/persistence","document/52.rabbitmq/03.reliability/03.persistence",{"title":2260,"path":2261,"stem":2262},"消费失败与死信处理","/document/rabbitmq/reliability/dead-letter","document/52.rabbitmq/03.reliability/04.dead-letter",{"title":2264,"path":2265,"stem":2266,"children":2267},"消费与运行管理","/document/rabbitmq/management","document/52.rabbitmq/04.management/01.index",[2268,2270],{"title":2269,"path":2265,"stem":2266},"多消费者与预取控制",{"title":2271,"path":2272,"stem":2273},"队列状态与故障排查","/document/rabbitmq/management/monitoring","document/52.rabbitmq/04.management/02.monitoring",{"title":2275,"icon":2276,"path":2277,"stem":2278,"children":2279,"page":50},"Socket.IO","i-simple-icons-socketdotio","/document/socket-io","document/53.socket-io",[2280,2295,2310,2321],{"title":2281,"path":2282,"stem":2283,"children":2284},"认识与消息收发","/document/socket-io/guide","document/53.socket-io/01.guide/01.index",[2285,2287,2291],{"title":2286,"path":2282,"stem":2283},"Socket.IO 简介与环境搭建",{"title":2288,"path":2289,"stem":2290},"事件发送与监听","/document/socket-io/guide/events","document/53.socket-io/01.guide/02.events",{"title":2292,"path":2293,"stem":2294},"消息确认与输入校验","/document/socket-io/guide/acknowledgements","document/53.socket-io/01.guide/03.acknowledgements",{"title":2296,"path":2297,"stem":2298,"children":2299},"广播、房间与认证","/document/socket-io/messaging","document/53.socket-io/02.messaging/01.index",[2300,2302,2306],{"title":2301,"path":2297,"stem":2298},"广播与消息接收范围",{"title":2303,"path":2304,"stem":2305},"房间加入与分组聊天","/document/socket-io/messaging/rooms","document/53.socket-io/02.messaging/02.rooms",{"title":2307,"path":2308,"stem":2309},"身份认证与房间权限","/document/socket-io/messaging/authentication","document/53.socket-io/02.messaging/03.authentication",{"title":2311,"path":2312,"stem":2313,"children":2314},"断线与消息补取","/document/socket-io/reliability","document/53.socket-io/03.reliability/01.index",[2315,2317],{"title":2316,"path":2312,"stem":2313},"断线重连与状态提示",{"title":2318,"path":2319,"stem":2320},"最近消息与断线补取","/document/socket-io/reliability/history","document/53.socket-io/03.reliability/02.history",{"title":2322,"path":2323,"stem":2324,"children":2325},"部署与故障排查","/document/socket-io/production","document/53.socket-io/04.production/01.index",[2326],{"title":2327,"path":2323,"stem":2324},"服务部署与常见故障排查",{"title":2329,"icon":2330,"path":2331,"stem":2332,"children":2333,"page":50},"Nginx","i-simple-icons-nginx","/document/nginx","document/55.nginx",[2334,2353,2372,2387],{"title":2335,"path":2336,"stem":2337,"children":2338},"认识与运行","/document/nginx/guide","document/55.nginx/01.guide/01.index",[2339,2341,2345,2349],{"title":2340,"path":2336,"stem":2337},"Nginx 课程概览",{"title":2342,"path":2343,"stem":2344},"安装与实验环境","/document/nginx/guide/install","document/55.nginx/01.guide/02.install",{"title":2346,"path":2347,"stem":2348},"配置结构","/document/nginx/guide/configuration","document/55.nginx/01.guide/03.configuration",{"title":2350,"path":2351,"stem":2352},"启动与重载","/document/nginx/guide/lifecycle","document/55.nginx/01.guide/04.lifecycle",{"title":2354,"path":2355,"stem":2356,"children":2357},"发布静态网站","/document/nginx/website","document/55.nginx/02.website/01.index",[2358,2360,2364,2368],{"title":2359,"path":2355,"stem":2356},"静态文件与目录",{"title":2361,"path":2362,"stem":2363},"站点与路径匹配","/document/nginx/website/location","document/55.nginx/02.website/02.location",{"title":2365,"path":2366,"stem":2367},"前端路由与回退","/document/nginx/website/spa-routing","document/55.nginx/02.website/03.spa-routing",{"title":2369,"path":2370,"stem":2371},"缓存与压缩","/document/nginx/website/cache-gzip","document/55.nginx/02.website/04.cache-gzip",{"title":2373,"path":2374,"stem":2375,"children":2376},"代理与服务分流","/document/nginx/proxy","document/55.nginx/03.proxy/01.index",[2377,2379,2383],{"title":2378,"path":2374,"stem":2375},"反向代理入门",{"title":2380,"path":2381,"stem":2382},"转发信息与超时","/document/nginx/proxy/forwarded-headers","document/55.nginx/03.proxy/02.forwarded-headers",{"title":2384,"path":2385,"stem":2386},"负载均衡","/document/nginx/proxy/load-balancing","document/55.nginx/03.proxy/03.load-balancing",{"title":2388,"path":2389,"stem":2390,"children":2391},"排错与发布","/document/nginx/operations","document/55.nginx/04.operations/01.index",[2392,2394,2398],{"title":2393,"path":2389,"stem":2390},"日志与故障排查",{"title":2395,"path":2396,"stem":2397},"大小与速率限制","/document/nginx/operations/request-limits","document/55.nginx/04.operations/02.request-limits",{"title":2399,"path":2400,"stem":2401},"HTTPS 与证书","/document/nginx/operations/https","document/55.nginx/04.operations/03.https",{"title":2403,"icon":2404,"path":2405,"stem":2406,"children":2407,"page":50},"Linux 与服务器基础","i-simple-icons-linux","/document/linux","document/56.linux",[2408,2435,2458],{"title":2409,"path":2410,"stem":2411,"children":2412},"Linux 入门与基本操作","/document/linux/guide","document/56.linux/01.guide/01.index",[2413,2415,2419,2423,2427,2431],{"title":2414,"path":2410,"stem":2411},"Linux 课程概览",{"title":2416,"path":2417,"stem":2418},"文件系统与目录","/document/linux/guide/filesystem","document/56.linux/01.guide/02.filesystem",{"title":2420,"path":2421,"stem":2422},"文件查看与 Vim","/document/linux/guide/editing","document/56.linux/01.guide/03.editing",{"title":2424,"path":2425,"stem":2426},"搜索、管道与重定向","/document/linux/guide/search-pipelines","document/56.linux/01.guide/04.search-pipelines",{"title":2428,"path":2429,"stem":2430},"用户、用户组与权限","/document/linux/guide/permissions","document/56.linux/01.guide/05.permissions",{"title":2432,"path":2433,"stem":2434},"SSH 与文件传输","/document/linux/guide/ssh","document/56.linux/01.guide/06.ssh",{"title":2436,"path":2437,"stem":2438,"children":2439},"Linux 服务器管理","/document/linux/server","document/56.linux/02.server/01.index",[2440,2442,2446,2450,2454],{"title":2441,"path":2437,"stem":2438},"软件包与环境变量",{"title":2443,"path":2444,"stem":2445},"进程与后台运行","/document/linux/server/processes","document/56.linux/02.server/02.processes",{"title":2447,"path":2448,"stem":2449},"systemd 服务管理","/document/linux/server/systemd","document/56.linux/02.server/03.systemd",{"title":2451,"path":2452,"stem":2453},"系统资源与磁盘","/document/linux/server/resources","document/56.linux/02.server/05.resources",{"title":2455,"path":2456,"stem":2457},"系统与应用日志","/document/linux/server/logs","document/56.linux/02.server/06.logs",{"title":2459,"path":2460,"stem":2461,"children":2462},"Shell 与服务器实战","/document/linux/practice","document/56.linux/03.practice/01.index",[2463,2465,2469],{"title":2464,"path":2460,"stem":2461},"Bash 脚本入门",{"title":2466,"path":2467,"stem":2468},"cron 定时任务","/document/linux/practice/cron","document/56.linux/03.practice/02.cron",{"title":2470,"path":2471,"stem":2472},"服务器基础安全","/document/linux/practice/security","document/56.linux/03.practice/03.security",{"title":2474,"icon":2475,"path":2476,"stem":2477,"children":2478,"page":50},"BFF 与多服务架构","i-lucide-network","/document/backend-architecture","document/57.backend-architecture",[2479,2494],{"title":2480,"path":2481,"stem":2482,"children":2483},"BFF 基础与实践","/document/backend-architecture/guide","document/57.backend-architecture/01.guide/01.index",[2484,2486,2490],{"title":2485,"path":2481,"stem":2482},"BFF 概览",{"title":2487,"path":2488,"stem":2489},"接口聚合","/document/backend-architecture/guide/aggregation","document/57.backend-architecture/01.guide/02.aggregation",{"title":2491,"path":2492,"stem":2493},"接口适配与职责边界","/document/backend-architecture/guide/adaptation","document/57.backend-architecture/01.guide/03.adaptation",{"title":2495,"path":2496,"stem":2497,"children":2498},"多服务拆分与协作","/document/backend-architecture/services","document/57.backend-architecture/02.services/01.index",[2499,2501,2505,2509],{"title":2500,"path":2496,"stem":2497},"从单体到多服务",{"title":2502,"path":2503,"stem":2504},"HTTP 服务协作","/document/backend-architecture/services/http-collaboration","document/57.backend-architecture/02.services/02.http-collaboration",{"title":2506,"path":2507,"stem":2508},"统一 API 入口","/document/backend-architecture/services/api-entry","document/57.backend-architecture/02.services/03.api-entry",{"title":2510,"path":2511,"stem":2512},"服务调用故障处理","/document/backend-architecture/services/failure-handling","document/57.backend-architecture/02.services/04.failure-handling",{"title":2514,"icon":2475,"path":2515,"stem":2516,"children":2517,"page":50},"微服务架构","/document/microservices","document/58.microservices",[2518,2537,2556],{"title":2519,"path":2520,"stem":2521,"children":2522},"微服务架构与设计","/document/microservices/guide","document/58.microservices/01.guide/01.index",[2523,2525,2529,2533],{"title":2524,"path":2520,"stem":2521},"微服务架构简介",{"title":2526,"path":2527,"stem":2528},"微服务的设计与拆分","/document/microservices/guide/service-design","document/58.microservices/01.guide/02.service-design",{"title":2530,"path":2531,"stem":2532},"项目结构与搭建","/document/microservices/guide/project-setup","document/58.microservices/01.guide/03.project-setup",{"title":2534,"path":2535,"stem":2536},"服务通信与发现","/document/microservices/guide/communication-discovery","document/58.microservices/01.guide/04.communication-discovery",{"title":2538,"path":2539,"stem":2540,"children":2541},"微服务业务开发","/document/microservices/development","document/58.microservices/02.development/01.index",[2542,2544,2548,2552],{"title":2543,"path":2539,"stem":2540},"数据库设计",{"title":2545,"path":2546,"stem":2547},"业务事件","/document/microservices/development/business-events","document/58.microservices/02.development/02.business-events",{"title":2549,"path":2550,"stem":2551},"分布式事务与数据一致性","/document/microservices/development/distributed-transactions","document/58.microservices/02.development/03.distributed-transactions",{"title":2553,"path":2554,"stem":2555},"容错与可靠性","/document/microservices/development/resilience","document/58.microservices/02.development/04.resilience",{"title":2557,"path":2558,"stem":2559,"children":2560},"微服务运行与治理","/document/microservices/operations","document/58.microservices/03.operations/01.index",[2561,2563,2567],{"title":2562,"path":2558,"stem":2559},"安全",{"title":2564,"path":2565,"stem":2566},"可观测性","/document/microservices/operations/observability","document/58.microservices/03.operations/02.observability",{"title":2568,"path":2569,"stem":2570},"部署与扩容","/document/microservices/operations/deployment-scaling","document/58.microservices/03.operations/04.deployment-scaling",{"title":2572,"icon":2573,"path":2574,"stem":2575,"children":2576,"page":50},"Kubernetes 应用部署","i-simple-icons-kubernetes","/document/kubernetes","document/59.kubernetes",[2577,2600],{"title":2578,"path":2579,"stem":2580,"children":2581},"Kubernetes 基础与应用部署","/document/kubernetes/guide","document/59.kubernetes/01.guide/01.index",[2582,2584,2588,2592,2596],{"title":2583,"path":2579,"stem":2580},"Kubernetes 简介",{"title":2585,"path":2586,"stem":2587},"环境搭建与基本操作","/document/kubernetes/guide/setup","document/59.kubernetes/01.guide/02.setup",{"title":2589,"path":2590,"stem":2591},"Pod","/document/kubernetes/guide/pod","document/59.kubernetes/01.guide/03.pod",{"title":2593,"path":2594,"stem":2595},"Deployment","/document/kubernetes/guide/deployment","document/59.kubernetes/01.guide/04.deployment",{"title":2597,"path":2598,"stem":2599},"Service","/document/kubernetes/guide/service","document/59.kubernetes/01.guide/05.service",{"title":2601,"path":2602,"stem":2603,"children":2604,"page":50},"服务配置与运行管理","/document/kubernetes/management","document/59.kubernetes/02.management",[2605,2609,2613,2617,2621,2625,2629],{"title":2606,"path":2607,"stem":2608},"Gateway API","/document/kubernetes/management/gateway-api","document/59.kubernetes/02.management/06.gateway-api",{"title":2610,"path":2611,"stem":2612},"ConfigMap 与 Secret","/document/kubernetes/management/configmap-secret","document/59.kubernetes/02.management/07.configmap-secret",{"title":2614,"path":2615,"stem":2616},"健康检查","/document/kubernetes/management/probes","document/59.kubernetes/02.management/08.probes",{"title":2618,"path":2619,"stem":2620},"资源请求与限制","/document/kubernetes/management/resources","document/59.kubernetes/02.management/09.resources",{"title":2622,"path":2623,"stem":2624},"滚动更新与回滚","/document/kubernetes/management/rolling-update","document/59.kubernetes/02.management/10.rolling-update",{"title":2626,"path":2627,"stem":2628},"扩容与自动伸缩","/document/kubernetes/management/autoscaling","document/59.kubernetes/02.management/11.autoscaling",{"title":2630,"path":2631,"stem":2632},"存储与持久化","/document/kubernetes/management/storage","document/59.kubernetes/02.management/12.storage",{"title":2634,"icon":2635,"path":2636,"stem":2637,"children":2638,"page":50},"LLM 基础","i-lucide-brain","/document/llm","document/60.llm",[2639,2662,2681],{"title":2640,"path":2641,"stem":2642,"children":2643},"大语言模型基础","/document/llm/guide","document/60.llm/01.guide/01.index",[2644,2646,2650,2654,2658],{"title":2645,"path":2641,"stem":2642},"LLM 基础概览",{"title":2647,"path":2648,"stem":2649},"模型工作原理","/document/llm/guide/how-llms-work","document/60.llm/01.guide/02.how-llms-work",{"title":2651,"path":2652,"stem":2653},"Token 与上下文","/document/llm/guide/tokens-and-context-window","document/60.llm/01.guide/03.tokens-and-context-window",{"title":2655,"path":2656,"stem":2657},"模型类型与参数","/document/llm/guide/model-types-and-parameters","document/60.llm/01.guide/04.model-types-and-parameters",{"title":2659,"path":2660,"stem":2661},"Embedding 与语义","/document/llm/guide/embeddings","document/60.llm/01.guide/05.embeddings",{"title":2663,"path":2664,"stem":2665,"children":2666},"Prompt Engineering","/document/llm/prompt-engineering","document/60.llm/02.prompt-engineering/01.index",[2667,2669,2673,2677],{"title":2668,"path":2664,"stem":2665},"提示词工程简介",{"title":2670,"path":2671,"stem":2672},"角色与指令设计","/document/llm/prompt-engineering/roles-and-instructions","document/60.llm/02.prompt-engineering/02.roles-and-instructions",{"title":2674,"path":2675,"stem":2676},"Few-shot 示例引导","/document/llm/prompt-engineering/few-shot","document/60.llm/02.prompt-engineering/03.few-shot",{"title":2678,"path":2679,"stem":2680},"结构化输出与任务拆分","/document/llm/prompt-engineering/structured-output-and-complex-tasks","document/60.llm/02.prompt-engineering/04.structured-output-and-complex-tasks",{"title":2682,"path":2683,"stem":2684,"children":2685},"上下文工程与实践","/document/llm/context-engineering","document/60.llm/03.context-engineering/01.index",[2686,2688],{"title":2687,"path":2683,"stem":2684},"上下文工程基础",{"title":2689,"path":2690,"stem":2691},"提示词测试与优化","/document/llm/context-engineering/prompt-testing-and-optimization","document/60.llm/03.context-engineering/02.prompt-testing-and-optimization",{"title":2693,"icon":2694,"path":2695,"stem":2696,"children":2697,"page":50},"AI SDK","i-lucide-code-xml","/document/ai-sdk","document/61.ai-sdk",[2698,2717,2734],{"title":2699,"path":2700,"stem":2701,"children":2702},"基础调用","/document/ai-sdk/guide","document/61.ai-sdk/01.guide/01.index",[2703,2705,2709,2713],{"title":2704,"path":2700,"stem":2701},"AI SDK 简介",{"title":2706,"path":2707,"stem":2708},"文本生成与参数","/document/ai-sdk/guide/text-generation","document/61.ai-sdk/01.guide/02.text-generation",{"title":2710,"path":2711,"stem":2712},"消息管理与多轮对话","/document/ai-sdk/guide/conversation","document/61.ai-sdk/01.guide/03.conversation",{"title":2714,"path":2715,"stem":2716},"流式输出","/document/ai-sdk/guide/streaming","document/61.ai-sdk/01.guide/04.streaming",{"title":2718,"path":2719,"stem":2720,"children":2721,"page":50},"模型能力与接入","/document/ai-sdk/capabilities","document/61.ai-sdk/02.capabilities",[2722,2726,2730],{"title":2723,"path":2724,"stem":2725},"结构化输出","/document/ai-sdk/capabilities/structured-output","document/61.ai-sdk/02.capabilities/05.structured-output",{"title":2727,"path":2728,"stem":2729},"Function Calling","/document/ai-sdk/capabilities/function-calling","document/61.ai-sdk/02.capabilities/06.function-calling",{"title":2731,"path":2732,"stem":2733},"多模态输入","/document/ai-sdk/capabilities/multimodal","document/61.ai-sdk/02.capabilities/07.multimodal",{"title":2735,"path":2736,"stem":2737,"children":2738,"page":50},"应用开发实战","/document/ai-sdk/application","document/61.ai-sdk/03.application",[2739,2743],{"title":2740,"path":2741,"stem":2742},"AI 服务接口","/document/ai-sdk/application/express-api","document/61.ai-sdk/03.application/08.express-api",{"title":2744,"path":2745,"stem":2746},"对话历史持久化","/document/ai-sdk/application/persistence","document/61.ai-sdk/03.application/09.persistence",{"id":2748,"title":2744,"body":2749,"description":6626,"extension":6627,"links":6628,"meta":6629,"navigation":6630,"path":2745,"seo":6631,"stem":2746,"__hash__":6632},"docs/document/61.ai-sdk/03.application/09.persistence.md",{"type":2750,"value":2751,"toc":6607},"minimal",[2752,2757,2766,2774,2777,2781,2788,2851,2866,2883,2885,2889,2894,2897,3137,3151,3162,3201,3208,3259,3263,3269,3706,3719,3723,3733,3898,3920,3922,3926,3937,3941,3947,4152,4158,4162,4168,4358,4371,4375,4381,4385,5048,5062,5066,5079,5083,5810,5817,5829,5833,5838,6146,6152,6158,6160,6164,6167,6183,6186,6216,6221,6243,6253,6258,6309,6351,6356,6368,6371,6554,6560,6566,6568,6572,6580,6583,6585,6589,6592,6598,6600,6603],[2753,2754,2756],"h2",{"id":2755},"引言","🎯 引言",[2758,2759,2760,2761,2765],"p",{},"前面使用 ",[2762,2763,2764],"code",{},"history"," 数组管理多轮对话时，消息保存在 Node.js 内存里。服务一旦重启，原来的聊天记录就无法找回。",[2758,2767,2768,2769,2773],{},"这篇文章用已经学过的 MySQL 解决这个问题：",[2770,2771,2772],"strong",{},"保存用户与助手的消息；再次提问时，读取对应会话的历史，交给 Chat Completions。"," 我们会独立建立一个 Express 接口，按功能逐步写代码，最后验证重启服务后能否继续对话。",[2775,2776],"hr",{},[2753,2778,2780],{"id":2779},"聊天记录怎样区分","🧱 聊天记录怎样区分",[2758,2782,2783,2784,2787],{},"同一个用户可能同时聊两个话题，不能把所有消息混在一起。我们用一个会话 ID（",[2762,2785,2786],{},"sessionId","）来区分：",[2789,2790,2791,2807],"table",{},[2792,2793,2794],"thead",{},[2795,2796,2797,2801,2804],"tr",{},[2798,2799,2800],"th",{},"会话 ID（示意）",[2798,2802,2803],{},"role",[2798,2805,2806],{},"content",[2808,2809,2810,2822,2832,2841],"tbody",{},[2795,2811,2812,2816,2819],{},[2813,2814,2815],"td",{},"A",[2813,2817,2818],{},"user",[2813,2820,2821],{},"我正在学习 Vue 3",[2795,2823,2824,2826,2829],{},[2813,2825,2815],{},[2813,2827,2828],{},"assistant",[2813,2830,2831],{},"你想先了解哪部分？",[2795,2833,2834,2836,2838],{},[2813,2835,2815],{},[2813,2837,2818],{},[2813,2839,2840],{},"先讲响应式",[2795,2842,2843,2846,2848],{},[2813,2844,2845],{},"B",[2813,2847,2818],{},[2813,2849,2850],{},"Node.js 服务启动失败怎么办？",[2758,2852,2853,2854,2857,2858,2861,2862,2865],{},"因此，数据库需要两张表：",[2762,2855,2856],{},"sessions"," 保存会话，",[2762,2859,2860],{},"messages"," 保存消息，并用 ",[2762,2863,2864],{},"session_id"," 指明每条消息属于哪个会话。表中的 A、B 是为了演示，实际使用 UUID。",[2758,2867,2868,2871,2872,2875,2876,2879,2880,2882],{},[2770,2869,2870],{},"用户的问题和助手的回答都要保存。"," 比如助手先回答“常见的响应式 API 有 ",[2762,2873,2874],{},"ref()"," 和 ",[2762,2877,2878],{},"reactive()","”，用户接着问“第一个怎么用？”，模型需要看到上一轮助手的回答，才能知道“第一个”指的是 ",[2762,2881,2874],{},"。",[2775,2884],{},[2753,2886,2888],{"id":2887},"使用-mysql-保存和读取消息","🛠 使用 MySQL 保存和读取消息",[2890,2891,2893],"h3",{"id":2892},"_1-建表与配置","1. 建表与配置",[2758,2895,2896],{},"在已有的 MySQL 中执行：",[2898,2899,2904],"pre",{"className":2900,"code":2901,"language":2902,"meta":2903,"style":2903},"language-sql shiki shiki-themes material-theme-lighter material-theme material-theme-palenight","CREATE DATABASE IF NOT EXISTS ai_chat CHARACTER SET utf8mb4;\nUSE ai_chat;\n\nCREATE TABLE IF NOT EXISTS sessions (\n    id CHAR(36) PRIMARY KEY,\n    title VARCHAR(100) NOT NULL\n);\n\nCREATE TABLE IF NOT EXISTS messages (\n    id BIGINT PRIMARY KEY AUTO_INCREMENT,\n    session_id CHAR(36) NOT NULL,\n    role VARCHAR(20) NOT NULL,\n    content TEXT NOT NULL,\n    FOREIGN KEY (session_id) REFERENCES sessions(id)\n);\n","sql","",[2762,2905,2906,2941,2950,2957,2977,3002,3021,3027,3032,3048,3062,3081,3101,3115,3132],{"__ignoreMap":2903},[2907,2908,2911,2915,2918,2922,2925,2928,2932,2935,2938],"span",{"class":2909,"line":2910},"line",1,[2907,2912,2914],{"class":2913},"smPcV","CREATE",[2907,2916,2917],{"class":2913}," DATABASE",[2907,2919,2921],{"class":2920},"swgpB"," IF",[2907,2923,2924],{"class":2913}," NOT",[2907,2926,2927],{"class":2913}," EXISTS",[2907,2929,2931],{"class":2930},"sndM8"," ai_chat ",[2907,2933,2934],{"class":2913},"CHARACTER",[2907,2936,2937],{"class":2913}," SET",[2907,2939,2940],{"class":2930}," utf8mb4;\n",[2907,2942,2944,2947],{"class":2909,"line":2943},2,[2907,2945,2946],{"class":2913},"USE",[2907,2948,2949],{"class":2930}," ai_chat;\n",[2907,2951,2953],{"class":2909,"line":2952},3,[2907,2954,2956],{"emptyLinePlaceholder":2955},true,"\n",[2907,2958,2960,2962,2965,2967,2969,2971,2974],{"class":2909,"line":2959},4,[2907,2961,2914],{"class":2913},[2907,2963,2964],{"class":2913}," TABLE",[2907,2966,2921],{"class":2920},[2907,2968,2924],{"class":2913},[2907,2970,2927],{"class":2913},[2907,2972,2973],{"class":2913}," sessions",[2907,2975,2976],{"class":2930}," (\n",[2907,2978,2980,2983,2987,2990,2993,2996,2999],{"class":2909,"line":2979},5,[2907,2981,2982],{"class":2930},"    id ",[2907,2984,2986],{"class":2985},"s50WR","CHAR",[2907,2988,2989],{"class":2930},"(",[2907,2991,2992],{"class":2913},"36",[2907,2994,2995],{"class":2930},") ",[2907,2997,2998],{"class":2985},"PRIMARY KEY",[2907,3000,3001],{"class":2930},",\n",[2907,3003,3005,3008,3011,3013,3016,3018],{"class":2909,"line":3004},6,[2907,3006,3007],{"class":2930},"    title ",[2907,3009,3010],{"class":2985},"VARCHAR",[2907,3012,2989],{"class":2930},[2907,3014,3015],{"class":2913},"100",[2907,3017,2995],{"class":2930},[2907,3019,3020],{"class":2913},"NOT NULL\n",[2907,3022,3024],{"class":2909,"line":3023},7,[2907,3025,3026],{"class":2930},");\n",[2907,3028,3030],{"class":2909,"line":3029},8,[2907,3031,2956],{"emptyLinePlaceholder":2955},[2907,3033,3035,3037,3039,3041,3043,3045],{"class":2909,"line":3034},9,[2907,3036,2914],{"class":2913},[2907,3038,2964],{"class":2913},[2907,3040,2921],{"class":2920},[2907,3042,2924],{"class":2913},[2907,3044,2927],{"class":2913},[2907,3046,3047],{"class":2930}," messages (\n",[2907,3049,3051,3053,3056,3059],{"class":2909,"line":3050},10,[2907,3052,2982],{"class":2930},[2907,3054,3055],{"class":2985},"BIGINT",[2907,3057,3058],{"class":2985}," PRIMARY KEY",[2907,3060,3061],{"class":2930}," AUTO_INCREMENT,\n",[2907,3063,3065,3068,3070,3072,3074,3076,3079],{"class":2909,"line":3064},11,[2907,3066,3067],{"class":2930},"    session_id ",[2907,3069,2986],{"class":2985},[2907,3071,2989],{"class":2930},[2907,3073,2992],{"class":2913},[2907,3075,2995],{"class":2930},[2907,3077,3078],{"class":2913},"NOT NULL",[2907,3080,3001],{"class":2930},[2907,3082,3084,3087,3090,3092,3095,3097,3099],{"class":2909,"line":3083},12,[2907,3085,3086],{"class":2913},"    role",[2907,3088,3089],{"class":2985}," VARCHAR",[2907,3091,2989],{"class":2930},[2907,3093,3094],{"class":2913},"20",[2907,3096,2995],{"class":2930},[2907,3098,3078],{"class":2913},[2907,3100,3001],{"class":2930},[2907,3102,3104,3107,3110,3113],{"class":2909,"line":3103},13,[2907,3105,3106],{"class":2930},"    content ",[2907,3108,3109],{"class":2985},"TEXT",[2907,3111,3112],{"class":2913}," NOT NULL",[2907,3114,3001],{"class":2930},[2907,3116,3118,3121,3124,3127,3129],{"class":2909,"line":3117},14,[2907,3119,3120],{"class":2985},"    FOREIGN KEY",[2907,3122,3123],{"class":2930}," (session_id) ",[2907,3125,3126],{"class":2985},"REFERENCES",[2907,3128,2973],{"class":2913},[2907,3130,3131],{"class":2930},"(id)\n",[2907,3133,3135],{"class":2909,"line":3134},15,[2907,3136,3026],{"class":2930},[2758,3138,3139,3142,3143,3146,3147,3150],{},[2762,3140,3141],{},"messages.session_id"," 关联 ",[2762,3144,3145],{},"sessions.id","；查询某个会话时，只读取对应的消息。",[2762,3148,3149],{},"messages.id"," 用来确定本例中消息的保存顺序。",[2758,3152,3153,3154,3157,3158,3161],{},"新建 ",[2762,3155,3156],{},"ai-chat"," 项目目录，使用 ",[2770,3159,3160],{},"Node.js 24.x","，安装本篇需要的依赖：",[2898,3163,3167],{"className":3164,"code":3165,"language":3166,"meta":2903,"style":2903},"language-bash shiki shiki-themes material-theme-lighter material-theme material-theme-palenight","npm init -y\nnpm install --save-exact express@5.1.0 openai@7.62.0 mysql2@3.24.6\n","bash",[2762,3168,3169,3182],{"__ignoreMap":2903},[2907,3170,3171,3175,3179],{"class":2909,"line":2910},[2907,3172,3174],{"class":3173},"sYGMc","npm",[2907,3176,3178],{"class":3177},"sIEYB"," init",[2907,3180,3181],{"class":3177}," -y\n",[2907,3183,3184,3186,3189,3192,3195,3198],{"class":2909,"line":2943},[2907,3185,3174],{"class":3173},[2907,3187,3188],{"class":3177}," install",[2907,3190,3191],{"class":3177}," --save-exact",[2907,3193,3194],{"class":3177}," express@5.1.0",[2907,3196,3197],{"class":3177}," openai@7.62.0",[2907,3199,3200],{"class":3177}," mysql2@3.24.6\n",[2758,3202,3203,3204,3207],{},"创建 ",[2762,3205,3206],{},".env","，填入实际配置：",[2898,3209,3213],{"className":3210,"code":3211,"language":3212,"meta":2903,"style":2903},"language-dotenv shiki shiki-themes material-theme-lighter material-theme material-theme-palenight","AI_API_KEY=你的AIHubMix密钥\nAI_BASE_URL=https://aihubmix.com/v1\nAI_MODEL=gpt-4o-mini\n\nDB_HOST=127.0.0.1\nDB_PORT=3306\nDB_USER=root\nDB_PASSWORD=你的MySQL密码\nDB_NAME=ai_chat\n","dotenv",[2762,3214,3215,3220,3225,3230,3234,3239,3244,3249,3254],{"__ignoreMap":2903},[2907,3216,3217],{"class":2909,"line":2910},[2907,3218,3219],{},"AI_API_KEY=你的AIHubMix密钥\n",[2907,3221,3222],{"class":2909,"line":2943},[2907,3223,3224],{},"AI_BASE_URL=https://aihubmix.com/v1\n",[2907,3226,3227],{"class":2909,"line":2952},[2907,3228,3229],{},"AI_MODEL=gpt-4o-mini\n",[2907,3231,3232],{"class":2909,"line":2959},[2907,3233,2956],{"emptyLinePlaceholder":2955},[2907,3235,3236],{"class":2909,"line":2979},[2907,3237,3238],{},"DB_HOST=127.0.0.1\n",[2907,3240,3241],{"class":2909,"line":3004},[2907,3242,3243],{},"DB_PORT=3306\n",[2907,3245,3246],{"class":2909,"line":3023},[2907,3247,3248],{},"DB_USER=root\n",[2907,3250,3251],{"class":2909,"line":3029},[2907,3252,3253],{},"DB_PASSWORD=你的MySQL密码\n",[2907,3255,3256],{"class":2909,"line":3034},[2907,3257,3258],{},"DB_NAME=ai_chat\n",[2890,3260,3262],{"id":3261},"_2-创建会话","2. 创建会话",[2758,3264,3203,3265,3268],{},[2762,3266,3267],{},"09.store.mjs","。先连接数据库，并实现创建会话、检查会话是否存在这两个操作：",[2898,3270,3274],{"className":3271,"code":3272,"language":3273,"meta":2903,"style":2903},"language-js shiki shiki-themes material-theme-lighter material-theme material-theme-palenight","import mysql from \"mysql2/promise\";\nimport { randomUUID } from \"node:crypto\";\n\nconst pool = mysql.createPool({\n    host: process.env.DB_HOST,\n    port: Number(process.env.DB_PORT),\n    user: process.env.DB_USER,\n    password: process.env.DB_PASSWORD,\n    database: process.env.DB_NAME,\n    connectionLimit: 5\n});\n\nexport async function createSession() {\n    const id = randomUUID();\n    await pool.execute(\n        \"INSERT INTO sessions (id, title) VALUES (?, ?)\",\n        [id, \"新对话\"]\n    );\n    return id;\n}\n\nexport async function hasSession(id) {\n    const [rows] = await pool.execute(\n        \"SELECT id FROM sessions WHERE id = ?\",\n        [id]\n    );\n    return rows.length > 0;\n}\n","js",[2762,3275,3276,3301,3326,3330,3355,3379,3403,3423,3443,3463,3473,3483,3487,3507,3524,3540,3553,3575,3583,3593,3599,3604,3625,3652,3664,3673,3680,3701],{"__ignoreMap":2903},[2907,3277,3278,3282,3285,3288,3292,3295,3298],{"class":2909,"line":2910},[2907,3279,3281],{"class":3280},"s8pZq","import",[2907,3283,3284],{"class":2930}," mysql ",[2907,3286,3287],{"class":3280},"from",[2907,3289,3291],{"class":3290},"s86vT"," \"",[2907,3293,3294],{"class":3177},"mysql2/promise",[2907,3296,3297],{"class":3290},"\"",[2907,3299,3300],{"class":3290},";\n",[2907,3302,3303,3305,3308,3311,3314,3317,3319,3322,3324],{"class":2909,"line":2943},[2907,3304,3281],{"class":3280},[2907,3306,3307],{"class":3290}," {",[2907,3309,3310],{"class":2930}," randomUUID",[2907,3312,3313],{"class":3290}," }",[2907,3315,3316],{"class":3280}," from",[2907,3318,3291],{"class":3290},[2907,3320,3321],{"class":3177},"node:crypto",[2907,3323,3297],{"class":3290},[2907,3325,3300],{"class":3290},[2907,3327,3328],{"class":2909,"line":2952},[2907,3329,2956],{"emptyLinePlaceholder":2955},[2907,3331,3332,3335,3338,3341,3344,3347,3350,3352],{"class":2909,"line":2959},[2907,3333,3334],{"class":2985},"const",[2907,3336,3337],{"class":2930}," pool ",[2907,3339,3340],{"class":3290},"=",[2907,3342,3343],{"class":2930}," mysql",[2907,3345,3346],{"class":3290},".",[2907,3348,3349],{"class":2920},"createPool",[2907,3351,2989],{"class":2930},[2907,3353,3354],{"class":3290},"{\n",[2907,3356,3357,3361,3364,3367,3369,3372,3374,3377],{"class":2909,"line":2979},[2907,3358,3360],{"class":3359},"sd2Uz","    host",[2907,3362,3363],{"class":3290},":",[2907,3365,3366],{"class":2930}," process",[2907,3368,3346],{"class":3290},[2907,3370,3371],{"class":2930},"env",[2907,3373,3346],{"class":3290},[2907,3375,3376],{"class":2930},"DB_HOST",[2907,3378,3001],{"class":3290},[2907,3380,3381,3384,3386,3389,3392,3394,3396,3398,3401],{"class":2909,"line":3004},[2907,3382,3383],{"class":3359},"    port",[2907,3385,3363],{"class":3290},[2907,3387,3388],{"class":2920}," Number",[2907,3390,3391],{"class":2930},"(process",[2907,3393,3346],{"class":3290},[2907,3395,3371],{"class":2930},[2907,3397,3346],{"class":3290},[2907,3399,3400],{"class":2930},"DB_PORT)",[2907,3402,3001],{"class":3290},[2907,3404,3405,3408,3410,3412,3414,3416,3418,3421],{"class":2909,"line":3023},[2907,3406,3407],{"class":3359},"    user",[2907,3409,3363],{"class":3290},[2907,3411,3366],{"class":2930},[2907,3413,3346],{"class":3290},[2907,3415,3371],{"class":2930},[2907,3417,3346],{"class":3290},[2907,3419,3420],{"class":2930},"DB_USER",[2907,3422,3001],{"class":3290},[2907,3424,3425,3428,3430,3432,3434,3436,3438,3441],{"class":2909,"line":3029},[2907,3426,3427],{"class":3359},"    password",[2907,3429,3363],{"class":3290},[2907,3431,3366],{"class":2930},[2907,3433,3346],{"class":3290},[2907,3435,3371],{"class":2930},[2907,3437,3346],{"class":3290},[2907,3439,3440],{"class":2930},"DB_PASSWORD",[2907,3442,3001],{"class":3290},[2907,3444,3445,3448,3450,3452,3454,3456,3458,3461],{"class":2909,"line":3034},[2907,3446,3447],{"class":3359},"    database",[2907,3449,3363],{"class":3290},[2907,3451,3366],{"class":2930},[2907,3453,3346],{"class":3290},[2907,3455,3371],{"class":2930},[2907,3457,3346],{"class":3290},[2907,3459,3460],{"class":2930},"DB_NAME",[2907,3462,3001],{"class":3290},[2907,3464,3465,3468,3470],{"class":2909,"line":3050},[2907,3466,3467],{"class":3359},"    connectionLimit",[2907,3469,3363],{"class":3290},[2907,3471,3472],{"class":2913}," 5\n",[2907,3474,3475,3478,3481],{"class":2909,"line":3064},[2907,3476,3477],{"class":3290},"}",[2907,3479,3480],{"class":2930},")",[2907,3482,3300],{"class":3290},[2907,3484,3485],{"class":2909,"line":3083},[2907,3486,2956],{"emptyLinePlaceholder":2955},[2907,3488,3489,3492,3495,3498,3501,3504],{"class":2909,"line":3103},[2907,3490,3491],{"class":3280},"export",[2907,3493,3494],{"class":2985}," async",[2907,3496,3497],{"class":2985}," function",[2907,3499,3500],{"class":2920}," createSession",[2907,3502,3503],{"class":3290},"()",[2907,3505,3506],{"class":3290}," {\n",[2907,3508,3509,3512,3515,3518,3520,3522],{"class":2909,"line":3117},[2907,3510,3511],{"class":2985},"    const",[2907,3513,3514],{"class":2930}," id",[2907,3516,3517],{"class":3290}," =",[2907,3519,3310],{"class":2920},[2907,3521,3503],{"class":3359},[2907,3523,3300],{"class":3290},[2907,3525,3526,3529,3532,3534,3537],{"class":2909,"line":3134},[2907,3527,3528],{"class":3280},"    await",[2907,3530,3531],{"class":2930}," pool",[2907,3533,3346],{"class":3290},[2907,3535,3536],{"class":2920},"execute",[2907,3538,3539],{"class":3359},"(\n",[2907,3541,3543,3546,3549,3551],{"class":2909,"line":3542},16,[2907,3544,3545],{"class":3290},"        \"",[2907,3547,3548],{"class":3177},"INSERT INTO sessions (id, title) VALUES (?, ?)",[2907,3550,3297],{"class":3290},[2907,3552,3001],{"class":3290},[2907,3554,3556,3559,3562,3565,3567,3570,3572],{"class":2909,"line":3555},17,[2907,3557,3558],{"class":3359},"        [",[2907,3560,3561],{"class":2930},"id",[2907,3563,3564],{"class":3290},",",[2907,3566,3291],{"class":3290},[2907,3568,3569],{"class":3177},"新对话",[2907,3571,3297],{"class":3290},[2907,3573,3574],{"class":3359},"]\n",[2907,3576,3578,3581],{"class":2909,"line":3577},18,[2907,3579,3580],{"class":3359},"    )",[2907,3582,3300],{"class":3290},[2907,3584,3586,3589,3591],{"class":2909,"line":3585},19,[2907,3587,3588],{"class":3280},"    return",[2907,3590,3514],{"class":2930},[2907,3592,3300],{"class":3290},[2907,3594,3596],{"class":2909,"line":3595},20,[2907,3597,3598],{"class":3290},"}\n",[2907,3600,3602],{"class":2909,"line":3601},21,[2907,3603,2956],{"emptyLinePlaceholder":2955},[2907,3605,3607,3609,3611,3613,3616,3618,3621,3623],{"class":2909,"line":3606},22,[2907,3608,3491],{"class":3280},[2907,3610,3494],{"class":2985},[2907,3612,3497],{"class":2985},[2907,3614,3615],{"class":2920}," hasSession",[2907,3617,2989],{"class":3290},[2907,3619,3561],{"class":3620},"sK9QF",[2907,3622,3480],{"class":3290},[2907,3624,3506],{"class":3290},[2907,3626,3628,3630,3633,3636,3639,3641,3644,3646,3648,3650],{"class":2909,"line":3627},23,[2907,3629,3511],{"class":2985},[2907,3631,3632],{"class":3290}," [",[2907,3634,3635],{"class":2930},"rows",[2907,3637,3638],{"class":3290},"]",[2907,3640,3517],{"class":3290},[2907,3642,3643],{"class":3280}," await",[2907,3645,3531],{"class":2930},[2907,3647,3346],{"class":3290},[2907,3649,3536],{"class":2920},[2907,3651,3539],{"class":3359},[2907,3653,3655,3657,3660,3662],{"class":2909,"line":3654},24,[2907,3656,3545],{"class":3290},[2907,3658,3659],{"class":3177},"SELECT id FROM sessions WHERE id = ?",[2907,3661,3297],{"class":3290},[2907,3663,3001],{"class":3290},[2907,3665,3667,3669,3671],{"class":2909,"line":3666},25,[2907,3668,3558],{"class":3359},[2907,3670,3561],{"class":2930},[2907,3672,3574],{"class":3359},[2907,3674,3676,3678],{"class":2909,"line":3675},26,[2907,3677,3580],{"class":3359},[2907,3679,3300],{"class":3290},[2907,3681,3683,3685,3688,3690,3693,3696,3699],{"class":2909,"line":3682},27,[2907,3684,3588],{"class":3280},[2907,3686,3687],{"class":2930}," rows",[2907,3689,3346],{"class":3290},[2907,3691,3692],{"class":2930},"length",[2907,3694,3695],{"class":3290}," >",[2907,3697,3698],{"class":2913}," 0",[2907,3700,3300],{"class":3290},[2907,3702,3704],{"class":2909,"line":3703},28,[2907,3705,3598],{"class":3290},[2758,3707,3708,3711,3712,3714,3715,3718],{},[2762,3709,3710],{},"createSession()"," 在 ",[2762,3713,2856],{}," 表中插入一条记录，并返回生成的 ID；",[2762,3716,3717],{},"hasSession()"," 用来避免对不存在的会话保存或读取消息。",[2890,3720,3722],{"id":3721},"_3-保存与读取消息","3. 保存与读取消息",[2758,3724,3725,3726,3732],{},"继续在 ",[2770,3727,3728,3729,3731],{},"同一个 ",[2762,3730,3267],{}," 文件末尾"," 添加两个函数：",[2898,3734,3736],{"className":3271,"code":3735,"language":3273,"meta":2903,"style":2903},"export async function addMessage(sessionId, role, content) {\n    await pool.execute(\n        \"INSERT INTO messages (session_id, role, content) VALUES (?, ?, ?)\",\n        [sessionId, role, content]\n    );\n}\n\nexport async function getMessages(sessionId) {\n    const [rows] = await pool.execute(\n        \"SELECT role, content FROM messages WHERE session_id = ? ORDER BY id ASC\",\n        [sessionId]\n    );\n    return rows;\n}\n",[2762,3737,3738,3767,3779,3790,3806,3812,3816,3820,3839,3861,3872,3880,3886,3894],{"__ignoreMap":2903},[2907,3739,3740,3742,3744,3746,3749,3751,3753,3755,3758,3760,3763,3765],{"class":2909,"line":2910},[2907,3741,3491],{"class":3280},[2907,3743,3494],{"class":2985},[2907,3745,3497],{"class":2985},[2907,3747,3748],{"class":2920}," addMessage",[2907,3750,2989],{"class":3290},[2907,3752,2786],{"class":3620},[2907,3754,3564],{"class":3290},[2907,3756,3757],{"class":3620}," role",[2907,3759,3564],{"class":3290},[2907,3761,3762],{"class":3620}," content",[2907,3764,3480],{"class":3290},[2907,3766,3506],{"class":3290},[2907,3768,3769,3771,3773,3775,3777],{"class":2909,"line":2943},[2907,3770,3528],{"class":3280},[2907,3772,3531],{"class":2930},[2907,3774,3346],{"class":3290},[2907,3776,3536],{"class":2920},[2907,3778,3539],{"class":3359},[2907,3780,3781,3783,3786,3788],{"class":2909,"line":2952},[2907,3782,3545],{"class":3290},[2907,3784,3785],{"class":3177},"INSERT INTO messages (session_id, role, content) VALUES (?, ?, ?)",[2907,3787,3297],{"class":3290},[2907,3789,3001],{"class":3290},[2907,3791,3792,3794,3796,3798,3800,3802,3804],{"class":2909,"line":2959},[2907,3793,3558],{"class":3359},[2907,3795,2786],{"class":2930},[2907,3797,3564],{"class":3290},[2907,3799,3757],{"class":2930},[2907,3801,3564],{"class":3290},[2907,3803,3762],{"class":2930},[2907,3805,3574],{"class":3359},[2907,3807,3808,3810],{"class":2909,"line":2979},[2907,3809,3580],{"class":3359},[2907,3811,3300],{"class":3290},[2907,3813,3814],{"class":2909,"line":3004},[2907,3815,3598],{"class":3290},[2907,3817,3818],{"class":2909,"line":3023},[2907,3819,2956],{"emptyLinePlaceholder":2955},[2907,3821,3822,3824,3826,3828,3831,3833,3835,3837],{"class":2909,"line":3029},[2907,3823,3491],{"class":3280},[2907,3825,3494],{"class":2985},[2907,3827,3497],{"class":2985},[2907,3829,3830],{"class":2920}," getMessages",[2907,3832,2989],{"class":3290},[2907,3834,2786],{"class":3620},[2907,3836,3480],{"class":3290},[2907,3838,3506],{"class":3290},[2907,3840,3841,3843,3845,3847,3849,3851,3853,3855,3857,3859],{"class":2909,"line":3034},[2907,3842,3511],{"class":2985},[2907,3844,3632],{"class":3290},[2907,3846,3635],{"class":2930},[2907,3848,3638],{"class":3290},[2907,3850,3517],{"class":3290},[2907,3852,3643],{"class":3280},[2907,3854,3531],{"class":2930},[2907,3856,3346],{"class":3290},[2907,3858,3536],{"class":2920},[2907,3860,3539],{"class":3359},[2907,3862,3863,3865,3868,3870],{"class":2909,"line":3050},[2907,3864,3545],{"class":3290},[2907,3866,3867],{"class":3177},"SELECT role, content FROM messages WHERE session_id = ? ORDER BY id ASC",[2907,3869,3297],{"class":3290},[2907,3871,3001],{"class":3290},[2907,3873,3874,3876,3878],{"class":2909,"line":3064},[2907,3875,3558],{"class":3359},[2907,3877,2786],{"class":2930},[2907,3879,3574],{"class":3359},[2907,3881,3882,3884],{"class":2909,"line":3083},[2907,3883,3580],{"class":3359},[2907,3885,3300],{"class":3290},[2907,3887,3888,3890,3892],{"class":2909,"line":3103},[2907,3889,3588],{"class":3280},[2907,3891,3687],{"class":2930},[2907,3893,3300],{"class":3290},[2907,3895,3896],{"class":2909,"line":3117},[2907,3897,3598],{"class":3290},[2758,3899,3900,3903,3904,3907,3908,2875,3910,3912,3913,3915,3916,3919],{},[2762,3901,3902],{},"addMessage()"," 每次保存一条消息，",[2762,3905,3906],{},"getMessages()"," 按顺序取出当前会话的消息。查询只返回 ",[2762,3909,2803],{},[2762,3911,2806],{},"，因为本篇普通文本对话传给 Chat Completions 的 ",[2762,3914,2860],{}," 正好需要这两个字段。SQL 中的 ",[2762,3917,3918],{},"?"," 使用参数绑定，避免拼接用户输入。",[2775,3921],{},[2753,3923,3925],{"id":3924},"逐步建立聊天接口","🛠 逐步建立聊天接口",[2758,3927,3928,3929,3932,3933,3936],{},"下面创建 ",[2762,3930,3931],{},"09.server.mjs","，",[2770,3934,3935],{},"每个代码块都是往同一个文件末尾继续添加","，不需要重复复制已经写过的内容。",[2890,3938,3940],{"id":3939},"_1-初始化-express-与模型客户端","1. 初始化 Express 与模型客户端",[2758,3942,3943,3944,3946],{},"先在 ",[2762,3945,3931],{}," 中写入：",[2898,3948,3950],{"className":3271,"code":3949,"language":3273,"meta":2903,"style":2903},"import express from \"express\";\nimport OpenAI from \"openai\";\nimport { createSession, hasSession, addMessage, getMessages } from \"./09.store.mjs\";\n\nconst app = express();\nconst client = new OpenAI({\n    apiKey: process.env.AI_API_KEY,\n    baseURL: process.env.AI_BASE_URL\n});\n\napp.use(express.json({ limit: \"16kb\" }));\n",[2762,3951,3952,3970,3988,4021,4025,4041,4060,4080,4098,4106,4110],{"__ignoreMap":2903},[2907,3953,3954,3956,3959,3961,3963,3966,3968],{"class":2909,"line":2910},[2907,3955,3281],{"class":3280},[2907,3957,3958],{"class":2930}," express ",[2907,3960,3287],{"class":3280},[2907,3962,3291],{"class":3290},[2907,3964,3965],{"class":3177},"express",[2907,3967,3297],{"class":3290},[2907,3969,3300],{"class":3290},[2907,3971,3972,3974,3977,3979,3981,3984,3986],{"class":2909,"line":2943},[2907,3973,3281],{"class":3280},[2907,3975,3976],{"class":2930}," OpenAI ",[2907,3978,3287],{"class":3280},[2907,3980,3291],{"class":3290},[2907,3982,3983],{"class":3177},"openai",[2907,3985,3297],{"class":3290},[2907,3987,3300],{"class":3290},[2907,3989,3990,3992,3994,3996,3998,4000,4002,4004,4006,4008,4010,4012,4014,4017,4019],{"class":2909,"line":2952},[2907,3991,3281],{"class":3280},[2907,3993,3307],{"class":3290},[2907,3995,3500],{"class":2930},[2907,3997,3564],{"class":3290},[2907,3999,3615],{"class":2930},[2907,4001,3564],{"class":3290},[2907,4003,3748],{"class":2930},[2907,4005,3564],{"class":3290},[2907,4007,3830],{"class":2930},[2907,4009,3313],{"class":3290},[2907,4011,3316],{"class":3280},[2907,4013,3291],{"class":3290},[2907,4015,4016],{"class":3177},"./09.store.mjs",[2907,4018,3297],{"class":3290},[2907,4020,3300],{"class":3290},[2907,4022,4023],{"class":2909,"line":2959},[2907,4024,2956],{"emptyLinePlaceholder":2955},[2907,4026,4027,4029,4032,4034,4037,4039],{"class":2909,"line":2979},[2907,4028,3334],{"class":2985},[2907,4030,4031],{"class":2930}," app ",[2907,4033,3340],{"class":3290},[2907,4035,4036],{"class":2920}," express",[2907,4038,3503],{"class":2930},[2907,4040,3300],{"class":3290},[2907,4042,4043,4045,4048,4050,4053,4056,4058],{"class":2909,"line":3004},[2907,4044,3334],{"class":2985},[2907,4046,4047],{"class":2930}," client ",[2907,4049,3340],{"class":3290},[2907,4051,4052],{"class":3290}," new",[2907,4054,4055],{"class":2920}," OpenAI",[2907,4057,2989],{"class":2930},[2907,4059,3354],{"class":3290},[2907,4061,4062,4065,4067,4069,4071,4073,4075,4078],{"class":2909,"line":3023},[2907,4063,4064],{"class":3359},"    apiKey",[2907,4066,3363],{"class":3290},[2907,4068,3366],{"class":2930},[2907,4070,3346],{"class":3290},[2907,4072,3371],{"class":2930},[2907,4074,3346],{"class":3290},[2907,4076,4077],{"class":2930},"AI_API_KEY",[2907,4079,3001],{"class":3290},[2907,4081,4082,4085,4087,4089,4091,4093,4095],{"class":2909,"line":3029},[2907,4083,4084],{"class":3359},"    baseURL",[2907,4086,3363],{"class":3290},[2907,4088,3366],{"class":2930},[2907,4090,3346],{"class":3290},[2907,4092,3371],{"class":2930},[2907,4094,3346],{"class":3290},[2907,4096,4097],{"class":2930},"AI_BASE_URL\n",[2907,4099,4100,4102,4104],{"class":2909,"line":3034},[2907,4101,3477],{"class":3290},[2907,4103,3480],{"class":2930},[2907,4105,3300],{"class":3290},[2907,4107,4108],{"class":2909,"line":3050},[2907,4109,2956],{"emptyLinePlaceholder":2955},[2907,4111,4112,4115,4117,4120,4123,4125,4128,4130,4133,4136,4138,4140,4143,4145,4147,4150],{"class":2909,"line":3064},[2907,4113,4114],{"class":2930},"app",[2907,4116,3346],{"class":3290},[2907,4118,4119],{"class":2920},"use",[2907,4121,4122],{"class":2930},"(express",[2907,4124,3346],{"class":3290},[2907,4126,4127],{"class":2920},"json",[2907,4129,2989],{"class":2930},[2907,4131,4132],{"class":3290},"{",[2907,4134,4135],{"class":3359}," limit",[2907,4137,3363],{"class":3290},[2907,4139,3291],{"class":3290},[2907,4141,4142],{"class":3177},"16kb",[2907,4144,3297],{"class":3290},[2907,4146,3313],{"class":3290},[2907,4148,4149],{"class":2930},"))",[2907,4151,3300],{"class":3290},[2758,4153,4154,4155,4157],{},"数据库操作来自刚写好的 ",[2762,4156,3267],{},"。接下来只需要把它们放进对应的接口。",[2890,4159,4161],{"id":4160},"_2-创建会话接口","2. 创建会话接口",[2758,4163,4164,4165,4167],{},"在 ",[2762,4166,3931],{}," 末尾添加：",[2898,4169,4171],{"className":3271,"code":4170,"language":3273,"meta":2903,"style":2903},"app.post(\"/api/sessions\", async (req, res) => {\n    try {\n        const id = await createSession();\n        res.status(201).json({ id });\n    } catch (error) {\n        console.error(error);\n        res.status(500).json({ error: \"创建会话失败\" });\n    }\n});\n",[2762,4172,4173,4213,4220,4237,4270,4287,4304,4345,4350],{"__ignoreMap":2903},[2907,4174,4175,4177,4179,4182,4184,4186,4189,4191,4193,4195,4198,4201,4203,4206,4208,4211],{"class":2909,"line":2910},[2907,4176,4114],{"class":2930},[2907,4178,3346],{"class":3290},[2907,4180,4181],{"class":2920},"post",[2907,4183,2989],{"class":2930},[2907,4185,3297],{"class":3290},[2907,4187,4188],{"class":3177},"/api/sessions",[2907,4190,3297],{"class":3290},[2907,4192,3564],{"class":3290},[2907,4194,3494],{"class":2985},[2907,4196,4197],{"class":3290}," (",[2907,4199,4200],{"class":3620},"req",[2907,4202,3564],{"class":3290},[2907,4204,4205],{"class":3620}," res",[2907,4207,3480],{"class":3290},[2907,4209,4210],{"class":2985}," =>",[2907,4212,3506],{"class":3290},[2907,4214,4215,4218],{"class":2909,"line":2943},[2907,4216,4217],{"class":3280},"    try",[2907,4219,3506],{"class":3290},[2907,4221,4222,4225,4227,4229,4231,4233,4235],{"class":2909,"line":2952},[2907,4223,4224],{"class":2985},"        const",[2907,4226,3514],{"class":2930},[2907,4228,3517],{"class":3290},[2907,4230,3643],{"class":3280},[2907,4232,3500],{"class":2920},[2907,4234,3503],{"class":3359},[2907,4236,3300],{"class":3290},[2907,4238,4239,4242,4244,4247,4249,4252,4254,4256,4258,4260,4262,4264,4266,4268],{"class":2909,"line":2959},[2907,4240,4241],{"class":2930},"        res",[2907,4243,3346],{"class":3290},[2907,4245,4246],{"class":2920},"status",[2907,4248,2989],{"class":3359},[2907,4250,4251],{"class":2913},"201",[2907,4253,3480],{"class":3359},[2907,4255,3346],{"class":3290},[2907,4257,4127],{"class":2920},[2907,4259,2989],{"class":3359},[2907,4261,4132],{"class":3290},[2907,4263,3514],{"class":2930},[2907,4265,3313],{"class":3290},[2907,4267,3480],{"class":3359},[2907,4269,3300],{"class":3290},[2907,4271,4272,4275,4278,4280,4283,4285],{"class":2909,"line":2979},[2907,4273,4274],{"class":3290},"    }",[2907,4276,4277],{"class":3280}," catch",[2907,4279,4197],{"class":3359},[2907,4281,4282],{"class":2930},"error",[2907,4284,2995],{"class":3359},[2907,4286,3354],{"class":3290},[2907,4288,4289,4292,4294,4296,4298,4300,4302],{"class":2909,"line":3004},[2907,4290,4291],{"class":2930},"        console",[2907,4293,3346],{"class":3290},[2907,4295,4282],{"class":2920},[2907,4297,2989],{"class":3359},[2907,4299,4282],{"class":2930},[2907,4301,3480],{"class":3359},[2907,4303,3300],{"class":3290},[2907,4305,4306,4308,4310,4312,4314,4317,4319,4321,4323,4325,4327,4330,4332,4334,4337,4339,4341,4343],{"class":2909,"line":3023},[2907,4307,4241],{"class":2930},[2907,4309,3346],{"class":3290},[2907,4311,4246],{"class":2920},[2907,4313,2989],{"class":3359},[2907,4315,4316],{"class":2913},"500",[2907,4318,3480],{"class":3359},[2907,4320,3346],{"class":3290},[2907,4322,4127],{"class":2920},[2907,4324,2989],{"class":3359},[2907,4326,4132],{"class":3290},[2907,4328,4329],{"class":3359}," error",[2907,4331,3363],{"class":3290},[2907,4333,3291],{"class":3290},[2907,4335,4336],{"class":3177},"创建会话失败",[2907,4338,3297],{"class":3290},[2907,4340,3313],{"class":3290},[2907,4342,3480],{"class":3359},[2907,4344,3300],{"class":3290},[2907,4346,4347],{"class":2909,"line":3029},[2907,4348,4349],{"class":3290},"    }\n",[2907,4351,4352,4354,4356],{"class":2909,"line":3034},[2907,4353,3477],{"class":3290},[2907,4355,3480],{"class":2930},[2907,4357,3300],{"class":3290},[2758,4359,4360,4361,4364,4365,4367,4368,4370],{},"浏览器先调用 ",[2762,4362,4363],{},"POST /api/sessions","，拿到一个 ",[2762,4366,3561],{},"。之后在这个会话中提问，都携带同一个 ",[2762,4369,2786],{},"，后端才能找到对应的历史。",[2890,4372,4374],{"id":4373},"_3-处理模型的流式回答","3. 处理模型的流式回答",[2758,4376,4377,4378],{},"聊天接口要把模型返回的文字逐段转发给浏览器，但不能把每个片段都保存为单独的数据库消息。因此先增加一个处理函数：",[2770,4379,4380],{},"向浏览器发送每段文字，同时把文本拼接成一条完整的助手回答，结束后再保存。",[2758,4382,3725,4383,4167],{},[2762,4384,3931],{},[2898,4386,4388],{"className":3271,"code":4387,"language":3273,"meta":2903,"style":2903},"async function streamReply(sessionId, history, res, signal) {\n    const stream = await client.chat.completions.create({\n        model: process.env.AI_MODEL,\n        messages: history,\n        stream: true\n    }, { signal });\n\n    res.setHeader(\"Content-Type\", \"application/x-ndjson; charset=utf-8\");\n    res.setHeader(\"Cache-Control\", \"no-cache, no-transform\");\n    res.setHeader(\"X-Accel-Buffering\", \"no\");\n\n    let answer = \"\";\n    let finishReason = null;\n\n    for await (const chunk of stream) {\n        const choice = chunk.choices[0];\n        if (!choice) continue;\n\n        const text = choice.delta?.content;\n        if (text) {\n            answer += text;\n            res.write(JSON.stringify({ type: \"delta\", text }) + \"\\n\");\n        }\n        if (choice.finish_reason != null) {\n            finishReason = choice.finish_reason;\n        }\n    }\n\n    if (finishReason === null) {\n        throw new Error(\"模型流未正常结束\");\n    }\n\n    if (answer) {\n        await addMessage(sessionId, \"assistant\", answer);\n    }\n    res.write(JSON.stringify({ type: \"done\", finishReason }) + \"\\n\");\n    res.end();\n}\n",[2762,4389,4390,4422,4455,4475,4486,4497,4512,4516,4548,4578,4608,4612,4627,4639,4643,4666,4692,4712,4716,4739,4752,4764,4821,4826,4849,4864,4868,4872,4876,4896,4920,4925,4930,4944,4972,4977,5029,5043],{"__ignoreMap":2903},[2907,4391,4392,4395,4397,4400,4402,4404,4406,4409,4411,4413,4415,4418,4420],{"class":2909,"line":2910},[2907,4393,4394],{"class":2985},"async",[2907,4396,3497],{"class":2985},[2907,4398,4399],{"class":2920}," streamReply",[2907,4401,2989],{"class":3290},[2907,4403,2786],{"class":3620},[2907,4405,3564],{"class":3290},[2907,4407,4408],{"class":3620}," history",[2907,4410,3564],{"class":3290},[2907,4412,4205],{"class":3620},[2907,4414,3564],{"class":3290},[2907,4416,4417],{"class":3620}," signal",[2907,4419,3480],{"class":3290},[2907,4421,3506],{"class":3290},[2907,4423,4424,4426,4429,4431,4433,4436,4438,4441,4443,4446,4448,4451,4453],{"class":2909,"line":2943},[2907,4425,3511],{"class":2985},[2907,4427,4428],{"class":2930}," stream",[2907,4430,3517],{"class":3290},[2907,4432,3643],{"class":3280},[2907,4434,4435],{"class":2930}," client",[2907,4437,3346],{"class":3290},[2907,4439,4440],{"class":2930},"chat",[2907,4442,3346],{"class":3290},[2907,4444,4445],{"class":2930},"completions",[2907,4447,3346],{"class":3290},[2907,4449,4450],{"class":2920},"create",[2907,4452,2989],{"class":3359},[2907,4454,3354],{"class":3290},[2907,4456,4457,4460,4462,4464,4466,4468,4470,4473],{"class":2909,"line":2952},[2907,4458,4459],{"class":3359},"        model",[2907,4461,3363],{"class":3290},[2907,4463,3366],{"class":2930},[2907,4465,3346],{"class":3290},[2907,4467,3371],{"class":2930},[2907,4469,3346],{"class":3290},[2907,4471,4472],{"class":2930},"AI_MODEL",[2907,4474,3001],{"class":3290},[2907,4476,4477,4480,4482,4484],{"class":2909,"line":2959},[2907,4478,4479],{"class":3359},"        messages",[2907,4481,3363],{"class":3290},[2907,4483,4408],{"class":2930},[2907,4485,3001],{"class":3290},[2907,4487,4488,4491,4493],{"class":2909,"line":2979},[2907,4489,4490],{"class":3359},"        stream",[2907,4492,3363],{"class":3290},[2907,4494,4496],{"class":4495},"sPKOg"," true\n",[2907,4498,4499,4502,4504,4506,4508,4510],{"class":2909,"line":3004},[2907,4500,4501],{"class":3290},"    },",[2907,4503,3307],{"class":3290},[2907,4505,4417],{"class":2930},[2907,4507,3313],{"class":3290},[2907,4509,3480],{"class":3359},[2907,4511,3300],{"class":3290},[2907,4513,4514],{"class":2909,"line":3023},[2907,4515,2956],{"emptyLinePlaceholder":2955},[2907,4517,4518,4521,4523,4526,4528,4530,4533,4535,4537,4539,4542,4544,4546],{"class":2909,"line":3029},[2907,4519,4520],{"class":2930},"    res",[2907,4522,3346],{"class":3290},[2907,4524,4525],{"class":2920},"setHeader",[2907,4527,2989],{"class":3359},[2907,4529,3297],{"class":3290},[2907,4531,4532],{"class":3177},"Content-Type",[2907,4534,3297],{"class":3290},[2907,4536,3564],{"class":3290},[2907,4538,3291],{"class":3290},[2907,4540,4541],{"class":3177},"application/x-ndjson; charset=utf-8",[2907,4543,3297],{"class":3290},[2907,4545,3480],{"class":3359},[2907,4547,3300],{"class":3290},[2907,4549,4550,4552,4554,4556,4558,4560,4563,4565,4567,4569,4572,4574,4576],{"class":2909,"line":3034},[2907,4551,4520],{"class":2930},[2907,4553,3346],{"class":3290},[2907,4555,4525],{"class":2920},[2907,4557,2989],{"class":3359},[2907,4559,3297],{"class":3290},[2907,4561,4562],{"class":3177},"Cache-Control",[2907,4564,3297],{"class":3290},[2907,4566,3564],{"class":3290},[2907,4568,3291],{"class":3290},[2907,4570,4571],{"class":3177},"no-cache, no-transform",[2907,4573,3297],{"class":3290},[2907,4575,3480],{"class":3359},[2907,4577,3300],{"class":3290},[2907,4579,4580,4582,4584,4586,4588,4590,4593,4595,4597,4599,4602,4604,4606],{"class":2909,"line":3050},[2907,4581,4520],{"class":2930},[2907,4583,3346],{"class":3290},[2907,4585,4525],{"class":2920},[2907,4587,2989],{"class":3359},[2907,4589,3297],{"class":3290},[2907,4591,4592],{"class":3177},"X-Accel-Buffering",[2907,4594,3297],{"class":3290},[2907,4596,3564],{"class":3290},[2907,4598,3291],{"class":3290},[2907,4600,4601],{"class":3177},"no",[2907,4603,3297],{"class":3290},[2907,4605,3480],{"class":3359},[2907,4607,3300],{"class":3290},[2907,4609,4610],{"class":2909,"line":3064},[2907,4611,2956],{"emptyLinePlaceholder":2955},[2907,4613,4614,4617,4620,4622,4625],{"class":2909,"line":3083},[2907,4615,4616],{"class":2985},"    let",[2907,4618,4619],{"class":2930}," answer",[2907,4621,3517],{"class":3290},[2907,4623,4624],{"class":3290}," \"\"",[2907,4626,3300],{"class":3290},[2907,4628,4629,4631,4634,4636],{"class":2909,"line":3103},[2907,4630,4616],{"class":2985},[2907,4632,4633],{"class":2930}," finishReason",[2907,4635,3517],{"class":3290},[2907,4637,4638],{"class":3290}," null;\n",[2907,4640,4641],{"class":2909,"line":3117},[2907,4642,2956],{"emptyLinePlaceholder":2955},[2907,4644,4645,4648,4650,4652,4654,4657,4660,4662,4664],{"class":2909,"line":3134},[2907,4646,4647],{"class":3280},"    for",[2907,4649,3643],{"class":3280},[2907,4651,4197],{"class":3359},[2907,4653,3334],{"class":2985},[2907,4655,4656],{"class":2930}," chunk",[2907,4658,4659],{"class":3290}," of",[2907,4661,4428],{"class":2930},[2907,4663,2995],{"class":3359},[2907,4665,3354],{"class":3290},[2907,4667,4668,4670,4673,4675,4677,4679,4682,4685,4688,4690],{"class":2909,"line":3542},[2907,4669,4224],{"class":2985},[2907,4671,4672],{"class":2930}," choice",[2907,4674,3517],{"class":3290},[2907,4676,4656],{"class":2930},[2907,4678,3346],{"class":3290},[2907,4680,4681],{"class":2930},"choices",[2907,4683,4684],{"class":3359},"[",[2907,4686,4687],{"class":2913},"0",[2907,4689,3638],{"class":3359},[2907,4691,3300],{"class":3290},[2907,4693,4694,4697,4699,4702,4705,4707,4710],{"class":2909,"line":3555},[2907,4695,4696],{"class":3280},"        if",[2907,4698,4197],{"class":3359},[2907,4700,4701],{"class":3290},"!",[2907,4703,4704],{"class":2930},"choice",[2907,4706,2995],{"class":3359},[2907,4708,4709],{"class":3280},"continue",[2907,4711,3300],{"class":3290},[2907,4713,4714],{"class":2909,"line":3577},[2907,4715,2956],{"emptyLinePlaceholder":2955},[2907,4717,4718,4720,4723,4725,4727,4729,4732,4735,4737],{"class":2909,"line":3585},[2907,4719,4224],{"class":2985},[2907,4721,4722],{"class":2930}," text",[2907,4724,3517],{"class":3290},[2907,4726,4672],{"class":2930},[2907,4728,3346],{"class":3290},[2907,4730,4731],{"class":2930},"delta",[2907,4733,4734],{"class":3290},"?.",[2907,4736,2806],{"class":2930},[2907,4738,3300],{"class":3290},[2907,4740,4741,4743,4745,4748,4750],{"class":2909,"line":3595},[2907,4742,4696],{"class":3280},[2907,4744,4197],{"class":3359},[2907,4746,4747],{"class":2930},"text",[2907,4749,2995],{"class":3359},[2907,4751,3354],{"class":3290},[2907,4753,4754,4757,4760,4762],{"class":2909,"line":3601},[2907,4755,4756],{"class":2930},"            answer",[2907,4758,4759],{"class":3290}," +=",[2907,4761,4722],{"class":2930},[2907,4763,3300],{"class":3290},[2907,4765,4766,4769,4771,4774,4776,4779,4781,4784,4786,4788,4791,4793,4795,4797,4799,4801,4803,4805,4807,4810,4812,4815,4817,4819],{"class":2909,"line":3606},[2907,4767,4768],{"class":2930},"            res",[2907,4770,3346],{"class":3290},[2907,4772,4773],{"class":2920},"write",[2907,4775,2989],{"class":3359},[2907,4777,4778],{"class":2930},"JSON",[2907,4780,3346],{"class":3290},[2907,4782,4783],{"class":2920},"stringify",[2907,4785,2989],{"class":3359},[2907,4787,4132],{"class":3290},[2907,4789,4790],{"class":3359}," type",[2907,4792,3363],{"class":3290},[2907,4794,3291],{"class":3290},[2907,4796,4731],{"class":3177},[2907,4798,3297],{"class":3290},[2907,4800,3564],{"class":3290},[2907,4802,4722],{"class":2930},[2907,4804,3313],{"class":3290},[2907,4806,2995],{"class":3359},[2907,4808,4809],{"class":3290},"+",[2907,4811,3291],{"class":3290},[2907,4813,4814],{"class":2930},"\\n",[2907,4816,3297],{"class":3290},[2907,4818,3480],{"class":3359},[2907,4820,3300],{"class":3290},[2907,4822,4823],{"class":2909,"line":3627},[2907,4824,4825],{"class":3290},"        }\n",[2907,4827,4828,4830,4832,4834,4836,4839,4842,4845,4847],{"class":2909,"line":3654},[2907,4829,4696],{"class":3280},[2907,4831,4197],{"class":3359},[2907,4833,4704],{"class":2930},[2907,4835,3346],{"class":3290},[2907,4837,4838],{"class":2930},"finish_reason",[2907,4840,4841],{"class":3290}," !=",[2907,4843,4844],{"class":3290}," null",[2907,4846,2995],{"class":3359},[2907,4848,3354],{"class":3290},[2907,4850,4851,4854,4856,4858,4860,4862],{"class":2909,"line":3666},[2907,4852,4853],{"class":2930},"            finishReason",[2907,4855,3517],{"class":3290},[2907,4857,4672],{"class":2930},[2907,4859,3346],{"class":3290},[2907,4861,4838],{"class":2930},[2907,4863,3300],{"class":3290},[2907,4865,4866],{"class":2909,"line":3675},[2907,4867,4825],{"class":3290},[2907,4869,4870],{"class":2909,"line":3682},[2907,4871,4349],{"class":3290},[2907,4873,4874],{"class":2909,"line":3703},[2907,4875,2956],{"emptyLinePlaceholder":2955},[2907,4877,4879,4882,4884,4887,4890,4892,4894],{"class":2909,"line":4878},29,[2907,4880,4881],{"class":3280},"    if",[2907,4883,4197],{"class":3359},[2907,4885,4886],{"class":2930},"finishReason",[2907,4888,4889],{"class":3290}," ===",[2907,4891,4844],{"class":3290},[2907,4893,2995],{"class":3359},[2907,4895,3354],{"class":3290},[2907,4897,4899,4902,4904,4907,4909,4911,4914,4916,4918],{"class":2909,"line":4898},30,[2907,4900,4901],{"class":3280},"        throw",[2907,4903,4052],{"class":3290},[2907,4905,4906],{"class":2920}," Error",[2907,4908,2989],{"class":3359},[2907,4910,3297],{"class":3290},[2907,4912,4913],{"class":3177},"模型流未正常结束",[2907,4915,3297],{"class":3290},[2907,4917,3480],{"class":3359},[2907,4919,3300],{"class":3290},[2907,4921,4923],{"class":2909,"line":4922},31,[2907,4924,4349],{"class":3290},[2907,4926,4928],{"class":2909,"line":4927},32,[2907,4929,2956],{"emptyLinePlaceholder":2955},[2907,4931,4933,4935,4937,4940,4942],{"class":2909,"line":4932},33,[2907,4934,4881],{"class":3280},[2907,4936,4197],{"class":3359},[2907,4938,4939],{"class":2930},"answer",[2907,4941,2995],{"class":3359},[2907,4943,3354],{"class":3290},[2907,4945,4947,4950,4952,4954,4956,4958,4960,4962,4964,4966,4968,4970],{"class":2909,"line":4946},34,[2907,4948,4949],{"class":3280},"        await",[2907,4951,3748],{"class":2920},[2907,4953,2989],{"class":3359},[2907,4955,2786],{"class":2930},[2907,4957,3564],{"class":3290},[2907,4959,3291],{"class":3290},[2907,4961,2828],{"class":3177},[2907,4963,3297],{"class":3290},[2907,4965,3564],{"class":3290},[2907,4967,4619],{"class":2930},[2907,4969,3480],{"class":3359},[2907,4971,3300],{"class":3290},[2907,4973,4975],{"class":2909,"line":4974},35,[2907,4976,4349],{"class":3290},[2907,4978,4980,4982,4984,4986,4988,4990,4992,4994,4996,4998,5000,5002,5004,5007,5009,5011,5013,5015,5017,5019,5021,5023,5025,5027],{"class":2909,"line":4979},36,[2907,4981,4520],{"class":2930},[2907,4983,3346],{"class":3290},[2907,4985,4773],{"class":2920},[2907,4987,2989],{"class":3359},[2907,4989,4778],{"class":2930},[2907,4991,3346],{"class":3290},[2907,4993,4783],{"class":2920},[2907,4995,2989],{"class":3359},[2907,4997,4132],{"class":3290},[2907,4999,4790],{"class":3359},[2907,5001,3363],{"class":3290},[2907,5003,3291],{"class":3290},[2907,5005,5006],{"class":3177},"done",[2907,5008,3297],{"class":3290},[2907,5010,3564],{"class":3290},[2907,5012,4633],{"class":2930},[2907,5014,3313],{"class":3290},[2907,5016,2995],{"class":3359},[2907,5018,4809],{"class":3290},[2907,5020,3291],{"class":3290},[2907,5022,4814],{"class":2930},[2907,5024,3297],{"class":3290},[2907,5026,3480],{"class":3359},[2907,5028,3300],{"class":3290},[2907,5030,5032,5034,5036,5039,5041],{"class":2909,"line":5031},37,[2907,5033,4520],{"class":2930},[2907,5035,3346],{"class":3290},[2907,5037,5038],{"class":2920},"end",[2907,5040,3503],{"class":3359},[2907,5042,3300],{"class":3290},[2907,5044,5046],{"class":2909,"line":5045},38,[2907,5047,3598],{"class":3290},[2758,5049,5050,5051,5054,5055,5057,5058,5061],{},"这里沿用流式输出的读取方式。真正新增的是 ",[2762,5052,5053],{},"answer += text"," 和最后的 ",[2762,5056,3902],{},"：",[2770,5059,5060],{},"前者收集本轮回答，后者把它作为一条助手消息保存。"," 如果模型因为长度限制结束，保存的是实际收到的内容，不一定是完整回答。",[2890,5063,5065],{"id":5064},"_4-接收问题读取历史并调用模型","4. 接收问题、读取历史并调用模型",[2758,5067,5068,5069,5072,5073,5075,5076,2882],{},"现在添加 ",[2762,5070,5071],{},"POST /api/chat","。收到 ",[2762,5074,2786],{}," 和用户问题后，先确认会话存在，然后把问题存入 MySQL，再读取历史交给 ",[2762,5077,5078],{},"streamReply()",[2758,5080,3725,5081,4167],{},[2762,5082,3931],{},[2898,5084,5086],{"className":3271,"code":5085,"language":3273,"meta":2903,"style":2903},"app.post(\"/api/chat\", async (req, res) => {\n    const { sessionId, message } = req.body ?? {};\n\n    if (typeof sessionId !== \"string\" || !sessionId.trim()) {\n        return res.status(400).json({ error: \"缺少会话 ID\" });\n    }\n    if (typeof message !== \"string\" || !message.trim() || message.length > 2000) {\n        return res.status(400).json({ error: \"请输入 1～2000 个字符的消息\" });\n    }\n\n    const controller = new AbortController();\n    res.on(\"close\", () => {\n        if (!res.writableEnded) controller.abort();\n    });\n\n    try {\n        if (!await hasSession(sessionId)) {\n            return res.status(404).json({ error: \"会话不存在\" });\n        }\n\n        await addMessage(sessionId, \"user\", message);\n        const history = await getMessages(sessionId);\n        await streamReply(sessionId, history, res, controller.signal);\n    } catch (error) {\n        if (controller.signal.aborted || res.destroyed) return;\n        console.error(error);\n\n        if (!res.headersSent) {\n            res.status(502).json({ error: \"聊天请求失败\" });\n        } else {\n            res.write(JSON.stringify({ type: \"error\", message: \"生成中断\" }) + \"\\n\");\n            res.end();\n        }\n    }\n});\n",[2762,5087,5088,5123,5155,5159,5198,5241,5245,5295,5336,5340,5344,5362,5389,5419,5427,5431,5437,5459,5502,5506,5510,5536,5556,5587,5601,5634,5650,5654,5673,5713,5723,5782,5794,5798,5802],{"__ignoreMap":2903},[2907,5089,5090,5092,5094,5096,5098,5100,5103,5105,5107,5109,5111,5113,5115,5117,5119,5121],{"class":2909,"line":2910},[2907,5091,4114],{"class":2930},[2907,5093,3346],{"class":3290},[2907,5095,4181],{"class":2920},[2907,5097,2989],{"class":2930},[2907,5099,3297],{"class":3290},[2907,5101,5102],{"class":3177},"/api/chat",[2907,5104,3297],{"class":3290},[2907,5106,3564],{"class":3290},[2907,5108,3494],{"class":2985},[2907,5110,4197],{"class":3290},[2907,5112,4200],{"class":3620},[2907,5114,3564],{"class":3290},[2907,5116,4205],{"class":3620},[2907,5118,3480],{"class":3290},[2907,5120,4210],{"class":2985},[2907,5122,3506],{"class":3290},[2907,5124,5125,5127,5129,5132,5134,5137,5139,5141,5144,5146,5149,5152],{"class":2909,"line":2943},[2907,5126,3511],{"class":2985},[2907,5128,3307],{"class":3290},[2907,5130,5131],{"class":2930}," sessionId",[2907,5133,3564],{"class":3290},[2907,5135,5136],{"class":2930}," message",[2907,5138,3313],{"class":3290},[2907,5140,3517],{"class":3290},[2907,5142,5143],{"class":2930}," req",[2907,5145,3346],{"class":3290},[2907,5147,5148],{"class":2930},"body",[2907,5150,5151],{"class":3290}," ??",[2907,5153,5154],{"class":3290}," {};\n",[2907,5156,5157],{"class":2909,"line":2952},[2907,5158,2956],{"emptyLinePlaceholder":2955},[2907,5160,5161,5163,5165,5168,5170,5173,5175,5178,5180,5183,5186,5188,5190,5193,5196],{"class":2909,"line":2959},[2907,5162,4881],{"class":3280},[2907,5164,4197],{"class":3359},[2907,5166,5167],{"class":3290},"typeof",[2907,5169,5131],{"class":2930},[2907,5171,5172],{"class":3290}," !==",[2907,5174,3291],{"class":3290},[2907,5176,5177],{"class":3177},"string",[2907,5179,3297],{"class":3290},[2907,5181,5182],{"class":3290}," ||",[2907,5184,5185],{"class":3290}," !",[2907,5187,2786],{"class":2930},[2907,5189,3346],{"class":3290},[2907,5191,5192],{"class":2920},"trim",[2907,5194,5195],{"class":3359},"()) ",[2907,5197,3354],{"class":3290},[2907,5199,5200,5203,5205,5207,5209,5211,5214,5216,5218,5220,5222,5224,5226,5228,5230,5233,5235,5237,5239],{"class":2909,"line":2979},[2907,5201,5202],{"class":3280},"        return",[2907,5204,4205],{"class":2930},[2907,5206,3346],{"class":3290},[2907,5208,4246],{"class":2920},[2907,5210,2989],{"class":3359},[2907,5212,5213],{"class":2913},"400",[2907,5215,3480],{"class":3359},[2907,5217,3346],{"class":3290},[2907,5219,4127],{"class":2920},[2907,5221,2989],{"class":3359},[2907,5223,4132],{"class":3290},[2907,5225,4329],{"class":3359},[2907,5227,3363],{"class":3290},[2907,5229,3291],{"class":3290},[2907,5231,5232],{"class":3177},"缺少会话 ID",[2907,5234,3297],{"class":3290},[2907,5236,3313],{"class":3290},[2907,5238,3480],{"class":3359},[2907,5240,3300],{"class":3290},[2907,5242,5243],{"class":2909,"line":3004},[2907,5244,4349],{"class":3290},[2907,5246,5247,5249,5251,5253,5255,5257,5259,5261,5263,5265,5267,5270,5272,5274,5277,5280,5282,5284,5286,5288,5291,5293],{"class":2909,"line":3023},[2907,5248,4881],{"class":3280},[2907,5250,4197],{"class":3359},[2907,5252,5167],{"class":3290},[2907,5254,5136],{"class":2930},[2907,5256,5172],{"class":3290},[2907,5258,3291],{"class":3290},[2907,5260,5177],{"class":3177},[2907,5262,3297],{"class":3290},[2907,5264,5182],{"class":3290},[2907,5266,5185],{"class":3290},[2907,5268,5269],{"class":2930},"message",[2907,5271,3346],{"class":3290},[2907,5273,5192],{"class":2920},[2907,5275,5276],{"class":3359},"() ",[2907,5278,5279],{"class":3290},"||",[2907,5281,5136],{"class":2930},[2907,5283,3346],{"class":3290},[2907,5285,3692],{"class":2930},[2907,5287,3695],{"class":3290},[2907,5289,5290],{"class":2913}," 2000",[2907,5292,2995],{"class":3359},[2907,5294,3354],{"class":3290},[2907,5296,5297,5299,5301,5303,5305,5307,5309,5311,5313,5315,5317,5319,5321,5323,5325,5328,5330,5332,5334],{"class":2909,"line":3029},[2907,5298,5202],{"class":3280},[2907,5300,4205],{"class":2930},[2907,5302,3346],{"class":3290},[2907,5304,4246],{"class":2920},[2907,5306,2989],{"class":3359},[2907,5308,5213],{"class":2913},[2907,5310,3480],{"class":3359},[2907,5312,3346],{"class":3290},[2907,5314,4127],{"class":2920},[2907,5316,2989],{"class":3359},[2907,5318,4132],{"class":3290},[2907,5320,4329],{"class":3359},[2907,5322,3363],{"class":3290},[2907,5324,3291],{"class":3290},[2907,5326,5327],{"class":3177},"请输入 1～2000 个字符的消息",[2907,5329,3297],{"class":3290},[2907,5331,3313],{"class":3290},[2907,5333,3480],{"class":3359},[2907,5335,3300],{"class":3290},[2907,5337,5338],{"class":2909,"line":3034},[2907,5339,4349],{"class":3290},[2907,5341,5342],{"class":2909,"line":3050},[2907,5343,2956],{"emptyLinePlaceholder":2955},[2907,5345,5346,5348,5351,5353,5355,5358,5360],{"class":2909,"line":3064},[2907,5347,3511],{"class":2985},[2907,5349,5350],{"class":2930}," controller",[2907,5352,3517],{"class":3290},[2907,5354,4052],{"class":3290},[2907,5356,5357],{"class":2920}," AbortController",[2907,5359,3503],{"class":3359},[2907,5361,3300],{"class":3290},[2907,5363,5364,5366,5368,5371,5373,5375,5378,5380,5382,5385,5387],{"class":2909,"line":3083},[2907,5365,4520],{"class":2930},[2907,5367,3346],{"class":3290},[2907,5369,5370],{"class":2920},"on",[2907,5372,2989],{"class":3359},[2907,5374,3297],{"class":3290},[2907,5376,5377],{"class":3177},"close",[2907,5379,3297],{"class":3290},[2907,5381,3564],{"class":3290},[2907,5383,5384],{"class":3290}," ()",[2907,5386,4210],{"class":2985},[2907,5388,3506],{"class":3290},[2907,5390,5391,5393,5395,5397,5400,5402,5405,5407,5410,5412,5415,5417],{"class":2909,"line":3103},[2907,5392,4696],{"class":3280},[2907,5394,4197],{"class":3359},[2907,5396,4701],{"class":3290},[2907,5398,5399],{"class":2930},"res",[2907,5401,3346],{"class":3290},[2907,5403,5404],{"class":2930},"writableEnded",[2907,5406,2995],{"class":3359},[2907,5408,5409],{"class":2930},"controller",[2907,5411,3346],{"class":3290},[2907,5413,5414],{"class":2920},"abort",[2907,5416,3503],{"class":3359},[2907,5418,3300],{"class":3290},[2907,5420,5421,5423,5425],{"class":2909,"line":3117},[2907,5422,4274],{"class":3290},[2907,5424,3480],{"class":3359},[2907,5426,3300],{"class":3290},[2907,5428,5429],{"class":2909,"line":3134},[2907,5430,2956],{"emptyLinePlaceholder":2955},[2907,5432,5433,5435],{"class":2909,"line":3542},[2907,5434,4217],{"class":3280},[2907,5436,3506],{"class":3290},[2907,5438,5439,5441,5443,5445,5448,5450,5452,5454,5457],{"class":2909,"line":3555},[2907,5440,4696],{"class":3280},[2907,5442,4197],{"class":3359},[2907,5444,4701],{"class":3290},[2907,5446,5447],{"class":3280},"await",[2907,5449,3615],{"class":2920},[2907,5451,2989],{"class":3359},[2907,5453,2786],{"class":2930},[2907,5455,5456],{"class":3359},")) ",[2907,5458,3354],{"class":3290},[2907,5460,5461,5464,5466,5468,5470,5472,5475,5477,5479,5481,5483,5485,5487,5489,5491,5494,5496,5498,5500],{"class":2909,"line":3577},[2907,5462,5463],{"class":3280},"            return",[2907,5465,4205],{"class":2930},[2907,5467,3346],{"class":3290},[2907,5469,4246],{"class":2920},[2907,5471,2989],{"class":3359},[2907,5473,5474],{"class":2913},"404",[2907,5476,3480],{"class":3359},[2907,5478,3346],{"class":3290},[2907,5480,4127],{"class":2920},[2907,5482,2989],{"class":3359},[2907,5484,4132],{"class":3290},[2907,5486,4329],{"class":3359},[2907,5488,3363],{"class":3290},[2907,5490,3291],{"class":3290},[2907,5492,5493],{"class":3177},"会话不存在",[2907,5495,3297],{"class":3290},[2907,5497,3313],{"class":3290},[2907,5499,3480],{"class":3359},[2907,5501,3300],{"class":3290},[2907,5503,5504],{"class":2909,"line":3585},[2907,5505,4825],{"class":3290},[2907,5507,5508],{"class":2909,"line":3595},[2907,5509,2956],{"emptyLinePlaceholder":2955},[2907,5511,5512,5514,5516,5518,5520,5522,5524,5526,5528,5530,5532,5534],{"class":2909,"line":3601},[2907,5513,4949],{"class":3280},[2907,5515,3748],{"class":2920},[2907,5517,2989],{"class":3359},[2907,5519,2786],{"class":2930},[2907,5521,3564],{"class":3290},[2907,5523,3291],{"class":3290},[2907,5525,2818],{"class":3177},[2907,5527,3297],{"class":3290},[2907,5529,3564],{"class":3290},[2907,5531,5136],{"class":2930},[2907,5533,3480],{"class":3359},[2907,5535,3300],{"class":3290},[2907,5537,5538,5540,5542,5544,5546,5548,5550,5552,5554],{"class":2909,"line":3606},[2907,5539,4224],{"class":2985},[2907,5541,4408],{"class":2930},[2907,5543,3517],{"class":3290},[2907,5545,3643],{"class":3280},[2907,5547,3830],{"class":2920},[2907,5549,2989],{"class":3359},[2907,5551,2786],{"class":2930},[2907,5553,3480],{"class":3359},[2907,5555,3300],{"class":3290},[2907,5557,5558,5560,5562,5564,5566,5568,5570,5572,5574,5576,5578,5580,5583,5585],{"class":2909,"line":3627},[2907,5559,4949],{"class":3280},[2907,5561,4399],{"class":2920},[2907,5563,2989],{"class":3359},[2907,5565,2786],{"class":2930},[2907,5567,3564],{"class":3290},[2907,5569,4408],{"class":2930},[2907,5571,3564],{"class":3290},[2907,5573,4205],{"class":2930},[2907,5575,3564],{"class":3290},[2907,5577,5350],{"class":2930},[2907,5579,3346],{"class":3290},[2907,5581,5582],{"class":2930},"signal",[2907,5584,3480],{"class":3359},[2907,5586,3300],{"class":3290},[2907,5588,5589,5591,5593,5595,5597,5599],{"class":2909,"line":3654},[2907,5590,4274],{"class":3290},[2907,5592,4277],{"class":3280},[2907,5594,4197],{"class":3359},[2907,5596,4282],{"class":2930},[2907,5598,2995],{"class":3359},[2907,5600,3354],{"class":3290},[2907,5602,5603,5605,5607,5609,5611,5613,5615,5618,5620,5622,5624,5627,5629,5632],{"class":2909,"line":3666},[2907,5604,4696],{"class":3280},[2907,5606,4197],{"class":3359},[2907,5608,5409],{"class":2930},[2907,5610,3346],{"class":3290},[2907,5612,5582],{"class":2930},[2907,5614,3346],{"class":3290},[2907,5616,5617],{"class":2930},"aborted",[2907,5619,5182],{"class":3290},[2907,5621,4205],{"class":2930},[2907,5623,3346],{"class":3290},[2907,5625,5626],{"class":2930},"destroyed",[2907,5628,2995],{"class":3359},[2907,5630,5631],{"class":3280},"return",[2907,5633,3300],{"class":3290},[2907,5635,5636,5638,5640,5642,5644,5646,5648],{"class":2909,"line":3675},[2907,5637,4291],{"class":2930},[2907,5639,3346],{"class":3290},[2907,5641,4282],{"class":2920},[2907,5643,2989],{"class":3359},[2907,5645,4282],{"class":2930},[2907,5647,3480],{"class":3359},[2907,5649,3300],{"class":3290},[2907,5651,5652],{"class":2909,"line":3682},[2907,5653,2956],{"emptyLinePlaceholder":2955},[2907,5655,5656,5658,5660,5662,5664,5666,5669,5671],{"class":2909,"line":3703},[2907,5657,4696],{"class":3280},[2907,5659,4197],{"class":3359},[2907,5661,4701],{"class":3290},[2907,5663,5399],{"class":2930},[2907,5665,3346],{"class":3290},[2907,5667,5668],{"class":2930},"headersSent",[2907,5670,2995],{"class":3359},[2907,5672,3354],{"class":3290},[2907,5674,5675,5677,5679,5681,5683,5686,5688,5690,5692,5694,5696,5698,5700,5702,5705,5707,5709,5711],{"class":2909,"line":4878},[2907,5676,4768],{"class":2930},[2907,5678,3346],{"class":3290},[2907,5680,4246],{"class":2920},[2907,5682,2989],{"class":3359},[2907,5684,5685],{"class":2913},"502",[2907,5687,3480],{"class":3359},[2907,5689,3346],{"class":3290},[2907,5691,4127],{"class":2920},[2907,5693,2989],{"class":3359},[2907,5695,4132],{"class":3290},[2907,5697,4329],{"class":3359},[2907,5699,3363],{"class":3290},[2907,5701,3291],{"class":3290},[2907,5703,5704],{"class":3177},"聊天请求失败",[2907,5706,3297],{"class":3290},[2907,5708,3313],{"class":3290},[2907,5710,3480],{"class":3359},[2907,5712,3300],{"class":3290},[2907,5714,5715,5718,5721],{"class":2909,"line":4898},[2907,5716,5717],{"class":3290},"        }",[2907,5719,5720],{"class":3280}," else",[2907,5722,3506],{"class":3290},[2907,5724,5725,5727,5729,5731,5733,5735,5737,5739,5741,5743,5745,5747,5749,5751,5753,5755,5757,5759,5761,5764,5766,5768,5770,5772,5774,5776,5778,5780],{"class":2909,"line":4922},[2907,5726,4768],{"class":2930},[2907,5728,3346],{"class":3290},[2907,5730,4773],{"class":2920},[2907,5732,2989],{"class":3359},[2907,5734,4778],{"class":2930},[2907,5736,3346],{"class":3290},[2907,5738,4783],{"class":2920},[2907,5740,2989],{"class":3359},[2907,5742,4132],{"class":3290},[2907,5744,4790],{"class":3359},[2907,5746,3363],{"class":3290},[2907,5748,3291],{"class":3290},[2907,5750,4282],{"class":3177},[2907,5752,3297],{"class":3290},[2907,5754,3564],{"class":3290},[2907,5756,5136],{"class":3359},[2907,5758,3363],{"class":3290},[2907,5760,3291],{"class":3290},[2907,5762,5763],{"class":3177},"生成中断",[2907,5765,3297],{"class":3290},[2907,5767,3313],{"class":3290},[2907,5769,2995],{"class":3359},[2907,5771,4809],{"class":3290},[2907,5773,3291],{"class":3290},[2907,5775,4814],{"class":2930},[2907,5777,3297],{"class":3290},[2907,5779,3480],{"class":3359},[2907,5781,3300],{"class":3290},[2907,5783,5784,5786,5788,5790,5792],{"class":2909,"line":4927},[2907,5785,4768],{"class":2930},[2907,5787,3346],{"class":3290},[2907,5789,5038],{"class":2920},[2907,5791,3503],{"class":3359},[2907,5793,3300],{"class":3290},[2907,5795,5796],{"class":2909,"line":4932},[2907,5797,4825],{"class":3290},[2907,5799,5800],{"class":2909,"line":4946},[2907,5801,4349],{"class":3290},[2907,5803,5804,5806,5808],{"class":2909,"line":4974},[2907,5805,3477],{"class":3290},[2907,5807,3480],{"class":2930},[2907,5809,3300],{"class":3290},[2758,5811,5812,5813,5816],{},"这里的顺序值得注意：",[2770,5814,5815],{},"先保存本次问题，再查询历史","。例如数据库原来已有一轮问答，此时用户输入“先讲响应式”，查询结果会包含之前的问答和这次的问题，不需要额外拼接本次消息。",[2758,5818,5819,5820,5822,5823,5825,5826,5828],{},"模型不会主动查询 MySQL。",[2762,5821,3906],{}," 取出的 ",[2762,5824,2764],{}," 会由 ",[2762,5827,5078],{}," 传给 Chat Completions，模型才能参考之前的对话。若请求失败，已保存的用户消息仍可能留在数据库；这里不扩展失败重试。",[2890,5830,5832],{"id":5831},"_5-提供读取历史的接口","5. 提供读取历史的接口",[2758,5834,5835,5836,4167],{},"最后让页面能够根据会话 ID 找回聊天记录。在 ",[2762,5837,3931],{},[2898,5839,5841],{"className":3271,"code":5840,"language":3273,"meta":2903,"style":2903},"app.get(\"/api/sessions/:id/messages\", async (req, res) => {\n    try {\n        if (!await hasSession(req.params.id)) {\n            return res.status(404).json({ error: \"会话不存在\" });\n        }\n        res.json({ messages: await getMessages(req.params.id) });\n    } catch (error) {\n        console.error(error);\n        res.status(500).json({ error: \"读取历史失败\" });\n    }\n});\n\napp.listen(3000, \"127.0.0.1\", () => {\n    console.log(\"http://127.0.0.1:3000\");\n});\n",[2762,5842,5843,5879,5885,5914,5954,5958,5999,6013,6029,6068,6072,6080,6084,6115,6138],{"__ignoreMap":2903},[2907,5844,5845,5847,5849,5852,5854,5856,5859,5861,5863,5865,5867,5869,5871,5873,5875,5877],{"class":2909,"line":2910},[2907,5846,4114],{"class":2930},[2907,5848,3346],{"class":3290},[2907,5850,5851],{"class":2920},"get",[2907,5853,2989],{"class":2930},[2907,5855,3297],{"class":3290},[2907,5857,5858],{"class":3177},"/api/sessions/:id/messages",[2907,5860,3297],{"class":3290},[2907,5862,3564],{"class":3290},[2907,5864,3494],{"class":2985},[2907,5866,4197],{"class":3290},[2907,5868,4200],{"class":3620},[2907,5870,3564],{"class":3290},[2907,5872,4205],{"class":3620},[2907,5874,3480],{"class":3290},[2907,5876,4210],{"class":2985},[2907,5878,3506],{"class":3290},[2907,5880,5881,5883],{"class":2909,"line":2943},[2907,5882,4217],{"class":3280},[2907,5884,3506],{"class":3290},[2907,5886,5887,5889,5891,5893,5895,5897,5899,5901,5903,5906,5908,5910,5912],{"class":2909,"line":2952},[2907,5888,4696],{"class":3280},[2907,5890,4197],{"class":3359},[2907,5892,4701],{"class":3290},[2907,5894,5447],{"class":3280},[2907,5896,3615],{"class":2920},[2907,5898,2989],{"class":3359},[2907,5900,4200],{"class":2930},[2907,5902,3346],{"class":3290},[2907,5904,5905],{"class":2930},"params",[2907,5907,3346],{"class":3290},[2907,5909,3561],{"class":2930},[2907,5911,5456],{"class":3359},[2907,5913,3354],{"class":3290},[2907,5915,5916,5918,5920,5922,5924,5926,5928,5930,5932,5934,5936,5938,5940,5942,5944,5946,5948,5950,5952],{"class":2909,"line":2959},[2907,5917,5463],{"class":3280},[2907,5919,4205],{"class":2930},[2907,5921,3346],{"class":3290},[2907,5923,4246],{"class":2920},[2907,5925,2989],{"class":3359},[2907,5927,5474],{"class":2913},[2907,5929,3480],{"class":3359},[2907,5931,3346],{"class":3290},[2907,5933,4127],{"class":2920},[2907,5935,2989],{"class":3359},[2907,5937,4132],{"class":3290},[2907,5939,4329],{"class":3359},[2907,5941,3363],{"class":3290},[2907,5943,3291],{"class":3290},[2907,5945,5493],{"class":3177},[2907,5947,3297],{"class":3290},[2907,5949,3313],{"class":3290},[2907,5951,3480],{"class":3359},[2907,5953,3300],{"class":3290},[2907,5955,5956],{"class":2909,"line":2979},[2907,5957,4825],{"class":3290},[2907,5959,5960,5962,5964,5966,5968,5970,5973,5975,5977,5979,5981,5983,5985,5987,5989,5991,5993,5995,5997],{"class":2909,"line":3004},[2907,5961,4241],{"class":2930},[2907,5963,3346],{"class":3290},[2907,5965,4127],{"class":2920},[2907,5967,2989],{"class":3359},[2907,5969,4132],{"class":3290},[2907,5971,5972],{"class":3359}," messages",[2907,5974,3363],{"class":3290},[2907,5976,3643],{"class":3280},[2907,5978,3830],{"class":2920},[2907,5980,2989],{"class":3359},[2907,5982,4200],{"class":2930},[2907,5984,3346],{"class":3290},[2907,5986,5905],{"class":2930},[2907,5988,3346],{"class":3290},[2907,5990,3561],{"class":2930},[2907,5992,2995],{"class":3359},[2907,5994,3477],{"class":3290},[2907,5996,3480],{"class":3359},[2907,5998,3300],{"class":3290},[2907,6000,6001,6003,6005,6007,6009,6011],{"class":2909,"line":3023},[2907,6002,4274],{"class":3290},[2907,6004,4277],{"class":3280},[2907,6006,4197],{"class":3359},[2907,6008,4282],{"class":2930},[2907,6010,2995],{"class":3359},[2907,6012,3354],{"class":3290},[2907,6014,6015,6017,6019,6021,6023,6025,6027],{"class":2909,"line":3029},[2907,6016,4291],{"class":2930},[2907,6018,3346],{"class":3290},[2907,6020,4282],{"class":2920},[2907,6022,2989],{"class":3359},[2907,6024,4282],{"class":2930},[2907,6026,3480],{"class":3359},[2907,6028,3300],{"class":3290},[2907,6030,6031,6033,6035,6037,6039,6041,6043,6045,6047,6049,6051,6053,6055,6057,6060,6062,6064,6066],{"class":2909,"line":3034},[2907,6032,4241],{"class":2930},[2907,6034,3346],{"class":3290},[2907,6036,4246],{"class":2920},[2907,6038,2989],{"class":3359},[2907,6040,4316],{"class":2913},[2907,6042,3480],{"class":3359},[2907,6044,3346],{"class":3290},[2907,6046,4127],{"class":2920},[2907,6048,2989],{"class":3359},[2907,6050,4132],{"class":3290},[2907,6052,4329],{"class":3359},[2907,6054,3363],{"class":3290},[2907,6056,3291],{"class":3290},[2907,6058,6059],{"class":3177},"读取历史失败",[2907,6061,3297],{"class":3290},[2907,6063,3313],{"class":3290},[2907,6065,3480],{"class":3359},[2907,6067,3300],{"class":3290},[2907,6069,6070],{"class":2909,"line":3050},[2907,6071,4349],{"class":3290},[2907,6073,6074,6076,6078],{"class":2909,"line":3064},[2907,6075,3477],{"class":3290},[2907,6077,3480],{"class":2930},[2907,6079,3300],{"class":3290},[2907,6081,6082],{"class":2909,"line":3083},[2907,6083,2956],{"emptyLinePlaceholder":2955},[2907,6085,6086,6088,6090,6093,6095,6098,6100,6102,6105,6107,6109,6111,6113],{"class":2909,"line":3103},[2907,6087,4114],{"class":2930},[2907,6089,3346],{"class":3290},[2907,6091,6092],{"class":2920},"listen",[2907,6094,2989],{"class":2930},[2907,6096,6097],{"class":2913},"3000",[2907,6099,3564],{"class":3290},[2907,6101,3291],{"class":3290},[2907,6103,6104],{"class":3177},"127.0.0.1",[2907,6106,3297],{"class":3290},[2907,6108,3564],{"class":3290},[2907,6110,5384],{"class":3290},[2907,6112,4210],{"class":2985},[2907,6114,3506],{"class":3290},[2907,6116,6117,6120,6122,6125,6127,6129,6132,6134,6136],{"class":2909,"line":3117},[2907,6118,6119],{"class":2930},"    console",[2907,6121,3346],{"class":3290},[2907,6123,6124],{"class":2920},"log",[2907,6126,2989],{"class":3359},[2907,6128,3297],{"class":3290},[2907,6130,6131],{"class":3177},"http://127.0.0.1:3000",[2907,6133,3297],{"class":3290},[2907,6135,3480],{"class":3359},[2907,6137,3300],{"class":3290},[2907,6139,6140,6142,6144],{"class":2909,"line":3134},[2907,6141,3477],{"class":3290},[2907,6143,3480],{"class":2930},[2907,6145,3300],{"class":3290},[2758,6147,6148,6149,6151],{},"到这里，",[2762,6150,3931],{}," 已经写完。它可以创建会话、在指定会话里提问，以及读取已保存的消息；不需要再把前面的代码汇总展示一遍。",[6153,6154,6155],"tip",{},[2758,6156,6157],{},"MySQL 可以长期保存完整历史，但实际应用中不一定每次都要把全部历史传给模型。长会话可以按之前学过的上下文管理方式控制 Token 开销。",[2775,6159],{},[2753,6161,6163],{"id":6162},"验证服务重启后能否恢复对话","🧪 验证服务重启后能否恢复对话",[2758,6165,6166],{},"确保 MySQL 已启动、建表 SQL 已执行，在项目根目录启动服务：",[2898,6168,6170],{"className":3164,"code":6169,"language":3166,"meta":2903,"style":2903},"node --env-file=.env 09.server.mjs\n",[2762,6171,6172],{"__ignoreMap":2903},[2907,6173,6174,6177,6180],{"class":2909,"line":2910},[2907,6175,6176],{"class":3173},"node",[2907,6178,6179],{"class":3177}," --env-file=.env",[2907,6181,6182],{"class":3177}," 09.server.mjs\n",[2758,6184,6185],{},"如果你的模型请求需要本地代理，使用：",[2898,6187,6189],{"className":3164,"code":6188,"language":3166,"meta":2903,"style":2903},"HTTPS_PROXY=http://127.0.0.1:7890 NODE_USE_ENV_PROXY=1 node --env-file=.env 09.server.mjs\n",[2762,6190,6191],{"__ignoreMap":2903},[2907,6192,6193,6196,6198,6201,6204,6206,6209,6212,6214],{"class":2909,"line":2910},[2907,6194,6195],{"class":2930},"HTTPS_PROXY",[2907,6197,3340],{"class":3290},[2907,6199,6200],{"class":3177},"http://127.0.0.1:7890",[2907,6202,6203],{"class":2930}," NODE_USE_ENV_PROXY",[2907,6205,3340],{"class":3290},[2907,6207,6208],{"class":3177},"1",[2907,6210,6211],{"class":3173}," node",[2907,6213,6179],{"class":3177},[2907,6215,6182],{"class":3177},[2758,6217,6218],{},[2770,6219,6220],{},"第一步：创建会话。",[2898,6222,6224],{"className":3164,"code":6223,"language":3166,"meta":2903,"style":2903},"curl -s -X POST http://127.0.0.1:3000/api/sessions\n",[2762,6225,6226],{"__ignoreMap":2903},[2907,6227,6228,6231,6234,6237,6240],{"class":2909,"line":2910},[2907,6229,6230],{"class":3173},"curl",[2907,6232,6233],{"class":3177}," -s",[2907,6235,6236],{"class":3177}," -X",[2907,6238,6239],{"class":3177}," POST",[2907,6241,6242],{"class":3177}," http://127.0.0.1:3000/api/sessions\n",[2758,6244,6245,6246,6249,6250,2882],{},"会返回 ",[2762,6247,6248],{},"{\"id\":\"...\"}","。复制实际 ID，并替换下面命令中的 ",[2762,6251,6252],{},"你的会话ID",[2758,6254,6255],{},[2770,6256,6257],{},"第二步：使用同一个会话 ID 提问两次。",[2898,6259,6261],{"className":3164,"code":6260,"language":3166,"meta":2903,"style":2903},"curl -N -X POST http://127.0.0.1:3000/api/chat \\\n    -H 'Content-Type: application/json' \\\n    -d '{\"sessionId\":\"你的会话ID\",\"message\":\"我正在学习 Vue 3\"}'\n",[2762,6262,6263,6280,6296],{"__ignoreMap":2903},[2907,6264,6265,6267,6270,6272,6274,6277],{"class":2909,"line":2910},[2907,6266,6230],{"class":3173},[2907,6268,6269],{"class":3177}," -N",[2907,6271,6236],{"class":3177},[2907,6273,6239],{"class":3177},[2907,6275,6276],{"class":3177}," http://127.0.0.1:3000/api/chat",[2907,6278,6279],{"class":2930}," \\\n",[2907,6281,6282,6285,6288,6291,6294],{"class":2909,"line":2943},[2907,6283,6284],{"class":3177},"    -H",[2907,6286,6287],{"class":3290}," '",[2907,6289,6290],{"class":3177},"Content-Type: application/json",[2907,6292,6293],{"class":3290},"'",[2907,6295,6279],{"class":2930},[2907,6297,6298,6301,6303,6306],{"class":2909,"line":2952},[2907,6299,6300],{"class":3177},"    -d",[2907,6302,6287],{"class":3290},[2907,6304,6305],{"class":3177},"{\"sessionId\":\"你的会话ID\",\"message\":\"我正在学习 Vue 3\"}",[2907,6307,6308],{"class":3290},"'\n",[2898,6310,6312],{"className":3164,"code":6311,"language":3166,"meta":2903,"style":2903},"curl -N -X POST http://127.0.0.1:3000/api/chat \\\n    -H 'Content-Type: application/json' \\\n    -d '{\"sessionId\":\"你的会话ID\",\"message\":\"我刚才说正在学习什么？\"}'\n",[2762,6313,6314,6328,6340],{"__ignoreMap":2903},[2907,6315,6316,6318,6320,6322,6324,6326],{"class":2909,"line":2910},[2907,6317,6230],{"class":3173},[2907,6319,6269],{"class":3177},[2907,6321,6236],{"class":3177},[2907,6323,6239],{"class":3177},[2907,6325,6276],{"class":3177},[2907,6327,6279],{"class":2930},[2907,6329,6330,6332,6334,6336,6338],{"class":2909,"line":2943},[2907,6331,6284],{"class":3177},[2907,6333,6287],{"class":3290},[2907,6335,6290],{"class":3177},[2907,6337,6293],{"class":3290},[2907,6339,6279],{"class":2930},[2907,6341,6342,6344,6346,6349],{"class":2909,"line":2952},[2907,6343,6300],{"class":3177},[2907,6345,6287],{"class":3290},[2907,6347,6348],{"class":3177},"{\"sessionId\":\"你的会话ID\",\"message\":\"我刚才说正在学习什么？\"}",[2907,6350,6308],{"class":3290},[2758,6352,6353],{},[2770,6354,6355],{},"第三步：查看保存的历史。",[2898,6357,6359],{"className":3164,"code":6358,"language":3166,"meta":2903,"style":2903},"curl http://127.0.0.1:3000/api/sessions/你的会话ID/messages\n",[2762,6360,6361],{"__ignoreMap":2903},[2907,6362,6363,6365],{"class":2909,"line":2910},[2907,6364,6230],{"class":3173},[2907,6366,6367],{"class":3177}," http://127.0.0.1:3000/api/sessions/你的会话ID/messages\n",[2758,6369,6370],{},"如果两次模型调用都成功，返回结构类似如下（助手的回答仅为示意）：",[2898,6372,6375],{"className":6373,"code":6374,"language":4127,"meta":2903,"style":2903},"language-json shiki shiki-themes material-theme-lighter material-theme material-theme-palenight","{\n    \"messages\": [\n        { \"role\": \"user\", \"content\": \"我正在学习 Vue 3\" },\n        { \"role\": \"assistant\", \"content\": \"好的，我们可以从 Vue 3 开始。\" },\n        { \"role\": \"user\", \"content\": \"我刚才说正在学习什么？\" },\n        { \"role\": \"assistant\", \"content\": \"你刚才说正在学习 Vue 3。\" }\n    ]\n}\n",[2762,6376,6377,6381,6395,6433,6470,6507,6545,6550],{"__ignoreMap":2903},[2907,6378,6379],{"class":2909,"line":2910},[2907,6380,3354],{"class":3290},[2907,6382,6383,6386,6388,6390,6392],{"class":2909,"line":2943},[2907,6384,6385],{"class":3290},"    \"",[2907,6387,2860],{"class":2985},[2907,6389,3297],{"class":3290},[2907,6391,3363],{"class":3290},[2907,6393,6394],{"class":3290}," [\n",[2907,6396,6397,6400,6402,6404,6406,6408,6410,6412,6414,6416,6418,6420,6422,6424,6426,6428,6430],{"class":2909,"line":2952},[2907,6398,6399],{"class":3290},"        {",[2907,6401,3291],{"class":3290},[2907,6403,2803],{"class":3173},[2907,6405,3297],{"class":3290},[2907,6407,3363],{"class":3290},[2907,6409,3291],{"class":3290},[2907,6411,2818],{"class":3177},[2907,6413,3297],{"class":3290},[2907,6415,3564],{"class":3290},[2907,6417,3291],{"class":3290},[2907,6419,2806],{"class":3173},[2907,6421,3297],{"class":3290},[2907,6423,3363],{"class":3290},[2907,6425,3291],{"class":3290},[2907,6427,2821],{"class":3177},[2907,6429,3297],{"class":3290},[2907,6431,6432],{"class":3290}," },\n",[2907,6434,6435,6437,6439,6441,6443,6445,6447,6449,6451,6453,6455,6457,6459,6461,6463,6466,6468],{"class":2909,"line":2959},[2907,6436,6399],{"class":3290},[2907,6438,3291],{"class":3290},[2907,6440,2803],{"class":3173},[2907,6442,3297],{"class":3290},[2907,6444,3363],{"class":3290},[2907,6446,3291],{"class":3290},[2907,6448,2828],{"class":3177},[2907,6450,3297],{"class":3290},[2907,6452,3564],{"class":3290},[2907,6454,3291],{"class":3290},[2907,6456,2806],{"class":3173},[2907,6458,3297],{"class":3290},[2907,6460,3363],{"class":3290},[2907,6462,3291],{"class":3290},[2907,6464,6465],{"class":3177},"好的，我们可以从 Vue 3 开始。",[2907,6467,3297],{"class":3290},[2907,6469,6432],{"class":3290},[2907,6471,6472,6474,6476,6478,6480,6482,6484,6486,6488,6490,6492,6494,6496,6498,6500,6503,6505],{"class":2909,"line":2979},[2907,6473,6399],{"class":3290},[2907,6475,3291],{"class":3290},[2907,6477,2803],{"class":3173},[2907,6479,3297],{"class":3290},[2907,6481,3363],{"class":3290},[2907,6483,3291],{"class":3290},[2907,6485,2818],{"class":3177},[2907,6487,3297],{"class":3290},[2907,6489,3564],{"class":3290},[2907,6491,3291],{"class":3290},[2907,6493,2806],{"class":3173},[2907,6495,3297],{"class":3290},[2907,6497,3363],{"class":3290},[2907,6499,3291],{"class":3290},[2907,6501,6502],{"class":3177},"我刚才说正在学习什么？",[2907,6504,3297],{"class":3290},[2907,6506,6432],{"class":3290},[2907,6508,6509,6511,6513,6515,6517,6519,6521,6523,6525,6527,6529,6531,6533,6535,6537,6540,6542],{"class":2909,"line":3004},[2907,6510,6399],{"class":3290},[2907,6512,3291],{"class":3290},[2907,6514,2803],{"class":3173},[2907,6516,3297],{"class":3290},[2907,6518,3363],{"class":3290},[2907,6520,3291],{"class":3290},[2907,6522,2828],{"class":3177},[2907,6524,3297],{"class":3290},[2907,6526,3564],{"class":3290},[2907,6528,3291],{"class":3290},[2907,6530,2806],{"class":3173},[2907,6532,3297],{"class":3290},[2907,6534,3363],{"class":3290},[2907,6536,3291],{"class":3290},[2907,6538,6539],{"class":3177},"你刚才说正在学习 Vue 3。",[2907,6541,3297],{"class":3290},[2907,6543,6544],{"class":3290}," }\n",[2907,6546,6547],{"class":2909,"line":3023},[2907,6548,6549],{"class":3290},"    ]\n",[2907,6551,6552],{"class":2909,"line":3029},[2907,6553,3598],{"class":3290},[2758,6555,6556,6559],{},[2770,6557,6558],{},"第四步：停止并重启服务","，再次查询同一个会话 ID。消息仍在，就证明数据没有随着 Node.js 进程结束而消失；继续提问时，模型也能参考这些历史。",[6561,6562,6563],"warning",{},[2758,6564,6565],{},"本例仅供本地学习：会话 ID 不是登录凭证。公开部署前，需要校验会话归属并限制模型调用额度。",[2775,6567],{},[2753,6569,6571],{"id":6570},"知识问答","❓ 知识问答",[2758,6573,6574],{},[2770,6575,6576,6577,6579],{},"Q：为什么不直接把整个 ",[2762,6578,2764],{}," 数组存成一条数据库记录？",[2758,6581,6582],{},"这种做法也能保存简单的聊天记录，但每次新增消息都要更新整份数据。这里按消息逐条存储，可以直接追加新消息，也方便按会话查询。",[2775,6584],{},[2753,6586,6588],{"id":6587},"小练习","🧪 小练习",[2758,6590,6591],{},"分别创建“Vue”和“Node.js”两个会话，在各自会话中提问。重启服务后，使用两个会话 ID 查询历史，再任选一个会话继续提问。",[2758,6593,6594,6597],{},[2770,6595,6596],{},"验证标准："," 两个会话的记录不会混在一起；重启后仍能读取旧消息；模型只参考当前会话的历史。",[2775,6599],{},[2758,6601,6602],{},"🎉 现在，你已经完成了对话记录的保存、读取和恢复，并让模型能够在服务重启后继续原来的对话。",[6604,6605,6606],"style",{},"html pre.shiki code .sYGMc, html code.shiki .sYGMc{--shiki-light:#E2931D;--shiki-default:#FFCB6B;--shiki-dark:#FFCB6B}html pre.shiki code .sIEYB, html code.shiki .sIEYB{--shiki-light:#91B859;--shiki-default:#C3E88D;--shiki-dark:#C3E88D}html .light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html.light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html pre.shiki code .s8pZq, html code.shiki .s8pZq{--shiki-light:#39ADB5;--shiki-light-font-style:italic;--shiki-default:#89DDFF;--shiki-default-font-style:italic;--shiki-dark:#89DDFF;--shiki-dark-font-style:italic}html pre.shiki code .sndM8, html code.shiki .sndM8{--shiki-light:#90A4AE;--shiki-default:#EEFFFF;--shiki-dark:#BABED8}html pre.shiki code .s86vT, html code.shiki .s86vT{--shiki-light:#39ADB5;--shiki-default:#89DDFF;--shiki-dark:#89DDFF}html pre.shiki code .s50WR, html code.shiki .s50WR{--shiki-light:#9C3EDA;--shiki-default:#C792EA;--shiki-dark:#C792EA}html pre.shiki code .swgpB, html code.shiki .swgpB{--shiki-light:#6182B8;--shiki-default:#82AAFF;--shiki-dark:#82AAFF}html pre.shiki code .sd2Uz, html code.shiki .sd2Uz{--shiki-light:#E53935;--shiki-default:#F07178;--shiki-dark:#F07178}html pre.shiki code .smPcV, html code.shiki .smPcV{--shiki-light:#F76D47;--shiki-default:#F78C6C;--shiki-dark:#F78C6C}html pre.shiki code .sK9QF, html code.shiki .sK9QF{--shiki-light:#90A4AE;--shiki-light-font-style:italic;--shiki-default:#EEFFFF;--shiki-default-font-style:italic;--shiki-dark:#BABED8;--shiki-dark-font-style:italic}html pre.shiki code .sPKOg, html code.shiki .sPKOg{--shiki-light:#FF5370;--shiki-default:#FF9CAC;--shiki-dark:#FF9CAC}",{"title":2903,"searchDepth":2943,"depth":2943,"links":6608},[6609,6610,6611,6616,6623,6624,6625],{"id":2755,"depth":2943,"text":2756},{"id":2779,"depth":2943,"text":2780},{"id":2887,"depth":2943,"text":2888,"children":6612},[6613,6614,6615],{"id":2892,"depth":2952,"text":2893},{"id":3261,"depth":2952,"text":3262},{"id":3721,"depth":2952,"text":3722},{"id":3924,"depth":2943,"text":3925,"children":6617},[6618,6619,6620,6621,6622],{"id":3939,"depth":2952,"text":3940},{"id":4160,"depth":2952,"text":4161},{"id":4373,"depth":2952,"text":4374},{"id":5064,"depth":2952,"text":5065},{"id":5831,"depth":2952,"text":5832},{"id":6162,"depth":2943,"text":6163},{"id":6570,"depth":2943,"text":6571},{"id":6587,"depth":2943,"text":6588},"使用 MySQL 保存聊天消息，让模型在服务重启后仍能读取历史并继续对话。","md",null,{},{"title":2744},{"title":2744,"description":6626},"JvtBpUbWkI",[6634,6628],{"title":2740,"path":2741,"stem":2742,"description":6635,"children":-1},"使用 Express 接收浏览器消息，调用模型并将流式回答逐段返回给前端。",1795360449938]