feat(platform): 支持扫码创建时自定义机器人ID#9067
Conversation
- 在扫码创建平台机器人时新增机器人 ID 输入框,允许用户在创建前自定义平台 ID。 - 输入框展示在二维码上方,并对空值、空格、冒号和感叹号进行校验。 - 用户手动填写 ID 后,扫码结果不会再自动覆盖该值。 - 同时补充中英俄三语言文案。
There was a problem hiding this comment.
Code Review
This pull request introduces a customizable Bot ID input field for Lark, DingTalk, QQ Official, and WeChat OC platforms during QR setup. The feedback highlights several improvement opportunities: removing .trim() from the input handler to prevent cursor jumps and allow validation of trailing spaces, reusing the existing isPlatformIdValid helper instead of duplicating the validation regex, and consolidating the duplicate CSS classes .weixin-oc-registration-inline and .registration-inline to reduce redundancy.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| setScanPlatformId(value) { | ||
| if (!this.selectedPlatformConfig) { | ||
| return; | ||
| } | ||
| this.scanPlatformIdCustomized = true; | ||
| this.selectedPlatformConfig.id = String(value || "").trim(); | ||
| }, |
There was a problem hiding this comment.
在用户输入过程中,使用 .trim() 会导致无法在输入框末尾输入空格(输入空格会被立即清除,从而可能导致光标跳转或无法触发“不能包含空格”的校验提示)。建议移除 .trim(),让校验器(scanPlatformIdError)来处理空格校验,或者仅在保存时进行 trim 处理。
setScanPlatformId(value) {
if (!this.selectedPlatformConfig) {
return;
}
this.scanPlatformIdCustomized = true;
this.selectedPlatformConfig.id = String(value || "");
},
| scanPlatformIdError() { | ||
| const platformId = String(this.selectedPlatformConfig?.id || ""); | ||
| if (!platformId) { | ||
| return this.tm("registrationAction.platformIdRequired"); | ||
| } | ||
| if (/[!:\s]/.test(platformId)) { | ||
| return this.tm("registrationAction.platformIdInvalid"); | ||
| } | ||
| return ""; | ||
| }, |
There was a problem hiding this comment.
建议复用已有的 isPlatformIdValid 方法来进行格式校验,避免重复编写 /[!:\s]/ 正则表达式,提高代码的可维护性。
scanPlatformIdError() {
const platformId = String(this.selectedPlatformConfig?.id || "");
if (!platformId) {
return this.tm("registrationAction.platformIdRequired");
}
if (!this.isPlatformIdValid(platformId)) {
return this.tm("registrationAction.platformIdInvalid");
}
return "";
},
| @@ -230,6 +263,17 @@ | |||
| v-else-if="isWeixinOcPlatform" | |||
| class="weixin-oc-registration-inline mt-4" | |||
|
|
||
| .weixin-oc-registration-inline { | ||
| display: flex; | ||
| flex-direction: column; | ||
| align-items: flex-start; | ||
| width: 320px; | ||
| gap: 8px; | ||
| } | ||
|
|
There was a problem hiding this comment.
Hey - I've left some high level feedback:
- The platform ID input field markup is duplicated across multiple scan blocks; consider extracting it into a small reusable component or a shared template fragment to keep the template DRY and easier to maintain.
- The CSS for
.registration-inlineand.weixin-oc-registration-inlineis almost identical; consolidating these into a single shared class (with modifiers if needed) would reduce style duplication and make layout changes simpler.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- The platform ID input field markup is duplicated across multiple scan blocks; consider extracting it into a small reusable component or a shared template fragment to keep the template DRY and easier to maintain.
- The CSS for `.registration-inline` and `.weixin-oc-registration-inline` is almost identical; consolidating these into a single shared class (with modifiers if needed) would reduce style duplication and make layout changes simpler.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
- 将平台专属CSS类名改为通用名称registration-inline - 使用统一的isPlatformIdValid方法校验ID格式,替代分散的正则判断 - 移除setter中对platform ID的trim操作,交由校验逻辑处理 - 删除不再使用的.weixin-oc-registration-inline样式定义
Modifications / 改动点
refs #9057
Screenshots or Test Results / 运行截图或测试结果
Checklist / 检查清单
😊 If there are new features added in the PR, I have discussed it with the authors through issues/emails, etc.
/ 如果 PR 中有新加入的功能,已经通过 Issue / 邮件等方式和作者讨论过。
👀 My changes have been well-tested, and "Verification Steps" and "Screenshots" have been provided above.
/ 我的更改经过了良好的测试,并已在上方提供了“验证步骤”和“运行截图”。
🤓 I have ensured that no new dependencies are introduced, OR if new dependencies are introduced, they have been added to the appropriate locations in
requirements.txtandpyproject.toml./ 我确保没有引入新依赖库,或者引入了新依赖库的同时将其添加到
requirements.txt和pyproject.toml文件相应位置。😮 My changes do not introduce malicious code.
/ 我的更改没有引入恶意代码。
Summary by Sourcery
Add customizable platform ID input when creating bots via QR-code scanning and prevent auto-overwriting once manually set.
New Features:
Enhancements:
Documentation: