chore:替换成远程api
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
# 接口前缀
|
||||
VITE_APP_BASEAPI="/api-dev"
|
||||
VITE_APP_URL="http://localhost:19001/api/app"
|
||||
VITE_APP_URL="http://123.207.63.87/api/app"
|
||||
VITE_APP_ENV_NAME = "dev"
|
||||
@@ -1,4 +1,4 @@
|
||||
# 接口前缀
|
||||
VITE_APP_BASEAPI="/prod-api"
|
||||
|
||||
VITE_APP_URL="http://123.207.63.87/api/app"
|
||||
VITE_APP_ENV_NAME = "production"
|
||||
@@ -6,7 +6,7 @@ const config = {
|
||||
// 开发环境接口前缀
|
||||
dev: import.meta.env.VITE_APP_BASEAPI,
|
||||
// 打包生产环境接口前缀
|
||||
pro: window.location.protocol + "//" + window.location.hostname + ":19001",
|
||||
pro: import.meta.env.VITE_APP_BASEAPI,
|
||||
},
|
||||
|
||||
/**
|
||||
|
||||
@@ -4,10 +4,11 @@ import { config } from "@/config/axios/config";
|
||||
import { Session } from "@/utils/storage";
|
||||
import useAuths from "@/hooks/useAuths";
|
||||
|
||||
const { VITE_APP_ENV_NAME } = import.meta.env;
|
||||
const { getToken } = useAuths();
|
||||
|
||||
const { request_timeout } = config;
|
||||
export const PATH_URL = import.meta.env.VITE_APP_BASEAPI;
|
||||
const { base_url, request_timeout, pre_interface } = config;
|
||||
export const PATH_URL = base_url[VITE_APP_ENV_NAME] + pre_interface;
|
||||
|
||||
// 配置新建一个 axios 实例
|
||||
const service = axios.create({
|
||||
|
||||
@@ -1,45 +1,41 @@
|
||||
import { fileURLToPath, URL } from 'node:url'
|
||||
import { fileURLToPath, URL } from "node:url";
|
||||
|
||||
import { defineConfig, loadEnv } from 'vite';
|
||||
import vue from '@vitejs/plugin-vue'
|
||||
import AutoImport from 'unplugin-auto-import/vite'
|
||||
import Components from 'unplugin-vue-components/vite'
|
||||
import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'
|
||||
import { defineConfig, loadEnv } from "vite";
|
||||
import vue from "@vitejs/plugin-vue";
|
||||
import AutoImport from "unplugin-auto-import/vite";
|
||||
import Components from "unplugin-vue-components/vite";
|
||||
import { ElementPlusResolver } from "unplugin-vue-components/resolvers";
|
||||
|
||||
var CopyWebpackPlugin = require('copy-webpack-plugin');
|
||||
var CopyWebpackPlugin = require("copy-webpack-plugin");
|
||||
/** @type {import('vite').UserConfig} */
|
||||
export default defineConfig(({ command, mode })=>{
|
||||
const env = loadEnv(mode, process.cwd(), '')
|
||||
return {
|
||||
// envDir: 'env',
|
||||
plugins: [
|
||||
vue(),
|
||||
AutoImport({
|
||||
resolvers: [ElementPlusResolver()],
|
||||
}),
|
||||
Components({
|
||||
resolvers: [ElementPlusResolver()],
|
||||
}),
|
||||
],
|
||||
resolve: {
|
||||
alias: {
|
||||
'@': fileURLToPath(new URL('./src', import.meta.url))
|
||||
}
|
||||
},
|
||||
server:{
|
||||
port:18001,
|
||||
open:true,
|
||||
proxy:{
|
||||
|
||||
[env.VITE_APP_BASEAPI]: {
|
||||
target: env.VITE_APP_URL,
|
||||
changeOrigin: true,
|
||||
rewrite: (path) => path.replace(/^\/api-dev/, ''),
|
||||
export default defineConfig(({ command, mode }) => {
|
||||
const env = loadEnv(mode, process.cwd(), "");
|
||||
return {
|
||||
// envDir: 'env',
|
||||
plugins: [
|
||||
vue(),
|
||||
AutoImport({
|
||||
resolvers: [ElementPlusResolver()],
|
||||
}),
|
||||
Components({
|
||||
resolvers: [ElementPlusResolver()],
|
||||
}),
|
||||
],
|
||||
resolve: {
|
||||
alias: {
|
||||
"@": fileURLToPath(new URL("./src", import.meta.url)),
|
||||
},
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
},
|
||||
server: {
|
||||
port: 18000,
|
||||
open: true,
|
||||
proxy: {
|
||||
[env.VITE_APP_BASEAPI]: {
|
||||
target: env.VITE_APP_URL,
|
||||
changeOrigin: true,
|
||||
rewrite: (path) => path.replace(/^\/api-dev/, ""),
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user