An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作
TypeScript agentic-aiai-agentknowledge-baselocal-firstmarkdownmcpmindmapnote-takingself-hostedsiyuanworkspace
export interface IBodyGradient {
mode: "auto" | "custom" | "off";
light: {color: string; opacity: number};
dark: {color: string; opacity: number};
}
export const normalizeBodyGradient = (value?: {mode?: string; light?: IBodyGradient["light"]; dark?: IBodyGradient["dark"]}): IBodyGradient => {
const normalizeColor = (color?: IBodyGradient["light"]) => ({
color: /^#[\da-f]{6}$/i.test(color?.color || "") ? color.color : "#9d12e2",
opacity: typeof color?.opacity === "number" && Number.isFinite(color.opacity) ?
Math.max(0, Math.min(100, color.opacity)) : 12,
});
return {
mode: value?.mode === "custom" || value?.mode === "off" ? value.mode : "auto",
light: normalizeColor(value?.light),
dark: normalizeColor(value?.dark),
};
};
export const getBodyGradientImage = (value: Parameters<typeof normalizeBodyGradient>[0], theme: "light" | "dark"): string => {
const config = normalizeBodyGradient(value);
if (config.mode === "auto") {
return "";
}
if (config.mode === "off") {
return "none";
}
const {color, opacity} = config[theme];
const rgb = [1, 3, 5].map(index => parseInt(color.slice(index, index + 2), 16));
return `radial-gradient(ellipse 45% 20% at 0% 0%, rgba(${rgb.join(", ")}, ${opacity / 100}) 0%, transparent 100%)`;
};