-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
feat(platform): 支持扫码创建时自定义机器人ID #9067
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
NayukiChiba
wants to merge
2
commits into
AstrBotDevs:master
Choose a base branch
from
NayukiChiba:feat/custom-scan-platform-id
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+85
−1
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -87,6 +87,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'" | ||
|
|
@@ -139,6 +150,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'" | ||
|
|
@@ -194,6 +216,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'" | ||
|
|
@@ -228,8 +261,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" | ||
|
|
@@ -834,6 +878,7 @@ export default { | |
| larkCreationMode: "", | ||
| dingtalkCreationMode: "", | ||
| qqOfficialCreationMode: "", | ||
| scanPlatformIdCustomized: false, | ||
|
|
||
| aBConfigRadioVal: "0", | ||
| selectedAbConfId: "default", | ||
|
|
@@ -1049,6 +1094,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) { | ||
|
|
@@ -1059,11 +1114,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) { | ||
|
|
@@ -1151,6 +1208,7 @@ export default { | |
| this.larkCreationMode = ""; | ||
| this.dingtalkCreationMode = ""; | ||
| this.qqOfficialCreationMode = ""; | ||
| this.scanPlatformIdCustomized = false; | ||
|
|
||
| this.aBConfigRadioVal = "0"; | ||
| this.selectedAbConfId = "default"; | ||
|
|
@@ -1467,6 +1525,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 || ""); | ||
| }, | ||
|
Comment on lines
+1528
to
+1534
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 在用户输入过程中,使用 |
||
|
|
||
| buildRandomPlatformIdSuffix() { | ||
| const letters = "abcdefghijklmnopqrstuvwxyz"; | ||
| let suffix = "_"; | ||
|
|
@@ -1487,6 +1553,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) { | ||
|
|
@@ -1963,8 +2032,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> | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
建议复用已有的
isPlatformIdValid方法来进行格式校验,避免重复编写/[!:\s]/正则表达式,提高代码的可维护性。