Skip to content

Commit 504c64f

Browse files
committed
docs: 固化发布规范 RELEASING.md;重建三档离线单文件并修复离线档位优先级
- 新增 docs/RELEASING.md:三档版本定义与命名、发布流程 (归档旧版 → 版本号推进 → 打包 → push → Tag → Release)、职责分工与检查清单 - README「下载」小节补充发布规范文档入口 - 修复 boot() 档位优先级:URL 参数 > localStorage > 离线包注入的 window.HIC_EDITION > 默认 X;此前离线 M/R 档单文件会误启动为 X 档 - 重建三档离线单文件(含 M/R/X 顶栏切换器),离线包与网页端能力对齐
1 parent a8760dc commit 504c64f

8 files changed

Lines changed: 326 additions & 60 deletions

File tree

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ HiCode(简称 **HC**)的诞生源于一个朴素的愿望:**让编程真
5757
- 下载页:**[https://HiCodeHC.github.io/download/](https://HiCodeHC.github.io/download/)**
5858
- 可选 **安卓端(.apk)****Windows 电脑端(.exe)****网页端(在线)** 三种形态,每版再分 **M 轻量 / R 标准 / X 全能** 三档(见下载页 / GitHub Releases);本地端基于网页端 IDE 封装的离线运行时,编译更快、体验一致。各版本(M/R/X)打包为 .apk / .exe 的步骤见下载页「打包为 .apk / .exe」指引,可分别产出对应版本的安装包。
5959
- **GitHub Releases**:自 v3.01 起,每个新版本均基于 Git Tag 在 **[GitHub Releases](https://github.com/HiCodeHC/HiCodeHC.github.io/releases)** 默认发布(含三档离线单文件版 / 源码 / 原生安装包),可前往查看各版本的发布说明与附件。
60+
- **发布规范**:版本发布流程(三档拆分 → 归档旧版 → 打包 → Tag → Release)见 **[docs/RELEASING.md](docs/RELEASING.md)**,每次发布照此执行。
6061

6162
## 官网
6263

android/js/app.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -893,13 +893,15 @@
893893
// 三版发布:网页端可直接切换 M/R/X。优先级:
894894
// ① URL 参数 ?edition=m|r|x(下载页「在线体验三版」直达)
895895
// ② localStorage 记忆的上次选择
896-
// ③ 默认 X 全能版
897-
let ed = "x";
896+
// ③ 离线单文件在 <head> 注入的 window.HIC_EDITION(发布形态固定档位)
897+
// ④ 默认 X 全能版
898+
let ed = "";
898899
try {
899900
const q = new URLSearchParams(window.location.search || "").get("edition");
900-
ed = q || localStorage.getItem("HIC_EDITION_PREF") || "x";
901-
} catch (e) {}
902-
state.edition = edNorm(ed);
901+
ed = q || localStorage.getItem("HIC_EDITION_PREF") || "";
902+
} catch (e) { ed = ""; }
903+
if (!ed && window.HIC_EDITION) ed = String(window.HIC_EDITION);
904+
state.edition = edNorm(ed || "x");
903905
applyEditionUI();
904906
// 轻量编辑器:语法高亮 + 行号 + 自动缩进 + 括号补全
905907
if (window.HICED) window.hiced = HICED.create(el.code);

docs/RELEASING.md

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
# HiCode 发布规范(RELEASING)
2+
3+
> 本文档固化 HiCode 的版本发布流程。每次发布照此执行,保证三档版本、归档、Git Tag 与 GitHub Release 资产的一致性。
4+
> 执行中遇到本文档未覆盖的细节,由发布执行者自行决定,不回头反复确认。
5+
6+
## 一、三档版本定义与命名
7+
8+
每个版本号统一拆为三档发布,能力递进、版本号相同(同一套引擎,按档位开启能力):
9+
10+
| 档位 | 名称 | 能力 |
11+
| --- | --- | --- |
12+
| `M` | 轻量版 | 仅全套 HIC 内核 |
13+
| `R` | 标准版 | 内核 + 编译 Python 为 HTML(`py:(…)end`|
14+
| `X` | 全能版 | 内核 + 编译 Python 与 C++ 为 HTML(`py:(…)end` / `cpp:(…)end`|
15+
16+
命名约定:
17+
18+
- **Git Tag**`v{版本号}`(如 `v3.66`),锚定发布时的 main。
19+
- **离线单文件**`HiCode-v{版本号}{M|R|X}-offline.html`(如 `HiCode-v3.66X-offline.html`)。
20+
- **归档目录**`old/v{旧版本号}/`(如 `old/v3.01/`)。
21+
- **网页端三版在线体验**`/ide/?edition=m|r|x` 直达对应档位,顶栏可随时切换,选择记忆在本地。
22+
23+
## 二、发布流程(按序执行)
24+
25+
### 1. 归档旧版本
26+
27+
- 将当前线上版本完整快照至 `old/v{旧版本号}/`(整站文件,含 README)。
28+
- 在历史版本索引页 `old/index.html` 补上旧版本入口链接。
29+
30+
### 2. 推进版本号与站点内容
31+
32+
版本号出现在以下位置,需一并对齐(当前以 v3.66 为例):
33+
34+
- `ide/js/hic.js``HC.APP.version`
35+
- `windows/index.html` / `android/index.html` — 顶栏 `verTag` 文案
36+
- `download/build/build-offline.js` — 输出文件名与标题中的版本号
37+
- `README.md` — 「当前版本」小节与「下载」链接
38+
- `download/index.html` — 三档文件链接、更新说明
39+
40+
### 3. 打包三档离线单文件
41+
42+
```bash
43+
node download/build/build-offline.js
44+
```
45+
46+
脚本以 `windows/` 为内核,按 M/R/X 注入 `window.HIC_EDITION`,产出三份自包含单文件至 `download/`。脚本内置校验:若仍有未内联的外部资源会直接报错退出。
47+
48+
### 4. 提交并推送
49+
50+
```bash
51+
git add -A
52+
git commit -m "release: v{版本号} …"
53+
git push origin main
54+
```
55+
56+
### 5. 打 Git Tag(锚定 main)
57+
58+
```bash
59+
git tag v{版本号}
60+
git push origin v{版本号}
61+
```
62+
63+
### 6. 建 GitHub Release 并上传资产
64+
65+
- 以 Tag `v{版本号}` 创建 Release,标题与 Tag 同名。
66+
- Release 说明:三档差异(M/R/X)+ 本版更新点。
67+
- 上传三档离线单文件 `HiCode-v{版本号}{M,R,X}-offline.html` 作为资产。
68+
69+
### 7. 验证
70+
71+
- GitHub Pages 生效后访问官网,确认「在线体验三版」直达链接可用。
72+
- 下载三档离线单文件,双击本地打开,确认档位正确(顶栏徽标与能力按钮与档位一致)。
73+
74+
## 三、职责分工
75+
76+
- 打包类工作(生成三档离线单文件、上传 Release 资产、归档旧版本)由发布执行者完成,不留 TODO 给用户。
77+
- 提交前无需用户反复审查;撰写过程遇到问题自行决定。
78+
79+
## 四、发布检查清单
80+
81+
- [ ] 旧版本已快照至 `old/v{旧版本号}/`
82+
- [ ] `old/index.html` 历史索引已补链接
83+
- [ ] 版本号已全文对齐(hic.js / verTag / build 脚本 / README / 下载页)
84+
- [ ] 三档离线单文件已生成并通过脚本内置校验
85+
- [ ] `main` 已提交并推送
86+
- [ ] Git Tag `v{版本号}` 已打并推送
87+
- [ ] GitHub Release 已创建,三档资产已上传
88+
- [ ] 网页端三版在线体验链接与离线包档位均验证可用

download/HiCode-v3.66M-offline.html

Lines changed: 72 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,11 @@
7272
.ver { font-size: 11.5px; color: var(--muted); background: var(--accent-soft); padding: 2px 8px; border-radius: 999px; }
7373
.crumb { flex: 1; min-width: 0; color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-align: center; }
7474
.actions { display: flex; gap: 10px; align-items: center; }
75+
/* ===== M/R/X 三版切换器 ===== */
76+
.ed-switch { display: inline-flex; gap: 2px; padding: 3px; border: 1px solid var(--line); border-radius: 999px; background: rgba(255, 252, 245, .6); }
77+
.ed-switch .ed-btn { min-width: 28px; padding: 5px 9px; border: none; border-radius: 999px; background: transparent; color: var(--dim); font-size: 12px; font-weight: 800; letter-spacing: .5px; cursor: pointer; transition: background .15s, color .15s; }
78+
.ed-switch .ed-btn:hover { color: var(--accent-strong); }
79+
.ed-switch .ed-btn.on { background: linear-gradient(140deg, #e2b878, #b38545); color: #fff; box-shadow: 0 3px 10px rgba(179, 133, 69, .35); }
7580
.menu-wrap { position: relative; }
7681
.menu {
7782
position: absolute; right: 0; top: calc(100% + 8px); min-width: 250px; z-index: 40;
@@ -396,6 +401,11 @@
396401
</div>
397402
<div class="crumb" id="crumb" title="当前文件"></div>
398403
<div class="actions">
404+
<div class="ed-switch" id="edSwitch" title="切换 HIC 版本:M 轻量(仅 HIC 内核)/ R 标准(+Python 编译)/ X 全能(+Python +C++ 编译)。切换后预览与导出页面均按所选版本编译">
405+
<button type="button" class="ed-btn" data-ed="m">M</button>
406+
<button type="button" class="ed-btn" data-ed="r">R</button>
407+
<button type="button" class="ed-btn on" data-ed="x">X</button>
408+
</div>
399409
<button id="btnLive" class="btn ghost live" title="观看实时转译:立即把当前页面 HIC 代码转译为 HTML">✓ 实时转译</button>
400410
<div class="menu-wrap">
401411
<button id="btnExport" class="btn solid">导出 ▾</button>
@@ -2264,6 +2274,7 @@ <h1>HiCode <span class="dim">· HIC 语言在线开发</span></h1>
22642274
addPage: $("addPage"),
22652275
btnLive: $("btnLive"),
22662276
btnExport: $("btnExport"),
2277+
edSwitch: $("edSwitch"),
22672278
fileImg: $("fileImg"),
22682279
fileHc: $("fileHc"),
22692280
fileApp: $("fileApp"),
@@ -2325,6 +2336,47 @@ <h1>HiCode <span class="dim">· HIC 语言在线开发</span></h1>
23252336
});
23262337
}
23272338

2339+
/* ---- 三版切换(M 轻量 / R 标准 / X 全能) ---- */
2340+
// 网页端可随时切换版本:切换后引擎可编译语言、预览与导出页面均按所选版本执行
2341+
const ED_NAME = { m: "M·轻量版", r: "R·标准版", x: "X·全能版" };
2342+
const ED_DESC = { m: "仅 HIC 内核", r: "内核 + Python 编译", x: "内核 + Python + C++ 编译" };
2343+
function edNorm(ed) {
2344+
const c = String(ed || "").toLowerCase()[0];
2345+
return (c === "m" || c === "r" || c === "x") ? c : "x";
2346+
}
2347+
function currentEdition() { return state.edition || "x"; }
2348+
// 把当前版本应用到:引擎(HC.setEdition)、全局标记(window.HIC_EDITION)、
2349+
// 顶栏版本徽标、切换器高亮、代码片段按钮(+ Python / + C++)显隐
2350+
function applyEditionUI() {
2351+
const ed = currentEdition();
2352+
if (typeof HC !== "undefined" && HC.setEdition) HC.setEdition(ed);
2353+
try { window.HIC_EDITION = ed; } catch (e) {}
2354+
const VT = document.getElementById("verTag");
2355+
if (VT) VT.textContent = "v3.66 · " + ED_NAME[ed];
2356+
if (el.edSwitch) Array.prototype.forEach.call(el.edSwitch.querySelectorAll(".ed-btn"), function (b) {
2357+
b.classList.toggle("on", b.getAttribute("data-ed") === ed);
2358+
});
2359+
Array.prototype.forEach.call(document.querySelectorAll(".snippet"), function (b) {
2360+
const needEd = (b.getAttribute("data-ed") || "").toLowerCase();
2361+
if (!needEd) return;
2362+
let visible = false;
2363+
if (needEd === "rx") visible = (ed === "r" || ed === "x");
2364+
else if (needEd === "x") visible = (ed === "x");
2365+
b.style.display = visible ? "" : "none";
2366+
});
2367+
}
2368+
function setEdition(ed, silent) {
2369+
const v = edNorm(ed);
2370+
if (v === state.edition) return;
2371+
state.edition = v;
2372+
try { localStorage.setItem("HIC_EDITION_PREF", v); } catch (e) {}
2373+
applyEditionUI();
2374+
if (!silent) {
2375+
logConsole("output", "已切换到 " + ED_NAME[v] + "(" + ED_DESC[v] + ");预览与导出页面将按此版本编译");
2376+
doLive();
2377+
}
2378+
}
2379+
23282380
/* ---- 首页引导 ---- */
23292381
function showHome() {
23302382
saveNow();
@@ -3024,16 +3076,14 @@ <h1>HiCode <span class="dim">· HIC 语言在线开发</span></h1>
30243076
});
30253077
// 可下载文件上传
30263078
el.fileApp.onchange = onFileApp;
3079+
// 三版切换器:M 轻量 / R 标准 / X 全能(切换后立即按新版本重新转译)
3080+
if (el.edSwitch) el.edSwitch.addEventListener("click", function (e) {
3081+
const b = e.target.closest ? e.target.closest("[data-ed]") : null;
3082+
if (b) setEdition(b.getAttribute("data-ed"));
3083+
});
30273084
// 快捷代码片段:触发区域 / use / 下载文件 / 原生HTML / 编译语言块
3028-
const _ed = (window.HIC_EDITION || "").toLowerCase(); // m=仅HIC r=+py x=+py+cpp
3085+
// (「+ Python / + C++」按钮随版本显隐由 applyEditionUI 统一处理)
30293086
Array.prototype.forEach.call(document.querySelectorAll(".snippet"), function (b) {
3030-
const needEd = (b.getAttribute("data-ed") || "").toLowerCase();
3031-
if (needEd) {
3032-
let ok = false;
3033-
if (needEd === "rx") ok = (_ed === "r" || _ed === "x");
3034-
else if (needEd === "x") ok = (_ed === "x");
3035-
if (!ok) { b.style.display = "none"; }
3036-
}
30373087
b.onclick = function () {
30383088
const snip = b.getAttribute("data-snip");
30393089
const code = el.code, s = code.selectionStart;
@@ -3063,15 +3113,22 @@ <h1>HiCode <span class="dim">· HIC 语言在线开发</span></h1>
30633113
function boot() {
30643114
bind();
30653115
bindNoBarPref();
3066-
// 三版发布:按 HIC_EDITION 设置引擎可编译语言并在顶栏显示版本号
3067-
const ed = (window.HIC_EDITION || "x").toLowerCase();
3068-
if (HC.setEdition) HC.setEdition(ed);
3069-
const ED_NAME = { m: "M·轻量版", r: "R·标准版", x: "X·全能版" }[ed] || "X·全能版";
3070-
const VT = document.getElementById("verTag");
3071-
if (VT) VT.textContent = "v3.66 · " + ED_NAME;
3116+
// 三版发布:网页端可直接切换 M/R/X。优先级:
3117+
// ① URL 参数 ?edition=m|r|x(下载页「在线体验三版」直达)
3118+
// ② localStorage 记忆的上次选择
3119+
// ③ 离线单文件在 <head> 注入的 window.HIC_EDITION(发布形态固定档位)
3120+
// ④ 默认 X 全能版
3121+
let ed = "";
3122+
try {
3123+
const q = new URLSearchParams(window.location.search || "").get("edition");
3124+
ed = q || localStorage.getItem("HIC_EDITION_PREF") || "";
3125+
} catch (e) { ed = ""; }
3126+
if (!ed && window.HIC_EDITION) ed = String(window.HIC_EDITION);
3127+
state.edition = edNorm(ed || "x");
3128+
applyEditionUI();
30723129
// 轻量编辑器:语法高亮 + 行号 + 自动缩进 + 括号补全
30733130
if (window.HICED) window.hiced = HICED.create(el.code);
3074-
if (typeof HC !== "undefined" && HC.APP) logConsole("output", "HiCode " + HC.APP.version + " " + ED_NAME + "(HIC " + (ed === "m" ? "仅 HIC 内核" : ed === "r" ? "内核 + Python" : "内核 + Python + C++") + ")已启动 · 就绪");
3131+
if (typeof HC !== "undefined" && HC.APP) logConsole("output", "HiCode " + HC.APP.version + " " + ED_NAME[currentEdition()] + "(HIC " + ED_DESC[currentEdition()] + ")已启动 · 就绪");
30753132
else logConsole("output", "HiCode IDE 已启动 · 就绪");
30763133
if (!Store.hasAnyProject()) { showHome(); return; }
30773134
showHome(); // 默认先回首页引导;也可自动恢复

0 commit comments

Comments
 (0)