超市页面修改

This commit is contained in:
ctw committed 2025-01-07 13:58:57 +08:00
1 parent 6f9d49f088
commit c966bc423f
19 files changed
+5137 -4140

No files matched your search

+8 -5
View File
@@ -1,4 +1,3 @@
# ******************** start 开发环境 start ********************
#是否是TOC应用
VITE_IS_TOC=true
@@ -8,19 +7,23 @@ VITE_IS_H5=true
#是否是微服务架构
VITE_IS_MICRO=true
# 后端请求前缀
VITE_API_URL = /api
# 前端加密密钥
VITE_PWD_ENC_KEY='pigxpigxpigxpigx'
# OAUTH2 APP模式客户端信息
VITE_OAUTH2_APP_CLIENT='mini:mini'
VITE_OAUTH2_ZZDSHAPP_CLIENT='zzdsh:zzdsh'
# 图片访问基础地址
VITE_IMAGE_BASE_PATH = http://localhost:9999
# VITE_APP_DEV_SERVICE =http://123.156.230.15:8089/api
# VITE_APP_DEV_SERVICE =http://123.156.230.15:8089/app-api
# ******************** start 开发环境 start ********************
# VITE_APP_DEV_SERVICE =http://123.156.228.134:48080/app-api
# VITE_APP_DEV_SERVICE = https://stgl.pj.gov.cn/app-api
VITE_APP_DEV_SERVICE = http://192.168.101.24:48080/app-api
# VITE_APP_DEV_SERVICE = http://192.168.101.24:48080/app-api
VITE_APP_DEV_SERVICE = http://localhost:9999
# ******************** end 开发环境 end ********************
+4944 -3844
View File
File diff suppressed because it is too large. Load diff
-1
View File
@@ -1,3 +1,2 @@
declare const __TABBAR__: Array<string>;
declare const __ROUTES__: Array<any>;
declare const __APP_SERVICE__: string;
+9 -6
View File
@@ -6,6 +6,8 @@ import { isEmpty } from "radash"
import { hooks, router } from "@@/index"
import { merchantApi, foodApi, payApi } from "@@/api"
import { filePath } from "@@/utils/file"
import zSwiper from "@zebra-ui/swiper/components/z-swiper/z-swiper.vue"
import zSwiperItem from "@zebra-ui/swiper/components/z-swiper-item/z-swiper-item.vue"
@@ -205,8 +207,8 @@ const doFood = () => {
<tm-sticky>
<!-- start 轮播 start -->
<z-swiper>
<z-swiper-item v-for="(v, i) in state.detail.swiper?.split(',')" :key="i">
<image class="w-100vw h-400rpx" :src="v" mode="aspectFill" />
<z-swiper-item v-for="(v, i) in state.detail.swiperPic?.split(',')" :key="i">
<image class="w-100vw h-400rpx" :src="filePath(v)" mode="aspectFill" />
</z-swiper-item>
</z-swiper>
<!-- end 轮播 end -->
@@ -215,22 +217,23 @@ const doFood = () => {
<!-- start 简介 start -->
<view class="h-15rpx" />
<view flex-row card p-20rpx>
<image class="w-160rpx h-160rpx rounded-12rpx" :src="state.detail.logo" mode="aspectFill" />
<image class="w-160rpx h-160rpx rounded-12rpx" :src="filePath(state.detail.logoPic)"
mode="aspectFill" />
<view class="flex-1 flex-col m-l-20rpx">
<view class="flex-row items-center justify-between">
<view class="flex-row-center sub-text-36">
<text>{{ state.detail.name }}</text>
</view>
<view>
<tm-tag size="s">{{ state.detail.deptStr }}</tm-tag>
<tm-tag size="s">{{ state.detail.deptName }}</tm-tag>
</view>
</view>
<view class="m-t-10rpx second-text-28">
<text>营业时间</text>
<text class="m-l-10rpx">
{{ hooks.useTime(state.detail.applianceStartTime, "{h}:{i}") }}
{{ state.detail.jobStartTime }}
~
{{ hooks.useTime(state.detail.applianceEndTime, "{h}:{i}") }}
{{ state.detail.jobEndTime }}
</text>
</view>
<view class="m-t-10rpx second-text-28">
+8 -6
View File
@@ -5,10 +5,12 @@ import { onLoad, onShow } from "@dcloudio/uni-app";
import { hooks, router } from "@@/index"
import { merchantApi } from "@@/api"
import { filePath } from "@@/utils/file"
const state = reactive<any>({
pa: {
pagesize: 10,
type: 'canteen'
type: '1'
}
})
@@ -22,7 +24,7 @@ onShow(() => {
})
const pageRef = ref<any>(null)
const pageHook = hooks.usePage(pageRef, merchantApi.page, null, 'data.list')
const pageHook = hooks.usePage(pageRef, merchantApi.page, null, 'data.records')
const query = (page: number, pagesize: number) => {
pageHook.startPage(page, pagesize, false, state.pa);
}
@@ -39,22 +41,22 @@ const query = (page: number, pagesize: number) => {
</template>
<view class="flex-row card p-20rpx m-b-20rpx" v-for="(v, i) in pageHook.list" :key="i"
@tap="router.jump('/pages/merchant/detail', { id: v.id })">
<image class="w-160rpx h-160rpx rounded-12rpx" :src="v.logo" mode="aspectFill" />
<image class="w-160rpx h-160rpx rounded-12rpx" :src="filePath(v.logoPic)" mode="aspectFill" />
<view class="flex-1 flex-col m-l-20rpx">
<view class="flex-row items-center justify-between">
<view class="flex-row-center sub-text-34">
<text> {{ v.name }}</text>
</view>
<view>
<tm-tag size="s">{{ v.deptStr }}</tm-tag>
<tm-tag size="s">{{ v.deptName }}</tm-tag>
</view>
</view>
<view class="m-t-10rpx second-text-28">
<text>营业时间</text>
<text class="m-l-10rpx">
{{ hooks.useTime(v.applianceStartTime, "{h}:{i}") }}
{{ v.jobStartTime }}
~
{{ hooks.useTime(v.applianceEndTime, "{h}:{i}") }}
{{ v.jobEndTime }}
</text>
</view>
<view v-if="v.addressDes" class="m-t-10rpx second-text-28">
+9 -12
View File
@@ -18,7 +18,7 @@ const applyFormRules = reactive<any>({
password: [{ required: true, message: "请输入密码" }],
});
onLoad(() => {});
onLoad(() => { });
onShow(() => {
const userInfoKey = constant.storageConstant.USERINFO;
@@ -33,19 +33,18 @@ const doSubmit = async () => {
const tokenKey = constant.storageConstant.TOKEN;
const userInfoKey = constant.storageConstant.USERINFO;
uni.showLoading({ title: "登录中...", mask: true });
// try {
const res = await userApi.login({ ...applyForm });
const res = await userApi.login({
...applyForm,
grant_type: 'password',
scope: 'server',
});
if (res.code != 0) {
uni.showToast({ title: res.msg + "。登录失败,请重新登录", icon: "error" });
uni.showToast({ title: res.msg + ",登录失败,请重新登录", icon: "error" });
return;
}
uni.setStorageSync(tokenKey, res.data);
const { data: userData } = await userApi.userInfo();
uni.setStorageSync(userInfoKey, userData);
// } catch (e) {
// console.log(222)
// console.log(e);
// }
uni.hideLoading();
uni.showToast({ title: "登录成功", icon: "none" });
router.back();
@@ -66,11 +65,9 @@ const doSubmit = async () => {
</tm-form-item>
</tm-form>
</view>
<view
v-if="state.detailType != 'view'"
<view v-if="state.detailType != 'view'"
class="bg-#0094ff p-y-20rpx text-center rounded-40rpx m-x-30rpx m-t-60rpx sub-text-30 color-white!"
@tap="doSubmit"
>
@tap="doSubmit">
登录
</view>
</crud-layout>
+6 -4
View File
@@ -7,6 +7,8 @@ import uqrcode from "@@/utils/uqrcode"
import { hooks, router } from "@@/index"
import { merchantApi, walletApi } from "@@/api"
import { filePath } from "@@/utils/file"
const state = reactive<any>({
showBindDialog: false,
showFreezeDialog: false,
@@ -35,7 +37,7 @@ onShow(() => {
})
const pageRef = ref<any>(null)
const pageHook = hooks.usePage(pageRef, walletApi.all, null, 'data')
const pageHook = hooks.usePage(pageRef, walletApi.all, null, 'data.records')
const query = (page: number, pagesize: number) => {
pageHook.startPage(page, pagesize, false, state.pa);
}
@@ -147,13 +149,13 @@ const doFreeze = async () => {
</view>
<view class="flex-row items-center justify-between m-t-10rpx">
<view class="flex-row items-center">
<image class="size-50rpx rounded-full" :src="v.walletIcon" mode="aspectFill" />
<image class="size-50rpx rounded-full" :src="filePath(v.walletIcon)" mode="aspectFill" />
<text class="m-l-25rpx sub-text-28">
{{ v.walletTypeStr }}
{{ v.walletTypeName }}
</text>
</view>
<view v-if="v.cardNumber">
<tm-tag v-if="v.checkFreezeStatus == 1" size="s" color="info">冻结审核中</tm-tag>
<tm-tag v-if="v.isFreeze" size="s" color="info">冻结审核中</tm-tag>
<slot v-else>
<tm-tag v-if="!v.isFreeze" size="s" color="success">正常</tm-tag>
<tm-tag v-else size="s" color="error">已冻结</tm-tag>
+1 -5
View File
@@ -76,10 +76,6 @@ const doPay = async () => {
channelCode: targetPayType.value,
channelExtras: {},
}
const { data: payData, code: payCode }: any = await payApi.submitOrder(_payPa)
if (payCode != 0) throw new Error()
state.currentPayType = 1
state.currentRecharge = -1
getDetail()
uni.hideLoading()
uni.showToast({ title: '充值成功', icon: "none" });
@@ -103,7 +99,7 @@ const doPay = async () => {
</view>
<view class="flex-row-center">
<view class="m-l-25rpx main-text-32 color-#fbddb0!">
{{ state.detail.walletTypeStr }}
{{ state.detail.walletTypeName }}
</view>
</view>
</view>
+2
View File
@@ -21,3 +21,5 @@ export { default as userApi } from "./user";
export { default as walletApi } from "./wallet";
export { default as faceApi } from "./face";
export { default as shopApi } from "./shop";
+2 -2
View File
@@ -3,7 +3,7 @@ import request from "@/sheep/utils/request";
export default {
page: (params: any) =>
request({
url: "/merchant/manage/page-join",
url: "/wallet/mch-manage/app/page-join",
method: "GET",
params,
custom: {
@@ -12,7 +12,7 @@ export default {
}),
detail: (params: any) =>
request({
url: "/merchant/manage/get",
url: "/wallet/mch-manage/app/detail",
method: "GET",
params,
custom: {
+2 -2
View File
@@ -3,7 +3,7 @@ import request from "@/sheep/utils/request";
export default {
page: (params: any) =>
request({
url: `/hardware/order/page-join`,
url: `/hard/hard-order/app/page-join`,
method: "GET",
params,
custom: {
@@ -12,7 +12,7 @@ export default {
}),
detail: (params: any) =>
request({
url: `/hardware/order/get-join`,
url: `/hard/hard-order/app/detail`,
method: "GET",
params,
custom: {
+49
View File
@@ -0,0 +1,49 @@
import request from "@/sheep/utils/request";
export default {
getSupermarketSpuList: (data: any) =>
request({
url: `/supermarket/supermarketSpu/ad/updateSpuStock`,
method: "POST",
data,
custom: {
showLoading: false,
},
}),
// del: (params: any) =>
// request({
// url: `/sys/user/face-delete`,
// method: "DELETE",
// params,
// custom: {
// showLoading: false,
// },
// }),
// create: (data: any) =>
// request({
// url: `/sys/user/face-create`,
// method: "POST",
// data,
// custom: {
// showLoading: false,
// },
// }),
// get: (params: any) =>
// request({
// url: `/sys/user/face-get`,
// method: "GET",
// params,
// custom: {
// showLoading: false,
// },
// }),
// put: (data: any) =>
// request({
// url: `/sys/user/face-update`,
// method: "PUT",
// data,
// custom: {
// showLoading: false,
// },
// }),
};
+16 -10
View File
@@ -1,8 +1,8 @@
import request from "@/sheep/utils/request";
import { encryptionBase64 } from "@/sheep/utils/util";
import { encryption } from "@/sheep/utils/encryption";
const basicAuth = "Basic " + encryptionBase64(import.meta.env.VITE_OAUTH2_APP_CLIENT);
const basicAuthzzdsh = "Basic " + encryptionBase64(import.meta.env.VITE_OAUTH2_ZZDSHAPP_CLIENT);
const basicAuth =
"Basic " + window.btoa(import.meta.env.VITE_OAUTH2_APP_CLIENT);
export default {
userInfo: () =>
@@ -44,17 +44,23 @@ export default {
},
}),
login: (params: any): any => {
params.scene = "account";
params.grant_type = "password";
params.scope = "server";
params.code = "";
request({
const { username, password, randomStr, code, grant_type, scope } = params;
const encPassword = encryption(password, import.meta.env.VITE_PWD_ENC_KEY);
return request({
url: `/auth/oauth2/token`,
method: "POST",
params,
params: {
username,
password: encPassword,
randomStr,
code,
grant_type,
scope,
},
data: { password: encPassword },
header: {
skipToken: true,
Authorization: basicAuth,
// Authorization: basicAuthzzdsh,
"content-type": "application/x-www-form-urlencoded",
},
custom: {
+5 -5
View File
@@ -3,7 +3,7 @@ import request from "@/sheep/utils/request";
export default {
all: () =>
request({
url: "pay/wallet/get-all",
url: "/wallet/wallet-manage/app/get-all",
method: "GET",
custom: {
showLoading: false,
@@ -20,7 +20,7 @@ export default {
}),
detail: (params: any) =>
request({
url: "pay/wallet/detail",
url: "wallet/wallet-manage/app/detail",
method: "GET",
params,
custom: {
@@ -56,7 +56,7 @@ export default {
}),
transaction: (params: any) =>
request({
url: "pay/wallet-transaction/page-by-id",
url: "wallet/wallet-transaction/page",
method: "GET",
params,
custom: {
@@ -74,7 +74,7 @@ export default {
}),
rechargeList: (params: any) =>
request({
url: "pay/wallet-recharge-package/list",
url: "wallet/wallet-recharge-package/app/list",
method: "GET",
params,
custom: {
@@ -83,7 +83,7 @@ export default {
}),
recharge: (data: any) =>
request({
url: "pay/wallet-recharge/create",
url: "wallet/wallet-recharge/app/create",
method: "POST",
data,
custom: {
+15
View File
@@ -0,0 +1,15 @@
import * as CryptoJS from "crypto-js";
/**
*加密处理
*/
export function encryption(src: string, keyWord: string) {
const key = CryptoJS.enc.Utf8.parse(keyWord);
// 加密
var encrypted = CryptoJS.AES.encrypt(src, key, {
iv: key,
mode: CryptoJS.mode.CFB,
padding: CryptoJS.pad.NoPadding,
});
return encrypted.toString();
}
+5
View File
@@ -0,0 +1,5 @@
export const filePath = (path?: string) => {
const imageBaseUrl = import.meta.env.VITE_IMAGE_BASE_PATH;
if (!path) return "";
return imageBaseUrl + path;
};
+40 -20
View File
@@ -30,15 +30,14 @@ function closeLoading() {
if (LoadingInstance.count > 0) LoadingInstance.count--;
if (LoadingInstance.count === 0) uni.hideLoading();
}
const http = new Request({
baseURL: __APP_SERVICE__,
baseURL: import.meta.env.VITE_API_URL,
timeout: 8000,
method: "GET",
header: {
Accept: "*/*",
"Content-Type": "application/json;charset=UTF-8",
Authorization: "",
"tenant-id": "",
},
withCredentials: true,
custom: options,
@@ -49,16 +48,19 @@ http.interceptors.request.use(
const tokenKey = constant.storageConstant.TOKEN;
const tokenStorage = uni.getStorageSync(tokenKey);
const config_header: any = config?.header;
// 添加终端类型
const isToc = import.meta.env.VITE_IS_TOC;
if (isToc === "true") {
config_header["CLIENT-TOC"] = "Y";
}
config_header["tenant-id"] = "1";
if (tokenStorage && tokenStorage.accessToken && config_header) {
config_header.Authorization = tokenStorage.accessToken;
config_header["TENANT-ID"] = "1";
if (
config.url != "/sys/auth/refresh-token" &&
tokenStorage &&
tokenStorage.access_token &&
config_header
) {
config_header.Authorization = `Bearer ${tokenStorage.access_token}`;
}
if (config.custom && config.custom.showLoading) {
LoadingInstance.count++;
@@ -80,9 +82,23 @@ http.interceptors.request.use(
http.interceptors.response.use(
async (response) => {
response.config && response.config.custom && response.config.custom.showLoading && closeLoading();
response.config &&
response.config.custom &&
response.config.custom.showLoading &&
closeLoading();
if (response.config.url === "/auth/oauth2/token") {
return Promise.resolve({
code: 0,
data: response.data,
msg: null,
});
}
if (response.data.code !== 0) {
if (response.config && response.config.custom && response.config.custom.showError) {
if (
response.config &&
response.config.custom &&
response.config.custom.showError
) {
switch (response.data.code) {
case 401:
setTimeout(() => {
@@ -118,16 +134,20 @@ http.interceptors.response.use(
}
const tokenKey = constant.storageConstant.TOKEN;
const tokenStorage = uni.getStorageSync(tokenKey);
if (!isEmpty(tokenStorage) && response.config.url != "/sys/auth/refresh-token") {
const { refreshToken, expiresTime } = tokenStorage;
const now = new Date().getTime();
const remain = expiresTime - now;
if (remain <= 1000 * 60 * 20) {
const _pa = { refreshToken: refreshToken };
const refreshData = await userApi.refreshToken(_pa);
console.log(refreshData, "refreshData");
if (!isEmpty(refreshData.data)) {
uni.setStorageSync(tokenKey, refreshData.data);
if (
!isEmpty(tokenStorage) &&
response.config.url != "/sys/auth/refresh-token"
) {
const { refresh_token, expiresTime } = tokenStorage;
if (!isEmpty(refresh_token) && !isEmpty(expiresTime)) {
const now = new Date().getTime();
const remain = expiresTime - now;
if (remain <= 1000 * 60 * 20) {
const _pa = { refreshToken: refresh_token };
const refreshData = await userApi.refreshToken(_pa);
if (!isEmpty(refreshData.data)) {
uni.setStorageSync(tokenKey, refreshData.data);
}
}
}
}
-203
View File
@@ -1,203 +0,0 @@
import { isObject } from "@vue/shared";
import * as CryptoJS from "crypto-js";
/**
* @description 获取元素节点信息(在组件中的元素必须要传ctx)
* @param { String } selector 选择器 '.app' | '#app'
* @param { Boolean } all 是否多选
* @param { ctx } context 当前组件实例
*/
export const getRect = (selector: string, all = false, context?: any) => {
return new Promise((resolve, reject) => {
let query = uni.createSelectorQuery();
if (context) {
query = uni.createSelectorQuery().in(context);
}
query[all ? "selectAll" : "select"](selector)
.boundingClientRect(function (rect) {
if (all && Array.isArray(rect) && rect.length) {
return resolve(rect);
}
if (!all && rect) {
return resolve(rect);
}
reject("找不到元素");
})
.exec();
});
};
/**
* @description 获取当前页面实例
*/
export function currentPage() {
const pages = getCurrentPages();
const currentPage = pages[pages.length - 1];
return currentPage || {};
}
/**
* @description 后台选择链接专用跳转
*/
interface Link {
path: string;
name?: string;
type: string;
isTab: boolean;
query?: Record<string, any>;
}
export enum LinkTypeEnum {
"SHOP_PAGES" = "shop",
"CUSTOM_LINK" = "custom",
}
export function navigateTo(link: Link, navigateType: "navigateTo" | "reLaunch" | "switchTab" = "navigateTo") {
const url = link.query ? `${link.path}?${objectToQuery(link.query)}` : link.path;
navigateType == "navigateTo" && uni.navigateTo({ url });
navigateType == "reLaunch" && uni.reLaunch({ url });
navigateType == "switchTab" && uni.switchTab({ url });
}
/**
* @description 是否为空
* @param {unknown} value
* @return {Boolean}
*/
export const isEmpty = (value: unknown) => {
return value == null && typeof value == "undefined";
};
/**
* @description 对象格式化为Query语法
* @param { Object } params
* @return {string} Query语法
*/
export function objectToQuery(params: Record<string, any>): string {
let query = "";
for (const props of Object.keys(params)) {
const value = params[props];
const part = encodeURIComponent(props) + "=";
if (!isEmpty(value)) {
console.log(encodeURIComponent(props), isObject(value));
if (isObject(value)) {
for (const key of Object.keys(value)) {
if (!isEmpty(value[key])) {
const params = props + "[" + key + "]";
const subPart = encodeURIComponent(params) + "=";
query += subPart + encodeURIComponent(value[key]) + "&";
}
}
} else {
query += part + encodeURIComponent(value) + "&";
}
}
}
return query.slice(0, -1);
}
/**
* @description 格式化输出价格
* @param { string } price 价格
* @param { string } take 小数点操作
* @param { string } prec 小数位补
*/
export function formatPrice({ price, take = "all", prec = undefined }: any) {
let [integer, decimals = ""] = (price + "").split(".");
// 小数位补
if (prec !== undefined) {
const LEN = decimals.length;
for (let i = prec - LEN; i > 0; --i) decimals += "0";
decimals = decimals.substr(0, prec);
}
switch (take) {
case "int":
return integer;
case "dec":
return decimals;
case "all":
return integer + "." + decimals;
}
}
/**
* @description 组合异步任务
* @param { string } task 异步任务
*/
export function series(...task: Array<(_arg: any) => any>) {
return function (): Promise<any> {
return new Promise((resolve, reject) => {
const iteratorTask = task.values();
const next = (res?: any) => {
const nextTask = iteratorTask.next();
if (nextTask.done) {
resolve(res);
} else {
Promise.resolve(nextTask.value(res)).then(next).catch(reject);
}
};
next();
});
};
}
/**
* @description 添加单位
* @param {String | Number} value 值 100
* @param {String} unit 单位 px em rem
*/
export const addUnit = (value: string | number, unit = "rpx") => {
return !Object.is(Number(value), NaN) ? `${value}${unit}` : value;
};
/**
* 自动适配不同的后端架构
* 1. 例如 /act/oa/task ,在微服务架构保持不变,在单体架构编程 /admin/oa/task
* 2. 特殊 /gen/xxx ,在微服务架构、单体架构编程 都需保持不变
*
* @param originUrl 原始路径
*/
export const adaptationUrl = (originUrl?: string) => {
// 微服务架构 不做路径转换,为空不做路径转换
const isMicro = import.meta.env.VITE_IS_MICRO;
if (isEmpty(isMicro) || isMicro === "true") {
return originUrl;
}
// 验证码服务
if (originUrl?.startsWith("/code/")) {
return `/admin${originUrl}`;
}
// 如果是代码生成服务,不做路径转换
if (originUrl?.startsWith("/gen")) {
return originUrl;
}
// 转为 /admin 路由前缀的请求
return `/admin/${originUrl?.split("/").splice(2).join("/")}`;
};
/**
*加密处理
*/
export function encryption(src: string, keyWord: string) {
const key = CryptoJS.enc.Utf8.parse(keyWord);
// 加密
const encrypted = CryptoJS.AES.encrypt(src, key, {
iv: key,
mode: CryptoJS.mode.CFB,
padding: CryptoJS.pad.NoPadding,
});
return encrypted.toString();
}
/**
*加密处理
*/
export function encryptionBase64(rawStr: string) {
let wordArray = CryptoJS.enc.Utf8.parse(rawStr);
return CryptoJS.enc.Base64.stringify(wordArray);
}
+16 -15
View File
@@ -5,11 +5,17 @@ import uni from "@dcloudio/vite-plugin-uni";
import Unocss from "unocss/vite";
import { useRouter } from "./src/sheep";
import { filePath } from "./src/sheep/utils/file-path";
export default defineConfig(({ mode }) => {
const { NODE_ENV, VITE_APP_DEV_SERVICE, VITE_APP_PROD_SERVICE } = loadEnv(mode, process.cwd(), "");
const baseUrl = NODE_ENV == "development" ? VITE_APP_DEV_SERVICE : VITE_APP_PROD_SERVICE;
const {
NODE_ENV,
VITE_APP_DEV_SERVICE,
VITE_APP_PROD_SERVICE,
VITE_IMAGE_BASE_PATH,
} = loadEnv(mode, process.cwd(), "");
const baseUrl =
NODE_ENV == "development" ? VITE_APP_DEV_SERVICE : VITE_APP_PROD_SERVICE;
return {
build: {
target: "es6",
@@ -32,23 +38,18 @@ export default defineConfig(({ mode }) => {
},
},
server: {
port: 8001,
hmr: true, // 启用热更新
host: "0.0.0.0",
port: 8888,
hmr: true,
proxy: {
"/api": {
target: baseUrl, // 目标服务器地址
changeOrigin: true, // 是否修改请求头中的 Origin 字段
target: baseUrl,
ws: true,
changeOrigin: true,
rewrite: (path) => path.replace(/^\/api/, ""),
},
"/mobile/api": {
target: baseUrl, // 目标服务器地址
changeOrigin: true, // 是否修改请求头中的 Origin 字段
rewrite: (path) => path.replace(/^\/mobile\/api/, ""),
},
},
},
define: {
__APP_SERVICE__: JSON.stringify(baseUrl),
},
define: {},
};
});