cx-chat 0.0.1

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 (404) hide show
  1. package/.cursor/rules/i18n-cn-gloss-comments.mdc +31 -0
  2. package/.cursor/rules/list-page-view-pageconfig.mdc +32 -0
  3. package/.cursor/rules/no-over-defensive-programming.mdc +90 -0
  4. package/.cursor/rules/requirement-description-for-agent.mdc +33 -0
  5. package/.cursor/rules/use-showToast-not-antd-message.mdc +28 -0
  6. package/.docker/Dockerfile +7 -0
  7. package/.env +9 -0
  8. package/.env.development +7 -0
  9. package/.env.production +7 -0
  10. package/.gitlab-ci/docker-build.yaml +28 -0
  11. package/.gitlab-ci/k8s-deploy-dev-master.yaml +42 -0
  12. package/.gitlab-ci/npm-build.yaml +17 -0
  13. package/.gitlab-ci.yml +8 -0
  14. package/.k8s/0-namespace.yaml +6 -0
  15. package/.k8s/1-configmap-web.yaml +7 -0
  16. package/.k8s/1-nginx-conf-dev.yaml +110 -0
  17. package/.k8s/2-deployment.yaml +27 -0
  18. package/.k8s/3-service.yaml +16 -0
  19. package/.k8s/4-ingress-dev.yaml +30 -0
  20. package/.lingma/rules/use-showToast-not-antd-message.md +34 -0
  21. package/.nginx/nginx.conf +52 -0
  22. package/.prettierrc +9 -0
  23. package/README.md +1 -0
  24. package/eslint.config.js +32 -0
  25. package/index.html +13 -0
  26. package/package.json +67 -0
  27. package/postcss.config.js +6 -0
  28. package/public/favicon.ico +0 -0
  29. package/public/vite.svg +1 -0
  30. package/src/App.tsx +96 -0
  31. package/src/_doc/0.docs-overview.md +28 -0
  32. package/src/_doc/cx-ui/0.docs-overview.md +30 -0
  33. package/src/_doc/cx-ui/comp.1.cx-ui-overview.md +82 -0
  34. package/src/_doc/cx-ui/comp.2.cx-modal.md +82 -0
  35. package/src/_doc/cx-ui/comp.3.cx-button.md +89 -0
  36. package/src/_doc/cx-ui/comp.4.cx-form.md +72 -0
  37. package/src/_doc/cx-ui/comp.5.cx-fields.md +76 -0
  38. package/src/_doc/cx-ui/comp.6.cx-tag.md +57 -0
  39. package/src/_doc/cx-ui/comp.7.cx-empty-state.md +29 -0
  40. package/src/_doc/meta/0.docs-overview.md +24 -0
  41. package/src/_doc/meta/comp.1.enum-runtime.md +33 -0
  42. package/src/_doc/meta/comp.2.dict-runtime.md +39 -0
  43. package/src/_doc/router/0.docs-overview.md +14 -0
  44. package/src/_doc/router/guide.1.menu-component-config.md +181 -0
  45. package/src/_doc/router/guide.2.router-auto-registration.md +114 -0
  46. package/src/_doc/table-view/0.docs-overview.md +30 -0
  47. package/src/_doc/table-view/comp.1.table-view.md +542 -0
  48. package/src/_doc/table-view/props.1.create-table-view-config.md +193 -0
  49. package/src/_doc/table-view/props.2.table-view-search-fields.md +106 -0
  50. package/src/api/_mock/README.md +340 -0
  51. package/src/api/_mock/api.ts +1642 -0
  52. package/src/api/_mock/bundle-shim.ts +16 -0
  53. package/src/api/_mock/handler-shim.ts +6 -0
  54. package/src/api/_mock/handler.ts +458 -0
  55. package/src/api/_mock/index.ts +711 -0
  56. package/src/api/_mock/interceptor.ts +15 -0
  57. package/src/api/_mock/mod.ts +12 -0
  58. package/src/api/_mock/utils.ts +65 -0
  59. package/src/api/base/memory.js +24 -0
  60. package/src/api/chat.js +210 -0
  61. package/src/api/common/auth.js +70 -0
  62. package/src/api/menus/business-rules.js +76 -0
  63. package/src/api/menus/feedback.js +102 -0
  64. package/src/api/menus/knowledge.js +159 -0
  65. package/src/api/menus/model-metadata/manage.js +70 -0
  66. package/src/api/menus/model-metadata/role.js +50 -0
  67. package/src/api/menus/model-metadata/training-detail-mock-data.js +569 -0
  68. package/src/api/menus/model-metadata/training.js +28 -0
  69. package/src/api/menus/skill.js +40 -0
  70. package/src/api/system/agent-config.js +16 -0
  71. package/src/api/system/department.js +94 -0
  72. package/src/api/system/dict.js +86 -0
  73. package/src/api/system/menu.js +37 -0
  74. package/src/api/system/permission.js +26 -0
  75. package/src/api/system/role.js +34 -0
  76. package/src/api/system/sys-config.js +16 -0
  77. package/src/api/system/sys-log.js +17 -0
  78. package/src/api/system/user.js +75 -0
  79. package/src/api/upload.js +39 -0
  80. package/src/assets/react.svg +1 -0
  81. package/src/components/auth/current-user-avatar.tsx +77 -0
  82. package/src/components/common/code-view.tsx +149 -0
  83. package/src/components/common/detail-link.tsx +67 -0
  84. package/src/components/common/error-boundary.tsx +98 -0
  85. package/src/components/common/language-switcher.tsx +91 -0
  86. package/src/components/common/lite-table/index.tsx +135 -0
  87. package/src/components/common/md-editor.tsx +126 -0
  88. package/src/components/common/modal/confirm-dialog.tsx +113 -0
  89. package/src/components/common/modal/dep-user-select-multi.tsx +324 -0
  90. package/src/components/common/modal/dep-user-select.tsx +249 -0
  91. package/src/components/common/modal/user-select-multi.tsx +266 -0
  92. package/src/components/common/pagination.tsx +472 -0
  93. package/src/components/common/path.tsx +175 -0
  94. package/src/components/common/system-logo-mark.tsx +48 -0
  95. package/src/components/cx-ui/button/index.less +208 -0
  96. package/src/components/cx-ui/button/index.tsx +611 -0
  97. package/src/components/cx-ui/checkbox/index.tsx +78 -0
  98. package/src/components/cx-ui/date-picker/index.less +17 -0
  99. package/src/components/cx-ui/date-picker/index.tsx +193 -0
  100. package/src/components/cx-ui/drawer/index.tsx +47 -0
  101. package/src/components/cx-ui/empty-state/index.tsx +20 -0
  102. package/src/components/cx-ui/floating-shell/CxFloatingShell.tsx +89 -0
  103. package/src/components/cx-ui/floating-shell/cx-floating-shell.less +283 -0
  104. package/src/components/cx-ui/floating-shell/has-floating-value.ts +41 -0
  105. package/src/components/cx-ui/form/CxForm.tsx +15 -0
  106. package/src/components/cx-ui/form/index.tsx +20 -0
  107. package/src/components/cx-ui/form-item/index.less +26 -0
  108. package/src/components/cx-ui/form-item/index.tsx +36 -0
  109. package/src/components/cx-ui/index.ts +70 -0
  110. package/src/components/cx-ui/input/auto-complete.tsx +134 -0
  111. package/src/components/cx-ui/input/index.tsx +259 -0
  112. package/src/components/cx-ui/input-number/index.jsx +66 -0
  113. package/src/components/cx-ui/modal/index.jsx +212 -0
  114. package/src/components/cx-ui/modal/index.less +144 -0
  115. package/src/components/cx-ui/modal/useCxModal.ts +125 -0
  116. package/src/components/cx-ui/multi-select/index.jsx +74 -0
  117. package/src/components/cx-ui/multi-select/index.less +40 -0
  118. package/src/components/cx-ui/multi-select/index2.tsx +361 -0
  119. package/src/components/cx-ui/radio/index.tsx +33 -0
  120. package/src/components/cx-ui/range-picker/index.less +65 -0
  121. package/src/components/cx-ui/range-picker/index.tsx +219 -0
  122. package/src/components/cx-ui/select/index.less +34 -0
  123. package/src/components/cx-ui/select/index.tsx +196 -0
  124. package/src/components/cx-ui/skeleton/index.tsx +12 -0
  125. package/src/components/cx-ui/steps/index.tsx +14 -0
  126. package/src/components/cx-ui/styles/_tokens.less +79 -0
  127. package/src/components/cx-ui/styles/index.less +246 -0
  128. package/src/components/cx-ui/switch/index.less +106 -0
  129. package/src/components/cx-ui/switch/index.tsx +120 -0
  130. package/src/components/cx-ui/table/index.less +160 -0
  131. package/src/components/cx-ui/table/index.tsx +152 -0
  132. package/src/components/cx-ui/tabs/index.less +15 -0
  133. package/src/components/cx-ui/tabs/index.tsx +34 -0
  134. package/src/components/cx-ui/tag/index.less +51 -0
  135. package/src/components/cx-ui/tag/index.tsx +140 -0
  136. package/src/components/cx-ui/timeline/index.tsx +14 -0
  137. package/src/components/cx-ui/tooltip/index.tsx +67 -0
  138. package/src/components/cx-ui/tree/index.tsx +193 -0
  139. package/src/components/cx-ui/tree-select/index.jsx +91 -0
  140. package/src/components/cx-ui/tree-select/index.less +27 -0
  141. package/src/components/cx-ui/upload-file/index.less +223 -0
  142. package/src/components/cx-ui/upload-file/index.tsx +640 -0
  143. package/src/components/cx-ui/upload-img/index.tsx +291 -0
  144. package/src/components/layout/components/Header.tsx +216 -0
  145. package/src/components/layout/components/Sidebar.tsx +717 -0
  146. package/src/components/layout/index.tsx +95 -0
  147. package/src/components/table-view/components/search-area.tsx +411 -0
  148. package/src/components/table-view/components/table-view-config.tsx +528 -0
  149. package/src/components/table-view/components/table-view.types.ts +478 -0
  150. package/src/components/table-view/components/tree-api-normalize.ts +38 -0
  151. package/src/components/table-view/components/tree-data-annotate.ts +31 -0
  152. package/src/components/table-view/components/tree-sidebar.tsx +74 -0
  153. package/src/components/table-view/index.tsx +61 -0
  154. package/src/components/table-view/list-page-view.tsx +1049 -0
  155. package/src/components/table-view/select-table-view.tsx +1094 -0
  156. package/src/components/table-view/styles/select-table-view.less +51 -0
  157. package/src/config/default-system-name.ts +9 -0
  158. package/src/config/system.ts +165 -0
  159. package/src/constants/countryCodes.ts +3 -0
  160. package/src/contexts/AuthContext.tsx +256 -0
  161. package/src/contexts/ChatContext.tsx +839 -0
  162. package/src/contexts/MenuContext.tsx +62 -0
  163. package/src/contexts/ToastContext.tsx +181 -0
  164. package/src/hooks/useCopyToClipboard.ts +47 -0
  165. package/src/hooks/useModalSubmit.ts +104 -0
  166. package/src/hooks/useRouter.ts +240 -0
  167. package/src/hooks/useStepForm.ts +46 -0
  168. package/src/hooks/useStickyHeader.ts +42 -0
  169. package/src/hooks/useThreadActions.ts +105 -0
  170. package/src/hooks/useUserPreferences.ts +101 -0
  171. package/src/http/axios.js +372 -0
  172. package/src/http/mock.interceptor.ts +9 -0
  173. package/src/http/obfuscationKey.ts +41 -0
  174. package/src/i18n.ts +60 -0
  175. package/src/index.js +1 -0
  176. package/src/index.less +169 -0
  177. package/src/locales/en/auth.ts +70 -0
  178. package/src/locales/en/base/memory.ts +28 -0
  179. package/src/locales/en/base/settings.ts +41 -0
  180. package/src/locales/en/chat.ts +40 -0
  181. package/src/locales/en/common.ts +173 -0
  182. package/src/locales/en/enum.ts +27 -0
  183. package/src/locales/en/menus/business-rules.ts +48 -0
  184. package/src/locales/en/menus/feedback.ts +62 -0
  185. package/src/locales/en/menus/knowledge.ts +120 -0
  186. package/src/locales/en/menus/model-metadata/index.ts +10 -0
  187. package/src/locales/en/menus/model-metadata/manage.ts +151 -0
  188. package/src/locales/en/menus/model-metadata/role.ts +48 -0
  189. package/src/locales/en/menus/model-metadata/training.ts +65 -0
  190. package/src/locales/en/menus/skill.ts +34 -0
  191. package/src/locales/en/system/agent-config.ts +34 -0
  192. package/src/locales/en/system/department.ts +68 -0
  193. package/src/locales/en/system/dict.ts +44 -0
  194. package/src/locales/en/system/menu.ts +45 -0
  195. package/src/locales/en/system/permission.ts +89 -0
  196. package/src/locales/en/system/role.ts +25 -0
  197. package/src/locales/en/system/sys-config.ts +33 -0
  198. package/src/locales/en/system/sys-log.ts +38 -0
  199. package/src/locales/en/system/user.ts +113 -0
  200. package/src/locales/en.ts +68 -0
  201. package/src/locales/zh/auth.ts +70 -0
  202. package/src/locales/zh/base/memory.ts +29 -0
  203. package/src/locales/zh/base/settings.ts +41 -0
  204. package/src/locales/zh/chat.ts +47 -0
  205. package/src/locales/zh/common.ts +178 -0
  206. package/src/locales/zh/enum.ts +28 -0
  207. package/src/locales/zh/menus/business-rules.ts +47 -0
  208. package/src/locales/zh/menus/feedback.ts +62 -0
  209. package/src/locales/zh/menus/knowledge.ts +117 -0
  210. package/src/locales/zh/menus/model-metadata/index.ts +10 -0
  211. package/src/locales/zh/menus/model-metadata/manage.ts +151 -0
  212. package/src/locales/zh/menus/model-metadata/role.ts +47 -0
  213. package/src/locales/zh/menus/model-metadata/training.ts +64 -0
  214. package/src/locales/zh/menus/skill.ts +34 -0
  215. package/src/locales/zh/system/agent-config.ts +33 -0
  216. package/src/locales/zh/system/department.ts +69 -0
  217. package/src/locales/zh/system/dict.ts +44 -0
  218. package/src/locales/zh/system/menu.ts +47 -0
  219. package/src/locales/zh/system/permission.ts +94 -0
  220. package/src/locales/zh/system/role.ts +25 -0
  221. package/src/locales/zh/system/sys-config.ts +32 -0
  222. package/src/locales/zh/system/sys-log.ts +38 -0
  223. package/src/locales/zh/system/user.ts +114 -0
  224. package/src/locales/zh.ts +67 -0
  225. package/src/main.tsx +50 -0
  226. package/src/meta/const/index.ts +40 -0
  227. package/src/meta/index-dict.ts +56 -0
  228. package/src/meta/index-enum.ts +95 -0
  229. package/src/meta/index.ts +14 -0
  230. package/src/meta/module/dict-data/runtime.ts +199 -0
  231. package/src/meta/module/dict-data/types.ts +17 -0
  232. package/src/meta/module/enum-data/runtime.ts +75 -0
  233. package/src/meta/module/enum-data/types.ts +18 -0
  234. package/src/router/index.tsx +312 -0
  235. package/src/styles/AntdThemeProvider.tsx +40 -0
  236. package/src/styles/antd-theme.ts +20 -0
  237. package/src/styles/global.less +107 -0
  238. package/src/styles/variable.less +103 -0
  239. package/src/types/feedback.ts +43 -0
  240. package/src/types/index.ts +85 -0
  241. package/src/types/menu.ts +43 -0
  242. package/src/utils/aesUtil.ts +123 -0
  243. package/src/utils/chatUtils.ts +524 -0
  244. package/src/utils/cn.ts +6 -0
  245. package/src/utils/crypto.ts +164 -0
  246. package/src/utils/date.ts +72 -0
  247. package/src/utils/file-icons.tsx +79 -0
  248. package/src/utils/index.ts +168 -0
  249. package/src/utils/markdown-math-plugins.ts +21 -0
  250. package/src/utils/menuI18n.ts +305 -0
  251. package/src/utils/menuRouteRegistry.ts +78 -0
  252. package/src/utils/permission-crud.ts +147 -0
  253. package/src/utils/routeConfig.ts +350 -0
  254. package/src/utils/storage.ts +135 -0
  255. package/src/utils/toastBridge.ts +26 -0
  256. package/src/utils/url.ts +38 -0
  257. package/src/utils/validation.ts +16 -0
  258. package/src/views/auth/auth-code/index.less +169 -0
  259. package/src/views/auth/auth-code/index.module.less +174 -0
  260. package/src/views/auth/auth-code/index.tsx +233 -0
  261. package/src/views/auth/login.tsx +498 -0
  262. package/src/views/auth/register.tsx +388 -0
  263. package/src/views/base/memory/index.tsx +136 -0
  264. package/src/views/base/memory/modal/detail-modal.tsx +89 -0
  265. package/src/views/base/memory/modal/submit-modal.tsx +134 -0
  266. package/src/views/base/settings/index.tsx +657 -0
  267. package/src/views/chat/chat.less +323 -0
  268. package/src/views/chat/components/chat-input.tsx +298 -0
  269. package/src/views/chat/components/header-thread-title.tsx +210 -0
  270. package/src/views/chat/components/message-list/content-answer.tsx +100 -0
  271. package/src/views/chat/components/message-list/content-question.tsx +18 -0
  272. package/src/views/chat/components/message-list/index.tsx +520 -0
  273. package/src/views/chat/components/message-list/message-item.tsx +199 -0
  274. package/src/views/chat/components/message-list/preparation-demo-items.ts +147 -0
  275. package/src/views/chat/components/message-list/preparation-steps.tsx +506 -0
  276. package/src/views/chat/components/message-list/suggestion-list.tsx +36 -0
  277. package/src/views/chat/components/message-list/thinking-process.tsx +49 -0
  278. package/src/views/chat/components/message-list/toolbar.tsx +224 -0
  279. package/src/views/chat/components/message-list/use-message-list-scroll.ts +214 -0
  280. package/src/views/chat/components/references-knowledge/context.tsx +57 -0
  281. package/src/views/chat/components/references-knowledge/index.ts +9 -0
  282. package/src/views/chat/components/references-knowledge/modal/knowledge-detail-drawer.tsx +556 -0
  283. package/src/views/chat/components/references-knowledge/modal/knowledge-doc-detail-drawer.tsx +529 -0
  284. package/src/views/chat/components/references-knowledge/panel.tsx +115 -0
  285. package/src/views/chat/hooks/use-chat-common.ts +19 -0
  286. package/src/views/chat/index-session.tsx +647 -0
  287. package/src/views/chat/index.tsx +127 -0
  288. package/src/views/page-error/401.tsx +56 -0
  289. package/src/views/page-error/404.tsx +56 -0
  290. package/src/views/page-menus/business-rules/index.tsx +376 -0
  291. package/src/views/page-menus/business-rules/modal/detail-modal.tsx +186 -0
  292. package/src/views/page-menus/business-rules/modal/scope-modal.tsx +272 -0
  293. package/src/views/page-menus/business-rules/modal/submit-modal.tsx +142 -0
  294. package/src/views/page-menus/feedback/components/feedback-dataset-list.tsx +471 -0
  295. package/src/views/page-menus/feedback/index.tsx +166 -0
  296. package/src/views/page-menus/feedback/modal/export-feedback-modal.tsx +367 -0
  297. package/src/views/page-menus/knowledge/components/doc-editor-by-type.tsx +32 -0
  298. package/src/views/page-menus/knowledge/components/doc-editor-type-file.tsx +330 -0
  299. package/src/views/page-menus/knowledge/detail.tsx +600 -0
  300. package/src/views/page-menus/knowledge/index.tsx +337 -0
  301. package/src/views/page-menus/knowledge/modal/detail-modal.tsx +618 -0
  302. package/src/views/page-menus/knowledge/modal/doc-detail-modal.tsx +550 -0
  303. package/src/views/page-menus/knowledge/modal/doc-parse.ts +99 -0
  304. package/src/views/page-menus/knowledge/modal/doc-submit-modal.tsx +349 -0
  305. package/src/views/page-menus/knowledge/modal/doc-type-picker-modal.tsx +88 -0
  306. package/src/views/page-menus/knowledge/modal/knowledge-user-select-modal.tsx +283 -0
  307. package/src/views/page-menus/knowledge/modal/submit-modal.tsx +179 -0
  308. package/src/views/page-menus/model-metadata/manage/components/metadata-detail-schema-tab.tsx +114 -0
  309. package/src/views/page-menus/model-metadata/manage/components/step1-basic-info.tsx +232 -0
  310. package/src/views/page-menus/model-metadata/manage/components/step2-schema.tsx +316 -0
  311. package/src/views/page-menus/model-metadata/manage/components/step3-permissions.tsx +134 -0
  312. package/src/views/page-menus/model-metadata/manage/components/step4-documents.tsx +134 -0
  313. package/src/views/page-menus/model-metadata/manage/components/step5-example-sql.tsx +101 -0
  314. package/src/views/page-menus/model-metadata/manage/components/submit-add.tsx +338 -0
  315. package/src/views/page-menus/model-metadata/manage/components/submit-edit.tsx +276 -0
  316. package/src/views/page-menus/model-metadata/manage/detail.tsx +298 -0
  317. package/src/views/page-menus/model-metadata/manage/hooks/model-metadata-submit-shared.ts +113 -0
  318. package/src/views/page-menus/model-metadata/manage/hooks/use-model-metadata-item-state.ts +20 -0
  319. package/src/views/page-menus/model-metadata/manage/index.tsx +304 -0
  320. package/src/views/page-menus/model-metadata/manage/modal/components/table-schema.ts +374 -0
  321. package/src/views/page-menus/model-metadata/manage/modal/components/use-table-detail-tabs.tsx +151 -0
  322. package/src/views/page-menus/model-metadata/manage/modal/components/use-table-submit-tabs.tsx +423 -0
  323. package/src/views/page-menus/model-metadata/manage/modal/detail-modal.tsx +218 -0
  324. package/src/views/page-menus/model-metadata/manage/modal/submit-modal.tsx +261 -0
  325. package/src/views/page-menus/model-metadata/manage/modal/table-detail-modal.tsx +196 -0
  326. package/src/views/page-menus/model-metadata/manage/modal/table-submit-modal.tsx +229 -0
  327. package/src/views/page-menus/model-metadata/manage/submit.tsx +31 -0
  328. package/src/views/page-menus/model-metadata/role/index.tsx +207 -0
  329. package/src/views/page-menus/model-metadata/role/modal/detail-modal.tsx +97 -0
  330. package/src/views/page-menus/model-metadata/role/modal/role-assign-users-modal.tsx +254 -0
  331. package/src/views/page-menus/model-metadata/role/modal/role-assign-users-panel.tsx +393 -0
  332. package/src/views/page-menus/model-metadata/role/modal/role-assign-users-utils.ts +120 -0
  333. package/src/views/page-menus/model-metadata/role/modal/role-permission-assign-panel.tsx +698 -0
  334. package/src/views/page-menus/model-metadata/role/modal/role-permission-modal.tsx +237 -0
  335. package/src/views/page-menus/model-metadata/role/modal/submit-modal.tsx +135 -0
  336. package/src/views/page-menus/model-metadata/training/components/detail-records/index.ts +4 -0
  337. package/src/views/page-menus/model-metadata/training/components/detail-records/node-card.tsx +72 -0
  338. package/src/views/page-menus/model-metadata/training/components/detail-records/summary-lines.ts +196 -0
  339. package/src/views/page-menus/model-metadata/training/components/detail-records/summary-list.tsx +153 -0
  340. package/src/views/page-menus/model-metadata/training/components/detail-records/timeline.tsx +103 -0
  341. package/src/views/page-menus/model-metadata/training/components/detail-records/types.ts +82 -0
  342. package/src/views/page-menus/model-metadata/training/detail.tsx +159 -0
  343. package/src/views/page-menus/model-metadata/training/index.tsx +236 -0
  344. package/src/views/page-menus/model-metadata/training/modal/update-detail-modal.tsx +154 -0
  345. package/src/views/page-menus/skill/index.tsx +201 -0
  346. package/src/views/page-menus/skill/modal/detail-modal.tsx +156 -0
  347. package/src/views/page-menus/skill/modal/submit-modal.tsx +214 -0
  348. package/src/views/page-system/agent-config/index.tsx +370 -0
  349. package/src/views/page-system/department/departmentFormShared.ts +36 -0
  350. package/src/views/page-system/department/index.tsx +541 -0
  351. package/src/views/page-system/department/modal/detail-modal.tsx +94 -0
  352. package/src/views/page-system/department/modal/member-role-modal.tsx +128 -0
  353. package/src/views/page-system/department/modal/submit-modal.tsx +265 -0
  354. package/src/views/page-system/dict/index.tsx +440 -0
  355. package/src/views/page-system/dict/modal/cate-submit-modal.tsx +315 -0
  356. package/src/views/page-system/dict/modal/submit-modal.tsx +184 -0
  357. package/src/views/page-system/logs/components/index.ts +3 -0
  358. package/src/views/page-system/logs/components/log-message-demo.tsx +30 -0
  359. package/src/views/page-system/logs/components/log-message-stream.ts +184 -0
  360. package/src/views/page-system/logs/components/message-list/content-answer.tsx +100 -0
  361. package/src/views/page-system/logs/components/message-list/content-question.tsx +18 -0
  362. package/src/views/page-system/logs/components/message-list/index.tsx +515 -0
  363. package/src/views/page-system/logs/components/message-list/message-item.tsx +193 -0
  364. package/src/views/page-system/logs/components/message-list/preparation-demo-items.ts +147 -0
  365. package/src/views/page-system/logs/components/message-list/preparation-steps.tsx +506 -0
  366. package/src/views/page-system/logs/components/message-list/suggestion-list.tsx +36 -0
  367. package/src/views/page-system/logs/components/message-list/thinking-process.tsx +49 -0
  368. package/src/views/page-system/logs/components/message-list/toolbar.tsx +134 -0
  369. package/src/views/page-system/logs/components/message-list/use-message-list-scroll.ts +214 -0
  370. package/src/views/page-system/logs/components/message-modal.tsx +239 -0
  371. package/src/views/page-system/logs/index.tsx +132 -0
  372. package/src/views/page-system/logs/modal/detail-modal.tsx +157 -0
  373. package/src/views/page-system/menu/components/menuFormShared.ts +283 -0
  374. package/src/views/page-system/menu/index.less +12 -0
  375. package/src/views/page-system/menu/index.tsx +410 -0
  376. package/src/views/page-system/menu/modal/icon-modal.less +51 -0
  377. package/src/views/page-system/menu/modal/icon-modal.tsx +87 -0
  378. package/src/views/page-system/menu/modal/submit-modal.tsx +263 -0
  379. package/src/views/page-system/permission/index.tsx +562 -0
  380. package/src/views/page-system/permission/modal/detail-modal.tsx +179 -0
  381. package/src/views/page-system/permission/modal/submit-modal.less +146 -0
  382. package/src/views/page-system/permission/modal/submit-modal.tsx +650 -0
  383. package/src/views/page-system/role/index.tsx +163 -0
  384. package/src/views/page-system/role/modal/detail-modal.tsx +127 -0
  385. package/src/views/page-system/role/modal/permission-assign-group-rules.ts +86 -0
  386. package/src/views/page-system/role/modal/permission-modal.tsx +111 -0
  387. package/src/views/page-system/role/modal/role-modal-shell-styles.ts +21 -0
  388. package/src/views/page-system/role/modal/role-permission-assign-panel.tsx +916 -0
  389. package/src/views/page-system/role/modal/role-permission-assign-shared.ts +1047 -0
  390. package/src/views/page-system/role/modal/submit-modal.tsx +193 -0
  391. package/src/views/page-system/sys-config/index.tsx +294 -0
  392. package/src/views/page-system/user/components/user-role-column.tsx +87 -0
  393. package/src/views/page-system/user/index.tsx +439 -0
  394. package/src/views/page-system/user/modal/assign-roles-modal.tsx +389 -0
  395. package/src/views/page-system/user/modal/detail-modal.tsx +72 -0
  396. package/src/views/page-system/user/modal/modal-style/submit-modal.less +40 -0
  397. package/src/views/page-system/user/modal/submit-modal.less +40 -0
  398. package/src/views/page-system/user/modal/submit-modal.tsx +287 -0
  399. package/src/views/page-system/user/userFormShared.ts +51 -0
  400. package/tailwind.config.js +17 -0
  401. package/tsconfig.app.json +48 -0
  402. package/tsconfig.json +11 -0
  403. package/tsconfig.node.json +26 -0
  404. package/vite.config.ts +264 -0
@@ -0,0 +1,471 @@
1
+ import { approveFeedbackAPI, rejectFeedbackAPI, updateFeedbackAPI } from '@/api/menus/feedback'
2
+ import ConfirmDialog from '@/components/common/modal/confirm-dialog'
3
+ import { useAuth } from '@/contexts/AuthContext'
4
+ import { useToast } from '@/contexts/ToastContext'
5
+ import {
6
+ type FeedbackDatasetItem,
7
+ feedbackStatusI18nKey,
8
+ isFeedbackPending,
9
+ } from '@/types/feedback'
10
+ import { parseBackendDate } from '@/utils/date'
11
+ import {
12
+ markdownRehypePlugins,
13
+ markdownRemarkPlugins,
14
+ } from '@/utils/markdown-math-plugins'
15
+ import { useMutation } from '@tanstack/react-query'
16
+ import clsx from 'clsx'
17
+ import {
18
+ CheckCircle,
19
+ Edit3,
20
+ Loader2,
21
+ Save,
22
+ ThumbsDown,
23
+ ThumbsUp,
24
+ Trash2,
25
+ X,
26
+ XCircle,
27
+ } from 'lucide-react'
28
+ import { useEffect, useRef, useState } from 'react'
29
+ import { useTranslation } from 'react-i18next'
30
+ import type { Options as ReactMarkdownOptions } from 'react-markdown'
31
+ import ReactMarkdown from 'react-markdown'
32
+
33
+ export interface FeedbackDatasetListProps {
34
+ pageConfig: {
35
+ fetchTableData?: () => Promise<void>
36
+ onDelete?: (record: { id: string }) => void
37
+ }
38
+ tableData: FeedbackDatasetItem[]
39
+ loading: boolean
40
+ }
41
+
42
+ export function FeedbackDatasetList({
43
+ pageConfig,
44
+ tableData,
45
+ loading,
46
+ }: FeedbackDatasetListProps) {
47
+ const { t } = useTranslation()
48
+ const { showToast } = useToast()
49
+ const { hasPermission } = useAuth()
50
+
51
+ const listTopRef = useRef<HTMLDivElement>(null)
52
+
53
+ const [editingId, setEditingId] = useState<string | null>(null)
54
+ const [editPrompt, setEditPrompt] = useState('')
55
+ const [editCompletion, setEditCompletion] = useState('')
56
+ const [reviewConfirm, setReviewConfirm] = useState<{
57
+ open: boolean
58
+ id: string
59
+ action: 'approve' | 'reject'
60
+ }>({ open: false, id: '', action: 'approve' })
61
+
62
+ const updateMutation = useMutation({
63
+ mutationFn: async (vars: { id: string; data: any }) => {
64
+ const response = await updateFeedbackAPI(
65
+ {
66
+ id: vars.id,
67
+ question: vars.data.question,
68
+ answer: vars.data.answer,
69
+ }
70
+ )
71
+ // Axios 响应对象:response.data 是实际的响应数据
72
+ const responseData = response.data
73
+ // 检查业务逻辑是否成功
74
+ if (responseData && responseData.success === false) {
75
+ throw new Error(responseData.message || t('common.operation_failed'))
76
+ }
77
+ return responseData
78
+ },
79
+ onSuccess: (data, variables) => {
80
+ void pageConfig.fetchTableData?.()
81
+ setEditingId(null)
82
+
83
+ if (variables.data.question || variables.data.answer) {
84
+ showToast(t('common.saved'), 'success')
85
+ }
86
+
87
+ setTimeout(() => {
88
+ listTopRef.current?.scrollIntoView({
89
+ behavior: 'smooth',
90
+ block: 'start',
91
+ })
92
+ }, 100)
93
+ },
94
+ onError: (error: any) => {
95
+ console.error('更新失败:', error)
96
+ },
97
+ })
98
+
99
+ useEffect(() => {
100
+ if (editingId) {
101
+ requestAnimationFrame(() => {
102
+ const element = document.getElementById(`feedback-item-${editingId}`)
103
+ element?.scrollIntoView({ behavior: 'smooth', block: 'nearest' })
104
+ })
105
+ }
106
+ }, [editingId])
107
+
108
+ const handleEdit = (item: FeedbackDatasetItem) => {
109
+ setEditingId(item.id)
110
+ setEditPrompt(item.question)
111
+ setEditCompletion(item.answer)
112
+ }
113
+
114
+ const handleCancelEdit = () => {
115
+ setEditingId(null)
116
+ }
117
+
118
+ const handleSave = (id: string) => {
119
+ updateMutation.mutate({
120
+ id,
121
+ data: {
122
+ question: editPrompt,
123
+ answer: editCompletion,
124
+ },
125
+ })
126
+ }
127
+
128
+ /** 调用审核通过或拒绝接口(需在确认框 onOk 中执行) */
129
+ const submitReview = async (id: string, action: 'approve' | 'reject') => {
130
+ const response =
131
+ action === 'approve'
132
+ ? await approveFeedbackAPI(id)
133
+ : await rejectFeedbackAPI(id)
134
+ const responseData = response.data
135
+ if (responseData && responseData.success === false) {
136
+ throw new Error(responseData.message || t('common.operation_failed'))
137
+ }
138
+ showToast(
139
+ action === 'approve'
140
+ ? t('menus.feedback.toast.approved')
141
+ : t('menus.feedback.toast.rejected'),
142
+ 'success',
143
+ )
144
+ void pageConfig.fetchTableData?.()
145
+ setTimeout(() => {
146
+ listTopRef.current?.scrollIntoView({
147
+ behavior: 'smooth',
148
+ block: 'start',
149
+ })
150
+ }, 100)
151
+ }
152
+
153
+ /** 打开审核确认弹框(与删除确认同款 ConfirmDialog) */
154
+ const openReviewConfirm = (id: string, action: 'approve' | 'reject') => {
155
+ setReviewConfirm({ open: true, id, action })
156
+ }
157
+
158
+ /** 关闭审核确认弹框 */
159
+ const closeReviewConfirm = () => {
160
+ setReviewConfirm((prev) => ({ ...prev, open: false }))
161
+ }
162
+
163
+ /** 确认审核:调用接口后关闭弹框 */
164
+ const confirmReview = async () => {
165
+ try {
166
+ await submitReview(reviewConfirm.id, reviewConfirm.action)
167
+ closeReviewConfirm()
168
+ } catch (err) {
169
+ console.log(err instanceof Error ? err.message : String(err))
170
+ }
171
+ }
172
+
173
+ if (loading && (!tableData || tableData.length === 0)) {
174
+ return (
175
+ <div className="flex flex-col justify-center items-center h-64">
176
+ <Loader2 className="animate-spin h-8 w-8 text-blue-600 mb-2" />
177
+ <p>{t('common.loading')}</p>
178
+ </div>
179
+ )
180
+ }
181
+
182
+ const feedbackList = tableData || []
183
+
184
+ return (
185
+ <>
186
+ <div className="space-y-6 scroll-mt-24" ref={listTopRef}>
187
+ {feedbackList.length === 0 ? (
188
+ <div className="text-center py-12 bg-white dark:bg-gray-800 rounded-xl border border-gray-200 dark:border-gray-700">
189
+ <p className="text-gray-500 dark:text-gray-400">
190
+ {t('menus.feedback.no_records')}
191
+ </p>
192
+ </div>
193
+ ) : (
194
+ feedbackList.map((item) => {
195
+ const isEditing = editingId === item.id
196
+ const statusKey = feedbackStatusI18nKey(item.status)
197
+ return (
198
+ <div
199
+ key={item.id}
200
+ id={`feedback-item-${item.id}`}
201
+ className="group bg-white dark:bg-gray-800 rounded-xl border border-gray-200 dark:border-gray-700 shadow-sm overflow-hidden flex flex-col">
202
+ <div className="px-6 py-4 border-b border-gray-100 dark:border-gray-700 flex justify-between items-center bg-gray-50/50 dark:bg-gray-800/50">
203
+ <div className="flex items-center gap-3 flex-wrap">
204
+ <span
205
+ className={clsx(
206
+ 'px-2.5 py-1 rounded-full text-xs font-bold uppercase tracking-wide',
207
+ statusKey === 'pending' &&
208
+ 'bg-yellow-100 text-yellow-800 dark:bg-yellow-900/30 dark:text-yellow-200',
209
+ statusKey === 'approved' &&
210
+ 'bg-green-100 text-green-800 dark:bg-green-900/30 dark:text-green-200',
211
+ statusKey === 'rejected' &&
212
+ 'bg-red-100 text-red-800 dark:bg-red-900/30 dark:text-red-200',
213
+ )}>
214
+ {t(`menus.feedback.status.${statusKey}`)}
215
+ </span>
216
+ {item.evaluationType === 10 && (
217
+ <span className="flex items-center gap-1 text-xs font-medium text-green-600 dark:text-green-400">
218
+ <ThumbsUp size={14} /> {t('menus.feedback.like')}
219
+ </span>
220
+ )}
221
+ {item.evaluationType === 20 && (
222
+ <span className="flex items-center gap-1 text-xs font-medium text-red-600 dark:text-red-400">
223
+ <ThumbsDown size={14} /> {t('menus.feedback.dislike')}
224
+ </span>
225
+ )}
226
+
227
+ <span className="text-xs text-gray-400 ml-2">
228
+ {t('menus.feedback.submitted_at')}:{' '}
229
+ {parseBackendDate(item.createTime)?.format('yyyy-MM-dd hh:mm:ss') ??
230
+ item.createTime}
231
+ </span>
232
+ </div>
233
+
234
+ {(item.reviewBy || item.reviewTime) && (
235
+ <div className="text-xs text-gray-500 flex items-center gap-2 shrink-0">
236
+ {item.reviewBy && (
237
+ <span>
238
+ {t('menus.feedback.reviewed_by', {
239
+ name: item.reviewBy,
240
+ })}
241
+ </span>
242
+ )}
243
+ {item.reviewTime && (
244
+ <span className="text-gray-400">
245
+ (
246
+ {parseBackendDate(item.reviewTime)?.format(
247
+ 'yyyy-MM-dd hh:mm:ss',
248
+ ) ?? item.reviewTime}
249
+ )
250
+ </span>
251
+ )}
252
+ </div>
253
+ )}
254
+ </div>
255
+
256
+ <div className="divide-y divide-gray-100 dark:divide-gray-700 flex-1">
257
+ <div className="p-6 bg-gray-50/30 dark:bg-gray-800/20">
258
+ <div className="text-xs font-semibold text-gray-500 dark:text-gray-400 uppercase tracking-wider mb-2">
259
+ {t('menus.feedback.user_input')}
260
+ </div>
261
+ {isEditing ? (
262
+ <textarea
263
+ autoFocus
264
+ value={editPrompt}
265
+ onChange={(e) => setEditPrompt(e.target.value)}
266
+ className="w-full h-32 p-3 text-sm bg-white dark:bg-gray-900 border border-gray-200 dark:border-gray-700 rounded-lg focus:ring-2 focus:ring-blue-500 outline-none font-mono text-gray-800 dark:text-gray-100"
267
+ />
268
+ ) : (
269
+ <div className="prose dark:prose-invert prose-sm max-w-none text-gray-800 dark:text-gray-200 break-words">
270
+ <ReactMarkdown
271
+ remarkPlugins={markdownRemarkPlugins}
272
+ rehypePlugins={markdownRehypePlugins}
273
+ components={{
274
+ table: ({ ...props }) => (
275
+ <table
276
+ className="min-w-full divide-y divide-gray-200 dark:divide-gray-700 border border-gray-200 dark:border-gray-700 rounded-lg overflow-hidden"
277
+ {...props}
278
+ />
279
+ ),
280
+ thead: ({ ...props }) => (
281
+ <thead
282
+ className="bg-gray-50 dark:bg-gray-800"
283
+ {...props}
284
+ />
285
+ ),
286
+ tbody: ({ ...props }) => (
287
+ <tbody
288
+ className="divide-y divide-gray-200 dark:divide-gray-700 bg-white dark:bg-gray-900"
289
+ {...props}
290
+ />
291
+ ),
292
+ tr: ({ ...props }) => <tr {...props} />,
293
+ th: ({ ...props }) => (
294
+ <th
295
+ className="px-3 py-2 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider border-r border-gray-200 dark:border-gray-700 last:border-r-0"
296
+ {...props}
297
+ />
298
+ ),
299
+ td: ({ ...props }) => (
300
+ <td
301
+ className="px-3 py-2 whitespace-normal text-sm text-gray-700 dark:text-gray-300 border-r border-gray-200 dark:border-gray-700 last:border-r-0"
302
+ {...props}
303
+ />
304
+ ),
305
+ }}>
306
+ {item.question}
307
+ </ReactMarkdown>
308
+ </div>
309
+ )}
310
+ </div>
311
+
312
+ <div className="p-6 bg-blue-50/10 dark:bg-blue-900/5">
313
+ <div className="text-xs font-semibold text-blue-600 dark:text-blue-400 uppercase tracking-wider mb-2">
314
+ {t('menus.feedback.ai_response')}
315
+ </div>
316
+ {isEditing ? (
317
+ <textarea
318
+ value={editCompletion}
319
+ onChange={(e) => setEditCompletion(e.target.value)}
320
+ className="w-full h-64 p-3 text-sm bg-white dark:bg-gray-900 border border-gray-200 dark:border-gray-700 rounded-lg focus:ring-2 focus:ring-blue-500 outline-none font-mono text-gray-800 dark:text-gray-100"
321
+ />
322
+ ) : (
323
+ <div className="prose dark:prose-invert prose-sm max-w-none text-gray-900 dark:text-gray-100 break-words">
324
+ <ReactMarkdown
325
+ remarkPlugins={
326
+ markdownRemarkPlugins as ReactMarkdownOptions['remarkPlugins']
327
+ }
328
+ rehypePlugins={
329
+ markdownRehypePlugins as ReactMarkdownOptions['rehypePlugins']
330
+ }
331
+ components={{
332
+ table: ({ ...props }) => (
333
+ <table
334
+ className="min-w-full divide-y divide-gray-200 dark:divide-gray-700 border border-gray-200 dark:border-gray-700 rounded-lg overflow-hidden my-4"
335
+ {...props}
336
+ />
337
+ ),
338
+ thead: ({ ...props }) => (
339
+ <thead
340
+ className="bg-gray-50 dark:bg-gray-800"
341
+ {...props}
342
+ />
343
+ ),
344
+ tbody: ({ ...props }) => (
345
+ <tbody
346
+ className="divide-y divide-gray-200 dark:divide-gray-700 bg-white dark:bg-gray-900"
347
+ {...props}
348
+ />
349
+ ),
350
+ tr: ({ ...props }) => <tr {...props} />,
351
+ th: ({ ...props }) => (
352
+ <th
353
+ className="px-3 py-2 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider border-r border-gray-200 dark:border-gray-700 last:border-r-0"
354
+ {...props}
355
+ />
356
+ ),
357
+ td: ({ ...props }) => (
358
+ <td
359
+ className="px-3 py-2 whitespace-normal text-sm text-gray-700 dark:text-gray-300 border-r border-gray-200 dark:border-gray-700 last:border-r-0"
360
+ {...props}
361
+ />
362
+ ),
363
+ }}>
364
+ {item.answer}
365
+ </ReactMarkdown>
366
+ </div>
367
+ )}
368
+ </div>
369
+ </div>
370
+
371
+ <div className="px-6 py-4 bg-gray-50 dark:bg-gray-800/50 border-t border-gray-100 dark:border-gray-700 flex justify-between items-center sticky bottom-0 z-10">
372
+ <div className="text-xs text-gray-400 font-mono select-all">
373
+ ID: {item.id}
374
+ </div>
375
+
376
+ <div className="flex items-center gap-3 flex-wrap justify-end">
377
+ {isEditing ? (
378
+ <>
379
+ <button
380
+ type="button"
381
+ onClick={() => handleSave(item.id)}
382
+ className="flex items-center gap-1 px-3 py-1.5 bg-blue-600 hover:bg-blue-700 active:scale-95 active:bg-blue-800 text-white rounded-lg text-xs font-medium transition-all">
383
+ <Save size={14} /> {t('common.save')}
384
+ </button>
385
+ <button
386
+ type="button"
387
+ onClick={handleCancelEdit}
388
+ className="p-1.5 text-gray-500 hover:bg-gray-200 dark:hover:bg-gray-700 active:scale-90 active:bg-gray-300 dark:active:bg-gray-600 rounded-lg transition-all">
389
+ <X size={16} />
390
+ </button>
391
+ </>
392
+ ) : (
393
+ isFeedbackPending(item.status) &&
394
+ hasPermission('feedback-manage:edit') && (
395
+ <button
396
+ type="button"
397
+ onClick={() => handleEdit(item)}
398
+ className="p-2 text-gray-500 hover:text-blue-600 hover:bg-blue-50 dark:hover:bg-blue-900/20 active:scale-90 active:bg-blue-100 dark:active:bg-blue-900/40 rounded-lg transition-all border border-transparent hover:border-blue-100 dark:hover:border-blue-800"
399
+ title={t('menus.feedback.actions.edit')}>
400
+ <Edit3 size={16} />
401
+ </button>
402
+ )
403
+ )}
404
+
405
+ {(isFeedbackPending(item.status) || isEditing) && (
406
+ <div className="h-4 w-px bg-gray-300 dark:bg-gray-600" />
407
+ )}
408
+
409
+ {isFeedbackPending(item.status) &&
410
+ !isEditing &&
411
+ (hasPermission('feedback-manage:approve') || hasPermission('feedback-manage:reject')) && (
412
+ <>
413
+ {hasPermission('feedback-manage:approve') && (
414
+ <button
415
+ type="button"
416
+ onClick={() => openReviewConfirm(item.id, 'approve')}
417
+ className="flex items-center gap-1 px-4 py-2 bg-green-600 hover:bg-green-700 text-white rounded-lg text-sm font-medium transition-transform active:scale-95 shadow-sm">
418
+ <CheckCircle size={16} />{' '}
419
+ {t('menus.feedback.actions.approve')}
420
+ </button>
421
+ )}
422
+ {hasPermission('feedback-manage:reject') && (
423
+ <button
424
+ type="button"
425
+ onClick={() => openReviewConfirm(item.id, 'reject')}
426
+ className="flex items-center gap-1 px-4 py-2 bg-white dark:bg-gray-800 border border-red-200 dark:border-red-900/50 text-red-600 hover:bg-red-50 dark:hover:bg-red-900/20 rounded-lg text-sm font-medium transition-transform active:scale-95">
427
+ <XCircle size={16} />{' '}
428
+ {t('menus.feedback.actions.reject')}
429
+ </button>
430
+ )}
431
+ </>
432
+ )}
433
+
434
+ {hasPermission('feedback-manage:delete') && (
435
+ <button
436
+ type="button"
437
+ onClick={() => pageConfig.onDelete?.({ id: item.id })}
438
+ className="ml-2 p-2 text-gray-400 hover:text-red-600 hover:bg-red-50 dark:hover:bg-red-900/20 active:scale-90 active:bg-red-100 dark:active:bg-red-900/40 rounded-lg transition-all"
439
+ title={t('menus.feedback.actions.delete')}>
440
+ <Trash2 size={16} />
441
+ </button>
442
+ )}
443
+ </div>
444
+ </div>
445
+ </div>
446
+ )
447
+ })
448
+ )}
449
+ </div>
450
+
451
+ <ConfirmDialog
452
+ isOpen={reviewConfirm.open}
453
+ danger={reviewConfirm.action === 'reject'}
454
+ title={
455
+ reviewConfirm.action === 'approve'
456
+ ? t('menus.feedback.confirm_approve_title')
457
+ : t('menus.feedback.confirm_reject_title')
458
+ }
459
+ message={
460
+ reviewConfirm.action === 'approve'
461
+ ? t('menus.feedback.confirm_approve_message')
462
+ : t('menus.feedback.confirm_reject_message')
463
+ }
464
+ confirmText={t('common.ok')}
465
+ cancelText={t('common.cancel')}
466
+ onClose={closeReviewConfirm}
467
+ onConfirm={confirmReview}
468
+ />
469
+ </>
470
+ )
471
+ }
@@ -0,0 +1,166 @@
1
+ import { deleteFeedbacksAPI, getFeedbackPageAPI } from '@/api/menus/feedback'
2
+ import { useAuth } from '@/contexts/AuthContext'
3
+ import type { FeedbackStatusFilter } from '@/types/feedback'
4
+ import ListPageView, { createListPageConfig } from '@components/table-view'
5
+ import clsx from 'clsx'
6
+ import { Download, MessageSquareQuote } from 'lucide-react'
7
+ import { useState } from 'react'
8
+ import { useTranslation } from 'react-i18next'
9
+ import { FeedbackDatasetList } from './components/feedback-dataset-list'
10
+ import ExportFeedbackModal from './modal/export-feedback-modal'
11
+
12
+ /** 列表顶部状态筛选是否与当前搜索条件一致(空值为「全部」) */
13
+ function isFeedbackStatusTabActive(
14
+ current: unknown,
15
+ tab: FeedbackStatusFilter,
16
+ ): boolean {
17
+ if (tab === '') {
18
+ return current === '' || current === undefined || current === null
19
+ }
20
+ return current === tab
21
+ }
22
+
23
+ const FEEDBACK_STATUS_TABS: Array<{
24
+ value: FeedbackStatusFilter
25
+ i18nKey: 'pending' | 'approved' | 'rejected' | 'all'
26
+ }> = [
27
+ { value: 0, i18nKey: 'pending' },
28
+ { value: 1, i18nKey: 'approved' },
29
+ { value: 2, i18nKey: 'rejected' },
30
+ { value: '', i18nKey: 'all' },
31
+ ]
32
+
33
+ const useListPageConfig = createListPageConfig({
34
+ tableAPI: getFeedbackPageAPI,
35
+ deleteAPI: deleteFeedbacksAPI,
36
+ pageInfo: {
37
+ title: 'menus.feedback.title_dataset',
38
+ subTitle: 'menus.feedback.subtitle_dataset',
39
+ },
40
+ pagination: { page: 1, pageSize: 10, total: 0 },
41
+ initialSearchFormData: {
42
+ status: '',
43
+ userName: '',
44
+ evaluationType: '',
45
+ startTime: '',
46
+ endTime: '',
47
+ },
48
+ searchFields: [
49
+ {
50
+ prop: 'userName',
51
+ label: 'menus.feedback.filter_content',
52
+ placeholder: 'menus.feedback.search_content_placeholder',
53
+ },
54
+ {
55
+ prop: 'evaluationType',
56
+ label: 'menus.feedback.filter_score',
57
+ placeholder: 'menus.feedback.search_score_placeholder',
58
+ type: 'select',
59
+ options: [
60
+ // {label: 'menus.feedback.score_all', value: '',},
61
+ {label: 'menus.feedback.like', value: '10',},
62
+ {label: 'menus.feedback.dislike', value: '20',}
63
+ ]
64
+ },
65
+ {
66
+ prop: 'startDate',
67
+ label: 'menus.feedback.search_date_range_label',
68
+ placeholder: [
69
+ 'menus.feedback.search_date_range_ph_start',
70
+ 'menus.feedback.search_date_range_ph_end',
71
+ ],
72
+ type: 'dateRange',
73
+ rangeStartProp: 'startTime',
74
+ rangeEndProp: 'endTime',
75
+ format: 'YYYY-MM-DD HH:mm:ss',
76
+ },
77
+ ],
78
+ table: { showPagination: true },
79
+ deleteConfirm: {
80
+ title: 'menus.feedback.confirm_delete_title',
81
+ content: 'menus.feedback.confirm_delete_message',
82
+ okText: 'common.delete',
83
+ cancelText: 'common.cancel',
84
+ },
85
+ })
86
+
87
+ function IndexView() {
88
+ const { t } = useTranslation()
89
+ const { hasPermission } = useAuth()
90
+ const [exportOpen, setExportOpen] = useState(false)
91
+ const [exportSnapshot, setExportSnapshot] = useState<{
92
+ paginationData?: { page?: number; pageSize?: number }
93
+ listQuery?: { sort?: string; order?: 'asc' | 'desc' }
94
+ searchFormData?: Record<string, unknown>
95
+ }>({})
96
+
97
+ const pageConfig = useListPageConfig()
98
+
99
+ return (
100
+ <div className="menus-feedback-page">
101
+ <ListPageView
102
+ pageConfig={pageConfig}
103
+ headerActions={
104
+ <>
105
+ {hasPermission('feedback-manage:export') && (
106
+ <button
107
+ type="button"
108
+ onClick={() => {
109
+ setExportSnapshot({
110
+ paginationData: pageConfig.paginationData,
111
+ listQuery: pageConfig.listQuery,
112
+ searchFormData: pageConfig.searchFormData as Record<
113
+ string,
114
+ unknown
115
+ >,
116
+ })
117
+ setExportOpen(true)
118
+ }}
119
+ className="px-4 py-2 bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 text-gray-700 dark:text-gray-300 rounded-lg text-sm font-medium hover:bg-gray-50 dark:hover:bg-gray-700 active:scale-95 active:bg-gray-100 dark:active:bg-gray-600 transition-all flex items-center gap-2 mr-2"
120
+ title={t('menus.feedback.export.title')}>
121
+ <Download size={16} />
122
+ <span className="hidden sm:inline">
123
+ {t('menus.feedback.export.action')}
124
+ </span>
125
+ </button>
126
+ )}
127
+ {FEEDBACK_STATUS_TABS.map(({ value, i18nKey }) => (
128
+ <button
129
+ key={i18nKey}
130
+ type="button"
131
+ onClick={() =>
132
+ pageConfig.patchSearchAndRefresh?.({ status: value })
133
+ }
134
+ className={clsx(
135
+ 'px-4 py-2 rounded-lg text-sm font-medium transition-all duration-200 active:scale-95',
136
+ isFeedbackStatusTabActive(
137
+ (pageConfig.searchFormData as { status?: unknown })
138
+ ?.status,
139
+ value,
140
+ )
141
+ ? 'bg-blue-600 text-white shadow-lg shadow-blue-600/20 scale-105 active:bg-blue-700'
142
+ : 'bg-gray-100 text-gray-600 dark:bg-gray-800 dark:text-gray-400 hover:bg-gray-200 dark:hover:bg-gray-700 hover:text-gray-900 dark:hover:text-gray-200 active:bg-gray-300 dark:active:bg-gray-600',
143
+ )}>
144
+ {t(`menus.feedback.status.${i18nKey}`)}
145
+ </button>
146
+ ))}
147
+ </>
148
+ }
149
+ renderList={() => (
150
+ <FeedbackDatasetList
151
+ pageConfig={pageConfig}
152
+ tableData={pageConfig.tableData}
153
+ loading={pageConfig.loading}
154
+ />
155
+ )}
156
+ />
157
+ <ExportFeedbackModal
158
+ isOpen={exportOpen}
159
+ onClose={() => setExportOpen(false)}
160
+ listSnapshot={exportSnapshot}
161
+ />
162
+ </div>
163
+ )
164
+ }
165
+
166
+ export default IndexView