1. 在 `Config.cs` 中新增多个环境常量字符串: - 新增 `ALL_IN_ONE`、`PRE` 和新的 `PROD` 常量。 - 删除旧的 `PROD` 常量,原值为 `"http://aijdw1.goldmye.com/"`。 2. 调整 `WEB_PATH` 的值: - `#if DEBUG` 下改为 `AppServer.PRE`。 - 非 `DEBUG` 下保持为 `AppServer.PROD`。 3. 在 `Tools.cs` 中注释掉两行 `Debug.WriteLine` 调试代码,减少不必要的调试输出。
113 lines
4.0 KiB
C#
113 lines
4.0 KiB
C#
using System;
|
|
using System.Text.RegularExpressions;
|
|
|
|
namespace AIProofread
|
|
{
|
|
public enum AppEnvironment
|
|
{
|
|
Dev,
|
|
Test,
|
|
Prod
|
|
}
|
|
|
|
public class AppServer
|
|
{
|
|
/// <summary>
|
|
/// 开发环境
|
|
/// </summary>
|
|
public const string DEV = "http://localhost:5173/";
|
|
/// <summary>
|
|
/// 一体机
|
|
/// </summary>
|
|
public const string ALL_IN_ONE = "http://112.48.25.226:89/";
|
|
/// <summary>
|
|
/// 果麦预发布环境
|
|
/// </summary>
|
|
public const string PRE = "https://pre-gm-plugin.gachafun.com/";
|
|
/// <summary>
|
|
/// 果麦生产环境
|
|
/// </summary>
|
|
public const string PROD = "https://gm-plugin.gachafun.com/";
|
|
/// <summary>
|
|
/// 测试环境
|
|
/// </summary>
|
|
public const string TEST = "http://tt-plugin.zverse.group/";
|
|
}
|
|
public class Config
|
|
{
|
|
public static readonly string APP_NAME = "AI校对王";
|
|
public static readonly string APP_VERSION = "2.2.5";
|
|
public static readonly string BuildVersion = "20250509_1656";
|
|
public static bool IS_WPS = false;
|
|
public static bool UpgradeForcedNotice = false;
|
|
public static readonly string APP_BASE_DIR = AppDomain.CurrentDomain.BaseDirectory;
|
|
public static readonly string CONFIG_FILE = AppDomain.CurrentDomain.BaseDirectory + "app.json";
|
|
public static string USER_MANUAL_URL = "https://aiprhelp.guomai.cn/";
|
|
/// <summary>
|
|
/// 文本背景色
|
|
/// </summary>
|
|
public static readonly string TextBackgroundColor = "#E9DABB"; // e9dabb D6AA69
|
|
public static string DeviceId = "";
|
|
|
|
|
|
#if DEBUG
|
|
/// <summary>
|
|
/// 网页访问地址
|
|
/// </summary>
|
|
public static string WEB_PATH = AppServer.PRE; //pre-gm-plugin.gachafun.com localhost:5173 gm2-plugin.zverse.group
|
|
public static bool RUN_IN_DEBUG = true;
|
|
public static AppEnvironment APP_ENV = AppEnvironment.Prod;
|
|
#else
|
|
public static string WEB_PATH = AppServer.PROD; // gm-plugin.gachafun.com pre-gm-plugin.gachafun.com
|
|
public static bool RUN_IN_DEBUG = false;
|
|
public static AppEnvironment APP_ENV = AppEnvironment.Prod;
|
|
#endif
|
|
|
|
public static readonly string APP_DATA_PATH = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\ai_proofread";
|
|
public static readonly string APP_LOG_PATH = APP_DATA_PATH + "\\logs\\";
|
|
public static readonly string WEB_DATA_PATH = APP_DATA_PATH + "\\userdata";
|
|
|
|
/// <summary>
|
|
/// 书签前缀
|
|
/// </summary>
|
|
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);
|
|
}
|
|
/// <summary>
|
|
/// 获取书签名称
|
|
/// </summary>
|
|
/// <param name="id">校对提示id</param>
|
|
/// <returns>书签名称</returns>
|
|
public static string BuildBookmarkName(int id)
|
|
{
|
|
return BOOKMARK_NAME_PREFIX + id;
|
|
}
|
|
/// <summary>
|
|
/// 根据书签名称获取校对提示id
|
|
/// </summary>
|
|
/// <param name="name">书签名称</param>
|
|
/// <returns>校对提示id</returns>
|
|
public static int GetBookmarkIdByName(string name)
|
|
{
|
|
if (!IsProofreadMark(name)) return -1;
|
|
return int.Parse(name.Substring(BOOKMARK_NAME_PREFIX.Length));
|
|
}
|
|
|
|
/// <summary>
|
|
/// 获取完整访问路径
|
|
/// </summary>
|
|
/// <param name="path"></param>
|
|
/// <returns></returns>
|
|
public static string WebPath(string path)
|
|
{
|
|
Random r = new Random();
|
|
return WEB_PATH + path + (path.IndexOf("?") == -1 ? "?":"&") + $"ver={APP_VERSION}&r=" + r.NextDouble();
|
|
}
|
|
}
|
|
}
|