197 lines
4.6 KiB
Vue
197 lines
4.6 KiB
Vue
<template>
|
|
<el-card class="app-download-card" shadow="hover">
|
|
<template #header>
|
|
<div class="card-header">
|
|
<span>应用下载</span>
|
|
</div>
|
|
</template>
|
|
|
|
<div class="app-list">
|
|
<!-- PDA APP -->
|
|
<div class="app-item" v-loading="loadingPda">
|
|
<div class="app-icon">
|
|
<el-icon :size="40" color="#409eff"><Cellphone /></el-icon>
|
|
</div>
|
|
<div class="app-info">
|
|
<div class="app-name">WMS PDA端</div>
|
|
<div class="app-version" v-if="pdaData">V {{ pdaData.version }}</div>
|
|
<div class="app-date" v-if="pdaData">{{ formatDate(pdaData.publishedAt) }}</div>
|
|
<div class="app-error" v-if="pdaError">获取版本信息失败</div>
|
|
</div>
|
|
<div class="app-action">
|
|
<el-button type="primary" size="small" :disabled="!pdaData?.downloadUrl" @click="download(pdaData?.downloadUrl)">
|
|
下载
|
|
</el-button>
|
|
</div>
|
|
</div>
|
|
|
|
<el-divider border-style="dashed" />
|
|
|
|
<!-- Print Server -->
|
|
<div class="app-item" v-loading="loadingPrint">
|
|
<div class="app-icon">
|
|
<el-icon :size="40" color="#67c23a"><Monitor /></el-icon>
|
|
</div>
|
|
<div class="app-info">
|
|
<div class="app-name">打印控件 (PC)</div>
|
|
<div class="app-version" v-if="printData">V {{ printData.version }}</div>
|
|
<div class="app-date" v-if="printData">{{ formatDate(printData.publishedAtUtc) }}</div>
|
|
<div class="app-error" v-if="printError">获取版本信息失败</div>
|
|
</div>
|
|
<div class="app-action">
|
|
<el-button type="success" size="small" :disabled="!printData?.url" @click="download(printData?.url)">
|
|
下载
|
|
</el-button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</el-card>
|
|
</template>
|
|
|
|
<script setup lang="ts">
|
|
import { ref, onMounted } from 'vue'
|
|
import { Cellphone, Monitor } from '@element-plus/icons-vue'
|
|
import dayjs from 'dayjs'
|
|
import axios from 'axios'
|
|
|
|
interface PdaVersionInfo {
|
|
version: string
|
|
versionName: string
|
|
downloadUrl: string
|
|
fileName: string
|
|
forceUpdate: boolean
|
|
publishedAt: string
|
|
}
|
|
|
|
interface PrintServerVersionInfo {
|
|
version: string
|
|
file: string
|
|
url: string
|
|
publishedAtUtc: string
|
|
}
|
|
|
|
const pdaData = ref<PdaVersionInfo | null>(null)
|
|
const printData = ref<PrintServerVersionInfo | null>(null)
|
|
|
|
const loadingPda = ref(true)
|
|
const loadingPrint = ref(true)
|
|
const pdaError = ref(false)
|
|
const printError = ref(false)
|
|
|
|
const formatDate = (dateString: string) => {
|
|
if (!dateString) return ''
|
|
return dayjs(dateString).format('YYYY-MM-DD HH:mm')
|
|
}
|
|
|
|
const fetchPdaInfo = async () => {
|
|
try {
|
|
loadingPda.value = true
|
|
pdaError.value = false
|
|
const response = await axios.get('/dl-api/pda/latest.json')
|
|
if (response.data) {
|
|
pdaData.value = response.data
|
|
}
|
|
} catch (error) {
|
|
console.error('Failed to fetch PDA version info', error)
|
|
pdaError.value = true
|
|
} finally {
|
|
loadingPda.value = false
|
|
}
|
|
}
|
|
|
|
const fetchPrintServerInfo = async () => {
|
|
try {
|
|
loadingPrint.value = true
|
|
printError.value = false
|
|
const response = await axios.get('/dl-api/printServer/latest.json')
|
|
if (response.data) {
|
|
printData.value = response.data
|
|
}
|
|
} catch (error) {
|
|
console.error('Failed to fetch Print Server version info', error)
|
|
printError.value = true
|
|
} finally {
|
|
loadingPrint.value = false
|
|
}
|
|
}
|
|
|
|
const download = (url?: string) => {
|
|
if (url) {
|
|
window.open(url, '_blank')
|
|
}
|
|
}
|
|
|
|
onMounted(() => {
|
|
fetchPdaInfo()
|
|
fetchPrintServerInfo()
|
|
})
|
|
</script>
|
|
|
|
<style lang="scss" scoped>
|
|
.app-download-card {
|
|
height: 100%;
|
|
|
|
.card-header {
|
|
display: flex;
|
|
justify-content: space-between;
|
|
align-items: center;
|
|
font-weight: bold;
|
|
font-size: 16px;
|
|
}
|
|
|
|
.app-list {
|
|
display: flex;
|
|
flex-direction: column;
|
|
padding: 10px 0;
|
|
}
|
|
|
|
.app-item {
|
|
display: flex;
|
|
align-items: center;
|
|
padding: 10px 0;
|
|
|
|
.app-icon {
|
|
width: 60px;
|
|
display: flex;
|
|
justify-content: center;
|
|
align-items: center;
|
|
margin-right: 15px;
|
|
}
|
|
|
|
.app-info {
|
|
flex: 1;
|
|
|
|
.app-name {
|
|
font-weight: 600;
|
|
font-size: 15px;
|
|
margin-bottom: 5px;
|
|
color: #303133;
|
|
}
|
|
|
|
.app-version {
|
|
font-size: 13px;
|
|
color: #606266;
|
|
margin-bottom: 2px;
|
|
}
|
|
|
|
.app-date {
|
|
font-size: 12px;
|
|
color: #909399;
|
|
}
|
|
|
|
.app-error {
|
|
font-size: 12px;
|
|
color: #f56c6c;
|
|
}
|
|
}
|
|
|
|
.app-action {
|
|
margin-left: 15px;
|
|
}
|
|
}
|
|
|
|
:deep(.el-divider--horizontal) {
|
|
margin: 12px 0;
|
|
}
|
|
}
|
|
</style> |