responsive name
This commit is contained in:
@@ -59,9 +59,7 @@ export default {
|
||||
await loginStore.getUserData();
|
||||
loginUserData.value = loginStore.userData;
|
||||
await acctMgmtStore.getUserDetail(loginUserData.value.username);
|
||||
if(currentViewingUserDetail.value.roles.find(role => role.code === 'admin')) {
|
||||
isAdmin.value = true;
|
||||
}
|
||||
isAdmin.value = acctMgmtStore.currentViewingUser.is_admin;
|
||||
};
|
||||
|
||||
const onBtnMyAccountClick = async() => {
|
||||
|
||||
@@ -190,6 +190,7 @@ export default defineStore('acctMgmtStore', {
|
||||
username: userToEdit,
|
||||
name: newName,
|
||||
is_active: this.currentViewingUser.is_active,
|
||||
is_admin: this.currentViewingUser.is_admin,
|
||||
});
|
||||
return response.status === 200;
|
||||
} catch (error) {
|
||||
@@ -206,6 +207,7 @@ export default defineStore('acctMgmtStore', {
|
||||
name: this.currentViewingUser.name,
|
||||
password: newPwd,
|
||||
is_active: this.currentViewingUser.is_active,
|
||||
is_admin: this.currentViewingUser.is_admin,
|
||||
});
|
||||
return response.status === 200;
|
||||
} catch (error) {
|
||||
@@ -249,13 +251,10 @@ export default defineStore('acctMgmtStore', {
|
||||
*/
|
||||
async getUserDetail(uniqueUsername: string): Promise<boolean> {
|
||||
const apiUserDetail = `/api/users/${uniqueUsername}`;
|
||||
|
||||
try {
|
||||
const response = await this.$axios.get(apiUserDetail);
|
||||
this.currentViewingUser = {
|
||||
...this.currentViewingUser,
|
||||
detail: response.data,
|
||||
};
|
||||
this.currentViewingUser = response.data;
|
||||
this.currentViewingUser.is_admin = response.data.roles.some(role => role.code === 'admin');
|
||||
return response.status === 200;
|
||||
} catch (error) {
|
||||
//不需要跳出錯誤,因為如果是錯誤反而是好事,表示帳號是獨一的
|
||||
|
||||
@@ -128,7 +128,7 @@ export default {
|
||||
|
||||
const visitTime = ref(0);
|
||||
const currentViewingUser = computed(() => acctMgmtStore.currentViewingUser);
|
||||
const name = computed(() => acctMgmtStore.currentViewingUser.name);
|
||||
const name = computed(() => currentViewingUser.value.name);
|
||||
const {
|
||||
username,
|
||||
is_admin,
|
||||
@@ -180,18 +180,9 @@ export default {
|
||||
isPwdLengthValid.value = inputPwd.value.length >= PWD_VALID_LENGTH;
|
||||
}
|
||||
|
||||
watch(() => acctMgmtStore.currentViewingUser, (newVal, oldVal) => {
|
||||
console.log('currentViewingUser updated:', newVal);
|
||||
console.log('newVal.name', newVal.name);
|
||||
});
|
||||
|
||||
onBeforeMount(async() => {
|
||||
// 在此設定 current viewing user 的來源是登入者的身分
|
||||
await acctMgmtStore.getUserDetail(loginStore.userData.username);
|
||||
});
|
||||
|
||||
onMounted(() => {
|
||||
onMounted(async() => {
|
||||
loadingStore.setIsLoading(false);
|
||||
await acctMgmtStore.getUserDetail(loginStore.userData.username);
|
||||
});
|
||||
|
||||
return {
|
||||
|
||||
Reference in New Issue
Block a user