Skip to content

Commit

Permalink
🐞 fix(store): top-level await...
Browse files Browse the repository at this point in the history
  • Loading branch information
CakeAL committed Dec 25, 2024
1 parent 7a05035 commit 5f458fc
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 23 deletions.
1 change: 0 additions & 1 deletion components.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ declare module 'vue' {
NMessageProvider: typeof import('naive-ui')['NMessageProvider']
NModal: typeof import('naive-ui')['NModal']
NModalProvider: typeof import('naive-ui')['NModalProvider']
NOption: typeof import('naive-ui')['NOption']
NP: typeof import('naive-ui')['NP']
NPopover: typeof import('naive-ui')['NPopover']
NProgress: typeof import('naive-ui')['NProgress']
Expand Down
8 changes: 7 additions & 1 deletion src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import UnbindMacs from "./pages/UnbindMacs.vue";
import SpeedTest from "./pages/SpeedTest.vue";
import MonthlyUserLog from "./pages/MonthlyUserLog.vue";
import OtherTools from "./pages/OtherTools.vue";
import { store } from "./store";
type RouteComponent = DefineComponent<{}, {}, any>;
Expand Down Expand Up @@ -112,12 +113,17 @@ const apply_background = async () => {
}
};
// download & onedrive
// download & onedrive & userName
onMounted(() => {
check_update(false);
load_collapse();
getCurUserName();
});
const getCurUserName = async () => {
store.userName = await invoke("get_current_user_name");
};
// sider
const collapsed = ref(true);
const load_collapse = async () => {
Expand Down
2 changes: 1 addition & 1 deletion src/pages/MonthlyUserLog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ const select_mb_or_gb = (value: string) => {
.day:hover {
box-shadow: rgba(127, 231, 196, 0.4) 0 3px, rgba(127, 231, 196, 0.3) 0 6px,
rgba(127, 231, 196, 0.2) 0 9px, rgba(127, 231, 196, 0.1) 0 12px,
rgba(127, 231, 196, 0.05) 0 15px;
rgba(127, 231, 196, 0.05) 0 15px, rgba(127, 231, 196, 0.4) 0px 0px 50px 1px;
}
.my-card {
Expand Down
31 changes: 11 additions & 20 deletions src/store.ts
Original file line number Diff line number Diff line change
@@ -1,27 +1,18 @@
import { invoke } from "@tauri-apps/api/core";
import { reactive } from "vue";

const getCurUserName = async (): Promise<string> => {
return await invoke("get_current_user_name");
};

const setCurUserName = async () => {
await invoke("set_current_user_name", { userName: store.userName });
};

async function initializeStore() {
const userName = await getCurUserName();
return reactive({
userName,
setUserName(userName: string) {
this.userName = userName;
setCurUserName();
},
clearUserName() {
this.userName = "";
setCurUserName();
},
});
}

export const store = await initializeStore();
export const store = reactive({
userName: "",
setUserName(userName: string) {
this.userName = userName;
setCurUserName();
},
clearUserName() {
this.userName = "";
setCurUserName();
},
});

0 comments on commit 5f458fc

Please sign in to comment.