scan the QR code to log in on the WeChat public account

This commit is contained in:
landaiqing
2024-08-15 23:57:12 +08:00
parent cab3b1ee96
commit 3140eaca99
11 changed files with 432 additions and 45 deletions

37
src/api/oauth/index.ts Normal file
View File

@@ -0,0 +1,37 @@
import {service} from "@/utils/alova/service.ts";
/**
* 生成客户端id
*/
export const generateClientId = () => {
return service.Get('/api/oauth/generate_client_id',
{
meta: {
ignoreToken: true,
}
}
);
};
/**
* 获取临时二维码
* @param clientId
*/
export const generateQrCode = (clientId: string) => {
return service.Get('/api/oauth/get_temp_qrcode',
{
params: {
client_id: clientId
},
meta: {
ignoreToken: true,
},
cacheFor: {
// 设置缓存模式为持久化模式
mode: 'restore',
// 缓存时间
expire: 30 * 24 * 60 * 60 * 1000,
tag: 'v1'
}
}
);
};