添加内容管理模块,包括分类管理、标签管理和Banner管理功能,新增相关API和前端页面。
This commit is contained in:
34
ruoyi-ui/src/utils/image.js
Normal file
34
ruoyi-ui/src/utils/image.js
Normal file
@@ -0,0 +1,34 @@
|
||||
/**
|
||||
* 图片工具类
|
||||
*/
|
||||
|
||||
/**
|
||||
* 获取图片完整URL
|
||||
* @param {string} imagePath 图片路径
|
||||
* @returns {string} 完整的图片URL
|
||||
*/
|
||||
export function getImageUrl(imagePath) {
|
||||
if (!imagePath) {
|
||||
return '';
|
||||
}
|
||||
|
||||
// 如果已经是完整URL,直接返回
|
||||
if (imagePath.startsWith('http://') || imagePath.startsWith('https://')) {
|
||||
return imagePath;
|
||||
}
|
||||
|
||||
// 使用项目的API前缀配置
|
||||
const baseApi = process.env.VUE_APP_BASE_API || '/dev-api';
|
||||
return baseApi + imagePath;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取图片完整URL(带默认图片)
|
||||
* @param {string} imagePath 图片路径
|
||||
* @param {string} defaultImage 默认图片路径
|
||||
* @returns {string} 完整的图片URL
|
||||
*/
|
||||
export function getImageUrlWithDefault(imagePath, defaultImage = '') {
|
||||
const url = getImageUrl(imagePath);
|
||||
return url || defaultImage;
|
||||
}
|
||||
Reference in New Issue
Block a user