vue3 infinite scroll

This commit is contained in:
Cindy Chang
2024-06-24 09:07:11 +08:00
parent 9b0d54bf5e
commit b55cc0a6d6
4 changed files with 90 additions and 46 deletions

View File

@@ -5,7 +5,9 @@ export default defineStore('acctMgmtStore', {
state: () => ({
allUserAccoutList: [],
isAcctMenuOpen: false,
currentViewingUser: {}
currentViewingUser: {
detail: null,
}
}),
getters: {
},
@@ -85,10 +87,24 @@ export default defineStore('acctMgmtStore', {
try{
const response = await this.$axios.post(apiCreateAccount, userToCreate);
console.log('TODO: response:', response, response.status);
}
catch(error) {
apiError(error, 'Failed to add a new account');
apiError(error, 'Failed to add a new account.');
};
},
/**
* Get user detail by unique username.
* @param {string} uniqueUsername
*/
async getUserDetail(uniqueUsername) {
const apiUserDetail = `/api/users/${uniqueUsername}`;
try{
const response = await this.$axios.get(apiUserDetail);
this.currentViewingUser.detail = response.data;
}
catch(error) {
apiError(error, 'Failed to get user detail.');
};
},
/**