Dashboard.vue 28 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031
  1. <template>
  2. <div class="dashboard">
  3. <div class="admin-dashboard">
  4. <!-- 欢迎区域 -->
  5. <div class="welcome-banner">
  6. <div class="welcome-content">
  7. <h1 class="welcome-title">欢迎回来!👋</h1>
  8. <p class="welcome-desc">今天是 {{ todayDate }},来看看今天的运营数据吧</p>
  9. </div>
  10. <div class="welcome-illustration">📊</div>
  11. </div>
  12. <!-- 统计卡片 -->
  13. <el-row :gutter="20" class="stats-row">
  14. <el-col :xs="12" :sm="12" :md="6">
  15. <el-card class="stat-card" shadow="hover">
  16. <div class="stat-icon" style="background: linear-gradient(135deg, #FF8C42, #FFA66B);">
  17. <i class="el-icon-s-home"></i>
  18. </div>
  19. <div class="stat-info">
  20. <div class="stat-value">{{ stats.totalFamilies || 0 }}</div>
  21. <div class="stat-label">家庭总数</div>
  22. </div>
  23. </el-card>
  24. </el-col>
  25. <el-col :xs="12" :sm="12" :md="6">
  26. <el-card class="stat-card" shadow="hover">
  27. <div class="stat-icon" style="background: linear-gradient(135deg, #6366F1, #818CF8);">
  28. <i class="el-icon-user"></i>
  29. </div>
  30. <div class="stat-info">
  31. <div class="stat-value">{{ stats.totalParents || 0 }}</div>
  32. <div class="stat-label">家长总数</div>
  33. </div>
  34. </el-card>
  35. </el-col>
  36. <el-col :xs="12" :sm="12" :md="6">
  37. <el-card class="stat-card" shadow="hover">
  38. <div class="stat-icon" style="background: linear-gradient(135deg, #F59E0B, #FBBF24);">
  39. <i class="el-icon-s-custom"></i>
  40. </div>
  41. <div class="stat-info">
  42. <div class="stat-value">{{ stats.totalChildren || 0 }}</div>
  43. <div class="stat-label">孩子总数</div>
  44. </div>
  45. </el-card>
  46. </el-col>
  47. <el-col :xs="12" :sm="12" :md="6">
  48. <el-card class="stat-card" shadow="hover">
  49. <div class="stat-icon" style="background: linear-gradient(135deg, #10B981, #34D399);">
  50. <i class="el-icon-s-cooperation"></i>
  51. </div>
  52. <div class="stat-info">
  53. <div class="stat-value">{{ stats.totalTeachers || 0 }}</div>
  54. <div class="stat-label">规划师总数</div>
  55. </div>
  56. </el-card>
  57. </el-col>
  58. </el-row>
  59. <!-- 第二行统计卡片 -->
  60. <el-row :gutter="20" class="stats-row">
  61. <el-col :xs="12" :sm="12" :md="6">
  62. <el-card class="stat-card todo-stat-card" shadow="hover" @click.native="stats.pendingGuideCount > 0 && $router.push('/review-center?tab=guide')">
  63. <div class="stat-icon" :class="stats.pendingGuideCount > 0 ? 'todo-heart' : 'todo-disabled'">
  64. <i class="el-icon-s-check"></i>
  65. </div>
  66. <div class="stat-info">
  67. <div class="stat-value">{{ stats.pendingGuideCount }}</div>
  68. <div class="stat-label">待审核规划师</div>
  69. <div class="stat-trend" :class="stats.pendingGuideCount > 0 ? '' : 'disabled'">
  70. {{ stats.pendingGuideCount > 0 ? '点击前往审核' : '暂无待审核' }}
  71. </div>
  72. </div>
  73. </el-card>
  74. </el-col>
  75. <el-col :xs="12" :sm="12" :md="6">
  76. <el-card class="stat-card todo-stat-card" shadow="hover" @click.native="stats.pendingPackageCount > 0 && $router.push('/review-center?tab=package')">
  77. <div class="stat-icon" :class="stats.pendingPackageCount > 0 ? 'todo-danger' : 'todo-disabled'">
  78. <i class="el-icon-s-goods"></i>
  79. </div>
  80. <div class="stat-info">
  81. <div class="stat-value">{{ stats.pendingPackageCount }}</div>
  82. <div class="stat-label">待审核任务模板</div>
  83. <div class="stat-trend" :class="stats.pendingPackageCount > 0 ? '' : 'disabled'">
  84. {{ stats.pendingPackageCount > 0 ? '点击前往审核' : '暂无待审核' }}
  85. </div>
  86. </div>
  87. </el-card>
  88. </el-col>
  89. <el-col :xs="12" :sm="12" :md="6">
  90. <el-card class="stat-card" shadow="hover">
  91. <div class="stat-icon" style="background: linear-gradient(135deg, #0EA5E9, #38BDF8);">
  92. <i class="el-icon-user-solid"></i>
  93. </div>
  94. <div class="stat-info">
  95. <div class="stat-value">{{ stats.activeUsers || 0 }}</div>
  96. <div class="stat-label">活跃用户</div>
  97. </div>
  98. </el-card>
  99. </el-col>
  100. <el-col :xs="12" :sm="12" :md="6">
  101. <el-card class="stat-card" shadow="hover">
  102. <div class="stat-icon" style="background: linear-gradient(135deg, #8B5CF6, #A78BFA);">
  103. <i class="el-icon-s-home"></i>
  104. </div>
  105. <div class="stat-info">
  106. <div class="stat-value">{{ stats.monthFamilies || 0 }}</div>
  107. <div class="stat-label">本月新增家庭</div>
  108. </div>
  109. </el-card>
  110. </el-col>
  111. </el-row>
  112. <!-- 图表区域 -->
  113. <el-row :gutter="20" class="chart-row">
  114. <el-col :span="16">
  115. <el-card class="chart-card" v-loading="trendLoading">
  116. <div slot="header" class="card-header">
  117. <span class="card-title">📈 用户与家庭增长趋势(近30天)</span>
  118. </div>
  119. <div ref="trendChart" class="echarts-container"></div>
  120. </el-card>
  121. </el-col>
  122. <el-col :span="8">
  123. <el-card class="chart-card" v-loading="memberLoading">
  124. <div slot="header" class="card-header">
  125. <span class="card-title">🍩 会员等级分布</span>
  126. </div>
  127. <div ref="memberPieChart" class="echarts-container"></div>
  128. </el-card>
  129. </el-col>
  130. </el-row>
  131. <!-- 内容区域 -->
  132. <el-row :gutter="20" class="content-row">
  133. <el-col :span="14">
  134. <el-card class="content-card" shadow="hover">
  135. <div slot="header" class="card-header">
  136. <span class="card-title">📋 最近任务</span>
  137. <el-button type="text" size="small" @click="$router.push('/tasks')">
  138. 查看全部 →
  139. </el-button>
  140. </div>
  141. <el-table :data="recentTasks" size="small" class="custom-table">
  142. <el-table-column prop="title" label="任务名称" min-width="180"></el-table-column>
  143. <el-table-column prop="childName" label="孩子" width="100"></el-table-column>
  144. <el-table-column prop="status" label="状态" width="100">
  145. <template slot-scope="scope">
  146. <el-tag
  147. :type="scope.row.status === 'completed' ? 'success' : 'warning'"
  148. size="small"
  149. effect="plain"
  150. >
  151. {{ scope.row.status === 'completed' ? '已完成' : '进行中' }}
  152. </el-tag>
  153. </template>
  154. </el-table-column>
  155. <el-table-column prop="points" label="积分" width="80">
  156. <template slot-scope="scope">
  157. <span class="points-text">+{{ scope.row.points }}</span>
  158. </template>
  159. </el-table-column>
  160. </el-table>
  161. </el-card>
  162. </el-col>
  163. <el-col :span="10">
  164. <el-card class="content-card system-health-card" shadow="hover">
  165. <div slot="header" class="card-header">
  166. <span class="card-title">⚙️ 系统状态</span>
  167. <el-tag size="mini" type="success">正常运行</el-tag>
  168. </div>
  169. <div class="health-grid">
  170. <div class="health-item">
  171. <div class="health-icon health-icon--status">
  172. <i class="el-icon-success"></i>
  173. </div>
  174. <div class="health-info">
  175. <div class="health-label">系统状态</div>
  176. <div class="health-value health-value--online">● 在线</div>
  177. </div>
  178. </div>
  179. <div class="health-item">
  180. <div class="health-icon health-icon--version">
  181. <i class="el-icon-info"></i>
  182. </div>
  183. <div class="health-info">
  184. <div class="health-label">系统版本</div>
  185. <div class="health-value">
  186. {{ version }}
  187. <button type="button" style="font-size:12px;border:none;background:none;color:#409EFF;cursor:pointer;padding:0;margin-left:6px" @click="showChangelog()">查看变更日志</button>
  188. </div>
  189. </div>
  190. </div>
  191. <div class="health-item">
  192. <div class="health-icon health-icon--time">
  193. <i class="el-icon-time"></i>
  194. </div>
  195. <div class="health-info">
  196. <div class="health-label">最后刷新</div>
  197. <div class="health-value">{{ todayDate }}</div>
  198. </div>
  199. </div>
  200. <div class="health-item">
  201. <div class="health-icon health-icon--api">
  202. <i class="el-icon-link"></i>
  203. </div>
  204. <div class="health-info">
  205. <div class="health-label">API 接口</div>
  206. <div class="health-value">~45 个</div>
  207. </div>
  208. </div>
  209. <div class="health-item">
  210. <div class="health-icon health-icon--uptime">
  211. <i class="el-icon-time"></i>
  212. </div>
  213. <div class="health-info">
  214. <div class="health-label">服务器运行时长</div>
  215. <div class="health-value">{{ serverHealth.uptime }}</div>
  216. </div>
  217. </div>
  218. <div class="health-item">
  219. <div class="health-icon health-icon--cpu">
  220. <i class="el-icon-cpu"></i>
  221. </div>
  222. <div class="health-info">
  223. <div class="health-label">CPU 使用率</div>
  224. <div class="health-value">{{ serverHealth.cpuUsagePercent }}% ({{ serverHealth.cpuCores }}核)</div>
  225. </div>
  226. </div>
  227. <div class="health-item">
  228. <div class="health-icon health-icon--memory">
  229. <i class="el-icon-coffee"></i>
  230. </div>
  231. <div class="health-info">
  232. <div class="health-label">JVM 内存</div>
  233. <div class="health-value">{{ serverHealth.memUsed }} / {{ serverHealth.memMax }} ({{ serverHealth.memUsagePercent }}%)</div>
  234. </div>
  235. </div>
  236. </div>
  237. <div class="health-links">
  238. <el-button size="mini" icon="el-icon-s-order" @click="$router.push('/tasks')">任务管理</el-button>
  239. <el-button size="mini" icon="el-icon-s-custom" @click="$router.push('/families')">家庭管理</el-button>
  240. <el-button size="mini" icon="el-icon-user" @click="$router.push('/users')">用户管理</el-button>
  241. </div>
  242. </el-card>
  243. </el-col>
  244. </el-row>
  245. <!-- 快捷操作 -->
  246. <el-row :gutter="20">
  247. <el-col :span="24">
  248. <div class="quick-actions-section">
  249. <div class="section-header">
  250. <span class="section-title">快捷操作</span>
  251. </div>
  252. <div class="quick-actions-grid">
  253. <div class="action-card" @click="$router.push('/tasks')">
  254. <div class="action-icon action-icon--primary">
  255. <i class="el-icon-s-order"></i>
  256. </div>
  257. <div class="action-label">任务管理</div>
  258. </div>
  259. <div class="action-card" @click="$router.push('/families')">
  260. <div class="action-icon action-icon--family">
  261. <i class="el-icon-s-custom"></i>
  262. </div>
  263. <div class="action-label">家庭管理</div>
  264. </div>
  265. <div class="action-card" @click="$router.push('/guide-pending')">
  266. <div class="action-icon action-icon--guide">
  267. <i class="el-icon-user"></i>
  268. </div>
  269. <div class="action-label">规划师审核</div>
  270. </div>
  271. <div class="action-card" @click="$router.push('/package-pending')">
  272. <div class="action-icon action-icon--package">
  273. <i class="el-icon-goods"></i>
  274. </div>
  275. <div class="action-label">任务模板审核</div>
  276. </div>
  277. <div class="action-card" @click="$router.push('/rewards')">
  278. <div class="action-icon action-icon--reward">
  279. <i class="el-icon-medal"></i>
  280. </div>
  281. <div class="action-label">奖励管理</div>
  282. </div>
  283. <div class="action-card" @click="$router.push('/users')">
  284. <div class="action-icon action-icon--user">
  285. <i class="el-icon-user-solid"></i>
  286. </div>
  287. <div class="action-label">用户管理</div>
  288. </div>
  289. <div class="action-card" @click="$router.push('/audit')">
  290. <div class="action-icon action-icon--audit">
  291. <i class="el-icon-document-checked"></i>
  292. </div>
  293. <div class="action-label">审核中心</div>
  294. </div>
  295. <div class="action-card" @click="$router.push('/settings')">
  296. <div class="action-icon action-icon--settings">
  297. <i class="el-icon-setting"></i>
  298. </div>
  299. <div class="action-label">系统设置</div>
  300. </div>
  301. </div>
  302. </div>
  303. </el-col>
  304. </el-row>
  305. <!-- 变更日志弹窗 -->
  306. <el-dialog
  307. title="变更日志"
  308. :visible.sync="changelogVisible"
  309. width="900px"
  310. custom-class="changelog-dialog"
  311. append-to-body
  312. >
  313. <div v-loading="changelogLoading" class="changelog-body" v-html="changelogContent"></div>
  314. </el-dialog>
  315. </div>
  316. </div>
  317. </template>
  318. <script>
  319. import * as echarts from 'echarts'
  320. import { getDashboardStats, getMembershipStats, getTrendStats, getDashboardOverview, getSystemHealth } from '@/api/admin'
  321. export default {
  322. name: 'Dashboard',
  323. data() {
  324. return {
  325. loadingTasks: false,
  326. stats: {
  327. totalFamilies: 0,
  328. totalParents: 0,
  329. totalChildren: 0,
  330. totalTeachers: 0,
  331. pendingGuideCount: 0,
  332. pendingPackageCount: 0,
  333. activeUsers: 0,
  334. monthFamilies: 0
  335. },
  336. recentTasks: [],
  337. trendLoading: false,
  338. memberLoading: false,
  339. membershipData: {},
  340. trendData: { familyTrend: {}, userTrend: {} },
  341. trendChart: null,
  342. memberChart: null,
  343. resizeHandler: null,
  344. changelogVisible: false,
  345. changelogContent: '',
  346. changelogLoading: false,
  347. serverHealth: {
  348. uptime: '加载中...',
  349. memUsed: '--',
  350. memMax: '--',
  351. memUsagePercent: '--',
  352. cpuCores: '--',
  353. cpuLoad: '--',
  354. cpuUsagePercent: '--'
  355. }
  356. }
  357. },
  358. computed: {
  359. version() {
  360. return process.env.VUE_APP_VERSION || '1.0.0'
  361. },
  362. todayDate() {
  363. const now = new Date()
  364. const months = ['一', '二', '三', '四', '五', '六', '七', '八', '九', '十', '十一', '十二']
  365. return `${months[now.getMonth()]}月${now.getDate()}日 星期${['日', '一', '二', '三', '四', '五', '六'][now.getDay()]}`
  366. }
  367. },
  368. mounted() {
  369. this.loadDashboardData()
  370. this.loadTrend()
  371. this.loadMembership()
  372. this.loadServerHealth()
  373. this.resizeHandler = () => {
  374. this.trendChart && this.trendChart.resize()
  375. this.memberChart && this.memberChart.resize()
  376. }
  377. window.addEventListener('resize', this.resizeHandler)
  378. },
  379. beforeDestroy() {
  380. this.trendChart && this.trendChart.dispose()
  381. this.memberChart && this.memberChart.dispose()
  382. this.resizeHandler && window.removeEventListener('resize', this.resizeHandler)
  383. },
  384. methods: {
  385. async loadDashboardData() {
  386. try {
  387. const res = await getDashboardStats()
  388. const d = res.data || {}
  389. this.stats.totalFamilies = d.totalFamilies || 0
  390. this.stats.totalParents = d.totalParents || 0
  391. this.stats.totalChildren = d.totalChildren || 0
  392. this.stats.totalTeachers = d.totalTeachers || 0
  393. this.stats.pendingGuideCount = d.pendingGuideCount || 0
  394. this.stats.pendingPackageCount = d.pendingPackageCount || 0
  395. this.recentTasks = (d.recentTasks || []).map(t => ({
  396. title: t.title,
  397. childName: t.childName || '',
  398. status: t.status,
  399. points: t.points || 0
  400. }))
  401. const overviewRes = await getDashboardOverview()
  402. const overview = overviewRes.data || {}
  403. this.stats.activeUsers = overview.activeUsers || 0
  404. this.stats.monthFamilies = overview.monthFamilies || 0
  405. } catch (error) {
  406. console.error('加载仪表盘数据失败:', error)
  407. }
  408. },
  409. async loadServerHealth() {
  410. try {
  411. const res = await getSystemHealth()
  412. if (res.code === 200 && res.data) {
  413. const d = res.data
  414. this.serverHealth = {
  415. uptime: d.uptime || '--',
  416. memUsed: d.memUsed || '--',
  417. memMax: d.memMax || '--',
  418. memUsagePercent: d.memUsagePercent || '--',
  419. cpuCores: d.cpuCores || '--',
  420. cpuLoad: d.cpuLoad || '--',
  421. cpuUsagePercent: d.cpuUsagePercent || '--'
  422. }
  423. }
  424. } catch (error) {
  425. console.error('加载服务器状态失败:', error)
  426. }
  427. },
  428. showChangelog() {
  429. this.changelogVisible = true
  430. if (this.changelogContent) return
  431. this.changelogLoading = true
  432. fetch(process.env.BASE_URL + 'CHANGELOG.md?t=' + Date.now()).then(function(res) {
  433. if (!res.ok) throw new Error('Not found')
  434. return res.text()
  435. }).then((function(text) {
  436. var html = ''
  437. var lines = text.split('\n')
  438. var inCodeBlock = false
  439. var listBuffer = ''
  440. var inList = false
  441. function flushList() {
  442. if (inList) {
  443. html += '<ul>' + listBuffer + '</ul>'
  444. listBuffer = ''
  445. inList = false
  446. }
  447. }
  448. for (var i = 0; i < lines.length; i++) {
  449. var line = lines[i]
  450. if (line.match(/^```/)) {
  451. flushList()
  452. if (inCodeBlock) {
  453. html += '</code></pre>'
  454. inCodeBlock = false
  455. } else {
  456. html += '<pre><code>'
  457. inCodeBlock = true
  458. }
  459. continue
  460. }
  461. if (inCodeBlock) {
  462. html += this._escapeHtml(line) + '\n'
  463. continue
  464. }
  465. if (line.match(/^### /)) {
  466. flushList()
  467. html += '<h3>' + this._parseInline(line.replace(/^### /, '')) + '</h3>'
  468. continue
  469. }
  470. if (line.match(/^## /)) {
  471. flushList()
  472. html += '<h2>' + this._parseInline(line.replace(/^## /, '')) + '</h2>'
  473. continue
  474. }
  475. if (line.match(/^# /)) {
  476. flushList()
  477. html += '<h1>' + this._parseInline(line.replace(/^# /, '')) + '</h1>'
  478. continue
  479. }
  480. if (line.match(/^\- /)) {
  481. inList = true
  482. listBuffer += '<li>' + this._parseInline(line.replace(/^\- /, '')) + '</li>\n'
  483. continue
  484. }
  485. if (line.trim() === '') {
  486. flushList()
  487. continue
  488. }
  489. flushList()
  490. html += '<p class="cl-item">' + this._parseInline(line) + '</p>\n'
  491. }
  492. flushList()
  493. this.changelogContent = html || '<p class="cl-empty">暂无变更日志</p>'
  494. this.changelogLoading = false
  495. }).bind(this)).catch((function() {
  496. this.changelogContent = '<p class="cl-empty">暂无变更日志</p>'
  497. this.changelogLoading = false
  498. }).bind(this))
  499. },
  500. _parseInline(text) {
  501. text = text.replace(/\*\*(.+?)\*\*/g, '<strong>$1</strong>')
  502. text = text.replace(/\*(.+?)\*/g, '<em>$1</em>')
  503. text = text.replace(/\[(.+?)\]\((.+?)\)/g, '<a href="$2" target="_blank">$1</a>')
  504. text = text.replace(/`(.+?)`/g, '<code style="background:#F1F5F9;padding:2px 4px;border-radius:3px;font-size:13px">$1</code>')
  505. text = text.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;')
  506. return text
  507. },
  508. _escapeHtml(text) {
  509. return text.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;')
  510. },
  511. async loadTrend() {
  512. this.trendLoading = true
  513. try {
  514. const res = await getTrendStats()
  515. if (res.code === 200 && res.data) {
  516. this.trendData = res.data
  517. this.$nextTick(() => this.initTrendChart())
  518. }
  519. } catch (e) {
  520. console.error('加载趋势数据失败:', e)
  521. } finally {
  522. this.trendLoading = false
  523. }
  524. },
  525. async loadMembership() {
  526. this.memberLoading = true
  527. try {
  528. const res = await getMembershipStats()
  529. if (res.code === 200 && res.data) {
  530. this.membershipData = res.data
  531. this.$nextTick(() => this.initMemberPieChart())
  532. }
  533. } catch (e) {
  534. console.error('加载会员数据失败:', e)
  535. } finally {
  536. this.memberLoading = false
  537. }
  538. },
  539. initTrendChart() {
  540. if (this.trendChart) this.trendChart.dispose()
  541. this.trendChart = echarts.init(this.$refs.trendChart)
  542. const familyData = Object.values(this.trendData.familyTrend || {})
  543. const userData = Object.values(this.trendData.userTrend || {})
  544. const xAxis = Object.keys(this.trendData.familyTrend || {})
  545. this.trendChart.setOption({
  546. tooltip: { trigger: 'axis' },
  547. legend: { data: ['新增家庭', '新增用户'] },
  548. grid: { left: 50, right: 20, bottom: 30, top: 40 },
  549. xAxis: { type: 'category', data: xAxis, axisLabel: { rotate: xAxis.length > 15 ? 45 : 0 } },
  550. yAxis: { type: 'value', minInterval: 1 },
  551. series: [
  552. { name: '新增家庭', type: 'bar', barWidth: '40%', data: familyData, itemStyle: { color: '#F97316', borderRadius: [4, 4, 0, 0] } },
  553. { name: '新增用户', type: 'line', smooth: true, data: userData, lineStyle: { color: '#0EA5E9', width: 2 }, itemStyle: { color: '#0EA5E9' } }
  554. ]
  555. })
  556. },
  557. initMemberPieChart() {
  558. if (this.memberChart) this.memberChart.dispose()
  559. this.memberChart = echarts.init(this.$refs.memberPieChart)
  560. this.memberChart.setOption({
  561. tooltip: { trigger: 'item', formatter: '{b}: {c} ({d}%)' },
  562. legend: { orient: 'vertical', left: 'left', top: 'center' },
  563. series: [{
  564. type: 'pie',
  565. radius: ['40%', '65%'],
  566. center: ['55%', '50%'],
  567. avoidLabelOverlap: true,
  568. label: { show: false },
  569. emphasis: { label: { show: true, fontSize: 14, fontWeight: 'bold' } },
  570. data: [
  571. { value: this.membershipData.freeCount || 0, name: '免费用户', itemStyle: { color: '#94A3B8' } },
  572. { value: this.membershipData.familyCount || 0, name: '家庭会员', itemStyle: { color: '#F97316' } },
  573. { value: this.membershipData.providerCount || 0, name: '服务商', itemStyle: { color: '#10B981' } }
  574. ]
  575. }]
  576. })
  577. }
  578. }
  579. }
  580. </script>
  581. <style scoped>
  582. .dashboard {
  583. padding: 0;
  584. }
  585. /* 欢迎横幅 */
  586. .welcome-banner {
  587. background: linear-gradient(135deg, #6366F1, #8B5CF6);
  588. border-radius: 16px;
  589. padding: 32px;
  590. display: flex;
  591. justify-content: space-between;
  592. align-items: center;
  593. margin-bottom: 24px;
  594. color: #FFFFFF;
  595. }
  596. .welcome-title {
  597. font-size: 28px;
  598. font-weight: 700;
  599. margin: 0 0 8px 0;
  600. }
  601. .welcome-desc {
  602. font-size: 16px;
  603. opacity: 0.9;
  604. margin: 0;
  605. }
  606. .welcome-illustration {
  607. font-size: 64px;
  608. }
  609. /* 统计卡片 */
  610. .stats-row {
  611. margin-bottom: 24px;
  612. }
  613. .stat-card {
  614. border-radius: 12px;
  615. border: none;
  616. }
  617. .stat-card ::v-deep .el-card__body {
  618. display: flex;
  619. align-items: center;
  620. padding: 24px;
  621. }
  622. .todo-stat-card {
  623. cursor: pointer;
  624. transition: transform 0.2s, box-shadow 0.2s;
  625. }
  626. .todo-stat-card:hover {
  627. transform: translateY(-2px);
  628. box-shadow: 0 4px 12px rgba(0,0,0,0.1);
  629. }
  630. .stat-icon {
  631. width: 56px;
  632. height: 56px;
  633. border-radius: 12px;
  634. display: flex;
  635. align-items: center;
  636. justify-content: center;
  637. font-size: 24px;
  638. color: #fff;
  639. margin-right: 16px;
  640. flex-shrink: 0;
  641. }
  642. .stat-icon.blue { background: linear-gradient(135deg, #6366F1, #818CF8); }
  643. .stat-icon.green { background: linear-gradient(135deg, #10B981, #34D399); }
  644. .stat-icon.orange { background: linear-gradient(135deg, #F59E0B, #FBBF24); }
  645. .stat-icon.purple { background: linear-gradient(135deg, #8B5CF6, #A78BFA); }
  646. .stat-icon.todo-warning { background: linear-gradient(135deg, #F59E0B, #FBBF24); }
  647. .stat-icon.todo-heart { background: linear-gradient(135deg, #FF6B9D, #FF8FB3); }
  648. .stat-icon.todo-danger { background: linear-gradient(135deg, #EF4444, #F87171); }
  649. .stat-icon.todo-disabled { background: linear-gradient(135deg, #CBD5E1, #94A3B8); }
  650. .stat-value {
  651. font-size: 28px;
  652. font-weight: 700;
  653. color: #1E293B;
  654. line-height: 1.2;
  655. }
  656. .stat-label {
  657. color: #64748B;
  658. font-size: 14px;
  659. margin-top: 4px;
  660. }
  661. .stat-trend {
  662. font-size: 12px;
  663. color: #6366F1;
  664. margin-top: 8px;
  665. }
  666. .stat-trend.disabled {
  667. color: #94A3B8;
  668. }
  669. /* 内容卡片 */
  670. .content-row {
  671. margin-bottom: 24px;
  672. }
  673. .content-card {
  674. border-radius: 12px;
  675. border: none;
  676. margin-bottom: 20px;
  677. }
  678. .card-header {
  679. display: flex;
  680. justify-content: space-between;
  681. align-items: center;
  682. }
  683. .card-title {
  684. font-size: 16px;
  685. font-weight: 600;
  686. color: #1E293B;
  687. }
  688. /* 表格样式 */
  689. .custom-table ::v-deep .el-table__header th {
  690. background: #F8FAFC;
  691. color: #64748B;
  692. font-weight: 600;
  693. }
  694. .points-text {
  695. color: #F59E0B;
  696. font-weight: 600;
  697. }
  698. /* 系统健康面板 */
  699. .system-health-card {
  700. border-radius: 12px;
  701. border: none;
  702. }
  703. .health-grid {
  704. display: flex;
  705. gap: 16px;
  706. flex-wrap: wrap;
  707. }
  708. .health-item {
  709. display: flex;
  710. align-items: center;
  711. gap: 12px;
  712. flex: 1;
  713. min-width: 140px;
  714. }
  715. .health-icon {
  716. width: 40px;
  717. height: 40px;
  718. border-radius: 10px;
  719. display: flex;
  720. align-items: center;
  721. justify-content: center;
  722. font-size: 18px;
  723. color: white;
  724. }
  725. .health-icon--status {
  726. background: linear-gradient(135deg, #10B981, #059669);
  727. }
  728. .health-icon--version {
  729. background: linear-gradient(135deg, #6366F1, #4F46E5);
  730. }
  731. .health-icon--time {
  732. background: linear-gradient(135deg, #F59E0B, #D97706);
  733. }
  734. .health-icon--api {
  735. background: linear-gradient(135deg, #0EA5E9, #0284C7);
  736. }
  737. .health-icon--uptime {
  738. background: linear-gradient(135deg, #8B5CF6, #7C3AED);
  739. }
  740. .health-icon--cpu {
  741. background: linear-gradient(135deg, #EF4444, #F87171);
  742. }
  743. .health-icon--memory {
  744. background: linear-gradient(135deg, #10B981, #059669);
  745. }
  746. .health-info {
  747. flex: 1;
  748. }
  749. .health-label {
  750. font-size: 12px;
  751. color: #9ca3af;
  752. margin-bottom: 2px;
  753. }
  754. .health-value {
  755. font-size: 14px;
  756. font-weight: 600;
  757. color: #1f2937;
  758. }
  759. .health-value--online {
  760. color: #10B981;
  761. }
  762. .health-links {
  763. margin-top: 16px;
  764. padding-top: 16px;
  765. border-top: 1px solid #f3f4f6;
  766. display: flex;
  767. gap: 8px;
  768. }
  769. /* 快捷操作 */
  770. .quick-card .el-card__body {
  771. padding: 12px;
  772. }
  773. .quick-actions {
  774. display: flex;
  775. justify-content: space-around;
  776. }
  777. .quick-item {
  778. display: flex;
  779. flex-direction: column;
  780. align-items: center;
  781. cursor: pointer;
  782. padding: 12px;
  783. border-radius: 8px;
  784. transition: background 0.2s;
  785. }
  786. .quick-item:hover {
  787. background: #F8FAFC;
  788. }
  789. .quick-item i {
  790. font-size: 24px;
  791. color: #6366F1;
  792. margin-bottom: 8px;
  793. }
  794. .quick-item span {
  795. font-size: 12px;
  796. color: #64748B;
  797. }
  798. /* 快捷操作 4x2 网格 */
  799. .quick-actions-section {
  800. margin-bottom: 24px;
  801. }
  802. .section-header {
  803. margin-bottom: 12px;
  804. }
  805. .section-title {
  806. font-size: 16px;
  807. font-weight: 600;
  808. color: #1f2937;
  809. }
  810. .quick-actions-grid {
  811. display: grid;
  812. grid-template-columns: repeat(4, 1fr);
  813. gap: 12px;
  814. }
  815. .action-card {
  816. background: white;
  817. border-radius: 12px;
  818. padding: 20px 16px;
  819. text-align: center;
  820. cursor: pointer;
  821. transition: all 0.2s ease;
  822. border: 1px solid #f3f4f6;
  823. }
  824. .action-card:hover {
  825. transform: translateY(-2px);
  826. box-shadow: 0 4px 12px rgba(0,0,0,0.08);
  827. border-color: #e5e7eb;
  828. }
  829. .action-icon {
  830. width: 48px;
  831. height: 48px;
  832. border-radius: 12px;
  833. display: flex;
  834. align-items: center;
  835. justify-content: center;
  836. margin: 0 auto 8px;
  837. font-size: 22px;
  838. color: white;
  839. }
  840. .action-icon--primary {
  841. background: linear-gradient(135deg, #FF8C42, #FF6B35);
  842. }
  843. .action-icon--family {
  844. background: linear-gradient(135deg, #6366F1, #4F46E5);
  845. }
  846. .action-icon--guide {
  847. background: linear-gradient(135deg, #F59E0B, #D97706);
  848. }
  849. .action-icon--package {
  850. background: linear-gradient(135deg, #10B981, #059669);
  851. }
  852. .action-icon--reward {
  853. background: linear-gradient(135deg, #FF6B9D, #E11D48);
  854. }
  855. .action-icon--user {
  856. background: linear-gradient(135deg, #0EA5E9, #0284C7);
  857. }
  858. .action-icon--audit {
  859. background: linear-gradient(135deg, #8B5CF6, #7C3AED);
  860. }
  861. .action-icon--settings {
  862. background: linear-gradient(135deg, #6B7280, #4B5563);
  863. }
  864. .action-label {
  865. font-size: 13px;
  866. color: #374151;
  867. font-weight: 500;
  868. }
  869. /* 图表区域 */
  870. .chart-row {
  871. margin-bottom: 24px;
  872. }
  873. .chart-card {
  874. border-radius: 12px;
  875. border: none;
  876. min-height: 320px;
  877. }
  878. .echarts-container {
  879. height: 260px;
  880. width: 100%;
  881. }
  882. </style>
  883. <style>
  884. .changelog-dialog .el-dialog__body {
  885. max-height: 700px;
  886. overflow-y: auto;
  887. }
  888. .changelog-body {
  889. padding: 8px 4px;
  890. line-height: 1.8;
  891. font-size: 14px;
  892. color: #374151;
  893. }
  894. .changelog-body h1 {
  895. font-size: 20px;
  896. font-weight: 700;
  897. margin: 16px 0 8px;
  898. color: #1E293B;
  899. }
  900. .changelog-body h2 {
  901. font-size: 17px;
  902. font-weight: 600;
  903. margin: 14px 0 6px;
  904. color: #1E293B;
  905. border-left: 3px solid #6366F1;
  906. padding-left: 8px;
  907. }
  908. .changelog-body h3 {
  909. font-size: 15px;
  910. font-weight: 600;
  911. margin: 10px 0 4px;
  912. color: #374151;
  913. }
  914. .changelog-body ul {
  915. margin: 4px 0 8px;
  916. padding-left: 20px;
  917. }
  918. .changelog-body li {
  919. margin: 2px 0;
  920. }
  921. .changelog-body .cl-item {
  922. margin: 4px 0;
  923. }
  924. .changelog-body .cl-empty {
  925. text-align: center;
  926. color: #94A3B8;
  927. padding: 32px 0;
  928. }
  929. .changelog-body code {
  930. background: #F1F5F9;
  931. padding: 2px 6px;
  932. border-radius: 3px;
  933. font-size: 13px;
  934. }
  935. .changelog-body pre {
  936. background: #F8FAFC;
  937. border: 1px solid #E2E8F0;
  938. border-radius: 8px;
  939. padding: 12px;
  940. overflow-x: auto;
  941. }
  942. .changelog-body pre code {
  943. background: none;
  944. padding: 0;
  945. }
  946. .changelog-body a {
  947. color: #6366F1;
  948. text-decoration: none;
  949. }
  950. .changelog-body a:hover {
  951. text-decoration: underline;
  952. }
  953. </style>