ZaiZai 1 år sedan
förälder
incheckning
811338d236
5 ändrade filer med 41 tillägg och 33 borttagningar
  1. 0 2
      package.json
  2. 3 0
      src/main/index.js
  3. 38 9
      src/renderer/src/App.vue
  4. 0 12
      src/renderer/src/layout/index.vue
  5. 0 10
      yarn.lock

+ 0 - 2
package.json

@@ -29,7 +29,6 @@
         "@unocss/eslint-config": "^0.58.5",
         "@vitejs/plugin-vue": "^5.0.3",
         "@vue/compiler-sfc": "^3.4.20",
-        "bignumber.js": "^9.1.2",
         "compressing": "^1.10.0",
         "dayjs": "^1.11.10",
         "echarts": "^5.5.0",
@@ -44,7 +43,6 @@
         "js-fast-way": "^0.4.6",
         "pinia": "^2.1.7",
         "sass": "^1.71.1",
-        "split.js": "^1.6.5",
         "unocss": "^0.58.5",
         "unocss-preset-extra": "^0.5.3",
         "vite": "^5.1.4",

+ 3 - 0
src/main/index.js

@@ -139,6 +139,9 @@ app.whenReady().then(() => {
                             resolve({ code: 300, data: res.msg })
                         }
                     })
+                    response.on('error', (error) => {
+                        console.log(`ERROR: ${JSON.stringify(error)}`)
+                    })
                 })
                 request.end()
             } catch (e) {

+ 38 - 9
src/renderer/src/App.vue

@@ -1,19 +1,25 @@
 <template>
     <hc-app-config>
         <router-view />
+        <!-- 弹窗 -->
+        <hc-new-dialog v-model="updateModal" widths="400px" title="检测到新版本" save-text="更新" @save="updateClick">
+            <hc-list-item title="系统平台:" :content="updateInfo.platform_arch" />
+            <hc-list-item title="当前版本:" :content="config.version" />
+            <hc-list-item title="最新版本:" :content="updateInfo.version" />
+            <hc-list-item title="发布日期:" :content="updateInfo.date" />
+            <hc-list-item title="更新说明:" :content="updateInfo.log" />
+        </hc-new-dialog>
     </hc-app-config>
 </template>
 
 <script setup>
-import { nextTick } from 'vue'
+import { nextTick, ref } from 'vue'
 import config from './config/index'
-import { toPage } from './utils/tools'
-import { isNullES, setElementMainColor } from 'js-fast-way'
-import split from 'split.js'
+import { openExternal, toPage } from './utils/tools'
+import { arrIndex, getArrValue, getObjValue, isNullES, setElementMainColor } from 'js-fast-way'
 
 nextTick(() => {
     setIpcRenderer()
-    window['$split'] = split
     setElementMainColor('#02a271')
     getCheckForUpdates()
 })
@@ -34,13 +40,36 @@ const setIpcRenderer = () => {
 }
 
 //检测更新
+const updateModal = ref(false)
+const updateInfo = ref({})
 const getCheckForUpdates = async () => {
-    const url = 'http://192.168.0.109:5175/local-app/index.json?time=' + new Date().getTime()
+    //platform:arm64 x64,arch:darwin win32
+    console.log('platform-arch:', window.api.platform, window.api.arch)
+    const http = 'https://archives.hczcxx.cn'
+    const url = `${http}/local-app/index.json?time=${new Date().getTime()}`
     const { code, data } = await window.electron.ipcRenderer.invoke('require', { url: url })
     if (code !== 200) return
-    console.log(data)
-    console.log('platform', window.api.platform)
-    console.log('arch', window.api.arch)
+    const appArr = getArrValue(data)
+    if (appArr.length <= 0) return
+    const PIndex = arrIndex(appArr, 'platform', window.api.platform)
+    if (PIndex < 0) return
+    const PInfo = getObjValue(appArr[PIndex])
+    const PInfoArr = getArrValue(PInfo.data)
+    const index = arrIndex(PInfoArr, 'arch', window.api.arch)
+    if (index < 0) return
+    const app = getObjValue(PInfoArr[index])
+    app.platform_arch = `${PInfo.platform}_${app.arch}`
+    app.app_url = `${http}${PInfo.url}${app.name}`
+    if (config.version < app.version) {
+        updateInfo.value = app
+        updateModal.value = true
+    }
+}
+
+//确定更新
+const updateClick = () => {
+    const { app_url } = updateInfo.value
+    openExternal(app_url)
 }
 </script>
 

+ 0 - 12
src/renderer/src/layout/index.vue

@@ -17,8 +17,6 @@
                                 <el-dropdown-item @click="handleProject">项目管理</el-dropdown-item>
                                 <el-dropdown-item divided @click="handleOnline">在线档案管理</el-dropdown-item>
                                 <el-dropdown-item divided @click="handleAbout">关于我们</el-dropdown-item>
-                                <!-- el-dropdown-item divided @click="handleClear">清除数据</el-dropdown-item>
-                                <el-dropdown-item divided @click="handleUpdate">检测更新</el-dropdown-item -->
                             </el-dropdown-menu>
                         </template>
                     </el-dropdown>
@@ -83,16 +81,6 @@ const handleOnline = () => {
 const handleAbout = () => {
     openExternal('http://hczc.hcxxy.com')
 }
-
-//清除数据
-const handleClear = () => {
-
-}
-
-//检测更新
-const handleUpdate = () => {
-
-}
 </script>
 
 <style lang="scss" scoped>

+ 0 - 10
yarn.lock

@@ -1530,11 +1530,6 @@ base64-js@^1.3.1, base64-js@^1.5.1:
   resolved "http://39.108.216.210:9000/base64-js/-/base64-js-1.5.1.tgz#1b1b440160a5bf7ad40b650f095963481903930a"
   integrity sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==
 
-bignumber.js@^9.1.2:
-  version "9.1.2"
-  resolved "http://39.108.216.210:9000/bignumber.js/-/bignumber.js-9.1.2.tgz#b7c4242259c008903b13707983b5f4bbd31eda0c"
-  integrity sha512-2/mKyZH9K85bzOEfhXDBFZTGd1CTs+5IHpeFQo9luiBG7hghdC851Pj2WAhb6E3R6b9tZj/XKhbg4fum+Kepug==
-
 binary-extensions@^2.0.0:
   version "2.2.0"
   resolved "http://39.108.216.210:9000/binary-extensions/-/binary-extensions-2.2.0.tgz#75f502eeaf9ffde42fc98829645be4ea76bd9e2d"
@@ -3782,11 +3777,6 @@ source-map@^0.6.0:
   resolved "http://39.108.216.210:9000/source-map/-/source-map-0.6.1.tgz#74722af32e9614e9c287a8d0bbde48b5e2f1a263"
   integrity sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==
 
-split.js@^1.6.5:
-  version "1.6.5"
-  resolved "http://39.108.216.210:9000/split.js/-/split.js-1.6.5.tgz#f7f61da1044c9984cb42947df4de4fadb5a3f300"
-  integrity sha512-mPTnGCiS/RiuTNsVhCm9De9cCAUsrNFFviRbADdKiiV+Kk8HKp/0fWu7Kr8pi3/yBmsqLFHuXGT9UUZ+CNLwFw==
-
 sprintf-js@^1.1.2:
   version "1.1.3"
   resolved "http://39.108.216.210:9000/sprintf-js/-/sprintf-js-1.1.3.tgz#4914b903a2f8b685d17fdf78a70e917e872e444a"