Files
gitlab-instance-0a899031_ka…/vue.config.js
2024-10-16 22:11:24 +08:00

71 lines
2.1 KiB
JavaScript

const { defineConfig } = require('@vue/cli-service')
// const Mock = require('mockjs');
module.exports = defineConfig({
transpileDependencies: true,
lintOnSave: false,
devServer: {
proxy: {
'/api': {
target: 'https://activityadminserver.dsx2020.com',
ws: true,
changeOrigin: true,
pathRewrite: {
'^/api': ''
}
},
}
}
// 可以继续添加其他 mock 接口
// devServer: {
// setupMiddlewares: (middlewares, devServer) => {
// // Mock 登录接口
// devServer.app.post('/api/login', (req, res) => {
// // 模拟的用户信息
// const userInfo = {
// username: 'dsx2016',
// password: '123456',
// };
// // 根据请求数据判断登录是否成功
// let body = '';
// req.on('data', chunk => {
// body += chunk.toString(); // 将请求体数据拼接
// });
// req.on('end', () => {
// const { username, password } = JSON.parse(body);
// if (username === userInfo.username && password === userInfo.password) {
// res.json({ code: 200, message: '登录成功', token: 'fake-token' });
// } else {
// res.json({ code: 401, message: '用户名或密码错误' });
// }
// });
// });
// // Mock 获取活动列表接口
// devServer.app.get('/api/activities', (req, res) => {
// const data = Mock.mock({
// code: 200,
// data: {
// 'list|10': [
// {
// 'id|+1': 1, // 自增的 id
// title: () => Mock.Random.ctitle(5, 10), // 随机中文标题
// description: () => Mock.Random.cparagraph(1, 3), // 随机中文段落
// date: () => Mock.Random.date(), // 随机日期
// },
// ],
// },
// });
// res.json(data);
// });
// // 其他 mock 接口可以继续添加
// return middlewares; // 返回中间件数组
// },
// },
})