Browse Source

build(h5): 配置 H5 构建输出目录及地图 SDK

- 新增 H5 平台构建输出目录为 smqjhh5
- manifest 配置调整,增加腾讯地图 sdk key
- 修改 vite 配置,H5 模式下输出路径为 smqjhh5
- manifest.json 同步添加地图 sdk 配置
- package.json 增加针对 H5 自定义构建命令
- 修正多个组件中图片 src 字符串空格问题
- 优化首页地址栏样式,修正部分视图宽度适配
- 修改重定向地址以适应新的 H5 域名
- 调整首页跳转逻辑,在 H5 环境打开微信文章链接
zhangtao 1 ngày trước cách đây
mục cha
commit
5744dd5a8d

+ 1 - 0
.gitignore

@@ -11,6 +11,7 @@ dist
 node_modules
 async-import.d.ts
 async-component.d.ts
+smqjhh5
 
 # Executables
 *.swf

+ 9 - 2
manifest.config.ts

@@ -86,8 +86,15 @@ export default defineManifestConfig({
     usingComponents: true,
   },
   'h5': {
-    darkmode: true,
-    themeLocation: 'theme.json',
+    // darkmode: true,
+    // themeLocation: 'theme.json',
+    sdkConfigs: {
+      maps: {
+        qqmap: {
+          key: 'JO5BZ-QLVCJ-22OFQ-XNV4U-MHIWV-UCFQB',
+        },
+      },
+    },
   },
   'uniStatistics': {
     enable: false,

+ 1 - 0
package.json

@@ -35,6 +35,7 @@
     "build:custom": "uni build -p",
     "build:h5": "uni build",
     "build:h5:ssr": "uni build --ssr",
+    "build:h5:custom": "uni build -p h5 --outDir smqjhh5",
     "build:h5:development": "uni build --mode development",
     "build:h5:staging": "uni build --mode staging",
     "build:h5:production": "uni build --mode production",

+ 1 - 1
src/config/index.ts

@@ -53,4 +53,4 @@ function handleEnvVersion() {
 /**
  * h5小橘重定向地址
  */
-export const REDIRECT_URL = 'https://smqjh.ddjy.zswlgz.com/'
+export const REDIRECT_URL = 'https://smqjh.h5.zswlgz.com/#/subPack-refueling/commonTab/index'

+ 7 - 2
src/manifest.json

@@ -84,7 +84,12 @@
   },
   "vueVersion": "3",
   "h5": {
-    "darkmode": true,
-    "themeLocation": "theme.json"
+    "sdkConfigs": {
+      "maps": {
+        "qqmap": {
+          "key": "JO5BZ-QLVCJ-22OFQ-XNV4U-MHIWV-UCFQB"
+        }
+      }
+    }
   }
 }

+ 2 - 2
src/pages/cart/index.vue

@@ -124,7 +124,7 @@ async function handleSelectAddress() {
                     <!-- <wd-input-number v-model="item.num" disable-input @change="handleChangeNum($event, item)" /> -->
                     <view class="flex items-center">
                       <image
-                        :src="` ${StaticUrl}/sub-cart.png`"
+                        :src="`${StaticUrl}/sub-cart.png`"
                         class="h-44rpx w-44rpx"
                         @click.stop="cartStore.cartSubGoods(item)"
                       />
@@ -132,7 +132,7 @@ async function handleSelectAddress() {
                         {{ item.num }}
                       </view>
                       <image
-                        :src="` ${StaticUrl}/add-cart.png`"
+                        :src="`${StaticUrl}/add-cart.png`"
                         class="h-44rpx w-44rpx"
                         @click.stop="cartStore.cartAddGoods(item)"
                       />

+ 4 - 4
src/pages/index/index.vue

@@ -136,8 +136,8 @@ function handleJyBanner() {
     url: 'https://mp.weixin.qq.com/s/lxpdZ6DUhgqg00AT9klu5Q',
   })
   // #endif
-  // #ifndef MP-WEIXIN
-  show({ msg: '请在微信小程序中使用此功能' })
+  // #ifdef H5
+  window.open('https://mp.weixin.qq.com/s/lxpdZ6DUhgqg00AT9klu5Q')
   // #endif
 }
 </script>
@@ -159,14 +159,14 @@ function handleJyBanner() {
       class="header-linear h-320rpx px-24rpx"
       :style="{ paddingTop: `${(Number(statusBarHeight) || 44) + MenuButtonHeight + 12}px` }"
     >
-      <view class="box-border flex items-center">
+      <view class="box-border w-full flex items-center">
         <view class="flex items-center" @click="useAddressStore().getMapAddress()">
           <image :src="`${StaticUrl}/location-black.png`" class="h-33.8rpx min-w-28.97rpx w-28.97rpx" />
           <view class="ml-18rpx max-w-180rpx truncate text-32rpx">
             {{ name }}
           </view>
         </view>
-        <view class="ml-16rpx h-60rpx w-502rpx flex items-center justify-between rounded-40rpx bg-white pr-6rpx">
+        <view class="ml-16rpx h-60rpx flex flex-1 items-center justify-between rounded-40rpx bg-white pr-6rpx">
           <view class="flex items-center pb-14rpx pl-24rpx pt-16rpx">
             <wd-icon name="search" size="14" color="#ccc" />
             <view class="ml-12rpx text-24rpx text-gray">

+ 2 - 2
src/subPack-xsb/commonTab/components/cart.vue

@@ -90,7 +90,7 @@ onMounted(async () => {
                       <!-- <wd-input-number v-model="item.num" disable-input @change="handleChangeNum($event, item)" /> -->
                       <view class="flex items-center">
                         <image
-                          :src="` ${StaticUrl}/sub-cart.png`"
+                          :src="`${StaticUrl}/sub-cart.png`"
                           class="h44rpx w44rpx"
                           @click.stop="cartStore.cartSubGoods(item)"
                         />
@@ -98,7 +98,7 @@ onMounted(async () => {
                           {{ item.num }}
                         </view>
                         <image
-                          :src="` ${StaticUrl}/add-cart.png`"
+                          :src="`${StaticUrl}/add-cart.png`"
                           class="h44rpx w44rpx"
                           @click.stop="cartStore.cartAddGoods(item)"
                         />

+ 1 - 1
vite.config.ts

@@ -19,7 +19,7 @@ export default async () => {
       exclude: process.env.NODE_ENV === 'development' ? ['wot-design-uni', 'uni-echarts'] : [],
     },
     build: {
-      outDir: 'smqjhh5',
+      outDir: process.env.UNI_PLATFORM === 'h5' ? 'smqjhh5' : undefined,
     },
     plugins: [
       // https://github.com/uni-helper/vite-plugin-uni-manifest