feat(文档): 添加RImg组件并配置资源路径别名

删除未使用的Custom.vue组件,新增RImg组件用于处理资源图片路径
在vite配置中添加资源路径别名,简化图片引用方式
更新client.ts注册RImg组件
This commit is contained in:
祀梦
2025-12-24 16:20:35 +08:00
parent ba9298852e
commit 98ec780ed9
4 changed files with 44 additions and 28 deletions

View File

@@ -1,11 +0,0 @@
<script setup lang="ts">
import { ref } from 'vue'
const message = ref('Hello World!')
</script>
<template>
<div class="my-custom-content">
{{ message }}
</div>
</template>

View File

@@ -0,0 +1,27 @@
<template>
<img :src="imageSrc" :alt="alt" v-bind="$attrs" />
</template>
<script setup>
import { computed } from 'vue'
const props = defineProps({
src: {
type: String,
required: true
},
alt: {
type: String,
default: ''
}
})
// 使用 Vite 的 import.meta.glob 或简单字符串拼接
// 由于别名在运行时不可直接动态拼接,我们这里使用一个更稳妥的方法
// 映射到我们配置好的别名
const imageSrc = computed(() => {
// 处理路径,确保指向别名
const path = props.src.startsWith('/') ? props.src.slice(1) : props.src
return new URL(`../../../resources/${path}`, import.meta.url).href
})
</script>