|
@@ -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>
|
|
|
|