fix: #327 add needed await keyword
This commit is contained in:
@@ -62,7 +62,6 @@ export default defineStore('acctMgmtStore', {
|
||||
*/
|
||||
setCurrentViewingUser(username: string) {
|
||||
const userFind: User | undefined = this.allUserAccoutList.find(user => user.username === username);
|
||||
console.log('userFind', userFind);
|
||||
this.currentViewingUser = userFind || { username: '', detail: {} };
|
||||
},
|
||||
/**
|
||||
|
||||
@@ -3,5 +3,10 @@ import { defineStore } from "pinia";
|
||||
export default defineStore('loadingStore', {
|
||||
state: () => ({
|
||||
isLoading: true,
|
||||
})
|
||||
}),
|
||||
actions: {
|
||||
setIsLoading(isLoadingBoolean) {
|
||||
this.isLoading = isLoadingBoolean;
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
@@ -135,30 +135,12 @@ import {
|
||||
import iconDetailOn from '@/assets/icon-detail-on.svg';
|
||||
import iconDetailOff from '@/assets/icon-detail-card.svg';
|
||||
|
||||
// 這是製作假資料,在正式環境不會用到
|
||||
function repeatAccountList(accountList, N) {
|
||||
const repeatedList = [];
|
||||
|
||||
for (let i = 0; i < N; i++) {
|
||||
accountList.forEach(account => {
|
||||
const newAccount = { ...account, id: account.id + i };
|
||||
repeatedList.push(newAccount);
|
||||
});
|
||||
}
|
||||
|
||||
return repeatedList;
|
||||
}
|
||||
|
||||
// 這是製作假資料,在正式環境不會用到
|
||||
// const repeatedAccountList = repeatAccountList(accountList, 20);
|
||||
|
||||
export default {
|
||||
setup() {
|
||||
const toast = useToast();
|
||||
const acctMgmtStore = useAcctMgmtStore();
|
||||
const loadingStore = LoadingStore();
|
||||
const modalStore = useModalStore();
|
||||
const { isLoading } = storeToRefs(loadingStore);
|
||||
const loginStore = piniaLoginStore();
|
||||
const infiniteStart = ref(0);
|
||||
|
||||
@@ -256,13 +238,14 @@ export default {
|
||||
|
||||
watch(shouldUpdateList, async(newShouldUpdateList) => {
|
||||
if (newShouldUpdateList) {
|
||||
await acctMgmtStore.getAllUserAccounts();
|
||||
acctMgmtStore.setShouldUpdateList(false);
|
||||
|
||||
await acctMgmtStore.getAllUserAccounts();
|
||||
// 當夾帶有infiniteStart.value,就表示依然考慮到無限捲動的需求
|
||||
infiniteAcctData.value = allAccountResponsive.value.slice(0, infiniteStart.value + ONCE_RENDER_NUM_OF_DATA);
|
||||
infiniteAcctData.value = acctMgmtStore.allUserAccoutList.slice(0, infiniteStart.value + ONCE_RENDER_NUM_OF_DATA);
|
||||
moveJustCreateUserToFirstRow();
|
||||
accountSearchResults.value = infiniteAcctData.value;
|
||||
|
||||
}
|
||||
acctMgmtStore.setShouldUpdateList(false);
|
||||
});
|
||||
|
||||
const onSearchAccountButtonClick = (inputQueryString) => {
|
||||
@@ -302,7 +285,8 @@ export default {
|
||||
toast.success(i18next.t("AcctMgmt.MsgAccountEdited"));
|
||||
}
|
||||
|
||||
onMounted(async () => {
|
||||
onMounted(async () => {
|
||||
loadingStore.setIsLoading(false);
|
||||
await fetchLoginUserData();
|
||||
await acctMgmtStore.getAllUserAccounts();
|
||||
});
|
||||
@@ -344,7 +328,6 @@ export default {
|
||||
|
||||
return {
|
||||
accountSearchResults,
|
||||
isLoading,
|
||||
modalStore,
|
||||
loginUserData,
|
||||
infiniteAcctData,
|
||||
@@ -413,14 +396,11 @@ export default {
|
||||
* 無限滾動: 滾到底後,要載入數據
|
||||
*/
|
||||
async fetchMoreDataVue2() {
|
||||
this.isLoading = true;
|
||||
this.infiniteFinish = false;
|
||||
this.infiniteStart += ONCE_RENDER_NUM_OF_DATA;
|
||||
this.infiniteAcctDataVue2 = await [...this.infiniteAcctDataVue2, ...this.allUserAccoutList.slice(
|
||||
this.infiniteStart, this.infiniteStart + ONCE_RENDER_NUM_OF_DATA)];
|
||||
this.isInfiniteFinish = true;
|
||||
this.isLoading = false;
|
||||
|
||||
},
|
||||
onDetailBtnClick(dataKey){
|
||||
this.openModal(MODAL_ACCT_INFO);
|
||||
|
||||
@@ -43,11 +43,11 @@ export default defineComponent({
|
||||
const router = useRouter();
|
||||
|
||||
const onDeleteConfirmBtnClick = async() => {
|
||||
if(acctMgmtStore.deleteAccount(acctMgmtStore.currentViewingUser.username)){
|
||||
if(await acctMgmtStore.deleteAccount(acctMgmtStore.currentViewingUser.username)){
|
||||
toast.success(i18next.t("AcctMgmt.MsgAccountDeleteSuccess"));
|
||||
modalStore.closeModal();
|
||||
acctMgmtStore.setShouldUpdateList(true);
|
||||
router.push("/account-admin");
|
||||
await router.push("/account-admin");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user