This commit is contained in:
sjeam 2025-08-31 18:05:14 +08:00
parent 412073a9fb
commit 3f12b30147
15 changed files with 198 additions and 93 deletions

26
env/.env vendored
View File

@ -10,22 +10,30 @@ VITE_APP_PUBLIC_BASE=/
# 登录页面 # 登录页面
VITE_LOGIN_URL = '/pages/login/index' VITE_LOGIN_URL = '/pages/login/index'
VITE_SERVER_BASEURL = 'https://test.shop.lihaink.cn/' # 数字乡村
VITE_UPLOAD_BASEURL = 'https://test.shop.lihaink.cn//upload' VITE_SERVER_BASEURL = 'http://127.0.0.1:8787'
VITE_UPLOAD_BASEURL = 'http://127.0.0.1:8787/upload'
VITE_CRMEB_SERVER_BASEURL = 'https://test.shop.lihaink.cn/pages/user/login' # 村集体
VITE_CRMEB_SERVER_BASEURL = 'https://test.shop.lihaink.cn'
# 村集体登录
VITE_CRMEB_SERVER_BASEURL_LOGIN = 'https://test.shop.lihaink.cn/pages/user/login'
# 有些同学可能需要在微信小程序里面根据 develop、trial、release 分别设置上传地址,参考代码如下。 # 有些同学可能需要在微信小程序里面根据 develop、trial、release 分别设置上传地址,参考代码如下。
# 下面的变量如果没有设置,会默认使用 VITE_SERVER_BASEURL or VITE_UPLOAD_BASEURL # 下面的变量如果没有设置,会默认使用 VITE_SERVER_BASEURL or VITE_UPLOAD_BASEURL
VITE_SERVER_BASEURL__WEIXIN_DEVELOP = 'https://test.shop.lihaink.cn/' VITE_SERVER_BASEURL__WEIXIN_DEVELOP = 'http://127.0.0.1:8787'
VITE_SERVER_BASEURL__WEIXIN_TRIAL = 'https://test.shop.lihaink.cn/' VITE_SERVER_BASEURL__WEIXIN_TRIAL = 'http://127.0.0.1:8787'
VITE_SERVER_BASEURL__WEIXIN_RELEASE = 'https://test.shop.lihaink.cn/' VITE_SERVER_BASEURL__WEIXIN_RELEASE = 'http://127.0.0.1:8787'
VITE_UPLOAD_BASEURL__WEIXIN_DEVELOP = 'https://test.shop.lihaink.cn//upload' VITE_UPLOAD_BASEURL__WEIXIN_DEVELOP = 'http://127.0.0.1:8787/upload'
VITE_UPLOAD_BASEURL__WEIXIN_TRIAL = 'https://test.shop.lihaink.cn//upload' VITE_UPLOAD_BASEURL__WEIXIN_TRIAL = 'http://127.0.0.1:8787/upload'
VITE_UPLOAD_BASEURL__WEIXIN_RELEASE = 'https://test.shop.lihaink.cn//upload' VITE_UPLOAD_BASEURL__WEIXIN_RELEASE = 'http://127.0.0.1:8787/upload'
# h5是否需要配置代理 # h5是否需要配置代理
VITE_APP_PROXY=true VITE_APP_PROXY=true
# 数字乡村代理
VITE_APP_PROXY_PREFIX = '/api' VITE_APP_PROXY_PREFIX = '/api'
# 村集体代理
VITE_APP_PROXY_PREFIX_CRMEB = '/crmeb'

View File

@ -3,7 +3,7 @@
*/ */
export interface IUserInfoVo { export interface IUserInfoVo {
id: number id: number
username: string nickname: string
avatar: string avatar: string
token: string token: string
} }
@ -13,7 +13,7 @@ export interface IUserInfoVo {
*/ */
export interface IUserLogin { export interface IUserLogin {
id: string id: string
username: string nickname: string
token: string token: string
} }

View File

@ -1,16 +1,16 @@
<template> <template>
<view class="fly-login" v-if="modelValue"> <view class="fly-login" v-if="modelValue">
<view class="fly-login-mask" @click="onClose" /> <view class="fly-login-mask" />
<view class="fly-login-content px-4"> <view class="fly-login-content px-4">
<view class="font-bold h-16 leading-16">获取您的昵称头像</view> <!-- <view class="font-bold h-16 leading-16">获取您的昵称头像</view> -->
<view <!-- <view
class="rounded-full bg-light-600 w-6 h-6 text-center absolute top-4 right-4" class="rounded-full bg-light-600 w-6 h-6 text-center absolute top-4 right-4"
@click="onClose" @click="onClose"
> >
<view class="i-carbon-close text-gray-700" /> <view class="i-carbon-close text-gray-700" />
</view> </view> -->
<view <!-- <view
class="flex items-center h-16 leading-16 border-b-gray-400 border-b-solid border-[0rpx]" class="flex items-center h-16 leading-16 border-b-gray-400 border-b-solid border-[0rpx]"
> >
<text class="mr-4 flex-shrink-0">头像</text> <text class="mr-4 flex-shrink-0">头像</text>
@ -20,7 +20,7 @@
@chooseavatar="onChooseAvatar" @chooseavatar="onChooseAvatar"
> >
<image class="w-8 h-8 rounded-full" :src="avatarUrl"></image> <image class="w-8 h-8 rounded-full" :src="avatarUrl"></image>
<!-- <text class="ml-auto i-carbon-chevron-right"></text> --> <text class="ml-auto i-carbon-chevron-right"></text>
</button> </button>
</view> </view>
@ -35,9 +35,22 @@
@change="onChange" @change="onChange"
@blur="onChange" @blur="onChange"
/> />
</view> -->
<view class="text-center m-10">
<wd-button
type="primary"
custom-class="font-bold font-size-4 "
block
size="large"
@click="onSubmit"
>
<text class="color-white font-bold font-size-4 text-shadow">手机号快捷登录</text>
</wd-button>
</view> </view>
<view class="text-center">
<button <text class="color-white font-bold font-size-4 text-shadow" @click="onClose">暂不登录</text>
</view>
<!-- <button
size="default" size="default"
type="default" type="default"
style="color: #fff; background-color: #1aad19; border-color: #1aad19" style="color: #fff; background-color: #1aad19; border-color: #1aad19"
@ -45,7 +58,7 @@
@click="onSubmit" @click="onSubmit"
> >
授权登录 授权登录
</button> </button> -->
</view> </view>
</view> </view>
</template> </template>
@ -105,6 +118,12 @@ const onSubmit = () => {
<style lang="scss" scoped> <style lang="scss" scoped>
.fly-login { .fly-login {
background: url(https://imgs.design006.com/201812/Design006_Nh8kwSNRfZ.jpg);
background-size: cover; /* 保持图片宽高比的同时覆盖整个背景区域 */
background-position: center; /* 将背景图片居中 */
background-repeat: no-repeat; /* 防止背景图片重复 */
width: 100%;
height: 100%;
display: flex; display: flex;
bottom: 0; bottom: 0;
z-index: 1; z-index: 1;
@ -122,7 +141,8 @@ const onSubmit = () => {
right: 0; right: 0;
bottom: var(--window-bottom); bottom: var(--window-bottom);
left: 0; left: 0;
background-color: #fff; top: 50vh;
// background-color: #fff;
border-top-left-radius: 16px; border-top-left-radius: 16px;
border-top-right-radius: 16px; border-top-right-radius: 16px;
} }

View File

@ -1,6 +1,6 @@
import qs from 'qs' import qs from 'qs'
import { useUserStore } from '@/store' import { useUserStore } from '@/store'
import { getEnvBaseUrl } from '@/utils' import { getEnvBaseUrl, getUrlCrmeb, getUrlCrmebProxy } from '@/utils'
import { platform } from '@/utils/platform' import { platform } from '@/utils/platform'
export type CustomRequestOptions = UniApp.RequestOptions & { export type CustomRequestOptions = UniApp.RequestOptions & {
@ -11,7 +11,7 @@ export type CustomRequestOptions = UniApp.RequestOptions & {
// 请求基准地址 // 请求基准地址
const baseUrl = getEnvBaseUrl() const baseUrl = getEnvBaseUrl()
const this_baseUrl = getUrlCrmeb()
// 拦截器配置 // 拦截器配置
const httpInterceptor = { const httpInterceptor = {
// 拦截前触发 // 拦截前触发
@ -21,29 +21,55 @@ const httpInterceptor = {
const queryStr = qs.stringify(options.query) const queryStr = qs.stringify(options.query)
if (options.url.includes('?')) { if (options.url.includes('?')) {
options.url += `&${queryStr}` options.url += `&${queryStr}`
} } else {
else {
options.url += `?${queryStr}` options.url += `?${queryStr}`
} }
} }
// 非 http 开头需拼接地址 if (options.url.startsWith(getUrlCrmebProxy())) {
if (!options.url.startsWith('http')) { options.url = options.url.replace('/crmeb', '')
// #ifdef H5 const this_baseUrl = getUrlCrmeb()
// console.log(__VITE_APP_PROXY__) // 非 http 开头需拼接地址
if (JSON.parse(__VITE_APP_PROXY__)) { if (!options.url.startsWith('http')) {
// 自动拼接代理前缀 // #ifdef H5
options.url = import.meta.env.VITE_APP_PROXY_PREFIX + options.url // console.log(__VITE_APP_PROXY__)
if (JSON.parse(__VITE_APP_PROXY__)) {
// 自动拼接代理前缀--非自定义代理
options.url = getUrlCrmebProxy() + options.url
} else {
options.url = this_baseUrl + options.url
}
// #endif
// 非H5正常拼接
// #ifndef H5
options.url = this_baseUrl + options.url
// #endif
// TIPS: 如果需要对接多个后端服务,也可以在这里处理,拼接成所需要的地址
} }
else { // options.url = options.url
options.url = baseUrl + options.url } else {
const this_baseUrl = getEnvBaseUrl()
// 非 http 开头需拼接地址
if (!options.url.startsWith('http')) {
// #ifdef H5
// console.log(__VITE_APP_PROXY__)
if (JSON.parse(__VITE_APP_PROXY__)) {
// 自动拼接代理前缀--非自定义代理
options.url = import.meta.env.VITE_APP_PROXY_PREFIX + options.url
} else {
options.url = this_baseUrl + options.url
}
// #endif
// 非H5正常拼接
// #ifndef H5
options.url = this_baseUrl + options.url
// #endif
// TIPS: 如果需要对接多个后端服务,也可以在这里处理,拼接成所需要的地址
} }
// #endif
// 非H5正常拼接
// #ifndef H5
options.url = baseUrl + options.url
// #endif
// TIPS: 如果需要对接多个后端服务,也可以在这里处理,拼接成所需要的地址
} }
// console.log('请求地址', options.url)
// console.log('请求地址', options.url.startsWith(getUrlCrmebProxy()))
// 1. 请求超时 // 1. 请求超时
options.timeout = 10000 // 10s options.timeout = 10000 // 10s
// 2. (可选)添加小程序端请求头标识 // 2. (可选)添加小程序端请求头标识

View File

@ -14,12 +14,12 @@
<!-- <StickyNav /> --> <!-- <StickyNav /> -->
<view class=""> <view class="">
<view class="background_home"> <view class="background_home">
<view class="px-2"> <view class="">
<view class="" style="" @click="more"> <view class="" style="" @click="more">
<wd-card custom-class="card-content"> <wd-card custom-class="card-content">
<view class="relative" style="height: 380rpx"> <view class="relative h-50">
<wd-img <wd-img
radius="20rpx" radius="0px 0px 20rpx 20rpx "
:width="'100%'" :width="'100%'"
:height="'100%'" :height="'100%'"
src="https://bpic.588ku.com/back_list_pic/23/05/17/75e92f4e681efeb526f7d8603199ca11.jpg" src="https://bpic.588ku.com/back_list_pic/23/05/17/75e92f4e681efeb526f7d8603199ca11.jpg"

View File

@ -13,15 +13,13 @@
<template> <template>
<view class=""> <view class="">
<view class="background_home"> <view class="background_home">
<view class="px-2" style="" @click="more"> <view class="" style="" @click="more">
<wd-card custom-class="card-content"> <wd-card custom-class="card-content">
<view class="relative" style="height: 680rpx"> <view class="relative" style="height: 680rpx">
<wd-swiper <wd-swiper
:list="[ value-key="url"
'https://img.shetu66.com/2023/07/04/1688453333865029.png', custom-text-style="color:#fff"
'https://www.keaitupian.cn/cjpic/frombd/2/253/1659552792/3869332496.jpg', :list="swiperList"
'https://img-baofun.zhhainiao.com/pcwallpaper_ugc/static/a6bba9bd1de44293b8d08a64d94775e4.jpg',
]"
autoplay autoplay
height="680rpx" height="680rpx"
:indicator="{ type: 'dots-bar' }" :indicator="{ type: 'dots-bar' }"
@ -33,9 +31,9 @@
style="backdrop-filter: blur(2rpx); border-radius: 10rpx" style="backdrop-filter: blur(2rpx); border-radius: 10rpx"
> >
<!-- <wd-search hide-cancel placeholder-left placeholder="请输入内容"></wd-search> --> <!-- <wd-search hide-cancel placeholder-left placeholder="请输入内容"></wd-search> -->
<text class="block font-size-4 text-left">三江区街道</text> <text class="block font-size-4 text-left">{{ swiperList[current].name }}</text>
<text class="block font-size-3 text-left"> <text class="block font-size-3 text-left">
因举办古韵悠然的传统民俗文化节热度飙升在这里你能感受到乡村文化的深厚底蕴和无穷魅力 {{ swiperList[current].title }}
</text> </text>
</view> </view>
</view> </view>
@ -437,11 +435,9 @@ onLoad(() => {
// postFoo() // postFoo()
}) })
const product_30 = ref([]) const product_30 = ref([])
const getProduct = async (id) => { const getProduct = async (id) => {
const res = await getProductAPI(id) const res = await getProductAPI(id)
product_30.value = res.data product_30.value = res.data
// // console.log(res.data)
// console.log(product_30.value) // console.log(product_30.value)
} }
@ -455,6 +451,34 @@ const getProduct = async (id) => {
// initialData, // initialData,
// }) // })
//
const swiperList = [
{
name: '三江区街道',
title:
'因举办古韵悠然的传统民俗文化节热度飙升,在这里,你能感受到乡村文化的深厚底蕴和无穷魅力。',
url: 'https://img.shetu66.com/2023/07/04/1688453333865029.png',
},
{
name: '农资供应',
title:
'因举办古韵悠然的传统民俗文化节热度飙升,在这里,你能感受到乡村文化的深厚底蕴和无穷魅力。',
url: 'https://www.keaitupian.cn/cjpic/frombd/2/253/1659552792/3869332496.jpg',
},
{
name: '土地流转',
title:
'因举办古韵悠然的传统民俗文化节热度飙升,在这里,你能感受到乡村文化的深厚底蕴和无穷魅力。',
url: 'https://img-baofun.zhhainiao.com/pcwallpaper_ugc/static/a6bba9bd1de44293b8d08a64d94775e4.jpg',
},
]
const current = ref(1)
function onChange(e) {
// console.log(e)
current.value = e.current
}
const currentTab = ref(1) const currentTab = ref(1)
function changeTab(e) { function changeTab(e) {
console.log(e) console.log(e)

View File

@ -6,17 +6,17 @@
<template> <template>
<view class="background_home"> <view class="background_home">
<view class="p-4" style=""> <view class=" " style="">
<wd-card custom-class="card-content"> <wd-card custom-class="card-content">
<view class="relative" style="height: 380rpx"> <view class="relative h-50">
<wd-img <wd-img
radius="20rpx" radius="0px 0px 20rpx 20rpx "
:width="'100%'" :width="'100%'"
:height="'100%'" :height="'100%'"
src="https://img.shetu66.com/2023/06/14/1686734441937414.png" src="https://img.shetu66.com/2023/06/14/1686734441937414.png"
/> />
<view <view
class="m-4 absolute bottom-0 text-left left-0 right-0 text-white bg-black bg-opacity-20" class="m-4 absolute bottom-0 text-left left-0 right-0 text-white bg-black bg-opacity-0"
style="backdrop-filter: blur(2rpx); border-radius: 10rpx" style="backdrop-filter: blur(2rpx); border-radius: 10rpx"
> >
<view class="p-4"> <view class="p-4">
@ -28,7 +28,7 @@
微信用户{{ userStore.userInfo?.nickname }} 微信用户{{ userStore.userInfo?.nickname }}
</view> </view>
<view class="ml-1 font-size-3" style="align-items: end"> <view class="ml-1 font-size-3" style="align-items: end">
<text class="pe-2 font-size-3">账号{{ userStore.userInfo?.nickname }}</text> <text class="pe-2 font-size-3">ID{{ userStore.userInfo?.id }}</text>
</view> </view>
</view> </view>
</view> </view>
@ -53,6 +53,7 @@ import { useUserStore } from '@/store'
const show = ref(false) const show = ref(false)
const userStore = useUserStore() const userStore = useUserStore()
console.log('获取用户信息', userStore.userInfo)
const hasLogin = computed(() => userStore.userInfo?.nickname) const hasLogin = computed(() => userStore.userInfo?.nickname)
const logout = () => { const logout = () => {
uni.showModal({ uni.showModal({

View File

@ -61,22 +61,22 @@ const logout = () => {
}, },
}) })
} }
// userStore.wxLogin()
// openId // // openId
uni.login({ // uni.login({
provider: 'weixin', // provider: 'weixin',
success: async ({ code }) => { // success: async ({ code }) => {
const res = await http<{ session_key: string; openid: string }>({ // const res = await http<{ session_key: string; openid: string }>({
method: 'POST', // method: 'POST',
url: '/api/auth/routineLogin', // url: '/api/auth/routineLogin',
data: { // data: {
code, // code,
}, // },
}) // })
console.log('微信登录-1', res) // console.log('-1', res)
// {code: 0, msg: "success", data: {session_key: "JTzhLVK+oM3X58uJ/heDcQ==", openid: "oSYa06xPVqjsK-eFYzt0kSPYu1q4"}} // // {code: 0, msg: "success", data: {session_key: "JTzhLVK+oM3X58uJ/heDcQ==", openid: "oSYa06xPVqjsK-eFYzt0kSPYu1q4"}}
openId.value = res.data.openid // openId.value = res.data.openid
userStore.setUserInfo({ openid: res.data.openid }) // userStore.setUserInfo({ openid: res.data.openid })
}, // },
}) // })
</script> </script>

View File

@ -31,9 +31,9 @@ function more(item) {
<template> <template>
<view class=""> <view class="">
<view class="background_home"> <view class="background_home">
<view class="relative h-50 px-2"> <view class="relative h-50">
<wd-img <wd-img
radius="20rpx" radius="0px 0px 20rpx 20rpx "
:width="'100%'" :width="'100%'"
:height="'100%'" :height="'100%'"
src="https://meizi-chao-pub.8531.cn/1813416312440430594_720px.jpg" src="https://meizi-chao-pub.8531.cn/1813416312440430594_720px.jpg"

View File

@ -23,7 +23,7 @@
<script> <script>
import { defineComponent, computed } from 'vue' import { defineComponent, computed } from 'vue'
import CustomNavbar from '@/components/CustomNavbar.vue' import CustomNavbar from '@/components/CustomNavbar.vue'
import { getUrlCrmeb } from '@/utils' import { getUrlCrmebLogin } from '@/utils'
export default defineComponent({ export default defineComponent({
data() { data() {
@ -50,7 +50,7 @@ export default defineComponent({
title: '商城', // title: '商城', //
}) })
this.local_url = decodeURIComponent(getUrlCrmeb() + option.local_url) this.local_url = decodeURIComponent(getUrlCrmebLogin() + option.local_url)
this.title = option.title || '商城首页' this.title = option.title || '商城首页'

View File

@ -21,7 +21,7 @@
<script> <script>
import { defineComponent, computed } from 'vue' import { defineComponent, computed } from 'vue'
import CustomNavbar from '@/components/CustomNavbar.vue' import CustomNavbar from '@/components/CustomNavbar.vue'
import { getUrlCrmeb } from '@/utils' import { getUrlCrmebLogin } from '@/utils'
export default defineComponent({ export default defineComponent({
data() { data() {
@ -44,10 +44,10 @@ export default defineComponent({
}, },
}, },
onLoad(option) { onLoad(option) {
// this.local_url = decodeURIComponent(getUrlCrmeb() + option.target) // this.local_url = decodeURIComponent(getUrlCrmebLogin() + option.target)
console.log(getUrlCrmeb()) console.log(getUrlCrmebLogin())
const target = encodeURIComponent(option.target) const target = encodeURIComponent(option.target)
this.local_url = getUrlCrmeb() + '?target=' + target this.local_url = getUrlCrmebLogin() + '?target=' + target
this.title = option.title || '' this.title = option.title || ''
uni.setNavigationBarTitle({ uni.setNavigationBarTitle({
title: this.title, // title: this.title, //

View File

@ -1,5 +1,5 @@
import { http } from '@/utils/http' import { http } from '@/utils/http'
import { getEnvBaseUrl, getUrlCrmeb, getUrlCrmebProxy } from '@/utils'
export interface IFooItem { export interface IFooItem {
cate_pid: string cate_pid: string
// name: string // name: string
@ -8,7 +8,7 @@ export interface IFooItem {
/** GET 请求 */ /** GET 请求 */
export function getProductAPI(cate_pid: string) { export function getProductAPI(cate_pid: string) {
return http.get<IFooItem>('/api/product/spu/lst', { cate_pid }) return http.get<IFooItem>(getUrlCrmebProxy() + '/api/product/spu/lst', { cate_pid })
} }
/** GET 请求;支持 传递 header 的范例 */ /** GET 请求;支持 传递 header 的范例 */
export function getFooAPI2(name: string) { export function getFooAPI2(name: string) {

View File

@ -1,6 +1,7 @@
import type { IUserInfoVo } from '@/api/login.typings' import type { IUserInfoVo } from '@/api/login.typings'
import { defineStore } from 'pinia' import { defineStore } from 'pinia'
import { ref } from 'vue' import { ref } from 'vue'
import { getEnvBaseUrl } from '@/utils'
import { import {
getUserInfo as _getUserInfo, getUserInfo as _getUserInfo,
login as _login, login as _login,
@ -9,11 +10,11 @@ import {
getWxCode, getWxCode,
} from '@/api/login' } from '@/api/login'
import { toast } from '@/utils/toast' import { toast } from '@/utils/toast'
const baseUrl = getEnvBaseUrl()
// 初始化状态 // 初始化状态
const userInfoState: IUserInfoVo = { const userInfoState: IUserInfoVo = {
id: 0, id: 0,
username: '', nickname: '',
avatar: '/static/images/default-avatar.png', avatar: '/static/images/default-avatar.png',
token: '', token: '',
} }
@ -30,7 +31,8 @@ export const useUserStore = defineStore(
if (!val.avatar) { if (!val.avatar) {
val.avatar = userInfoState.avatar val.avatar = userInfoState.avatar
} else { } else {
val.avatar = 'https://oss.laf.run/ukw0y1-site/avatar.jpg?feige' val.avatar = baseUrl + val.avatar //地址拼接
// val.avatar = 'https://oss.laf.run/ukw0y1-site/avatar.jpg?feige'
} }
userInfo.value = val userInfo.value = val
} }
@ -63,7 +65,7 @@ export const useUserStore = defineStore(
* @returns R<IUserLogin> * @returns R<IUserLogin>
*/ */
const login = async (credentials: { const login = async (credentials: {
username: string nickname: string
password: string password: string
code: string code: string
uuid: string uuid: string
@ -88,10 +90,15 @@ export const useUserStore = defineStore(
const wxLogin = async () => { const wxLogin = async () => {
// 获取微信小程序登录的code // 获取微信小程序登录的code
const data = await getWxCode() const data = await getWxCode()
console.log('微信登录code', data) // console.log('微信登录code', data)
const res = await _wxLogin(data) const res = await _wxLogin(data)
await getUserInfo() console.log('微信登录信息', res.data)
// await getUserInfo()
const userInfo = res.data
setUserInfo(userInfo)
uni.setStorageSync('userInfo', userInfo)
uni.setStorageSync('token', userInfo.token)
return res return res
} }

View File

@ -162,8 +162,20 @@ export function getEnvBaseUploadUrl() {
return baseUploadUrl return baseUploadUrl
} }
export function getUrlCrmebLogin() {
// 请求基准地址
let baseUrl = import.meta.env.VITE_CRMEB_SERVER_BASEURL_LOGIN
return baseUrl
}
export function getUrlCrmeb() { export function getUrlCrmeb() {
// 请求基准地址 // 请求基准地址
let baseUrl = import.meta.env.VITE_CRMEB_SERVER_BASEURL let baseUrl = import.meta.env.VITE_CRMEB_SERVER_BASEURL
return baseUrl return baseUrl
} }
export function getUrlCrmebProxy() {
// 获取代理路径
let baseUrl = import.meta.env.VITE_APP_PROXY_PREFIX_CRMEB
return baseUrl
}

View File

@ -46,10 +46,12 @@ export default async ({ command, mode }) => {
const { const {
VITE_APP_PORT, VITE_APP_PORT,
VITE_SERVER_BASEURL, VITE_SERVER_BASEURL,
VITE_CRMEB_SERVER_BASEURL,
VITE_DELETE_CONSOLE, VITE_DELETE_CONSOLE,
VITE_SHOW_SOURCEMAP, VITE_SHOW_SOURCEMAP,
VITE_APP_PROXY, VITE_APP_PROXY,
VITE_APP_PROXY_PREFIX, VITE_APP_PROXY_PREFIX,
VITE_APP_PROXY_PREFIX_CRMEB,
} = env } = env
console.log('环境变量 env -> ', env) console.log('环境变量 env -> ', env)
@ -165,6 +167,11 @@ export default async ({ command, mode }) => {
changeOrigin: true, changeOrigin: true,
rewrite: (path) => path.replace(new RegExp(`^${VITE_APP_PROXY_PREFIX}`), ''), rewrite: (path) => path.replace(new RegExp(`^${VITE_APP_PROXY_PREFIX}`), ''),
}, },
[VITE_APP_PROXY_PREFIX_CRMEB]: {
target: VITE_CRMEB_SERVER_BASEURL,
changeOrigin: true,
rewrite: (path) => path.replace(new RegExp(`^${VITE_APP_PROXY_PREFIX_CRMEB}`), ''),
},
} }
: undefined, : undefined,
}, },