File size: 1,490 Bytes
7fc5208 025b1cc 7fc5208 025b1cc 7fc5208 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
import { API_BASE_URL, getHeaders, handleResponse } from './util';
export interface EmailMonitorConfig {
/** 监控的邮箱地址 */
email: string;
/** 上次邮件时间戳 (用于判断新邮件) */
lastEmailTimestamp: string;
/** 检查间隔 (分钟) */
checkInterval: number;
/** 上次检查时间 */
lastCheckTime?: string;
/** 上次邮件ID */
lastEmailId?: string;
}
export interface Settings {
/** 飞书配置 */
feishu: {
/** 飞书应用ID */
app_id: string;
/** 飞书应用密钥 */
app_secret: string;
/** 飞书应用验证Token */
verification_token: string;
/** 飞书应用加密Key */
encrypt_key: string;
/** 飞书机器人接收ID */
receive_id: string;
};
/** 邮箱监控配置 */
emailMonitor?: EmailMonitorConfig[];
}
export const settingApi = {
async update(settings: Settings) {
const response = await fetch(
`${API_BASE_URL}/api/setting`,
{
headers: getHeaders(),
method: 'POST',
body: JSON.stringify(settings)
}
);
return handleResponse(response);
},
async get(): Promise<Settings> {
const response = await fetch(
`${API_BASE_URL}/api/setting`,
{
headers: getHeaders()
}
);
return handleResponse(response);
},
} |