diff --git a/.env.development b/.env.development new file mode 100644 index 0000000..6ea6a53 --- /dev/null +++ b/.env.development @@ -0,0 +1,2 @@ +VITE_API=/api +VITE_API_MT=/mt \ No newline at end of file diff --git a/.env.production b/.env.production new file mode 100644 index 0000000..f86a420 --- /dev/null +++ b/.env.production @@ -0,0 +1,2 @@ +VITE_API=http://123.56.226.179:3000 +VITE_API_MT=http://mt.myalger.top \ No newline at end of file diff --git a/index.html b/index.html index b148bed..5bc960a 100644 --- a/index.html +++ b/index.html @@ -4,7 +4,7 @@ - Vite App + 网抑云 | algerkong { const value = 'Drive My Car' const options = [ { - label: 'Girl', - key: 'Girl' + label: '打卡', + key: 'card' }, { - label: 'login', + label: '听歌升级', + key: 'card_music' + }, + { + label: '歌曲次数', + key: 'listen' + }, + { + label: '登录', key: 'login' }, { @@ -110,9 +119,27 @@ const options = [ } ] -const selectItem = (key: any) => { +const selectItem = async (key: any) => { // switch 判断 switch (key) { + case 'card': + await request.get('/?do=sign') + .then(res => { + console.log(res) + }) + break; + case 'card_music': + await request.get('/?do=daka') + .then(res => { + console.log(res) + }) + break; + case 'listen': + await request.get('/?do=listen&id=1885175990&time=300') + .then(res => { + console.log(res) + }) + break; case 'logout': logout().then(() => { store.state.user = null diff --git a/src/utils/request.ts b/src/utils/request.ts index 80d3e58..d1c0bee 100644 --- a/src/utils/request.ts +++ b/src/utils/request.ts @@ -1,7 +1,8 @@ import axios from "axios"; +let baseURL = import.meta.env.VITE_API + ""; const request = axios.create({ - baseURL: "http://123.56.226.179:3000", + baseURL: baseURL, timeout: 10000, }); diff --git a/src/utils/request_mt.ts b/src/utils/request_mt.ts new file mode 100644 index 0000000..e1c7a4b --- /dev/null +++ b/src/utils/request_mt.ts @@ -0,0 +1,19 @@ +import axios from "axios"; +let baseURL = import.meta.env.VITE_API_MT + ""; +const request = axios.create({ + baseURL: baseURL, + timeout: 10000, +}); + +// 请求拦截器 +request.interceptors.request.use( + (config) => { + return config; + }, + (error) => { + // 当请求异常时做一些处理 + return Promise.reject(error); + } +); + +export default request; diff --git a/src/views/user/index.vue b/src/views/user/index.vue index a3b278b..245448e 100644 --- a/src/views/user/index.vue +++ b/src/views/user/index.vue @@ -69,9 +69,9 @@ loadPage() - + diff --git a/vite.config.ts b/vite.config.ts index ead71bb..7fa9fa9 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -10,4 +10,21 @@ export default defineConfig({ "@": path.resolve(__dirname, "src"), }, }, + server: { + host: "0.0.0.0", //允许本机 + proxy: { + // string shorthand + "/mt": { + target: "http://mt.myalger.top", + changeOrigin: true, + rewrite: (path) => path.replace(/^\/mt/, ""), + }, + // with options + "/api": { + target: "http://123.56.226.179:3000", + changeOrigin: true, + rewrite: (path) => path.replace(/^\/api/, ""), + }, + }, + }, });