xuxueyang
2024-07-08 d3b3262835502c091d88883145cb9606a6e1af7f
update 自定义发行
已修改5个文件
已添加1个文件
4527 ■■■■ 文件已修改
App.vue 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
manifest.json 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
modifyManifest.js 41 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
package-lock.json 4404 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
package.json 72 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pages/login/supplier-login.vue 7 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
App.vue
@@ -40,6 +40,7 @@
                    const res = await this.$store.dispatch('getCurrentInfo');
                    // console.log('init info',res,this.currentInfo)
                    if (this.currentInfo && this.currentInfo.id && !this.currentInfo.openId) {
                        uni.reLaunch({
                            url: '/pages/home/supplier-home'
                        })
manifest.json
@@ -49,7 +49,7 @@
    "quickapp" : {},
    /* 快应用特有相关 */
    "mp-weixin" : {
        "appid" : "wx3203fd935a6ffe09",
        "appid" : "wx6d0ecc4e18710458",
        "setting" : {
            "urlCheck" : false,
            "es6" : true,
modifyManifest.js
对比新文件
@@ -0,0 +1,41 @@
const fs = require('fs')
//此处如果是用HBuilderX创建的项目manifest.json文件在项目跟目录,如果是 cli 创建的则在 src 下,这里要注意
//process.env.UNI_INPUT_DIR为项目所在的绝对路径,经测试,相对路径会找不到文件
const manifestPath = process.env.UNI_INPUT_DIR + '/manifest.json'
let Manifest = fs.readFileSync(manifestPath, { encoding: 'utf-8' })
function replaceManifest(path, value) {
  const arr = path.split('.')
  const len = arr.length
  const lastItem = arr[len - 1]
  let i = 0
  let ManifestArr = Manifest.split(/\n/)
  for (let index = 0; index < ManifestArr.length; index++) {
    const item = ManifestArr[index]
    if (new RegExp(`"${arr[i]}"`).test(item)) ++i;
    if (i === len) {
      const hasComma = /,/.test(item)
      ManifestArr[index] = item.replace(new RegExp(`"${lastItem}"[\\s\\S]*:[\\s\\S]*`), `"${lastItem}": ${value}${hasComma ? ',' : ''}`)
      break;
    }
  }
  Manifest = ManifestArr.join('\n')
}
//动态配置 h5.router.base ,这部分的代码可根据自己的需要写,需要改什么,按照manifest.json对应的路径写好即可
if (process.env.NODE_ENV === 'production') {
replaceManifest('h5.router.base', '"/game"')
}
else if (process.env.NODE_ENV === 'test') {
replaceManifest('h5.router.base', '"/test/game"')
}
else if (process.env.NODE_ENV === 'development') {
replaceManifest('h5.router.base', '"/dev/game"')
}
fs.writeFileSync(manifestPath, Manifest, {
  "flag": "w"
})
package-lock.json
文件太大
package.json
@@ -1,37 +1,37 @@
{
    "uni-app": {
        "scripts": {
            "local": {
                "title": "花农/供应商",
                "BROWSER": "Chrome",
                "env": {
                    "UNI_PLATFORM": "MP",
                    "SERVER_COMMON": "supplier"
                },
                "define": {
                    "H5-SERVERLOCAL": true
                }
            },
            "common": {
                "title": "一般",
                "BROWSER": "Chrome",
                "env": {
                    "UNI_PLATFORM": "MP",
                    "SERVER_COMMON": "AAA"
                },
                "define": {
                    "H5-SERVERCOMMON": true
                }
            }
        }
    },
    "dependencies": {
        "moment": "^2.30.1",
        "uview-ui": "^2.0.36"
    },
    "devDependencies": {
        "sass": "^1.77.6",
        "sass-loader": "^10.5.2"
    }
{
    "uni-app": {
        "scripts": {
            "supplier": {
                "title": "花农/供应商-小程序",
                "BROWSER": "Chrome",
                "env": {
                    "UNI_PLATFORM": "mp-weixin",
                    "PUB_TYPE": "supplier"
                },
                "define": {
                    "PUB_SUPPLIER": true
                }
            },
            "partner": {
                "title": "合伙人-小程序",
                "BROWSER": "Chrome",
                "env": {
                    "UNI_PLATFORM": "mp-weixin",
                    "PUB_TYPE": "partner"
                },
                "define": {
                    "PUB_PARTNER": true
                }
            }
        }
    },
    "dependencies": {
        "moment": "^2.30.1",
        "uview-ui": "^2.0.36"
    },
    "devDependencies": {
        "sass": "^1.77.6",
        "sass-loader": "^10.5.2"
    }
}
pages/login/supplier-login.vue
@@ -56,8 +56,13 @@
            apitype: {
                type:String,
                default(){
                    // #ifdef PUB_SUPPLIER
                    return 'loginSupplier'
                    // #endif
                    // #ifdef PUB_PARTNER
                    return 'loginPartner'
                    // #endif
                    return ''
                    // return 'loginPartner'
                }
            },