Browse Source

✨ feat: 加入版本更新功能

Pchen. 8 months ago
parent
commit
668a15dd61
4 changed files with 39 additions and 11 deletions
  1. 1 0
      .env
  2. 24 2
      src/App.vue
  3. 8 0
      src/api/user.js
  4. 6 9
      src/pages/lepao/accountList/index.vue

+ 1 - 0
.env

@@ -1,3 +1,4 @@
 NODE_ENV=production
 VITE_APP_API_BASE_URL=https://lepao-api.xxoo365.top
 VITE_RSA_PUBLIC_KEY=LS0tLS1CRUdJTiBQVUJMSUMgS0VZLS0tLS0KTUlJQklqQU5CZ2txaGtpRzl3MEJBUUVGQUFPQ0FROEFNSUlCQ2dLQ0FRRUF6Z1lGYzVRMGVqbTh4akZsSjdMSQpBZDJGeC9TalM0OWQ5emwyZHlaNzNDMGZLU3Fuc1pJQUZkREpWZWV6bUp6T1hOWFdoYVZHaHFwM0dCUWVvcDBKClIxekZ3bUs1em9ReElTTDc5WVF3SmxoSjdaellhL0xNcGtGZDRDVFQ4UzUwTGFzN1FpcUtqRE1BQjFLZEpaTnIKNE5HcjNUWVV4MVVpTzlUTW9YV3lBdFZRQVN2a3lFSVFIb3B4T2Vod0ZuNGRhVE8vLzF5TXRyNnZoclE4enJRMwpxUG01YWJmY0lRM3B1WDVJd1MrekRmSkI5Rm9rc0paa3RWNHI2KzM2U1E3WGp2MDFBQjJvK20yejZqNzNuWjQ1Ci95TEx5NmZHTG5lTWpTaUxHMDhNUWFCUjV1dTNITTRnMkpnanA4eU10Rkg1Tkc5Zys1dXRhTDNzd3JGQjhxd1UKdFFJREFRQUIKLS0tLS1FTkQgUFVCTElDIEtFWS0tLS0tCg==
+VITE_APP_VERSION=1.0

+ 24 - 2
src/App.vue

@@ -20,6 +20,8 @@
 <script setup>
 import { ref, onMounted } from 'vue'
 import storage from 'store'
+import { Modal, Message } from '@arco-design/web-vue'
+import { getAppVersion } from '@/api/user'
 
 const mobile = ref(false)
 
@@ -40,8 +42,30 @@ function mobileGoOn() {
   storage.set('mobileShow', true)
 }
 
+async function GetAppVersion() {
+  try {
+    const current = import.meta.env.VITE_APP_VERSION
+    const res = await getAppVersion()
+    if (!res || res.code !== 0 || !res.data)
+      return Message.error(`获取版本更新内容失败!${res?.msg ?? ''}`)
+    if (res.data.version === current) return
+    Modal.info({
+      title: '版本更新',
+      escToClose: false,
+      maskClosable: false,
+      content: `发现新版本${res.data.version},是否立即刷新页面?\n${res.data?.msg ?? ''}`,
+      onBeforeOk: () => {
+        window.location.reload()
+      }
+    })
+  } catch (error) {
+    Message.error('获取版本更新内容失败')
+  }
+}
+
 onMounted(() => {
   checkMobile()
+  GetAppVersion()
 })
 
 </script>
@@ -62,6 +86,4 @@ onMounted(() => {
   top: 50%;
   transform: translateY(-50%);
 }
-
-
 </style>

+ 8 - 0
src/api/user.js

@@ -1,6 +1,7 @@
 import request from '../utils/request'
 
 const api = {
+  AppVersion: '/Public/GetAppVersion',
   ChangeUsername: '/User/ChangeUsername',
   ChangePassword: '/User/ChangePassword',
   UserInfo: '/User/Info',
@@ -12,6 +13,13 @@ const api = {
   AdminGetReqLogDetail: '/Admin/User/GetReqLogDetail'
 }
 
+export function getAppVersion() {
+  return request({
+    url: api.AppVersion,
+    method: 'get'
+  })
+}
+
 export function ChangeUsername(parameter) {
   return request({
     url: api.ChangeUsername,

+ 6 - 9
src/pages/lepao/accountList/index.vue

@@ -85,7 +85,7 @@
         </a-col>
       </a-row>
 
-      <a-table :data="data" stripe hoverable column-resizable class="table" :loading="loading" :scroll="{
+      <a-table :data="data" stripe hoverable class="table" :loading="loading" :scroll="{
         x: 1600
       }" :pagination="{
         showPageSize: true,
@@ -95,7 +95,6 @@
         current: pagination.current,
         total: pagination.total
       }" @page-change="handlePageChange" @page-size-change="handlePageSizeChange">
-
         <template #name-filter="{ filterValue, setFilterValue, handleFilterConfirm, handleFilterReset }">
           <div class="custom-filter">
             <a-space direction="vertical">
@@ -203,12 +202,10 @@
               {{ autoTimeLabel(record.auto_time) }}
             </template>
           </a-table-column>
-          <a-table-column title="累计次数" data-index="total_num" :width="110" ellipsis tooltip :sortable="{
-            sortDirections: ['ascend', 'descend']
-          }"></a-table-column>
-          <a-table-column title="剩余次数" :width="110" ellipsis tooltip>
+          <a-table-column title="累计次数" :width="110" ellipsis tooltip>
             <template #cell="{ record }">
-              {{ record.term_num - record.total_num > 0 ? (record.term_num - record.total_num) : '已完成' }}
+              {{ record.term_num - record.total_num > 0 ? `${record.total_num} / ${record.term_num}` :
+                '已完成' }}
             </template>
           </a-table-column>
           <a-table-column title="添加时间" :width="170" ellipsis tooltip :sortable="{
@@ -317,7 +314,7 @@ const pagination = reactive({
 })
 
 const handleSearch = (value) => {
-  const emailSuffix = ["qq.com", "ctbu.edu.cn"]
+  const emailSuffix = ["qq.com", "ctbu.edu.cn", "163.com"]
   const input = (value || "").trim()
 
   if (!input) {
@@ -484,7 +481,7 @@ const handleBeforeOk = async (done) => {
 
     Message.success('保存成功!')
     done()
-    getAccounts()
+    getAccountsAsync()
   } catch (error) {
     Notification.error({
       title: '保存乐跑账号失败!',