gengxin
This commit is contained in:
parent
1f5f4d16e6
commit
a0cdd2b851
@ -18,7 +18,7 @@
|
||||
>
|
||||
<img
|
||||
v-if="logo"
|
||||
:src="API_BASE_URL + logo.replace(/^\//, '/')"
|
||||
:src="getPreviewUrl(logo)"
|
||||
class="logo-image"
|
||||
/>
|
||||
<el-icon v-else class="logo-uploader-icon"><Plus /></el-icon>
|
||||
@ -33,7 +33,7 @@
|
||||
>
|
||||
<img
|
||||
v-if="logow"
|
||||
:src="API_BASE_URL + logow.replace(/^\//, '/')"
|
||||
:src="getPreviewUrl(logow)"
|
||||
class="logo-image darkbg"
|
||||
/>
|
||||
<el-icon v-else class="logo-uploader-icon"><Plus /></el-icon>
|
||||
@ -48,7 +48,7 @@
|
||||
>
|
||||
<img
|
||||
v-if="ico"
|
||||
:src="API_BASE_URL + ico.replace(/^\//, '/')"
|
||||
:src="getPreviewUrl(ico)"
|
||||
class="logo-image"
|
||||
/>
|
||||
<el-icon v-else class="logo-uploader-icon"><Plus /></el-icon>
|
||||
@ -119,6 +119,18 @@ const normalRules: FormRules = {
|
||||
sitename: [{ required: true, message: "请输入站点名称", trigger: "blur" }],
|
||||
};
|
||||
|
||||
const getPreviewUrl = (url: string) => {
|
||||
const value = String(url || "").trim().replace(/\\/g, "/");
|
||||
if (!value) return "";
|
||||
if (/^(https?:\/\/|\/\/|data:|blob:)/i.test(value)) {
|
||||
return value;
|
||||
}
|
||||
|
||||
const base = String(API_BASE_URL || "").replace(/\/+$/, "");
|
||||
const path = value.startsWith("/") ? value : `/${value}`;
|
||||
return `${base}${path}`;
|
||||
};
|
||||
|
||||
//调用基础数据
|
||||
const initNormalInfos = async () => {
|
||||
const res = await getNormalInfos(authStore.user.tid);
|
||||
|
||||
@ -589,9 +589,20 @@ const getUserCateData = async () => {
|
||||
}
|
||||
};
|
||||
|
||||
//图片拼接接口地址
|
||||
// 图片拼接接口地址
|
||||
// 七牛云等云存储会返回完整 http/https 地址,直接使用;本地存储返回相对路径时再拼接接口地址
|
||||
const getFileUrl = (url: string) => {
|
||||
return `${import.meta.env.VITE_API_BASE_URL}${url}`;
|
||||
if (!url) return "";
|
||||
|
||||
const normalizedUrl = String(url).trim().replace(/\\/g, "/");
|
||||
if (/^(https?:\/\/|data:|blob:)/i.test(normalizedUrl)) {
|
||||
return normalizedUrl;
|
||||
}
|
||||
|
||||
const baseUrl = String(import.meta.env.VITE_API_BASE_URL || "").replace(/\/$/, "");
|
||||
const path = normalizedUrl.startsWith("/") ? normalizedUrl : `/${normalizedUrl}`;
|
||||
|
||||
return `${baseUrl}${path}`;
|
||||
};
|
||||
|
||||
// 未分类分组(固定,不可编辑)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user