From b86ea914a3f5b3160bdabe12b8772f28bb692a85 Mon Sep 17 00:00:00 2001 From: Apcallover <1503963513@qq.com> Date: Mon, 15 Apr 2024 18:01:50 +0800 Subject: [PATCH] flat: tiket --- src/api/user.js | 5 +++-- src/page/login/userlogin.vue | 27 +++++++++++++++++++-------- src/store/modules/user.js | 3 ++- vue.config.js | 2 +- 4 files changed, 25 insertions(+), 12 deletions(-) diff --git a/src/api/user.js b/src/api/user.js index 4984ff8..c3d429d 100644 --- a/src/api/user.js +++ b/src/api/user.js @@ -1,7 +1,7 @@ import website from '@/config/website'; import request from '@/router/axios'; -export const loginByUsername = (username, password, type, key, code, loginType) => +export const loginByUsername = (username, password, type, key, code, loginType, ticket) => request({ url: '/api/jobslink-auth/oauth/token', method: 'post', @@ -15,7 +15,8 @@ export const loginByUsername = (username, password, type, key, code, loginType) password, grant_type: (website.captchaMode ? 'captcha' : 'password'), scope: 'all', - type + type, + ticket } }); diff --git a/src/page/login/userlogin.vue b/src/page/login/userlogin.vue index dce0296..37ee3d8 100644 --- a/src/page/login/userlogin.vue +++ b/src/page/login/userlogin.vue @@ -54,7 +54,7 @@ import { mapGetters } from "vuex"; import topLang from "@/page/index/top/top-lang"; // import { info } from "@/api/system/tenant"; import { getCaptcha } from "@/api/user"; -if (/(\/login\b)(\?.*)(\&.*)/ig.test(location.href)) { +if (/(\/login\?)(.*)/ig.test(location.href)) { const obj = {} const query = location.href.split('?')[1].replace(/\?/, '').split('&') query.forEach((item) => { const a = item.split('='); obj[a[0]] = a[1]}) @@ -100,6 +100,7 @@ export default { passwordType: "password", proLoading: false, loading: null, + ticket: '' }; }, watch: { @@ -107,12 +108,12 @@ export default { }, created () { // this.getTenant(); - const { username, password } = JSON.parse(window.sessionStorage.getItem('query_session') || "{}") + const { ticket } = JSON.parse(window.sessionStorage.getItem('query_session') || "{}") window.sessionStorage.removeItem('query_session') - if(username && password) { + console.log(ticket) + if(ticket) { this.proLoading = true - this.loginForm.username = username - this.loginForm.password = password + this.ticket = ticket this.handleLogin() } else { console.log('刷新1') @@ -143,7 +144,13 @@ export default { }, handleLogin () { if(this.proLoading) { - this.ByUsernameCallback() + let params = { + ...this.loginForm, + username: "admin", + password: "admin", + ticket: this.ticket + } + this.ByUsernameCallback(params) return } this.$refs.loginForm.validate(valid => { @@ -152,13 +159,17 @@ export default { } }); }, - ByUsernameCallback() { + ByUsernameCallback(params) { const loading = this.$loading({ lock: true, text: '登录中,请稍后。。。', spinner: "el-icon-loading" }); - this.$store.dispatch("LoginByUsername", this.loginForm).then(() => { + let obj = this.loginForm + if(params) { + obj = params + } + this.$store.dispatch("LoginByUsername", obj).then(() => { this.$store.dispatch('jlHelpShow', false) this.$router.push({ path: this.tagWel.value }); loading.close(); diff --git a/src/store/modules/user.js b/src/store/modules/user.js index f7bbd54..11ed84a 100644 --- a/src/store/modules/user.js +++ b/src/store/modules/user.js @@ -65,7 +65,8 @@ const user = { userInfo.type, userInfo.key, userInfo.code, - userInfo.loginType + userInfo.loginType, + userInfo.ticket ) .then((res) => { const data = res.data; diff --git a/vue.config.js b/vue.config.js index 90ff354..daacde0 100644 --- a/vue.config.js +++ b/vue.config.js @@ -23,7 +23,7 @@ module.exports = { port: 1888, proxy: { "/api": { - target: 'http://localhost:8000', + target: 'http://10.165.0.173:8000', ws: true, changeOrigin: true, pathRewrite: {