新增在线更新功能

This commit is contained in:
gyq
2024-09-04 09:08:32 +08:00
parent 86c8ca6472
commit d57cecd91d
7 changed files with 16057 additions and 9 deletions

View File

@@ -8,7 +8,8 @@
<div class="t2">
<span>原价{{ formatDecimal(props.amount) }}</span>
<span style="margin-left: 20px;">优惠{{ formatDecimal(props.amount - money) }}</span>
<span style="margin-left: 20px;" v-if="props.discount" @click="cancelDiscount">折扣{{ formatDecimal(props.discount * 10, 1, true) }}
<span style="margin-left: 20px;" v-if="props.discount" @click="cancelDiscount">折扣{{
formatDecimal(props.discount * 10, 1, true) }}
<el-icon style="margin-left: 6px;">
<CircleClose />
</el-icon>
@@ -295,7 +296,8 @@ async function getMemberList() {
shopId: store.userInfo.shopId,
phone: tableData.phone,
page: tableData.page,
pageSize: tableData.size
pageSize: tableData.size,
isFlag: 1
})
tableData.loading = false
tableData.list = res.list

View File

@@ -0,0 +1,88 @@
<template>
<el-dialog v-model="showDialog" title="发现新版本" width="500" :close-on-click-modal="false"
:close-on-press-escape="false" :show-close="false">
<div class="message">
{{ updataInfo.message }}
</div>
<div class="progress_wrap" style="padding-top: 20px;">
<el-progress :percentage="uploadPro" :stroke-width="15" striped :striped-flow="uploadPro < 100" />
</div>
<template #footer>
<div class="footer" style="padding: 0 20px 20px;">
<el-button v-if="!updataInfo.isUp && !isUpload" @click="showDialog = false">下次更新</el-button>
<el-button type="primary" :loading="isUpload" @click="uplaodHandle">
<template v-if="!uploadSucess">
<template v-if="!isUpload">
立即更新
</template>
<template v-else>
下载中...
</template>
</template>
<template v-else>
立即安装
</template>
</el-button>
</div>
</template>
</el-dialog>
</template>
<script setup>
import { onMounted, ref } from 'vue'
import { findVersion } from '@/api/user.js'
import packageData from "../../package.json";
import { ipcRenderer } from 'electron'
import { useUser } from "@/store/user.js";
const store = useUser()
const showDialog = ref(false)
const updataInfo = ref({})
const isUpload = ref(false)
const uploadPro = ref(0)
const uploadSucess = ref(false)
const uploadResponse = ref({})
const tempFilePath = ref('')
// 检查版本更新
async function findVersionAjax() {
try {
const res = await findVersion()
let reg = /\./g;
if (res.version.replace(reg, '') > packageData.version.replace(reg, '') && res.url) {
showDialog.value = true
updataInfo.value = res
}
} catch (error) {
console.log(error);
}
}
// 下载新版本
async function uplaodHandle() {
try {
if (!uploadSucess.value) {
isUpload.value = true
ipcRenderer.send('downloadFile', JSON.stringify({ url: updataInfo.value.url }))
// await downloadFile(updataInfo.value.url)
// isUpload.value = false
// uploadSucess.value = true
} else {
// 安装文件
}
} catch (error) {
console.log(error);
}
}
onMounted(() => {
if (store.userInfo) {
findVersionAjax()
}
ipcRenderer.on('updateProgress', (event, res) => {
uploadPro.value = res
})
})
</script>