Explorar o código

更新图片展示

liuyuhang hai 3 semanas
pai
achega
abb54d3eef
Modificáronse 1 ficheiros con 13 adicións e 1 borrados
  1. 13 1
      src/master/views/vip/vip-edit.vue

+ 13 - 1
src/master/views/vip/vip-edit.vue

@@ -116,6 +116,16 @@ const themeOptions = ref<{ label: string; value: string }[]>([]);
 // 从全局配置里取后端 baseURL
 const baseURL = (window as any).config?.baseURL || "";
 
+// 获取图片完整 URL
+const getImageUrl = (iconPath: string) => {
+  if (!iconPath) return "";
+  // 如果路径不是以 http:// 或 https:// 或 / 开头,加上 / 前缀
+  if (!iconPath.startsWith("http://") && !iconPath.startsWith("https://") && !iconPath.startsWith("/")) {
+    return "/" + iconPath;
+  }
+  return iconPath;
+};
+
 // 上传地址和头信息
 const fileUpdateUrl = computed(
   () => `${baseURL}/upload/uploadFile.do?fileDir=identityLevel`
@@ -298,10 +308,12 @@ onMounted(() => {
     form.status = (route.query.status as string) || "1"; // 1=上架, 0=下架
     form.levelIconLabel = (route.query.icon as string) || "";
     if (form.levelIconLabel) {
+      // 使用 getImageUrl 确保图片 URL 正确
+      const fullImageUrl = getImageUrl(form.levelIconLabel);
       iconFileList.value = [
         {
           name: "icon",
-          url: form.levelIconLabel,
+          url: fullImageUrl,
         },
       ];
     }