chore: 初始化仓库,导入项目基线代码

Academy v0.8.3 完整代码基线:Go 后端(internal/cmd/cli/mcp-server/docreader)、
Vue 前端(frontend)、数据库迁移(migrations)、部署编排(docker/helm/deploy)与文档。
今日开发的培训推送管理改动随后单独提交。
This commit is contained in:
runny committed 2026-11-16 18:12:23 +08:00
commit 7ec21f35b0
5767 files changed
+1436788

No files matched your search

+99
View File
@@ -0,0 +1,99 @@
const { getSettings } = require("../../utils/config");
const { createSession, knowledgeChat } = require("../../utils/request");
const { collectAnswerFromSSE } = require("../../utils/sse");
const { applyNavTitle, applyTabBar, getMessages, t } = require("../../utils/i18n");
function buildViewModel() {
const messages = getMessages();
return {
chatTitle: messages.chatTitle,
chatSubtitle: messages.chatSubtitle,
questionLabel: messages.question,
questionPlaceholder: messages.questionPlaceholder,
askText: messages.askAcademy,
answerLabel: messages.answer
};
}
Page({
data: {
chatTitle: "知识问答",
chatSubtitle: "向当前选中的 Academy 知识库提问。",
questionLabel: "问题",
questionPlaceholder: "输入你的问题…",
askText: "向 Academy 提问",
answerLabel: "回答",
answer: "",
displayAnswer: "",
loading: false,
query: "",
rawResponse: "",
sessionId: ""
},
applyI18n() {
this.setData(buildViewModel());
},
onLoad() {
this.applyI18n();
},
onShow() {
try {
applyTabBar();
applyNavTitle("navChat");
this.applyI18n();
} catch (error) {
// keep fallback Chinese copy
}
},
onQueryInput(event) {
this.setData({ query: event.detail.value });
},
async ensureSession() {
if (this.data.sessionId) {
return this.data.sessionId;
}
const settings = getSettings();
const response = await createSession(settings.selectedKnowledgeBaseId);
const sessionId = response && response.data ? response.data.id : "";
if (!sessionId) {
throw new Error(t("sessionIdMissing"));
}
this.setData({ sessionId: sessionId });
return sessionId;
},
async ask() {
this.setData({ answer: "", rawResponse: "", displayAnswer: "", loading: true });
try {
const sessionId = await this.ensureSession();
const settings = getSettings();
const response = await knowledgeChat(
sessionId,
this.data.query.trim(),
settings.selectedKnowledgeBaseId
);
const rawResponse = typeof response === "string" ? response : JSON.stringify(response);
const answer = collectAnswerFromSSE(rawResponse);
const displayAnswer = answer || rawResponse;
this.setData({
answer: answer,
rawResponse: answer ? "" : rawResponse,
displayAnswer: displayAnswer
});
} catch (error) {
wx.showModal({
title: t("chatFailed"),
content: (error && error.message) || "",
showCancel: false
});
} finally {
this.setData({ loading: false });
}
}
});
+3
View File
@@ -0,0 +1,3 @@
{
"navigationBarTitleText": "问答"
}
+18
View File
@@ -0,0 +1,18 @@
<view class="page">
<view class="card">
<view class="title">{{chatTitle}}</view>
<view class="muted">{{chatSubtitle}}</view>
<view class="field">
<text class="label">{{questionLabel}}</text>
<textarea value="{{query}}" placeholder="{{questionPlaceholder}}" bindinput="onQueryInput" />
</view>
<button bindtap="ask" loading="{{loading}}" disabled="{{!query}}">{{askText}}</button>
</view>
<view class="card answer-card" wx:if="{{displayAnswer}}">
<view class="label">{{answerLabel}}</view>
<view class="answer">{{displayAnswer}}</view>
</view>
</view>
+10
View File
@@ -0,0 +1,10 @@
.answer-card {
margin-top: 28rpx;
}
.answer {
white-space: pre-wrap;
line-height: 1.7;
color: #1a1a1a;
font-size: 28rpx;
}