using System; using System.Text.RegularExpressions; namespace AIProofread { public class Config { public static readonly string APP_NAME = "AI校对王"; #if DEBUG /// /// 网页访问地址 /// public static readonly string WEB_PATH = "http://localhost:5173/"; #else public static readonly string WEB_PATH = "dist/index.html"; #endif /// /// 词库地址 /// public static readonly string LEXICON_PATH = "https://gm.gachafun.com/lexicon"; public static readonly string WEB_DATA_PATH = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\ai_proofread\\userdata"; /// /// 书签前缀 /// public static readonly string BOOKMARK_NAME_PREFIX = "ai_proofread_"; private static readonly Regex regex = new Regex("^ai_proofread_\\d+$"); public static bool IsProofreadMark(string name) { return name != null && regex.IsMatch(name); } /// /// 获取书签名称 /// /// 校对提示id /// 书签名称 public static string BuildBookmarkName(int id) { return BOOKMARK_NAME_PREFIX + id; } /// /// 根据书签名称获取校对提示id /// /// 书签名称 /// 校对提示id public static int GetBookmarkIdByName(string name) { if (!IsProofreadMark(name)) return -1; return int.Parse(name.Substring(BOOKMARK_NAME_PREFIX.Length)); } /// /// 获取完整访问路径 /// /// /// public static string WebPath(string path) { return WEB_PATH + path; } } }