From 4693af2e8f6d9eb9bd7c6bcf30046e8af4acba24 Mon Sep 17 00:00:00 2001 From: aaron <> Date: Fri, 28 Feb 2025 23:01:43 +0800 Subject: [PATCH] update --- .env.development | 1 + .env.production | 1 + public/index.html | 1 + src/App.vue | 60 +++- src/components/CommunityRequest.vue | 76 ++++- src/components/PartnerRequest.vue | 506 ++++++++++++++++++++++++++++ src/main.js | 8 +- src/router/index.js | 9 + src/services/api.js | 52 +++ 9 files changed, 695 insertions(+), 19 deletions(-) create mode 100644 .env.development create mode 100644 .env.production create mode 100644 public/index.html create mode 100644 src/components/PartnerRequest.vue create mode 100644 src/services/api.js diff --git a/.env.development b/.env.development new file mode 100644 index 0000000..abe8cfc --- /dev/null +++ b/.env.development @@ -0,0 +1 @@ +VUE_APP_ENV=dev \ No newline at end of file diff --git a/.env.production b/.env.production new file mode 100644 index 0000000..9be2c39 --- /dev/null +++ b/.env.production @@ -0,0 +1 @@ +VUE_APP_ENV=prd \ No newline at end of file diff --git a/public/index.html b/public/index.html new file mode 100644 index 0000000..0fc3a1f --- /dev/null +++ b/public/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/App.vue b/src/App.vue index d48fef5..c91fdc4 100644 --- a/src/App.vue +++ b/src/App.vue @@ -1,8 +1,60 @@ - \ No newline at end of file + + + \ No newline at end of file diff --git a/src/components/CommunityRequest.vue b/src/components/CommunityRequest.vue index b9db782..4e2b3e0 100644 --- a/src/components/CommunityRequest.vue +++ b/src/components/CommunityRequest.vue @@ -1,5 +1,5 @@ + + \ No newline at end of file diff --git a/src/main.js b/src/main.js index 044a83a..45ca2d9 100644 --- a/src/main.js +++ b/src/main.js @@ -1,6 +1,12 @@ import { createApp } from 'vue' import App from './App.vue' import router from './router' +import axios from 'axios' import './assets/main.css' -createApp(App).use(router).mount('#app') \ No newline at end of file +// 配置 axios 默认值 +axios.defaults.baseURL = 'https://api-dev.beefast.co' + +const app = createApp(App) +app.use(router) +app.mount('#app') \ No newline at end of file diff --git a/src/router/index.js b/src/router/index.js index 3bfe979..15e38a9 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -5,6 +5,7 @@ import UserAgreement from '../components/UserAgreement.vue' import Dashboard from '../components/Dashboard.vue' import HowToUse from '../components/HowToUse.vue' import CommunityRequest from '../components/CommunityRequest.vue' +import PartnerRequest from '../components/PartnerRequest.vue' const routes = [ { @@ -45,6 +46,14 @@ const routes = [ meta: { title: '小区开通申请' } + }, + { + path: '/partner-request', + name: 'PartnerRequest', + component: PartnerRequest, + meta: { + title: '合伙人申请' + } } ] diff --git a/src/services/api.js b/src/services/api.js new file mode 100644 index 0000000..c2c5ce3 --- /dev/null +++ b/src/services/api.js @@ -0,0 +1,52 @@ +import axios from 'axios' + +// 根据环境变量确定基础URL +const getBaseURL = () => { + const appEnv = import.meta.env.VITE_APP_ENV || 'local' + + switch (appEnv) { + case 'dev': + return 'https://api-dev.beefast.co' + case 'prd': + return 'https://api.beefast.ci' + default: + return 'http://localhost:8000' + } +} + +// 创建 axios 实例 +const apiClient = axios.create({ + baseURL: getBaseURL(), + timeout: 10000, // 请求超时时间 + headers: { + 'Content-Type': 'application/json' + } +}) + +// 请求拦截器 +apiClient.interceptors.request.use( + config => { + // 在发送请求之前做些什么 + console.log(`API请求到: ${config.baseURL}${config.url}`) + return config + }, + error => { + // 对请求错误做些什么 + return Promise.reject(error) + } +) + +// 响应拦截器 +apiClient.interceptors.response.use( + response => { + // 对响应数据做点什么 + return response + }, + error => { + // 对响应错误做点什么 + console.error('API请求错误:', error) + return Promise.reject(error) + } +) + +export default apiClient \ No newline at end of file