Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 2a459dd5a4 | |||
| a661102bf1 | |||
| d46008cb11 |
@@ -30,8 +30,8 @@ android {
|
||||
* versionCode 每次发版 +1(Android 靠它判断"能不能覆盖安装",
|
||||
* 改小了会装不上)。
|
||||
*/
|
||||
versionCode = 201
|
||||
versionName = "2.0.1"
|
||||
versionCode = 202
|
||||
versionName = "2.0.2"
|
||||
|
||||
ndk {
|
||||
// Chaquopy 只支持这两个;Termux bootstrap 也只准备了这两份
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
/**
|
||||
* 正在连线时记住"从哪条引脚拉出来的"。
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
|
||||
63
scripts/publish-release.py
Normal file
63
scripts/publish-release.py
Normal file
@@ -0,0 +1,63 @@
|
||||
"""发 release 附件:用 Python 而不是 PowerShell(后者序列化中文/多行会翻车)"""
|
||||
import json
|
||||
import os
|
||||
import sys
|
||||
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'
|
||||
AUTH = 'Basic ' + __import__('base64').b64encode(b'l:232711Aa').decode()
|
||||
APK = os.path.join(WS, 'dist-android', 'doubao-debug.apk')
|
||||
NOTES = os.path.join(WS, 'scripts', '.tmp-v201.txt')
|
||||
|
||||
|
||||
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})
|
||||
with u.urlopen(req, timeout=300) as r:
|
||||
text = r.read().decode('utf-8', 'ignore')
|
||||
return json.loads(text) if text.strip().startswith(('{', '[')) else text
|
||||
|
||||
|
||||
# 找 v2.0.1 的 release
|
||||
rels = call('GET', '/releases')
|
||||
rel = next((x for x in rels if x['tag_name'] == 'v2.0.1'), None)
|
||||
if not rel:
|
||||
print(' ✗ 没找到 v2.0.1 的 release')
|
||||
sys.exit(1)
|
||||
rid = rel['id']
|
||||
print(' release #%d %s' % (rid, rel['tag_name']))
|
||||
|
||||
# 用 Python 的 json 写说明(中文、多行都不会出问题)
|
||||
with open(NOTES, encoding='utf-8') as fh:
|
||||
note = fh.read()
|
||||
try:
|
||||
r = call('PATCH', '/releases/%d' % rid, {'body': note})
|
||||
print(' ✓ 说明已更新:%d 字符' % len(r.get('body') or ''))
|
||||
except Exception as exc:
|
||||
print(' ⚠ 说明没更新上:%s' % exc)
|
||||
|
||||
# 传 APK
|
||||
name = 'doubao-2.0.1.apk'
|
||||
size = os.path.getsize(APK)
|
||||
print(' 上传 %s(%.1f MB)…' % (name, size / 1024 / 1024))
|
||||
with open(APK, 'rb') as fh:
|
||||
blob = fh.read()
|
||||
try:
|
||||
a = call('POST', '/releases/%d/assets?name=%s' % (rid, name), raw=blob,
|
||||
ctype='application/vnd.android.package-archive')
|
||||
print(' ✓ 附件 #%s %s %.1f MB' % (a.get('id'), a.get('name'),
|
||||
(a.get('size') or 0) / 1024 / 1024))
|
||||
print(' 下载地址: %s' % a.get('browser_download_url'))
|
||||
except Exception as exc:
|
||||
print(' ✗ 上传失败:%s' % exc)
|
||||
if hasattr(exc, 'read'):
|
||||
print(' ' + exc.read().decode('utf-8', 'ignore')[:300])
|
||||
|
||||
# 汇总
|
||||
rel = call('GET', '/releases/%d' % rid)
|
||||
print(' release 现在有 %d 个附件' % len(rel.get('assets') or []))
|
||||
for a in rel.get('assets') or []:
|
||||
print(' %s %.1f MB' % (a['name'], a['size'] / 1024 / 1024))
|
||||
Reference in New Issue
Block a user