index.vue 27 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136
  1. <template>
  2. <div class="connection-pool-page">
  3. <v-card class="hero-card" elevation="2">
  4. <div class="hero-content d-flex align-center">
  5. <div class="hero-icon d-flex align-center justify-center">
  6. <v-icon color="primary" size="30">mdi-database-sync-outline</v-icon>
  7. </div>
  8. <div class="hero-copy">
  9. <h1>外部数据源连接池</h1>
  10. <p>
  11. 统一查看 PostgreSQL 与 MySQL 数据源的连接复用、占用和故障隔离状态。
  12. 连接池按业务访问惰性创建,不包含平台自身数据库。
  13. </p>
  14. </div>
  15. <v-spacer />
  16. <div class="hero-actions d-flex align-center">
  17. <v-btn
  18. outlined
  19. color="primary"
  20. class="mr-3"
  21. @click="$router.push('/data-governance/data-source')"
  22. >
  23. <v-icon left>mdi-database-cog-outline</v-icon>
  24. 数据源管理
  25. </v-btn>
  26. <v-btn
  27. color="primary"
  28. :loading="loading"
  29. @click="loadData"
  30. >
  31. <v-icon left>mdi-refresh</v-icon>
  32. 立即刷新
  33. </v-btn>
  34. </div>
  35. </div>
  36. </v-card>
  37. <v-row class="summary-row" dense>
  38. <v-col
  39. v-for="item in summaryItems"
  40. :key="item.label"
  41. cols="12"
  42. sm="6"
  43. lg="3"
  44. >
  45. <v-card class="summary-card" elevation="2">
  46. <div
  47. class="summary-icon d-flex align-center justify-center"
  48. :class="item.tone"
  49. >
  50. <v-icon size="25">{{ item.icon }}</v-icon>
  51. </div>
  52. <div>
  53. <div class="summary-label">{{ item.label }}</div>
  54. <div class="summary-value">{{ item.value }}</div>
  55. <div class="summary-hint">{{ item.hint }}</div>
  56. </div>
  57. </v-card>
  58. </v-col>
  59. </v-row>
  60. <v-card class="management-card" elevation="2">
  61. <div class="toolbar d-flex align-center flex-wrap">
  62. <v-text-field
  63. v-model="searchText"
  64. class="toolbar-control"
  65. label="数据源名称或地址"
  66. prepend-inner-icon="mdi-magnify"
  67. outlined
  68. dense
  69. clearable
  70. hide-details
  71. />
  72. <v-select
  73. v-model="typeFilter"
  74. class="toolbar-control"
  75. :items="databaseTypes"
  76. label="数据库类型"
  77. outlined
  78. dense
  79. clearable
  80. hide-details
  81. />
  82. <v-select
  83. v-model="stateFilter"
  84. class="toolbar-control"
  85. :items="poolStates"
  86. label="连接池状态"
  87. outlined
  88. dense
  89. clearable
  90. hide-details
  91. />
  92. <v-spacer />
  93. <div class="refresh-control d-flex align-center">
  94. <span class="refresh-time">更新于 {{ refreshedAt || '--:--:--' }}</span>
  95. <v-switch
  96. v-model="autoRefresh"
  97. class="ml-4 mt-0"
  98. color="primary"
  99. label="每 15 秒自动刷新"
  100. hide-details
  101. />
  102. </div>
  103. </div>
  104. <v-divider />
  105. <v-data-table
  106. class="pool-table"
  107. :headers="headers"
  108. :items="filteredItems"
  109. :loading="loading"
  110. :items-per-page="10"
  111. :footer-props="{
  112. itemsPerPageText: '每页行数',
  113. itemsPerPageOptions: [10, 20, 50]
  114. }"
  115. item-key="uid"
  116. loading-text="正在读取连接池状态..."
  117. no-data-text="暂无符合条件的数据源"
  118. >
  119. <template v-slot:[`item.source`]="{ item }">
  120. <div class="source-cell">
  121. <div class="source-name">{{ item.name_zh || item.name_en }}</div>
  122. <div class="source-meta">
  123. {{ item.name_en }}
  124. <span v-if="item.database">· {{ item.database }}</span>
  125. </div>
  126. <div class="source-endpoint">{{ item.host }}:{{ item.port }}</div>
  127. </div>
  128. </template>
  129. <template v-slot:[`item.type`]="{ item }">
  130. <div class="database-type">
  131. <v-icon
  132. size="19"
  133. :color="item.type === 'postgresql' ? 'primary' : 'warning'"
  134. class="mr-2"
  135. >
  136. mdi-database-outline
  137. </v-icon>
  138. {{ databaseTypeLabel(item.type) }}
  139. </div>
  140. </template>
  141. <template v-slot:[`item.pool_state`]="{ item }">
  142. <v-chip
  143. small
  144. label
  145. :color="stateMeta(item.pool_state).color"
  146. :outlined="item.pool_state === 'lazy'"
  147. :dark="item.pool_state !== 'lazy'"
  148. >
  149. <v-icon left x-small>{{ stateMeta(item.pool_state).icon }}</v-icon>
  150. {{ stateMeta(item.pool_state).label }}
  151. </v-chip>
  152. <div
  153. v-if="item.pool_state === 'lazy'"
  154. class="state-caption"
  155. >
  156. 首次业务访问时创建
  157. </div>
  158. </template>
  159. <template v-slot:[`item.usage`]="{ item }">
  160. <div v-if="item.has_pool" class="usage-cell">
  161. <div class="d-flex justify-space-between usage-label">
  162. <span>{{ item.checked_out }} 已借出</span>
  163. <span>{{ item.checked_in }} 空闲</span>
  164. </div>
  165. <v-progress-linear
  166. :value="usagePercent(item)"
  167. :color="usageColor(item)"
  168. height="6"
  169. rounded
  170. />
  171. </div>
  172. <span v-else class="muted-text">尚无运行实例</span>
  173. </template>
  174. <template v-slot:[`item.capacity`]="{ item }">
  175. <div class="capacity-value">
  176. {{ item.pool_size || item.configured_pool_size || 2 }}
  177. <span class="capacity-overflow">
  178. + {{ item.configured_max_overflow || 3 }}
  179. </span>
  180. </div>
  181. <div class="state-caption">基础 + 临时溢出</div>
  182. </template>
  183. <template v-slot:[`item.signals`]="{ item }">
  184. <template v-if="item.has_pool">
  185. <div>{{ formatNumber(item.checkout_wait_ms) }} ms 等待</div>
  186. <div class="state-caption">
  187. {{ item.query_total || 0 }} 次查询 · {{ item.pool_timeout_total || 0 }} 次超时
  188. </div>
  189. </template>
  190. <span v-else class="muted-text">暂无指标</span>
  191. </template>
  192. <template v-slot:[`item.actions`]="{ item }">
  193. <div class="action-cell">
  194. <v-btn text small color="primary" @click="openDetail(item)">
  195. 详情
  196. </v-btn>
  197. <v-btn
  198. v-if="item.has_pool"
  199. text
  200. small
  201. color="warning"
  202. @click="confirmReset(item)"
  203. >
  204. 安全重置
  205. </v-btn>
  206. </div>
  207. </template>
  208. <template #no-data>
  209. <div class="empty-state">
  210. <v-icon size="42" color="blue-grey lighten-2">
  211. mdi-database-off-outline
  212. </v-icon>
  213. <div class="empty-title">
  214. {{ items.length ? '暂无符合条件的数据源' : '暂无可管理的数据源' }}
  215. </div>
  216. <div class="empty-copy">
  217. {{
  218. items.length
  219. ? '请调整名称、类型或状态筛选条件。'
  220. : '请先在数据来源中新增 PostgreSQL 或 MySQL 数据源。'
  221. }}
  222. </div>
  223. <v-btn
  224. v-if="!items.length"
  225. text
  226. color="primary"
  227. @click="$router.push('/data-governance/data-source')"
  228. >
  229. 前往数据源管理
  230. </v-btn>
  231. </div>
  232. </template>
  233. </v-data-table>
  234. </v-card>
  235. <v-navigation-drawer
  236. v-model="drawer"
  237. fixed
  238. right
  239. temporary
  240. :width="$vuetify.breakpoint.smAndDown ? '100%' : 520"
  241. class="pool-detail-drawer"
  242. style="z-index: var(--zIndex-drawers);"
  243. >
  244. <div v-if="selectedItem" class="detail-shell">
  245. <div class="detail-header d-flex align-center">
  246. <div>
  247. <div class="detail-eyebrow">连接池详情</div>
  248. <h2>{{ selectedItem.name_zh || selectedItem.name_en }}</h2>
  249. </div>
  250. <v-spacer />
  251. <v-btn icon aria-label="关闭详情" @click="drawer = false">
  252. <v-icon>mdi-close</v-icon>
  253. </v-btn>
  254. </div>
  255. <div class="detail-body">
  256. <div class="detail-status d-flex align-center">
  257. <div
  258. class="detail-status-icon d-flex align-center justify-center"
  259. :class="stateMeta(selectedItem.pool_state).tone"
  260. >
  261. <v-icon>{{ stateMeta(selectedItem.pool_state).icon }}</v-icon>
  262. </div>
  263. <div>
  264. <div class="detail-status-title">
  265. {{ stateMeta(selectedItem.pool_state).label }}
  266. </div>
  267. <div class="detail-status-copy">
  268. {{ stateMeta(selectedItem.pool_state).description }}
  269. </div>
  270. </div>
  271. </div>
  272. <section class="detail-section">
  273. <h3>数据源信息</h3>
  274. <dl class="definition-grid">
  275. <div>
  276. <dt>数据库类型</dt>
  277. <dd>{{ databaseTypeLabel(selectedItem.type) }}</dd>
  278. </div>
  279. <div>
  280. <dt>服务器地址</dt>
  281. <dd>{{ selectedItem.host }}:{{ selectedItem.port }}</dd>
  282. </div>
  283. <div>
  284. <dt>数据库 / Schema</dt>
  285. <dd>
  286. {{ selectedItem.database || '-' }} /
  287. {{ selectedItem.schema || '-' }}
  288. </dd>
  289. </div>
  290. <div>
  291. <dt>凭据版本</dt>
  292. <dd>
  293. {{
  294. selectedItem.credential_version
  295. ? `v${selectedItem.credential_version}`
  296. : '-'
  297. }}
  298. </dd>
  299. </div>
  300. </dl>
  301. </section>
  302. <section class="detail-section">
  303. <h3>实时容量</h3>
  304. <div class="metric-grid">
  305. <div
  306. v-for="metric in detailMetrics"
  307. :key="metric.label"
  308. class="metric-item"
  309. >
  310. <div class="metric-value">{{ metric.value }}</div>
  311. <div class="metric-label">{{ metric.label }}</div>
  312. </div>
  313. </div>
  314. </section>
  315. <section class="detail-section">
  316. <h3>运行信号</h3>
  317. <v-simple-table dense>
  318. <tbody>
  319. <tr>
  320. <td>累计创建连接</td>
  321. <td class="text-right">
  322. {{ selectedItem.connection_created_total || 0 }}
  323. </td>
  324. </tr>
  325. <tr>
  326. <td>连接失败</td>
  327. <td class="text-right">
  328. {{ selectedItem.connection_failed_total || 0 }}
  329. </td>
  330. </tr>
  331. <tr>
  332. <td>池等待超时</td>
  333. <td class="text-right">
  334. {{ selectedItem.pool_timeout_total || 0 }}
  335. </td>
  336. </tr>
  337. <tr>
  338. <td>连续失败</td>
  339. <td class="text-right">
  340. {{ selectedItem.consecutive_failures || 0 }}
  341. </td>
  342. </tr>
  343. <tr>
  344. <td>最近查询耗时</td>
  345. <td class="text-right">
  346. {{ formatNumber(selectedItem.last_query_duration_ms) }} ms
  347. </td>
  348. </tr>
  349. </tbody>
  350. </v-simple-table>
  351. </section>
  352. <v-alert
  353. v-if="!selectedItem.has_pool"
  354. type="info"
  355. text
  356. dense
  357. >
  358. 当前数据源尚未触发业务访问,因此没有创建运行连接池。这是正常的惰性创建状态。
  359. </v-alert>
  360. <v-alert
  361. v-else
  362. type="warning"
  363. text
  364. dense
  365. >
  366. 安全重置会停止新连接借出,并等待正在使用的连接归还;下一次业务访问将按最新配置重新创建。
  367. </v-alert>
  368. <v-btn
  369. v-if="selectedItem.has_pool"
  370. block
  371. color="warning"
  372. dark
  373. :loading="resettingUid === selectedItem.uid"
  374. @click="confirmReset(selectedItem)"
  375. >
  376. <v-icon left>mdi-database-refresh-outline</v-icon>
  377. 安全重置连接池
  378. </v-btn>
  379. </div>
  380. </div>
  381. </v-navigation-drawer>
  382. </div>
  383. </template>
  384. <script>
  385. import {
  386. getDatasourceList,
  387. getDatasourcePools,
  388. invalidateDatasourcePool
  389. } from '@/api/dataOrigin'
  390. const STATE_META = {
  391. healthy: {
  392. label: '健康',
  393. color: 'success',
  394. tone: 'success-tone',
  395. icon: 'mdi-check-circle-outline',
  396. description: '连接池运行正常,可以持续复用外部数据库连接。'
  397. },
  398. degraded: {
  399. label: '性能下降',
  400. color: 'warning',
  401. tone: 'warning-tone',
  402. icon: 'mdi-alert-outline',
  403. description: '近期出现连接失败,请关注外部数据库网络和服务状态。'
  404. },
  405. open: {
  406. label: '已熔断',
  407. color: 'error',
  408. tone: 'error-tone',
  409. icon: 'mdi-shield-alert-outline',
  410. description: '连续连接失败触发了隔离保护,当前数据源暂时拒绝新请求。'
  411. },
  412. draining: {
  413. label: '排空中',
  414. color: 'info',
  415. tone: 'info-tone',
  416. icon: 'mdi-timer-sand',
  417. description: '连接池正在等待已借出连接归还,随后会被安全释放。'
  418. },
  419. lazy: {
  420. label: '未创建',
  421. color: 'blue-grey',
  422. tone: 'neutral-tone',
  423. icon: 'mdi-database-clock-outline',
  424. description: '连接池按需创建,首次业务访问后会自动进入运行状态。'
  425. }
  426. }
  427. export default {
  428. name: 'ConnectionPoolManagement',
  429. data () {
  430. return {
  431. loading: false,
  432. items: [],
  433. searchText: '',
  434. typeFilter: null,
  435. stateFilter: null,
  436. autoRefresh: true,
  437. refreshedAt: '',
  438. refreshTimer: null,
  439. drawer: false,
  440. selectedItem: null,
  441. resettingUid: null,
  442. databaseTypes: [
  443. { text: 'PostgreSQL', value: 'postgresql' },
  444. { text: 'MySQL', value: 'mysql' }
  445. ],
  446. poolStates: [
  447. { text: '健康', value: 'healthy' },
  448. { text: '性能下降', value: 'degraded' },
  449. { text: '已熔断', value: 'open' },
  450. { text: '排空中', value: 'draining' },
  451. { text: '未创建', value: 'lazy' }
  452. ],
  453. headers: [
  454. { text: '数据源', value: 'source', sortable: false, width: 190 },
  455. { text: '数据库类型', value: 'type', width: 105 },
  456. { text: '状态', value: 'pool_state', width: 120 },
  457. { text: '连接使用', value: 'usage', sortable: false, width: 140 },
  458. { text: '连接上限', value: 'capacity', sortable: false, width: 95 },
  459. { text: '运行信号', value: 'signals', sortable: false, width: 145 },
  460. { text: '操作', value: 'actions', sortable: false, width: 125 }
  461. ]
  462. }
  463. },
  464. computed: {
  465. summaryItems () {
  466. const activePools = this.items.filter(item => item.has_pool)
  467. const abnormalPools = activePools.filter(item => (
  468. ['degraded', 'open'].includes(item.pool_state)
  469. ))
  470. const checkedOut = activePools.reduce(
  471. (sum, item) => sum + Number(item.checked_out || 0),
  472. 0
  473. )
  474. return [
  475. {
  476. label: '外部数据源',
  477. value: this.items.length,
  478. hint: 'PostgreSQL / MySQL',
  479. icon: 'mdi-database-outline',
  480. tone: 'primary-tone'
  481. },
  482. {
  483. label: '已创建连接池',
  484. value: activePools.length,
  485. hint: `${this.items.length - activePools.length} 个等待首次访问`,
  486. icon: 'mdi-connection',
  487. tone: 'info-tone'
  488. },
  489. {
  490. label: '当前借出连接',
  491. value: checkedOut,
  492. hint: '正在被业务任务使用',
  493. icon: 'mdi-swap-horizontal',
  494. tone: 'success-tone'
  495. },
  496. {
  497. label: '异常连接池',
  498. value: abnormalPools.length,
  499. hint: abnormalPools.length ? '需要管理员关注' : '当前运行稳定',
  500. icon: 'mdi-shield-check-outline',
  501. tone: abnormalPools.length ? 'error-tone' : 'success-tone'
  502. }
  503. ]
  504. },
  505. filteredItems () {
  506. const keyword = String(this.searchText || '').trim().toLowerCase()
  507. return this.items.filter(item => {
  508. const matchesKeyword = !keyword || [
  509. item.name_zh,
  510. item.name_en,
  511. item.host,
  512. item.database
  513. ].some(value => String(value || '').toLowerCase().includes(keyword))
  514. const matchesType = !this.typeFilter || item.type === this.typeFilter
  515. const matchesState = !this.stateFilter || (
  516. item.pool_state === this.stateFilter
  517. )
  518. return matchesKeyword && matchesType && matchesState
  519. })
  520. },
  521. detailMetrics () {
  522. if (!this.selectedItem) return []
  523. return [
  524. {
  525. label: '基础连接',
  526. value: this.selectedItem.pool_size ||
  527. this.selectedItem.configured_pool_size || 2
  528. },
  529. {
  530. label: '当前借出',
  531. value: this.selectedItem.checked_out || 0
  532. },
  533. {
  534. label: '当前空闲',
  535. value: this.selectedItem.checked_in || 0
  536. },
  537. {
  538. label: '借出峰值',
  539. value: this.selectedItem.checked_out_peak || 0
  540. },
  541. {
  542. label: '临时溢出',
  543. value: this.selectedItem.overflow || 0
  544. },
  545. {
  546. label: '活动租约',
  547. value: this.selectedItem.leases || 0
  548. }
  549. ]
  550. }
  551. },
  552. watch: {
  553. autoRefresh: {
  554. immediate: true,
  555. handler (enabled) {
  556. this.clearRefreshTimer()
  557. if (enabled) {
  558. this.refreshTimer = setInterval(this.loadData, 15000)
  559. }
  560. }
  561. }
  562. },
  563. created () {
  564. this.loadData()
  565. },
  566. beforeDestroy () {
  567. this.clearRefreshTimer()
  568. },
  569. methods: {
  570. async loadData () {
  571. this.loading = true
  572. try {
  573. const [sourceResponse, poolResponse] = await Promise.all([
  574. getDatasourceList({}),
  575. getDatasourcePools()
  576. ])
  577. const sources = sourceResponse.data.data_source || []
  578. const pools = poolResponse.data.pools || []
  579. const poolMap = pools.reduce((result, item) => {
  580. result[item.data_source_uid] = item
  581. return result
  582. }, {})
  583. const sourceUids = new Set(sources.map(item => item.uid))
  584. const merged = sources.map(source => {
  585. const pool = poolMap[source.uid]
  586. return {
  587. ...source,
  588. ...pool,
  589. uid: source.uid,
  590. has_pool: Boolean(pool),
  591. pool_state: pool ? pool.pool_state : 'lazy',
  592. configured_pool_size: source.pool_size,
  593. configured_max_overflow: source.max_overflow
  594. }
  595. })
  596. pools
  597. .filter(pool => !sourceUids.has(pool.data_source_uid))
  598. .forEach(pool => {
  599. merged.push({
  600. ...pool,
  601. uid: pool.data_source_uid,
  602. name_zh: '已移除的数据源定义',
  603. name_en: pool.data_source_uid,
  604. type: 'unknown',
  605. host: '-',
  606. port: '-',
  607. database: '-',
  608. has_pool: true
  609. })
  610. })
  611. this.items = merged
  612. if (this.selectedItem) {
  613. this.selectedItem = merged.find(
  614. item => item.uid === this.selectedItem.uid
  615. ) || this.selectedItem
  616. }
  617. this.refreshedAt = new Date().toLocaleTimeString('zh-CN', {
  618. hour12: false
  619. })
  620. } catch (error) {
  621. this.$snackbar.error(
  622. typeof error === 'string' ? error : '读取连接池状态失败'
  623. )
  624. } finally {
  625. this.loading = false
  626. }
  627. },
  628. stateMeta (state) {
  629. return STATE_META[state] || STATE_META.lazy
  630. },
  631. databaseTypeLabel (type) {
  632. const labels = {
  633. postgresql: 'PostgreSQL',
  634. mysql: 'MySQL'
  635. }
  636. return labels[type] || '未知'
  637. },
  638. usagePercent (item) {
  639. const capacity = Math.max(
  640. Number(item.pool_size || item.configured_pool_size || 2) +
  641. Number(item.configured_max_overflow || 3),
  642. 1
  643. )
  644. return Math.min(100, Number(item.checked_out || 0) / capacity * 100)
  645. },
  646. usageColor (item) {
  647. const percent = this.usagePercent(item)
  648. if (percent >= 90) return 'error'
  649. if (percent >= 70) return 'warning'
  650. return 'primary'
  651. },
  652. formatNumber (value) {
  653. const number = Number(value || 0)
  654. return Number.isInteger(number) ? number : number.toFixed(1)
  655. },
  656. openDetail (item) {
  657. this.selectedItem = item
  658. this.drawer = true
  659. },
  660. confirmReset (item) {
  661. this.$confirm(
  662. '安全重置连接池',
  663. `确认重置“${item.name_zh || item.name_en}”的连接池吗?系统会等待正在使用的连接归还,下一次业务访问时自动重建。`
  664. ).then(() => this.resetPool(item))
  665. },
  666. async resetPool (item) {
  667. this.resettingUid = item.uid
  668. try {
  669. await invalidateDatasourcePool(item.uid)
  670. this.$snackbar.success('连接池已进入安全失效流程')
  671. await this.loadData()
  672. } catch (error) {
  673. this.$snackbar.error(
  674. typeof error === 'string' ? error : '连接池重置失败'
  675. )
  676. } finally {
  677. this.resettingUid = null
  678. }
  679. },
  680. clearRefreshTimer () {
  681. if (this.refreshTimer) {
  682. clearInterval(this.refreshTimer)
  683. this.refreshTimer = null
  684. }
  685. }
  686. }
  687. }
  688. </script>
  689. <style lang="scss" scoped>
  690. .connection-pool-page {
  691. min-height: 100%;
  692. padding: 4px;
  693. color: #263238;
  694. font-size: 14px;
  695. box-sizing: border-box;
  696. }
  697. .hero-card {
  698. border-radius: 6px;
  699. border-top: 3px solid #1976d2;
  700. }
  701. .hero-content {
  702. min-height: 104px;
  703. padding: 20px 24px;
  704. }
  705. .hero-icon {
  706. width: 56px;
  707. height: 56px;
  708. flex: 0 0 56px;
  709. margin-right: 18px;
  710. border-radius: 12px;
  711. background: #e9f2fd;
  712. }
  713. .hero-copy {
  714. max-width: 720px;
  715. h1 {
  716. margin: 0 0 7px;
  717. color: #263238;
  718. font-size: 22px;
  719. font-weight: 600;
  720. line-height: 1.3;
  721. }
  722. p {
  723. margin: 0;
  724. color: #607d8b;
  725. font-size: 14px;
  726. line-height: 1.65;
  727. }
  728. }
  729. .summary-row {
  730. margin-top: 12px;
  731. }
  732. .summary-card {
  733. display: flex;
  734. min-height: 108px;
  735. padding: 19px 20px;
  736. align-items: center;
  737. border-radius: 6px;
  738. }
  739. .summary-icon {
  740. width: 46px;
  741. height: 46px;
  742. flex: 0 0 46px;
  743. margin-right: 15px;
  744. border-radius: 10px;
  745. }
  746. .summary-icon .v-icon {
  747. color: inherit !important;
  748. }
  749. .primary-tone {
  750. color: #1976d2;
  751. background: #e9f2fd;
  752. }
  753. .info-tone {
  754. color: #0288d1;
  755. background: #e4f4fb;
  756. }
  757. .success-tone {
  758. color: #2e7d32;
  759. background: #e8f5e9;
  760. }
  761. .warning-tone {
  762. color: #ef6c00;
  763. background: #fff3e0;
  764. }
  765. .error-tone {
  766. color: #c62828;
  767. background: #ffebee;
  768. }
  769. .neutral-tone {
  770. color: #607d8b;
  771. background: #eceff1;
  772. }
  773. .summary-label {
  774. color: #607d8b;
  775. font-size: 13px;
  776. }
  777. .summary-value {
  778. margin: 2px 0;
  779. color: #263238;
  780. font-size: 25px;
  781. font-weight: 600;
  782. line-height: 1.2;
  783. }
  784. .summary-hint {
  785. color: #90a4ae;
  786. font-size: 12px;
  787. }
  788. .management-card {
  789. margin-top: 12px;
  790. overflow: hidden;
  791. border-radius: 6px;
  792. }
  793. .toolbar {
  794. min-height: 76px;
  795. padding: 14px 18px;
  796. gap: 12px;
  797. }
  798. .toolbar-control {
  799. max-width: 200px;
  800. flex: 0 1 200px;
  801. }
  802. .refresh-control {
  803. flex-shrink: 0;
  804. }
  805. .refresh-time {
  806. color: #90a4ae;
  807. font-size: 12px;
  808. }
  809. .pool-table {
  810. font-size: 14px;
  811. }
  812. ::v-deep .pool-table .v-data-table__wrapper {
  813. overflow-x: auto;
  814. }
  815. ::v-deep .pool-table table {
  816. min-width: 920px;
  817. }
  818. ::v-deep .pool-table thead th {
  819. height: 48px;
  820. color: #455a64 !important;
  821. background: #f5f8fb;
  822. font-size: 13px;
  823. font-weight: 600;
  824. white-space: nowrap;
  825. }
  826. ::v-deep .pool-table tbody td {
  827. height: 67px;
  828. color: #37474f;
  829. font-size: 13px;
  830. }
  831. .source-name {
  832. color: #263238;
  833. font-weight: 600;
  834. }
  835. .source-meta,
  836. .state-caption,
  837. .muted-text {
  838. margin-top: 3px;
  839. color: #90a4ae;
  840. font-size: 12px;
  841. }
  842. .source-endpoint {
  843. margin-top: 3px;
  844. color: #78909c;
  845. font-family: Menlo, Monaco, Consolas, monospace;
  846. font-size: 11px;
  847. }
  848. .database-type {
  849. display: flex;
  850. align-items: center;
  851. white-space: nowrap;
  852. }
  853. .usage-cell {
  854. width: 138px;
  855. }
  856. .usage-label {
  857. margin-bottom: 7px;
  858. color: #607d8b;
  859. font-size: 11px;
  860. }
  861. .capacity-value {
  862. color: #263238;
  863. font-size: 16px;
  864. font-weight: 600;
  865. }
  866. .capacity-overflow {
  867. color: #1976d2;
  868. font-size: 13px;
  869. font-weight: 500;
  870. }
  871. .action-cell {
  872. display: flex;
  873. white-space: nowrap;
  874. }
  875. .empty-state {
  876. padding: 42px 16px;
  877. text-align: center;
  878. }
  879. .empty-title {
  880. margin-top: 10px;
  881. color: #455a64;
  882. font-size: 15px;
  883. font-weight: 600;
  884. }
  885. .empty-copy {
  886. margin: 5px 0 4px;
  887. color: #90a4ae;
  888. font-size: 13px;
  889. }
  890. .pool-detail-drawer {
  891. font-size: 14px;
  892. }
  893. .detail-shell {
  894. min-height: 100%;
  895. padding-top: 70px;
  896. background: #f5f7fa;
  897. }
  898. .detail-header {
  899. min-height: 82px;
  900. padding: 18px 22px;
  901. background: #fff;
  902. border-bottom: 1px solid #e6ebf0;
  903. h2 {
  904. margin: 2px 0 0;
  905. color: #263238;
  906. font-size: 20px;
  907. font-weight: 600;
  908. }
  909. }
  910. .detail-eyebrow {
  911. color: #90a4ae;
  912. font-size: 12px;
  913. }
  914. .detail-body {
  915. padding: 18px;
  916. }
  917. .detail-status,
  918. .detail-section {
  919. margin-bottom: 14px;
  920. padding: 18px;
  921. background: #fff;
  922. border: 1px solid #e8edf2;
  923. border-radius: 6px;
  924. }
  925. .detail-status-icon {
  926. width: 44px;
  927. height: 44px;
  928. flex: 0 0 44px;
  929. margin-right: 14px;
  930. border-radius: 10px;
  931. }
  932. .detail-status-title {
  933. color: #263238;
  934. font-size: 16px;
  935. font-weight: 600;
  936. }
  937. .detail-status-copy {
  938. margin-top: 2px;
  939. color: #78909c;
  940. font-size: 12px;
  941. line-height: 1.5;
  942. }
  943. .detail-section h3 {
  944. margin: 0 0 14px;
  945. color: #455a64;
  946. font-size: 14px;
  947. font-weight: 600;
  948. }
  949. .definition-grid {
  950. display: grid;
  951. margin: 0;
  952. grid-template-columns: repeat(2, minmax(0, 1fr));
  953. gap: 16px 18px;
  954. dt {
  955. color: #90a4ae;
  956. font-size: 12px;
  957. }
  958. dd {
  959. margin: 4px 0 0;
  960. color: #37474f;
  961. font-size: 13px;
  962. word-break: break-all;
  963. }
  964. }
  965. .metric-grid {
  966. display: grid;
  967. grid-template-columns: repeat(3, minmax(0, 1fr));
  968. gap: 10px;
  969. }
  970. .metric-item {
  971. padding: 12px 8px;
  972. text-align: center;
  973. background: #f6f9fc;
  974. border-radius: 4px;
  975. }
  976. .metric-value {
  977. color: #1976d2;
  978. font-size: 21px;
  979. font-weight: 600;
  980. }
  981. .metric-label {
  982. margin-top: 3px;
  983. color: #78909c;
  984. font-size: 11px;
  985. }
  986. @media (max-width: 960px) {
  987. .hero-content {
  988. align-items: flex-start !important;
  989. flex-wrap: wrap;
  990. }
  991. .hero-copy {
  992. width: calc(100% - 74px);
  993. }
  994. .hero-actions {
  995. width: 100%;
  996. margin-top: 18px;
  997. padding-left: 74px;
  998. }
  999. .refresh-control {
  1000. width: 100%;
  1001. justify-content: flex-end;
  1002. }
  1003. }
  1004. @media (max-width: 600px) {
  1005. .connection-pool-page {
  1006. padding: 0;
  1007. }
  1008. .hero-content {
  1009. padding: 18px;
  1010. }
  1011. .hero-icon {
  1012. width: 46px;
  1013. height: 46px;
  1014. flex-basis: 46px;
  1015. margin-right: 12px;
  1016. }
  1017. .hero-copy {
  1018. width: calc(100% - 58px);
  1019. h1 {
  1020. font-size: 19px;
  1021. }
  1022. }
  1023. .hero-actions {
  1024. padding-left: 0;
  1025. .v-btn {
  1026. flex: 1;
  1027. margin-right: 8px !important;
  1028. }
  1029. }
  1030. .toolbar-control {
  1031. max-width: none;
  1032. flex-basis: 100%;
  1033. }
  1034. .refresh-control {
  1035. justify-content: space-between;
  1036. }
  1037. .definition-grid {
  1038. grid-template-columns: 1fr;
  1039. }
  1040. }
  1041. </style>