88 lines
4.3 KiB
C++
88 lines
4.3 KiB
C++
#ifndef CONSTANTS_H
|
||
#define CONSTANTS_H
|
||
|
||
#include <QCoreApplication>
|
||
#include <QString>
|
||
|
||
// ============================================================================
|
||
// 项目公共常量 — 所有 URL、路径、文件名等配置集中于此,修改只需改一处
|
||
// ============================================================================
|
||
|
||
namespace Constants {
|
||
|
||
// ---------------------------------------------------------------------------
|
||
// 应用版本号(发版时只需修改此处)
|
||
// ---------------------------------------------------------------------------
|
||
namespace App {
|
||
constexpr char Version[] = "1.4.0";
|
||
}
|
||
|
||
// ---------------------------------------------------------------------------
|
||
// URL 常量
|
||
// ---------------------------------------------------------------------------
|
||
namespace Urls {
|
||
constexpr char Base[] = "http://10.20.163.105:6045";
|
||
|
||
inline QString updateInfo() { return QString::fromLatin1(Base) + "/download/uft3changecode/update_info.json"; }
|
||
inline QString downloadPage(){ return QString::fromLatin1(Base) + "/uft3changecode/下载.html"; }
|
||
inline QString helpPage() { return QString::fromLatin1(Base) + "/uft3changecode"; }
|
||
}
|
||
|
||
// ---------------------------------------------------------------------------
|
||
// 目录 / 文件路径常量(相对于 exe 目录的子路径名称)
|
||
// ---------------------------------------------------------------------------
|
||
namespace Paths {
|
||
inline const QString ToolDir = "uf2touft3"; // 工具主目录
|
||
inline const QString LogDir = "logs"; // 日志目录
|
||
inline const QString CacheDir = "cache"; // 缓存目录
|
||
inline const QString ChangeCodeDir = "change_code"; // 代码检索根目录(toolDir 下)
|
||
inline const QString FunctionOutput = "function_output"; // 调用链/文件导出目录
|
||
}
|
||
|
||
// ---------------------------------------------------------------------------
|
||
// ToolDir 下的文件名
|
||
// ---------------------------------------------------------------------------
|
||
namespace ToolFiles {
|
||
inline const QString Exe = "uf2touft3.exe";
|
||
inline const QString ConfigIni = "config.ini";
|
||
inline const QString Uf2Json = "uf2.json";
|
||
inline const QString Uft3Json = "uft3.json";
|
||
inline const QString Uft3Trans = "uft3Trans.json";
|
||
inline const QString CustJson = "cust.json";
|
||
}
|
||
|
||
// ---------------------------------------------------------------------------
|
||
// Cache 相关
|
||
// ---------------------------------------------------------------------------
|
||
namespace Cache {
|
||
inline const QString DbFile = "config_cache.db";
|
||
}
|
||
|
||
// ---------------------------------------------------------------------------
|
||
// 运行时路径辅助函数(基于 applicationDirPath 拼接)
|
||
// ---------------------------------------------------------------------------
|
||
inline QString toolDir() { return QCoreApplication::applicationDirPath() + "/" + Paths::ToolDir; }
|
||
inline QString toolExe() { return toolDir() + "/" + ToolFiles::Exe; }
|
||
inline QString configIni() { return toolDir() + "/" + ToolFiles::ConfigIni; }
|
||
inline QString custJson() { return toolDir() + "/" + ToolFiles::CustJson; }
|
||
inline QString logDir() { return QCoreApplication::applicationDirPath() + "/" + Paths::LogDir; }
|
||
inline QString cacheDir() { return QCoreApplication::applicationDirPath() + "/" + Paths::CacheDir; }
|
||
inline QString cacheDb() { return cacheDir() + "/" + Cache::DbFile; }
|
||
|
||
// ---------------------------------------------------------------------------
|
||
// 代码检索(CodeSearch)相关常量与路径
|
||
// ---------------------------------------------------------------------------
|
||
namespace CodeSearch {
|
||
constexpr char ChangeCodeIni[] = "change_code.ini"; // 路径持久化配置文件名
|
||
constexpr char ConvertPathKey[] = "codeSearch/convertPath"; // QSettings 键:转码业务路径
|
||
constexpr char SearchPathKey[] = "codeSearch/searchPath"; // QSettings 键:非转码业务路径
|
||
}
|
||
|
||
inline QString changeCodeDir() { return toolDir() + "/" + Paths::ChangeCodeDir; } // 默认代码检索根目录
|
||
inline QString changeCodeIni() { return toolDir() + "/" + QString::fromLatin1(CodeSearch::ChangeCodeIni); }
|
||
inline QString functionOutput() { return Paths::FunctionOutput; } // 调用链/文件导出目录名
|
||
|
||
} // namespace Constants
|
||
|
||
#endif // CONSTANTS_H
|