chore: 初始化仓库,导入项目基线代码
Academy v0.8.3 完整代码基线:Go 后端(internal/cmd/cli/mcp-server/docreader)、 Vue 前端(frontend)、数据库迁移(migrations)、部署编排(docker/helm/deploy)与文档。 今日开发的培训推送管理改动随后单独提交。
This commit is contained in:
commit
7ec21f35b0
5767 files changed
+1436788
No files matched your search
@@ -0,0 +1,54 @@
|
||||
const STORAGE_KEY = "academy_settings";
|
||||
|
||||
function normalizeBaseUrl(baseUrl) {
|
||||
if (!baseUrl || typeof baseUrl !== "string") {
|
||||
return "";
|
||||
}
|
||||
|
||||
return baseUrl.trim().replace(/\/+$/, "");
|
||||
}
|
||||
|
||||
function normalizeLocale(locale) {
|
||||
return locale === "en" ? "en" : "zh";
|
||||
}
|
||||
|
||||
function getSettings() {
|
||||
const stored = wx.getStorageSync(STORAGE_KEY) || {};
|
||||
return {
|
||||
baseUrl: normalizeBaseUrl(stored.baseUrl || ""),
|
||||
apiKey: stored.apiKey || "",
|
||||
selectedKnowledgeBaseId: stored.selectedKnowledgeBaseId || "",
|
||||
locale: normalizeLocale(stored.locale || "zh")
|
||||
};
|
||||
}
|
||||
|
||||
function saveSettings(settings) {
|
||||
const current = getSettings();
|
||||
const nextBaseUrl =
|
||||
settings.baseUrl !== undefined && settings.baseUrl !== null
|
||||
? settings.baseUrl
|
||||
: current.baseUrl;
|
||||
const nextLocale =
|
||||
settings.locale !== undefined && settings.locale !== null
|
||||
? settings.locale
|
||||
: current.locale;
|
||||
const next = {
|
||||
baseUrl: normalizeBaseUrl(nextBaseUrl),
|
||||
apiKey: settings.apiKey !== undefined ? settings.apiKey : current.apiKey,
|
||||
selectedKnowledgeBaseId:
|
||||
settings.selectedKnowledgeBaseId !== undefined
|
||||
? settings.selectedKnowledgeBaseId
|
||||
: current.selectedKnowledgeBaseId,
|
||||
locale: normalizeLocale(nextLocale)
|
||||
};
|
||||
wx.setStorageSync(STORAGE_KEY, next);
|
||||
return next;
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
STORAGE_KEY,
|
||||
getSettings,
|
||||
normalizeBaseUrl,
|
||||
normalizeLocale,
|
||||
saveSettings
|
||||
};
|
||||
Reference in new issue
Block a user