全量细审修复:部署漏配防清空、scrypt 并发闸、发布冲突可解、价格文件只在改了才写、排位扩容
- cms.py:没设 YS_PORTAL_DIR / YS_ORDER_DIR 或缺 content/site.json 时拒绝工作(不建空的第一版,免得一发布清空网站); 同时最多 2 个 scrypt(内存上限 256M);登录冷却记录定期清理;价格 / 付款只在这次发布真改了才写回 (不覆盖 admin.py price 的改动) - 后台页面:发布冲突二选一(丢掉我的草稿 / 确认后覆盖发布);草稿没存上、还有图在上传时不让发布 - layout.js:中圈排满后分档到外圈空槽之间找位置,40 条世界线也不重叠;去掉慢的 Math.hypot - config.js:后台把世界线删光也照实显示;门户删掉旧启动仪式留下的死数据;版本号 v=3 - 测试:内容后台 78 / 回归 27 / 数据库 38 全过;端到端浏览器 36 全过 - 文档同步(交接文档、内容后台设计「实现对照」、后端交接说明、交付清单) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -75,6 +75,6 @@ window.JZ_UNIVERSE = {
|
|||||||
(function () {
|
(function () {
|
||||||
var C = window.JZ_CONTENT && window.JZ_CONTENT.universe, U = window.JZ_UNIVERSE;
|
var C = window.JZ_CONTENT && window.JZ_CONTENT.universe, U = window.JZ_UNIVERSE;
|
||||||
if (!C || !U) return;
|
if (!C || !U) return;
|
||||||
if (Array.isArray(C.UNIVERSES) && C.UNIVERSES.length) U.UNIVERSES = C.UNIVERSES;
|
if (Array.isArray(C.UNIVERSES)) U.UNIVERSES = C.UNIVERSES; // 后台把世界线删光了也照实显示(不退回兜底)
|
||||||
if (C.LOOKS && typeof C.LOOKS === 'object') U.LOOKS = C.LOOKS;
|
if (C.LOOKS && typeof C.LOOKS === 'object') U.LOOKS = C.LOOKS;
|
||||||
})();
|
})();
|
||||||
|
|||||||
@@ -12,7 +12,7 @@
|
|||||||
* ============================================================================= */
|
* ============================================================================= */
|
||||||
import * as THREE from 'three';
|
import * as THREE from 'three';
|
||||||
import { makePlanet } from './planets.js?v=2';
|
import { makePlanet } from './planets.js?v=2';
|
||||||
import { layoutSystems } from './layout.js?v=2';
|
import { layoutSystems } from './layout.js?v=3';
|
||||||
|
|
||||||
export function mountGalaxy(el) {
|
export function mountGalaxy(el) {
|
||||||
const CFG = window.JZ_UNIVERSE, G = CFG.GALAXY, C = G.colors;
|
const CFG = window.JZ_UNIVERSE, G = CFG.GALAXY, C = G.colors;
|
||||||
|
|||||||
@@ -12,6 +12,7 @@
|
|||||||
* · 补给线连到「比它更靠近核心、又离它最近」的那颗星(没有合适的就连核心),
|
* · 补给线连到「比它更靠近核心、又离它最近」的那颗星(没有合适的就连核心),
|
||||||
* 而且这条线不能从别的星系中间穿过;
|
* 而且这条线不能从别的星系中间穿过;
|
||||||
* · 按编号从小到大一颗一颗排,每一颗只看排在它前面的 —— 所以**新加一条,已有的星和线都不动**。
|
* · 按编号从小到大一颗一颗排,每一颗只看排在它前面的 —— 所以**新加一条,已有的星和线都不动**。
|
||||||
|
* · 中圈排满(二十来条以后)才会去外圈空槽之间找位置;那一档要避开空槽,所以改「空槽数」可能让这几颗挪一挪。
|
||||||
*
|
*
|
||||||
* 用法:import { layoutSystems } from './layout.js';
|
* 用法:import { layoutSystems } from './layout.js';
|
||||||
* const L = layoutSystems(window.JZ_UNIVERSE) → [{ u, look, x, z, kind, parent }]
|
* const L = layoutSystems(window.JZ_UNIVERSE) → [{ u, look, x, z, kind, parent }]
|
||||||
@@ -26,12 +27,13 @@ export function footprint(look) {
|
|||||||
return (look.r || 1) * 2.2 + (moons.length ? Math.max(...moons) : 0);
|
return (look.r || 1) * 2.2 + (moons.length ? Math.max(...moons) : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
const dist = (a, b) => Math.hypot(a.x - b.x, a.z - b.z);
|
const dist = (a, b) => { const dx = a.x - b.x, dz = a.z - b.z; return Math.sqrt(dx * dx + dz * dz); }; // 别用 Math.hypot:V8 里慢好几倍
|
||||||
/** 点到线段的距离(补给线按直线近似;实际画的是稍微拱起来的弧,水平投影还是这条线) */
|
/** 点到线段的距离(补给线按直线近似;实际画的是稍微拱起来的弧,水平投影还是这条线) */
|
||||||
function segDist(p, a, b) {
|
function segDist(p, a, b) {
|
||||||
const vx = b.x - a.x, vz = b.z - a.z, L2 = vx * vx + vz * vz || 1;
|
const vx = b.x - a.x, vz = b.z - a.z, L2 = vx * vx + vz * vz || 1;
|
||||||
const t = Math.max(0, Math.min(1, ((p.x - a.x) * vx + (p.z - a.z) * vz) / L2));
|
const t = Math.max(0, Math.min(1, ((p.x - a.x) * vx + (p.z - a.z) * vz) / L2));
|
||||||
return Math.hypot(p.x - (a.x + vx * t), p.z - (a.z + vz * t));
|
const dx = p.x - (a.x + vx * t), dz = p.z - (a.z + vz * t);
|
||||||
|
return Math.sqrt(dx * dx + dz * dz);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function layoutSystems(CFG) {
|
export function layoutSystems(CFG) {
|
||||||
@@ -74,7 +76,7 @@ export function layoutSystems(CFG) {
|
|||||||
|
|
||||||
// 给一个候选位置挑补给线起点:比它更靠近核心的星(或核心),线不能穿过别的星系
|
// 给一个候选位置挑补给线起点:比它更靠近核心的星(或核心),线不能穿过别的星系
|
||||||
function parentFor(c, others) {
|
function parentFor(c, others) {
|
||||||
const cands = [CORE, ...others.filter(o => Math.hypot(o.x, o.z) < c.r - 4)];
|
const cands = [CORE, ...others.filter(o => o.r < c.r - 4)];
|
||||||
let best = null;
|
let best = null;
|
||||||
for (const p of cands) {
|
for (const p of cands) {
|
||||||
const len = dist(p, c);
|
const len = dist(p, c);
|
||||||
@@ -88,33 +90,53 @@ export function layoutSystems(CFG) {
|
|||||||
return best;
|
return best;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const u of list) {
|
// 候选位置:按「够不够宽敞」先粗筛打分(便宜),再只给排在前面的几十个检查补给线会不会穿星(贵)—— 40 条世界线也很快。
|
||||||
if (u.empty || out.has(u.no)) continue;
|
// 中圈排满了就分档放宽:到外圈空槽之间找位置(这时也要避开空槽)、间距要求逐步降低;最后兜底也保证不叠在别人身上。
|
||||||
const look = lookOf(u), fp = footprint(look);
|
const slots = [...out.values()].filter(s => s.kind === 'slot');
|
||||||
let best = null;
|
const PASSES = [
|
||||||
|
{ rMax: R * 0.68, need: 4, offs: [-0.2, -0.1, 0, 0.1, 0.2], slots: false },
|
||||||
|
{ rMax: R * 0.96, need: 3, offs: [-0.3, -0.2, -0.1, 0, 0.1, 0.2, 0.3], slots: true },
|
||||||
|
{ rMax: R * 0.98, need: 1.2, offs: [-0.4, -0.3, -0.2, -0.1, 0, 0.1, 0.2, 0.3, 0.4], slots: true },
|
||||||
|
];
|
||||||
|
function place(fp, pass) {
|
||||||
|
const others = pass.slots ? placed.concat(slots) : placed, cands = [];
|
||||||
for (let arm = 0; arm < ARMS; arm++) {
|
for (let arm = 0; arm < ARMS; arm++) {
|
||||||
for (let r = rMin; r <= rMax; r += 1.25) {
|
for (let r = rMin; r <= pass.rMax; r += 1.25) {
|
||||||
for (const off of [-0.2, -0.1, 0, 0.1, 0.2]) {
|
for (const off of pass.offs) {
|
||||||
const a = armAngle(r, arm, G) + off;
|
const a = armAngle(r, arm, G) + off;
|
||||||
const c = { x: Math.cos(a) * r, z: Math.sin(a) * r, r };
|
const c = { x: Math.cos(a) * r, z: Math.sin(a) * r, r };
|
||||||
let clear = r - CORE.fp - fp;
|
let clear = r - CORE.fp - fp;
|
||||||
for (const o of placed) clear = Math.min(clear, dist(o, c) - o.fp - fp);
|
for (const o of others) clear = Math.min(clear, dist(o, c) - o.fp - fp);
|
||||||
if (clear < 4) continue;
|
if (clear < pass.need) continue;
|
||||||
const par = parentFor(c, placed);
|
|
||||||
if (!par) continue;
|
|
||||||
// 分数:够宽敞(封顶,不为了宽敞跑到边上)、靠近中圈、所在旋臂人少、在旋臂正中更好
|
// 分数:够宽敞(封顶,不为了宽敞跑到边上)、靠近中圈、所在旋臂人少、在旋臂正中更好
|
||||||
const score = Math.min(clear, 12) - 0.08 * Math.abs(r - mid) - 2.2 * armCount[arm] - 3 * Math.abs(off) + Math.min(par.clear, 6) * 0.3;
|
cands.push({ c, a, r, arm, clear, score: Math.min(clear, 12) - 0.08 * Math.abs(r - mid) - 2.2 * armCount[arm] - 3 * Math.abs(off) });
|
||||||
if (!best || score > best.score + 1e-9) best = { score, r, a, arm, parent: par.p };
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!best) { // 实在挤不下(几十条以后):退回外圈槽位,至少不叠在别人身上
|
cands.sort((x, y) => y.score - x.score || x.r - y.r || x.a - y.a);
|
||||||
const e = Math.max(0, num(u) - first), r = R * 0.86;
|
let best = null;
|
||||||
put(u, look, r, armAngle(r, e % ARMS, G) + 0.32 * Math.floor(e / ARMS) + 0.16, 'auto', null);
|
for (const k of cands.slice(0, 60)) {
|
||||||
|
const par = parentFor(k.c, placed);
|
||||||
|
if (!par) continue;
|
||||||
|
const s = k.score + Math.min(par.clear, 6) * 0.3;
|
||||||
|
if (!best || s > best.s + 1e-9) best = { s, k, parent: par.p };
|
||||||
|
}
|
||||||
|
if (best) return best;
|
||||||
|
return cands.length ? { k: cands[0], parent: CORE } : null; // 线怎么都会擦到别的星:就近连核心,至少星不叠
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const u of list) {
|
||||||
|
if (u.empty || out.has(u.no)) continue;
|
||||||
|
const look = lookOf(u), fp = footprint(look);
|
||||||
|
let got = null;
|
||||||
|
for (const pass of PASSES) { got = place(fp, pass); if (got) break; }
|
||||||
|
if (!got) { // 整张图都满了(几十条以后):退到最外圈,按编号错开
|
||||||
|
const e = Math.max(0, num(u) - first), r = R * 1.02 + 2 * Math.floor(e / ARMS);
|
||||||
|
placed.push(put(u, look, r, armAngle(r, e % ARMS, G) + 0.16, 'auto', null));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
const s = put(u, look, best.r, best.a, 'auto', best.parent.no);
|
const s = put(u, look, got.k.r, got.k.a, 'auto', got.parent.no);
|
||||||
armCount[best.arm]++;
|
armCount[got.k.arm]++;
|
||||||
placed.push(s);
|
placed.push(s);
|
||||||
}
|
}
|
||||||
// 4) 空槽的淡线:接到最近的、不穿星的已点亮星(或核心)
|
// 4) 空槽的淡线:接到最近的、不穿星的已点亮星(或核心)
|
||||||
|
|||||||
Reference in New Issue
Block a user