内容后台上线:网页里改网站内容(账号密码 + 首次强制改密 + 草稿/预览/发布/回滚 + 画展传图);新世界线自动排位;星球预设 18 种
- backend-site/cms.py(新):账号(scrypt 加盐哈希)、服务端会话(只存哈希,30 天滑动,可撤销)、 admin/admin 首次登录强制改密(改密前其它接口一律 403)、CSRF / 来源 / https / 登录冷却、 内容校验、发布写 content/ 与 prices.json / payinfo.json、版本与回滚、传图核验 + 去元数据 + ffmpeg 缩略图 - server.py 把 /api/cms/* 交给 cms.py;admin.py 加 user list/add/passwd/reset/disable/enable/sessions - portal/admin/(新):内容后台页面;门户顶栏加不带字的淡色铅笔入口 - 门户 / 下单页读 content/site.js、order/content/order.js(代码里的数据降级为兜底);?preview=1 预览草稿 - portal/assets/universe/layout.js(新):新点亮的世界线自动排到中圈不挤的位置、补给线接附近的星、已有的都不动 - planets.js:加 10 种卡通预设(类地 / 海洋 / 丛林 / 荒漠 / 冻原 / 熔岩 / 毒雾 / 荒芜岩球 / 冰巨星 / 带环巨星) - galaxy.js:名牌 / 档案卡文字一律转义 - tests/内容后台测试.py(75 条);回归 27 + 数据库 38 照旧全过;端到端浏览器 36 条 - 文档:交接文档-2026-10.md(变更 / 接口 / 部署 7.1b / 测试 / 第 10 节)、内容后台设计.md(实现对照)、星系图交接说明、nginx 片段 ④ Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -11,7 +11,8 @@
|
||||
* 返回 { fly(no), home(), resize() }。画面滚出视口时自动暂停渲染。
|
||||
* ============================================================================= */
|
||||
import * as THREE from 'three';
|
||||
import { makePlanet } from './planets.js?v=1';
|
||||
import { makePlanet } from './planets.js?v=2';
|
||||
import { layoutSystems } from './layout.js?v=2';
|
||||
|
||||
export function mountGalaxy(el) {
|
||||
const CFG = window.JZ_UNIVERSE, G = CFG.GALAXY, C = G.colors;
|
||||
@@ -29,6 +30,8 @@ export function mountGalaxy(el) {
|
||||
const rnd = (a = 0, b = 1) => a + Math.random() * (b - a);
|
||||
const gauss = () => { let u = 0, v = 0; while (!u) u = Math.random(); while (!v) v = Math.random(); return Math.sqrt(-2 * Math.log(u)) * Math.cos(2 * Math.PI * v); };
|
||||
const armAngle = (r, arm) => arm * Math.PI * 2 / ARMS + r * G.twist;
|
||||
// 名牌 / 档案卡里的文字一律转义(内容来自后台,不能当 HTML 拼)
|
||||
const esc = x => String(x == null ? '' : x).replace(/[&<>"']/g, c => ({ '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' }[c]));
|
||||
const LIGHT = new THREE.Vector3(-1, 0.55, 0.6).normalize();
|
||||
|
||||
// ============================================================ 旋臂星系(粒子)—— 星点大小有上限,离镜头很近的也不会糊成大光斑
|
||||
@@ -97,27 +100,26 @@ export function mountGalaxy(el) {
|
||||
// ============================================================ 星系(每条世界线一颗卡通星球 + 卫星)
|
||||
const systems = [], planets = [];
|
||||
const lit = CFG.UNIVERSES.filter(u => !u.empty), empty = CFG.UNIVERSES.filter(u => u.empty);
|
||||
CFG.UNIVERSES.forEach((u, i) => {
|
||||
const ei = empty.indexOf(u);
|
||||
const L = Object.assign({}, CFG.EMPTY_LOOK, CFG.LOOKS[u.no] || {});
|
||||
if (!CFG.LOOKS[u.no]) L.orbit = [R * (0.8 + 0.12 * (ei % 2)), ei % ARMS]; // 空槽放在外圈,按顺序分到各条旋臂
|
||||
const [r, arm] = L.orbit || [R * 0.85, i % ARMS];
|
||||
const a = r ? armAngle(r, arm) + (u.empty ? 0.32 * Math.floor(ei / ARMS) : 0) : 0;
|
||||
const g = new THREE.Group(); g.position.set(Math.cos(a) * r, 0, Math.sin(a) * r); scene.add(g);
|
||||
// 位置和补给线由 layout.js 算(写死的 / 空槽按编号 / 新点亮的自动排位,规则见那个文件开头)
|
||||
const LAY = layoutSystems(CFG), byNo = new Map();
|
||||
LAY.forEach((ly, i) => {
|
||||
const u = ly.u, L = ly.look;
|
||||
const g = new THREE.Group(); g.position.set(ly.x, 0, ly.z); scene.add(g);
|
||||
const p = makePlanet(THREE, Object.assign({ seed: i * 7.3 + 1 }, L)); g.add(p.group); planets.push(p);
|
||||
const moons = (L.moons || []).map((m, k) => { const piv = new THREE.Group(); piv.rotation.x = 0.35 - k * 0.2; piv.rotation.y = k * 2.1; g.add(piv);
|
||||
const mp = makePlanet(THREE, Object.assign({ seed: i * 13 + k * 3.1, spin: 0.4 }, m)); mp.group.position.x = m.d; piv.add(mp.group); planets.push(mp); return { piv, speed: Math.abs(m.speed || 0.3) }; }); // 卫星一律同一个方向转(和星系自转同向)
|
||||
const tag = document.createElement('button'); tag.type = 'button'; tag.className = 'tag' + (u.empty ? ' empty' : ''); tag.style.setProperty('--c', L.accent || C.ui);
|
||||
tag.innerHTML = '<span class="t"><b>' + (u.empty ? '空槽' : u.name) + '</b><em>' + u.no + (u.empty ? ' · 未点亮' : ' · ' + u.kind) + '</em></span>';
|
||||
tag.innerHTML = '<span class="t"><b>' + esc(u.empty ? '空槽' : u.name) + '</b><em>' + esc(u.no) + (u.empty ? ' · 未点亮' : ' · ' + esc(u.kind)) + '</em></span>';
|
||||
labels.appendChild(tag);
|
||||
const s = { u, L, g, planet: p, moons, tag }; p.body.userData.s = s; systems.push(s);
|
||||
const s = { u, L, g, planet: p, moons, tag, parent: ly.parent }; p.body.userData.s = s; systems.push(s); byNo.set(u.no, s);
|
||||
tag.addEventListener('click', () => fly(s));
|
||||
});
|
||||
// 补给线:核心 → 每个星系,虚线往外流
|
||||
// 补给线:从「上一站」(核心或更靠里的那颗星)连过来,虚线往外流;空槽的线很淡
|
||||
const supply = [];
|
||||
for (const s of systems) { if (s.u.no === '0000') continue;
|
||||
const b = s.g.position.clone(), mid = b.clone().multiplyScalar(0.5); mid.y += b.length() * 0.12;
|
||||
const l = new THREE.Line(new THREE.BufferGeometry().setFromPoints(new THREE.QuadraticBezierCurve3(new THREE.Vector3(), mid, b).getPoints(80)),
|
||||
for (const s of systems) { if (s.u.no === '0000' || !s.g.position.lengthSq()) continue;
|
||||
const a = s.parent && byNo.has(s.parent) ? byNo.get(s.parent).g.position.clone() : new THREE.Vector3();
|
||||
const b = s.g.position.clone(), mid = a.clone().add(b).multiplyScalar(0.5); mid.y += a.distanceTo(b) * 0.12;
|
||||
const l = new THREE.Line(new THREE.BufferGeometry().setFromPoints(new THREE.QuadraticBezierCurve3(a, mid, b).getPoints(80)),
|
||||
new THREE.LineDashedMaterial({ color: s.u.empty ? lineCol : new THREE.Color(C.ui), dashSize: 0.9, gapSize: 0.8, transparent: true, opacity: s.u.empty ? 0.14 : 0.42, depthWrite: false }));
|
||||
l.computeLineDistances(); l.userData.op = l.material.opacity; scene.add(l); supply.push(l); }
|
||||
// 散落的无名星球(只是让星系看起来有人住;不进档案、不能点)
|
||||
@@ -225,10 +227,9 @@ export function mountGalaxy(el) {
|
||||
for (const s of systems) { s.g.getWorldPosition(tmp).project(camera); const d = Math.hypot((tmp.x - ptr.x) * r.width / 2, (tmp.y - ptr.y) * r.height / 2); if (d < bd && tmp.z < 1) { bd = d; best = s; } }
|
||||
return best;
|
||||
}
|
||||
const esc = x => String(x || '').replace(/[&<>"]/g, c => ({ '&': '&', '<': '<', '>': '>', '"': '"' }[c]));
|
||||
function card(s) { const u = s.u, nav = '<div class="nav"><button class="btn" type="button" data-s="-1">上一个</button><button class="btn" type="button" data-s="1">下一个</button></div>';
|
||||
if (u.empty) return '<div class="card" style="--pc:' + (s.L.accent) + '"><div class="k">UNIVERSE ' + u.no + ' · 未点亮</div><h2>空槽</h2><div class="tg">这条世界线还没写出来,星系还没被点亮。</div><div class="acts">' + nav + '<button class="btn" type="button" data-home>回到星系图</button></div></div>';
|
||||
return '<div class="card" style="--pc:' + s.L.accent + '"><div class="k">UNIVERSE ' + u.no + ' · ' + esc(u.kind) + ' · 已点亮</div><h2>' + esc(u.name) + '</h2><div class="tg">' + esc(u.tag) + '</div>' +
|
||||
if (u.empty) return '<div class="card" style="--pc:' + esc(s.L.accent) + '"><div class="k">UNIVERSE ' + esc(u.no) + ' · 未点亮</div><h2>空槽</h2><div class="tg">这条世界线还没写出来,星系还没被点亮。</div><div class="acts">' + nav + '<button class="btn" type="button" data-home>回到星系图</button></div></div>';
|
||||
return '<div class="card" style="--pc:' + esc(s.L.accent) + '"><div class="k">UNIVERSE ' + esc(u.no) + ' · ' + esc(u.kind) + ' · 已点亮</div><h2>' + esc(u.name) + '</h2><div class="tg">' + esc(u.tag) + '</div>' +
|
||||
'<p class="ds">' + esc(u.desc) + '</p><div class="tags">' + (u.tags || []).map(t => '<span>' + esc(t) + '</span>').join('') + '</div><div class="acts">' + nav + '<button class="btn pri" type="button" data-home>回到星系图</button></div></div>'; }
|
||||
panel && panel.addEventListener('click', e => { const b = e.target.closest('[data-s]'); if (b) step(+b.dataset.s); if (e.target.closest('[data-home]')) home(); });
|
||||
function step(d) { const i = systems.indexOf(focus); fly(systems[(i + d + systems.length) % systems.length]); }
|
||||
|
||||
Reference in New Issue
Block a user