Files
ykxmz/_build/patch_dynamic_feature_tab.py
T
xmz7891 b705216e4a ykxmz 1.5.0锛氫慨澶嶆墜琛ㄧ TLS 璇佷功鏍¢獙 + MTU 淇缃戠粶绋冲畾鎬?
琚帶绔?- 淇 MTU 闂锛氬す MSS + 璺緞 MTU 鎺㈡祴锛堝叕缃戝彲鐢ㄧ巼 48% -> 100%锛?- 澶嶇敤 HTTP 杩炴帴锛堝厤鎺夋瘡娆℃柊寤?TLS 鐨?30% 鎻℃墜澶辫触锛?- 姣忓垎閽熷洖澶存壘灞€鍩熺綉锛岃嚜鍔ㄥ垏鍥炲揩 400 鍊嶇殑璺緞
- 鐢婚潰蹇冭烦甯э細闈欐鏃剁渷娴侀噺锛屽鎴风浠嶇煡閬撴祦鏄椿鐨?- 閿佸睆鏃剁粰鍑哄彲鎿嶄綔鐨勬彁绀?
鎵嬭〃绔?- 鍐呯疆 GTS Root R4 / GlobalSign Root CA锛屼慨 SSLHandshakeException
- 杩炴帴閿欒缈昏瘧鎴愪汉璇濓紙璇佷功/鏃堕棿/瑙f瀽/瓒呮椂鍒嗗埆鎻愮ず锛?- 缁忎腑杞繛涓婂悗鐢ㄦ湇鍔″櫒鎶ョ殑鍦板潃鍒锋柊宸查厤瀵硅褰?- 鏂板灞€鍩熺綉杩炴帴椤甸潰銆佹湇鍔″櫒寤惰繜妫€娴?
鏈嶅姟鍣ㄧ
- 鏀寔 chunked 璇锋眰浣擄紙淇瘡 16 绉掍竴娆$殑杩炴帴閿欎贡涓庡ぇ闈㈢Н 502锛?- 缃戠粶璋冧紭鑴氭湰 net-tune.sh锛堝紑鏈鸿嚜鍔ㄥ簲鐢級
- 绠$悊椤碉細鎵归噺鍒犻櫎銆佺綉缁滀綋妫€銆佷笅杞藉尯
- 闅ч亾鏀?HTTP/2 + 鍙岃繛鎺?
鏂囨。
- 璁稿彲鍗忚 / 瀹夎鍓嶅繀璇?/ 瀹夎鍚庨』鐭ワ紙浣滆€咃細灏忛害瀛愶級
2026-10-06 19:01:05 +08:00

155 lines
5.8 KiB
Python

# -*- coding: utf-8 -*-
"""「功能」分页改成动态:分组由电脑端声明,手表端拉取后渲染。
原来写死了 6 个分组按钮,现在电脑端有 10 组、80 个功能,
写死就不合适了 —— 以后电脑端加一组,手表端自动就有。
"""
from __future__ import annotations
import sys
from pathlib import Path
MAIN = Path(r"C:\Users\shu\Desktop\deepseekagent\LanRemote\android\src"
r"\com\lanremote\watch\MainActivity.java")
# 1. 「功能」分页只留一个占位按钮(真正的按钮动态生成)
TAB_OLD = ''' new TabDef("功能", new Act[]{
act("显示", new Runnable() {
public void run() { pickFeatureGroup("显示"); }
}),
act("音量", new Runnable() {
public void run() { pickFeatureGroup("音量"); }
}),
act("系统", new Runnable() {
public void run() { pickFeatureGroup("系统"); }
}),
act("查看", new Runnable() {
public void run() { pickFeatureGroup("查看"); }
}),
act("效率", new Runnable() {
public void run() { pickFeatureGroup("效率"); }
}),
act("文件", new Runnable() {
public void run() { pickFeatureGroup("文件"); }
}),
}),'''
TAB_NEW = ''' // 「功能」页的按钮是动态生成的,这里留空
new TabDef("功能", new Act[]{}),'''
# 2. selectTab:功能页走动态构建
SELECT_OLD = ''' tabContent.removeAllViews();
cellQueue.clear();
for (Act item : tabDefs[index].acts) {
addRow(tabContent, action(item.label, item.task), null);
}
flushGrid(tabContent);
}'''
SELECT_NEW = ''' if ("功能".equals(tabDefs[index].name)) {
buildFeatureTab();
return;
}
tabContent.removeAllViews();
cellQueue.clear();
for (Act item : tabDefs[index].acts) {
addRow(tabContent, action(item.label, item.task), null);
}
flushGrid(tabContent);
}
/** 「功能」页:分组由电脑端声明,这里拉取后动态生成按钮。 */
private void buildFeatureTab() {
tabContent.removeAllViews();
cellQueue.clear();
if (featureGroups == null) {
TextView hint = new TextView(this);
hint.setText("正在获取电脑端功能列表…");
hint.setTextColor(C_DIM);
hint.setTextSize(TypedValue.COMPLEX_UNIT_SP, 12);
hint.setPadding(dp(4), dp(8), dp(4), dp(8));
tabContent.addView(hint);
io.execute(new Runnable() {
@Override
public void run() {
try {
Map<String, Object> reply =
client.call(Json.obj("cmd", "feature_list"), 20000);
final List<Map<String, Object>> items = mapList(reply, "features");
final List<String> groups = new ArrayList<String>();
for (Map<String, Object> item : items) {
String group = Json.str(item, "group", "其他");
if (!groups.contains(group)) {
groups.add(group);
}
}
featureCache = items;
ui.post(new Runnable() {
@Override
public void run() {
featureGroups = groups;
selectTab(currentTab);
}
});
} catch (final IOException e) {
ui.post(new Runnable() {
@Override
public void run() {
appendLog("获取功能列表失败:" + e.getMessage());
toast("没能连上电脑");
}
});
}
}
});
return;
}
if (featureGroups.isEmpty()) {
TextView hint = new TextView(this);
hint.setText("电脑端没有声明任何功能");
hint.setTextColor(C_DIM);
hint.setPadding(dp(4), dp(8), dp(4), dp(8));
tabContent.addView(hint);
return;
}
for (final String group : featureGroups) {
addRow(tabContent, action(group, new Runnable() {
@Override
public void run() {
pickFeatureGroup(group);
}
}), null);
}
flushGrid(tabContent);
}'''
# 3. 字段
FIELD_OLD = " private List<Map<String, Object>> featureCache = null;"
FIELD_NEW = (" private List<Map<String, Object>> featureCache = null;\n"
" private List<String> featureGroups = null;")
def main() -> int:
text = MAIN.read_text(encoding="utf-8")
ok = True
for old, new, tag in ((FIELD_OLD, FIELD_NEW, "字段"),
(TAB_OLD, TAB_NEW, "功能分页"),
(SELECT_OLD, SELECT_NEW, "动态构建")):
if old not in text:
print(f" [失败] {tag} 锚点未匹配")
ok = False
else:
text = text.replace(old, new, 1)
print(f" {tag}: OK")
if ok:
MAIN.write_text(text, encoding="utf-8")
return 0 if ok else 1
if __name__ == "__main__":
sys.exit(main())