refactor: 使用更简洁的方式进行认证
This commit is contained in:
@@ -174,7 +174,12 @@
|
||||
import { ref, reactive, watch } from "vue";
|
||||
import { AuthManager } from "../../utils/AuthManager";
|
||||
import { useAlertStore } from "../../components/Alert";
|
||||
import { BoardStatus, type NetworkConfigDto } from "../../APIClient";
|
||||
import {
|
||||
BoardStatus,
|
||||
DataClient,
|
||||
NetConfigClient,
|
||||
type NetworkConfigDto,
|
||||
} from "../../APIClient";
|
||||
import { useRequiredInjection } from "@/utils/Common";
|
||||
import { useBoardManager } from "@/utils/BoardManager";
|
||||
|
||||
@@ -267,8 +272,7 @@ async function handleSubmit() {
|
||||
isSubmitting.value = true;
|
||||
|
||||
try {
|
||||
// 通过 AuthManager 获取认证的 DataClient
|
||||
const dataClient = AuthManager.createAuthenticatedDataClient();
|
||||
const dataClient = AuthManager.createClient(DataClient);
|
||||
|
||||
// 添加板卡到数据库
|
||||
const boardId = await dataClient.addBoard(form.name.trim());
|
||||
@@ -293,8 +297,7 @@ async function handleCancelPairing() {
|
||||
if (!addedBoardId.value) return;
|
||||
|
||||
try {
|
||||
// 通过 AuthManager 获取认证的 DataClient
|
||||
const dataClient = AuthManager.createAuthenticatedDataClient();
|
||||
const dataClient = AuthManager.createClient(DataClient);
|
||||
|
||||
// 删除添加的板卡
|
||||
await dataClient.deleteBoard(addedBoardId.value);
|
||||
@@ -317,8 +320,8 @@ async function handlePairingConfirm() {
|
||||
|
||||
try {
|
||||
// 通过 AuthManager 获取认证的客户端
|
||||
const dataClient = AuthManager.createAuthenticatedDataClient();
|
||||
const netConfigClient = AuthManager.createAuthenticatedNetConfigClient();
|
||||
const dataClient = AuthManager.createClient(DataClient);
|
||||
const netConfigClient = AuthManager.createClient(NetConfigClient);
|
||||
|
||||
// 获取数据库中对应分配的板卡信息
|
||||
const boardInfo = await dataClient.getBoardByID(addedBoardId.value);
|
||||
@@ -365,7 +368,7 @@ async function handlePairingConfirm() {
|
||||
|
||||
// 配置失败,删除数据库中的板卡信息
|
||||
try {
|
||||
const dataClient = AuthManager.createAuthenticatedDataClient();
|
||||
const dataClient = AuthManager.createClient(DataClient);
|
||||
await dataClient.deleteBoard(addedBoardId.value);
|
||||
} catch (deleteError) {
|
||||
console.error("删除板卡失败:", deleteError);
|
||||
|
||||
Reference in New Issue
Block a user