fix(api): 引入 TextDecoder(gbk) 解决腾讯接口中文乱码,并在前端表单锁定币种联动字段

This commit is contained in:
kennethcheng 2026-04-28 13:10:59 +08:00
parent ea57b4629a
commit 80029817a9
3 changed files with 5 additions and 3 deletions

View File

@ -29,7 +29,9 @@ export async function syncAllStockPrices() {
try {
const tCode = getTencentSymbol(asset);
const response = await fetch(`https://qt.gtimg.cn/q=${tCode}`, { cache: 'no-store' });
const text = await response.text();
const arrayBuffer = await response.arrayBuffer();
const decoder = new TextDecoder('gbk');
const text = decoder.decode(arrayBuffer);
const match = text.match(/="([^"]+)"/);
if (match && match[1]) {

View File

@ -174,7 +174,7 @@ export function AddAssetDialog() {
<FormItem>
<FormLabel></FormLabel>
<FormControl>
<Input placeholder="例如: USD" {...field} />
<Input placeholder="例如: USD" {...field} disabled className="bg-muted" />
</FormControl>
<FormMessage />
</FormItem>

View File

@ -239,7 +239,7 @@ export function AddTransactionDialog({ assets }: AddTransactionDialogProps) {
render={({ field }) => (
<FormItem>
<FormLabel></FormLabel>
<Select onValueChange={field.onChange} defaultValue={field.value}>
<Select disabled onValueChange={field.onChange} defaultValue={field.value}>
<FormControl>
<SelectTrigger>
<SelectValue placeholder="选择币种" />