壳子替换
This commit is contained in:
@@ -938,9 +938,116 @@ public static class ToolResultBuilder
|
||||
metadata["defaultExpandedBlocks"] = string.Join(",", experience.DefaultExpandedBlocks ?? []);
|
||||
}
|
||||
|
||||
var localJsProfile = LocalJsProfileFor(toolId);
|
||||
if (!string.IsNullOrWhiteSpace(localJsProfile))
|
||||
{
|
||||
metadata["localJsProfile"] = localJsProfile;
|
||||
}
|
||||
|
||||
var relatedActions = RelatedActionsFor(toolId, language);
|
||||
if (!string.IsNullOrWhiteSpace(relatedActions))
|
||||
{
|
||||
metadata["relatedActions"] = relatedActions;
|
||||
}
|
||||
|
||||
return metadata;
|
||||
}
|
||||
|
||||
private static string LocalJsProfileFor(string toolId)
|
||||
=> toolId switch
|
||||
{
|
||||
"json_formatter" => "json",
|
||||
"yaml_json_converter" => "yaml",
|
||||
"xml_formatter" => "xml",
|
||||
"html_minifier" or "js_obfuscator" => "markup",
|
||||
"markdown_preview" or "markdown_table_normalizer" => "markdown",
|
||||
"html_entity" => "html-entity",
|
||||
"punycode_codec" => "idn",
|
||||
"timestamp_converter" or "date_time_calculator" => "time",
|
||||
"base64_codec" or "url_codec" or "unicode_codec" => "codec",
|
||||
"hash_generator" or "hmac_generator" => "hash",
|
||||
"qr_generator" => "qrcode",
|
||||
_ => string.Empty
|
||||
};
|
||||
|
||||
private static string RelatedActionsFor(string toolId, string language)
|
||||
{
|
||||
var english = language.StartsWith("en", StringComparison.OrdinalIgnoreCase);
|
||||
object Action(string kind, string labelZh, string labelEn, string target, string toolId = "", string routeTag = "")
|
||||
=> new
|
||||
{
|
||||
kind,
|
||||
label = english ? labelEn : labelZh,
|
||||
target,
|
||||
toolId,
|
||||
routeTag
|
||||
};
|
||||
|
||||
var actions = toolId switch
|
||||
{
|
||||
"json_formatter" => new[]
|
||||
{
|
||||
Action("navigateTool", "转到 JSONPath", "Open JSONPath", "json_path_helper", "json_path_helper"),
|
||||
Action("navigateTool", "转 YAML/JSON", "Open YAML/JSON", "yaml_json_converter", "yaml_json_converter")
|
||||
},
|
||||
"yaml_json_converter" => new[]
|
||||
{
|
||||
Action("navigateTool", "转到 JSON 格式化", "Open JSON formatter", "json_formatter", "json_formatter")
|
||||
},
|
||||
"markdown_preview" => new[]
|
||||
{
|
||||
Action("navigateTool", "整理 Markdown 表格", "Normalize markdown table", "markdown_table_normalizer", "markdown_table_normalizer")
|
||||
},
|
||||
"markdown_table_normalizer" => new[]
|
||||
{
|
||||
Action("navigateTool", "预览 Markdown", "Preview markdown", "markdown_preview", "markdown_preview")
|
||||
},
|
||||
"base64_codec" or "url_codec" or "html_entity" or "unicode_codec" or "punycode_codec" => new[]
|
||||
{
|
||||
Action("navigateTool", "转到 URL 编解码", "Open URL codec", "url_codec", "url_codec"),
|
||||
Action("navigateTool", "转到 Base64", "Open Base64", "base64_codec", "base64_codec")
|
||||
},
|
||||
"url_inspector" or "url_redirect_trace" => new[]
|
||||
{
|
||||
Action("navigateTool", "转到 URL 编解码", "Open URL codec", "url_codec", "url_codec"),
|
||||
Action("navigateTool", "转到域名 RDAP", "Open domain RDAP", "rdap_domain_lookup", "rdap_domain_lookup")
|
||||
},
|
||||
"dns_query" or "ip_lookup" or "ip_info" => new[]
|
||||
{
|
||||
Action("navigateTool", "转到 IP 信息", "Open IP info", "ip_info", "ip_info"),
|
||||
Action("navigateTool", "转到 RDAP 查询", "Open RDAP lookup", "rdap_ip_lookup", "rdap_ip_lookup")
|
||||
},
|
||||
"hash_generator" or "hmac_generator" => new[]
|
||||
{
|
||||
Action("navigateTool", "生成哈希清单", "Build hash manifest", "hash_manifest_builder", "hash_manifest_builder"),
|
||||
Action("navigateTool", "校验哈希清单", "Verify hash manifest", "hash_manifest_verify", "hash_manifest_verify")
|
||||
},
|
||||
"hash_manifest_builder" => new[]
|
||||
{
|
||||
Action("navigateTool", "校验哈希清单", "Verify hash manifest", "hash_manifest_verify", "hash_manifest_verify")
|
||||
},
|
||||
"hash_manifest_verify" => new[]
|
||||
{
|
||||
Action("navigateTool", "生成哈希清单", "Build hash manifest", "hash_manifest_builder", "hash_manifest_builder")
|
||||
},
|
||||
"qr_generator" => new[]
|
||||
{
|
||||
Action("navigateTool", "扫描二维码", "Scan QR code", "qrcode_scanner", "qrcode_scanner")
|
||||
},
|
||||
"qrcode_scanner" => new[]
|
||||
{
|
||||
Action("navigateTool", "生成二维码", "Generate QR code", "qr_generator", "qr_generator")
|
||||
},
|
||||
"sanguosha_skin" => new[]
|
||||
{
|
||||
Action("navigateRoute", "查看服务状态", "Open service status", "serviceStatus", routeTag: "serviceStatus")
|
||||
},
|
||||
_ => []
|
||||
};
|
||||
|
||||
return actions.Length == 0 ? string.Empty : JsonSerializer.Serialize(actions);
|
||||
}
|
||||
|
||||
private static Dictionary<string, string> RemoteMetadata(ApiEndpoint endpoint, ToolResultKind kind, string language)
|
||||
{
|
||||
var metadata = Metadata(endpoint.Id, kind, language, "remote-dashboard");
|
||||
|
||||
Reference in New Issue
Block a user