From fb69937cc5ca45dab3412636fdecdaf063156147 Mon Sep 17 00:00:00 2001 From: zouyu <2723363702@qq.com> Date: 星期三, 13 八月 2025 16:57:50 +0800 Subject: [PATCH] 浪潮平台对接单点登录3 --- src/views/tideLogin.vue | 26 +++++++++----------------- src/store/modules/user.js | 4 ++-- 2 files changed, 11 insertions(+), 19 deletions(-) diff --git a/src/store/modules/user.js b/src/store/modules/user.js index 1c0d1d2..d52efa6 100644 --- a/src/store/modules/user.js +++ b/src/store/modules/user.js @@ -109,12 +109,12 @@ }) }) }, - TideLogin({ commit }, code) { + TideLogin(code) { return new Promise((resolve, reject) => { tideLogin(code) .then((res) => { setToken(res.token); - commit("SET_TOKEN", res.token); + this.token = res.token Vue.prototype.uploadHeader = { Authorization: "Bearer " + res.token, }; diff --git a/src/views/tideLogin.vue b/src/views/tideLogin.vue index a96165e..e4a82f7 100644 --- a/src/views/tideLogin.vue +++ b/src/views/tideLogin.vue @@ -1,23 +1,15 @@ <template> <div></div> </template> -<script> -import store from "@/store"; -export default { - data() { - return {} - }, - created() { - this.goLogin() - }, - computed: {}, - methods: { - goLogin() { - store.dispatch('TideLogin', {code : this.$route.query.code}).then(() => { - this.$router.push({ path: this.redirect || "/" }).catch(() => { }); - }) - } - } +<script setup> +import useUserStore from '@/store/modules/user' +const userStore = useUserStore() +let { proxy } = getCurrentInstance() +function goLogin() { + userStore.TideLogin({code : proxy.$route.query.code}).then(() => { + proxy.$router.push({ path: redirect || "/" }).catch(() => { }); + }) } +goLogin() </script> <style scoped></style> -- Gitblit v1.9.3