diff --git a/.env b/.env index 43bab3c..bd71af8 100644 --- a/.env +++ b/.env @@ -2,4 +2,7 @@ VITE_PWD_ENC_KEY='thanks,rax4cloud' VITE_OAUTH2_PASSWORD_CLIENT='rax:rax' +# OAUTH2 短信客户端信息 +VITE_OAUTH2_MOBILE_CLIENT='app:app' + VITE_RAX_BASE_URL='/api' \ No newline at end of file diff --git a/src/api/login-phone.ts b/src/api/login-phone.ts new file mode 100644 index 0000000..ff791b1 --- /dev/null +++ b/src/api/login-phone.ts @@ -0,0 +1,31 @@ +import request from '@/utils/request'; +import {Session} from "@/utils/storage"; + +const FORM_CONTENT_TYPE = 'application/x-www-form-urlencoded'; + +export const sendMobileCode = (mobile: any) => { + return request({ + url: '/admin/mobile/' + mobile, + method: 'get', + }); +}; + + +export const loginByMobile = (mobile: any, code: any) => { + + const grant_type = 'mobile'; + const scope = 'server'; + const basicAuth = 'Basic ' + window.btoa(import.meta.env.VITE_OAUTH2_MOBILE_CLIENT); + Session.set('basicAuth', basicAuth); + + return request({ + url: '/admin/oauth2/token', + headers: { + skipToken: true, + Authorization: basicAuth, + 'Content-Type': FORM_CONTENT_TYPE, + }, + method: 'post', + data: {mobile: mobile, code: code, grant_type, scope}, + }); +}; \ No newline at end of file diff --git a/src/router/routes.ts b/src/router/routes.ts index 100e703..0b89ed7 100644 --- a/src/router/routes.ts +++ b/src/router/routes.ts @@ -58,10 +58,10 @@ export const constantRoute = [ ] }, { - path: '/remote-manage', + path: '/remote-manage/remote-manage', name: '远程管理', component: () => import('@/views/remote-manage/index.vue'), - redirect: '/remote-manage/remote-manage', + // redirect: '/remote-manage/remote-manage', children: [ { path: '/remote-manage/remote-manage', diff --git a/src/views/login/login.vue b/src/views/login/login.vue index d5d274c..8334258 100644 --- a/src/views/login/login.vue +++ b/src/views/login/login.vue @@ -1,133 +1,133 @@ diff --git a/vite.config.ts b/vite.config.ts index aae3ad1..f14a5b9 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -24,16 +24,16 @@ export default defineConfig({ proxy: { '/api': { // target: 'http://localhost:9999', // 目标服务器地址 - // target: 'http://localhost:6379', // 目标服务器地址 - target: 'http://110.41.142.124:6379', // 目标服务器地址 + target: 'http://localhost:6379', // 目标服务器地址 + // target: 'http://110.41.142.124:6379', // 目标服务器地址 ws: true, // 是否启用 WebSocket changeOrigin: true, // 是否修改请求头中的 Origin 字段 rewrite: (path) => path.replace(/^\/api/, ''), }, '/socket.io': { // target: 'ws://localhost:9999', - // target: 'ws://localhost:6379', - target: 'ws://110.41.142.124:6379', + target: 'ws://localhost:6379', + // target: 'ws://110.41.142.124:6379', ws: true, changeOrigin: true, rewrite: (path) => path.replace(/^\/socket.io/, ''),