🐛 fix(frontend): 修复上传进度与八位取件码输入

This commit is contained in:
orion committed 2026-09-18 16:02:49 +08:00
1 parent 988ae2429d
commit 7c6119b0c9
7 files changed
+28 -5

No files matched your search

+2 -2
View File
@@ -25,7 +25,7 @@
required required
:aria-invalid="error" :aria-invalid="error"
:readonly="inputStatus.readonly" :readonly="inputStatus.readonly"
maxlength="5" maxlength="8"
@focus="isInputFocused = true" @focus="isInputFocused = true"
@blur="isInputFocused = false" @blur="isInputFocused = false"
/> />
@@ -46,7 +46,7 @@
<button <button
type="submit" type="submit"
class="fcb-action fcb-button-primary group relative w-full overflow-hidden rounded-lg bg-gradient-to-r from-indigo-500 via-purple-500 to-pink-500 px-4 py-3 font-bold text-white transition duration-300 hover:from-indigo-600 hover:via-purple-600 hover:to-pink-600 hover:shadow-lg focus:outline-none focus:ring-2 focus:ring-purple-500 focus:ring-opacity-50 disabled:cursor-not-allowed disabled:opacity-50 motion-safe:disabled:hover:scale-100" class="fcb-action fcb-button-primary group relative w-full overflow-hidden rounded-lg bg-gradient-to-r from-indigo-500 via-purple-500 to-pink-500 px-4 py-3 font-bold text-white transition duration-300 hover:from-indigo-600 hover:via-purple-600 hover:to-pink-600 hover:shadow-lg focus:outline-none focus:ring-2 focus:ring-purple-500 focus:ring-opacity-50 disabled:cursor-not-allowed disabled:opacity-50 motion-safe:disabled:hover:scale-100"
:disabled="inputStatus.loading || code.trim().length !== 5" :disabled="inputStatus.loading || ![5, 8].includes(code.trim().length)"
> >
<span class="flex items-center justify-center relative z-10"> <span class="flex items-center justify-center relative z-10">
<span>{{ inputStatus.loading ? t('common.loading') : t('retrieve.submit') }}</span> <span>{{ inputStatus.loading ? t('common.loading') : t('retrieve.submit') }}</span>
+1 -1
View File
@@ -36,7 +36,7 @@ export function useRetrieveFlow() {
const renderedContent = ref('') const renderedContent = ref('')
const normalizedCode = computed(() => code.value.trim()) const normalizedCode = computed(() => code.value.trim())
const isWorking = computed(() => isInspecting.value || isRetrieving.value) const isWorking = computed(() => isInspecting.value || isRetrieving.value)
const hasValidCode = computed(() => normalizedCode.value.length === 5) const hasValidCode = computed(() => [5, 8].includes(normalizedCode.value.length))
const formatFileSize = (bytes: number) => { const formatFileSize = (bytes: number) => {
if (bytes === 0) return '0 ' + t('fileSize.bytes') if (bytes === 0) return '0 ' + t('fileSize.bytes')
+1 -1
View File
@@ -87,7 +87,7 @@ export const uploadChunkedFile = async (
} }
const start = index * chunkSize const start = index * chunkSize
const end = Math.min(start + CHUNK_SIZE, file.size) const end = Math.min(start + chunkSize, file.size)
const chunk = file.slice(start, end) const chunk = file.slice(start, end)
const chunkResponse = await FileService.uploadChunk( const chunkResponse = await FileService.uploadChunk(
uploadId, uploadId,
+1 -1
View File
@@ -106,7 +106,7 @@ onMounted(() => {
}) })
watch(code, (newCode) => { watch(code, (newCode) => {
if (newCode.length === 5) { if ([5, 8].includes(newCode.length)) {
void handleSubmit() void handleSubmit()
} }
}) })
+4
View File
@@ -26,6 +26,8 @@
:selected-file="selectedFile" :selected-file="selectedFile"
:selected-files="selectedFiles" :selected-files="selectedFiles"
:progress="uploadProgress" :progress="uploadProgress"
:uploaded-bytes="uploadedBytes"
:total-bytes="totalBytes"
:disabled="isSubmitting" :disabled="isSubmitting"
:upload-status="isFinalizing ? 'confirming' : isSubmitting ? 'uploading' : 'idle'" :upload-status="isFinalizing ? 'confirming' : isSubmitting ? 'uploading' : 'idle'"
:description="uploadDescription" :description="uploadDescription"
@@ -161,6 +163,8 @@ const {
expirationMethod, expirationMethod,
expirationValue, expirationValue,
uploadProgress, uploadProgress,
uploadedBytes,
totalBytes,
showDrawer, showDrawer,
selectedRecord, selectedRecord,
isSubmitting, isSubmitting,
+1
View File
@@ -0,0 +1 @@
export function saveAs() { throw new Error('Browser download is not used in SSR layout tests') }
+18
View File
@@ -0,0 +1,18 @@
import {test,before,after} from 'node:test'
import assert from 'node:assert/strict'
import {createServer} from 'vite'
import {fileURLToPath} from 'node:url'
import {createSSRApp,h} from 'vue'
import {renderToString} from 'vue/server-renderer'
import {createI18n} from 'vue-i18n'
let server,Area,Detail,zh,originalWindow
before(async()=>{originalWindow=globalThis.window;globalThis.window={location:{origin:'https://test.example'}};server=await createServer({resolve:{alias:{'file-saver':fileURLToPath(new URL('./fixtures/browser-save.stub.mjs',import.meta.url))}},server:{middlewareMode:true,watch:null},appType:'custom'});Area=(await server.ssrLoadModule('/src/components/common/FileUploadArea.vue')).default;Detail=(await server.ssrLoadModule('/src/components/common/FileDetailModal.vue')).default;zh=(await server.ssrLoadModule('/src/i18n/locales/zh-CN.ts')).default})
after(async()=>{await server?.close();globalThis.window=originalWindow})
async function render(component,props){const context={};const app=createSSRApp({render:()=>h(component,props)});app.use(createI18n({legacy:false,locale:'zh-CN',messages:{'zh-CN':zh}}));return (await renderToString(app,context))+Object.values(context.teleports||{}).join('')}
test('upload area displays actual bytes while sending and verifying',async()=>{
for(const uploadStatus of ['uploading','confirming']){const html=await render(Area,{uploadStatus,uploadedBytes:52428800,totalBytes:104857600,progress:50});assert.ok(html.includes('50 MB / 100 MB'));assert.ok(!html.includes('0 B / 0 B'))}
})
test('retrieval detail uses accessible shared dialog and exposes entire long filename',async()=>{
const filename='FlClash-'+'long-'.repeat(25)+'android-arm64-v8a.apk';const html=await render(Detail,{visible:true,record:{filename,size:'51.58 MB',date:'2026/09/18 15:08:09',code:'ABCD2345',downloadUrl:'/share/download?code=ABCD2345'}})
assert.ok(html.includes('role="dialog"'));assert.ok(html.includes(filename));assert.ok(html.includes('aria-modal="true"'));assert.ok(html.includes('点击下载'))
})