全量细审修复:部署漏配防清空、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:
+18
-1
@@ -905,7 +905,9 @@ $('#prevBtn').onclick = async () => {
|
||||
+ '<div class="mf"><button class="btn" type="button" onclick="closeModal()">知道了</button></div>');
|
||||
};
|
||||
async function openPublish() {
|
||||
if (DOC.site.gallery.some(g => g._up)) return toast('还有图在上传,等传完再发布', true);
|
||||
await flush();
|
||||
if (dirtyLocal) return toast('最新的改动没存上(看右上角的提示),先改好再发布 —— 不然发出去的是上一次存上的草稿', true);
|
||||
if (!CHANGES.length) return toast('没有要发布的改动');
|
||||
openModal('<h3>发布这些改动</h3><p>发布后马上出现在网站上。每次发布都留一份完整版本,随时能回到之前的版本。</p>'
|
||||
+ '<ul class="chg">' + CHANGES.map(c => '<li><b>' + esc(c[0]) + '</b><span>' + esc(dtxt(c)) + '</span></li>').join('') + '</ul>'
|
||||
@@ -915,12 +917,27 @@ async function openPublish() {
|
||||
$('#pubGo').disabled = true;
|
||||
const j = await api('publish', { note: $('#pubNote').value.trim(), base: BASE });
|
||||
if (!j.ok) { $('#pubGo').disabled = false;
|
||||
if (j.conflict) { closeModal(); openModal('<h3>别人刚发布过</h3><p>' + esc(j.error) + '</p><div class="mf"><button class="btn" type="button" onclick="closeModal()">先不发</button><button class="btn pri" type="button" id="reloadGo">刷新看看</button></div>'); $('#reloadGo').onclick = async () => { closeModal(); await loadContent(); renderAll(); go('home'); }; return; }
|
||||
if (j.conflict) { closeModal(); conflictModal(j.error); return; }
|
||||
return toast(j.error || '发布失败', true); }
|
||||
closeModal(); await loadContent(); renderAll(); go(PANE); toast('v' + j.version + ' 已发布,网站上已经是新内容');
|
||||
};
|
||||
}
|
||||
$('#pubBtn').onclick = openPublish;
|
||||
/* 别人在你编辑期间发布过:二选一 —— 丢掉自己的草稿看网站上现在的,或者确认后用自己的草稿覆盖发布 */
|
||||
function conflictModal(msg) {
|
||||
openModal('<h3>别人刚发布过</h3><p>' + esc(msg) + '</p><p>可以先去「发布记录」看对方改了什么。然后:</p>'
|
||||
+ '<div class="mf"><button class="btn" type="button" onclick="closeModal()">先不发</button><button class="btn bad" type="button" id="cfDrop">丢掉我的草稿</button><button class="btn pri" type="button" id="cfMine">用我的草稿覆盖发布</button></div>');
|
||||
$('#cfDrop').onclick = async () => { closeModal(); clearTimeout(saveTimer); dirtyLocal = false; await api('discard', {}); await loadContent(); renderAll(); go('home'); toast('已丢掉你的草稿,现在显示的是网站上的内容'); };
|
||||
$('#cfMine').onclick = async () => {
|
||||
if (!confirm('确定用你的草稿覆盖?对方那次发布的改动会被你的版本盖掉(发布记录里还能找回)。')) return;
|
||||
closeModal();
|
||||
const mine = clone(DOC); await loadContent(); DOC = mine; BASE = VERSION; dirtyLocal = true;
|
||||
if (!(await save())) return;
|
||||
const j = await api('publish', { note: '覆盖发布(基于 v' + VERSION + ')', base: VERSION });
|
||||
if (!j.ok) return toast(j.error || '发布失败', true);
|
||||
await loadContent(); renderAll(); go(PANE); toast('v' + j.version + ' 已发布');
|
||||
};
|
||||
}
|
||||
async function renderVersions() {
|
||||
const j = await api('versions');
|
||||
const V = j.versions || [];
|
||||
|
||||
@@ -75,6 +75,6 @@ window.JZ_UNIVERSE = {
|
||||
(function () {
|
||||
var C = window.JZ_CONTENT && window.JZ_CONTENT.universe, U = window.JZ_UNIVERSE;
|
||||
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;
|
||||
})();
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
* ============================================================================= */
|
||||
import * as THREE from 'three';
|
||||
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) {
|
||||
const CFG = window.JZ_UNIVERSE, G = CFG.GALAXY, C = G.colors;
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
* · 补给线连到「比它更靠近核心、又离它最近」的那颗星(没有合适的就连核心),
|
||||
* 而且这条线不能从别的星系中间穿过;
|
||||
* · 按编号从小到大一颗一颗排,每一颗只看排在它前面的 —— 所以**新加一条,已有的星和线都不动**。
|
||||
* · 中圈排满(二十来条以后)才会去外圈空槽之间找位置;那一档要避开空槽,所以改「空槽数」可能让这几颗挪一挪。
|
||||
*
|
||||
* 用法:import { layoutSystems } from './layout.js';
|
||||
* 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);
|
||||
}
|
||||
|
||||
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) {
|
||||
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));
|
||||
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) {
|
||||
@@ -74,7 +76,7 @@ export function layoutSystems(CFG) {
|
||||
|
||||
// 给一个候选位置挑补给线起点:比它更靠近核心的星(或核心),线不能穿过别的星系
|
||||
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;
|
||||
for (const p of cands) {
|
||||
const len = dist(p, c);
|
||||
@@ -88,33 +90,53 @@ export function layoutSystems(CFG) {
|
||||
return best;
|
||||
}
|
||||
|
||||
for (const u of list) {
|
||||
if (u.empty || out.has(u.no)) continue;
|
||||
const look = lookOf(u), fp = footprint(look);
|
||||
let best = null;
|
||||
// 候选位置:按「够不够宽敞」先粗筛打分(便宜),再只给排在前面的几十个检查补给线会不会穿星(贵)—— 40 条世界线也很快。
|
||||
// 中圈排满了就分档放宽:到外圈空槽之间找位置(这时也要避开空槽)、间距要求逐步降低;最后兜底也保证不叠在别人身上。
|
||||
const slots = [...out.values()].filter(s => s.kind === 'slot');
|
||||
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 r = rMin; r <= rMax; r += 1.25) {
|
||||
for (const off of [-0.2, -0.1, 0, 0.1, 0.2]) {
|
||||
for (let r = rMin; r <= pass.rMax; r += 1.25) {
|
||||
for (const off of pass.offs) {
|
||||
const a = armAngle(r, arm, G) + off;
|
||||
const c = { x: Math.cos(a) * r, z: Math.sin(a) * r, r };
|
||||
let clear = r - CORE.fp - fp;
|
||||
for (const o of placed) clear = Math.min(clear, dist(o, c) - o.fp - fp);
|
||||
if (clear < 4) continue;
|
||||
const par = parentFor(c, placed);
|
||||
if (!par) continue;
|
||||
for (const o of others) clear = Math.min(clear, dist(o, c) - o.fp - fp);
|
||||
if (clear < pass.need) 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;
|
||||
if (!best || score > best.score + 1e-9) best = { score, r, a, arm, parent: par.p };
|
||||
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) { // 实在挤不下(几十条以后):退回外圈槽位,至少不叠在别人身上
|
||||
const e = Math.max(0, num(u) - first), r = R * 0.86;
|
||||
put(u, look, r, armAngle(r, e % ARMS, G) + 0.32 * Math.floor(e / ARMS) + 0.16, 'auto', null);
|
||||
cands.sort((x, y) => y.score - x.score || x.r - y.r || x.a - y.a);
|
||||
let best = 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;
|
||||
}
|
||||
const s = put(u, look, best.r, best.a, 'auto', best.parent.no);
|
||||
armCount[best.arm]++;
|
||||
const s = put(u, look, got.k.r, got.k.a, 'auto', got.parent.no);
|
||||
armCount[got.k.arm]++;
|
||||
placed.push(s);
|
||||
}
|
||||
// 4) 空槽的淡线:接到最近的、不穿星的已点亮星(或核心)
|
||||
|
||||
+2
-12
@@ -1687,7 +1687,7 @@ window.__hdcEarly=(function(){
|
||||
<script src="content/site.js"></script>
|
||||
<script>/* 预览草稿:后台点「预览」会带 ?preview=1 打开;只有登录了内容后台的浏览器拿得到草稿(拿不到就还是正式内容) */
|
||||
if(/[?&]preview=1(&|$)/.test(location.search)) document.write('<script src="/order/api/cms/draft.js"><\/script>');</script>
|
||||
<script src="assets/universe/config.js?v=2"></script>
|
||||
<script src="assets/universe/config.js?v=3"></script>
|
||||
<script>
|
||||
/* ============================================================================
|
||||
金钻宇宙门户 · 状态机与交互(纯原生,零依赖)
|
||||
@@ -1815,16 +1815,6 @@ const BOARD_SLOTS = { gallery:6 };
|
||||
/* 浏览器标题 / 文档描述里的站点名。 */
|
||||
const SITE_NAME = '金钻客栈';
|
||||
|
||||
/* 启动序列逐字文本(晶钻超算 + 浮尘) */
|
||||
const BOOT_LINES = [
|
||||
'ICD-0 // 晶钻超算 演算集群',
|
||||
'> 扫描平行宇宙世界线 <b>...</b>',
|
||||
'> 发现 11 条世界线 · <b>5</b> 条已点亮',
|
||||
'> 浮尘机器人布点完成(肉眼不可见)',
|
||||
'> 权限核验:金钻 · 主宇宙',
|
||||
'ACCESS GRANTED <span class="ok">✓</span>'
|
||||
];
|
||||
|
||||
/* ---------- 2. 全局 Ticker(单一 rAF,隐藏页暂停) ---------- */
|
||||
const Ticker = (function(){
|
||||
const subs = new Set();
|
||||
@@ -3588,7 +3578,7 @@ function mark(no) { document.querySelectorAll('#uniList .ucell,#uSlots button').
|
||||
let api = null, loading = null, pending = null;
|
||||
function load() {
|
||||
if (loading) return loading;
|
||||
loading = import('./assets/universe/galaxy.js?v=2').then(({ mountGalaxy }) => {
|
||||
loading = import('./assets/universe/galaxy.js?v=3').then(({ mountGalaxy }) => {
|
||||
api = mountGalaxy({ stage, canvas: $('uGl'), labels: $('uLabels'), panel: $('uPanel'), back: $('uBack'), hud: $('uHud'),
|
||||
// 选中时星球让位:桌面往左挪给档案卡,手机往上挪(档案卡是窗里的底部抽屉)
|
||||
layout: () => mob() ? { x: 0, y: 0.26 } : { x: 0.17, y: 0 },
|
||||
|
||||
Reference in New Issue
Block a user