This commit is contained in:
parent
84f22cfeb8
commit
fec9ef25bf
|
@ -23,6 +23,7 @@ const props = defineProps({
|
|||
const stateStore = useStateStore();
|
||||
const route = useRoute();
|
||||
const router = useRouter();
|
||||
const regex = /(\/\d+)/;
|
||||
const searchRightDataKey = computed(() => {
|
||||
if (!props.searchDataKey) return route.name;
|
||||
return props.searchDataKey;
|
||||
|
@ -35,6 +36,9 @@ const arrayData = useArrayData(props.dataKey, {
|
|||
onBeforeMount(async () => {
|
||||
try {
|
||||
if (props.idInWhere) arrayData.store.filter.where = { id: route.params.id };
|
||||
else if (!regex.test(props.url))
|
||||
arrayData.store.url = `${props.url}/${route.params.id}`;
|
||||
|
||||
await arrayData.fetch({ append: false, updateRouter: false });
|
||||
} catch {
|
||||
const { matched: matches } = router.currentRoute.value;
|
||||
|
@ -46,7 +50,6 @@ onBeforeMount(async () => {
|
|||
if (!props.idInWhere) {
|
||||
onBeforeRouteUpdate(async (to, from) => {
|
||||
if (to.params.id !== from.params.id) {
|
||||
const regex = /(\/\d+)/;
|
||||
arrayData.store.url = !regex.test(props.url)
|
||||
? `${props.url}/${to.params.id}`
|
||||
: props.url.replace(regex, `/${to.params.id}`);
|
||||
|
|
Loading…
Reference in New Issue