Эх сурвалжийг харах

Merge branch 'pre' of http://git.bjzxtw.org.cn:3000/zxt/admin_home into pre

CaoGQ123 4 өдөр өмнө
parent
commit
52a2fb66f2

BIN
dist.zip


+ 27 - 4
src/permission.js

@@ -3,10 +3,10 @@ import store from './store'
 import { Message } from 'element-ui'
 import NProgress from 'nprogress' // progress bar
 import 'nprogress/nprogress.css' // progress bar style
-import { getToken,setUserUrl } from '@/utils/auth' // get token from cookie
+import { getToken,setUserUrl, setUseType,setWebSiteId,hashParams} from '@/utils/auth' // get token from cookie
 import getPageTitle from '@/utils/get-page-title'
 import URL from '@/utils/baseUrl';
-
+import {getInfo} from '@/api/user'
 NProgress.configure({ showSpinner: false }) // NProgress Configuration
 
 const whiteList = ['/login', '/auth-redirect'] // no redirect whitelist
@@ -25,9 +25,28 @@ router.beforeEach(async(to, from, next) => {
 
   if (hasToken) {
     if (to.path === '/login') {
+      
+      // Retrieve userurl
+      const userurl = hashParams();
+      if(userurl){
+        setUserUrl(userurl, 86400) 
+      }
+  
+      const userInfo = await getInfo();
+      console.log("User Info:", userInfo);
+      if (userInfo.code === 200) {
+        console.log("####")
+        setUseType(userInfo.data.userType, 86400)
+        setWebSiteId(userInfo.data.siteId, 86400)
+        next({ path: '/' })
+        NProgress.done() // hack: https://github.com/PanJiaChen/vue-element-admin/pull/2939
+      }else{
+        next({ path: '/' })
+        NProgress.done() // hack: https://github.com/PanJiaChen/vue-element-admin/pull/2939
+      }
       // if is logged in, redirect to the home page
-      next({ path: '/' })
-      NProgress.done() // hack: https://github.com/PanJiaChen/vue-element-admin/pull/2939
+
+    
     } else {
       // determine whether the user has obtained his permission roles through getInfo
       const hasRoles = store.getters.roles && store.getters.roles.length > 0
@@ -48,6 +67,10 @@ router.beforeEach(async(to, from, next) => {
           // hack method to ensure that addRoutes is complete
           // set the replace: true, so the navigation will not leave a history record
           next({ ...to, replace: true })
+
+          // Call getInfo to fetch user information
+          const userInfo = await getInfo();
+          console.log("User Info:", userInfo);
         } catch (error) {
           // remove token and go to login page to re-login
           await store.dispatch('user/resetToken')

+ 17 - 0
src/utils/auth.js

@@ -86,4 +86,21 @@ function convertSecondsToDays(seconds) {
   return seconds/(60*60*24); //1天=60秒*60分钟*24小时
 }
 
+// Function to parse hash parameters from the URL
+export function hashParams() {
+  const urlString = window.location.href;
+  const url = new URL(urlString);
+  const hash = url.hash;
+  const hashParams = new URLSearchParams(hash.split('?')[1]);
+  const userurl = hashParams.get('userurl');
+
+  if (userurl) {
+    // Create a URL object to extract the domain
+    const userUrlObject = new URL(userurl);
+    return userUrlObject.hostname; // Return only the domain
+  }
+
+  return null; // Return null if userurl is not present
+}
+
 

+ 1 - 0
src/utils/baseUrl.js

@@ -5,6 +5,7 @@ const URL = {
   //baseUrl: 'http://admindev.bjzxtw.org.cn:9501',//测试域名
   //baseUrl: 'http://116.131.8.26:9501',//pre环境ip
   //baseUrl: 'http://adminpre.bjzxtw.org.cn:9501',//pre环境域名
+
   webUrl: 'adminpre.bjzxtw.org.cn',//管理系统地址,如果用户因为某种原因以外退出,需要一个userurl用于请求接口
   baseUrl: 'http://apipre1.bjzxtw.org.cn:29501',//pre环境域名2
   // baseUrl: 'http://192.168.1.201:9501',//刘佳伟本地环境

+ 2 - 1
src/views/website/blackWordList.vue

@@ -31,7 +31,8 @@
                         </el-table-column>
                         <el-table-column prop="created_at" label="创建时间">
                         </el-table-column>
-                    
+                        <el-table-column prop="updated_at" label="修改时间">
+                        </el-table-column>
                         <el-table-column fixed="right" header-align="center" label="操作" width="220">
                             <template slot-scope="scope">
                                 <div class="listBtnBox">