refactor: 抽离管理后台基础设施模块
This commit is contained in:
1 parent
cfa183015b
commit
d811478d0f
3 files changed
+26
-21
No files matched your search
@@ -1,5 +1,5 @@
|
||||
import { ApiClient } from "@personal-brand/api-client";
|
||||
import { bootstrapAdmin } from "./main.js";
|
||||
import { createApiClient } from "./lib/api.js";
|
||||
|
||||
const root = document.querySelector<HTMLElement>("#app");
|
||||
if (root) {
|
||||
@@ -11,10 +11,7 @@ if (root) {
|
||||
const username = (root.querySelector("#username") as HTMLInputElement).value;
|
||||
const password = (root.querySelector("#password") as HTMLInputElement).value;
|
||||
try {
|
||||
const client = new ApiClient({
|
||||
baseUrl: import.meta.env.VITE_API_BASE_URL ?? "http://localhost:3001",
|
||||
fetcher: (input, init) => fetch(input, init),
|
||||
});
|
||||
const client = createApiClient();
|
||||
const result = await client.loginAdmin(username, password);
|
||||
localStorage.setItem("adminToken", result.token);
|
||||
location.reload();
|
||||
|
||||
Reference in new issue
Block a user