- 提交 world.html 及 assets/(地形贴图/背景/视频/js)、index/login/terrain_preview - world.html: 微观世界入场加载页重构为左下角提示药丸 + 全宽进度条 - 排除 .bak/__bak 备份文件(.gitignore)
43 lines
1.7 KiB
JavaScript
43 lines
1.7 KiB
JavaScript
// 宇森游戏 · 前端与 Odoo 通信层
|
||
// 所有接口同源(yt.pengyuthon.cn),由 nginx 代理 /game/* 到 Odoo(game 库)。
|
||
// 关键点:Odoo 通过 URL 上的 ?db=game 选定数据库(与 game.conf 的 /web/login?db=game 一致),
|
||
// 否则请求到达时未选中库,控制器路由找不到 → 404。因此所有调用都带 ?db=game。
|
||
// 登录态通过 Odoo session cookie 保持,fetch 带 credentials:'same-origin'。
|
||
|
||
const API = {
|
||
async me() {
|
||
return (await fetch('/game/api/me?db=game', { credentials: 'same-origin' })).json();
|
||
},
|
||
async login(login, password) {
|
||
return (await fetch('/game/api/login?db=game', {
|
||
method: 'POST', credentials: 'same-origin',
|
||
headers: { 'Content-Type': 'application/json' },
|
||
body: JSON.stringify({ login, password }),
|
||
})).json();
|
||
},
|
||
async register(payload) {
|
||
return (await fetch('/game/api/register?db=game', {
|
||
method: 'POST', credentials: 'same-origin',
|
||
headers: { 'Content-Type': 'application/json' },
|
||
body: JSON.stringify(payload),
|
||
})).json();
|
||
},
|
||
async logout() {
|
||
return (await fetch('/game/api/logout?db=game', {
|
||
method: 'POST', credentials: 'same-origin',
|
||
})).json();
|
||
},
|
||
async codex() {
|
||
return (await fetch('/game/api/codex?db=game', { credentials: 'same-origin' })).json();
|
||
},
|
||
async rules() {
|
||
return (await fetch('/game/api/rules?db=game', { credentials: 'same-origin' })).json();
|
||
},
|
||
async threads() {
|
||
return (await fetch('/game/api/threads?db=game', { credentials: 'same-origin' })).json();
|
||
},
|
||
async announcements() {
|
||
return (await fetch('/game/api/announcements?db=game', { credentials: 'same-origin' })).json();
|
||
},
|
||
};
|