mirror of
https://github.com/ZZZure/ZZZ-Plugin.git
synced 2025-12-18 14:17:45 +00:00
fix:未绑定设备使用默认值
This commit is contained in:
parent
4913e524c9
commit
c71cb5a7f4
1 changed files with 57 additions and 39 deletions
|
|
@ -87,12 +87,13 @@ export class ZZZPlugin extends plugin {
|
||||||
return { api: null, uid: null, deviceFp: null };
|
return { api: null, uid: null, deviceFp: null };
|
||||||
}
|
}
|
||||||
// 获取设备指纹
|
// 获取设备指纹
|
||||||
let deviceFp = await redis.get(`ZZZ:DEVICE_FP:${ltuid}:FP`);
|
let deviceFp
|
||||||
let bindInfo = await redis.get(`ZZZ:DEVICE_FP:${ltuid}:BIND`);
|
let bindInfo = await redis.get(`ZZZ:DEVICE_FP:${ltuid}:BIND`);
|
||||||
|
if (bindInfo) {
|
||||||
|
deviceFp = await redis.get(`ZZZ:DEVICE_FP:${ltuid}:FP`);
|
||||||
let data = {
|
let data = {
|
||||||
deviceFp,
|
deviceFp,
|
||||||
};
|
};
|
||||||
if (bindInfo) {
|
|
||||||
try {
|
try {
|
||||||
bindInfo = JSON.parse(bindInfo);
|
bindInfo = JSON.parse(bindInfo);
|
||||||
data = {
|
data = {
|
||||||
|
|
@ -106,7 +107,6 @@ export class ZZZPlugin extends plugin {
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
bindInfo = null;
|
bindInfo = null;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if (!deviceFp) {
|
if (!deviceFp) {
|
||||||
const sdk = api.getUrl('getFp', data);
|
const sdk = api.getUrl('getFp', data);
|
||||||
const res = await request(sdk.url, {
|
const res = await request(sdk.url, {
|
||||||
|
|
@ -147,6 +147,24 @@ export class ZZZPlugin extends plugin {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
deviceFp = await redis.get(`ZZZ:DEVICE_FP:${uid}`);
|
||||||
|
if (!deviceFp) {
|
||||||
|
const sdk = api.getUrl('getFp');
|
||||||
|
const res = await fetch(sdk.url, {
|
||||||
|
headers: sdk.headers,
|
||||||
|
method: 'POST',
|
||||||
|
body: sdk.body,
|
||||||
|
});
|
||||||
|
const fpRes = await res.json();
|
||||||
|
deviceFp = fpRes?.data?.device_fp;
|
||||||
|
if (deviceFp) {
|
||||||
|
await redis.set(`ZZZ:DEVICE_FP:${uid}`, deviceFp, {
|
||||||
|
EX: 86400 * 7,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
// 返回数据(API、UID、设备指纹)
|
// 返回数据(API、UID、设备指纹)
|
||||||
return { api, uid, deviceFp };
|
return { api, uid, deviceFp };
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue