Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 40 additions & 8 deletions dashboard/src/components/platform/AddNewPlatform.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
<v-card-title class="text-h3 pa-4 pb-0 pl-6">
{{
updatingMode
? `${tm('dialog.edit')} ${updatingPlatformConfig.id} ${tm(
'dialog.adapter',
? `${tm("dialog.edit")} ${updatingPlatformConfig.id} ${tm(
"dialog.adapter",
)}`
: tm('dialog.addPlatform')
: tm("dialog.addPlatform")
}}
</v-card-title>
<v-card-text
Expand Down Expand Up @@ -73,7 +73,9 @@
activator="parent"
:text="
tm(
`createDialog.platformTooltips.${platformTemplates[item.raw].type}`,
`createDialog.platformTooltips.${
platformTemplates[item.raw].type
}`,
)
"
location="end"
Expand Down Expand Up @@ -734,7 +736,9 @@

<v-card-actions>
<v-spacer></v-spacer>
<v-btn variant="text" @click="closeDialog">{{ tm("dialog.cancel") }}</v-btn>
<v-btn variant="text" @click="closeDialog">{{
tm("dialog.cancel")
}}</v-btn>
<v-btn
:disabled="!canSave"
color="primary"
Expand Down Expand Up @@ -850,7 +854,13 @@
</template>

<script>
import { botApi, configProfileApi, configRouteApi, fileApi, sessionApi } from "@/api/v1";
import {
botApi,
configProfileApi,
configRouteApi,
fileApi,
sessionApi,
} from "@/api/v1";
import { useModuleI18n } from "@/i18n/composables";
import {
getPlatformIcon,
Expand Down Expand Up @@ -894,6 +904,10 @@ export default {
type: Object,
default: null,
},
initialScanPlatform: {
type: Object,
default: null,
},
},
data() {
return {
Expand Down Expand Up @@ -959,6 +973,7 @@ export default {
return this.show;
},
set(value) {
if (!value) this.resetForm();
this.$emit("update:show", value);
},
},
Expand Down Expand Up @@ -1588,7 +1603,9 @@ export default {
}

let suffix = "";
const explicitSuffix = this.sanitizePlatformIdPart(data.platform_id_suffix);
const explicitSuffix = this.sanitizePlatformIdPart(
data.platform_id_suffix,
);
if (explicitSuffix) {
suffix =
explicitSuffix.startsWith("_") || explicitSuffix.startsWith("-")
Expand Down Expand Up @@ -1944,7 +1961,22 @@ export default {
this.showConfigSection = true;
},

prepareData() {
async prepareData() {
if (!this.updatingMode && this.initialScanPlatform) {
const scanPlatform = this.initialScanPlatform;
this.resetForm();
await this.$nextTick();
this.selectedPlatformType =
Object.keys(this.platformTemplates).find(
(name) => this.platformTemplates[name].type === scanPlatform.type,
) || null;
await this.$nextTick();
if (this.selectedPlatformConfig) {
this.larkCreationMode = "scan";
this.dingtalkCreationMode = "scan";
this.qqOfficialCreationMode = "scan";
}
}
this.getConfigInfoList();
this.getConfigForPreview(this.selectedAbConfId);
if (
Expand Down
26 changes: 25 additions & 1 deletion dashboard/src/components/platform/PlatformEditor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,25 @@
</div>

<div class="bot-editor__actions">
<v-btn
v-if="
[
'lark',
'dingtalk',
'qq_official',
'qq_official_webhook',
'weixin_oc',
].includes(platform.type)
"
prepend-icon="mdi-qrcode"
variant="text"
rounded="xl"
:loading="rescanning"
:disabled="saving"
@click="$emit('rescan')"
>
{{ tm("workspace.rescan") }}
</v-btn>
<v-btn
v-if="runtimeStat?.error_count > 0"
color="error"
Expand Down Expand Up @@ -49,7 +68,7 @@
variant="tonal"
rounded="xl"
:loading="saving"
:disabled="!canSave"
:disabled="!canSave || rescanning"
@click="save"
>
{{ tm("workspace.save") }}
Expand Down Expand Up @@ -391,13 +410,18 @@ const props = defineProps({
type: Boolean,
default: false,
},
rescanning: {
type: Boolean,
default: false,
},
});

const emit = defineEmits([
"saved",
"show-toast",
"show-error",
"show-qr",
"rescan",
"show-webhook",
]);

Expand Down
2 changes: 2 additions & 0 deletions dashboard/src/i18n/locales/en-US/features/platform.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
"addAdapter": "Add Adapter",
"emptyText": "No platform adapters yet, click Add Adapter to create one",
"workspace": {
"rescan": "Rebind via QR code",
"rescanConfirm": "After you click Confirm, existing connection settings will be deleted and the QR code creation page will open automatically.",
"listTitle": "Bots",
"selectHint": "Select a bot to configure",
"empty": "No bots yet. Create one to start configuring it.",
Expand Down
2 changes: 2 additions & 0 deletions dashboard/src/i18n/locales/ja-JP/features/platform.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
"addAdapter": "ボットを作成",
"emptyText": "プラットフォームアダプターがありません。「ボットを作成」をクリックして追加してください",
"workspace": {
"rescan": "QRコードで再連携",
"rescanConfirm": "確認をクリックすると、現在の接続設定が削除され、QRコードによる作成画面に自動的に移動します。",
"listTitle": "ボット",
"selectHint": "設定するボットを選択してください",
"empty": "ボットがありません。作成すると設定を開始できます。",
Expand Down
2 changes: 2 additions & 0 deletions dashboard/src/i18n/locales/ru-RU/features/platform.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
"addAdapter": "Создать бота",
"emptyText": "Боты не настроены. Нажмите «Создать бота», чтобы начать.",
"workspace": {
"rescan": "Перепривязать по QR-коду",
"rescanConfirm": "После нажатия «Подтвердить» текущие настройки подключения будут удалены и автоматически откроется страница создания по QR-коду.",
"listTitle": "Боты",
"selectHint": "Выберите бота для настройки",
"empty": "Ботов пока нет. Создайте бота, чтобы начать настройку.",
Expand Down
2 changes: 2 additions & 0 deletions dashboard/src/i18n/locales/zh-CN/features/platform.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
"addAdapter": "创建机器人",
"emptyText": "暂无平台适配器,点击 创建机器人 添加",
"workspace": {
"rescan": "重新扫码绑定",
"rescanConfirm": "点击确定后,现有连接配置将被删除,并自动跳转到扫码创建页面。",
"listTitle": "机器人",
"selectHint": "选择一个机器人进行配置",
"empty": "还没有机器人,创建后即可开始配置。",
Expand Down
40 changes: 40 additions & 0 deletions dashboard/src/views/PlatformPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,8 @@
:metadata="metadata"
:runtime-stat="getPlatformStat(selectedPlatform.id)"
:has-qr-payload="hasQrPayload(selectedPlatform.id)"
:rescanning="rescanning"
@rescan="rescanPlatform(selectedPlatform)"
@saved="handlePlatformSaved"
@show-toast="showToast"
@show-error="showErrorDetails(selectedPlatform)"
Expand All @@ -174,6 +176,12 @@
:metadata="metadata"
:config_data="configData"
:updating-mode="false"
:initial-scan-platform="scanPlatform"
@update:show="
(show) => {
if (!show) scanPlatform = null;
}
"
@show-toast="showToast"
@refresh-config="handlePlatformCreated"
/>
Expand Down Expand Up @@ -338,6 +346,8 @@ const metadata = ref({});
const loadingPlatforms = ref(true);
const selectedPlatformId = ref(null);
const showAddPlatformDialog = ref(false);
const scanPlatform = ref(null);
const rescanning = ref(false);
const platformStats = ref({});
const showWebhookDialog = ref(false);
const currentWebhookUuid = ref("");
Expand Down Expand Up @@ -478,6 +488,36 @@ async function deletePlatform(platform) {
}
}

async function rescanPlatform(platform) {
if (rescanning.value) return;
rescanning.value = true;
try {
if (
!(await askForConfirmationDialog(
tm("workspace.rescanConfirm"),
confirmDialog,
))
)
return;

const response = await botApi.delete(platform.id);
if (response.data.status !== "ok") {
throw new Error(response.data.message || tm("status.error"));
}
configData.value.platform = platforms.value.filter(
(item) => item.id !== platform.id,
);
selectedPlatformId.value = null;
scanPlatform.value = { type: platform.type };
showAddPlatformDialog.value = true;
await getConfig();
} catch (error) {
showError(error);
} finally {
rescanning.value = false;
}
}

function handlePlatformCreated(platformId) {
getConfig(platformId || null);
getPlatformStats();
Expand Down
Loading