节点 1: 字符串合并 (多行) 作用: 将输入 A 和输入 B 合并,并在中间插入换行符。
| 6 | """ |
| 7 | |
| 8 | class PD_JoinStringMultiLine: |
| 9 | """ |
| 10 | 节点 1: 字符串合并 (多行) |
| 11 | 作用: 将输入 A 和输入 B 合并,并在中间插入换行符。 |
| 12 | """ |
| 13 | def __init__(self): |
| 14 | pass |
| 15 | |
| 16 | @classmethod |
| 17 | def INPUT_TYPES(s): |
| 18 | return { |
| 19 | "required": { |
| 20 | # forceInput=True 强制显示左侧输入点 |
| 21 | "string_1": ("STRING", {"forceInput": True, "multiline": True, "default": ""}), |
| 22 | "string_2": ("STRING", {"forceInput": True, "multiline": True, "default": ""}), |
| 23 | } |
| 24 | } |
| 25 | |
| 26 | RETURN_TYPES = ("STRING",) |
| 27 | RETURN_NAMES = ("combined_string",) |
| 28 | FUNCTION = "join_strings" |
| 29 | CATEGORY = "PD Nodes" |
| 30 | |
| 31 | def join_strings(self, string_1, string_2): |
| 32 | # 核心逻辑:中间加一个换行符 \n |
| 33 | s1 = str(string_1) if string_1 is not None else "" |
| 34 | s2 = str(string_2) if string_2 is not None else "" |
| 35 | |
| 36 | # 如果第一项为空,直接返回第二项,避免头部出现空行 |
| 37 | if s1 == "": |
| 38 | return (s2,) |
| 39 | if s2 == "": |
| 40 | return (s1,) |
| 41 | |
| 42 | result = s1 + "\n" + s2 |
| 43 | return (result,) |
| 44 | |
| 45 | |
| 46 | class PD_StringLineCount: |
nothing calls this directly
no outgoing calls
no test coverage detected