index.vue 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718
  1. <template>
  2. <div class="container">
  3. <Breadcrumb :items="['校园乐跑', '乐跑账号']" />
  4. <userCard />
  5. <a-card title="账号列表" style="margin-top: 15px;">
  6. <div class="buttonGroup">
  7. <a-button type="primary" size="large" @click="editAccount()">
  8. <template #icon>
  9. <icon-plus />
  10. </template>
  11. 添加账号
  12. </a-button>
  13. <a-button size="large" @click="download" style="margin-left: 10px;">
  14. <template #icon>
  15. <icon-question-circle />
  16. </template>
  17. 操作说明
  18. </a-button>
  19. <a-button size="large" @click="$router.push('/download/down')" style="margin-left: 10px;" v-if="!isElectron()">
  20. <template #icon>
  21. <icon-download />
  22. </template>
  23. 客户端/登录器下载
  24. </a-button>
  25. </div>
  26. <a-row class="queryForm">
  27. <a-col :flex="1">
  28. <a-form :model="queryDataForm" :label-col-props="{ span: 6 }" :wrapper-col-props="{ span: 18 }"
  29. label-align="left">
  30. <a-row :gutter="16">
  31. <a-col :span="8">
  32. <a-form-item field="area" label="跑区">
  33. <a-select v-model="queryDataForm.area" placeholder="请选择乐跑跑区" default-value="">
  34. <a-option value="">所有跑区</a-option>
  35. <a-option v-for="(item, index) in area" :key="index" :value="item">
  36. {{ item }}
  37. </a-option>
  38. </a-select>
  39. </a-form-item>
  40. </a-col>
  41. <a-col :span="8">
  42. <a-form-item field="email" label="邮箱">
  43. <a-input v-model="queryDataForm.email" allow-clear />
  44. </a-form-item>
  45. </a-col>
  46. <a-col :span="8">
  47. <a-form-item field="username" label="姓名">
  48. <a-input v-model="queryDataForm.username" allow-clear />
  49. </a-form-item>
  50. </a-col>
  51. <a-col :span="8">
  52. <a-form-item field="student_num" label="学号">
  53. <a-input v-model="queryDataForm.student_num" allow-clear />
  54. </a-form-item>
  55. </a-col>
  56. <a-col :span="8">
  57. <a-form-item field="area" label="状态">
  58. <a-select v-model="queryDataForm.state" :options="state" placeholder="请选择账号状态" :default-value="-1" />
  59. </a-form-item>
  60. </a-col>
  61. <a-col :span="8">
  62. <a-form-item field="auto_time" label="乐跑时段">
  63. <a-select v-model="queryDataForm.auto_time" placeholder="请选择自动乐跑时段" :default-value="-1">
  64. <a-option :value="0">所有时段</a-option>
  65. <a-option v-for="(item, index) in auto_time" :key="index" :value="item.value">
  66. {{ item.label }}
  67. </a-option>
  68. </a-select>
  69. </a-form-item>
  70. </a-col>
  71. </a-row>
  72. </a-form>
  73. </a-col>
  74. <a-divider style="height: 84px" direction="vertical" />
  75. <a-col :flex="'86px'" style="text-align: right">
  76. <a-space direction="vertical" :size="18">
  77. <a-button type="primary" @click="search">
  78. <template #icon>
  79. <icon-search />
  80. </template>
  81. 搜索
  82. </a-button>
  83. <a-button @click="reset">
  84. <template #icon>
  85. <icon-refresh />
  86. </template>
  87. 重置
  88. </a-button>
  89. </a-space>
  90. </a-col>
  91. </a-row>
  92. <a-alert v-if="notice" style="margin-bottom: 15px;">{{ notice }}</a-alert>
  93. <a-table :data="data" :bordered="false" hoverable class="table" :loading="loading" expandable :scroll="{
  94. x: 1600
  95. }" :pagination="{
  96. showPageSize: true,
  97. showJumper: true,
  98. showTotal: true,
  99. pageSize: pagination.pagesize,
  100. current: pagination.current,
  101. total: pagination.total
  102. }" @page-change="handlePageChange" @page-size-change="handlePageSizeChange">
  103. <template #name-filter="{ filterValue, setFilterValue, handleFilterConfirm, handleFilterReset }">
  104. <div class="custom-filter">
  105. <a-space direction="vertical">
  106. <a-input :model-value="filterValue[0]" @input="(value) => setFilterValue([value])" />
  107. <div class="custom-filter-footer">
  108. <a-button @click="handleFilterReset">重置</a-button>
  109. <a-button @click="handleFilterConfirm">确定</a-button>
  110. </div>
  111. </a-space>
  112. </div>
  113. </template>
  114. <template #columns>
  115. <a-table-column title="" :width="50" data-index="user_avatar" tooltip>
  116. <template #cell="{ record }">
  117. <a-avatar>
  118. <img :alt="record.name ?? ''"
  119. :src="record.user_avatar || 'https://lepao-cloud.xxoo365.top/view.php/25aa126dc406974ff3579a99a2c6501a.png'" />
  120. </a-avatar>
  121. </template>
  122. </a-table-column>
  123. <a-table-column title="学号" :width="115" data-index="student_num" ellipsis tooltip></a-table-column>
  124. <a-table-column title="姓名" :width="130">
  125. <template #cell="{ record }">
  126. {{ record.name ?? '请使用乐跑登录器更新账号信息' }}
  127. </template>
  128. </a-table-column>
  129. <a-table-column title="性别" :width="80" ellipsis tooltip :filterable="{
  130. filters: [
  131. { text: '男', value: 1 },
  132. { text: '女', value: 2 }
  133. ],
  134. filter: (value, record) => record.sex == value
  135. }">
  136. <template #cell="{ record }">
  137. <icon-man v-if="record.sex === 1" />
  138. <icon-woman v-else-if="record.sex === 2" />
  139. {{ record.sex === 1 ? '男' : (record.sex === 2 ? '女' : '') }}
  140. </template>
  141. </a-table-column>
  142. <a-table-column title="年级" :width="70" data-index="grade_id" tooltip></a-table-column>
  143. <a-table-column title="学院" :width="220" data-index="academy_name" tooltip></a-table-column>
  144. <a-table-column title="跑区" :width="130">
  145. <template #cell="{ record }">
  146. {{ record.area || '随机分配' }}
  147. </template>
  148. </a-table-column>
  149. <a-table-column title="通知邮箱" :width="180" data-index="email" ellipsis tooltip></a-table-column>
  150. <a-table-column title="帐号状态" :width="100" ellipsis tooltip>
  151. <template #cell="{ record }">
  152. <div v-if="record.state === 0" class="state">
  153. <div class="circle zero"></div>需登录
  154. </div>
  155. <div v-else-if="record.state === 1" class="state">
  156. <div class="circle one"></div>正常
  157. </div>
  158. <div v-else class="state">
  159. <div class="circle else"></div>状态异常
  160. </div>
  161. </template>
  162. </a-table-column>
  163. <!-- <a-table-column title="人脸状态" :width="100" ellipsis tooltip>
  164. <template #cell="{ record }">
  165. <div v-if="record.face_state === 0" class="state">
  166. <div class="circle zero"></div>未采集
  167. </div>
  168. <div v-else-if="record.face_state === 1" class="state">
  169. <div class="circle one"></div>已通过
  170. </div>
  171. <div v-else class="state">
  172. <div class="circle else"></div>不通过
  173. </div>
  174. </template>
  175. </a-table-column> -->
  176. <a-table-column title="自动乐跑" :width="105" ellipsis tooltip :filterable="{
  177. filters: [
  178. { text: '开启', value: 1 },
  179. { text: '关闭', value: 0 }
  180. ],
  181. filter: (value, record) => record.auto_run == value
  182. }">
  183. <template #cell="{ record }">
  184. <a-tag color="green" v-if="record.auto_run">{{ record.target_count === 0 ? '开启-∞次' :
  185. `开启-${record.target_count}次` }}</a-tag>
  186. <a-tag color="red" v-else>关闭</a-tag>
  187. </template>
  188. </a-table-column>
  189. <a-table-column title="自动乐跑时段" :width="130" ellipsis tooltip>
  190. <template #cell="{ record }">
  191. {{ autoTimeLabel(record) }}
  192. </template>
  193. </a-table-column>
  194. <a-table-column title="学期目标" :width="88" ellipsis tooltip>
  195. <template #cell="{ record }">
  196. {{ record.term_num != record.total_num ? `${record.total_num} / ${record.term_num}` :
  197. '已完成' }}
  198. </template>
  199. </a-table-column>
  200. <a-table-column title="添加时间" :width="145" ellipsis tooltip :sortable="{
  201. sortDirections: ['ascend', 'descend']
  202. }">
  203. <template #cell="{ record }">
  204. {{ stramptoTime(record.create_time) }}
  205. </template>
  206. </a-table-column>
  207. <a-table-column title="上次登录时间" :width="145" ellipsis tooltip>
  208. <template #cell="{ record }">
  209. {{ record.update_time ? stramptoTime(record.update_time) : '待登录' }}
  210. </template>
  211. </a-table-column>
  212. <a-table-column title="备注" :width="200" ellipsis tooltip>
  213. <template #cell="{ record }">
  214. {{ record.notes }}
  215. </template>
  216. </a-table-column>
  217. <a-table-column title="" fixed="right" :width="100">
  218. <template #cell="{ record }">
  219. <a-dropdown :popup-max-height="false" trigger="hover">
  220. <a-button>操作 <icon-down /></a-button>
  221. <template #content>
  222. <a-doption @click="editAccount(record)"><icon-edit /> 编辑账号</a-doption>
  223. <!-- <a-doption @click="faceRecoRef.openModal(record)"><icon-video-camera /> 人脸采集</a-doption> -->
  224. <a-doption @click="SingleRun(record)"><icon-play-circle /> 开始单次乐跑</a-doption>
  225. <a-doption @click="ChangeAutoRun(record)"><icon-translate /> {{ record.auto_run ? '关闭' :
  226. '开启' }}自动乐跑</a-doption>
  227. <a-doption @click="DeleteAccount(record)"><icon-minus-circle /> 解绑账号</a-doption>
  228. </template>
  229. </a-dropdown>
  230. </template>
  231. </a-table-column>
  232. </template>
  233. </a-table>
  234. </a-card>
  235. </div>
  236. <!-- 账号编辑对话框 -->
  237. <a-modal v-model:visible="visible" title="编辑账号" @cancel="handleCancel" @before-ok="handleBeforeOk" draggable
  238. :ok-loading="ok_loading" esc-to-close closable>
  239. <a-form :model="form">
  240. <a-form-item field="student_num" label="学号">
  241. <a-input v-model="form.student_num" placeholder="账号所有者学号,填写错误将无法登录" allow-clear />
  242. </a-form-item>
  243. <a-form-item field="email" label="通知邮箱">
  244. <a-auto-complete :data="email" @search="handleSearch" v-model="form.email" placeholder="用于接收乐跑失败、登录失效的通知"
  245. allow-clear />
  246. </a-form-item>
  247. <a-form-item field="area" label="乐跑跑区">
  248. <a-select v-model="form.area" placeholder="请选择乐跑跑区" default-value="">
  249. <a-option value="">随机分配</a-option>
  250. <a-option v-for="(item, index) in area" :key="index" :value="item">
  251. <span class="vipcontent">
  252. <span>{{ item }} </span>
  253. <!-- <img src="@/assets/vip.svg" alt="vip" height="20"> -->
  254. </span>
  255. </a-option>
  256. </a-select>
  257. </a-form-item>
  258. <a-form-item field="auto_run" label="自动乐跑开关">
  259. <a-switch v-model="form.auto_run" :checked-value="1" :unchecked-value="0" />
  260. </a-form-item>
  261. <a-form-item field="target_count" label="乐跑目标次数" v-if="form.auto_run">
  262. <a-input-number v-model="form.target_count" placeholder="请输入乐跑目标次数" mode="button" />
  263. <template #extra>
  264. <div>当学期有效次数达到目标次数时自动乐跑将关闭,0为不限次</div>
  265. </template>
  266. </a-form-item>
  267. <a-form-item field="auto_time" label="自动乐跑时段" v-if="form.auto_run">
  268. <a-select v-model="form.auto_time" placeholder="请选择每天自动乐跑的时段" :options="auto_time" />
  269. </a-form-item>
  270. <a-form-item field="notes" label="备注">
  271. <a-textarea v-model="form.notes" placeholder="添加对账号的备注(非必填)" :max-length="{ length: 50 }" allow-clear
  272. show-word-limit />
  273. </a-form-item>
  274. </a-form>
  275. </a-modal>
  276. <faceModal :faceInfo="faceInfo" ref="faceRecoRef" />
  277. </template>
  278. <script setup>
  279. import { ref, reactive, onUnmounted, onMounted, h } from 'vue'
  280. import { accountList, deleteAccount, addAccount, changeAutoRun, singleRun } from '@/api/lepao'
  281. import { Modal, Notification, Message } from '@arco-design/web-vue'
  282. import { IconSearch } from '@arco-design/web-vue/es/icon'
  283. import userCard from '@/components/userCard/userCard.vue'
  284. import { isElectron } from '@/utils/electron'
  285. import faceModal from '@/components/FaceModal/faceModal.vue'
  286. import { useRoute } from 'vue-router'
  287. import { getNotice } from '@/utils/util'
  288. const notice = ref('')
  289. const email = ref([])
  290. const faceInfo = ref({})
  291. const faceRecoRef = ref(null)
  292. const queryDataForm = reactive({
  293. area: '',
  294. student_num: '',
  295. email: '',
  296. username: '',
  297. state: -1,
  298. auto_time: 0
  299. })
  300. const queryData = reactive({
  301. area: '',
  302. student_num: '',
  303. email: '',
  304. username: '',
  305. state: -1,
  306. auto_time: 0
  307. })
  308. const pagination = reactive({
  309. total: 0,
  310. current: 1, // 默认从第1页开始
  311. pagesize: 20
  312. })
  313. const handleSearch = (value) => {
  314. const emailSuffix = ["qq.com", "ctbu.edu.cn", "163.com"]
  315. const input = (value || "").trim()
  316. if (!input) {
  317. email.value = []
  318. return
  319. }
  320. // 没有输入 @,直接拼接所有后缀
  321. if (!input.includes("@")) {
  322. email.value = emailSuffix.map(suffix => `${input}@${suffix}`)
  323. return
  324. }
  325. // 输入了 @ 但结尾是 @,拼接所有后缀
  326. if (input.endsWith("@")) {
  327. email.value = emailSuffix.map(suffix => `${input}${suffix}`)
  328. return
  329. }
  330. // 输入了 @ 且有部分后缀,智能匹配
  331. const [prefix, suffixPart] = input.split("@")
  332. email.value = emailSuffix
  333. .filter(suffix => suffix.startsWith(suffixPart))
  334. .map(suffix => `${prefix}@${suffix}`)
  335. }
  336. const area = ["兰花湖校区跑区", "主校区北跑区", "主校区南跑区", "重庆工商大学茶园校区"]
  337. const state = [
  338. { label: '全部', value: -1 }, { label: '需登录', value: 0 }, { label: '正常', value: 1 }, { label: '状态异常', value: 2 }
  339. ]
  340. const search = () => {
  341. pagination.current = 1
  342. queryData.area = queryDataForm.area
  343. queryData.student_num = queryDataForm.student_num
  344. queryData.email = queryDataForm.email
  345. queryData.username = queryDataForm.username
  346. queryData.state = queryDataForm.state
  347. queryData.auto_time = queryDataForm.auto_time
  348. getAccountsAsync()
  349. }
  350. const reset = () => {
  351. queryDataForm.area = ''
  352. queryDataForm.student_num = ''
  353. queryDataForm.email = ''
  354. queryDataForm.username = ''
  355. queryDataForm.state = -1
  356. queryDataForm.auto_time = 0
  357. queryData.area = ''
  358. queryData.student_num = ''
  359. queryData.email = ''
  360. queryData.username = ''
  361. queryData.state = -1
  362. queryData.auto_time = 0
  363. getAccountsAsync()
  364. }
  365. // 分页 - 页码变化
  366. const handlePageChange = (page) => {
  367. pagination.current = page
  368. getAccountsAsync()
  369. }
  370. // 分页 - 每页条数变化
  371. const handlePageSizeChange = (size) => {
  372. pagination.pagesize = size
  373. pagination.current = 1 // 页大小变化后回到第一页
  374. getAccountsAsync()
  375. }
  376. const auto_time = [
  377. { label: '随机分配', value: -1 },
  378. ...Array.from({ length: 17 }, (_, i) => {
  379. const hour = i + 7
  380. return { label: `${hour} ~ ${hour + 1}时`, value: hour }
  381. })
  382. ]
  383. const autoTimeLabel = (record) => {
  384. if (record.auto_time === -1 && record.today_auto_time) {
  385. return `随机-今日${record.today_auto_time}时`
  386. }
  387. const match = auto_time.find(item => item.value === record.auto_time)
  388. return match ? match.label : '-'
  389. }
  390. const data = ref([])
  391. const loading = ref(false)
  392. const visible = ref(false)
  393. const ok_loading = ref(false)
  394. const form = reactive({
  395. id: null,
  396. student_num: '',
  397. email: '',
  398. distance: [2.00, 4.00],
  399. area: '',
  400. auto_time: -1,
  401. auto_run: 1,
  402. target_count: 30,
  403. notes: ''
  404. })
  405. const download = () => {
  406. const a = document.createElement('a');
  407. a.href = 'https:\/\/lepao-cloud.xxoo365.top\/down.php\/682d99f9694c6fe76b64b86c5741a2d8.pdf';
  408. a.download = 'RunForge操作说明.pdf'
  409. a.target = '_blank'
  410. document.body.appendChild(a);
  411. a.click();
  412. document.body.removeChild(a);
  413. }
  414. const editAccount = (item) => {
  415. if (item) {
  416. form.id = item.id
  417. form.student_num = item.student_num
  418. form.email = item.email
  419. form.area = item.area
  420. form.auto_time = item.auto_time
  421. form.auto_run = item.auto_run
  422. form.target_count = item.target_count
  423. form.notes = item.notes
  424. } else {
  425. form.id = null
  426. form.student_num = ''
  427. form.email = ''
  428. form.auto_run = 1
  429. form.auto_time = -1
  430. form.target_count = 30
  431. form.area = ''
  432. form.notes = ''
  433. }
  434. visible.value = true
  435. }
  436. const handleBeforeOk = async (done) => {
  437. try {
  438. ok_loading.value = true
  439. const { student_num, email } = form
  440. if (!student_num || !email) {
  441. Message.error('请填写完整的账号信息')
  442. return false
  443. }
  444. const studentNumRegex = /^\d{10}$/
  445. if (!studentNumRegex.test(student_num)) {
  446. Message.error('请检查学号格式是否正确')
  447. return false
  448. }
  449. const emailRegex = /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/
  450. if (!emailRegex.test(email)) {
  451. Message.error('请检查邮箱格式是否正确')
  452. return false
  453. }
  454. let data = {
  455. ...form,
  456. min_distance: form.distance[0],
  457. max_distance: form.distance[1]
  458. }
  459. const res = await addAccount(data)
  460. if (!res || res.code !== 0) {
  461. Notification.error({
  462. title: '保存乐跑账号失败!',
  463. content: res?.msg ?? '请稍后再试'
  464. })
  465. return false
  466. }
  467. Message.success('保存成功!')
  468. done()
  469. getAccountsAsync()
  470. } catch (error) {
  471. Notification.error({
  472. title: '保存乐跑账号失败!',
  473. content: error.message || '请稍后再试'
  474. })
  475. return false
  476. } finally {
  477. ok_loading.value = false
  478. }
  479. }
  480. const handleCancel = () => {
  481. visible.value = false
  482. }
  483. const getAccountsAsync = async () => {
  484. loading.value = true
  485. await getAccounts()
  486. loading.value = false
  487. }
  488. const getAccounts = async () => {
  489. try {
  490. const reqData = {
  491. ...queryData,
  492. pagesize: pagination.pagesize,
  493. current: pagination.current
  494. }
  495. const res = await accountList(reqData)
  496. if (!res || res.code !== 0)
  497. return Notification.error({
  498. title: '获取乐跑账号数据失败!',
  499. content: res?.msg ?? '请稍后再试'
  500. })
  501. data.value = res.data
  502. pagination.total = res.pagination.total
  503. } catch (error) {
  504. Notification.error({
  505. title: '获取乐跑账号数据失败!',
  506. content: error.message || '请稍后再试'
  507. })
  508. }
  509. }
  510. const GetNotice = async () => {
  511. const { path } = useRoute()
  512. const res = await getNotice(path)
  513. notice.value = res
  514. }
  515. const SingleRun = async (item) => {
  516. if (item.state !== 1)
  517. return Notification.warning({
  518. title: '当前乐跑账号需登录,请登录后再试',
  519. content: '如有疑问请联系RunForge客服'
  520. })
  521. Modal.confirm({
  522. title: '开始乐跑',
  523. content: () => h('div', [
  524. h('p', `您是否要为 ${item.name}(${item.student_num}) 乐跑?若乐跑成功将扣减乐跑次数`)
  525. ]),
  526. onOk: async () => {
  527. const res = await singleRun({ student_num: item.student_num })
  528. if (!res || res.code !== 0)
  529. return Notification.error({
  530. title: '提交乐跑任务失败',
  531. content: res?.msg ?? '请稍后再试'
  532. })
  533. Message.success('提交乐跑任务成功!')
  534. }
  535. })
  536. }
  537. const DeleteAccount = async (item) => {
  538. Modal.confirm({
  539. title: '解绑账号',
  540. content: () => h('div', [
  541. h('p', '您是否要解绑该账号?')
  542. ]),
  543. onOk: async () => {
  544. const res = await deleteAccount({ id: item.id })
  545. if (!res || res.code !== 0)
  546. return Notification.error({
  547. title: '解绑失败',
  548. content: res?.msg ?? '请稍后再试'
  549. })
  550. Message.success('解绑成功!')
  551. getAccounts()
  552. }
  553. })
  554. }
  555. const ChangeAutoRun = async (record) => {
  556. const oldValue = record.auto_run;
  557. record.auto_run = oldValue === 1 ? 0 : 1;
  558. try {
  559. const res = await changeAutoRun({ id: record.id });
  560. if (!res || res.code !== 0) {
  561. record.auto_run = oldValue;
  562. Notification.error({
  563. title: '切换自动乐跑状态失败!',
  564. content: res?.msg ?? '请稍后再试'
  565. })
  566. } else {
  567. Message.success(`自动乐跑状态已${record.auto_run === 1 ? '开启' : '关闭'}`)
  568. getAccounts()
  569. }
  570. } catch (error) {
  571. record.auto_run = oldValue;
  572. Message.error('切换自动乐跑状态失败!');
  573. }
  574. }
  575. const stramptoTime = (time) => {
  576. return new Date(time).toLocaleString('zh-CN', { year: 'numeric', month: '2-digit', day: '2-digit', hour: '2-digit', minute: '2-digit' })
  577. }
  578. let timer = null
  579. // 轮询
  580. const startPolling = () => {
  581. if (!timer) {
  582. timer = setInterval(async () => {
  583. await getAccounts()
  584. }, 5000)
  585. }
  586. }
  587. // 停止轮询
  588. const stopPolling = () => {
  589. if (timer) {
  590. clearInterval(timer)
  591. timer = null
  592. }
  593. }
  594. onMounted(async () => {
  595. getAccountsAsync()
  596. GetNotice()
  597. startPolling()
  598. })
  599. // 组件销毁时停止轮询
  600. onUnmounted(() => {
  601. stopPolling()
  602. })
  603. </script>
  604. <style scoped lang="less">
  605. .container {
  606. padding: 0 20px 20px 20px;
  607. }
  608. .queryForm {
  609. margin-top: 20px;
  610. padding: 0 15px
  611. }
  612. .table {
  613. font-family: -apple-system, BlinkMacSystemFont;
  614. .state {
  615. display: flex;
  616. align-items: center;
  617. .circle {
  618. border-radius: 50%;
  619. height: 8px;
  620. min-height: 8px;
  621. width: 8px;
  622. min-width: 8px;
  623. margin-right: 5px;
  624. }
  625. .zero {
  626. background-color: rgb(var(--orange-6));
  627. }
  628. .one {
  629. background-color: rgb(var(--green-6));
  630. }
  631. .else {
  632. background-color: rgb(var(--red-6));
  633. }
  634. }
  635. }
  636. .custom-filter {
  637. padding: 20px;
  638. background: var(--color-bg-5);
  639. border: 1px solid var(--color-neutral-3);
  640. border-radius: var(--border-radius-medium);
  641. box-shadow: 0 2px 5px rgb(0 0 0 / 10%);
  642. }
  643. .custom-filter-footer {
  644. display: flex;
  645. justify-content: space-between;
  646. }
  647. .vipcontent {
  648. display: flex;
  649. align-items: center;
  650. }
  651. </style>