redirect to page not found for invalid collections (#11882)

This commit is contained in:
Azri Kahar
2022-03-01 00:05:58 +08:00
committed by GitHub
parent c2ed7fdcb0
commit e6a0a40319

View File

@@ -62,12 +62,19 @@ export default defineModule({
async beforeEnter(to) {
const collectionsStore = useCollectionsStore();
const info = collectionsStore.getCollection(to.params.collection as string);
const fieldsStore = useFieldsStore();
if (!info) {
return {
name: 'settings-not-found',
params: { _: to.path.split('/').slice(1) },
};
}
if (!info?.meta) {
await api.patch(`/collections/${to.params.collection}`, { meta: {} });
}
const fieldsStore = useFieldsStore();
fieldsStore.hydrate();
},
props: (route) => ({