fix(sj_1.1.0_beta1): 修复新增命名空间选项未刷新问题

This commit is contained in:
xlsea 2024-06-12 11:23:00 +08:00
parent 99d11116da
commit 541a321558
4 changed files with 38 additions and 7 deletions

View File

@ -29,6 +29,9 @@
"warning-outlined": {
"body": "<path fill=\"currentColor\" d=\"M464 720a48 48 0 1 0 96 0a48 48 0 1 0-96 0m16-304v184c0 4.4 3.6 8 8 8h48c4.4 0 8-3.6 8-8V416c0-4.4-3.6-8-8-8h-48c-4.4 0-8 3.6-8 8m475.7 440l-416-720c-6.2-10.7-16.9-16-27.7-16s-21.6 5.3-27.7 16l-416 720C56 877.4 71.4 904 96 904h832c24.6 0 40-26.6 27.7-48m-783.5-27.9L512 239.9l339.8 588.2z\"/>"
},
"check-outlined": {
"body": "<path fill=\"currentColor\" d=\"M912 190h-69.9c-9.8 0-19.1 4.5-25.1 12.2L404.7 724.5L207 474a32 32 0 0 0-25.1-12.2H112c-6.7 0-10.4 7.7-6.3 12.9l273.9 347c12.8 16.2 37.4 16.2 50.3 0l488.4-618.9c4.1-5.1.4-12.8-6.3-12.8\"/>"
},
"clock-circle-outlined": {
"body": "<path fill=\"currentColor\" d=\"M512 64C264.6 64 64 264.6 64 512s200.6 448 448 448s448-200.6 448-448S759.4 64 512 64m0 820c-205.4 0-372-166.6-372-372s166.6-372 372-372s372 166.6 372 372s-166.6 372-372 372\"/><path fill=\"currentColor\" d=\"M686.7 638.6L544.1 535.5V288c0-4.4-3.6-8-8-8H488c-4.4 0-8 3.6-8 8v275.4c0 2.6 1.2 5 3.3 6.5l165.4 120.6c3.6 2.6 8.6 1.8 11.2-1.7l28.6-39c2.6-3.7 1.8-8.7-1.8-11.2\"/>"
},

View File

@ -1,6 +1,7 @@
<script lang="tsx" setup>
import { computed, ref, watch } from 'vue';
import { useRouter } from 'vue-router';
import { NEllipsis } from 'naive-ui';
import { $t } from '@/locales';
import { localStg } from '@/utils/storage';
import { useAppStore } from '@/store/modules/app';
@ -16,7 +17,7 @@ const router = useRouter();
const appStore = useAppStore();
const authStore = useAuthStore();
const namespaceId = ref<string>(localStg.get('namespaceId')!);
const userInfo = localStg.get('userInfo');
const namespaceIds = ref(localStg.get('userInfo')?.namespaceIds || []);
watch(
() => authStore.namespaceUniqueId,
@ -26,19 +27,31 @@ watch(
}
);
watch(
() => authStore.userInfo.namespaceIds,
val => {
namespaceIds.value = val;
},
{ deep: true }
);
const dropOptions = computed(() =>
userInfo?.namespaceIds.map(item => {
namespaceIds.value.map(item => {
return {
label: () => {
if (item.uniqueId === namespaceId.value) {
return (
<div class="flex-center">
<span class="block w-113px">{item.name}</span>
<SvgIcon icon="ant-design:check-outlined" />
<div class="max-w-130px flex items-center justify-between">
<NEllipsis>{item.name}</NEllipsis>
<SvgIcon class="ml-6px" icon="ant-design:check-outlined" />
</div>
);
}
return <span class="block w-120px">{item.name}</span>;
return (
<div class="max-w-130px flex items-center justify-between">
<NEllipsis>{item.name}</NEllipsis>
</div>
);
},
key: item.uniqueId
};
@ -52,7 +65,7 @@ const onChange = (value: string) => {
};
const namespaceName = computed(() => {
return userInfo?.namespaceIds.filter(item => item.uniqueId === namespaceId.value)[0].name || 'Default';
return namespaceIds.value.filter(item => item.uniqueId === namespaceId.value)[0].name || 'Default';
});
</script>
@ -115,4 +128,15 @@ const namespaceName = computed(() => {
.namespace-select:hover {
border-color: rgb(var(--nprogress-color));
}
.namespace-select-option {
display: flex;
justify-content: space-between;
align-items: center;
:deep(.n-ellipsis) {
width: 100%;
max-width: 113px;
}
}
</style>

View File

@ -178,6 +178,7 @@ export const useAuthStore = defineStore(SetupStoreId.Auth, () => {
loginLoading,
resetStore,
login,
getUserInfo,
initUserInfo,
initAppVersion,
setNamespaceId

View File

@ -5,6 +5,7 @@ import { useFormRules, useNaiveForm } from '@/hooks/common/form';
import OperateDrawer from '@/components/common/operate-drawer.vue';
import { $t } from '@/locales';
import { fetchAddNamespace, fetchEditNamespace } from '@/service/api';
import { useAuthStore } from '@/store/modules/auth';
defineOptions({
name: 'NamespaceOperateDrawer'
@ -25,6 +26,7 @@ interface Emits {
const emit = defineEmits<Emits>();
const authStore = useAuthStore();
const visible = defineModel<boolean>('visible', {
default: false
});
@ -98,6 +100,7 @@ async function handleSubmit() {
window.$message?.success($t('common.updateSuccess'));
}
await authStore.getUserInfo();
closeDrawer();
emit('submitted');
}