fix: cant fetch ?raw dynamically after bundling
This commit is contained in:
parent
f6a2460b81
commit
511ce84942
|
|
@ -6,7 +6,7 @@ import { Tabs, TabsContent, TabsList, TabsTrigger } from '@/lib/registry/default
|
|||
import { useConfigStore } from '@/stores/config'
|
||||
import { cn } from '@/lib/utils'
|
||||
|
||||
withDefaults(defineProps<{
|
||||
const props = withDefaults(defineProps<{
|
||||
name: string
|
||||
align?: 'center' | 'start' | 'end'
|
||||
sfcTsCode?: string
|
||||
|
|
@ -40,7 +40,7 @@ const { style } = useConfigStore()
|
|||
<TabsContent value="preview" class="relative rounded-md border">
|
||||
<div class="flex items-center justify-between p-4">
|
||||
<StyleSwitcher />
|
||||
<Stackblitz :key="style" :style="style" :name="name" />
|
||||
<Stackblitz :key="style" :style="style" :name="name" :code="decodeURIComponent(sfcTsCode ?? '')" />
|
||||
</div>
|
||||
<div
|
||||
:class="cn('preview flex min-h-[350px] w-full justify-center p-6 lg:p-10', {
|
||||
|
|
|
|||
|
|
@ -7,16 +7,14 @@ import { type Style } from '@/lib/registry/styles'
|
|||
|
||||
const props = defineProps<{
|
||||
name: string
|
||||
code: string
|
||||
style: Style
|
||||
}>()
|
||||
|
||||
const sources = ref<Record<string, string>>({})
|
||||
|
||||
onMounted(() => {
|
||||
const importName = `../../../src/lib/registry/${props.style}/example/${props.name}.vue?raw`
|
||||
import(/* @vite-ignore */importName).then(
|
||||
res => (sources.value['App.vue'] = res.default),
|
||||
)
|
||||
sources.value['App.vue'] = props.code
|
||||
})
|
||||
|
||||
function handleClick() {
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user