hannoeru / vite-plugin-pages

File system based route generator for ⚡️Vite
MIT License
1.84k stars 127 forks source link

How to add meta in route #396

Closed ibrahim-990 closed 1 year ago

ibrahim-990 commented 1 year ago

Describe the bug

meta: permission: parent: roles action: !expr > ${isEdit.value ? 'can_update' : 'can_view'}

i cant access isEdit from in route with vuejs. i Get value like this permission: {parent: 'roles', action: "${isEdit.value ? 'can_update' : 'can_view'}"}

Reproduction

no repo

System Info

Browsers

Used Package Manager

npm

Validations

jbaubree commented 1 year ago

https://github.com/hannoeru/vite-plugin-pages#sfc-custom-block-for-route-data

ibrahim-990 commented 1 year ago

https://github.com/hannoeru/vite-plugin-pages#sfc-custom-block-for-route-data

i cant access isEdit from script in !!

ibrahim-990 commented 1 year ago

@jbaubree

jbaubree commented 1 year ago

Can you share a repo with repro ?

ibrahim-990 commented 1 year ago

I'm work on vuexy dashboard image I'm use like this

ibrahim-990 commented 1 year ago

@jbaubree

ibrahim-990 commented 1 year ago

@jbaubree can you help me please ?

jbaubree commented 1 year ago

I don't understand why you wan't to use route for this. You have isEdit in script and you can build your input types and submit button depending on isEdit or not. What do you want to do with action in route?

jbaubree commented 1 year ago

You can use route meta to define if you need specific role or auth to show this page for example:

// yourPage.vue

<route lang="yaml">
meta:
  needAuth: true
</route>

// router.ts

router.beforeEach(({ meta }) => {
    const userStore = useUserStore()
    if (meta.needAuth && !userStore.isAuthenticated))
      return { name: 'sign-in' }
    return true
  })
ibrahim-990 commented 1 year ago

ok this work, but i have on form page and this form has meta permission edit or add and i want to check like this to add permission ${isEdit.value ? 'can_update' : 'can_view'} how i can do this?

jbaubree commented 1 year ago

your edit or add state does not need to be in route meta, or i do not understand why.

Edit: you need to move this issue to discussion