Skip to content

feat: The custom parameters of the tool can set a default value#5224

Open
wangliang181230 wants to merge 1 commit into1Panel-dev:v2from
wangliang181230:PR/feat-1-tool
Open

feat: The custom parameters of the tool can set a default value#5224
wangliang181230 wants to merge 1 commit into1Panel-dev:v2from
wangliang181230:PR/feat-1-tool

Conversation

@wangliang181230
Copy link
Copy Markdown
Contributor

What this PR does / why we need it?

feat: The custom parameters of the tool can set a default value

Summary of your change

新特性:工具的自定义参数,可以设置一个默认值。

界面效果截图
图片

Please indicate you've done the following:

  • Made sure tests are passing and test coverage is added if needed.
  • Made sure commit message follow the rule of Conventional Commits specification.
  • Considered the docs impact and opened a new docs issue or PR with docs changes if needed.

@f2c-ci-robot
Copy link
Copy Markdown

f2c-ci-robot Bot commented May 7, 2026

Adding the "do-not-merge/release-note-label-needed" label because no release-note block was detected, please follow our release note process to remove it.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@f2c-ci-robot
Copy link
Copy Markdown

f2c-ci-robot Bot commented May 7, 2026

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

return json.dumps(data, default=default_serializer, ensure_ascii=False)
else:
# 直接输出数组(list)对象
return data
Copy link
Copy Markdown
Contributor Author

@wangliang181230 wangliang181230 May 7, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

其他优化2. MySQL 查询 工具,添加 to_json_str 参数,用于控制查询结果是否转为JSON字符串(默认值:1=会转为JSON字符串)

在部分情况下,可设置该参数为0,输出结果不转为JSON字符串,可通过其他工具来处理数据。


finally:
if db:
db.close()', '[{"name": "sql", "type": "string", "source": "reference", "is_required": true}, {"name": "to_json_str", "desc": "结果是否转换为JSON字符串:1=是 | 0=否", "type": "boolean", "source": "custom", "is_required": false, "default_value": "1"}]', '[{"attrs": {"maxlength": 200, "minlength": 1, "show-word-limit": true}, "field": "host", "label": "host", "required": true, "input_type": "TextInput", "props_info": {"rules": [{"message": "host 为必填属性", "required": true}, {"max": 200, "min": 1, "message": "host长度在 1 到 200 个字符", "trigger": "blur"}]}, "default_value": "x", "show_default_value": false}, {"attrs": {"maxlength": 20, "minlength": 1, "show-word-limit": true}, "field": "port", "label": "port", "required": true, "input_type": "TextInput", "props_info": {"rules": [{"message": "port 为必填属性", "required": true}, {"max": 20, "min": 1, "message": "port长度在 1 到 20 个字符", "trigger": "blur"}]}, "default_value": "3306", "show_default_value": false}, {"attrs": {"maxlength": 200, "minlength": 1, "show-word-limit": true}, "field": "user", "label": "user", "required": true, "input_type": "TextInput", "props_info": {"rules": [{"message": "user 为必填属性", "required": true}, {"max": 200, "min": 1, "message": "user长度在 1 到 200 个字符", "trigger": "blur"}]}, "default_value": "root", "show_default_value": false}, {"attrs": {"type": "password", "maxlength": 200, "minlength": 1, "show-password": true, "show-word-limit": true}, "field": "password", "label": "password", "required": true, "input_type": "PasswordInput", "props_info": {"rules": [{"message": "password 为必填属性", "required": true}, {"max": 200, "min": 1, "message": "password长度在 1 到 200 个字符", "trigger": "blur"}]}, "default_value": "x", "show_default_value": false}, {"attrs": {"maxlength": 200, "minlength": 1, "show-word-limit": true}, "field": "database", "label": "database", "required": true, "input_type": "TextInput", "props_info": {"rules": [{"message": "database 为必填属性", "required": true}, {"max": 200, "min": 1, "message": "database长度在 1 到 200 个字符", "trigger": "blur"}]}, "default_value": "x", "show_default_value": false}]', './tool/mysql/icon.png', true, 'INTERNAL', 'INTERNAL', null, 'None', null, 'f0dd8f71-e4ee-11ee-8c84-a8a1595801ab', 'default');
Copy link
Copy Markdown
Contributor Author

@wangliang181230 wangliang181230 May 7, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

其他优化2:MySQL 查询 工具,db.close() 放到 finally: 中执行

return json_data

# 关闭数据库连接
db.close()
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

db.close()return 之后,为无效代码,根本就没有关闭掉。

@wangliang181230 wangliang181230 force-pushed the PR/feat-1-tool branch 2 times, most recently from 0bd6c1c to 2268f2f Compare May 7, 2026 08:12
{{ item.desc }}
</template>
<AppIcon iconName="app-warning" class="app-warning-icon"></AppIcon>
</el-tooltip>
Copy link
Copy Markdown
Contributor Author

@wangliang181230 wangliang181230 May 7, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

工具调试界面,展示 desc 参数提示说明

@wangliang181230 wangliang181230 force-pushed the PR/feat-1-tool branch 2 times, most recently from 4fe8fbf to 855e0ef Compare May 7, 2026 09:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant