southnote-mini-sdk 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (309) hide show
  1. package/app.js +22 -0
  2. package/app.json +53 -0
  3. package/app.wxss +15 -0
  4. package/assets/file/badwords.js +63008 -0
  5. package/assets/file/rules.js +38 -0
  6. package/assets/images/emoji/smile001.png +0 -0
  7. package/assets/images/emoji/smile002.png +0 -0
  8. package/assets/images/emoji/smile003.png +0 -0
  9. package/assets/images/emoji/smile004.png +0 -0
  10. package/assets/images/emoji/smile005.png +0 -0
  11. package/assets/images/emoji/smile006.png +0 -0
  12. package/assets/images/emoji/smile007.png +0 -0
  13. package/assets/images/emoji/smile008.png +0 -0
  14. package/assets/images/emoji/smile009.png +0 -0
  15. package/assets/images/emoji/smile010.png +0 -0
  16. package/assets/images/emoji/smile011.png +0 -0
  17. package/assets/images/emoji/smile012.png +0 -0
  18. package/assets/images/emoji/smile013.png +0 -0
  19. package/assets/images/emoji/smile014.png +0 -0
  20. package/assets/images/emoji/smile015.png +0 -0
  21. package/assets/images/emoji/smile016.png +0 -0
  22. package/assets/images/emoji/smile017.png +0 -0
  23. package/assets/images/emoji/smile018.png +0 -0
  24. package/assets/images/emoji/smile019.png +0 -0
  25. package/assets/images/emoji/smile020.png +0 -0
  26. package/assets/images/emoji/smile021.png +0 -0
  27. package/assets/images/emoji/smile022.png +0 -0
  28. package/assets/images/emoji/smile023.png +0 -0
  29. package/assets/images/emoji/smile024.png +0 -0
  30. package/assets/images/emoji/smile025.png +0 -0
  31. package/assets/images/emoji/smile026.png +0 -0
  32. package/assets/images/emoji/smile027.png +0 -0
  33. package/assets/images/emoji/smile028.png +0 -0
  34. package/assets/images/emoji/smile029.png +0 -0
  35. package/assets/images/emoji/smile030.png +0 -0
  36. package/assets/images/emoji/smile031.png +0 -0
  37. package/assets/images/emoji/smile032.png +0 -0
  38. package/assets/images/emoji/smile033.png +0 -0
  39. package/assets/images/emoji/smile034.png +0 -0
  40. package/assets/images/emoji/smile035.png +0 -0
  41. package/assets/images/emoji/smile036.png +0 -0
  42. package/assets/images/emoji/smile037.png +0 -0
  43. package/assets/images/emoji/smile038.png +0 -0
  44. package/assets/images/emoji/smile039.png +0 -0
  45. package/assets/images/emoji/smile040.png +0 -0
  46. package/assets/images/emoji/smile041.png +0 -0
  47. package/assets/images/emoji/smile042.png +0 -0
  48. package/assets/images/emoji/smile043.png +0 -0
  49. package/assets/images/emoji/smile044.png +0 -0
  50. package/assets/images/emoji/smile045.png +0 -0
  51. package/assets/images/emoji/smile046.png +0 -0
  52. package/assets/images/emoji/smile047.png +0 -0
  53. package/assets/images/emoji/smile048.png +0 -0
  54. package/assets/images/emoji/smile049.png +0 -0
  55. package/assets/images/emoji/smile050.png +0 -0
  56. package/assets/images/emoji/smile051.png +0 -0
  57. package/assets/images/emoji/smile052.png +0 -0
  58. package/assets/images/icons/age1.png +0 -0
  59. package/assets/images/icons/age2.png +0 -0
  60. package/assets/images/icons/age3.png +0 -0
  61. package/assets/images/icons/attachment.png +0 -0
  62. package/assets/images/icons/clear.png +0 -0
  63. package/assets/images/icons/edit_input.png +0 -0
  64. package/assets/images/icons/header_placeholder.png +0 -0
  65. package/assets/images/icons/home_collect.png +0 -0
  66. package/assets/images/icons/home_collected.png +0 -0
  67. package/assets/images/icons/home_comment.png +0 -0
  68. package/assets/images/icons/home_like.png +0 -0
  69. package/assets/images/icons/home_liked.png +0 -0
  70. package/assets/images/icons/home_message.png +0 -0
  71. package/assets/images/icons/home_share.png +0 -0
  72. package/assets/images/icons/icon_more.png +0 -0
  73. package/assets/images/icons/input_game.png +0 -0
  74. package/assets/images/icons/logo.png +0 -0
  75. package/assets/images/icons/lv1.png +0 -0
  76. package/assets/images/icons/lv2.png +0 -0
  77. package/assets/images/icons/lv3.png +0 -0
  78. package/assets/images/icons/lv4.png +0 -0
  79. package/assets/images/icons/search.png +0 -0
  80. package/assets/images/icons/sex1.png +0 -0
  81. package/assets/images/icons/sex2.png +0 -0
  82. package/assets/images/icons/sign_empty.png +0 -0
  83. package/assets/images/icons/sign_login.png +0 -0
  84. package/assets/wheel/wheel_bg.png +0 -0
  85. package/assets/wheel/wheel_bg2.png +0 -0
  86. package/assets/wheel/wheel_fore.png +0 -0
  87. package/assets/wheel/wheel_to.png +0 -0
  88. package/components/bottomSheet/bottomSheet.js +473 -0
  89. package/components/bottomSheet/bottomSheet.json +3 -0
  90. package/components/bottomSheet/bottomSheet.wxml +73 -0
  91. package/components/bottomSheet/bottomSheet.wxss +238 -0
  92. package/components/experience-item/experience-item.js +105 -0
  93. package/components/experience-item/experience-item.json +4 -0
  94. package/components/experience-item/experience-item.wxml +39 -0
  95. package/components/experience-item/experience-item.wxss +110 -0
  96. package/components/grid-item/grid-item.js +8 -0
  97. package/components/grid-item/grid-item.json +4 -0
  98. package/components/grid-item/grid-item.wxml +62 -0
  99. package/components/grid-item/grid-item.wxss +191 -0
  100. package/components/post-item/post-item.js +1085 -0
  101. package/components/post-item/post-item.json +4 -0
  102. package/components/post-item/post-item.wxml +427 -0
  103. package/components/post-item/post-item.wxss +525 -0
  104. package/components/wiki-renderer/wiki-renderer.js +636 -0
  105. package/components/wiki-renderer/wiki-renderer.json +12 -0
  106. package/components/wiki-renderer/wiki-renderer.wxml +150 -0
  107. package/components/wiki-renderer/wiki-renderer.wxss +412 -0
  108. package/components/wiki-tabs/wiki-tabs.js +52 -0
  109. package/components/wiki-tabs/wiki-tabs.json +3 -0
  110. package/components/wiki-tabs/wiki-tabs.wxml +28 -0
  111. package/components/wiki-tabs/wiki-tabs.wxss +43 -0
  112. package/index.js +49 -0
  113. package/package.json +35 -0
  114. package/pages/addGame/addGame.js +454 -0
  115. package/pages/addGame/addGame.json +3 -0
  116. package/pages/addGame/addGame.wxml +71 -0
  117. package/pages/addGame/addGame.wxss +110 -0
  118. package/pages/addSubject/addSubject.js +199 -0
  119. package/pages/addSubject/addSubject.json +4 -0
  120. package/pages/addSubject/addSubject.wxml +78 -0
  121. package/pages/addSubject/addSubject.wxss +85 -0
  122. package/pages/commonLogin/commonLogin.js +269 -0
  123. package/pages/commonLogin/commonLogin.json +4 -0
  124. package/pages/commonLogin/commonLogin.wxml +57 -0
  125. package/pages/commonLogin/commonLogin.wxss +177 -0
  126. package/pages/copyOfficial/copyOfficial.js +25 -0
  127. package/pages/copyOfficial/copyOfficial.json +3 -0
  128. package/pages/copyOfficial/copyOfficial.wxml +22 -0
  129. package/pages/copyOfficial/copyOfficial.wxss +49 -0
  130. package/pages/demo/demo.js +23 -0
  131. package/pages/demo/demo.json +3 -0
  132. package/pages/demo/demo.wxml +8 -0
  133. package/pages/demo/demo.wxss +24 -0
  134. package/pages/game/game.js +1254 -0
  135. package/pages/game/game.json +8 -0
  136. package/pages/game/game.wxml +371 -0
  137. package/pages/game/game.wxss +672 -0
  138. package/pages/home/home.js +665 -0
  139. package/pages/home/home.json +10 -0
  140. package/pages/home/home.wxml +115 -0
  141. package/pages/home/home.wxss +231 -0
  142. package/pages/lottery-winners/lottery-winners.js +60 -0
  143. package/pages/lottery-winners/lottery-winners.json +4 -0
  144. package/pages/lottery-winners/lottery-winners.wxml +53 -0
  145. package/pages/lottery-winners/lottery-winners.wxss +127 -0
  146. package/pages/message/messageCommentsAndAt/messageCommentsAndAt.js +178 -0
  147. package/pages/message/messageCommentsAndAt/messageCommentsAndAt.json +5 -0
  148. package/pages/message/messageCommentsAndAt/messageCommentsAndAt.wxml +93 -0
  149. package/pages/message/messageCommentsAndAt/messageCommentsAndAt.wxss +177 -0
  150. package/pages/message/messageEntire/messageEntire.js +112 -0
  151. package/pages/message/messageEntire/messageEntire.json +4 -0
  152. package/pages/message/messageEntire/messageEntire.wxml +44 -0
  153. package/pages/message/messageEntire/messageEntire.wxss +88 -0
  154. package/pages/message/messageLikeAndCollect/messageLikeAndCollect.js +147 -0
  155. package/pages/message/messageLikeAndCollect/messageLikeAndCollect.json +5 -0
  156. package/pages/message/messageLikeAndCollect/messageLikeAndCollect.wxml +84 -0
  157. package/pages/message/messageLikeAndCollect/messageLikeAndCollect.wxss +166 -0
  158. package/pages/message/messageNewFans/messageNewFans.js +139 -0
  159. package/pages/message/messageNewFans/messageNewFans.json +5 -0
  160. package/pages/message/messageNewFans/messageNewFans.wxml +35 -0
  161. package/pages/message/messageNewFans/messageNewFans.wxss +85 -0
  162. package/pages/officialWebview/officialWebview.js +13 -0
  163. package/pages/officialWebview/officialWebview.json +3 -0
  164. package/pages/officialWebview/officialWebview.wxml +2 -0
  165. package/pages/officialWebview/officialWebview.wxss +1 -0
  166. package/pages/post/post.js +1856 -0
  167. package/pages/post/post.json +6 -0
  168. package/pages/post/post.wxml +694 -0
  169. package/pages/post/post.wxss +1003 -0
  170. package/pages/post-editor/post-editor.js +465 -0
  171. package/pages/post-editor/post-editor.json +4 -0
  172. package/pages/post-editor/post-editor.wxml +63 -0
  173. package/pages/post-editor/post-editor.wxss +195 -0
  174. package/pages/postDialog/postDialog.js +560 -0
  175. package/pages/postDialog/postDialog.json +6 -0
  176. package/pages/postDialog/postDialog.wxml +377 -0
  177. package/pages/postDialog/postDialog.wxss +979 -0
  178. package/pages/report-category/report-category.js +29 -0
  179. package/pages/report-category/report-category.json +4 -0
  180. package/pages/report-category/report-category.wxml +14 -0
  181. package/pages/report-category/report-category.wxss +43 -0
  182. package/pages/report-form/report-form.js +65 -0
  183. package/pages/report-form/report-form.json +3 -0
  184. package/pages/report-form/report-form.wxml +11 -0
  185. package/pages/report-form/report-form.wxss +44 -0
  186. package/pages/sevenDaySignDetail/sevenDaySignDetail.js +273 -0
  187. package/pages/sevenDaySignDetail/sevenDaySignDetail.json +3 -0
  188. package/pages/sevenDaySignDetail/sevenDaySignDetail.wxml +82 -0
  189. package/pages/sevenDaySignDetail/sevenDaySignDetail.wxss +173 -0
  190. package/pages/topic/topic.js +266 -0
  191. package/pages/topic/topic.json +6 -0
  192. package/pages/topic/topic.wxml +77 -0
  193. package/pages/topic/topic.wxss +162 -0
  194. package/pages/user/user.js +939 -0
  195. package/pages/user/user.json +5 -0
  196. package/pages/user/user.wxml +179 -0
  197. package/pages/user/user.wxss +340 -0
  198. package/pages/userDatum/userDatum.js +24 -0
  199. package/pages/userDatum/userDatum.json +4 -0
  200. package/pages/userDatum/userDatum.wxml +36 -0
  201. package/pages/userDatum/userDatum.wxss +41 -0
  202. package/pages/userGameLib/userGameLib.js +105 -0
  203. package/pages/userGameLib/userGameLib.json +4 -0
  204. package/pages/userGameLib/userGameLib.wxml +42 -0
  205. package/pages/userGameLib/userGameLib.wxss +119 -0
  206. package/pages/webview/webview.js +25 -0
  207. package/pages/webview/webview.json +3 -0
  208. package/pages/webview/webview.wxml +22 -0
  209. package/pages/webview/webview.wxss +50 -0
  210. package/pages/wheelActivivty/wheelActivivty.js +492 -0
  211. package/pages/wheelActivivty/wheelActivivty.json +8 -0
  212. package/pages/wheelActivivty/wheelActivivty.wxml +131 -0
  213. package/pages/wheelActivivty/wheelActivivty.wxss +459 -0
  214. package/pages/wiki/wiki.js +138 -0
  215. package/pages/wiki/wiki.json +6 -0
  216. package/pages/wiki/wiki.wxml +20 -0
  217. package/pages/wiki/wiki.wxss +44 -0
  218. package/request/JKRequest.js +177 -0
  219. package/services/home.js +603 -0
  220. package/towxml/config.js +291 -0
  221. package/towxml/decode.js +35 -0
  222. package/towxml/decode.json +11 -0
  223. package/towxml/decode.wxml +137 -0
  224. package/towxml/decode.wxss +0 -0
  225. package/towxml/img/img.js +98 -0
  226. package/towxml/img/img.json +3 -0
  227. package/towxml/img/img.wxml +1 -0
  228. package/towxml/img/img.wxss +0 -0
  229. package/towxml/index.js +19 -0
  230. package/towxml/latex/latex.js +53 -0
  231. package/towxml/latex/latex.json +5 -0
  232. package/towxml/latex/latex.wxml +1 -0
  233. package/towxml/latex/latex.wxss +0 -0
  234. package/towxml/parse/highlight/highlight.js +1 -0
  235. package/towxml/parse/highlight/index.js +8 -0
  236. package/towxml/parse/highlight/languages/bash.js +111 -0
  237. package/towxml/parse/highlight/languages/c-like.js +236 -0
  238. package/towxml/parse/highlight/languages/c.js +22 -0
  239. package/towxml/parse/highlight/languages/css.js +132 -0
  240. package/towxml/parse/highlight/languages/dart.js +134 -0
  241. package/towxml/parse/highlight/languages/go.js +63 -0
  242. package/towxml/parse/highlight/languages/htmlbars.js +80 -0
  243. package/towxml/parse/highlight/languages/java.js +125 -0
  244. package/towxml/parse/highlight/languages/javascript.js +265 -0
  245. package/towxml/parse/highlight/languages/json.js +52 -0
  246. package/towxml/parse/highlight/languages/less.js +148 -0
  247. package/towxml/parse/highlight/languages/nginx.js +101 -0
  248. package/towxml/parse/highlight/languages/php.js +161 -0
  249. package/towxml/parse/highlight/languages/python-repl.js +29 -0
  250. package/towxml/parse/highlight/languages/python.js +131 -0
  251. package/towxml/parse/highlight/languages/scss.js +122 -0
  252. package/towxml/parse/highlight/languages/shell.js +22 -0
  253. package/towxml/parse/highlight/languages/typescript.js +215 -0
  254. package/towxml/parse/highlight/languages/xml.js +139 -0
  255. package/towxml/parse/highlight/style/github.wxss +99 -0
  256. package/towxml/parse/highlight/style/monokai.wxss +70 -0
  257. package/towxml/parse/index.js +118 -0
  258. package/towxml/parse/markdown/index.js +67 -0
  259. package/towxml/parse/markdown/markdown.js +4 -0
  260. package/towxml/parse/markdown/plugins/echarts.js +11 -0
  261. package/towxml/parse/markdown/plugins/emoji.js +2 -0
  262. package/towxml/parse/markdown/plugins/ins.js +1 -0
  263. package/towxml/parse/markdown/plugins/latex.js +158 -0
  264. package/towxml/parse/markdown/plugins/mark.js +1 -0
  265. package/towxml/parse/markdown/plugins/sub.js +1 -0
  266. package/towxml/parse/markdown/plugins/sup.js +1 -0
  267. package/towxml/parse/markdown/plugins/todo.js +147 -0
  268. package/towxml/parse/markdown/plugins/yuml.js +20 -0
  269. package/towxml/parse/parse2/Parser.js +492 -0
  270. package/towxml/parse/parse2/Tokenizer.js +903 -0
  271. package/towxml/parse/parse2/domelementtype/index.js +55 -0
  272. package/towxml/parse/parse2/domhandler/index.js +145 -0
  273. package/towxml/parse/parse2/domhandler/node.js +474 -0
  274. package/towxml/parse/parse2/entities/decode.js +179 -0
  275. package/towxml/parse/parse2/entities/decode_codepoint.js +60 -0
  276. package/towxml/parse/parse2/entities/encode.js +77 -0
  277. package/towxml/parse/parse2/entities/escape.js +112 -0
  278. package/towxml/parse/parse2/entities/generated/decode-data-html.js +9 -0
  279. package/towxml/parse/parse2/entities/generated/decode-data-xml.js +9 -0
  280. package/towxml/parse/parse2/entities/generated/encode-html.js +12 -0
  281. package/towxml/parse/parse2/entities/index.js +137 -0
  282. package/towxml/parse/parse2/index.js +8 -0
  283. package/towxml/style/main.wxss +419 -0
  284. package/towxml/style/theme/dark.wxss +73 -0
  285. package/towxml/style/theme/light.wxss +63 -0
  286. package/towxml/table/table.js +11 -0
  287. package/towxml/table/table.json +6 -0
  288. package/towxml/table/table.wxml +24 -0
  289. package/towxml/table/table.wxss +0 -0
  290. package/towxml/todogroup/todogroup.js +20 -0
  291. package/towxml/todogroup/todogroup.json +6 -0
  292. package/towxml/todogroup/todogroup.wxml +12 -0
  293. package/towxml/todogroup/todogroup.wxss +3 -0
  294. package/towxml/towxml.js +22 -0
  295. package/towxml/towxml.json +6 -0
  296. package/towxml/towxml.wxml +5 -0
  297. package/towxml/towxml.wxss +8 -0
  298. package/towxml/yuml/yuml.js +51 -0
  299. package/towxml/yuml/yuml.json +5 -0
  300. package/towxml/yuml/yuml.wxml +5 -0
  301. package/towxml/yuml/yuml.wxss +0 -0
  302. package/utils/auth.js +17 -0
  303. package/utils/base64.js +67 -0
  304. package/utils/compressImage.js +41 -0
  305. package/utils/exp.js +49 -0
  306. package/utils/formatPost.js +18 -0
  307. package/utils/parseContent.js +191 -0
  308. package/utils/query-select.js +9 -0
  309. package/utils/sensitive.js +82 -0
@@ -0,0 +1,636 @@
1
+ const towxml = require('../../towxml/index') // ✅ 补上引入
2
+ import {
3
+ submitGameWikiScore
4
+ } from '../../services/home'
5
+ import {
6
+ checkLogin
7
+ } from "../../utils/auth"
8
+ Component({
9
+ options: {
10
+ styleIsolation: 'apply-shared'
11
+ },
12
+
13
+ properties: {
14
+ data: {
15
+ type: Array,
16
+ value: []
17
+ },
18
+ gameId: {
19
+ type: String,
20
+ value: ''
21
+ },
22
+ wikiUsers: {
23
+ type: Array,
24
+ value: []
25
+ },
26
+ images: {
27
+ type: Array,
28
+ value: []
29
+ },
30
+ name: {
31
+ type: String,
32
+ value: ''
33
+ }
34
+ },
35
+
36
+ data: {
37
+ parsedBlocks: [],
38
+ tabActiveMap: {},
39
+ filterMap: {},
40
+ collapseActive: {},
41
+ scoreModal: {
42
+ visible: false,
43
+ title: '',
44
+ blockIndex: -1,
45
+ selected: 0,
46
+
47
+ }
48
+ },
49
+
50
+ observers: {
51
+ 'data, images': function (data, images) {
52
+ if (!data || !data.length) return
53
+ const parsed = this._parseBlocks(data)
54
+ const imageIdSet = new Set((images || []).map(img => img.id))
55
+
56
+ const tabActiveMap = {
57
+ ...this.data.tabActiveMap
58
+ }
59
+ const collapseActive = {
60
+ ...this.data.collapseActive
61
+ }
62
+
63
+ parsed.forEach((block, index) => {
64
+ if ((block.type === 'tabs' || block.type === 'content-tabs') && block.tabs?.length) {
65
+ if (!tabActiveMap[index]) {
66
+ tabActiveMap[index] = block.tabs[0].name
67
+ }
68
+ }
69
+ if (block.type === 'container' && block.key === 'collapse') {
70
+ if (collapseActive[index] === undefined) {
71
+ collapseActive[index] = false
72
+ }
73
+ }
74
+ if (block.type === 'filter-tabs') {
75
+ block.classes = (block.classes || []).map(cls => ({
76
+ ...cls,
77
+ allKeys: ['不限', ...cls.keys]
78
+ }))
79
+ block.filteredChildren = block.children
80
+ }
81
+ })
82
+
83
+ // 递归注入 visible
84
+ const injectVisible = (blocks) => {
85
+ return blocks.map(block => {
86
+ if (block.type === 'image') {
87
+ return {
88
+ ...block,
89
+ visible: !block.id || imageIdSet.has(block.id)
90
+ }
91
+ }
92
+ // lr 块:递归处理 left / right
93
+ if (block.type === 'lr') {
94
+ return {
95
+ ...block,
96
+ left: block.left ? injectVisible([block.left])[0] : null,
97
+ right: block.right ? injectVisible([block.right])[0] : null,
98
+ }
99
+ }
100
+ // container / content-tabs 等有 children 的块
101
+ if (block.children?.length) {
102
+ return {
103
+ ...block,
104
+ children: injectVisible(block.children)
105
+ }
106
+ }
107
+ // tabs / content-tabs 有 tabs[].children
108
+ if (block.tabs?.length) {
109
+ return {
110
+ ...block,
111
+ tabs: block.tabs.map(tab => ({
112
+ ...tab,
113
+ children: injectVisible(tab.children || [])
114
+ }))
115
+ }
116
+ }
117
+ return block
118
+ })
119
+ }
120
+
121
+ this.setData({
122
+ parsedBlocks: injectVisible(parsed),
123
+ tabActiveMap,
124
+ collapseActive
125
+ })
126
+ }
127
+ },
128
+
129
+ methods: {
130
+ _isDarkColor(argb) {
131
+ if (!argb) return false
132
+ let hex = argb.replace('#', '').toLowerCase()
133
+ if (hex.length === 6) hex = 'ff' + hex
134
+ if (hex.length !== 8) return false
135
+ const r = parseInt(hex.slice(2, 4), 16) / 255
136
+ const g = parseInt(hex.slice(4, 6), 16) / 255
137
+ const b = parseInt(hex.slice(6, 8), 16) / 255
138
+ const a = parseInt(hex.slice(0, 2), 16) / 255
139
+ return (r + g + b) * a / 3 < 0.7
140
+ },
141
+ _colorInfo(argb) {
142
+ const color = this._argbToCssHex(argb)
143
+ const titleTextColor = color ? (this._isDarkColor(argb) ? '#ffffff' : '#000000') : ''
144
+ return {
145
+ color,
146
+ titleTextColor
147
+ }
148
+ },
149
+ _argbToCssHex(argb) {
150
+ if (!argb) return ''
151
+ argb = argb.replace('#', '').toLowerCase()
152
+ if (argb.length !== 8) return `#${argb}`
153
+ const r = argb.slice(2, 4),
154
+ g = argb.slice(4, 6),
155
+ b = argb.slice(6, 8),
156
+ a = argb.slice(0, 2)
157
+ return `#${r}${g}${b}${a}`
158
+ },
159
+
160
+ _parseBlocks(data) {
161
+ return data.map(block => {
162
+ switch (block?.type) {
163
+ case 0:
164
+ return {
165
+ type: 'empty'
166
+ }
167
+ case 1:
168
+ return {
169
+ type: 'text', desc: block.data.desc
170
+ }
171
+ case 'text':
172
+ return {
173
+ type: 'text', desc: block.desc
174
+ }
175
+ case 2:
176
+ return {
177
+ type: 'richText', desc: block.data.desc, towxmlNodes: this._toTowxml(block.data.desc)
178
+ }
179
+ case 'richText':
180
+ return {
181
+ type: 'richText', desc: block.desc, towxmlNodes: this._toTowxml(block.desc)
182
+ }
183
+ case 3:
184
+ return {
185
+ type: 'table', desc: block.data.desc, towxmlNodes: this._toTowxml(block.data.desc)
186
+ }
187
+ case 'table':
188
+ return {
189
+ type: 'table', desc: block.desc, towxmlNodes: this._toTowxml(block.desc)
190
+ }
191
+ case 4:
192
+ return {
193
+ type: 'image',
194
+ id: block.data.image_jump.image.id,
195
+ url: block.data.image_jump.image.url,
196
+ jump: block.data.image_jump.jump,
197
+ ratio: block.data.percent / 100
198
+ }
199
+ case 'image':
200
+ return {
201
+ type: 'image', url: block.url, jump: block.jump, ratio: block.ratio, id: block.id
202
+ }
203
+ case 5:
204
+ return {
205
+ type: 'banner', ratio: block.data.percent / 100, children: block.data.children
206
+ }
207
+ case 'banner':
208
+ return {
209
+ type: 'banner', ratio: block.ratio, children: block.children
210
+ }
211
+ case 6:
212
+ return {
213
+ type: 'score',
214
+ title: block.data.title,
215
+ score: block.stats?.score ?? 0,
216
+ voteCount: block.stats?.stats?.vote_count ?? 0,
217
+ averageScore: (block.stats?.stats?.average_score ?? 0).toFixed(1),
218
+ }
219
+ case 'score':
220
+ return {
221
+ type: 'score',
222
+ title: block.title,
223
+ score: block.score ?? 0,
224
+ voteCount: block.voteCount ?? 0,
225
+ averageScore: block.averageScore ?? '0.0',
226
+ }
227
+ case 100:
228
+ return {
229
+ type: 'grid', title: block.data.title, count: block.data.count,
230
+ ...this._colorInfo(block.data.color),
231
+ children: block.data.children.map(c => ({
232
+ type: block.data.child_type, // ✅ 补上
233
+ name: c.name,
234
+ desc: c.desc,
235
+ jump: c.jump,
236
+ image: c.image?.url || c.image
237
+ }))
238
+ }
239
+ case 'grid':
240
+ return {
241
+ type: 'grid', count: block.count, color: block.color,
242
+ children: block.children.map(c => ({
243
+ type: c.type, // ✅ 保留原有 type
244
+ name: c.name,
245
+ desc: c.desc,
246
+ jump: c.jump,
247
+ image: c.image?.url || c.image
248
+ }))
249
+ }
250
+
251
+ case 101:
252
+ return {
253
+ type: 'tabs', title: block.data.title, count: block.data.count,
254
+ ...this._colorInfo(block.data.color),
255
+ tabs: block.data.tabs.map(t => ({
256
+ name: t.tab,
257
+ children: t.children.map(c => ({
258
+ type: block.data.child_type, // ✅ 补上
259
+ name: c.name,
260
+ desc: c.desc,
261
+ jump: c.jump,
262
+ image: c.image?.url || ''
263
+ }))
264
+ }))
265
+ }
266
+ case 'tabs':
267
+ return {
268
+ type: 'tabs', title: block.title, count: block.count, color: block.color,
269
+ titleTextColor: block.titleTextColor || (block.color ? (this._isDarkColor(block.color) ? '#ffffff' : '#000000') : ''),
270
+
271
+ tabs: block.tabs.map(t => ({
272
+ name: t.name,
273
+ children: t.children
274
+ }))
275
+ }
276
+
277
+ case 102:
278
+ return {
279
+ type: 'filter-tabs', title: block.data.title, count: block.data.count,
280
+ ...this._colorInfo(block.data.color),
281
+ classes: block.data.classes || [],
282
+ children: block.data.children.map(c => ({
283
+ ...c,
284
+ type: block.data.child_type, // ✅ 补上
285
+ keys: c.keys || []
286
+ }))
287
+ }
288
+
289
+ case 2000:
290
+ return {
291
+ type: 'container', title: block.data.title,
292
+ hasDivider: true,
293
+ ...this._colorInfo(block.data.color),
294
+ children: this._parseBlocks(block.data.children || [])
295
+ }
296
+ case 1000:
297
+ return {
298
+ type: 'container', title: block.data.title,
299
+ ...this._colorInfo(block.data.color),
300
+ children: this._parseBlocks(block.data.children || [])
301
+ }
302
+ case 1001:
303
+ return {
304
+ type: 'info', title: '攻略组成员', ...this._colorInfo(block.data.color), info: block.data.info
305
+ }
306
+ case 'info':
307
+ return {
308
+ type: 'info', title: '攻略组成员', color: block.color, info: block.info
309
+ }
310
+
311
+ case 1002:
312
+ return {
313
+ type: 'container', key: 'collapse', title: block.data.title,
314
+ ...this._colorInfo(block.data.color),
315
+ children: this._parseBlocks(block.data.children || [])
316
+ }
317
+ case 1003:
318
+ return {
319
+ type: 'content-tabs', title: block.data.title,
320
+ ...this._colorInfo(block.data.color),
321
+ tabs: block.data.tabs.map(tab => ({
322
+ name: tab.tab,
323
+ children: this._parseBlocks(tab.children || [])
324
+ }))
325
+ }
326
+ case 'content-tabs':
327
+ return {
328
+ titleTextColor: block.titleTextColor || (block.color ? (this._isDarkColor(block.color) ? '#ffffff' : '#000000') : ''),
329
+
330
+ type: 'content-tabs', title: block.title, color: block.color, tabs: block.tabs
331
+ }
332
+
333
+ case 1004: {
334
+ const left = block.data.left ? this._parseBlocks([block.data.left])[0] : null
335
+ const right = block.data.right ? this._parseBlocks([block.data.right])[0] : null
336
+ return {
337
+ type: 'lr',
338
+ title: block.data.title,
339
+ ...this._colorInfo(block.data.color),
340
+ percent: block.data.percent,
341
+ left,
342
+ right,
343
+ children: [left, right].filter(Boolean) // ✅ 补上
344
+ }
345
+ }
346
+ case 'lr':
347
+ return {
348
+ type: 'lr', title: block.title, color: block.color,
349
+ percent: block.percent, left: block.left, right: block.right,
350
+ children: block.children
351
+ }
352
+
353
+ case 1005:
354
+ return {
355
+ type: 'container', key: 'hasBGC', title: block.data.title,
356
+ ...this._colorInfo(block.data.color),
357
+ children: this._parseBlocks(block.data.children || [])
358
+ }
359
+ case 'container':
360
+ return {
361
+ type: 'container', key: block.key, title: block.title, color: block.color,
362
+ titleTextColor: block.titleTextColor || (block.color ? (this._isDarkColor(block.color) ? '#ffffff' : '#000000') : ''),
363
+
364
+ children: this._parseBlocks(block.children || [])
365
+ }
366
+ default:
367
+ return null
368
+ }
369
+ }).filter(Boolean)
370
+ },
371
+
372
+
373
+ _toTowxml(md) {
374
+ if (!md) return {}
375
+ try {
376
+ // ✅ 去掉表头里的权重标记,如 |名称:0| → |名称|
377
+ md = md.replace(/\|([^|]*?):\d+/g, '|$1')
378
+
379
+ // 把 #[文字](颜色) 转成 <span style="color:xxx">文字</span>
380
+ md = md.replace(/#\[([^\]]+)\]\(([^\)]+)\)/g, (match, text, color) => {
381
+ let cssColor = color
382
+ if (/^[0-9a-fA-F]{8}$/.test(color)) {
383
+ const r = color.slice(2, 4)
384
+ const g = color.slice(4, 6)
385
+ const b = color.slice(6, 8)
386
+ cssColor = `#${r}${g}${b}`
387
+ } else if (/^[0-9a-fA-F]{6}$/.test(color)) {
388
+ cssColor = `#${color}`
389
+ }
390
+ return `<span style="color:${cssColor}">${text}</span>`
391
+ })
392
+
393
+ return towxml(md, 'markdown', {
394
+ theme: 'light',
395
+ events: {
396
+ tap: (e) => {
397
+ const dataset = e.currentTarget?.dataset || e.target?.dataset || {}
398
+ const href = dataset.src || dataset.href || dataset.url || ''
399
+ if (!href) return
400
+ const decoded = decodeURIComponent(href)
401
+ if (!decoded.startsWith('http://') && !decoded.startsWith('https://')) {
402
+ this._jumpAction(decoded)
403
+ }
404
+ }
405
+ }
406
+ })
407
+ } catch (err) {
408
+ console.error('towxml 解析失败', err)
409
+ return {}
410
+ }
411
+ },
412
+
413
+ onTabChange(e) {
414
+ const {
415
+ blockIndex,
416
+ tabName
417
+ } = e.currentTarget.dataset
418
+ const tabActiveMap = {
419
+ ...this.data.tabActiveMap,
420
+ [blockIndex]: tabName
421
+ }
422
+ this.setData({
423
+ tabActiveMap
424
+ })
425
+ },
426
+
427
+ onFilterChange(e) {
428
+ const {
429
+ ci,
430
+ key
431
+ } = e.currentTarget.dataset
432
+ const filterMap = {
433
+ ...this.data.filterMap,
434
+ [ci]: key
435
+ }
436
+ const parsedBlocks = this.data.parsedBlocks.map(block => {
437
+ if (block.type !== 'filter-tabs') return block
438
+ const filteredChildren = block.children.filter(item =>
439
+ block.classes.every((cls, idx) => {
440
+ const selected = filterMap[idx] || '不限'
441
+ return selected === '不限' || item.keys.includes(selected)
442
+ })
443
+ )
444
+ return {
445
+ ...block,
446
+ filteredChildren
447
+ }
448
+ })
449
+ this.setData({
450
+ filterMap,
451
+ parsedBlocks
452
+ })
453
+ },
454
+
455
+ onToggleCollapse(e) {
456
+ const {
457
+ index
458
+ } = e.currentTarget.dataset
459
+ const collapseActive = {
460
+ ...this.data.collapseActive
461
+ }
462
+ collapseActive[index] = !collapseActive[index]
463
+ this.setData({
464
+ collapseActive
465
+ })
466
+ },
467
+
468
+ onVanTabChange(e) {
469
+ const {
470
+ blockIndex
471
+ } = e.currentTarget.dataset
472
+ const tabName = e.detail.name // van-tabs 的 change 事件里 name 在 detail 里
473
+ const tabActiveMap = {
474
+ ...this.data.tabActiveMap,
475
+ [blockIndex]: tabName
476
+ }
477
+ this.setData({
478
+ tabActiveMap
479
+ })
480
+ },
481
+
482
+ onJump(e) {
483
+ const jump = e.currentTarget.dataset.jump
484
+ if (jump) this._jumpAction(jump)
485
+ },
486
+
487
+ onTowxmlLinkTap(e) {
488
+ const href = e.detail.href || ''
489
+ if (!href) return
490
+ const name = decodeURIComponent(href)
491
+ console.log('wiki 跳转:', name)
492
+ this._jumpAction(name)
493
+ },
494
+
495
+ onRichTextTap(e) {
496
+ debugger
497
+ // towxml 点击事件,dataset 挂在被点击的节点上
498
+ const dataset = e.target.dataset || e.currentTarget.dataset
499
+
500
+ // 1️⃣ 拦截 wiki-link:[文字](武学:xxx)
501
+ // towxml 渲染后 data-wiki 挂在节点的 dataset 上
502
+ if (dataset.wiki) {
503
+ this._jumpAction(dataset.wiki)
504
+ return
505
+ }
506
+
507
+ // 2️⃣ 拦截普通链接:towxml 的 a 标签点击
508
+ // towxml 把 href 挂在 data-src 或 data-href 上
509
+ const href = dataset.src || dataset.href
510
+ if (href) {
511
+ const link = decodeURIComponent(href)
512
+ this._jumpAction(link)
513
+ return
514
+ }
515
+
516
+ // 3️⃣ 拦截 towxml 内部 tap 事件冒泡上来的节点
517
+ // 有时候点击的是子节点,需要向上找父节点的 dataset
518
+ // 通过 index 找到对应的 block,再判断内容
519
+ const index = e.currentTarget.dataset.index
520
+ console.log('richText tap, block index:', index)
521
+ },
522
+ onImageTap(e) {
523
+ const jump = e.currentTarget.dataset.jump
524
+ if (jump) this._jumpAction(jump)
525
+ },
526
+
527
+ _jumpAction(name) {
528
+ if (!name) return
529
+ wx.navigateTo({
530
+ url: `/pages/wiki/wiki?game_id=${this.properties.gameId}&name=${encodeURIComponent(name)}`
531
+ })
532
+ },
533
+
534
+ gotoUserCenter(e) {
535
+ const id = e.currentTarget.dataset.id
536
+ wx.navigateTo({
537
+ url: `/pages/user/user?id=${id}`
538
+ })
539
+ },
540
+ // 评分
541
+ onOpenScoreModal(e) {
542
+ if (!checkLogin()) return;
543
+
544
+ const {
545
+ index
546
+ } = e.currentTarget.dataset
547
+ const block = this.data.parsedBlocks[index]
548
+ this.setData({
549
+ scoreModal: {
550
+ visible: true,
551
+ title: block.title,
552
+ blockIndex: index,
553
+ selected: block.score || 0,
554
+ }
555
+ })
556
+ },
557
+
558
+ onSelectStar(e) {
559
+ this.setData({
560
+ 'scoreModal.selected': e.detail,
561
+ })
562
+ },
563
+
564
+ onCloseScoreModal() {
565
+ this.setData({
566
+ 'scoreModal.visible': false
567
+ })
568
+ },
569
+
570
+
571
+
572
+ stopPropagation() {
573
+ // 阻止弹窗内点击冒泡到蒙层
574
+ },
575
+
576
+ async onSubmitScore() {
577
+ console.log('submit', this.data.scoreModal)
578
+ const {
579
+ selected,
580
+ blockIndex
581
+ } = this.data.scoreModal
582
+ if (!selected || selected <= 0) return
583
+
584
+ try {
585
+ wx.showLoading({
586
+ title: '提交中...'
587
+ })
588
+
589
+ const wiki_name = this.data.name ?? ''
590
+ const res = await submitGameWikiScore(this.properties.gameId, wiki_name, selected)
591
+ wx.hideLoading()
592
+ wx.showToast({
593
+ title: '评分成功',
594
+ icon: 'success'
595
+ })
596
+
597
+ // 用接口返回的真实数据更新
598
+ const parsedBlocks = this.data.parsedBlocks.map((b, i) => {
599
+ if (i !== blockIndex) return b
600
+ return {
601
+ ...b,
602
+ score: res.data.score,
603
+ voteCount: res.data.stats.vote_count,
604
+ averageScore: res.data.stats.average_score.toFixed(1),
605
+ starFillMap: this._getStarFillMap(res.data.stats.average_score),
606
+ }
607
+ })
608
+ this.setData({
609
+ parsedBlocks,
610
+ 'scoreModal.visible': false,
611
+ })
612
+ } catch (err) {
613
+ wx.hideLoading()
614
+ wx.showToast({
615
+ title: '提交失败',
616
+ icon: 'none'
617
+ })
618
+ }
619
+ },
620
+
621
+ // 根据 averageScore (如 3.5) 生成每颗星的填充百分比
622
+ _getStarFillMap(score) {
623
+ const fills = {}
624
+ for (let i = 1; i <= 5; i++) {
625
+ if (score >= i) {
626
+ fills[i] = 100 // 整颗星
627
+ } else if (score >= i - 0.5) {
628
+ fills[i] = 50 // 半颗星
629
+ } else {
630
+ fills[i] = 0 // 空星
631
+ }
632
+ }
633
+ return fills
634
+ }
635
+ }
636
+ })
@@ -0,0 +1,12 @@
1
+ {
2
+ "component": true,
3
+ "usingComponents": {
4
+ "towxml": "/towxml/towxml",
5
+ "wiki-renderer": "/components/wiki-renderer/wiki-renderer",
6
+ "grid-item": "/components/grid-item/grid-item",
7
+ "van-tabs": "@vant/weapp/tabs/index",
8
+ "van-tab": "@vant/weapp/tab/index",
9
+ "wiki-tabs": "/components/wiki-tabs/wiki-tabs",
10
+ "van-rate": "@vant/weapp/rate/index"
11
+ }
12
+ }