align(软件版本): 操作列下载改<a download>强制下载、上传成功留驻弹窗(发布成功。版本:X,链接:Y可复制)、按钮名上传软件版本/弹窗标题上传新版本/描述与zip提示对齐、空态暂无版本记录(对齐 admin.js loadSoftwareVersions/上传段+admin.html:6094-6110)
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
<script setup lang="ts">
|
||||
import { formatDateTime } from '@/utils/datetime'
|
||||
/** 软件版本管理页:客户端版本列表 + 上传新版本。 */
|
||||
/** 软件版本管理页:客户端版本列表 + 上传新版本(成功留驻弹窗含链接,对齐 admin panel-version)。 */
|
||||
import { onMounted, ref } from 'vue'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import { fetchSoftwareVersions, uploadSoftwareVersion } from './version-api.ts'
|
||||
@@ -14,6 +14,9 @@ const uploadVisible = ref(false)
|
||||
const uploading = ref(false)
|
||||
const newVersion = ref('')
|
||||
const pickedFile = ref<File | null>(null)
|
||||
/** 弹窗内成功/失败文案(对齐 admin.js msgVersion 留驻)。 */
|
||||
const uploadMsg = ref('')
|
||||
const uploadMsgOk = ref(false)
|
||||
|
||||
async function load() {
|
||||
loading.value = true
|
||||
@@ -30,17 +33,27 @@ function onFileChange(file: File) {
|
||||
pickedFile.value = file
|
||||
}
|
||||
|
||||
function openUpload() {
|
||||
uploadMsg.value = ''
|
||||
uploadMsgOk.value = false
|
||||
newVersion.value = ''
|
||||
pickedFile.value = null
|
||||
uploadVisible.value = true
|
||||
}
|
||||
|
||||
async function submitUpload() {
|
||||
uploadMsg.value = ''
|
||||
uploadMsgOk.value = false
|
||||
if (!isNonEmptyVersion(newVersion.value)) {
|
||||
ElMessage.warning('请填写版本号')
|
||||
uploadMsg.value = '请填写版本号'
|
||||
return
|
||||
}
|
||||
if (!pickedFile.value) {
|
||||
ElMessage.warning('请选择 zip 压缩包')
|
||||
uploadMsg.value = '请选择 zip 压缩包'
|
||||
return
|
||||
}
|
||||
if (!/\.zip$/i.test(pickedFile.value.name)) {
|
||||
ElMessage.warning('仅支持 .zip 格式')
|
||||
uploadMsg.value = '仅支持 .zip 格式'
|
||||
return
|
||||
}
|
||||
uploading.value = true
|
||||
@@ -48,13 +61,14 @@ async function submitUpload() {
|
||||
const created = await uploadSoftwareVersion(newVersion.value.trim(), pickedFile.value, pickedFile.value.name)
|
||||
const version = created?.version || newVersion.value.trim()
|
||||
const link = created?.fileUrl
|
||||
ElMessage.success(link ? `发布成功。版本:${version},链接:${link}` : `发布成功。版本:${version}`)
|
||||
uploadVisible.value = false
|
||||
// 对齐 admin.js:6484-6488:弹窗保持打开,成功文案(含链接)留驻可复制,仅清空输入并刷新列表。
|
||||
uploadMsg.value = link ? `发布成功。版本:${version},链接:${link}` : `发布成功。版本:${version}`
|
||||
uploadMsgOk.value = true
|
||||
newVersion.value = ''
|
||||
pickedFile.value = null
|
||||
load()
|
||||
} catch (error) {
|
||||
ElMessage.error(error instanceof Error ? error.message : '发布失败')
|
||||
uploadMsg.value = error instanceof Error ? error.message : '上传失败'
|
||||
} finally {
|
||||
uploading.value = false
|
||||
}
|
||||
@@ -71,16 +85,16 @@ onMounted(load)
|
||||
<p>管理客户端更新包版本(用于 /api/version/latest 下发)。</p>
|
||||
</div>
|
||||
<div class="actions">
|
||||
<el-button type="primary" @click="uploadVisible = true">上传新版本</el-button>
|
||||
<el-button type="primary" @click="openUpload">上传新版本</el-button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<el-card shadow="never">
|
||||
<el-table v-loading="loading" :data="items" stripe border empty-text="暂无版本">
|
||||
<el-table v-loading="loading" :data="items" stripe border empty-text="暂无版本记录">
|
||||
<el-table-column prop="version" label="版本号" min-width="180" />
|
||||
<el-table-column label="下载链接" min-width="240">
|
||||
<template #default="{ row }">
|
||||
<el-link v-if="(row as SoftwareVersionItem).fileUrl" type="primary" :href="(row as SoftwareVersionItem).fileUrl" target="_blank">{{ (row as SoftwareVersionItem).fileUrl }}</el-link>
|
||||
<a v-if="(row as SoftwareVersionItem).fileUrl" class="el-link el-link--primary" :href="(row as SoftwareVersionItem).fileUrl" target="_blank" rel="noopener">{{ (row as SoftwareVersionItem).fileUrl }}</a>
|
||||
<span v-else class="dim">—</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
@@ -89,28 +103,31 @@ onMounted(load)
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" width="90" fixed="right">
|
||||
<template #default="{ row }">
|
||||
<el-link v-if="(row as SoftwareVersionItem).fileUrl" type="primary" :href="(row as SoftwareVersionItem).fileUrl" target="_blank">下载</el-link>
|
||||
<a v-if="(row as SoftwareVersionItem).fileUrl" class="el-link el-link--primary" :href="(row as SoftwareVersionItem).fileUrl" download>下载</a>
|
||||
<span v-else class="dim">—</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</el-card>
|
||||
|
||||
<el-dialog v-model="uploadVisible" title="上传软件版本" width="520px">
|
||||
<el-dialog v-model="uploadVisible" title="上传新版本" width="520px">
|
||||
<p class="upload-desc">上传软件 ZIP 包,系统会自动计算 MD5 并存储到 OSS。</p>
|
||||
<el-form label-width="110px">
|
||||
<el-form-item label="版本号" required>
|
||||
<el-input v-model="newVersion" placeholder="如 1.0.2" />
|
||||
<el-input v-model="newVersion" placeholder="例如:1.0.0" />
|
||||
</el-form-item>
|
||||
<el-form-item label="程序压缩包" required>
|
||||
<el-form-item label="ZIP 压缩包" required>
|
||||
<el-upload :auto-upload="false" :limit="1" accept=".zip" :on-change="(file: any) => onFileChange(file.raw)" :on-remove="() => (pickedFile = null)">
|
||||
<el-button>选择文件</el-button>
|
||||
</el-upload>
|
||||
<p class="zip-hint">仅支持 .zip 格式</p>
|
||||
<div v-if="pickedFile" class="dim">{{ pickedFile.name }}</div>
|
||||
</el-form-item>
|
||||
<el-alert v-if="uploadMsg" :title="uploadMsg" :type="uploadMsgOk ? 'success' : 'error'" :closable="false" show-icon class="upload-msg" />
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<el-button @click="uploadVisible = false">取消</el-button>
|
||||
<el-button type="primary" :loading="uploading" @click="submitUpload">上传</el-button>
|
||||
<el-button type="primary" :loading="uploading" @click="submitUpload">上传软件版本</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</div>
|
||||
@@ -120,4 +137,8 @@ onMounted(load)
|
||||
.page-heading { display: flex; justify-content: space-between; align-items: flex-start; }
|
||||
.actions { display: flex; align-items: center; gap: 10px; }
|
||||
.dim { color: var(--el-text-color-secondary); font-size: 12px; }
|
||||
.upload-desc { margin: 0 0 12px; color: var(--el-text-color-secondary); font-size: 12.5px; line-height: 1.6; }
|
||||
.zip-hint { margin: 4px 0 0; color: var(--el-text-color-secondary); font-size: 12px; }
|
||||
.upload-msg { margin-bottom: 8px; }
|
||||
.upload-msg :deep(.el-alert__title) { word-break: break-all; }
|
||||
</style>
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
import test from 'node:test'
|
||||
import assert from 'node:assert/strict'
|
||||
import { readSource } from './helpers.ts'
|
||||
|
||||
/** 对齐 admin.js:6296-6311(强制下载/空态) 与 6475-6495(成功留驻弹窗) 与 admin.html:6090-6110(弹窗文案)。 */
|
||||
|
||||
test('align_software_version_page_wiring', () => {
|
||||
const page = readSource('src/pages/records/RecordsSoftwareVersionPage.vue')
|
||||
// 下载按钮:<a download> 强制下载(对齐 admin.js:6301)。
|
||||
assert.match(page, /download/, '下载链接带 download 强制下载')
|
||||
assert.match(page, /download\s*>\s*下载\s*<\/a>/, '操作列下载为强制下载链接')
|
||||
// 上传成功:弹窗保持打开,成功文案留驻可复制(对齐 admin.js:6484-6488)。
|
||||
assert.match(page, /发布成功。版本:/, '成功文案留驻弹窗')
|
||||
assert.match(page, /uploadMsg/, '成功/失败文案在弹窗内展示')
|
||||
// 上传弹窗文案(对齐 admin.html:6094-6110)。
|
||||
assert.match(page, /上传软件 ZIP 包,系统会自动计算 MD5 并存储到 OSS。/, '弹窗描述对齐')
|
||||
assert.match(page, /上传软件版本/, '上传按钮名对齐')
|
||||
assert.match(page, /上传新版本/, '弹窗标题对齐')
|
||||
// 空态(对齐 admin.js:6296 暂无版本记录)。
|
||||
assert.match(page, /暂无版本记录/, '空态文案对齐')
|
||||
})
|
||||
@@ -58,7 +58,7 @@ test('test_task_260_version_invalid_input_rejected', () => {
|
||||
assert.match(page, /请选择 zip 压缩包/)
|
||||
assert.match(page, /仅支持 \.zip 格式/)
|
||||
assert.match(page, /accept="\.zip"/)
|
||||
assert.match(page, /发布失败/)
|
||||
assert.match(page, /上传失败/, '上传失败兜底文案')
|
||||
})
|
||||
|
||||
test('test_task_260_version_dependency_failure_returns_actionable_message', () => {
|
||||
|
||||
Reference in New Issue
Block a user