feat: 添加设备认证对话框的预配置支持,优化自动认证逻辑

This commit is contained in:
SunWuyuan
2025-11-02 15:15:46 +08:00
parent 9aae9601f6
commit 7f166ffddc
3 changed files with 157 additions and 5 deletions
+30 -2
View File
@@ -100,14 +100,18 @@
</template>
<script setup>
import { ref } from 'vue'
import { ref, watch } from 'vue'
import { getSetting, setSetting } from '@/utils/settings'
import axios from '@/axios/axios'
defineProps({
const props = defineProps({
showCancel: {
type: Boolean,
default: false
},
preconfig: {
type: Object,
default: null
}
})
@@ -120,6 +124,30 @@ const form = ref({
const authenticating = ref(false)
const error = ref('')
// 监听预配置数据变化
watch(
() => props.preconfig,
(newPreconfig) => {
if (newPreconfig) {
console.log('应用预配置数据:', newPreconfig)
form.value.namespace = newPreconfig.namespace || ''
form.value.password = newPreconfig.password || ''
// 如果启用自动执行且有命名空间,自动尝试认证
if (newPreconfig.autoExecute && newPreconfig.namespace) {
console.log('检测到自动执行标志且有命名空间,自动执行认证')
// 延迟一下确保UI已更新
setTimeout(() => {
authenticate()
}, 300)
} else if (newPreconfig.namespace) {
console.log('预配置数据已填入,等待手动认证')
}
}
},
{ immediate: true, deep: true }
)
const authenticate = async () => {
if (!form.value.namespace || authenticating.value) return
error.value = ''