Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| affc407f5e | |||
| 29f29a4524 | |||
| 2a459dd5a4 | |||
| a661102bf1 | |||
| d46008cb11 |
@@ -30,8 +30,8 @@ android {
|
||||
* versionCode 每次发版 +1(Android 靠它判断"能不能覆盖安装",
|
||||
* 改小了会装不上)。
|
||||
*/
|
||||
versionCode = 201
|
||||
versionName = "2.0.1"
|
||||
versionCode = 203
|
||||
versionName = "2.0.3"
|
||||
|
||||
ndk {
|
||||
// Chaquopy 只支持这两个;Termux bootstrap 也只准备了这两份
|
||||
@@ -39,14 +39,52 @@ android {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 签名。
|
||||
*
|
||||
* ★ 为什么要自己配一个 keystore,而不是用 debug 默认的:
|
||||
*
|
||||
* 1. **debug 证书换机器就变**。用 debug 包发出去,换台电脑构建出来的
|
||||
* 签名指纹不一样,用户装的时候必须**先卸载**(Android 不允许
|
||||
* 同包名不同签名覆盖安装)。发出去的包就成了"只能装一次"的。
|
||||
*
|
||||
* 2. **默认只签 v2/v3,缺 v1(JAR)签名**。Android 7+ 自己装没问题,
|
||||
* 但很多安装器(比如从远程传过去的)和严格的 ROM 会按 v1 检查,
|
||||
* 报"解析失败:安装包没有签名文件" —— 这个真踩到了。
|
||||
* 下面显式把 v1/v2/v3 全开。
|
||||
*
|
||||
* ★ 密码就写在这里,**它不是秘密**:keystore 也提交进仓库了。
|
||||
* 这是个**自签**证书,目的是"指纹稳定、能覆盖安装",不是"证明是谁发的"。
|
||||
* 谁拿到这个仓库谁就能签出一样的包 —— 对这个本地工具来说够了。
|
||||
* (真要防伪得保护 keystore + 用 CI 的密钥管理,那是另一件事。)
|
||||
*/
|
||||
signingConfigs {
|
||||
create("doubao") {
|
||||
storeFile = file("../doubao-release.jks")
|
||||
storePassword = "doubao-clone"
|
||||
keyAlias = "doubao"
|
||||
keyPassword = "doubao-clone"
|
||||
// ★ 三个方案全开:v1 给老安装器,v2/v3 给新系统
|
||||
enableV1Signing = true
|
||||
enableV2Signing = true
|
||||
enableV3Signing = true
|
||||
}
|
||||
}
|
||||
|
||||
buildTypes {
|
||||
release {
|
||||
isMinifyEnabled = false
|
||||
signingConfig = signingConfigs.getByName("doubao")
|
||||
proguardFiles(
|
||||
getDefaultProguardFile("proguard-android-optimize.txt"),
|
||||
"proguard-rules.pro",
|
||||
)
|
||||
}
|
||||
debug {
|
||||
// debug 包也用它 —— 这样"我本地调试的包"和"发出去的包"
|
||||
// 签名一致,能互相覆盖安装,不用来回卸载
|
||||
signingConfig = signingConfigs.getByName("doubao")
|
||||
}
|
||||
}
|
||||
|
||||
compileOptions {
|
||||
|
||||
@@ -892,7 +892,11 @@ private fun MeetingEditorScreen(vm: AppViewModel, initial: Meeting, onBack: () -
|
||||
&& (branch == "true" || branch == "false")
|
||||
val dup = meeting.edges.any {
|
||||
it.from == from && it.to == n.id &&
|
||||
it.branch == branch && it.kind == fromKind
|
||||
it.branch == branch && it.kind == fromKind &&
|
||||
// ★ 引脚也要一起比:运算的两个入口都是 num,
|
||||
// 光看 kind 的话"给 A 接了、再给 B 接"会被当成
|
||||
// 重复(其实是两个不同的入口,都得接上)。
|
||||
it.toPin == pin.key
|
||||
}
|
||||
if (!dup) {
|
||||
val kept = if (isBranch) {
|
||||
@@ -903,8 +907,25 @@ private fun MeetingEditorScreen(vm: AppViewModel, initial: Meeting, onBack: () -
|
||||
} else {
|
||||
meeting.edges
|
||||
}
|
||||
// ★ 一个**数据入口**只接一根线(后接的替换先接的)。
|
||||
// 不然两条线并到一个入口,用户以为接上了 B、
|
||||
// 其实两根都进 A(这就是"B 连不上")。
|
||||
val kept2 = if (fromKind == "exec") {
|
||||
kept
|
||||
} else {
|
||||
kept.filterNot {
|
||||
it.to == n.id && it.toPin == pin.key &&
|
||||
it.kind != "exec"
|
||||
}
|
||||
}
|
||||
meeting = meeting.copy(
|
||||
edges = kept + MeetingEdge(from, n.id, branch, fromKind),
|
||||
edges = kept2 + MeetingEdge(
|
||||
from = from,
|
||||
to = n.id,
|
||||
branch = branch,
|
||||
kind = fromKind,
|
||||
toPin = pin.key,
|
||||
),
|
||||
)
|
||||
dirty = true
|
||||
persist()
|
||||
@@ -955,8 +976,8 @@ private fun MeetingEditorScreen(vm: AppViewModel, initial: Meeting, onBack: () -
|
||||
val b = meeting.nodes.firstOrNull { it.id == edge.to } ?: return@forEach
|
||||
// ★ 从**引脚的准确位置**出发,不是从节点中心 ——
|
||||
// 判断节点两条出线一行一个,都从中心出发就分不清谁是谁
|
||||
val start = px(portOut(a, edge.kind, edge.branch))
|
||||
val end = px(portIn(b, edge.kind))
|
||||
val start = px(portOut(a, edge.kind, edge.branch, edge.fromPin))
|
||||
val end = px(portIn(b, edge.kind, edge.toPin))
|
||||
// ★ 执行线白色(蓝图里 exec 线就是白的),
|
||||
// 数据线按**类型**上色(白/绿/蓝/红)——
|
||||
// 和引脚同一个颜色,用户顺着颜色就能看出这根线接得对不对。
|
||||
@@ -1972,8 +1993,22 @@ private fun outPinIndex(node: MeetingNode, kind: String, branch: String): Int {
|
||||
* 找不到对应种类时退回第一条 —— 老会议里没有 kind 字段,边一律当 exec,
|
||||
* 而老图的节点只有一条入线,退回第一条正好对上。
|
||||
*/
|
||||
private fun portIn(node: MeetingNode, kind: String): Offset {
|
||||
private fun portIn(
|
||||
node: MeetingNode,
|
||||
kind: String,
|
||||
/**
|
||||
* 边上记的引脚 key。有就**按 key 精确定位** ——
|
||||
* 运算的 A/B 都是 num,不靠它分不开(表现就是两条线都落在 A 上、B 收不到)。
|
||||
*/
|
||||
pinKey: String = "",
|
||||
) : Offset {
|
||||
val pins = inputPins(node)
|
||||
// ① 边上有引脚 key:精确匹配(新会议都走这条)
|
||||
if (pinKey.isNotBlank()) {
|
||||
val byKey = pins.indexOfFirst { it.key == pinKey }
|
||||
if (byKey >= 0) return pinPos(node, byKey, isOutput = false)
|
||||
}
|
||||
// ② 没记引脚(老会议):退回按类型找
|
||||
// ★ 按"这个入口能不能接 kind"来找,不是 kind 相等 ——
|
||||
// while 的条件入口能接 bool 和 str,两种情况都得能定位到同一条引脚。
|
||||
val index = pins.indexOfFirst { it.accepts_(kind) }
|
||||
@@ -1981,8 +2016,20 @@ private fun portIn(node: MeetingNode, kind: String): Offset {
|
||||
}
|
||||
|
||||
/** 输出端口的位置 */
|
||||
private fun portOut(node: MeetingNode, kind: String, branch: String): Offset =
|
||||
pinPos(node, outPinIndex(node, kind, branch), isOutput = true)
|
||||
private fun portOut(
|
||||
node: MeetingNode,
|
||||
kind: String,
|
||||
branch: String,
|
||||
/** 边上记的引脚 key(同 portIn;只有自定义节点有多个同名类型的数据出口时才用得上) */
|
||||
pinKey: String = "",
|
||||
): Offset {
|
||||
val pins = outputPins(node)
|
||||
if (pinKey.isNotBlank()) {
|
||||
val byKey = pins.indexOfFirst { it.key == pinKey }
|
||||
if (byKey >= 0) return pinPos(node, byKey, isOutput = true)
|
||||
}
|
||||
return pinPos(node, outPinIndex(node, kind, branch), isOutput = true)
|
||||
}
|
||||
|
||||
/**
|
||||
* 正在连线时记住"从哪条引脚拉出来的"。
|
||||
|
||||
BIN
android/doubao-release.jks
Normal file
BIN
android/doubao-release.jks
Normal file
Binary file not shown.
@@ -1006,7 +1006,16 @@ def _sanitize_edges(edges: list, nodes: list) -> list:
|
||||
if want is None or give is None or give not in want:
|
||||
continue
|
||||
|
||||
out.append({'from': src, 'to': dst, 'branch': str(e.get('branch') or ''), 'kind': kind})
|
||||
# ★ 引脚信息要**原样留着**:一个节点有两个同类型入口(运算的 A/B)时,
|
||||
# 光靠 from/to 分不清线接的是哪个 —— 表现就是"两条线都落在 A 上,
|
||||
# B 永远收不到"。老的边没这个字段,留空时按顺序兜底。
|
||||
out.append({
|
||||
'from': src, 'to': dst,
|
||||
'branch': str(e.get('branch') or ''),
|
||||
'kind': kind,
|
||||
'toPin': str(e.get('toPin') or ''),
|
||||
'fromPin': str(e.get('fromPin') or ''),
|
||||
})
|
||||
return out
|
||||
|
||||
|
||||
|
||||
110
scripts/publish-release.py
Normal file
110
scripts/publish-release.py
Normal file
@@ -0,0 +1,110 @@
|
||||
"""
|
||||
发 release:建说明 + 传 APK 附件。
|
||||
|
||||
用法:
|
||||
python scripts/publish-release.py v2.0.2 scripts/.tmp-v202.txt
|
||||
|
||||
为什么用 Python 而不是 PowerShell:
|
||||
PowerShell 的 ConvertTo-Json 处理**中文 + 多行 markdown** 会翻车 ——
|
||||
Gitea 会回 422("cannot unmarshal object into Go struct field
|
||||
CreateReleaseOption.Note of type string"),而且看不出哪里错了。
|
||||
这个坑真踩过两次,所以这个脚本固定用 Python。
|
||||
|
||||
需要的:
|
||||
· Gitea 上有这个 tag(先 git push local <tag>)
|
||||
· 本地已经构建好 dist-android/doubao-debug.apk
|
||||
"""
|
||||
import base64
|
||||
import json
|
||||
import os
|
||||
import sys
|
||||
import urllib.error
|
||||
import urllib.request as u
|
||||
|
||||
WS = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||||
API = 'http://192.168.100.103:8080/api/v1/repos/l/doubao-clone'
|
||||
# ★ 凭据不从仓库读(仓库是公开的)。要发版就先把这两个环境变量设上:
|
||||
# DOUBAO_GIT_USER / DOUBAO_GIT_PASS
|
||||
# 没设时退回默认值,方便本机用。
|
||||
USER = os.environ.get('DOUBAO_GIT_USER') or 'l'
|
||||
PASS = os.environ.get('DOUBAO_GIT_PASS') or '232711Aa'
|
||||
AUTH = 'Basic ' + base64.b64encode(f'{USER}:{PASS}'.encode()).decode()
|
||||
APK = os.path.join(WS, 'dist-android', 'doubao-debug.apk')
|
||||
|
||||
|
||||
def call(method, path, data=None, ctype='application/json', raw=None):
|
||||
body = raw if raw is not None else (
|
||||
json.dumps(data).encode('utf-8') if data is not None else None)
|
||||
req = u.Request(API + path, data=body, method=method,
|
||||
headers={'Authorization': AUTH, 'Content-Type': ctype})
|
||||
try:
|
||||
with u.urlopen(req, timeout=600) as r:
|
||||
text = r.read().decode('utf-8', 'ignore')
|
||||
except urllib.error.HTTPError as exc:
|
||||
detail = exc.read().decode('utf-8', 'ignore')[:400]
|
||||
raise RuntimeError(f'HTTP {exc.code}: {detail}') from None
|
||||
return json.loads(text) if text.strip().startswith(('{', '[')) else text
|
||||
|
||||
|
||||
def main():
|
||||
if len(sys.argv) < 2:
|
||||
print('用法: publish-release.py <tag> [说明文件]')
|
||||
return 1
|
||||
tag = sys.argv[1]
|
||||
notes_file = sys.argv[2] if len(sys.argv) > 2 else ''
|
||||
# 附件名带版本号,下载下来能一眼看出是哪版
|
||||
ver = tag.lstrip('v')
|
||||
apk_name = f'doubao-{ver}.apk'
|
||||
|
||||
if not os.path.isfile(APK):
|
||||
print(f' ✗ 没找到 APK:{APK}(先 node scripts/build-apk.mjs)')
|
||||
return 1
|
||||
|
||||
# 说明:优先用文件,没有就留空
|
||||
note = ''
|
||||
if notes_file and os.path.isfile(notes_file):
|
||||
with open(notes_file, encoding='utf-8') as fh:
|
||||
note = fh.read()
|
||||
|
||||
# 找 release(tag 已经推上去了的话 Gitea 可能已经自动建了一个草稿)
|
||||
rels = call('GET', '/releases')
|
||||
rel = next((x for x in rels if x['tag_name'] == tag), None)
|
||||
if rel:
|
||||
rid = rel['id']
|
||||
print(f' 已有 release #{rid} {tag}')
|
||||
if note:
|
||||
r = call('PATCH', f'/releases/{rid}', {'body': note})
|
||||
print(f' ✓ 说明已更新:{len(r.get("body") or "")} 字符')
|
||||
else:
|
||||
payload = {'tag_name': tag, 'name': tag, 'body': note,
|
||||
'draft': False, 'prerelease': False}
|
||||
r = call('POST', '/releases', payload)
|
||||
rid = r['id']
|
||||
print(f' ✓ 建好 release #{rid} {tag}')
|
||||
|
||||
# 传 APK(同名附件先删掉,重发时不会堆一串)
|
||||
rel = call('GET', f'/releases/{rid}')
|
||||
for a in rel.get('assets') or []:
|
||||
if a['name'] == apk_name:
|
||||
call('DELETE', f'/releases/{rid}/assets/{a["id"]}')
|
||||
print(f' · 删掉旧的同名附件 {apk_name}')
|
||||
|
||||
size = os.path.getsize(APK)
|
||||
print(f' 上传 {apk_name}({size / 1024 / 1024:.1f} MB)…')
|
||||
with open(APK, 'rb') as fh:
|
||||
blob = fh.read()
|
||||
a = call('POST', f'/releases/{rid}/assets?name={apk_name}', raw=blob,
|
||||
ctype='application/vnd.android.package-archive')
|
||||
print(f' ✓ 附件 #{a.get("id")} {a.get("name")} '
|
||||
f'{(a.get("size") or 0) / 1024 / 1024:.1f} MB')
|
||||
print(f' 直链: {a.get("browser_download_url")}')
|
||||
|
||||
rel = call('GET', f'/releases/{rid}')
|
||||
print(f' release 现在有 {len(rel.get("assets") or [])} 个附件:')
|
||||
for x in rel.get('assets') or []:
|
||||
print(f' {x["name"]} {x["size"] / 1024 / 1024:.1f} MB')
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
sys.exit(main())
|
||||
Reference in New Issue
Block a user