24 lines
706 B
TypeScript
24 lines
706 B
TypeScript
import { DEFAULT_SETTINGS, RssUnionSettings } from "./plugin_settings";
|
||
|
||
/** 全局设置引用:main.ts 加载完写入,其余模块只读,避免各处 import main 造成循环依赖 */
|
||
let current: RssUnionSettings = Object.assign({}, DEFAULT_SETTINGS);
|
||
|
||
export function setSettings(next: RssUnionSettings) {
|
||
current = next;
|
||
}
|
||
|
||
export function getSettings(): RssUnionSettings {
|
||
return current;
|
||
}
|
||
|
||
/** 站点地址是否已经填了(授权码可以为空,验证时会单独提示) */
|
||
export function hasSite(): boolean {
|
||
return normalizeSiteUrl(current.siteUrl) !== "";
|
||
}
|
||
|
||
export function normalizeSiteUrl(raw: string): string {
|
||
return String(raw || "")
|
||
.trim()
|
||
.replace(/\/+$/, "");
|
||
}
|