fix(server): 每次启动重新计算设备特征码,环境变化时自动更新
This commit is contained in:
@@ -12,13 +12,21 @@ export const getUxConfig = async (db: DB) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const ensureUxConfig = async (db: DB) => {
|
export const ensureUxConfig = async (db: DB) => {
|
||||||
|
const fingerprint = await computeDeviceFingerprint()
|
||||||
const existing = await getUxConfig(db)
|
const existing = await getUxConfig(db)
|
||||||
|
|
||||||
if (existing) {
|
if (existing) {
|
||||||
|
if (existing.fingerprint !== fingerprint) {
|
||||||
|
const rows = await db
|
||||||
|
.update(uxConfigTable)
|
||||||
|
.set({ fingerprint })
|
||||||
|
.where(eq(uxConfigTable.id, existing.id))
|
||||||
|
.returning()
|
||||||
|
return rows[0] as (typeof rows)[number]
|
||||||
|
}
|
||||||
return existing
|
return existing
|
||||||
}
|
}
|
||||||
|
|
||||||
const fingerprint = await computeDeviceFingerprint()
|
|
||||||
const rows = await db
|
const rows = await db
|
||||||
.insert(uxConfigTable)
|
.insert(uxConfigTable)
|
||||||
.values({
|
.values({
|
||||||
|
|||||||
Reference in New Issue
Block a user