lingrui-web/README-CDN.md
榆钱落尽槿花稀 2b3ecd7164 - 优化首页、关于我们、产品服务、社会责任等页面的布局和样式
- 添加视频播放功能,支持在页面中嵌入并播放视频
- 更新新闻动态模块,支持动态加载和展示新闻内容
- 修复部分页面样式问题,提升用户体验
2025-05-15 18:35:29 +08:00

58 lines
1.6 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 灵睿官网3.0 - CDN图片处理指南
## 静态生成模式下的CDN图片处理
本项目已配置为支持在使用 `nuxt generate` 静态生成模式下自动处理图片CDN路径。以下是相关功能和使用方法的说明。
### 配置说明
1. CDN基础URL已配置为 `https://cdn.web.0rui.cn/`
2.`nuxt.config.ts` 中已添加相关配置
3. 创建了专用的CDN图片处理插件和组件
### 使用方法
#### 方法一使用CdnImage组件推荐
```vue
<template>
<!-- 使用CdnImage组件自动处理CDN路径 -->
<CdnImage src="public/img/logo.png" class="image_1" referrerpolicy="no-referrer" />
</template>
```
#### 方法二:使用全局$cdnImage方法
```vue
<template>
<img :src="$cdnImage('public/img/logo.png')" class="image_1" referrerpolicy="no-referrer" />
</template>
<script setup>
const { $cdnImage } = useNuxtApp()
</script>
```
### 路径处理规则
-`public/` 开头的路径会自动转换为 `https://cdn.web.0rui.cn/img/...`
- 已经是完整URL的路径以http://或https://开头)不会被修改
- 其他路径会直接拼接CDN基础URL
### 开发与生产环境
- 在开发环境中默认使用本地路径不进行CDN转换
- 在生产环境静态生成自动应用CDN路径
- 如需在开发环境中测试CDN路径可以使用 `<CdnImage src="..." :forceCdn="true" />` 强制启用CDN
### 静态生成命令
```bash
# 生成静态网站
npm run generate
# 预览生成的静态网站
npm run preview
```
生成的静态文件将位于 `.output/public` 目录中,可以部署到任何静态文件服务器。