浏览代码

修复本地图片路径问题

shmily1213 1 月之前
父节点
当前提交
056dbc792d

+ 27 - 20
index.html

@@ -1,22 +1,29 @@
 <!DOCTYPE html>
 <html lang="zh" translate="no">
-  <head>
-    <meta charset="UTF-8" />
-    <meta name="referrer" content="never">
-    <meta name="google" content="notranslate" />
-    <script>
-      var coverSupport = 'CSS' in window && typeof CSS.supports === 'function' && (CSS.supports('top: env(a)') ||
-        CSS.supports('top: constant(a)'))
-      document.write(
-        '<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0' +
-        (coverSupport ? ', viewport-fit=cover' : '') + '" />')
-    </script>
-    <title></title>
-    <!--preload-links-->
-    <!--app-context-->
-  </head>
-  <body>
-    <div id="app"><!--app-html--></div>
-    <script type="module" src="/src/main.ts"></script>
-  </body>
-</html>
+
+<head>
+  <meta charset="UTF-8" />
+  <meta name="referrer" content="never">
+  <meta name="google" content="notranslate" />
+  <script>
+    var coverSupport = 'CSS' in window && typeof CSS.supports === 'function' && (CSS.supports('top: env(a)') ||
+      CSS.supports('top: constant(a)'))
+    document.write(
+      '<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0' +
+      (coverSupport ? ', viewport-fit=cover' : '') + '" />')
+  </script>
+  <title></title>
+  <!--preload-links-->
+  <!--app-context-->
+  <script src="https://unpkg.com/vconsole@3.15.1/dist/vconsole.min.js"></script>
+  <script>
+    const vconsole = new VConsole();
+  </script>
+</head>
+
+<body>
+  <div id="app"><!--app-html--></div>
+  <script type="module" src="/src/main.ts"></script>
+</body>
+
+</html>

+ 0 - 1
src/App.vue

@@ -15,7 +15,6 @@ export default {
 <style>
 /*每个页面公共css */
 @import "@/uni_modules/uv-ui-tools/index.scss";
-/* @import "@/static/tailwind.css"; */
 @import '@/static/theme/theme.module.scss';
 @import "@/static/common.scss";
 </style>

+ 15 - 2
src/components/ie-image/ie-image.vue

@@ -1,7 +1,7 @@
 <template>
   <view class="overflow-hidden" :class="customClass" @click="handleClick"
     :style="{ borderRadius: round + 'px', backgroundColor: loaded ? 'transparent' : bgColor }">
-    <image class="w-full h-full block" :src="imageSrc" :mode="mode" :lazy-load="lazyLoad"
+    <image class="w-full h-full block mx-auto" :src="imageSrc" :mode="mode" :lazy-load="lazyLoad"
       :style="{ borderRadius: round + 'px' }" @load="onLoad"></image>
   </view>
 </template>
@@ -38,13 +38,26 @@ const props = defineProps({
     default: '#F3F5F6'
   }
 });
+const handleSrc = (src: string) => {
+  // h5的开发环境,补上/h5/src/前缀
+  // #ifdef H5
+  if (import.meta.env.DEV && !src.startsWith('/h5/src/')) {
+    return `/h5/src/${src.replace(/^\//, '')}`;
+  }
+  return src;
+  // #endif
+  // #ifdef MP-WEIXIN
+  return src;
+  // #endif
+}
 const imageSrc = computed(() => {
-  return props.src ? (props.isOss ? config.ossUrl + props.src : props.src) : '';
+  return props.src ? (props.isOss ? config.ossUrl + props.src : handleSrc(props.src)) : '';
 });
 const emit = defineEmits(['click']);
 const handleClick = () => {
   emit('click');
 }
+
 const loaded = ref(false);
 const onLoad = () => {
   loaded.value = true;

+ 1 - 1
src/components/ie-page/ie-page.vue

@@ -1,6 +1,6 @@
 <template>
   <view class="ie-page theme-ie"
-    :class="[tabbar ? '' : (safeAreaInsetBottom ? 'safe-area-inset-bottom' : ''), { 'is-fixed': fixHeight }]"
+    :class="[safeAreaInsetBottom ? 'safe-area-inset-bottom' : '', { 'is-fixed': fixHeight }]"
     :style="{ backgroundColor: bgColor }">
     <view class="ie-page-content" :class="{ 'tabbar-layout': tabbar }">
       <slot></slot>

+ 6 - 11
src/manifest.json

@@ -5,7 +5,6 @@
     "versionName" : "1.0.0",
     "versionCode" : "100",
     "transformPx" : false,
-    /* 5+App特有相关 */
     "app-plus" : {
         "usingComponents" : true,
         "nvueStyleCompiler" : "uni-app",
@@ -16,11 +15,8 @@
             "autoclose" : true,
             "delay" : 0
         },
-        /* 模块配置 */
         "modules" : {},
-        /* 应用发布信息 */
         "distribute" : {
-            /* android打包配置 */
             "android" : {
                 "permissions" : [
                     "<uses-permission android:name=\"android.permission.CHANGE_NETWORK_STATE\"/>",
@@ -40,18 +36,12 @@
                     "<uses-permission android:name=\"android.permission.WRITE_SETTINGS\"/>"
                 ]
             },
-            /* ios打包配置 */
             "ios" : {},
-            /* SDK配置 */
             "sdkConfigs" : {}
         }
     },
-    /* 快应用特有相关 */
     "quickapp" : {},
-    /* 小程序特有相关 */
     "mp-weixin" : {
-        // 
-        // wx7d140533344f5e3f // 地大物泊
         "appid" : "wxa4d6c494e8f5d450",
         "setting" : {
             "urlCheck" : false,
@@ -63,7 +53,8 @@
         "permission" : {},
         "singlePage" : {
             "navigationBarFit" : "float"
-        }
+        },
+        "optimization":{"subPackages":true}
     },
     "mp-alipay" : {
         "usingComponents" : true
@@ -84,6 +75,10 @@
             "treeShaking" : {
                 "enable" : true
             }
+        },
+        "router" : {
+            "mode" : "history",
+            "base" : "/h5/"
         }
     },
     "locale" : "zh-Hans",

+ 1 - 1
src/pagesMain/pages/index/components/index-banner.vue

@@ -3,7 +3,7 @@
     <ie-image :is-oss="true" src="/banner/index-banner-1.png" custom-class="w-full min-h-264 overflow-hidden"
       :round="15" />
     <view class="pt-24 pb-40 bg-white grid grid-cols-4 gap-y-32 justify-items-center">
-      <view class="w-fit justify-items-center" v-for="item in menus" :key="item.name" @click="navigateTo(item.pageUrl, item.navigateType)">
+      <view class="w-fit" v-for="item in menus" :key="item.name" @click="navigateTo(item.pageUrl, item.navigateType)">
         <ie-image :is-oss="true" custom-class="w-auto h-82" :round="10" :src="item.icon" mode="heightFix" />
         <view class="text-26 text-fore-title">{{ item.name }}</view>
       </view>

+ 2 - 2
src/pagesMain/pages/index/components/index-guide.vue

@@ -6,7 +6,7 @@
         <view class="p-30 grid grid-cols-2 gap-x-20 gap-y-20 justify-items-center">
           <view class="w-full justify-items-center relative" v-for="(item, index) in contentList" :key="item.id"
             @click="handleClick(item)">
-            <ie-image :src="item.image" class="w-full h-150" :round="10" bg-color="transparent" />
+            <ie-image :is-oss="true" :src="item.image" class="w-full h-150" :round="10" bg-color="transparent" />
             <view class="absolute inset-0 h-full z-1 flex flex-col items-start justify-center box-border pl-16">
               <view v-if="item.subType" class="text-28 text-fore-title font-bold">{{ item.subType }}</view>
               <view v-if="item.description" class="mt-6 text-20 text-fore-light">{{ item.description }}</view>
@@ -48,7 +48,7 @@ const contentList = computed(() => {
     const bgPoolIndex = current.value % bgPool.length;
     return {
       ...item,
-      image: config.ossUrl + '/guide/' + bgPool[bgPoolIndex][index % bgPool[bgPoolIndex].length]
+      image: '/guide/' + bgPool[bgPoolIndex][index % bgPool[bgPoolIndex].length]
     }
   });
 });

+ 1 - 1
src/pagesStudy/pages/homework/homework.vue

@@ -8,7 +8,7 @@
       <view class="absolute inset-0">
         <z-paging ref="paging" :fixed="false" v-model="dataList" :safe-area-inset-bottom="true"
           :use-safe-area-placeholder="true" :auto="false" empty-view-text="暂无发布组卷作业~"
-          empty-view-img="/src/pagesStudy/static/image/icon-empty.png" :empty-view-style="emptyViewStyle"
+          empty-view-img="/pagesStudy/static/image/icon-empty.png" :empty-view-style="emptyViewStyle"
           :empty-view-img-style="emptyViewImgStyle" :empty-view-title-style="emptyViewTextStyle" @query="handleQuery">
           <view v-if="dataList.length > 0" class="pt-10">
             <view class="card-item" v-for="item in dataList" :key="item.id">

+ 2 - 2
src/pagesStudy/pages/index/compoentns/index-exam-record.vue

@@ -2,9 +2,9 @@
   <view class="px-30 bg-back">
     <view class="h-94 flex items-center justify-center">
       <view class="h-0 w-160 border-0 border-b border-dashed border-border"></view>
-      <ie-image src="/src/pagesStudy/static/image/icon-ear-left.png" customClass="w-20 h-26 ml-26 mr-30" />
+      <ie-image src="/pagesStudy/static/image/icon-ear-left.png" customClass="w-20 h-26 ml-26 mr-30" />
       <view class="text-30 text-fore-title font-bold">考试记录</view>
-      <ie-image src="/src/pagesStudy/static/image/icon-ear-right.png" customClass="w-20 h-26 ml-26 mr-30" />
+      <ie-image src="/pagesStudy/static/image/icon-ear-right.png" customClass="w-20 h-26 ml-26 mr-30" />
       <view class="h-0 w-160 border-0 border-b border-dashed border-border"></view>
     </view>
     <exam-record-item />

+ 2 - 2
src/pagesStudy/pages/index/compoentns/index-test.vue

@@ -13,12 +13,12 @@
             <view class="w-50 h-50 bg-primary rounded-full text-28 text-white font-bold leading-50 mx-auto">1</view>
             <view class="mt-26 text-24 text-fore-title">选择考试院校</view>
           </view>
-          <ie-image src="/src/pagesStudy/static/image/icon-arrow-multiple.png" customClass="w-30 h-18 -translate-y-8" />
+          <ie-image src="/pagesStudy/static/image/icon-arrow-multiple.png" customClass="w-30 h-18 -translate-y-8" />
           <view class="flex-1 -translate-y-24">
             <view class="w-50 h-50 bg-primary rounded-full text-28 text-white font-bold leading-50 mx-auto">2</view>
             <view class="mt-26 text-24 text-fore-title">选择考试专业</view>
           </view>
-          <ie-image src="/src/pagesStudy/static/image/icon-arrow-multiple.png" customClass="w-30 h-18 -translate-y-8" />
+          <ie-image src="/pagesStudy/static/image/icon-arrow-multiple.png" customClass="w-30 h-18 -translate-y-8" />
           <view class="flex-1 -translate-y-24">
             <view class="w-50 h-50 bg-primary rounded-full text-28 text-white font-bold leading-50 mx-auto">3</view>
             <view class="mt-26 text-24 text-fore-title">AI智能出卷</view>

+ 1 - 1
src/pagesStudy/pages/index/index.vue

@@ -31,7 +31,7 @@
             <view class="w-fit ellipsis-1 text-[#F59E0B]">
               <text class="text-24 ">长沙民政职业技术学院长沙民政职业技术学院</text>
             </view>
-            <ie-image src="/src/pagesStudy/static/image/icon-edit-pen.png" custom-class="w-28 h-28" mode="aspectFill" />
+            <ie-image src="/pagesStudy/static/image/icon-edit-pen.png" custom-class="w-28 h-28" mode="aspectFill" />
           </view>
           <view class="ml-30 mb-32 z-1 relative">
             <view class="text-28 text-fore-title font-bold">专项刷题</view>

+ 2 - 0
src/pagesStudy/pages/simulation-analysis/components/rate-chart.vue

@@ -155,8 +155,10 @@ const options = computed(() => {
           fontSize: 32,
           fontWeight: 'bold',
           offsetCenter: [0, -10],
+          // #ifdef H5
           textBorderColor: '#333333',
           textBorderWidth: 4,
+          // #endif
         },
         data: [
           {

+ 3 - 3
src/pagesStudy/pages/simulation-analysis/simulation-analysis.vue

@@ -11,17 +11,17 @@
           <view class="h-1 bg-[#E6E6E6] my-20"></view>
           <view>
             <view class="my-20 flex items-center justify-between text-24">
-              <ie-image src="/src/pagesStudy/static/image/icon-house.png" custom-class="w-24 h-24" mode="aspectFill" />
+              <ie-image src="/pagesStudy/static/image/icon-house.png" custom-class="w-24 h-24" mode="aspectFill" />
               <text class="ml-10 text-fore-light flex-1">考试院校</text>
               <text class="text-fore-title">长沙民政职业技术学院-大数据与会计</text>
             </view>
             <view class="my-20 flex items-center justify-between text-24">
-              <ie-image src="/src/pagesStudy/static/image/icon-group.png" custom-class="w-24 h-24" mode="aspectFill" />
+              <ie-image src="/pagesStudy/static/image/icon-group.png" custom-class="w-24 h-24" mode="aspectFill" />
               <text class="ml-10 text-fore-light flex-1">测试类型</text>
               <text class="text-fore-title">职业技能模拟考试</text>
             </view>
             <view class="my-20 flex items-center justify-between text-24">
-              <ie-image src="/src/pagesStudy/static/image/icon-clock.png" custom-class="w-24 h-24" mode="aspectFill" />
+              <ie-image src="/pagesStudy/static/image/icon-clock.png" custom-class="w-24 h-24" mode="aspectFill" />
               <text class="ml-10 text-fore-light flex-1">测试时间</text>
               <text class="text-fore-title">2025.09.25 10:00</text>
             </view>

+ 2 - 2
src/pagesStudy/pages/study-plan-edit/components/question-setting.vue

@@ -13,8 +13,8 @@
           <text class="ml-20 text-26 text-fore-title">道题</text>
         </view>
         <view class="mt-20 flex gap-x-20">
-          <view class="flex-1 py-20 text-center rounded-6 bg-back text-28 text-fore-subcontnt"
-            :class="questionCount === item ? 'bg-[#E5F7FF] text-primary' : ''" v-for="item in quickOptions"
+          <view class="flex-1 py-20 text-center rounded-6 text-28 text-fore-subcontnt"
+            :class="questionCount === item ? 'bg-[#E5F7FF] text-primary' : 'bg-back'" v-for="item in quickOptions"
             @click="questionCount = item">{{ item }}</view>
         </view>
       </view>

+ 5 - 5
src/pagesStudy/pages/study-plan/components/page-calendar.vue

@@ -3,7 +3,7 @@
     <uni-calendar :insert="true" :lunar="false" :readonly="true" :showMonth="false" :selected="selected"
       :endDate="endDate" @change-month="changeMonth" />
     <view class="wrap mt-20 w-fit mx-auto px-98 py-16 flex items-center justify-center">
-      <ie-image src="/src/pagesStudy/static/image/icon-calendar.png" custom-class="w-22 h-22" />
+      <ie-image src="/pagesStudy/static/image/icon-calendar.png" custom-class="w-22 h-22" />
       <text class="ml-4 text-20 text-primary">{{ tip }}</text>
     </view>
     <view class="mt-40 mx-40 mb-30 grid grid-cols-2 gap-x-26 gap-y-26">
@@ -24,25 +24,25 @@ const stat = ref([
     name: '答题数',
     unit: '道题',
     value: '0/90',
-    icon: '/src/pagesStudy/static/image/icon-pen.png'
+    icon: '/pagesStudy/static/image/icon-pen.png'
   },
   {
     name: '课程学习',
     unit: '课时',
     value: '0/5',
-    icon: '/src/pagesStudy/static/image/icon-video.png'
+    icon: '/pagesStudy/static/image/icon-video.png'
   },
   {
     name: '学习时长',
     unit: '分钟',
     value: '0/120',
-    icon: '/src/pagesStudy/static/image/icon-time.png'
+    icon: '/pagesStudy/static/image/icon-time.png'
   },
   {
     name: '正确率',
     unit: '',
     value: '70%',
-    icon: '/src/pagesStudy/static/image/icon-chart.png'
+    icon: '/pagesStudy/static/image/icon-chart.png'
   }
 ])
 const selected = ref([

+ 3 - 3
src/pagesStudy/pages/targeted-setting/targeted-setting.vue

@@ -12,7 +12,7 @@
       <view class="text-32 text-fore-title font-bold">我的定向院校</view>
       <view v-if="hasSetting" class="flex items-center gap-x-4">
         <text class="text-28 text-[#F59E0B]">设置</text>
-        <ie-image src="/src/pagesStudy/static/image/icon-edit-pen.png" custom-class="w-24 h-24" mode="aspectFill" />
+        <ie-image src="/pagesStudy/static/image/icon-edit-pen.png" custom-class="w-24 h-24" mode="aspectFill" />
       </view>
     </view>
     <view v-if="hasSetting" class="px-30">
@@ -32,7 +32,7 @@
               <view class="mt-8  text-fore-light">财经商贸大类>财务会计类</view>
               <view
                 class="flex items-center gap-x-4 text-white bg-gradient-to-r from-[#FED448] to-[#F9942F] rounded-full px-12 py-4">
-                <ie-image src="/src/pagesStudy/static/image/icon-check-white.png" custom-class="w-24 h-24" />
+                <ie-image src="/pagesStudy/static/image/icon-check-white.png" custom-class="w-24 h-24" />
                 <text>定向学习中</text>
               </view>
             </view>
@@ -41,7 +41,7 @@
       </view>
     </view>
     <view v-else class="flex-1 flex flex-col items-center justify-center gap-y-50">
-      <ie-image src="/src/pagesStudy/static/image/icon-empty.png" custom-class="w-364 h-252 mx-auto" mode="aspectFill" />
+      <ie-image src="/pagesStudy/static/image/icon-empty.png" custom-class="w-364 h-252 mx-auto" mode="aspectFill" />
       <text class="text-30 text-fore-light text-center">目前暂无定向院校~</text>
     </view>
     <ie-safe-toolbar v-if="collegeList.length < 3" :height="84" :shadow="false">