update: 2026-03-28 20:59

This commit is contained in:
2026-03-28 20:59:52 +08:00
parent e21d58e603
commit 1c81d4e6ea
611 changed files with 27847 additions and 65061 deletions

View File

@@ -53,7 +53,9 @@
</main>
</div>
<script src="/aimodelapp/shared/ai-prompts.js"></script>
<script src="env.js"></script>
<script src="/aimodelapp/shared/ai-chat.js"></script>
<script src="script.js"></script>
</body>
</html>

View File

@@ -35,28 +35,22 @@ function clearResults() {
}
async function callKinshipAPI(relationChain) {
const token = window.AUTH_CONFIG.getToken();
if (!token) throw new Error('未登录请先登录后使用AI功能');
const url = `${window.API_CONFIG.baseUrl}${window.API_CONFIG.endpoints.kinshipCalculator}`;
const resp = await fetch(url, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': `Bearer ${token}`
},
body: JSON.stringify({ relation_chain: relationChain })
});
if (!resp.ok) {
if (resp.status === 402) throw new Error('您的萌芽币余额不足,无法使用此功能');
const err = await resp.json().catch(() => ({}));
throw new Error(err.error || `API请求失败: ${resp.status} ${resp.statusText}`);
const content = await window.AiChat.complete([
{ role: 'user', content: window.AiPrompts.kinship(relationChain) },
]);
var parsed;
try {
parsed = JSON.parse(content);
} catch (e) {
var m = content.match(/\{[\s\S]*\}/);
parsed = m ? JSON.parse(m[0]) : {};
}
const data = await resp.json();
if (!data.success) throw new Error(data.error || 'API响应异常');
return data;
return {
success: true,
mandarin_title: parsed.mandarin_title,
dialect_titles: parsed.dialect_titles,
notes: parsed.notes,
};
}
function renderDialects(dialectTitles) {