index_v2.html 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436
  1. <!doctype html>
  2. <html lang="zh">
  3. <head>
  4. <meta charset="utf-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1">
  6. <title>创作知识的解构 · v2</title>
  7. <script crossorigin src="https://unpkg.com/react@18/umd/react.production.min.js"></script>
  8. <script crossorigin src="https://unpkg.com/react-dom@18/umd/react-dom.production.min.js"></script>
  9. <script src="https://unpkg.com/@babel/standalone/babel.min.js"></script>
  10. <style>
  11. *{box-sizing:border-box}
  12. html,body{margin:0;padding:0;font-family:-apple-system,"PingFang SC","Microsoft YaHei",sans-serif;font-size:13px;color:#111827;background:#f5f5f7;height:100vh;overflow:hidden}
  13. .app{height:100vh;display:flex;flex-direction:column}
  14. header.top{padding:11px 18px 9px;background:#fff;border-bottom:1px solid #e5e7eb;flex:none}
  15. header.top h1{margin:0 0 7px;font-size:16px;font-weight:600}
  16. .picker{display:flex;gap:6px;flex-wrap:wrap;align-items:center}
  17. .picker .lab{font-size:11.5px;color:#9ca3af;margin-right:2px}
  18. .pill{font-size:12px;padding:4px 11px;border-radius:14px;border:1px solid #e5e7eb;background:#fff;color:#6b7280;cursor:pointer}
  19. .pill:hover{background:#f3f4f6}
  20. .pill.on{background:#1e293b;color:#fff;border-color:#1e293b;font-weight:600}
  21. .pill .n{font-size:10px;opacity:.7;margin-left:4px}
  22. .scroll{flex:1;overflow:auto;background:#f5f5f7;padding-bottom:40px}
  23. details.src{margin:10px 18px 0;background:#fff;border:1px solid #e2e8f0;border-radius:6px}
  24. details.src summary{padding:8px 14px;cursor:pointer;font-size:12px;color:#475569;list-style:none}
  25. details.src summary::before{content:'▶ ';color:#94a3b8;font-size:10px}
  26. details.src[open] summary::before{content:'▼ '}
  27. .srcbody{padding:4px 16px 12px;font-size:12px}
  28. .srcbody a{color:#2563eb;word-break:break-all}
  29. .srcprompt{color:#0e7490;font-size:11.5px;cursor:pointer}.srcprompt:hover{text-decoration:underline}
  30. .srcimgs{display:flex;flex-wrap:wrap;gap:6px;margin-top:8px}
  31. .srcimgs img{width:80px;height:80px;object-fit:cover;border-radius:4px;border:1px solid #e2e8f0;cursor:zoom-in}
  32. .barhint{margin:8px 18px 0;font-size:11.5px;color:#6b7280}
  33. .ribbon{margin:11px 18px 0;background:#fff;border:1px solid #e2e8f0;border-radius:8px;padding:10px 14px}
  34. .rcap{font-size:11.5px;color:#6b7280;margin-bottom:8px}
  35. .rsteps{display:flex;align-items:stretch;flex-wrap:wrap}
  36. .rstep{flex:1;min-width:148px;border:1px solid #e2e8f0;border-radius:8px;padding:9px 11px;cursor:pointer;background:#f8fafc}
  37. .rstep:hover{background:#ecfeff;border-color:#99d5d0}
  38. .rstep.auto{cursor:default;background:#f1f5f9;opacity:.9}.rstep.auto:hover{background:#f1f5f9;border-color:#e2e8f0}
  39. .rtop{display:flex;align-items:center;gap:7px}
  40. .rn{width:18px;height:18px;border-radius:50%;background:#0e7490;color:#fff;font-size:11px;display:flex;align-items:center;justify-content:center;flex:none}
  41. .rstep.auto .rn{background:#94a3b8}
  42. .rlab{font-size:13.5px;font-weight:600}
  43. .rdesc{font-size:11.5px;color:#6b7280;margin:5px 0 7px;line-height:1.5}
  44. .rbtn{font-size:11.5px;color:#0e7490}.rstep.auto .rbtn{color:#94a3b8}
  45. .rarrow{display:flex;align-items:center;color:#cbd5e1;font-size:18px;padding:0 4px;flex:none}
  46. .pmwhy{font-size:12.5px;color:#92400e;background:#fffbeb;border:1px solid #fde68a;border-radius:6px;padding:8px 11px;margin-bottom:12px;line-height:1.6}
  47. .pmwhy b{color:#78350f}
  48. .lbtn{padding:3px 9px;border:1px solid #cbd5e1;border-radius:5px;background:#fff;cursor:pointer;font-size:11.5px;color:#334155;font-family:inherit}
  49. .lbtn:hover{background:#f1f5f9}.lbtn.on{background:#fef3c7;border-color:#d97706;color:#92400e;font-weight:600}
  50. /* 颗卡 */
  51. .kcard{margin:12px 18px 0;background:#fff;border:1px solid #e2e8f0;border-radius:8px;overflow:hidden}
  52. .khead{display:flex;align-items:center;gap:8px;padding:9px 14px;border-bottom:1px solid #eef2f7;flex-wrap:wrap}
  53. .kno{font-size:11px;font-weight:700;color:#fff;background:#475569;border-radius:4px;padding:1px 7px}
  54. .ktype{font-size:11px;font-weight:700;border-radius:4px;padding:1px 8px}
  55. .ty-how{background:#cffafe;color:#155e75}.ty-what{background:#fae8ff;color:#86198f}.ty-why{background:#fef9c3;color:#854d0e}
  56. .ktitle{font-size:14px;font-weight:600}
  57. .krole{font-size:10.5px;padding:1px 6px;border-radius:3px;background:#f1f5f9;color:#64748b}
  58. .kref{font-size:11px;color:#0e7490;cursor:pointer}.kref:hover{text-decoration:underline}
  59. .srcbtn{cursor:pointer;color:#0e7490;margin-left:3px;user-select:none}.srcbtn:hover{color:#155e75}
  60. .srccard{border:1px solid #e2e8f0;border-radius:6px;padding:8px 10px;margin:8px 0;background:#f8fafc}
  61. .srccard .ci{font-size:11.5px;color:#6b7280;font-weight:600;margin-bottom:5px}
  62. .srccard img{max-width:100%;max-height:360px;border-radius:5px;border:1px solid #e2e8f0;cursor:zoom-in}
  63. .srccard video{max-width:100%;max-height:300px;border-radius:5px}
  64. .srcread{font-size:12.5px;color:#1f2937;line-height:1.6;margin-top:6px;background:#fff;border-left:3px solid #0e7490;padding:6px 9px}
  65. .kbiz{font-size:11px;padding:1px 7px;border-radius:3px;background:#fef3c7;color:#92400e}
  66. .kacts{margin-left:auto;display:flex;gap:6px}
  67. .kbody{padding:6px 14px 13px}
  68. /* how 工序表 */
  69. .twrap{overflow:auto;border:1px solid #e5e7eb;border-radius:6px;margin-top:8px}
  70. table.proc{width:max-content;min-width:100%;border-collapse:collapse;font-size:12px}
  71. table.proc th,table.proc td{border:1px solid #e5e7eb;padding:6px 8px;vertical-align:top;line-height:1.5}
  72. table.proc thead th{font-weight:600;text-align:center;font-size:12px;position:sticky;top:0;z-index:3}
  73. table.proc thead tr:nth-child(2) th{top:30px}
  74. td.idx{width:30px;text-align:center;color:#6b7280;background:#f8fafc}
  75. th.c-intent,td.intent{width:210px;min-width:210px;max-width:210px;white-space:pre-wrap}
  76. th.c-cstage,td.cstage{width:54px;text-align:center;background:#ecfeff}
  77. th.c-act,td.act{min-width:110px;max-width:140px;word-break:break-word;background:#ecfeff}
  78. th.c-dir,td.dir{min-width:230px;max-width:330px;white-space:pre-wrap;word-break:break-word;background:#ecfeff}
  79. th.c-out,td.out{min-width:160px;max-width:240px;white-space:pre-wrap;background:#ecfeff}
  80. th.c-scope,td.scope{width:92px;min-width:92px;max-width:92px;word-break:break-word}
  81. th.g-frame{background:#0e7490;color:#fff;cursor:pointer}th.g-frame:hover{background:#155e75}
  82. th.g-scope{background:#7c3aed;color:#fff;cursor:pointer}th.g-scope:hover{background:#6d28d9}
  83. th.c-idx{background:#475569;color:#fff;vertical-align:middle}
  84. thead tr:nth-child(2) th.c-intent,thead tr:nth-child(2) th.c-cstage,thead tr:nth-child(2) th.c-act,thead tr:nth-child(2) th.c-dir,thead tr:nth-child(2) th.c-out{background:#0891b2;color:#fff}
  85. thead tr:nth-child(2) th.s-substance{background:#dc2626;color:#fff}thead tr:nth-child(2) th.s-form{background:#2563eb;color:#fff}
  86. thead tr:nth-child(2) th.s-feeling{background:#db2777;color:#fff}thead tr:nth-child(2) th.s-effect{background:#16a34a;color:#fff}thead tr:nth-child(2) th.s-intent{background:#d97706;color:#fff}
  87. td.scope.s-substance{background:#fef2f2}td.scope.s-form{background:#eff6ff}td.scope.s-feeling{background:#fdf2f8}td.scope.s-effect{background:#f0fdf4}td.scope.s-intent{background:#fffbeb}
  88. tr.step>td{border-top:1.5px solid #cbd5e1}
  89. .cstage-chip{display:inline-block;font-size:11px;padding:1px 6px;border-radius:10px;background:#ede9fe;color:#5b21b6}
  90. .act-chip{display:inline-block;font-size:11.5px;padding:1px 7px;border-radius:4px;background:#fff7ed;color:#9a3412;border:1px solid #fed7aa}
  91. .dir-txt{font-size:11.5px;color:#33312c;line-height:1.65}.out-txt{font-size:11.5px;color:#166534}
  92. .in-txt{font-size:11.5px;color:#1e40af;line-height:1.6}
  93. .cue{font-size:11px;color:#7c2d12;background:#fff7ed;border-left:2px solid #fb923c;padding:3px 7px;margin-top:4px;border-radius:0 4px 4px 0}
  94. .cue b{color:#9a3412}
  95. .kindb{font-size:10.5px;font-weight:700;padding:1px 8px;border-radius:9px;margin-right:8px;vertical-align:middle;cursor:help}
  96. .kind-选项{background:#dbeafe;color:#1e40af}.kind-构成{background:#dcfce7;color:#166534}
  97. .ksec-f.key{background:#fde68a;color:#92400e;font-weight:700}
  98. .glossbtn{background:#ede9fe!important;color:#6d28d9!important;border-color:#ddd6fe!important}
  99. .v2tag{font-size:11px;font-weight:500;color:#fff;background:#7c3aed;padding:2px 9px;border-radius:10px;margin-left:8px;vertical-align:middle}
  100. .from{font-size:11px;color:#9ca3af}
  101. /* what/why 自由小节 */
  102. .def{font-size:13px;background:#fdf4ff;border-left:3px solid #a21caf;border-radius:0 6px 6px 0;padding:8px 12px;margin:6px 0 10px}
  103. .ksec{margin:9px 0;padding-left:11px;border-left:3px solid #e2e8f0}
  104. .ksec-h{display:flex;align-items:center;gap:7px;margin-bottom:4px}
  105. .ksec-t{font-size:13px;font-weight:600;color:#334155}
  106. .ksec-f{font-size:10.5px;padding:1px 7px;border-radius:9px;background:#f1f5f9;color:#64748b}
  107. .ksec-c{font-size:12.5px;line-height:1.65;color:#1f2937;margin-bottom:4px}
  108. table.elem{border-collapse:collapse;width:100%;font-size:12.5px}
  109. table.elem td{border:1px solid #f0e6f5;padding:6px 10px;text-align:left;vertical-align:top}
  110. table.elem td.el{font-weight:600;color:#86198f;background:#fdf4ff;width:130px}
  111. /* why 论点卡 */
  112. .why-row{display:flex;gap:10px;margin:7px 0}
  113. .why-lab{font-size:11px;font-weight:700;border-radius:4px;padding:2px 8px;flex:none;height:20px}
  114. .wl-claim{background:#fef9c3;color:#854d0e}.wl-basis{background:#e0e7ff;color:#3730a3}.wl-impact{background:#dcfce7;color:#166534}
  115. .why-txt{font-size:12.5px;line-height:1.65;color:#1f2937}
  116. /* 颗级作用域 */
  117. .kscopes{margin-top:9px;display:flex;gap:5px;flex-wrap:wrap;align-items:center}
  118. .kscopes .lab{font-size:11px;color:#9ca3af}
  119. .sv{display:inline-block;cursor:pointer;font-size:11.5px;padding:1px 5px;border-radius:3px;border:1px solid rgba(0,0,0,.08);background:rgba(255,255,255,.7);margin:1px 0}
  120. .sv:hover{box-shadow:0 0 0 1px #1e293b}
  121. .sv .k{font-size:11.5px;opacity:.85;font-weight:700;margin-right:4px}
  122. table.proc th.c-scope{font-size:13.5px}
  123. .sv .mk{font-size:9px;padding:0 3px;border-radius:2px;margin-left:3px;vertical-align:top}
  124. .mk-new{background:#fde68a;color:#92400e}.mk-reuse{background:#bbf7d0;color:#166534}
  125. .sv.s-substance{background:#fef2f2}.sv.s-form{background:#eff6ff}.sv.s-feeling{background:#fdf2f8}.sv.s-effect{background:#f0fdf4}.sv.s-intent{background:#fffbeb}
  126. body.hl .sv .mk-new{outline:2px solid #d97706}
  127. /* drawer + modal */
  128. .ov{position:fixed;inset:0;background:rgba(0,0,0,.35);z-index:100}
  129. .drawer{position:fixed;right:0;top:0;bottom:0;width:440px;max-width:92vw;background:#fff;box-shadow:-4px 0 16px rgba(0,0,0,.15);z-index:101;overflow-y:auto}
  130. .drawer h2{margin:0;padding:13px 16px;background:#1e293b;color:#fff;font-size:14px;display:flex;align-items:center}
  131. .drawer h2 .x{margin-left:auto;cursor:pointer;font-size:18px}
  132. .dc{padding:14px 16px;font-size:12.5px;line-height:1.6}.dc .row{margin:6px 0}.dc b{color:#374151}
  133. .verdict{display:inline-block;padding:2px 9px;border-radius:5px;font-weight:600;font-size:12px}
  134. .v-new{background:#fef3c7;color:#92400e}.v-reuse{background:#dcfce7;color:#166534}
  135. .nn{margin:5px 0;padding:7px 10px;border:1px solid #e5e7eb;border-radius:5px;background:#f8fafc}
  136. .nn .nm{font-weight:600}.nn .sc{float:right;color:#6b7280;font-family:ui-monospace,monospace}
  137. .nn .pth{color:#9ca3af;font-size:11px;font-family:ui-monospace,monospace;word-break:break-all}
  138. .modal{position:fixed;inset:0;background:rgba(0,0,0,.45);z-index:110;display:flex;align-items:center;justify-content:center;padding:20px}
  139. .mbox{background:#fff;width:760px;max-width:94vw;max-height:86vh;border-radius:10px;overflow:hidden;display:flex;flex-direction:column}
  140. .mbox h2{margin:0;padding:13px 18px;background:#0f766e;color:#fff;font-size:14px;display:flex;align-items:center}
  141. .mbox h2 .x{margin-left:auto;cursor:pointer;font-size:18px}
  142. .mbox .body{padding:15px 18px;overflow:auto}.mbox pre{margin:0;font:12.5px/1.7 ui-monospace,Menlo,monospace;white-space:pre-wrap;color:#1f2937}
  143. /* 提示词 Markdown 渲染 */
  144. .md{font-size:13px;line-height:1.7;color:#1f2937}
  145. .md h3{font-size:16px;margin:18px 0 8px;padding-bottom:5px;border-bottom:2px solid #0f766e;color:#0f766e}
  146. .md h4{font-size:14px;margin:15px 0 6px;color:#0f766e}
  147. .md h5,.md h6{font-size:13px;margin:12px 0 5px;color:#115e59}
  148. .md p{margin:8px 0}
  149. .md strong{color:#9a3412;font-weight:700}
  150. .md code{background:#f1f5f9;color:#be123c;padding:1px 5px;border-radius:4px;font:12px ui-monospace,Menlo,monospace}
  151. .md pre{background:#0f172a;border-radius:8px;padding:12px 14px;overflow-x:auto;margin:10px 0}
  152. .md pre code{background:none;color:#e2e8f0;padding:0;font-size:12px;line-height:1.6}
  153. .md blockquote{margin:10px 0;padding:8px 12px;background:#f0fdfa;border-left:3px solid #14b8a6;border-radius:0 6px 6px 0;color:#134e4a}
  154. .md ul,.md ol{margin:8px 0;padding-left:22px}.md li{margin:4px 0}
  155. .md hr{border:none;border-top:1px dashed #cbd5e1;margin:14px 0}
  156. .md table{border-collapse:collapse;width:100%;margin:10px 0;font-size:12.5px}
  157. .md th,.md td{border:1px solid #cbd5e1;padding:6px 9px;text-align:left;vertical-align:top}
  158. .md th{background:#0f766e;color:#fff;font-weight:600;white-space:nowrap}
  159. .md tbody tr:nth-child(even){background:#f8fafc}
  160. .md a{color:#0e7490;text-decoration:underline}
  161. .md .ptag{font-size:14px;font-weight:700;color:#0f766e;margin:16px 0 7px;padding:4px 10px;background:#ccfbf1;border-radius:6px;display:inline-block}
  162. .md .ptag-ex{font-size:12px;font-weight:600;color:#92400e;background:#fef3c7;margin:11px 0 5px;padding:2px 9px}
  163. .md .ptag-sub{font-weight:400;font-size:11.5px;opacity:.8;margin-left:7px}
  164. .lb{position:fixed;inset:0;background:rgba(0,0,0,.85);display:flex;align-items:center;justify-content:center;z-index:120;cursor:zoom-out}.lb img{max-width:92vw;max-height:92vh;border-radius:6px}
  165. .empty{color:#9ca3af;padding:50px;text-align:center}
  166. </style>
  167. </head>
  168. <body>
  169. <div id="root"></div>
  170. <script type="text/x-jsx" id="app-src">
  171. const {useState,useEffect}=React;
  172. const j=u=>fetch(u,{cache:"no-store"}).then(r=>r.json());
  173. const SCOPES=[["substance","实质"],["form","形式"],["feeling","感受"],["effect","作用"],["intent","意图"]];
  174. const SC_CN={substance:"实质",form:"形式",feeling:"感受",effect:"作用",intent:"意图"};
  175. const TYPECN={how:"How 工序",what:"What 构成",why:"Why 原理"};
  176. // 把提示词里的"黑话"形式标签换成大白话(找不到就原样显示)
  177. const FORM_PLAIN={"取舍":"怎么用","依据":"为什么对","机制":"怎么起作用","平台逻辑":"平台规则","读者心理":"读者心理","例证":"例子","反例":"反例","判据":"判断标准","对照":"对比","清单":"清单","分类":"分类","定义":"定义","维度":"方面"};
  178. const plainForm=f=>FORM_PLAIN[f]||f;
  179. const GLOSSARY=`## 一篇帖子能拆出三种知识(平级的)
  180. 这三种各帮你做一个不同的决定,没有谁更重要。
  181. | 标签 | 大白话 | 它帮你决定 |
  182. |---|---|---|
  183. | **怎么做** (How) | 一步步把东西做出来的流程 | 按什么**顺序**做 |
  184. | **是什么** (What) | 某东西由什么组成 / 有哪些种类 | 用**哪些料** |
  185. | **为什么** (Why) | 背后的道理、标准、平台规则 | 该**留什么、砍什么** |
  186. ## 「是什么」分两种
  187. - **组成·都要用**(构成型):像配方,列出的几样要**全用上**(例:人物 = 生理+社会+心理)。
  188. - **可选·挑着用**(选项型):像菜单,列出几种**选一种**用(例:7 种叙事结构挑一种)。
  189. - 每个选项后面那句 **👉 什么时候用** 就是「**选择线索**」——告诉你哪种情况该挑它。没有它,就只能背、不会选。
  190. ## 「为什么」里每条道理的小标签
  191. 说明这条是哪种支撑:
  192. - **怎么用**(原"取舍"):这条道理落到创作上——该多写什么、砍什么。**最重要,每条「为什么」都有**。
  193. - **为什么对**(原"依据"):这条说法凭什么成立。
  194. - **怎么起作用**(原"机制"):它是怎么运转、起效果的。
  195. - **平台规则 / 读者心理**:从平台算法、或读者角度的解释。
  196. - 例子 / 反例 / …:举例支撑(这些标签是开放的,可能还有别的)。`;
  197. const STEPS=[
  198. {key:"read",label:"读懂帖子",desc:"把图、视频读成文字",
  199. why:"创作知识常在图里、不在正文;这一步只忠实转写、不判断,避免一步干两件事。",
  200. src:["/prompt-read/extract.txt"]},
  201. {key:"frame",label:"拆出知识",desc:"从文字里拆出一条条知识,理清每条是 怎么做 / 是什么 / 为什么",
  202. why:"先判类型再拆——三类成形不同,默认 how 会把纯 what 硬掰成假 how;how 先吸进步骤里的 what/why,吸不进的才独立成一条。",
  203. src:["/prompt-skill/phase1-frame.md"]},
  204. {key:"scope",label:"给知识归类",desc:"标好 讲什么 / 起什么作用 / 哪个创作环节,再和已有分类库对上号",
  205. why:"这 5 类标签最容易串味,又要中途调向量回扣工具;单独一步写厚,避免塞进一个提示词复杂到死循环。",
  206. src:["/prompt-skill/phase2-scope.md"]},
  207. {key:"store",label:"存进知识库",desc:"整理成统一格式存起来,供以后调用",
  208. why:"纯拼接 + 校验的确定性活,程序自动做——没有提示词,让 AI 来干只会帮倒忙。",
  209. src:null}
  210. ];
  211. const STEPMAP={}; STEPS.forEach(s=>STEPMAP[s.key]=s);
  212. // 极简 Markdown 渲染(自带、无外部依赖):标题/表格/代码/引用/列表/加粗/行内码/链接
  213. function mdToHtml(src){
  214. var escc=function(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;");};
  215. var inline=function(t){
  216. t=escc(t);
  217. t=t.replace(/`([^`]+)`/g,'<code>$1</code>');
  218. t=t.replace(/\*\*([^*]+)\*\*/g,'<strong>$1</strong>');
  219. t=t.replace(/\[([^\]]+)\]\(([^)]+)\)/g,'<a href="$2" target="_blank">$1</a>');
  220. return t;
  221. };
  222. var L=(src||"").split("\n"), out=[], i=0;
  223. var isStruct=function(s){return /^```/.test(s)||/^\s*#{1,6}\s/.test(s)||/^\s*>\s?/.test(s)||/^\s*[-*]\s+/.test(s)||/^\s*\d+\.\s+/.test(s)||/^\s*([-*_])(\s*\1){2,}\s*$/.test(s)||/^\s*\|/.test(s)||/^\s*<\/?[^<>]+>/.test(s);};
  224. while(i<L.length){
  225. var ln=L[i];
  226. if(/^```/.test(ln)){ var b=[]; i++; while(i<L.length&&!/^```/.test(L[i])){b.push(L[i]);i++;} i++; out.push("<pre><code>"+escc(b.join("\n"))+"</code></pre>"); continue; }
  227. if(/^\s*\|/.test(ln)&&i+1<L.length&&/^\s*\|?[\s:|-]*-[\s:|-]*\|?\s*$/.test(L[i+1])){
  228. var head=ln, rows=[]; i+=2;
  229. while(i<L.length&&/^\s*\|/.test(L[i])&&L[i].trim()!==""){rows.push(L[i]);i++;}
  230. var cells=function(r){r=r.trim().replace(/^\|/,"").replace(/\|$/,"");return r.split("|").map(function(c){return c.trim();});};
  231. var th=cells(head).map(function(c){return "<th>"+inline(c)+"</th>";}).join("");
  232. var tb=rows.map(function(r){return "<tr>"+cells(r).map(function(c){return "<td>"+inline(c)+"</td>";}).join("")+"</tr>";}).join("");
  233. out.push("<table><thead><tr>"+th+"</tr></thead><tbody>"+tb+"</tbody></table>"); continue;
  234. }
  235. if(/^\s*([-*_])(\s*\1){2,}\s*$/.test(ln)){ out.push("<hr/>"); i++; continue; }
  236. var tag=ln.match(/^\s*<(\/?)([^<>\/][^<>]*)>\s*(.*)$/); // 行首伪标签(如 <工作要点> / <example> 描述)→ 当小节标题
  237. if(tag){ if(tag[1]){i++;continue;} var nm=tag[2], rest=tag[3].trim(), ex=/^example$/i.test(nm);
  238. out.push('<div class="ptag'+(ex?' ptag-ex':'')+'">'+inline(ex?'示例':nm)+(rest?'<span class="ptag-sub">'+inline(rest)+'</span>':'')+"</div>"); i++; continue; }
  239. var h=ln.match(/^\s*(#{1,6})\s+(.*)$/);
  240. if(h){ var lv=Math.min(h[1].length+2,6); out.push("<h"+lv+">"+inline(h[2])+"</h"+lv+">"); i++; continue; }
  241. if(/^\s*>\s?/.test(ln)){ var q=[]; while(i<L.length&&/^\s*>\s?/.test(L[i])){q.push(inline(L[i].replace(/^\s*>\s?/,"")));i++;} out.push("<blockquote>"+q.join("<br/>")+"</blockquote>"); continue; }
  242. if(/^\s*[-*]\s+/.test(ln)){ var ul=[]; while(i<L.length&&/^\s*[-*]\s+/.test(L[i])){ul.push("<li>"+inline(L[i].replace(/^\s*[-*]\s+/,""))+"</li>");i++;} out.push("<ul>"+ul.join("")+"</ul>"); continue; }
  243. if(/^\s*\d+\.\s+/.test(ln)){ var ol=[]; while(i<L.length&&/^\s*\d+\.\s+/.test(L[i])){ol.push("<li>"+inline(L[i].replace(/^\s*\d+\.\s+/,""))+"</li>");i++;} out.push("<ol>"+ol.join("")+"</ol>"); continue; }
  244. if(ln.trim()===""){ i++; continue; }
  245. var p=[]; while(i<L.length&&L[i].trim()!==""&&!isStruct(L[i])){p.push(inline(L[i]));i++;} out.push("<p>"+p.join("<br/>")+"</p>");
  246. }
  247. return out.join("\n");
  248. }
  249. function Ribbon({onOpen}){
  250. return <div className="ribbon">
  251. <div className="rcap">这套系统怎么「从帖子拆解知识」——点任一步看它的提示词</div>
  252. <div className="rsteps">{STEPS.map((s,i)=><React.Fragment key={s.key}>
  253. {i>0&&<span className="rarrow">→</span>}
  254. <div className={"rstep"+(s.src?"":" auto")} onClick={()=>onOpen(s.key)}>
  255. <div className="rtop"><span className="rn">{i+1}</span><span className="rlab">{s.label}</span></div>
  256. <div className="rdesc">{s.desc}</div>
  257. <div className="rbtn">{s.src?"📄 看提示词":"⚙️ 程序自动"}</div>
  258. </div></React.Fragment>)}</div>
  259. </div>;
  260. }
  261. function ScopeChip({x,onScope,showType}){
  262. return <span className={"sv s-"+x.scope_type} onClick={()=>onScope(x)}>{showType&&<span className="k">{SC_CN[x.scope_type]||x.scope_type}</span>}{x.value}<span className={"mk "+(x.link==="复用"?"mk-reuse":"mk-new")}>{x.link==="复用"?"复":"新"}</span></span>;
  263. }
  264. function KScopes({list,onScope}){
  265. if(!list||!list.length) return null;
  266. return <div className="kscopes"><span className="lab">作用域(5 棵树):</span>
  267. {list.map((x,i)=><ScopeChip key={i} x={{...x}} onScope={onScope} showType={true}/>)}</div>;
  268. }
  269. function HowTable({k,onScope,onPrompt,onSource}){
  270. const steps=k.steps||[];
  271. const scOf=(s,t)=>(s.作用域||[]).filter(x=>x.scope_type===t);
  272. return <div className="twrap"><table className="proc">
  273. <thead>
  274. <tr><th className="c-idx" rowSpan="2">#</th>
  275. <th className="g-frame" colSpan="5" onClick={()=>onPrompt("frame")}>② 拆框架 + 轻标签 ▸ 提示词</th>
  276. <th className="g-scope" colSpan="5" onClick={()=>onPrompt("scope")}>③ 作用域 ▸ 提示词</th></tr>
  277. <tr><th className="c-intent">输入</th><th className="c-cstage">创作<br/>阶段</th><th className="c-act">动作</th><th className="c-dir">方法</th><th className="c-out">产出</th>
  278. {SCOPES.map(([kk,cn])=><th key={kk} className={"c-scope s-"+kk}>{cn}</th>)}</tr>
  279. </thead>
  280. <tbody>{steps.map((s,i)=><tr className="step" key={i}>
  281. <td className="idx">{i+1}</td>
  282. <td className="intent"><span className="in-txt">{s.input}</span>{s.出处&&s.出处.length>0&&<span className="srcbtn" title={"看原文出处 "+s.出处.join(" ")} onClick={()=>onSource(s.出处)}>🔍</span>}</td>
  283. <td className="cstage">{s.创作阶段&&<span className="cstage-chip">{s.创作阶段}</span>}</td>
  284. <td className="act">{s.动作&&<span className="act-chip">{s.动作}</span>}</td>
  285. <td className="dir"><span className="dir-txt">{s.directive}</span></td>
  286. <td className="out"><span className="out-txt">{s.output}</span></td>
  287. {SCOPES.map(([kk])=><td key={kk} className={"scope s-"+kk}>{scOf(s,kk).map((x,j)=><ScopeChip key={j} x={x} onScope={onScope}/>)}</td>)}
  288. </tr>)}</tbody>
  289. </table></div>;
  290. }
  291. function KSection({b}){
  292. const items=b.条目||[];
  293. const isKey=b.形式==="取舍";
  294. return <div className="ksec">
  295. <div className="ksec-h">{b.小标题&&<span className="ksec-t">{b.小标题}</span>}{b.形式&&<span className={"ksec-f"+(isKey?" key":"")} title={"原标签:"+b.形式}>{isKey?"💡 ":""}{plainForm(b.形式)}</span>}</div>
  296. {b.内容&&<div className="ksec-c">{b.内容}</div>}
  297. {items.length>0&&<table className="elem"><tbody>{items.map((c,i)=><tr key={i}>
  298. <td className="el">{c.词||c.要素}</td><td>{c.说明}{c.选择线索&&<div className="cue"><b>👉 什么时候用:</b>{c.选择线索}</div>}</td></tr>)}</tbody></table>}
  299. </div>;
  300. }
  301. function WhatCard({k,onScope,onGloss}){
  302. return <div>
  303. {k.界定&&<div className="def">{k.kind&&<span className={"kindb kind-"+k.kind} title="点开「名词说明」看区别" onClick={()=>onGloss&&onGloss()}>{k.kind==="选项"?"🎯 可选·挑着用":"🧩 组成·都要用"}</span>}界定:{k.界定}</div>}
  304. {(k.主体||[]).map((b,i)=><KSection key={i} b={b}/>)}
  305. <KScopes list={k.作用域} onScope={onScope}/>
  306. </div>;
  307. }
  308. function WhyCard({k,onScope}){
  309. return <div>
  310. {k.主张&&<div className="why-row"><span className="why-lab wl-claim">主张</span><span className="why-txt">{k.主张}</span></div>}
  311. {(k.支撑||[]).map((b,i)=><KSection key={i} b={b}/>)}
  312. <KScopes list={k.作用域} onScope={onScope}/>
  313. </div>;
  314. }
  315. function KnowledgeCard({k,idx,onScope,onPrompt,onJson,onSource,payload,how_titles,onGloss}){
  316. const par=k.parent;
  317. return <div className="kcard" id={"k-"+k.id}>
  318. <div className="khead">
  319. <span className="kno">第{idx+1}颗</span>
  320. <span className={"ktype ty-"+k.type}>{TYPECN[k.type]}</span>
  321. <span className="ktitle">{k.title}</span>
  322. {k.出处&&k.出处.length>0&&<span className="kref" title={"看原文出处 "+k.出处.join(" ")} onClick={()=>onSource(k.出处)}>🔍 出处 {k.出处.join(" ")}</span>}
  323. {par&&<span className="kref" onClick={()=>{var e=document.getElementById("k-"+par.how_id);if(e)e.scrollIntoView({behavior:"smooth",block:"center"});}}>↑ 出自「{how_titles[par.how_id]||par.how_id}」第{par.step}步</span>}
  324. {(k.业务阶段||[]).map((b,i)=><span key={i} className="kbiz">业务阶段:{b}</span>)}
  325. <span className="kacts">{payload&&<button className="lbtn" onClick={()=>onJson(payload)}>⚙️ 入库 payload</button>}</span>
  326. </div>
  327. <div className="kbody">
  328. {k.type==="how"&&<HowTable k={k} onScope={onScope} onPrompt={onPrompt} onSource={onSource}/>}
  329. {k.type==="what"&&<WhatCard k={k} onScope={onScope} onGloss={onGloss}/>}
  330. {k.type==="why"&&<WhyCard k={k} onScope={onScope}/>}
  331. </div>
  332. </div>;
  333. }
  334. function App(){
  335. const [items,setItems]=useState([]);
  336. const [sel,setSel]=useState(0);
  337. const [scope,setScope]=useState(null);
  338. const [pm,setPm]=useState(null);
  339. const [json,setJson]=useState(null);
  340. const [zoom,setZoom]=useState(null);
  341. const [src,setSrc]=useState(null);
  342. const [hl,setHl]=useState(false);
  343. const [gloss,setGloss]=useState(false);
  344. useEffect(()=>{Promise.all([j("/frameworks_v2.json"),j("/payloads_v2.json").catch(()=>[])]).then(([f,pl])=>{
  345. setItems((f.posts||[]).map(p=>({...p,payloads:(pl||[]).filter(x=>(x.source||{}).id===(p.source_id||("xhs_"+p.post_id)))})));});},[]);
  346. useEffect(()=>{document.body.classList.toggle("hl",hl);},[hl]);
  347. function openPrompt(key){
  348. const st=STEPMAP[key]; if(!st) return;
  349. if(!st.src){ setPm({label:st.label,why:st.why,text:"(这一步是程序自动完成的,没有提示词。)"}); return; }
  350. setPm({label:st.label,why:st.why,text:"加载中…"});
  351. Promise.all(st.src.map(u=>fetch(u,{cache:"no-store"}).then(r=>r.ok?r.text():"(未找到 "+u+")").catch(()=>"(加载失败 "+u+")")))
  352. .then(txts=>setPm({label:st.label,why:st.why,text:txts.join("\n\n──────\n\n")}));
  353. }
  354. if(!items.length) return <div className="empty">加载中…</div>;
  355. const it=items[sel];
  356. const ks=it.knowledges||[];
  357. const how_titles={}; ks.forEach(k=>{if(k.type==="how")how_titles[k.id]=k.title;});
  358. const payloadOf=k=>(it.payloads||[]).find(p=>p.title===k.title);
  359. const media=it.media||{}; const imgs=media.images||[]; const videoUrl=media.video_url;
  360. const cardsById={}; (it.cards||[]).forEach(c=>cardsById[c.index]=c);
  361. const openSource=list=>{var cs=(list||[]).map(s=>{var m=String(s).match(/\d+/);return m?cardsById[parseInt(m[0])]:null;}).filter(Boolean);if(cs.length)setSrc({cards:cs});};
  362. const fmtT=s=>{s=Math.floor(s||0);return Math.floor(s/60)+":"+String(s%60).padStart(2,"0");};
  363. return <div className="app">
  364. <header className="top">
  365. <h1>创作知识的解构 <span className="v2tag">v2 · 决策落点版(How 输入→方法→产出 / What 选项+选择线索 / Why 必带取舍)</span></h1>
  366. <div className="picker"><span className="lab">帖子:</span>
  367. {items.map((x,i)=><div key={i} className={"pill"+(sel===i?" on":"")} onClick={()=>{setSel(i);setScope(null);}}>{x.title.slice(0,16)}<span className="n">{(x.knowledges||[]).length}颗</span></div>)}
  368. </div>
  369. </header>
  370. <div className="scroll">
  371. <Ribbon onOpen={openPrompt}/>
  372. <details className="src"><summary>原帖:{it.title}(这一帖的原料)· {it.platform}{videoUrl?" · 视频":""}</summary>
  373. <div className="srcbody"><a href={it.url} target="_blank" rel="noreferrer">{it.url}</a>
  374. {videoUrl
  375. ? <div style={{marginTop:8}}><video src={videoUrl} controls style={{maxWidth:"380px",maxHeight:"320px",borderRadius:"6px",border:"1px solid #e2e8f0"}}/></div>
  376. : <div className="srcimgs">{imgs.map((u,i)=><img key={i} src={u} onClick={()=>setZoom(u)} onError={e=>e.target.style.display='none'}/>)}</div>}
  377. </div>
  378. </details>
  379. <div className="barhint" style={{display:"flex",gap:8,alignItems:"center"}}>
  380. <span>这一帖拆出 <b>{ks.length}</b> 颗知识(how 工序表 / what 构成卡 / why 论点卡);组件颗标「出自某 how 第 N 步」可点跳。</span>
  381. <button className="lbtn glossbtn" onClick={()=>setGloss(true)} style={{marginLeft:"auto"}}>❓ 名词说明</button>
  382. <button className={"lbtn"+(hl?" on":"")} onClick={()=>setHl(!hl)}>高亮「新值」</button>
  383. </div>
  384. {ks.length===0 && <div className="kcard"><div className="kbody" style={{padding:"20px 16px",color:"#9ca3af",fontSize:"13px"}}>🚫 这帖<b style={{color:"#6b7280"}}>没有可提取的创作知识</b>(纯作品 / 展示 / 无关)——① 读懂时 <code>is_empty=true</code>,后面拆颗/归类/入库已自动跳过。</div></div>}
  385. {ks.map((k,i)=><KnowledgeCard key={i} k={k} idx={i} onScope={setScope} onPrompt={openPrompt} onJson={setJson} onSource={openSource} payload={payloadOf(k)} how_titles={how_titles} onGloss={()=>setGloss(true)}/>)}
  386. </div>
  387. {scope&&<div><div className="ov" onClick={()=>setScope(null)}></div>
  388. <div className="drawer"><h2>作用域回扣详情<span className="x" onClick={()=>setScope(null)}>×</span></h2>
  389. <div className="dc">
  390. <div className="row"><b>提取候选值</b>:{scope.candidate||scope.value}</div>
  391. <div className="row"><b>判定</b>:<span className={"verdict "+(scope.link==="复用"?"v-reuse":"v-new")}>{scope.link==="复用"?"复用现有节点":"新建(树里没有)"}</span> = 最近邻 {scope.score}</div>
  392. <div className="row"><b>最终入库值</b>:{scope.value}</div>
  393. <h3 style={{margin:"12px 0 6px",fontSize:12.5,color:"#475569"}}>分类树最近邻 top-{(scope.top||[]).length}(火山余弦)</h3>
  394. {(scope.top||[]).map((h,i)=><div className="nn" key={i}><span className="sc">{h.score}</span><span className="nm">{h.name}</span><div className="pth">{h.path}</div></div>)}
  395. {(!scope.top||!scope.top.length)&&<div style={{color:"#9ca3af"}}>无最近邻</div>}
  396. </div></div></div>}
  397. {pm&&<div className="modal" onClick={()=>setPm(null)}><div className="mbox" onClick={e=>e.stopPropagation()}>
  398. <h2>📄 {pm.label} · 这一步的提示词<span className="x" onClick={()=>setPm(null)}>×</span></h2>
  399. <div className="body">
  400. <div className="pmwhy"><b>为什么这么做:</b>{pm.why}</div>
  401. {pm.text==="加载中…"?<pre>{pm.text}</pre>:<div className="md" dangerouslySetInnerHTML={{__html:mdToHtml(pm.text)}}/>}</div></div></div>}
  402. {json&&<div className="modal" onClick={()=>setJson(null)}><div className="mbox" onClick={e=>e.stopPropagation()}>
  403. <h2>⚙️ ingest payload(给机器看)<span className="x" onClick={()=>setJson(null)}>×</span></h2>
  404. <div className="body"><pre>{JSON.stringify(json,null,2)}</pre></div></div></div>}
  405. {src&&<div className="modal" onClick={()=>setSrc(null)}><div className="mbox" onClick={e=>e.stopPropagation()}>
  406. <h2>🔍 原文出处(① 读到的卡片)<span className="x" onClick={()=>setSrc(null)}>×</span></h2>
  407. <div className="body">{src.cards.map((c,i)=><div className="srccard" key={i}>
  408. <div className="ci">卡片{c.index}{c.start!=null?(" · "+fmtT(c.start)+"–"+fmtT(c.end)):""}</div>
  409. {c.image_url&&<img src={c.image_url} onClick={()=>setZoom(c.image_url)} onError={e=>e.target.style.display='none'}/>}
  410. {c.video_url&&<video src={c.video_url+(c.start!=null?("#t="+Math.floor(c.start)+","+Math.floor(c.end)):"")} controls/>}
  411. {c.content?<div className="srcread">① 在这张卡读到的:{c.content}</div>:<div style={{color:"#9ca3af",fontSize:"12px",marginTop:5}}>(这张卡没读到要点)</div>}
  412. </div>)}</div></div></div>}
  413. {gloss&&<div className="modal" onClick={()=>setGloss(false)}><div className="mbox" onClick={e=>e.stopPropagation()}>
  414. <h2>❓ 名词说明 · 用大白话讲清楚<span className="x" onClick={()=>setGloss(false)}>×</span></h2>
  415. <div className="body"><div className="md" dangerouslySetInnerHTML={{__html:mdToHtml(GLOSSARY)}}/></div></div></div>}
  416. {zoom&&<div className="lb" onClick={()=>setZoom(null)}><img src={zoom}/></div>}
  417. </div>;
  418. }
  419. ReactDOM.createRoot(document.getElementById("root")).render(<App/>);
  420. </script>
  421. <script>
  422. (function(){var src=document.getElementById("app-src").textContent;
  423. var out=Babel.transform(src,{presets:[["react",{runtime:"classic"}]]}).code;(0,eval)(out);})();
  424. </script>
  425. </body>
  426. </html>