@liujitcn/kratos-admin-system 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 (208) hide show
  1. package/README.md +137 -0
  2. package/dist/package/declarations/index.d.ts +1 -0
  3. package/dist/package/declarations/src/ai.d.ts +10 -0
  4. package/dist/package/declarations/src/api/base/ai_message.d.ts +27 -0
  5. package/dist/package/declarations/src/api/base/ai_session.d.ts +17 -0
  6. package/dist/package/declarations/src/api/base/ai_tool.d.ts +7 -0
  7. package/dist/package/declarations/src/api/base/oauth.d.ts +13 -0
  8. package/dist/package/declarations/src/api/base/sse.d.ts +31 -0
  9. package/dist/package/declarations/src/api/system/auth.d.ts +17 -0
  10. package/dist/package/declarations/src/api/system/base_api.d.ts +22 -0
  11. package/dist/package/declarations/src/api/system/base_area.d.ts +19 -0
  12. package/dist/package/declarations/src/api/system/base_config.d.ts +20 -0
  13. package/dist/package/declarations/src/api/system/base_dept.d.ts +21 -0
  14. package/dist/package/declarations/src/api/system/base_dict.d.ts +32 -0
  15. package/dist/package/declarations/src/api/system/base_job.d.ts +28 -0
  16. package/dist/package/declarations/src/api/system/base_log.d.ts +9 -0
  17. package/dist/package/declarations/src/api/system/base_menu.d.ts +21 -0
  18. package/dist/package/declarations/src/api/system/base_migration.d.ts +10 -0
  19. package/dist/package/declarations/src/api/system/base_post.d.ts +21 -0
  20. package/dist/package/declarations/src/api/system/base_role.d.ts +23 -0
  21. package/dist/package/declarations/src/api/system/base_tenant.d.ts +21 -0
  22. package/dist/package/declarations/src/api/system/base_user.d.ts +23 -0
  23. package/dist/package/declarations/src/api/system/code_gen.d.ts +14 -0
  24. package/dist/package/declarations/src/api/system/code_gen_column.d.ts +12 -0
  25. package/dist/package/declarations/src/api/system/code_gen_proto.d.ts +10 -0
  26. package/dist/package/declarations/src/api/system/code_gen_sse.d.ts +8 -0
  27. package/dist/package/declarations/src/api/system/code_gen_table.d.ts +18 -0
  28. package/dist/package/declarations/src/api/system/project_document.d.ts +9 -0
  29. package/dist/package/declarations/src/components/Ai.vue.d.ts +3 -0
  30. package/dist/package/declarations/src/index.d.ts +3 -0
  31. package/dist/package/declarations/src/module.d.ts +2 -0
  32. package/dist/package/declarations/src/rpc/base/v1/ai_message.d.ts +82 -0
  33. package/dist/package/declarations/src/rpc/base/v1/ai_session.d.ts +176 -0
  34. package/dist/package/declarations/src/rpc/base/v1/ai_tool.d.ts +59 -0
  35. package/dist/package/declarations/src/rpc/base/v1/oauth.d.ts +167 -0
  36. package/dist/package/declarations/src/rpc/base/v1/sse.d.ts +13 -0
  37. package/dist/package/declarations/src/rpc/common/v1/common.d.ts +57 -0
  38. package/dist/package/declarations/src/rpc/common/v1/enum.d.ts +58 -0
  39. package/dist/package/declarations/src/rpc/common/v1/types.d.ts +60 -0
  40. package/dist/package/declarations/src/rpc/google/protobuf/empty.d.ts +11 -0
  41. package/dist/package/declarations/src/rpc/google/protobuf/timestamp.d.ts +107 -0
  42. package/dist/package/declarations/src/rpc/system/admin/v1/auth.d.ts +156 -0
  43. package/dist/package/declarations/src/rpc/system/admin/v1/base_api.d.ts +193 -0
  44. package/dist/package/declarations/src/rpc/system/admin/v1/base_area.d.ts +82 -0
  45. package/dist/package/declarations/src/rpc/system/admin/v1/base_config.d.ts +112 -0
  46. package/dist/package/declarations/src/rpc/system/admin/v1/base_dept.d.ts +112 -0
  47. package/dist/package/declarations/src/rpc/system/admin/v1/base_dict.d.ts +215 -0
  48. package/dist/package/declarations/src/rpc/system/admin/v1/base_job.d.ts +177 -0
  49. package/dist/package/declarations/src/rpc/system/admin/v1/base_log.d.ts +87 -0
  50. package/dist/package/declarations/src/rpc/system/admin/v1/base_menu.d.ts +151 -0
  51. package/dist/package/declarations/src/rpc/system/admin/v1/base_migration.d.ts +64 -0
  52. package/dist/package/declarations/src/rpc/system/admin/v1/base_post.d.ts +112 -0
  53. package/dist/package/declarations/src/rpc/system/admin/v1/base_role.d.ts +128 -0
  54. package/dist/package/declarations/src/rpc/system/admin/v1/base_tenant.d.ts +112 -0
  55. package/dist/package/declarations/src/rpc/system/admin/v1/base_user.d.ts +161 -0
  56. package/dist/package/declarations/src/rpc/system/admin/v1/code_gen.d.ts +155 -0
  57. package/dist/package/declarations/src/rpc/system/admin/v1/code_gen_column.d.ts +143 -0
  58. package/dist/package/declarations/src/rpc/system/admin/v1/code_gen_proto.d.ts +86 -0
  59. package/dist/package/declarations/src/rpc/system/admin/v1/code_gen_table.d.ts +149 -0
  60. package/dist/package/declarations/src/rpc/system/admin/v1/project_document.d.ts +64 -0
  61. package/dist/package/declarations/src/rpc/system/common/v1/enum.d.ts +67 -0
  62. package/dist/package/declarations/src/views/ai/chat/attachment.d.ts +14 -0
  63. package/dist/package/declarations/src/views/ai/chat/components/AiMarkdown.vue.d.ts +13 -0
  64. package/dist/package/declarations/src/views/ai/chat/components/ChatPanel.vue.d.ts +45 -0
  65. package/dist/package/declarations/src/views/ai/chat/components/SessionPanel.vue.d.ts +34 -0
  66. package/dist/package/declarations/src/views/ai/chat/components/XSender.vue.d.ts +12 -0
  67. package/dist/package/declarations/src/views/ai/chat/index.vue.d.ts +4 -0
  68. package/dist/package/declarations/src/views/ai/chat/message.d.ts +59 -0
  69. package/dist/package/declarations/src/views/ai/chat/stream.d.ts +10 -0
  70. package/dist/package/declarations/src/views/ai/chat/types.d.ts +115 -0
  71. package/dist/package/declarations/src/views/base/api/index.vue.d.ts +3 -0
  72. package/dist/package/declarations/src/views/base/area/index.vue.d.ts +3 -0
  73. package/dist/package/declarations/src/views/base/config/index.vue.d.ts +3 -0
  74. package/dist/package/declarations/src/views/base/dept/index.vue.d.ts +3 -0
  75. package/dist/package/declarations/src/views/base/dict/index.vue.d.ts +3 -0
  76. package/dist/package/declarations/src/views/base/dict/item.vue.d.ts +3 -0
  77. package/dist/package/declarations/src/views/base/job/index.vue.d.ts +3 -0
  78. package/dist/package/declarations/src/views/base/job/log.vue.d.ts +3 -0
  79. package/dist/package/declarations/src/views/base/log/index.vue.d.ts +3 -0
  80. package/dist/package/declarations/src/views/base/menu/index.vue.d.ts +3 -0
  81. package/dist/package/declarations/src/views/base/migration/index.vue.d.ts +4 -0
  82. package/dist/package/declarations/src/views/base/post/index.vue.d.ts +3 -0
  83. package/dist/package/declarations/src/views/base/role/index.vue.d.ts +3 -0
  84. package/dist/package/declarations/src/views/base/tenant/index.vue.d.ts +3 -0
  85. package/dist/package/declarations/src/views/base/user/components/dept-tree.vue.d.ts +19 -0
  86. package/dist/package/declarations/src/views/base/user/index.vue.d.ts +3 -0
  87. package/dist/package/declarations/src/views/profile/components/base.vue.d.ts +13 -0
  88. package/dist/package/declarations/src/views/profile/components/password.vue.d.ts +3 -0
  89. package/dist/package/declarations/src/views/profile/components/security.vue.d.ts +15 -0
  90. package/dist/package/declarations/src/views/profile/index.vue.d.ts +3 -0
  91. package/dist/package/declarations/src/views/tool/api-doc/index.vue.d.ts +4 -0
  92. package/dist/package/declarations/src/views/tool/code-gen/code-preview/index.vue.d.ts +3 -0
  93. package/dist/package/declarations/src/views/tool/code-gen/columns/index.vue.d.ts +3 -0
  94. package/dist/package/declarations/src/views/tool/code-gen/columns/option-copy.d.ts +25 -0
  95. package/dist/package/declarations/src/views/tool/code-gen/components/CodeGenProgressDialog.vue.d.ts +16 -0
  96. package/dist/package/declarations/src/views/tool/code-gen/components/CodePreviewPane.vue.d.ts +9 -0
  97. package/dist/package/declarations/src/views/tool/code-gen/config.d.ts +32 -0
  98. package/dist/package/declarations/src/views/tool/code-gen/preview/capabilities.d.ts +20 -0
  99. package/dist/package/declarations/src/views/tool/code-gen/preview/data.d.ts +42 -0
  100. package/dist/package/declarations/src/views/tool/code-gen/preview/index.vue.d.ts +3 -0
  101. package/dist/package/declarations/src/views/tool/code-gen/proto/index.vue.d.ts +3 -0
  102. package/dist/package/declarations/src/views/tool/code-gen/table/index.vue.d.ts +3 -0
  103. package/dist/package/declarations/src/views/tool/project-doc/index.vue.d.ts +4 -0
  104. package/dist/package/src/ai.ts +16 -0
  105. package/dist/package/src/api/base/ai_message.ts +139 -0
  106. package/dist/package/src/api/base/ai_session.ts +77 -0
  107. package/dist/package/src/api/base/ai_tool.ts +22 -0
  108. package/dist/package/src/api/base/oauth.ts +47 -0
  109. package/dist/package/src/api/base/sse.ts +192 -0
  110. package/dist/package/src/api/system/auth.ts +65 -0
  111. package/dist/package/src/api/system/base_api.ts +95 -0
  112. package/dist/package/src/api/system/base_area.ts +73 -0
  113. package/dist/package/src/api/system/base_config.ts +82 -0
  114. package/dist/package/src/api/system/base_dept.ts +83 -0
  115. package/dist/package/src/api/system/base_dict.ts +144 -0
  116. package/dist/package/src/api/system/base_job.ts +125 -0
  117. package/dist/package/src/api/system/base_log.ts +32 -0
  118. package/dist/package/src/api/system/base_menu.ts +83 -0
  119. package/dist/package/src/api/system/base_migration.ts +35 -0
  120. package/dist/package/src/api/system/base_post.ts +83 -0
  121. package/dist/package/src/api/system/base_role.ts +93 -0
  122. package/dist/package/src/api/system/base_tenant.ts +83 -0
  123. package/dist/package/src/api/system/base_user.ts +93 -0
  124. package/dist/package/src/api/system/code_gen.ts +56 -0
  125. package/dist/package/src/api/system/code_gen_column.ts +43 -0
  126. package/dist/package/src/api/system/code_gen_proto.ts +32 -0
  127. package/dist/package/src/api/system/code_gen_sse.ts +33 -0
  128. package/dist/package/src/api/system/code_gen_table.ts +74 -0
  129. package/dist/package/src/api/system/project_document.ts +33 -0
  130. package/dist/package/src/components/Ai.vue +57 -0
  131. package/dist/package/src/index.ts +3 -0
  132. package/dist/package/src/module.ts +17 -0
  133. package/dist/package/src/rpc/base/v1/ai_message.ts +98 -0
  134. package/dist/package/src/rpc/base/v1/ai_session.ts +214 -0
  135. package/dist/package/src/rpc/base/v1/ai_tool.ts +74 -0
  136. package/dist/package/src/rpc/base/v1/oauth.ts +199 -0
  137. package/dist/package/src/rpc/base/v1/sse.ts +22 -0
  138. package/dist/package/src/rpc/common/v1/common.ts +71 -0
  139. package/dist/package/src/rpc/common/v1/enum.ts +71 -0
  140. package/dist/package/src/rpc/common/v1/types.ts +77 -0
  141. package/dist/package/src/rpc/google/protobuf/empty.ts +19 -0
  142. package/dist/package/src/rpc/google/protobuf/timestamp.ts +115 -0
  143. package/dist/package/src/rpc/system/admin/v1/auth.ts +208 -0
  144. package/dist/package/src/rpc/system/admin/v1/base_api.ts +241 -0
  145. package/dist/package/src/rpc/system/admin/v1/base_area.ts +105 -0
  146. package/dist/package/src/rpc/system/admin/v1/base_config.ts +140 -0
  147. package/dist/package/src/rpc/system/admin/v1/base_dept.ts +140 -0
  148. package/dist/package/src/rpc/system/admin/v1/base_dict.ts +249 -0
  149. package/dist/package/src/rpc/system/admin/v1/base_job.ts +206 -0
  150. package/dist/package/src/rpc/system/admin/v1/base_log.ts +101 -0
  151. package/dist/package/src/rpc/system/admin/v1/base_menu.ts +195 -0
  152. package/dist/package/src/rpc/system/admin/v1/base_migration.ts +81 -0
  153. package/dist/package/src/rpc/system/admin/v1/base_post.ts +134 -0
  154. package/dist/package/src/rpc/system/admin/v1/base_role.ts +151 -0
  155. package/dist/package/src/rpc/system/admin/v1/base_tenant.ts +134 -0
  156. package/dist/package/src/rpc/system/admin/v1/base_user.ts +190 -0
  157. package/dist/package/src/rpc/system/admin/v1/code_gen.ts +176 -0
  158. package/dist/package/src/rpc/system/admin/v1/code_gen_column.ts +170 -0
  159. package/dist/package/src/rpc/system/admin/v1/code_gen_proto.ts +104 -0
  160. package/dist/package/src/rpc/system/admin/v1/code_gen_table.ts +179 -0
  161. package/dist/package/src/rpc/system/admin/v1/project_document.ts +79 -0
  162. package/dist/package/src/rpc/system/common/v1/enum.ts +80 -0
  163. package/dist/package/src/typings/swagger-ui-dist.d.ts +28 -0
  164. package/dist/package/src/typings/x-markdown-vue.d.ts +1 -0
  165. package/dist/package/src/views/ai/chat/attachment.ts +65 -0
  166. package/dist/package/src/views/ai/chat/components/AiMarkdown.vue +162 -0
  167. package/dist/package/src/views/ai/chat/components/ChatPanel.vue +1861 -0
  168. package/dist/package/src/views/ai/chat/components/SessionPanel.vue +316 -0
  169. package/dist/package/src/views/ai/chat/components/XSender.vue +554 -0
  170. package/dist/package/src/views/ai/chat/index.vue +848 -0
  171. package/dist/package/src/views/ai/chat/message.ts +416 -0
  172. package/dist/package/src/views/ai/chat/stream.ts +115 -0
  173. package/dist/package/src/views/ai/chat/types.ts +126 -0
  174. package/dist/package/src/views/base/api/index.vue +455 -0
  175. package/dist/package/src/views/base/area/index.vue +269 -0
  176. package/dist/package/src/views/base/config/index.vue +530 -0
  177. package/dist/package/src/views/base/dept/index.vue +461 -0
  178. package/dist/package/src/views/base/dict/index.vue +304 -0
  179. package/dist/package/src/views/base/dict/item.vue +373 -0
  180. package/dist/package/src/views/base/job/index.vue +535 -0
  181. package/dist/package/src/views/base/job/log.vue +202 -0
  182. package/dist/package/src/views/base/log/index.vue +317 -0
  183. package/dist/package/src/views/base/menu/index.vue +944 -0
  184. package/dist/package/src/views/base/migration/index.vue +791 -0
  185. package/dist/package/src/views/base/post/index.vue +324 -0
  186. package/dist/package/src/views/base/role/index.vue +684 -0
  187. package/dist/package/src/views/base/tenant/index.vue +328 -0
  188. package/dist/package/src/views/base/user/components/dept-tree.vue +75 -0
  189. package/dist/package/src/views/base/user/index.vue +783 -0
  190. package/dist/package/src/views/profile/components/base.vue +320 -0
  191. package/dist/package/src/views/profile/components/password.vue +269 -0
  192. package/dist/package/src/views/profile/components/security.vue +443 -0
  193. package/dist/package/src/views/profile/index.vue +199 -0
  194. package/dist/package/src/views/tool/api-doc/index.vue +275 -0
  195. package/dist/package/src/views/tool/code-gen/code-preview/index.vue +233 -0
  196. package/dist/package/src/views/tool/code-gen/columns/index.vue +1456 -0
  197. package/dist/package/src/views/tool/code-gen/columns/option-copy.ts +125 -0
  198. package/dist/package/src/views/tool/code-gen/components/CodeGenProgressDialog.vue +328 -0
  199. package/dist/package/src/views/tool/code-gen/components/CodePreviewPane.vue +42 -0
  200. package/dist/package/src/views/tool/code-gen/config.ts +175 -0
  201. package/dist/package/src/views/tool/code-gen/preview/capabilities.ts +34 -0
  202. package/dist/package/src/views/tool/code-gen/preview/data.ts +331 -0
  203. package/dist/package/src/views/tool/code-gen/preview/index.vue +831 -0
  204. package/dist/package/src/views/tool/code-gen/proto/index.vue +703 -0
  205. package/dist/package/src/views/tool/code-gen/table/index.vue +864 -0
  206. package/dist/package/src/views/tool/project-doc/index.vue +561 -0
  207. package/package.json +60 -0
  208. package/tsconfig.json +13 -0
@@ -0,0 +1,791 @@
1
+ <!-- 数据库迁移升级历史 -->
2
+ <template>
3
+ <div v-loading="loading" class="table-box migration-page">
4
+ <main class="migration-content">
5
+ <el-form class="migration-filters" :model="filters" inline @submit.prevent="handleSearch">
6
+ <el-form-item label="模块">
7
+ <el-input v-model="filters.module" clearable placeholder="请输入迁移模块" @keyup.enter="handleSearch" />
8
+ </el-form-item>
9
+ <el-form-item label="数据源">
10
+ <el-input v-model="filters.data_source" clearable placeholder="请输入数据源名称" @keyup.enter="handleSearch" />
11
+ </el-form-item>
12
+ <el-form-item label="版本">
13
+ <el-input v-model="filters.version" clearable placeholder="请输入版本号" @keyup.enter="handleSearch" />
14
+ </el-form-item>
15
+ <el-form-item class="migration-filters__actions">
16
+ <el-button type="primary" :icon="Search" native-type="submit">查询</el-button>
17
+ <el-button :icon="Refresh" @click="handleReset">重置</el-button>
18
+ </el-form-item>
19
+ </el-form>
20
+
21
+ <el-empty v-if="!loading && !histories.length" description="暂无升级历史" />
22
+
23
+ <section v-else class="migration-workspace" aria-label="数据库升级历史">
24
+ <aside class="migration-list-panel">
25
+ <div class="migration-list-scroll" role="listbox" aria-label="升级记录列表">
26
+ <button
27
+ v-for="history in histories"
28
+ :key="history.id"
29
+ type="button"
30
+ class="migration-list-item"
31
+ :class="{ 'is-active': selectedMigrationId === history.id }"
32
+ :aria-selected="selectedMigrationId === history.id"
33
+ @click="selectMigration(history.id)"
34
+ >
35
+ <div class="migration-list-item__top">
36
+ <strong>{{ history.version }}</strong>
37
+ </div>
38
+ <div class="migration-list-item__data-source">
39
+ {{ history.module || "数据库迁移" }} · {{ history.data_source || "default" }}
40
+ </div>
41
+ <time :datetime="history.created_at">{{ formatDate(history.created_at) }}</time>
42
+ </button>
43
+ </div>
44
+
45
+ <div v-if="pageable.total > pageable.page_size" class="migration-pagination">
46
+ <span class="migration-pagination__total">共 {{ pageable.total }} 条</span>
47
+ <el-pagination
48
+ background
49
+ small
50
+ layout="prev, pager, next"
51
+ :current-page="pageable.page_num"
52
+ :page-size="pageable.page_size"
53
+ :pager-count="5"
54
+ :total="pageable.total"
55
+ @current-change="handleCurrentPageChange"
56
+ />
57
+ </div>
58
+ </aside>
59
+
60
+ <section class="migration-detail-panel">
61
+ <div v-if="detailLoading && !selectedMigration" class="detail-loading">
62
+ <el-skeleton :rows="8" animated />
63
+ </div>
64
+ <template v-else-if="selectedMigration">
65
+ <header class="detail-header">
66
+ <div class="detail-header__title">
67
+ <span class="detail-header__data-source">
68
+ {{ selectedMigration.module || "数据库迁移" }} · {{ selectedMigration.data_source || "default" }}
69
+ </span>
70
+ <div class="detail-header__version">
71
+ <h2>{{ selectedMigration.version }}</h2>
72
+ </div>
73
+ </div>
74
+ <div class="detail-header__meta">
75
+ <time :datetime="selectedMigration.created_at">{{ selectedMigration.created_at }}</time>
76
+ </div>
77
+ </header>
78
+
79
+ <div v-loading="detailLoading" class="detail-scroll">
80
+ <template v-if="!detailLoading">
81
+ <section v-if="selectedMigration.description" class="detail-section">
82
+ <div class="detail-section__title">
83
+ <el-icon><Document /></el-icon>
84
+ <span>升级说明</span>
85
+ </div>
86
+ <MarkdownRenderer
87
+ class="migration-markdown"
88
+ :markdown="selectedMigration.description"
89
+ :allow-html="false"
90
+ :sanitize="true"
91
+ :enable-breaks="true"
92
+ :enable-latex="false"
93
+ :enable-animate="false"
94
+ :enable-shiki="false"
95
+ :enable-mermaid="false"
96
+ :is-dark="globalStore.isDark"
97
+ :show-code-block-header="true"
98
+ :sticky-code-block-header="false"
99
+ :enable-code-line-number="false"
100
+ code-max-height="360px"
101
+ :style="markdownRootStyle"
102
+ />
103
+ </section>
104
+
105
+ <section v-if="selectedMigration.up_sql || selectedMigration.down_sql" class="detail-section">
106
+ <div class="detail-section__title">
107
+ <el-icon><Files /></el-icon>
108
+ <span>SQL 脚本</span>
109
+ </div>
110
+ <el-collapse class="release-sql">
111
+ <el-collapse-item v-if="selectedMigration.up_sql" name="up">
112
+ <template #title>
113
+ <span class="sql-title">
114
+ <el-icon><DocumentAdd /></el-icon>
115
+ <span>升级脚本</span>
116
+ <code>up.sql</code>
117
+ </span>
118
+ </template>
119
+ <div class="sql-panel">
120
+ <pre class="sql-code"><code>{{ selectedMigration.up_sql }}</code></pre>
121
+ <el-tooltip content="复制升级脚本" placement="top">
122
+ <el-button
123
+ class="sql-copy"
124
+ text
125
+ circle
126
+ :icon="CopyDocument"
127
+ aria-label="复制升级脚本"
128
+ @click.stop="copySql(selectedMigration.up_sql)"
129
+ />
130
+ </el-tooltip>
131
+ </div>
132
+ </el-collapse-item>
133
+ <el-collapse-item v-if="selectedMigration.down_sql" name="down">
134
+ <template #title>
135
+ <span class="sql-title">
136
+ <el-icon><DocumentRemove /></el-icon>
137
+ <span>回退脚本</span>
138
+ <code>down.sql</code>
139
+ </span>
140
+ </template>
141
+ <div class="sql-panel">
142
+ <pre class="sql-code"><code>{{ selectedMigration.down_sql }}</code></pre>
143
+ <el-tooltip content="复制回退脚本" placement="top">
144
+ <el-button
145
+ class="sql-copy"
146
+ text
147
+ circle
148
+ :icon="CopyDocument"
149
+ aria-label="复制回退脚本"
150
+ @click.stop="copySql(selectedMigration.down_sql)"
151
+ />
152
+ </el-tooltip>
153
+ </div>
154
+ </el-collapse-item>
155
+ </el-collapse>
156
+ </section>
157
+
158
+ <div v-if="!hasDetailContent" class="detail-empty">
159
+ <el-icon><Document /></el-icon>
160
+ <span>该记录暂无描述或脚本</span>
161
+ </div>
162
+ </template>
163
+ </div>
164
+ </template>
165
+ <el-empty v-else description="请选择一条升级记录" />
166
+ </section>
167
+ </section>
168
+
169
+ </main>
170
+ </div>
171
+ </template>
172
+
173
+ <script setup lang="ts">
174
+ import { computed, onMounted, reactive, ref } from "vue";
175
+ import { CopyDocument, Document, DocumentAdd, DocumentRemove, Files, Refresh, Search } from "@element-plus/icons-vue";
176
+ import { MarkdownRenderer } from "x-markdown-vue";
177
+ import "x-markdown-vue/style";
178
+ import { defBaseMigrationService } from "@liujitcn/kratos-admin-system/api/system/base_migration";
179
+ import type { BaseMigration, BaseMigrationListItem, PageBaseMigrationRequest } from "@liujitcn/kratos-admin-system/rpc/system/admin/v1/base_migration";
180
+ import { useGlobalStore } from "@liujitcn/kratos-admin-core/stores/runtime";
181
+ import { buildPageRequest } from "@liujitcn/kratos-admin-core/table";
182
+
183
+ defineOptions({
184
+ name: "BaseMigration",
185
+ inheritAttrs: false
186
+ });
187
+
188
+ /** 数据库升级历史筛选条件。 */
189
+ interface MigrationFilters {
190
+ /** 迁移版本号。 */
191
+ version: string | undefined;
192
+ /** 迁移模块名称。 */
193
+ module: string | undefined;
194
+ /** 数据源名称。 */
195
+ data_source: string | undefined;
196
+ }
197
+
198
+ /** 数据库升级历史分页状态。 */
199
+ interface MigrationPageable {
200
+ /** 当前页码。 */
201
+ page_num: number;
202
+ /** 每页条数。 */
203
+ page_size: number;
204
+ /** 总记录数。 */
205
+ total: number;
206
+ }
207
+
208
+ const globalStore = useGlobalStore();
209
+ const loading = ref(false);
210
+ const detailLoading = ref(false);
211
+ const histories = ref<BaseMigrationListItem[]>([]);
212
+ const selectedMigrationId = ref<number | null>(null);
213
+ const selectedMigration = ref<BaseMigration | null>(null);
214
+ const detailRequestToken = ref(0);
215
+ const filters = reactive<MigrationFilters>({
216
+ version: undefined,
217
+ module: undefined,
218
+ data_source: undefined
219
+ });
220
+ const pageable = reactive<MigrationPageable>({
221
+ page_num: 1,
222
+ page_size: 10,
223
+ total: 0
224
+ });
225
+ /** 覆盖 MarkdownRenderer 默认容器样式,保持内容与详情面板对齐。 */
226
+ const markdownRootStyle = {
227
+ padding: "0",
228
+ color: "inherit",
229
+ backgroundColor: "transparent"
230
+ };
231
+ const hasDetailContent = computed(() =>
232
+ Boolean(selectedMigration.value?.description || selectedMigration.value?.up_sql || selectedMigration.value?.down_sql)
233
+ );
234
+
235
+ /**
236
+ * 加载数据库升级历史列表。
237
+ */
238
+ async function loadMigrationHistory() {
239
+ loading.value = true;
240
+ try {
241
+ const params: PageBaseMigrationRequest = {
242
+ data_source: filters.data_source ?? "",
243
+ version: filters.version,
244
+ module: filters.module,
245
+ page_num: pageable.page_num,
246
+ page_size: pageable.page_size
247
+ };
248
+ const data = await defBaseMigrationService.PageBaseMigration(buildPageRequest(params));
249
+ histories.value = data.base_migrations ?? [];
250
+ pageable.total = Number(data.total ?? 0);
251
+ const nextId = histories.value.find(item => item.id === selectedMigrationId.value)?.id ?? histories.value[0]?.id;
252
+ if (nextId === undefined) {
253
+ selectedMigrationId.value = null;
254
+ selectedMigration.value = null;
255
+ detailRequestToken.value += 1;
256
+ } else {
257
+ await selectMigration(nextId);
258
+ }
259
+ } finally {
260
+ loading.value = false;
261
+ }
262
+ }
263
+
264
+ /**
265
+ * 选择升级记录并查询右侧详情。
266
+ */
267
+ async function selectMigration(id: number) {
268
+ selectedMigrationId.value = id;
269
+ selectedMigration.value = null;
270
+ detailLoading.value = true;
271
+ const requestToken = detailRequestToken.value + 1;
272
+ detailRequestToken.value = requestToken;
273
+ try {
274
+ const detail = await defBaseMigrationService.GetBaseMigration({ id });
275
+ if (detailRequestToken.value === requestToken && selectedMigrationId.value === id) {
276
+ selectedMigration.value = detail;
277
+ }
278
+ } finally {
279
+ if (detailRequestToken.value === requestToken) {
280
+ detailLoading.value = false;
281
+ }
282
+ }
283
+ }
284
+
285
+ /**
286
+ * 按版本号重新查询升级历史。
287
+ */
288
+ function handleSearch() {
289
+ pageable.page_num = 1;
290
+ loadMigrationHistory();
291
+ }
292
+
293
+ /**
294
+ * 清空版本筛选条件并重新查询。
295
+ */
296
+ function handleReset() {
297
+ filters.version = undefined;
298
+ filters.module = undefined;
299
+ filters.data_source = undefined;
300
+ handleSearch();
301
+ }
302
+
303
+ /**
304
+ * 切换升级历史分页。
305
+ */
306
+ function handleCurrentPageChange(page: number) {
307
+ pageable.page_num = page;
308
+ loadMigrationHistory();
309
+ }
310
+
311
+ /**
312
+ * 复制 SQL 脚本内容。
313
+ */
314
+ async function copySql(sql: string) {
315
+ try {
316
+ await navigator.clipboard.writeText(sql);
317
+ ElMessage.success("SQL 脚本已复制");
318
+ } catch {
319
+ ElMessage.error("复制失败,请手动选择脚本内容");
320
+ }
321
+ }
322
+
323
+ /**
324
+ * 格式化列表日期。
325
+ */
326
+ function formatDate(value: string) {
327
+ if (!value) return "--";
328
+ const date = new Date(value.replace(" ", "T"));
329
+ if (Number.isNaN(date.getTime())) return value;
330
+ return new Intl.DateTimeFormat("zh-CN", {
331
+ year: "numeric",
332
+ month: "short",
333
+ day: "numeric"
334
+ }).format(date);
335
+ }
336
+
337
+ onMounted(() => {
338
+ loadMigrationHistory();
339
+ });
340
+ </script>
341
+
342
+ <style scoped lang="scss">
343
+ .migration-page {
344
+ box-sizing: border-box;
345
+ display: flex;
346
+ flex-direction: column;
347
+ width: 100%;
348
+ min-height: 100%;
349
+ padding: 0;
350
+ color: var(--admin-page-text-primary);
351
+ background: var(--el-bg-color-page);
352
+ }
353
+
354
+ .migration-content {
355
+ box-sizing: border-box;
356
+ display: flex;
357
+ flex: 1;
358
+ flex-direction: column;
359
+ width: 100%;
360
+ min-height: 0;
361
+ margin: 0;
362
+ overflow: hidden;
363
+ background: var(--admin-page-card-bg);
364
+ border: 1px solid var(--admin-page-card-border);
365
+ border-radius: var(--admin-page-radius);
366
+ box-shadow: var(--admin-page-shadow);
367
+ }
368
+
369
+ .migration-filters {
370
+ display: flex;
371
+ flex-wrap: wrap;
372
+ align-items: flex-end;
373
+ gap: 0 12px;
374
+ width: 100%;
375
+ padding: 18px 24px 14px;
376
+ margin: 0;
377
+ border-bottom: 1px solid var(--admin-page-divider);
378
+ }
379
+
380
+ .migration-filters :deep(.el-form-item) {
381
+ margin: 0 0 8px;
382
+ }
383
+
384
+ .migration-filters :deep(.el-input) {
385
+ width: 220px;
386
+ }
387
+
388
+ .migration-filters__actions {
389
+ display: flex;
390
+ gap: 8px;
391
+ }
392
+
393
+ .migration-filters__actions :deep(.el-form-item__content) {
394
+ gap: 8px;
395
+ }
396
+
397
+ .migration-workspace {
398
+ display: grid;
399
+ flex: 1;
400
+ grid-template-columns: 360px minmax(0, 1fr);
401
+ gap: 0;
402
+ width: 100%;
403
+ height: auto;
404
+ min-height: 440px;
405
+ max-height: none;
406
+ margin: 0;
407
+ }
408
+
409
+ .migration-list-panel,
410
+ .migration-detail-panel {
411
+ display: flex;
412
+ min-width: 0;
413
+ min-height: 0;
414
+ flex-direction: column;
415
+ overflow: hidden;
416
+ background: transparent;
417
+ }
418
+
419
+ .migration-detail-panel {
420
+ border-left: 1px solid var(--admin-page-divider);
421
+ }
422
+
423
+ .migration-list-scroll {
424
+ flex: 1;
425
+ min-height: 0;
426
+ overflow-y: auto;
427
+ }
428
+
429
+ .migration-list-item {
430
+ display: block;
431
+ width: 100%;
432
+ padding: 14px 18px;
433
+ color: var(--admin-page-text-primary);
434
+ text-align: left;
435
+ cursor: pointer;
436
+ background: transparent;
437
+ border: 0;
438
+ border-bottom: 1px solid var(--admin-page-divider);
439
+ transition:
440
+ background-color 0.2s ease,
441
+ box-shadow 0.2s ease;
442
+ }
443
+
444
+ .migration-list-item:hover {
445
+ background: var(--el-fill-color-light);
446
+ }
447
+
448
+ .migration-list-item.is-active {
449
+ background: var(--admin-page-accent-soft-bg);
450
+ box-shadow: inset 3px 0 0 var(--el-color-primary);
451
+ }
452
+
453
+ .migration-list-item__top {
454
+ display: flex;
455
+ align-items: center;
456
+ justify-content: space-between;
457
+ gap: 12px;
458
+ }
459
+
460
+ .migration-list-item__top strong {
461
+ min-width: 0;
462
+ overflow: hidden;
463
+ font-size: 15px;
464
+ font-weight: 650;
465
+ color: var(--el-color-primary);
466
+ text-overflow: ellipsis;
467
+ white-space: nowrap;
468
+ }
469
+
470
+ .migration-list-item__data-source {
471
+ margin-top: 8px;
472
+ overflow: hidden;
473
+ font-size: 13px;
474
+ color: var(--admin-page-text-primary);
475
+ text-overflow: ellipsis;
476
+ white-space: nowrap;
477
+ }
478
+
479
+ .migration-list-item time {
480
+ display: block;
481
+ margin-top: 5px;
482
+ font-size: 12px;
483
+ color: var(--admin-page-text-secondary);
484
+ }
485
+
486
+ .migration-pagination {
487
+ display: flex;
488
+ align-items: center;
489
+ gap: 12px;
490
+ justify-content: flex-end;
491
+ min-width: 0;
492
+ overflow: hidden;
493
+ padding: 12px 18px;
494
+ border-top: 1px solid var(--admin-page-divider);
495
+ }
496
+
497
+ .migration-pagination__total {
498
+ flex: 0 0 auto;
499
+ font-size: 12px;
500
+ color: var(--admin-page-text-secondary);
501
+ white-space: nowrap;
502
+ }
503
+
504
+ .migration-pagination :deep(.el-pagination) {
505
+ flex: 1 1 auto;
506
+ min-width: 0;
507
+ margin: 0;
508
+ overflow-x: auto;
509
+ padding: 0;
510
+ white-space: nowrap;
511
+ }
512
+
513
+ .detail-header {
514
+ display: flex;
515
+ flex: 0 0 auto;
516
+ align-items: flex-start;
517
+ justify-content: space-between;
518
+ gap: 20px;
519
+ padding: 22px 24px 20px;
520
+ border-bottom: 1px solid var(--admin-page-divider);
521
+ }
522
+
523
+ .detail-header__title {
524
+ min-width: 0;
525
+ }
526
+
527
+ .detail-header__data-source {
528
+ display: block;
529
+ overflow: hidden;
530
+ font-size: 12px;
531
+ font-weight: 600;
532
+ color: var(--admin-page-text-secondary);
533
+ letter-spacing: 0.04em;
534
+ text-overflow: ellipsis;
535
+ white-space: nowrap;
536
+ }
537
+
538
+ .detail-header__version {
539
+ display: flex;
540
+ flex-wrap: wrap;
541
+ gap: 10px;
542
+ align-items: center;
543
+ margin-top: 8px;
544
+ }
545
+
546
+ .detail-header h2 {
547
+ margin: 0;
548
+ font-size: 24px;
549
+ font-weight: 650;
550
+ line-height: 1.35;
551
+ overflow-wrap: anywhere;
552
+ }
553
+
554
+ .detail-header__meta {
555
+ display: flex;
556
+ flex: 0 0 auto;
557
+ flex-direction: column;
558
+ align-items: flex-end;
559
+ gap: 6px;
560
+ padding-top: 3px;
561
+ font-size: 12px;
562
+ color: var(--admin-page-text-secondary);
563
+ text-align: right;
564
+ }
565
+
566
+ .detail-scroll {
567
+ flex: 1;
568
+ min-height: 0;
569
+ overflow-y: auto;
570
+ padding: 24px;
571
+ }
572
+
573
+ .detail-section + .detail-section {
574
+ margin-top: 26px;
575
+ }
576
+
577
+ .detail-section__title {
578
+ display: flex;
579
+ gap: 7px;
580
+ align-items: center;
581
+ padding-bottom: 10px;
582
+ margin-bottom: 16px;
583
+ font-size: 14px;
584
+ font-weight: 600;
585
+ color: var(--admin-page-text-primary);
586
+ border-bottom: 1px solid var(--admin-page-divider);
587
+ }
588
+
589
+ .detail-section__title :deep(.el-icon) {
590
+ color: var(--el-color-primary);
591
+ }
592
+
593
+ .migration-markdown {
594
+ width: 100%;
595
+ max-width: 100%;
596
+ overflow-wrap: anywhere;
597
+ }
598
+
599
+ .migration-markdown :deep(.x-md-core > :first-child) {
600
+ margin-top: 0;
601
+ }
602
+
603
+ .migration-markdown :deep(.x-md-core > :last-child) {
604
+ margin-bottom: 0;
605
+ }
606
+
607
+ .migration-markdown :deep(h1),
608
+ .migration-markdown :deep(h2),
609
+ .migration-markdown :deep(h3),
610
+ .migration-markdown :deep(h4),
611
+ .migration-markdown :deep(h5),
612
+ .migration-markdown :deep(h6) {
613
+ color: var(--admin-page-text-primary);
614
+ }
615
+
616
+ .migration-markdown :deep(a) {
617
+ color: var(--el-color-primary);
618
+ }
619
+
620
+ .migration-markdown :deep(blockquote) {
621
+ border-left-color: var(--el-border-color);
622
+ }
623
+
624
+ .migration-markdown :deep(table) {
625
+ max-width: 100%;
626
+ overflow-x: auto;
627
+ }
628
+
629
+ .release-sql {
630
+ border: 1px solid var(--admin-page-card-border-soft);
631
+ border-radius: var(--admin-page-radius);
632
+ }
633
+
634
+ .release-sql :deep(.el-collapse) {
635
+ border: 0;
636
+ }
637
+
638
+ .release-sql :deep(.el-collapse-item__header) {
639
+ height: 46px;
640
+ padding: 0 14px;
641
+ color: var(--admin-page-text-primary);
642
+ background: var(--admin-page-card-bg-soft);
643
+ border-bottom-color: var(--admin-page-card-border-soft);
644
+ }
645
+
646
+ .release-sql :deep(.el-collapse-item__wrap) {
647
+ background: var(--admin-page-card-bg);
648
+ border-bottom-color: var(--admin-page-card-border-soft);
649
+ }
650
+
651
+ .release-sql :deep(.el-collapse-item__content) {
652
+ padding: 14px;
653
+ }
654
+
655
+ .sql-title {
656
+ display: inline-flex;
657
+ gap: 8px;
658
+ align-items: center;
659
+ min-width: 0;
660
+ font-size: 13px;
661
+ font-weight: 600;
662
+ }
663
+
664
+ .sql-title :deep(.el-icon) {
665
+ color: var(--el-color-primary);
666
+ }
667
+
668
+ .sql-title code {
669
+ padding: 2px 6px;
670
+ font-size: 11px;
671
+ font-weight: 500;
672
+ color: var(--admin-page-text-secondary);
673
+ background: var(--admin-page-card-bg-muted);
674
+ border-radius: 4px;
675
+ }
676
+
677
+ .sql-panel {
678
+ position: relative;
679
+ min-width: 0;
680
+ }
681
+
682
+ .sql-code {
683
+ max-height: 360px;
684
+ padding: 14px 48px 14px 16px;
685
+ margin: 0;
686
+ overflow: auto;
687
+ color: var(--admin-page-text-primary);
688
+ white-space: pre;
689
+ background: var(--admin-page-card-bg-muted);
690
+ border: 1px solid var(--admin-page-card-border-soft);
691
+ border-radius: var(--admin-page-radius);
692
+ }
693
+
694
+ .sql-code code {
695
+ font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
696
+ font-size: 12px;
697
+ line-height: 1.65;
698
+ }
699
+
700
+ .sql-copy {
701
+ position: absolute;
702
+ top: 6px;
703
+ right: 6px;
704
+ color: var(--admin-page-text-secondary);
705
+ }
706
+
707
+ .sql-copy:hover {
708
+ color: var(--el-color-primary);
709
+ }
710
+
711
+ .detail-empty {
712
+ display: flex;
713
+ min-height: 180px;
714
+ flex-direction: column;
715
+ align-items: center;
716
+ justify-content: center;
717
+ gap: 8px;
718
+ font-size: 13px;
719
+ color: var(--admin-page-text-placeholder);
720
+ }
721
+
722
+ .detail-empty :deep(.el-icon) {
723
+ font-size: 28px;
724
+ }
725
+
726
+ .detail-loading {
727
+ padding: 24px;
728
+ }
729
+
730
+ @media (max-width: 900px) {
731
+ .migration-page {
732
+ padding: 12px;
733
+ }
734
+
735
+ .migration-workspace {
736
+ grid-template-columns: 280px minmax(0, 1fr);
737
+ }
738
+ }
739
+
740
+ @media (max-width: 720px) {
741
+ .migration-filters {
742
+ padding-right: 16px;
743
+ padding-left: 16px;
744
+ }
745
+
746
+ .migration-filters :deep(.el-input) {
747
+ width: 100%;
748
+ }
749
+
750
+ .migration-workspace {
751
+ display: flex;
752
+ height: auto;
753
+ min-height: 0;
754
+ flex-direction: column;
755
+ }
756
+
757
+ .migration-list-panel {
758
+ height: 320px;
759
+ flex: 0 0 auto;
760
+ border-bottom: 1px solid var(--admin-page-divider);
761
+ }
762
+
763
+ .migration-detail-panel {
764
+ min-height: 480px;
765
+ border-left: 0;
766
+ }
767
+
768
+ .migration-pagination {
769
+ justify-content: center;
770
+ padding-right: 12px;
771
+ padding-left: 12px;
772
+ overflow-x: auto;
773
+ }
774
+
775
+ .detail-header,
776
+ .detail-scroll {
777
+ padding-right: 16px;
778
+ padding-left: 16px;
779
+ }
780
+
781
+ .detail-header {
782
+ flex-direction: column;
783
+ gap: 10px;
784
+ }
785
+
786
+ .detail-header__meta {
787
+ align-items: flex-start;
788
+ text-align: left;
789
+ }
790
+ }
791
+ </style>