mirror of
https://github.com/AstrBotDevs/AstrBot
synced 2026-07-15 17:30:13 +08:00
feat(platform): 支持扫码创建时自定义机器人ID (#9067)
* feat(platform): 支持扫码创建时自定义机器人ID - 在扫码创建平台机器人时新增机器人 ID 输入框,允许用户在创建前自定义平台 ID。 - 输入框展示在二维码上方,并对空值、空格、冒号和感叹号进行校验。 - 用户手动填写 ID 后,扫码结果不会再自动覆盖该值。 - 同时补充中英俄三语言文案。 * refactor(platform): 重构扫码创建平台ID输入组件 - 将平台专属CSS类名改为通用名称registration-inline - 使用统一的isPlatformIdValid方法校验ID格式,替代分散的正则判断 - 移除setter中对platform ID的trim操作,交由校验逻辑处理 - 删除不再使用的.weixin-oc-registration-inline样式定义
This commit is contained in:
@@ -88,6 +88,17 @@
|
||||
v-if="larkCreationMode === 'scan'"
|
||||
class="registration-inline mt-3"
|
||||
>
|
||||
<v-text-field
|
||||
:model-value="selectedPlatformConfig.id || ''"
|
||||
:label="tm('registrationAction.platformIdLabel')"
|
||||
:error="Boolean(scanPlatformIdError)"
|
||||
:error-messages="scanPlatformIdError"
|
||||
variant="outlined"
|
||||
density="compact"
|
||||
hide-details="auto"
|
||||
class="registration-platform-id-field"
|
||||
@update:model-value="setScanPlatformId"
|
||||
/>
|
||||
<PlatformRegistrationAction
|
||||
:platform-config="selectedPlatformConfig"
|
||||
:active="larkCreationMode === 'scan'"
|
||||
@@ -140,6 +151,17 @@
|
||||
v-if="dingtalkCreationMode === 'scan'"
|
||||
class="registration-inline mt-3"
|
||||
>
|
||||
<v-text-field
|
||||
:model-value="selectedPlatformConfig.id || ''"
|
||||
:label="tm('registrationAction.platformIdLabel')"
|
||||
:error="Boolean(scanPlatformIdError)"
|
||||
:error-messages="scanPlatformIdError"
|
||||
variant="outlined"
|
||||
density="compact"
|
||||
hide-details="auto"
|
||||
class="registration-platform-id-field"
|
||||
@update:model-value="setScanPlatformId"
|
||||
/>
|
||||
<PlatformRegistrationAction
|
||||
:platform-config="selectedPlatformConfig"
|
||||
:active="dingtalkCreationMode === 'scan'"
|
||||
@@ -195,6 +217,17 @@
|
||||
v-if="qqOfficialCreationMode === 'scan'"
|
||||
class="registration-inline mt-3"
|
||||
>
|
||||
<v-text-field
|
||||
:model-value="selectedPlatformConfig.id || ''"
|
||||
:label="tm('registrationAction.platformIdLabel')"
|
||||
:error="Boolean(scanPlatformIdError)"
|
||||
:error-messages="scanPlatformIdError"
|
||||
variant="outlined"
|
||||
density="compact"
|
||||
hide-details="auto"
|
||||
class="registration-platform-id-field"
|
||||
@update:model-value="setScanPlatformId"
|
||||
/>
|
||||
<PlatformRegistrationAction
|
||||
:platform-config="selectedPlatformConfig"
|
||||
:active="qqOfficialCreationMode === 'scan'"
|
||||
@@ -229,8 +262,19 @@
|
||||
|
||||
<div
|
||||
v-else-if="isWeixinOcPlatform"
|
||||
class="weixin-oc-registration-inline mt-4"
|
||||
class="registration-inline mt-4"
|
||||
>
|
||||
<v-text-field
|
||||
:model-value="selectedPlatformConfig.id || ''"
|
||||
:label="tm('registrationAction.platformIdLabel')"
|
||||
:error="Boolean(scanPlatformIdError)"
|
||||
:error-messages="scanPlatformIdError"
|
||||
variant="outlined"
|
||||
density="compact"
|
||||
hide-details="auto"
|
||||
class="registration-platform-id-field"
|
||||
@update:model-value="setScanPlatformId"
|
||||
/>
|
||||
<PlatformRegistrationAction
|
||||
:platform-config="selectedPlatformConfig"
|
||||
:active="isWeixinOcPlatform"
|
||||
@@ -839,6 +883,7 @@ export default {
|
||||
larkCreationMode: "",
|
||||
dingtalkCreationMode: "",
|
||||
qqOfficialCreationMode: "",
|
||||
scanPlatformIdCustomized: false,
|
||||
|
||||
aBConfigRadioVal: "0",
|
||||
selectedAbConfId: "default",
|
||||
@@ -1054,6 +1099,16 @@ export default {
|
||||
this.selectedPlatformConfig?.type,
|
||||
);
|
||||
},
|
||||
scanPlatformIdError() {
|
||||
const platformId = String(this.selectedPlatformConfig?.id || "");
|
||||
if (!platformId) {
|
||||
return this.tm("registrationAction.platformIdRequired");
|
||||
}
|
||||
if (!this.isPlatformIdValid(platformId)) {
|
||||
return this.tm("registrationAction.platformIdInvalid");
|
||||
}
|
||||
return "";
|
||||
},
|
||||
},
|
||||
watch: {
|
||||
selectedPlatformType(newType) {
|
||||
@@ -1064,11 +1119,13 @@ export default {
|
||||
this.larkCreationMode = "";
|
||||
this.dingtalkCreationMode = "";
|
||||
this.qqOfficialCreationMode = "";
|
||||
this.scanPlatformIdCustomized = false;
|
||||
} else {
|
||||
this.selectedPlatformConfig = null;
|
||||
this.larkCreationMode = "";
|
||||
this.dingtalkCreationMode = "";
|
||||
this.qqOfficialCreationMode = "";
|
||||
this.scanPlatformIdCustomized = false;
|
||||
}
|
||||
},
|
||||
selectedAbConfId(newConfigId) {
|
||||
@@ -1156,6 +1213,7 @@ export default {
|
||||
this.larkCreationMode = "";
|
||||
this.dingtalkCreationMode = "";
|
||||
this.qqOfficialCreationMode = "";
|
||||
this.scanPlatformIdCustomized = false;
|
||||
|
||||
this.aBConfigRadioVal = "0";
|
||||
this.selectedAbConfId = "default";
|
||||
@@ -1472,6 +1530,14 @@ export default {
|
||||
this.$emit("show-toast", { message: message, type: "error" });
|
||||
},
|
||||
|
||||
setScanPlatformId(value) {
|
||||
if (!this.selectedPlatformConfig) {
|
||||
return;
|
||||
}
|
||||
this.scanPlatformIdCustomized = true;
|
||||
this.selectedPlatformConfig.id = String(value || "");
|
||||
},
|
||||
|
||||
buildRandomPlatformIdSuffix() {
|
||||
const letters = "abcdefghijklmnopqrstuvwxyz";
|
||||
let suffix = "_";
|
||||
@@ -1492,6 +1558,9 @@ export default {
|
||||
if (!this.selectedPlatformConfig || !data) {
|
||||
return;
|
||||
}
|
||||
if (this.scanPlatformIdCustomized) {
|
||||
return;
|
||||
}
|
||||
const currentId = String(this.selectedPlatformConfig.id || "").trim();
|
||||
const platformType = this.selectedPlatformConfig.type;
|
||||
if (!currentId) {
|
||||
@@ -1968,8 +2037,14 @@ export default {
|
||||
|
||||
.registration-inline {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: flex-start;
|
||||
justify-content: flex-start;
|
||||
width: 320px;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.registration-platform-id-field {
|
||||
width: 300px;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -181,6 +181,9 @@
|
||||
"created": "Setup Complete",
|
||||
"startFailed": "Failed to start QR setup",
|
||||
"pollFailed": "Failed to poll QR setup status",
|
||||
"platformIdLabel": "Bot ID",
|
||||
"platformIdRequired": "Bot ID is required",
|
||||
"platformIdInvalid": "Bot ID cannot contain spaces, ':' or '!'",
|
||||
"mode": {
|
||||
"title": "Choose setup method",
|
||||
"scan": "One-click QR setup",
|
||||
|
||||
@@ -181,6 +181,9 @@
|
||||
"created": "Настройка завершена",
|
||||
"startFailed": "Не удалось начать QR настройку",
|
||||
"pollFailed": "Не удалось проверить статус QR настройки",
|
||||
"platformIdLabel": "ID бота",
|
||||
"platformIdRequired": "ID бота обязателен",
|
||||
"platformIdInvalid": "ID бота не может содержать пробелы, ':' или '!'",
|
||||
"mode": {
|
||||
"title": "Выберите способ создания",
|
||||
"scan": "Создать через QR",
|
||||
|
||||
@@ -181,6 +181,9 @@
|
||||
"created": "创建成功",
|
||||
"startFailed": "发起扫码创建失败",
|
||||
"pollFailed": "获取扫码创建状态失败",
|
||||
"platformIdLabel": "机器人 ID",
|
||||
"platformIdRequired": "机器人 ID 不能为空",
|
||||
"platformIdInvalid": "机器人 ID 不能包含空格、':' 或 '!'",
|
||||
"mode": {
|
||||
"title": "选择创建方式",
|
||||
"scan": "扫码一键创建",
|
||||
|
||||
Reference in New Issue
Block a user