首次发布git
This commit is contained in:
@@ -0,0 +1,119 @@
|
||||
import { create } from "zustand";
|
||||
import { persist } from "zustand/middleware";
|
||||
|
||||
export interface AIPrompt {
|
||||
id: string;
|
||||
label: string;
|
||||
description: string;
|
||||
systemPrompt: string;
|
||||
}
|
||||
|
||||
export const defaultPrompts: AIPrompt[] = [
|
||||
{
|
||||
id: "improve",
|
||||
label: "润色内容",
|
||||
description: "提升语言表达质量",
|
||||
systemPrompt: "你是专业的写作润色助手。请优化以下文本,使其更流畅、专业,具有吸引力,同时保持原意。请直接输出优化后的文本,不要包含任何解释或'优化后'等前缀。",
|
||||
},
|
||||
{
|
||||
id: "complete",
|
||||
label: "续写内容",
|
||||
description: "基于上下文自动续写",
|
||||
systemPrompt: "你是富有创意的写作助手。请根据以下上下文逻辑,自然地续写一段内容,风格与前文保持一致。",
|
||||
},
|
||||
{
|
||||
id: "summarize",
|
||||
label: "生成摘要",
|
||||
description: "提取核心观点",
|
||||
systemPrompt: "你是专业的文档总结助手。请为以下文本生成一份简明扼要的摘要,提取核心观点,使用中文回答。",
|
||||
},
|
||||
];
|
||||
|
||||
interface SettingsState {
|
||||
fontFamily: string;
|
||||
fontSize: number; // in pixels (e.g. 16)
|
||||
lineHeight: number; // e.g. 1.5
|
||||
tableLineHeight: number; // e.g. 1.2
|
||||
timezone: string;
|
||||
|
||||
// AI Config
|
||||
aiConfig: {
|
||||
apiKey: string;
|
||||
baseURL: string;
|
||||
model: string;
|
||||
};
|
||||
|
||||
// Custom Prompts
|
||||
prompts: AIPrompt[];
|
||||
|
||||
setFontFamily: (font: string) => void;
|
||||
setFontSize: (size: number) => void;
|
||||
setLineHeight: (height: number) => void;
|
||||
setTableLineHeight: (height: number) => void;
|
||||
setTimezone: (timezone: string) => void;
|
||||
setAIConfig: (config: Partial<{ apiKey: string; baseURL: string; model: string }>) => void;
|
||||
|
||||
// Prompt Actions
|
||||
setPrompts: (prompts: AIPrompt[]) => void;
|
||||
addPrompt: (prompt: AIPrompt) => void;
|
||||
updatePrompt: (id: string, prompt: Partial<AIPrompt>) => void;
|
||||
deletePrompt: (id: string) => void;
|
||||
resetPrompts: () => void;
|
||||
}
|
||||
|
||||
export const useSettingsStore = create<SettingsState>()(
|
||||
persist(
|
||||
(set) => ({
|
||||
fontFamily: "Inter", // Default
|
||||
fontSize: 16,
|
||||
lineHeight: 1.5,
|
||||
tableLineHeight: 1.2,
|
||||
timezone: "Asia/Shanghai",
|
||||
|
||||
aiConfig: {
|
||||
apiKey: "",
|
||||
baseURL: "https://api.openai.com/v1",
|
||||
model: "gpt-3.5-turbo",
|
||||
},
|
||||
|
||||
prompts: defaultPrompts,
|
||||
|
||||
setFontFamily: (font) => set({ fontFamily: font }),
|
||||
setFontSize: (size) => set({ fontSize: size }),
|
||||
setLineHeight: (height) => set({ lineHeight: height }),
|
||||
setTableLineHeight: (height) => set({ tableLineHeight: height }),
|
||||
setTimezone: (timezone) => set({ timezone }),
|
||||
setAIConfig: (config) => set((state) => ({ aiConfig: { ...state.aiConfig, ...config } })),
|
||||
|
||||
setPrompts: (prompts) => set({ prompts }),
|
||||
addPrompt: (prompt) => set((state) => ({ prompts: [...state.prompts, prompt] })),
|
||||
updatePrompt: (id, prompt) => set((state) => ({
|
||||
prompts: state.prompts.map((p) => (p.id === id ? { ...p, ...prompt } : p)),
|
||||
})),
|
||||
deletePrompt: (id) => set((state) => ({ prompts: state.prompts.filter((p) => p.id !== id) })),
|
||||
resetPrompts: () => set({ prompts: defaultPrompts }),
|
||||
}),
|
||||
{
|
||||
name: "noteai-settings",
|
||||
}
|
||||
)
|
||||
);
|
||||
|
||||
export const fontOptions = [
|
||||
{ label: "Default (Inter)", value: "Inter" },
|
||||
{ label: "Serif", value: "serif" },
|
||||
{ label: "Mono", value: "monospace" },
|
||||
{ label: "System", value: "system-ui" },
|
||||
];
|
||||
|
||||
export const timezoneOptions = [
|
||||
{ label: "UTC", value: "UTC" },
|
||||
{ label: "Shanghai (UTC+8)", value: "Asia/Shanghai" },
|
||||
{ label: "Tokyo (UTC+9)", value: "Asia/Tokyo" },
|
||||
{ label: "New York (UTC-5/EDT)", value: "America/New_York" },
|
||||
{ label: "London (UTC+0/BST)", value: "Europe/London" },
|
||||
{ label: "Paris (UTC+1/CEST)", value: "Europe/Paris" },
|
||||
{ label: "Sydney (UTC+10/AEST)", value: "Australia/Sydney" },
|
||||
{ label: "Dubai (UTC+4)", value: "Asia/Dubai" },
|
||||
{ label: "Los Angeles (UTC-8/PDT)", value: "America/Los_Angeles" },
|
||||
];
|
||||
Reference in New Issue
Block a user