feat: 添加环境配置文件,更新API基础地址
This commit is contained in:
7
.env.dev
Normal file
7
.env.dev
Normal file
@@ -0,0 +1,7 @@
|
||||
|
||||
# base api
|
||||
VUE_APP_BASE_API = 'http://127.0.0.1:3000/api'
|
||||
|
||||
|
||||
|
||||
|
||||
4
.env.prod
Normal file
4
.env.prod
Normal file
@@ -0,0 +1,4 @@
|
||||
|
||||
# base api
|
||||
VUE_APP_BASE_API = 'http://10.0.0.88:3000/api'
|
||||
|
||||
4
.env.test
Normal file
4
.env.test
Normal file
@@ -0,0 +1,4 @@
|
||||
|
||||
# base api
|
||||
VUE_APP_BASE_API = 'http://10.0.0.93:3000/api'
|
||||
|
||||
1
auto-imports.d.ts
vendored
1
auto-imports.d.ts
vendored
@@ -3,7 +3,6 @@
|
||||
// @ts-nocheck
|
||||
// noinspection JSUnusedGlobalSymbols
|
||||
// Generated by unplugin-auto-import
|
||||
// biome-ignore lint: disable
|
||||
export {}
|
||||
declare global {
|
||||
|
||||
|
||||
3
components.d.ts
vendored
3
components.d.ts
vendored
@@ -1,13 +1,12 @@
|
||||
/* eslint-disable */
|
||||
/* prettier-ignore */
|
||||
// @ts-nocheck
|
||||
// Generated by unplugin-vue-components
|
||||
// Read more: https://github.com/vuejs/core/pull/3399
|
||||
export {}
|
||||
|
||||
/* prettier-ignore */
|
||||
declare module 'vue' {
|
||||
export interface GlobalComponents {
|
||||
ElButton: typeof import('element-plus/es')['ElButton']
|
||||
Foot: typeof import('./src/components/Foot.vue')['default']
|
||||
Head: typeof import('./src/components/Head.vue')['default']
|
||||
RouterLink: typeof import('vue-router')['RouterLink']
|
||||
|
||||
11
index.html
11
index.html
@@ -1,16 +1,13 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<link rel="icon" href="/favicon.ico" />
|
||||
<meta
|
||||
name="viewport"
|
||||
content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=0"
|
||||
/>
|
||||
<title>东风猛士agv配置</title>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>Vite App</title>
|
||||
</head>
|
||||
<body>
|
||||
<div id="app"></div>
|
||||
<!-- <script type="module" src="/src/main.ts"></script> -->
|
||||
<script type="module" src="/src/main.ts"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
36
package.json
36
package.json
@@ -3,29 +3,33 @@
|
||||
"version": "0.0.0",
|
||||
"scripts": {
|
||||
"dev": "rsbuild dev",
|
||||
"build": "rsbuild build",
|
||||
"build:dev": "rsbuild build --env-mode dev",
|
||||
"build:test": "rsbuild build --env-mode test",
|
||||
"build:prod": "rsbuild build --env-mode prod",
|
||||
"preview": "rsbuild preview"
|
||||
},
|
||||
"dependencies": {
|
||||
"axios": "^1.7.8",
|
||||
"@element-plus/icons-vue": "^2.3.1",
|
||||
"axios": "^1.8.3",
|
||||
"dayjs": "^1.11.13",
|
||||
"element-plus": "^2.9.0",
|
||||
"element-plus": "^2.9.6",
|
||||
"file-saver": "^2.0.5",
|
||||
"normalize.css": "^8.0.1",
|
||||
"pinia": "^2.2.8",
|
||||
"qs": "^6.11.2",
|
||||
"pinia": "^3.0.1",
|
||||
"qs": "^6.14.0",
|
||||
"vue": "^3.5.13",
|
||||
"vue-router": "^4.5.0"
|
||||
"vue-router": "^4.5.0",
|
||||
"xlsx": "^0.18.5"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@rsbuild/core": "^1.1.7",
|
||||
"@rsbuild/plugin-sass": "^1.1.1",
|
||||
"@rsbuild/plugin-vue": "^1.0.5",
|
||||
"@types/node": "^18.17.1",
|
||||
"@vitejs/plugin-vue": "^5.2.1",
|
||||
"sass": "^1.81.1",
|
||||
"typescript": "^5.0.0",
|
||||
"unplugin-auto-import": "^0.18.6",
|
||||
"unplugin-vue-components": "^0.27.5",
|
||||
"vue-tsc": "^2.1.10"
|
||||
"@rsbuild/core": "^1.2.19",
|
||||
"@rsbuild/plugin-sass": "^1.2.2",
|
||||
"@rsbuild/plugin-vue": "^1.0.7",
|
||||
"@types/node": "^22.13.10",
|
||||
"sass": "^1.86.0",
|
||||
"typescript": "^5.8.2",
|
||||
"unplugin-auto-import": "^19.1.1",
|
||||
"unplugin-vue-components": "^28.4.1",
|
||||
"vue-tsc": "^2.2.8"
|
||||
}
|
||||
}
|
||||
2156
pnpm-lock.yaml
generated
2156
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
@@ -1,19 +1,34 @@
|
||||
import { defineConfig } from '@rsbuild/core'
|
||||
import { pluginVue } from '@rsbuild/plugin-vue'
|
||||
import { pluginSass } from '@rsbuild/plugin-sass'
|
||||
const path = require('path')
|
||||
export default defineConfig({
|
||||
plugins: [pluginVue(), pluginSass()],
|
||||
html: {
|
||||
template: './index.html'
|
||||
},
|
||||
// 设置mode
|
||||
|
||||
source: {
|
||||
entry: {
|
||||
index: './src/main.ts'
|
||||
},
|
||||
define: {
|
||||
'process.env.VUE_APP_BASE_API': JSON.stringify(
|
||||
process.env.VUE_APP_BASE_API
|
||||
)
|
||||
},
|
||||
alias: {
|
||||
'@': './src'
|
||||
'@': path.resolve(__dirname, 'src')
|
||||
}
|
||||
},
|
||||
|
||||
server: {
|
||||
proxy: {
|
||||
'/api': 'http://10.0.0.93:3000'
|
||||
}
|
||||
},
|
||||
|
||||
environments: {
|
||||
web: {
|
||||
source: {
|
||||
|
||||
@@ -12,23 +12,19 @@ import axios from 'axios' //引入 axios库
|
||||
import qs from 'qs' //引入 node中自带的qs模块(数据格式转换)
|
||||
/* 2.全局默认配置 */
|
||||
let baseURL
|
||||
let process: any = {
|
||||
env: {
|
||||
NODE_ENV: 'development'
|
||||
}
|
||||
}
|
||||
let process: any
|
||||
// 判断开发环境(一般用于本地代理)
|
||||
if (process.env.NODE_ENV === 'development') {
|
||||
// 开发环境
|
||||
baseURL = 'https://api.vvhan.com/' // 你设置的本地代理请求(跨域代理),下文会详细介绍怎么进行跨域代理
|
||||
baseURL = 'http://www.liulongbin.top:3006' // 你设置的本地代理请求(跨域代理),下文会详细介绍怎么进行跨域代理
|
||||
} else {
|
||||
// 编译环境
|
||||
if (process.env.type === 'test') {
|
||||
// 测试环境
|
||||
baseURL = 'https://api.vvhan.com/'
|
||||
baseURL = 'http://www.liulongbin.top:3006'
|
||||
} else {
|
||||
// 正式环境
|
||||
baseURL = 'https://api.vvhan.com/'
|
||||
baseURL = 'http://www.liulongbin.top:3006'
|
||||
}
|
||||
}
|
||||
// 配置axios的属性
|
||||
@@ -67,7 +63,6 @@ Axios.interceptors.request.use(
|
||||
return Promise.reject(error)
|
||||
}
|
||||
)
|
||||
|
||||
Axios.interceptors.response.use(
|
||||
(res) => {
|
||||
//请求响应后拦截
|
||||
|
||||
@@ -1,4 +1,12 @@
|
||||
// import path from 'node:path/win32'
|
||||
/*
|
||||
* @Description: {{ByRuin}}
|
||||
* @Version: 2.0
|
||||
* @Author: Ruin 🍭
|
||||
* @Date: 2022-01-25 16:57:54
|
||||
* @LastEditors: 刘引
|
||||
* @LastEditTime: 2022-03-11 14:26:24
|
||||
*/
|
||||
import path from 'node:path/win32'
|
||||
import { createRouter, createWebHashHistory } from 'vue-router'
|
||||
const routes = [
|
||||
{
|
||||
@@ -24,3 +32,4 @@ const router = createRouter({
|
||||
routes
|
||||
})
|
||||
export default router
|
||||
// 我感觉
|
||||
|
||||
@@ -1,26 +1,47 @@
|
||||
import Axios from '@/api/base-service' // 导入配置好的axios文件
|
||||
// 封装axios请求函数,并用export导出
|
||||
// get请求
|
||||
const getInfo = (params: unknown) => {
|
||||
return Axios({
|
||||
url: '/api/horoscope',
|
||||
method: 'get',
|
||||
headers: {
|
||||
'Content-Type': 'application/x-www-form-urlencoded' //设置请求头请求格式form
|
||||
},
|
||||
params
|
||||
})
|
||||
}
|
||||
/*
|
||||
* @Description: {{ByRuin}}
|
||||
* @Version: 2.0
|
||||
* @Author: Ruin 🍭
|
||||
* @Date: 2022-01-25 17:42:57
|
||||
* @LastEditors: 刘引
|
||||
* @LastEditTime: 2022-01-25 18:04:29
|
||||
*/
|
||||
|
||||
// post请求
|
||||
const getItem = (data: unknown) => {
|
||||
import Axios from "../api/base-service"; // 导入配置好的axios文件
|
||||
// 封装axios请求函数,并用export导出
|
||||
export function getInfo(datas: unknown) {
|
||||
return Axios({
|
||||
url: '/api/getItem',
|
||||
method: 'post',
|
||||
url: "/api.php?key=free&appid=0&msg=鹅鹅鹅",
|
||||
method: "GET",
|
||||
headers: {
|
||||
'Content-Type': 'application/json' //设置请求头请求格式为json
|
||||
"content-type": "application/json",
|
||||
},
|
||||
data
|
||||
})
|
||||
data: datas,
|
||||
});
|
||||
}
|
||||
export function getInfoA(datas: unknown) {
|
||||
return Axios({
|
||||
url: "/api/getbooks",
|
||||
method: "get",
|
||||
headers: {
|
||||
"Content-Type": "application/x-www-form-urlencoded", //设置请求头请求格式form
|
||||
},
|
||||
data: datas,
|
||||
});
|
||||
}
|
||||
export function getItem(datas: unknown) {
|
||||
return Axios({
|
||||
url: "/api/getItem",
|
||||
method: "post",
|
||||
headers: {
|
||||
"Content-Type": "application/json", //设置请求头请求格式为json
|
||||
},
|
||||
data: datas,
|
||||
});
|
||||
}
|
||||
export function getItemInfo(datas: unknown) {
|
||||
return Axios({
|
||||
url: "/api/getItemInfo" + datas,
|
||||
method: "get",
|
||||
});
|
||||
}
|
||||
export { getInfo, getItem }
|
||||
|
||||
13
src/utils/other.ts
Normal file
13
src/utils/other.ts
Normal file
@@ -0,0 +1,13 @@
|
||||
/*
|
||||
* @Description: {{ByRuin}}
|
||||
* @Version: 2.0
|
||||
* @Author: Ruin 🍭
|
||||
* @Date: 2022-01-25 17:45:05
|
||||
* @LastEditors: 刘引
|
||||
* @LastEditTime: 2022-01-25 17:47:27
|
||||
*/
|
||||
import axios from "axios";
|
||||
const otherApi = axios.create({
|
||||
baseURL: "http://baidu.com",
|
||||
});
|
||||
export default otherApi;
|
||||
13
src/utils/request/request.ts
Normal file
13
src/utils/request/request.ts
Normal file
@@ -0,0 +1,13 @@
|
||||
/*
|
||||
* @Description: {{ByRuin}}
|
||||
* @Version: 2.0
|
||||
* @Author: Ruin 🍭
|
||||
* @Date: 2022-01-25 17:36:26
|
||||
* @LastEditors: 刘引
|
||||
* @LastEditTime: 2022-01-25 17:46:39
|
||||
*/
|
||||
import axios from 'axios'
|
||||
const homeApi = axios.create({
|
||||
baseURL: 'http://baidu.com'
|
||||
})
|
||||
export default homeApi
|
||||
@@ -1,3 +1,11 @@
|
||||
<!--
|
||||
* @Description: {{ByRuin}}
|
||||
* @Version: 2.0
|
||||
* @Author: Ruin 🍭
|
||||
* @Date: 2022-03-10 10:11:06
|
||||
* @LastEditors: 刘引
|
||||
* @LastEditTime: 2022-07-26 14:42:06
|
||||
-->
|
||||
<template>
|
||||
<div class="root-home">
|
||||
<p>我是home组件</p>
|
||||
@@ -6,33 +14,9 @@
|
||||
</div>
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
import { computed, watch, onUpdated, ref, reactive, onBeforeMount } from 'vue'
|
||||
import { computed, watch, onUpdated, ref, reactive } from 'vue';
|
||||
import news from './components/news.vue'
|
||||
import { getInfo, getItem } from '@/services/home'
|
||||
|
||||
// get请求
|
||||
const getDataFromApi = async () => {
|
||||
try {
|
||||
const res = await getInfo({ type: 'scorpio', time: 'today' })
|
||||
console.debug(res, '获取到的数据')
|
||||
} catch (error) {
|
||||
console.error('get获取星座数据报错', error)
|
||||
}
|
||||
}
|
||||
|
||||
// post请求
|
||||
const postDataFromApi = async () => {
|
||||
try {
|
||||
} catch (error) {
|
||||
console.error('post获取数据报错', error)
|
||||
}
|
||||
}
|
||||
|
||||
// dom加载前调用
|
||||
onBeforeMount(() => {
|
||||
// getDataFromApi()
|
||||
// postDataFromApi()
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped></style>
|
||||
<style lang="scss" scoped>
|
||||
</style>
|
||||
@@ -1,15 +1,12 @@
|
||||
<template>
|
||||
<Head></Head>
|
||||
<div>根组件{{ store.count }}</div>
|
||||
<home></home>
|
||||
<Foot></Foot>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { reactive, onMounted, watch } from 'vue'
|
||||
import { useMain } from '@/store'
|
||||
import home from '@/views/home/index.vue'
|
||||
|
||||
const store = useMain()
|
||||
</script>
|
||||
|
||||
|
||||
@@ -1,3 +1,11 @@
|
||||
<!--
|
||||
* @Description: {{ByRuin}}
|
||||
* @Version: 2.0
|
||||
* @Author: Ruin 🍭
|
||||
* @Date: 2022-03-10 10:11:06
|
||||
* @LastEditors: 刘引 liu.yin.work@foxmail.com
|
||||
* @LastEditTime: 2023-08-01 15:45:57
|
||||
-->
|
||||
<template>
|
||||
<div class="root-home">
|
||||
<news></news>
|
||||
|
||||
Reference in New Issue
Block a user