浏览代码

修改授权登录

ZaiZai 1 年之前
父节点
当前提交
779fa230ef
共有 2 个文件被更改,包括 13 次插入3 次删除
  1. 7 0
      src/store/index.js
  2. 6 3
      src/views/home/auth.vue

+ 7 - 0
src/store/index.js

@@ -42,6 +42,7 @@ export const useAppStore = defineStore('main', {
         isScreenShort: false,
         barMenuName: '',
         isSource: getStoreValue('isSource') || '', //来源
+        isLayout: getStoreValue('isLayout') || '', //是否显示layout
     }),
     getters: {
         //系统信息
@@ -77,6 +78,7 @@ export const useAppStore = defineStore('main', {
         getCollapse: state => state.isCollapse,
         getDragModalSortTop: state => state.dragModalSortTop,
         getIsSource: state => state.isSource,
+        getIsLayout: state => state.isLayout,
     },
     actions: {
         //系统信息
@@ -197,6 +199,10 @@ export const useAppStore = defineStore('main', {
             this.isSource = value
             setStoreValue('isSource', value)
         },
+        setIsLayout(value) {
+            this.isLayout = value
+            setStoreValue('isLayout', value)
+        },
         //清除缓存和token
         clearStoreData() {
             //清除状态
@@ -220,6 +226,7 @@ export const useAppStore = defineStore('main', {
             this.isCollapse = false
             this.dragModalSortTop = []
             this.isSource = ''
+            this.isLayout = ''
             //清除缓存
             clearStoreAll()
             removeToken()

+ 6 - 3
src/views/home/auth.vue

@@ -34,17 +34,20 @@ store.clearStoreData()
 //变量
 const loading = ref(true)
 const isErrorShow = ref(false)
+const toUrl = ref('/home/index')
 
 //渲染完成
 onMounted(() => {
-    // http://质检的域名/#/auth-token?token=xxx&tid=xxx&pid=xxx&cid=xxx
-    const { token, tid, pid, cid } = getObjValue(useRoutes.query)
+    // http://质检的域名/#/auth-token?token=xxx&tid=xxx&pid=xxx&cid=xxx&layout=no&url=xxx
+    const { token, tid, pid, cid, layout, url } = getObjValue(useRoutes.query)
     if (!isNullES(token)) {
         isErrorShow.value = false
+        toUrl.value = url ?? '/home/index'
         //缓存数据
         store.setTokenVal(token)
         store.setProjectId(pid)
         store.setContractId(cid)
+        store.setIsLayout(layout)
         //处理授权登录
         setLoginByTokenData(token, tid)
     } else {
@@ -77,7 +80,7 @@ const loginByTokenApi = async (form) => {
             loading.value = false
             isErrorShow.value = false
             window?.$message?.success('授权登录成功')
-            router.push({ path: '/home/index' })
+            router.push({ path: toUrl.value })
         }, 1500)
     } else {
         window.$message?.error('授权登录失败')