feat: add login background darken factor

This commit is contained in:
Esing
2026-05-12 22:12:02 +08:00
parent edba6b80d3
commit 22c35119c0
8 changed files with 65 additions and 7 deletions

View File

@@ -24,6 +24,7 @@ export const setting = sqliteTable('setting', {
ruleEmail: text('rule_email').default('').notNull(),
ruleType: integer('rule_type').default(0).notNull(),
loginOpacity: integer('login_opacity').default(0.88),
loginDarkenFactor: integer('login_darken_factor').default(0),
resendTokens: text('resend_tokens').default("{}").notNull(),
noticeTitle: text('notice_title').default('').notNull(),
noticeContent: text('notice_content').default('').notNull(),

View File

@@ -29,10 +29,19 @@ const dbInit = {
await this.v2_8DB(c);
await this.v2_9DB(c);
await this.v3_0DB(c);
await this.v3_1DB(c);
await settingService.refresh(c);
return c.text('success');
},
async v3_1DB(c) {
try {
await c.env.db.prepare(`ALTER TABLE setting ADD COLUMN login_darken_factor INTEGER NOT NULL DEFAULT 0;`).run();
} catch (e) {
console.warn(`跳过字段:${e.message}`);
}
},
async v3_0DB(c) {
try {
await c.env.db.batch([

View File

@@ -138,6 +138,11 @@ const settingService = {
params.aiCodeFilter = params.aiCodeFilter + '';
}
if (params.loginDarkenFactor !== undefined) {
const factor = Number(params.loginDarkenFactor);
params.loginDarkenFactor = Number.isNaN(factor) ? 0 : Math.min(1, Math.max(0, factor));
}
params.resendTokens = JSON.stringify(resendTokens);
await orm(c).update(setting).set({ ...params }).returning().get();
await this.refresh(c);
@@ -214,6 +219,7 @@ const settingService = {
siteKey: settingRow.siteKey,
background: settingRow.background,
loginOpacity: settingRow.loginOpacity,
loginDarkenFactor: settingRow.loginDarkenFactor,
domainList: settingRow.loginDomain === 1 && !token ? [] : settingRow.domainList,
regKey: settingRow.regKey,
regVerifyOpen: settingRow.regVerifyOpen,