From 5b4761d9396d64e61a970a7e57bf53f7881f6a22 Mon Sep 17 00:00:00 2001 From: chyan <1251513674@qq.com> Date: Tue, 20 Jun 2023 11:00:36 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E5=88=9B=E5=BB=BAapi?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/login.js | 0 src/axios/index.js | 0 vite.config.js | 0 3 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 src/api/login.js create mode 100644 src/axios/index.js create mode 100644 vite.config.js diff --git a/src/api/login.js b/src/api/login.js new file mode 100644 index 0000000..e69de29 diff --git a/src/axios/index.js b/src/axios/index.js new file mode 100644 index 0000000..e69de29 diff --git a/vite.config.js b/vite.config.js new file mode 100644 index 0000000..e69de29 -- Gitee From 5965fae5779068e2d848c654d36e54d5e967d072 Mon Sep 17 00:00:00 2001 From: chyan <1251513674@qq.com> Date: Tue, 20 Jun 2023 11:00:55 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E5=88=9B=E5=BB=BAapi?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/login.js | 13 +++++++++++++ src/axios/index.js | 9 +++++++++ vite.config.js | 21 +++++++++++++++++++++ 3 files changed, 43 insertions(+) diff --git a/src/api/login.js b/src/api/login.js index e69de29..376c0dc 100644 --- a/src/api/login.js +++ b/src/api/login.js @@ -0,0 +1,13 @@ +import request from '../axios/index'; + +/* + * 描述:用户登录 + * 参数data: object {username: '用户名', password: '密码'} + */ +export function login(data) { + return request({ + method: 'post', + url: '/login', + data: data + }); +} \ No newline at end of file diff --git a/src/axios/index.js b/src/axios/index.js index e69de29..03f0e72 100644 --- a/src/axios/index.js +++ b/src/axios/index.js @@ -0,0 +1,9 @@ +import axios from 'axios'; + +const instance = axios.create({ + baseURL: 'http://127.0.0.1:5173/dev-api', + withCredentials: true, + timeout: 10 * 1000 +}); + +export default instance; \ No newline at end of file diff --git a/vite.config.js b/vite.config.js index e69de29..c44e0b8 100644 --- a/vite.config.js +++ b/vite.config.js @@ -0,0 +1,21 @@ + +import { defineConfig } from 'vite' +import vue from '@vitejs/plugin-vue' + +// https://vitejs.dev/config/ +export default defineConfig({ + plugins: [vue()], + server: { + hmr: true, //是否开启热更新 + https: false, //是否开启 https + open: true, //是否开启本地跨域代理 + proxy: { + ['/dev-api']: { + target: 'http://127.0.0.1:7001', //后端请求地址 + ws: false, + changeOrigin: true, + rewrite: (path) => path.replace(new RegExp(`^/dev-api`), '') + } + } + } +}) -- Gitee