Skip to content

Commit f3c71a6

Browse files
committed
添加缺失的文件
1 parent db4433b commit f3c71a6

4 files changed

Lines changed: 216 additions & 5 deletions

File tree

.idea/workspace.xml

Lines changed: 3 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

scripts/release_tag.sh

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
#!/bin/bash
2+
3+
# 当任何命令失败时,立即退出脚本
4+
set -e
5+
6+
# --- 配置 ---
7+
# 检查 git 命令是否存在
8+
if ! command -v git &> /dev/null
9+
then
10+
echo "错误: git 命令未找到. 请先安装 Git."
11+
exit 1
12+
fi
13+
14+
15+
# --- 函数定义 ---
16+
17+
# 显示用法说明
18+
usage() {
19+
echo "用法: $0 <tag_name>"
20+
echo "例如: $0 v1.2.3"
21+
exit 1
22+
}
23+
24+
# 创建并推送标签
25+
create_and_push_tag() {
26+
local TAG_NAME=$1
27+
echo "➡️ 正在创建本地标签: $TAG_NAME..."
28+
git tag "$TAG_NAME"
29+
echo "✅ 本地标签创建成功."
30+
31+
echo "➡️ 正在推送标签到远程仓库..."
32+
git push origin "$TAG_NAME"
33+
echo "✅ 标签 '$TAG_NAME' 已成功推送到远程仓库."
34+
}
35+
36+
# 删除本地和远程的标签
37+
delete_tag() {
38+
local TAG_NAME=$1
39+
echo "➡️ 正在删除本地标签: $TAG_NAME..."
40+
git tag -d "$TAG_NAME" || echo "ℹ️ 本地标签不存在, 跳过删除."
41+
42+
echo "➡️ 正在删除远程标签: $TAG_NAME..."
43+
git push --delete origin "$TAG_NAME" || echo "ℹ️ 远程标签不存在, 跳过删除."
44+
45+
echo "✅ 标签 '$TAG_NAME' 已从本地和远程仓库删除."
46+
}
47+
48+
# --- 主逻辑 ---
49+
50+
# 检查是否提供了标签名
51+
if [ -z "$1" ]; then
52+
usage
53+
fi
54+
55+
TAG_NAME=$1
56+
57+
# 主菜单
58+
echo "🚀 Git 标签发布助手"
59+
echo "----------------------------------"
60+
echo "操作的标签: $TAG_NAME"
61+
echo "----------------------------------"
62+
echo "1. 发布新标签"
63+
echo "2. 删除并重试"
64+
echo "3. 仅删除标签"
65+
echo "4. 退出"
66+
echo "----------------------------------"
67+
68+
read -p "请输入你的选择 [1-4]: " choice
69+
70+
case $choice in
71+
1)
72+
echo "--- 开始发布新标签 ---"
73+
create_and_push_tag "$TAG_NAME"
74+
;;
75+
2)
76+
echo "--- 开始删除并重试 ---"
77+
delete_tag "$TAG_NAME"
78+
echo "🔄 准备重试..."
79+
create_and_push_tag "$TAG_NAME"
80+
;;
81+
3)
82+
echo "--- 开始仅删除标签 ---"
83+
delete_tag "$TAG_NAME"
84+
;;
85+
4)
86+
echo "👋 已取消操作."
87+
exit 0
88+
;;
89+
*)
90+
echo "❌ 无效的选择. 脚本退出."
91+
exit 1
92+
;;
93+
esac
94+
95+
echo "🎉 操作完成!"
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
package vm
2+
3+
import com.google.gson.*
4+
import vm.element.WidgetNode
5+
6+
/**
7+
* 安全的Gson配置,用于处理深度嵌套的Widget Tree
8+
*/
9+
object SafeGsonConfig {
10+
11+
private const val MAX_DEPTH = 250
12+
13+
val gson: Gson = GsonBuilder()
14+
.setStrictness(Strictness.LENIENT)
15+
.registerTypeAdapter(WidgetNode::class.java, SafeWidgetNodeDeserializer())
16+
.create()
17+
18+
/**
19+
* 安全的WidgetNode反序列化器,限制嵌套深度
20+
*/
21+
class SafeWidgetNodeDeserializer : JsonDeserializer<WidgetNode> {
22+
23+
override fun deserialize(
24+
json: JsonElement,
25+
typeOfT: java.lang.reflect.Type,
26+
context: JsonDeserializationContext
27+
): WidgetNode {
28+
return deserializeWithDepth(json, context, 0)
29+
}
30+
31+
private fun deserializeWithDepth(
32+
json: JsonElement,
33+
context: JsonDeserializationContext,
34+
currentDepth: Int
35+
): WidgetNode {
36+
val jsonObject = json.asJsonObject
37+
38+
// 如果深度超过限制,返回简化的节点
39+
if (currentDepth >= MAX_DEPTH) {
40+
return WidgetNode(
41+
description = jsonObject.get("description")?.asString + " (深度限制)",
42+
shouldIndent = jsonObject.get("shouldIndent")?.asBoolean,
43+
widgetRuntimeType = jsonObject.get("widgetRuntimeType")?.asString,
44+
valueId = jsonObject.get("valueId")?.asString,
45+
createdByLocalProject = jsonObject.get("createdByLocalProject")?.asBoolean,
46+
children = null, // 截断子节点
47+
textPreview = jsonObject.get("textPreview")?.asString,
48+
properties = null,
49+
renderObject = null,
50+
hasChildren = jsonObject.get("hasChildren")?.asBoolean,
51+
allowsInspection = jsonObject.get("allowsInspection")?.asBoolean,
52+
locationId = jsonObject.get("locationId")?.asString,
53+
creationLocation = null,
54+
isStateful = jsonObject.get("isStateful")?.asBoolean
55+
)
56+
}
57+
58+
// 递归处理子节点
59+
val children = jsonObject.get("children")?.asJsonArray?.let { childrenArray ->
60+
if (childrenArray.size() > 20) {
61+
// 如果子节点太多,只取前20个
62+
childrenArray.take(20).map { childElement ->
63+
deserializeWithDepth(childElement, context, currentDepth + 1)
64+
}
65+
} else {
66+
childrenArray.map { childElement ->
67+
deserializeWithDepth(childElement, context, currentDepth + 1)
68+
}
69+
}
70+
}
71+
72+
return WidgetNode(
73+
description = jsonObject.get("description")?.asString,
74+
shouldIndent = jsonObject.get("shouldIndent")?.asBoolean,
75+
widgetRuntimeType = jsonObject.get("widgetRuntimeType")?.asString,
76+
valueId = jsonObject.get("valueId")?.asString,
77+
createdByLocalProject = jsonObject.get("createdByLocalProject")?.asBoolean,
78+
children = children,
79+
textPreview = jsonObject.get("textPreview")?.asString,
80+
properties = null, // 暂时不处理properties以减少复杂度
81+
renderObject = null,
82+
hasChildren = jsonObject.get("hasChildren")?.asBoolean,
83+
allowsInspection = jsonObject.get("allowsInspection")?.asBoolean,
84+
locationId = jsonObject.get("locationId")?.asString,
85+
creationLocation = null, // 暂时不处理creationLocation
86+
isStateful = jsonObject.get("isStateful")?.asBoolean
87+
)
88+
}
89+
}
90+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package vm.element
2+
3+
import com.google.gson.annotations.SerializedName
4+
5+
/**
6+
* 选中的Widget信息
7+
*/
8+
data class SelectedWidgetInfo(
9+
@SerializedName("result")
10+
val result: SelectedWidgetResult?
11+
)
12+
13+
data class SelectedWidgetResult(
14+
@SerializedName("objectId")
15+
val objectId: String?,
16+
17+
@SerializedName("creationLocation")
18+
val creationLocation: CreationLocation?,
19+
20+
@SerializedName("description")
21+
val description: String?,
22+
23+
@SerializedName("widgetRuntimeType")
24+
val widgetRuntimeType: String?,
25+
26+
@SerializedName("properties")
27+
val properties: List<WidgetProperty>?
28+
)

0 commit comments

Comments
 (0)