fix(api): 引入 TextDecoder(gbk) 解决腾讯接口中文乱码,并在前端表单锁定币种联动字段
This commit is contained in:
parent
ea57b4629a
commit
80029817a9
@ -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]) {
|
||||
|
||||
@ -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>
|
||||
|
||||
@ -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="选择币种" />
|
||||
|
||||
Loading…
Reference in New Issue
Block a user