实现了服务号的推送以及未读

This commit is contained in:
xuncha
2026-04-12 08:03:12 +08:00
parent f89ad6ec15
commit f2f78bb4e2
10 changed files with 857 additions and 46 deletions

View File

@@ -72,6 +72,8 @@ export const CONFIG_KEYS = {
HTTP_API_PORT: 'httpApiPort',
HTTP_API_HOST: 'httpApiHost',
MESSAGE_PUSH_ENABLED: 'messagePushEnabled',
MESSAGE_PUSH_FILTER_MODE: 'messagePushFilterMode',
MESSAGE_PUSH_FILTER_LIST: 'messagePushFilterList',
WINDOW_CLOSE_BEHAVIOR: 'windowCloseBehavior',
QUOTE_LAYOUT: 'quoteLayout',
@@ -1505,6 +1507,29 @@ export async function setMessagePushEnabled(enabled: boolean): Promise<void> {
await config.set(CONFIG_KEYS.MESSAGE_PUSH_ENABLED, enabled)
}
export type MessagePushFilterMode = 'all' | 'whitelist' | 'blacklist'
export type MessagePushSessionType = 'private' | 'group' | 'official' | 'other'
export async function getMessagePushFilterMode(): Promise<MessagePushFilterMode> {
const value = await config.get(CONFIG_KEYS.MESSAGE_PUSH_FILTER_MODE)
if (value === 'whitelist' || value === 'blacklist') return value
return 'all'
}
export async function setMessagePushFilterMode(mode: MessagePushFilterMode): Promise<void> {
await config.set(CONFIG_KEYS.MESSAGE_PUSH_FILTER_MODE, mode)
}
export async function getMessagePushFilterList(): Promise<string[]> {
const value = await config.get(CONFIG_KEYS.MESSAGE_PUSH_FILTER_LIST)
return Array.isArray(value) ? value.map(item => String(item || '').trim()).filter(Boolean) : []
}
export async function setMessagePushFilterList(list: string[]): Promise<void> {
const normalized = Array.from(new Set((list || []).map(item => String(item || '').trim()).filter(Boolean)))
await config.set(CONFIG_KEYS.MESSAGE_PUSH_FILTER_LIST, normalized)
}
export async function getWindowCloseBehavior(): Promise<WindowCloseBehavior> {
const value = await config.get(CONFIG_KEYS.WINDOW_CLOSE_BEHAVIOR)
if (value === 'tray' || value === 'quit') return value