fix: refs #6919 reactivity
gitea/salix-front/pipeline/pr-dev This commit looks good Details

This commit is contained in:
Jorge Penadés 2024-11-15 11:14:19 +01:00
parent 84f22cfeb8
commit fec9ef25bf
1 changed files with 4 additions and 1 deletions

View File

@ -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}`);