fix(api): 引入 TextDecoder(gbk) 解决腾讯接口中文乱码,并在前端表单锁定币种联动字段
This commit is contained in:
parent
ea57b4629a
commit
80029817a9
@ -29,7 +29,9 @@ export async function syncAllStockPrices() {
|
|||||||
try {
|
try {
|
||||||
const tCode = getTencentSymbol(asset);
|
const tCode = getTencentSymbol(asset);
|
||||||
const response = await fetch(`https://qt.gtimg.cn/q=${tCode}`, { cache: 'no-store' });
|
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(/="([^"]+)"/);
|
const match = text.match(/="([^"]+)"/);
|
||||||
if (match && match[1]) {
|
if (match && match[1]) {
|
||||||
|
|||||||
@ -174,7 +174,7 @@ export function AddAssetDialog() {
|
|||||||
<FormItem>
|
<FormItem>
|
||||||
<FormLabel>基础币种</FormLabel>
|
<FormLabel>基础币种</FormLabel>
|
||||||
<FormControl>
|
<FormControl>
|
||||||
<Input placeholder="例如: USD" {...field} />
|
<Input placeholder="例如: USD" {...field} disabled className="bg-muted" />
|
||||||
</FormControl>
|
</FormControl>
|
||||||
<FormMessage />
|
<FormMessage />
|
||||||
</FormItem>
|
</FormItem>
|
||||||
|
|||||||
@ -239,7 +239,7 @@ export function AddTransactionDialog({ assets }: AddTransactionDialogProps) {
|
|||||||
render={({ field }) => (
|
render={({ field }) => (
|
||||||
<FormItem>
|
<FormItem>
|
||||||
<FormLabel>交易币种</FormLabel>
|
<FormLabel>交易币种</FormLabel>
|
||||||
<Select onValueChange={field.onChange} defaultValue={field.value}>
|
<Select disabled onValueChange={field.onChange} defaultValue={field.value}>
|
||||||
<FormControl>
|
<FormControl>
|
||||||
<SelectTrigger>
|
<SelectTrigger>
|
||||||
<SelectValue placeholder="选择币种" />
|
<SelectValue placeholder="选择币种" />
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user