fix: 上传前视频状态未知时阻止提交 (#27)
This commit is contained in:
@@ -22,7 +22,7 @@
|
||||
* (2026-09-03 负责人决定)。所以本地总数可能大于店铺当前商品数,
|
||||
* 这是预期行为,不要加自动清理。
|
||||
*/
|
||||
import { computed, h, onMounted, onUnmounted, ref } from 'vue'
|
||||
import { computed, h, onMounted, onUnmounted, ref, watch } from 'vue'
|
||||
import { NButton, useDialog, useMessage } from 'naive-ui'
|
||||
import { EventsOff, EventsOn } from '../../wailsjs/runtime/runtime'
|
||||
import * as AppBindings from '../../wailsjs/go/main/App'
|
||||
@@ -85,6 +85,7 @@ const uploadStatusOptions = [
|
||||
{ label: '上传中', value: 'running' },
|
||||
{ label: '已上传', value: 'done' },
|
||||
{ label: '上传失败', value: 'failed' },
|
||||
{ label: '视频状态未确认', value: 'unconfirmed' },
|
||||
{ label: '已有视频', value: 'existing' },
|
||||
{ label: '缺少视频', value: 'missing' },
|
||||
{ label: '视频不合规', value: 'invalid' },
|
||||
@@ -227,6 +228,8 @@ const rows = ref([])
|
||||
const total = ref(0)
|
||||
const loading = ref(false)
|
||||
const checkedIds = ref([])
|
||||
const uploadPreviewNotice = ref(null)
|
||||
watch(checkedIds, () => { uploadPreviewNotice.value = null })
|
||||
const searchingProductID = ref('')
|
||||
|
||||
// ---- 主图原图弹窗 ----
|
||||
@@ -307,8 +310,15 @@ const columns = [
|
||||
{
|
||||
title: '上传状态',
|
||||
key: 'uploadStatus',
|
||||
width: 100,
|
||||
render: (row) => renderStatus(row.uploadStatus, uploadText),
|
||||
width: 125,
|
||||
render: (row) => {
|
||||
const requestId = row.uploadStatus === 'unconfirmed'
|
||||
? String(row.lastError || '').match(/requestId=([A-Za-z0-9_-]{1,80})/)?.[1] : ''
|
||||
return h('span', {
|
||||
title: row.uploadStatus === 'unconfirmed'
|
||||
? `视频状态无法确认,上传未提交${requestId ? `;请求编号:${requestId}` : ''}` : '',
|
||||
}, renderStatus(row.uploadStatus, uploadText))
|
||||
},
|
||||
},
|
||||
{ title: '创建时间', key: 'createdAt', width: 150 },
|
||||
{
|
||||
@@ -369,6 +379,7 @@ const uploadText = {
|
||||
running: ['上传中', 'primary'],
|
||||
done: ['已上传', 'ok'],
|
||||
failed: ['失败', 'bad'],
|
||||
unconfirmed: ['视频状态未确认', 'warn'],
|
||||
existing: ['已有视频', 'muted'],
|
||||
missing: ['缺少视频', 'warn'],
|
||||
invalid: ['视频不合规', 'bad'],
|
||||
@@ -620,12 +631,25 @@ function formatFileSize(size) {
|
||||
return `${(value / (1024 * 1024)).toFixed(2)} MB`
|
||||
}
|
||||
|
||||
function uploadPreviewStateUnknown(err) {
|
||||
try {
|
||||
const detail = JSON.parse(String(err))
|
||||
if (detail.status !== 502 || detail.errorCode !== 'HHH_UPSTREAM_ERROR' || detail.stage !== 'check') return null
|
||||
const requestId = typeof detail.requestId === 'string' && /^[A-Za-z0-9_-]{1,80}$/.test(detail.requestId)
|
||||
? detail.requestId : ''
|
||||
return { requestId }
|
||||
} catch (_) {
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
async function uploadSelectedVideo() {
|
||||
if (checkedIds.value.length === 0) {
|
||||
message.warning('请先勾选要上传的商品')
|
||||
return
|
||||
}
|
||||
try {
|
||||
uploadPreviewNotice.value = null
|
||||
// 使用 Wails 生成绑定的命名空间访问新方法;审核者生成绑定后即可直接使用。
|
||||
const preview = await AppBindings.GetUploadPreview([...checkedIds.value])
|
||||
dialog.warning({
|
||||
@@ -650,7 +674,12 @@ async function uploadSelectedVideo() {
|
||||
},
|
||||
})
|
||||
} catch (err) {
|
||||
message.error(`读取上传信息失败:${err}`)
|
||||
const unknown = uploadPreviewStateUnknown(err)
|
||||
if (unknown) {
|
||||
uploadPreviewNotice.value = unknown
|
||||
} else {
|
||||
message.error(`读取上传信息失败:${err}`)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -859,6 +888,18 @@ onUnmounted(() => {
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<n-alert
|
||||
v-if="uploadPreviewNotice"
|
||||
type="warning"
|
||||
title="视频状态无法确认,上传未提交"
|
||||
closable
|
||||
aria-live="assertive"
|
||||
@close="uploadPreviewNotice = null"
|
||||
>
|
||||
erpgo 无法确认该商品在货憨憨的当前视频状态。没有发送上传请求,本地 MP4 保留;稍后可重新尝试。
|
||||
<span v-if="uploadPreviewNotice.requestId">请求编号:{{ uploadPreviewNotice.requestId }}</span>
|
||||
</n-alert>
|
||||
|
||||
<n-alert
|
||||
v-if="productSyncResult"
|
||||
:type="productSyncResult.failedShops || productSyncResult.stopError ? 'warning' : productSyncResult.totalShops ? 'success' : 'info'"
|
||||
|
||||
Reference in New Issue
Block a user