新增 小程序名称环境变量配置,支持通过VITE_APPNAME动态设置应用名称

This commit is contained in:
yuantao
2026-01-19 13:54:45 +08:00
parent 2d0c665ad5
commit 22d9602a25
2 changed files with 3 additions and 0 deletions

1
.env
View File

@@ -1,6 +1,7 @@
VITE_BASE_URL= #接口地址 VITE_BASE_URL= #接口地址
VITE_ASSETSURL=https://cdn.vrupup.com/s/1598/assets/ #资源地址 VITE_ASSETSURL=https://cdn.vrupup.com/s/1598/assets/ #资源地址
VITE_APPID=wx9cb717d8151d8486 #小程序APPID VITE_APPID=wx9cb717d8151d8486 #小程序APPID
VITE_APPNAME=template #小程序名称
VITE_UNI_APPID=_UNI_8842336 #UNI-APPID VITE_UNI_APPID=_UNI_8842336 #UNI-APPID
VITE_LIBVERSION=3.0.0 #微信小程序基础库 VITE_LIBVERSION=3.0.0 #微信小程序基础库
VITE_WEBHOOK=https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=9a401eb2-065a-4882-82e9-b438bcd1eac4#WEBHOOK地址 VITE_WEBHOOK=https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=9a401eb2-065a-4882-82e9-b438bcd1eac4#WEBHOOK地址

View File

@@ -24,6 +24,7 @@ function replaceManifestAppid() {
// 获取环境变量,明确指定路径为项目根目录 // 获取环境变量,明确指定路径为项目根目录
dotenv.config({ path: resolve(__dirname, '.env') }) dotenv.config({ path: resolve(__dirname, '.env') })
const appid = process.env.VITE_APPID const appid = process.env.VITE_APPID
const appName = process.env.VITE_APPNAME
const uni_appId = process.env.VITE_UNI_APPID const uni_appId = process.env.VITE_UNI_APPID
const libVersion = process.env.VITE_LIBVERSION || '3.0.0' const libVersion = process.env.VITE_LIBVERSION || '3.0.0'
@@ -35,6 +36,7 @@ function replaceManifestAppid() {
const manifest = JSON.parse(manifestContent) const manifest = JSON.parse(manifestContent)
// 替换 // 替换
manifest.appid = uni_appId manifest.appid = uni_appId
manifest.name = appName
if (manifest['mp-weixin']) { if (manifest['mp-weixin']) {
manifest['mp-weixin'].appid = appid manifest['mp-weixin'].appid = appid