Skip to content

Commit 54c44a2

Browse files
committed
fix: 性能优化
1 parent c48c5fc commit 54c44a2

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

frontend/src/utils/file.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ export const getKey = (path: string) =>
4444
.replace(/\./g, '_')
4545

4646
export const getEncodeValue = (buffer: ArrayBuffer) => {
47-
const encode: string[] = []
47+
let encode = 'utf-8'
4848

4949
for (const item of ENCODING_OPTIONS) {
5050
try {
@@ -61,11 +61,12 @@ export const getEncodeValue = (buffer: ArrayBuffer) => {
6161
}
6262
}
6363

64-
encode.push(item.value)
64+
encode = item.value
65+
break
6566
} catch {
6667
continue
6768
}
6869
}
6970

70-
return { encode: encode[0] || 'utf8', value: new TextDecoder(encode[0] || 'utf8').decode(buffer) }
71+
return { encode, value: new TextDecoder(encode).decode(buffer) }
7172
}

0 commit comments

Comments
 (0)