新增渠道更新

This commit is contained in:
cc
2026-04-02 22:14:46 +08:00
parent 4a13d3209b
commit 54ed35ffb3
8 changed files with 794 additions and 39 deletions

View File

@@ -58,6 +58,7 @@ export const CONFIG_KEYS = {
// 更新
IGNORED_UPDATE_VERSION: 'ignoredUpdateVersion',
UPDATE_CHANNEL: 'updateChannel',
// 通知
NOTIFICATION_ENABLED: 'notificationEnabled',
@@ -96,6 +97,7 @@ export interface ExportDefaultMediaConfig {
export type WindowCloseBehavior = 'ask' | 'tray' | 'quit'
export type QuoteLayout = 'quote-top' | 'quote-bottom'
export type UpdateChannel = 'stable' | 'preview' | 'dev'
const DEFAULT_EXPORT_MEDIA_CONFIG: ExportDefaultMediaConfig = {
images: true,
@@ -1381,6 +1383,18 @@ export async function setIgnoredUpdateVersion(version: string): Promise<void> {
await config.set(CONFIG_KEYS.IGNORED_UPDATE_VERSION, version)
}
// 获取更新渠道(空值/auto 视为未显式设置,交由安装包类型决定默认渠道)
export async function getUpdateChannel(): Promise<UpdateChannel | null> {
const value = await config.get(CONFIG_KEYS.UPDATE_CHANNEL)
if (value === 'stable' || value === 'preview' || value === 'dev') return value
return null
}
// 设置更新渠道
export async function setUpdateChannel(channel: UpdateChannel): Promise<void> {
await config.set(CONFIG_KEYS.UPDATE_CHANNEL, channel)
}
// 获取通知开关
export async function getNotificationEnabled(): Promise<boolean> {
const value = await config.get(CONFIG_KEYS.NOTIFICATION_ENABLED)