2024-09-20 19:29:16 +08:00
|
|
|
<template>
|
|
|
|
|
<div>
|
|
|
|
|
<contextHolder />
|
2024-10-28 21:55:37 +08:00
|
|
|
<a-input v-bind="attrs" :value="value" :allow-clear="true" @update:value="emit('update:value', $event)">
|
2024-09-20 19:29:16 +08:00
|
|
|
<template #suffix>
|
|
|
|
|
<a-tag class="cursor-pointer" @click="getDeviceId">获取设备ID</a-tag>
|
|
|
|
|
</template>
|
|
|
|
|
</a-input>
|
|
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script lang="tsx" setup>
|
2026-01-22 18:33:39 +08:00
|
|
|
import { inject, ref, useAttrs } from "vue";
|
2024-09-20 19:29:16 +08:00
|
|
|
import { Modal } from "ant-design-vue";
|
2024-09-27 02:15:41 +08:00
|
|
|
import { ComponentPropsType, doRequest } from "/@/components/plugins/lib";
|
2024-09-20 19:29:16 +08:00
|
|
|
|
2024-10-07 03:21:16 +08:00
|
|
|
defineOptions({
|
2025-03-26 12:05:28 +08:00
|
|
|
name: "DeviceIdGetter",
|
2024-10-07 03:21:16 +08:00
|
|
|
});
|
|
|
|
|
|
2024-09-27 02:15:41 +08:00
|
|
|
const props = defineProps<ComponentPropsType>();
|
2024-09-20 19:29:16 +08:00
|
|
|
const emit = defineEmits<{
|
|
|
|
|
"update:value": any;
|
|
|
|
|
}>();
|
|
|
|
|
|
|
|
|
|
const attrs = useAttrs();
|
|
|
|
|
|
|
|
|
|
const otpCodeRef = ref("");
|
2024-11-26 01:14:16 +08:00
|
|
|
const getScope: any = inject("get:scope");
|
2025-06-26 18:43:16 +08:00
|
|
|
const getPluginType: any = inject("get:plugin:type", () => {
|
|
|
|
|
return "access";
|
|
|
|
|
});
|
2024-09-20 19:29:16 +08:00
|
|
|
|
|
|
|
|
async function loginWithOTPCode(otpCode: string) {
|
2024-11-26 01:14:16 +08:00
|
|
|
const { form } = getScope();
|
|
|
|
|
const pluginType = getPluginType();
|
|
|
|
|
|
2024-09-27 02:15:41 +08:00
|
|
|
return await doRequest({
|
2024-11-26 01:14:16 +08:00
|
|
|
type: pluginType,
|
|
|
|
|
typeName: form.type,
|
2024-09-27 02:15:41 +08:00
|
|
|
action: "LoginWithOPTCode",
|
|
|
|
|
data: {
|
2025-03-26 12:05:28 +08:00
|
|
|
otpCode,
|
2024-09-27 02:15:41 +08:00
|
|
|
},
|
2025-03-26 12:05:28 +08:00
|
|
|
input: form,
|
2024-09-20 19:29:16 +08:00
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const [modal, contextHolder] = Modal.useModal();
|
|
|
|
|
async function getDeviceId() {
|
|
|
|
|
//打开对话框
|
|
|
|
|
modal.confirm({
|
|
|
|
|
title: "请输入OTP验证码",
|
2024-10-01 23:52:44 +08:00
|
|
|
maskClosable: true,
|
2024-09-20 19:29:16 +08:00
|
|
|
content: () => {
|
|
|
|
|
return (
|
|
|
|
|
<a-form-item-rest>
|
|
|
|
|
<a-input v-model:value={otpCodeRef.value} placeholder="请输入OTP验证码" />
|
|
|
|
|
</a-form-item-rest>
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
onOk: async () => {
|
|
|
|
|
const res = await loginWithOTPCode(otpCodeRef.value);
|
|
|
|
|
console.log("did返回", res);
|
|
|
|
|
emit("update:value", res.did);
|
2025-03-26 12:05:28 +08:00
|
|
|
},
|
2024-09-20 19:29:16 +08:00
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
</script>
|