Dashboard.vue 28 KB

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