mirror of
https://codeup.aliyun.com/67762337eccfc218f6110e0e/vue/fe-manage.git
synced 2025-12-11 11:56:46 +08:00
feat:增加获取用户信息以及token失效跳到登录页
This commit is contained in:
@@ -89,6 +89,7 @@ export default defineComponent({
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
orgTree();
|
orgTree();
|
||||||
|
|
||||||
return {
|
return {
|
||||||
routes,
|
routes,
|
||||||
name: currentRouteName,
|
name: currentRouteName,
|
||||||
|
|||||||
@@ -2,11 +2,12 @@
|
|||||||
* @Author: lixg lixg@dongwu-inc.com
|
* @Author: lixg lixg@dongwu-inc.com
|
||||||
* @Date: 2022-11-21 14:32:52
|
* @Date: 2022-11-21 14:32:52
|
||||||
* @LastEditors: lixg lixg@dongwu-inc.com
|
* @LastEditors: lixg lixg@dongwu-inc.com
|
||||||
* @LastEditTime: 2022-11-23 09:59:26
|
* @LastEditTime: 2022-11-25 15:05:34
|
||||||
* @FilePath: /fe-manage/src/api/config.js
|
* @FilePath: /fe-manage/src/api/config.js
|
||||||
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
|
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
|
||||||
*/
|
*/
|
||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
|
// import { getCookie } from '../api/method'
|
||||||
// const Qs = require("qs");
|
// const Qs = require("qs");
|
||||||
|
|
||||||
// axios.defaults.headers.post["Content-Type"] =
|
// axios.defaults.headers.post["Content-Type"] =
|
||||||
@@ -24,8 +25,9 @@ const http = axios.create({
|
|||||||
http.interceptors.request.use(
|
http.interceptors.request.use(
|
||||||
(config) => {
|
(config) => {
|
||||||
const token = localStorage.getItem("token");
|
const token = localStorage.getItem("token");
|
||||||
|
// const token = getCookie('token')
|
||||||
|
// console.log('token', token)
|
||||||
if (token) {
|
if (token) {
|
||||||
// config.headers.token = token;
|
|
||||||
config.headers.token = token; //测试1111
|
config.headers.token = token; //测试1111
|
||||||
} else {
|
} else {
|
||||||
console.log("当前请求页面无token,请执行操作!!!");
|
console.log("当前请求页面无token,请执行操作!!!");
|
||||||
@@ -44,12 +46,15 @@ http.interceptors.request.use(
|
|||||||
|
|
||||||
http.interceptors.response.use(
|
http.interceptors.response.use(
|
||||||
(response) => {
|
(response) => {
|
||||||
|
// console.log('response', response)
|
||||||
const {
|
const {
|
||||||
data: { code, msg },
|
data: { code, msg },
|
||||||
} = response;
|
} = response;
|
||||||
|
// console.log('code', code)
|
||||||
if (code === 0 || code === 200) {
|
if (code === 0 || code === 200) {
|
||||||
return response;
|
return response;
|
||||||
} else {
|
} else {
|
||||||
|
// window.open("https://u-pre.boe.com/web/", '_self');
|
||||||
console.log("api %o", msg);
|
console.log("api %o", msg);
|
||||||
}
|
}
|
||||||
return response;
|
return response;
|
||||||
|
|||||||
@@ -2,13 +2,13 @@
|
|||||||
* @Author: lixg lixg@dongwu-inc.com
|
* @Author: lixg lixg@dongwu-inc.com
|
||||||
* @Date: 2022-11-04 22:45:31
|
* @Date: 2022-11-04 22:45:31
|
||||||
* @LastEditors: lixg lixg@dongwu-inc.com
|
* @LastEditors: lixg lixg@dongwu-inc.com
|
||||||
* @LastEditTime: 2022-11-24 15:11:25
|
* @LastEditTime: 2022-11-25 14:56:59
|
||||||
* @FilePath: /fe-manage/src/api/index1.js
|
* @FilePath: /fe-manage/src/api/index1.js
|
||||||
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
|
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
|
||||||
*/
|
*/
|
||||||
import http from "./config";
|
import http from "./config";
|
||||||
import qs from "qs";
|
import qs from "qs";
|
||||||
|
// import { getCookie } from '../api/method'
|
||||||
/**
|
/**
|
||||||
* 接口传参数方式(get)
|
* 接口传参数方式(get)
|
||||||
* axios.get('/user', {
|
* axios.get('/user', {
|
||||||
@@ -104,7 +104,8 @@ export const getMemberInfo = (obj) => http.post('/admin/orgStruct/getMemberInfo'
|
|||||||
export const getAudienceInfo = (obj) => http.post('/admin/orgStruct/getAudienceInfo', obj)
|
export const getAudienceInfo = (obj) => http.post('/admin/orgStruct/getAudienceInfo', obj)
|
||||||
//获取授权(修改版)
|
//获取授权(修改版)
|
||||||
export const optionAuthPerm = (obj) => http.post('/admin/AuthPerm/optionAuthPerm', obj)
|
export const optionAuthPerm = (obj) => http.post('/admin/AuthPerm/optionAuthPerm', obj)
|
||||||
|
//获取用户登录
|
||||||
|
export const getUser = () => http.post('/admin/CheckUser/login')
|
||||||
|
|
||||||
|
|
||||||
// 获取组织结构树
|
// 获取组织结构树
|
||||||
|
|||||||
@@ -162,11 +162,47 @@ function autoComma(number) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//把token存到cookie
|
||||||
|
//name 字段名 value 字段值 perpetual 有效期
|
||||||
|
const setCookie = (name, value, perpetual) => {
|
||||||
|
console.log('存储token到cookie')
|
||||||
|
let exdate = new Date()
|
||||||
|
exdate.setDate(perpetual * 24 * 60 * 60 * 1000) //exdate.setDate(exdate.getDate() + 365)
|
||||||
|
document.cookie = name + '=' + value + ';expires=' + exdate.toGMTString()
|
||||||
|
//永久有效
|
||||||
|
//document.cookie = name + '=' + value + ';expires=' + 'Fri, 31 Dec 9999 23:59:59 GMT'
|
||||||
|
}
|
||||||
|
//获取cookie数据
|
||||||
|
|
||||||
|
//先写一个方法
|
||||||
|
function getCookie(name) {
|
||||||
|
//1.获取cookie字符串
|
||||||
|
var cookies = document.cookie;
|
||||||
|
//通过;来分割字符串
|
||||||
|
var cookie = cookies.split("; ");
|
||||||
|
// console.log('cookie', cookie)
|
||||||
|
//遍历,使键值对匹配上
|
||||||
|
for (var i = 0; i < cookie.length; i++) {
|
||||||
|
var arr = cookie[i].split("token=");
|
||||||
|
// console.log('arr', arr)
|
||||||
|
console.log('name', name)
|
||||||
|
// if (arr[0] == name) {
|
||||||
|
// console.log('arr[1]', arr[1])
|
||||||
|
// return arr[1];
|
||||||
|
// }
|
||||||
|
// console.log('arr[1]', arr[1])
|
||||||
|
return arr[1]
|
||||||
|
}
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
//最后通
|
||||||
|
|
||||||
|
|
||||||
//新建延迟
|
//新建延迟
|
||||||
const commonData = {
|
const commonData = {
|
||||||
timeout: 50
|
timeout: 50,
|
||||||
}
|
}
|
||||||
|
|
||||||
// const organizationalTree = [
|
// const organizationalTree = [
|
||||||
// {
|
// {
|
||||||
// title: "京东方",
|
// title: "京东方",
|
||||||
@@ -376,6 +412,8 @@ export {
|
|||||||
getWeek,
|
getWeek,
|
||||||
autoComma,
|
autoComma,
|
||||||
formatNumber,
|
formatNumber,
|
||||||
|
setCookie,
|
||||||
|
getCookie,
|
||||||
commonData,
|
commonData,
|
||||||
organizationalTree,
|
organizationalTree,
|
||||||
iframeUrl,
|
iframeUrl,
|
||||||
|
|||||||
@@ -31,7 +31,7 @@
|
|||||||
"
|
"
|
||||||
src="../assets/images/img.jpg"
|
src="../assets/images/img.jpg"
|
||||||
/>
|
/>
|
||||||
<div>李玉冰</div>
|
<div>{{ username }}</div>
|
||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
class="signOutMain"
|
class="signOutMain"
|
||||||
@@ -59,6 +59,7 @@
|
|||||||
<script>
|
<script>
|
||||||
import { reactive, toRefs } from "vue";
|
import { reactive, toRefs } from "vue";
|
||||||
import DownLoad from "../components/drawers/DownLoad";
|
import DownLoad from "../components/drawers/DownLoad";
|
||||||
|
import * as api from "../api/index1";
|
||||||
export default {
|
export default {
|
||||||
name: "NavTop",
|
name: "NavTop",
|
||||||
components: {
|
components: {
|
||||||
@@ -67,6 +68,7 @@ export default {
|
|||||||
setup() {
|
setup() {
|
||||||
const state = reactive({
|
const state = reactive({
|
||||||
selectRole: "管理员",
|
selectRole: "管理员",
|
||||||
|
username: "",
|
||||||
roleList: [
|
roleList: [
|
||||||
{
|
{
|
||||||
id: 1,
|
id: 1,
|
||||||
@@ -91,6 +93,21 @@ export default {
|
|||||||
state.visible = true;
|
state.visible = true;
|
||||||
console.log("点击下载", state.visible);
|
console.log("点击下载", state.visible);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const getUser = () => {
|
||||||
|
api
|
||||||
|
.getUser()
|
||||||
|
.then((res) => {
|
||||||
|
console.log("获取登录信息成功", res);
|
||||||
|
if (res.data.code === 200) {
|
||||||
|
state.username = res.data.data.realName;
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch((err) => {
|
||||||
|
console.log("获取登录信息失败", err);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
getUser();
|
||||||
return {
|
return {
|
||||||
...toRefs(state),
|
...toRefs(state),
|
||||||
changeRole,
|
changeRole,
|
||||||
|
|||||||
@@ -559,8 +559,6 @@ export default {
|
|||||||
//获取选中部门的人员信息
|
//获取选中部门的人员信息
|
||||||
const getPeoples = () => {
|
const getPeoples = () => {
|
||||||
let obj = {
|
let obj = {
|
||||||
keyWord: "",
|
|
||||||
id: 0,
|
|
||||||
org: state.selectedKeys[0],
|
org: state.selectedKeys[0],
|
||||||
pageNo: state.currentPage,
|
pageNo: state.currentPage,
|
||||||
pageSize: state.pageSize,
|
pageSize: state.pageSize,
|
||||||
@@ -569,7 +567,7 @@ export default {
|
|||||||
state.tableDataTotal = 0;
|
state.tableDataTotal = 0;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// console.log("obj", obj);
|
console.log("obj", obj);
|
||||||
api
|
api
|
||||||
.getMemberInfo(obj)
|
.getMemberInfo(obj)
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
|
|||||||
@@ -646,7 +646,11 @@ import QueryRight from "../../components/drawers/QueryRight";
|
|||||||
import ManageRight from "../../components/drawers/ManageRight";
|
import ManageRight from "../../components/drawers/ManageRight";
|
||||||
import * as api from "../../api/index1";
|
import * as api from "../../api/index1";
|
||||||
import { message } from "ant-design-vue";
|
import { message } from "ant-design-vue";
|
||||||
import { toDate, commonData } from "../../api/method";
|
import {
|
||||||
|
toDate,
|
||||||
|
commonData,
|
||||||
|
// setCookie
|
||||||
|
} from "../../api/method";
|
||||||
import { storage } from "../../api/storage";
|
import { storage } from "../../api/storage";
|
||||||
export default {
|
export default {
|
||||||
name: "learningPath",
|
name: "learningPath",
|
||||||
@@ -1642,6 +1646,9 @@ export default {
|
|||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
// console.log("执行");
|
// console.log("执行");
|
||||||
getLearnPath();
|
getLearnPath();
|
||||||
|
// let cookie =
|
||||||
|
// "eyJ0eXBlIjoidG9rZW4iLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwOlwvXC91LmJvZS5jb20iLCJpYXQiOjE2NjkzNTU0MjQsImV4cCI6MTY2OTM2MjYyNCwiR2l2ZW5OYW1lIjoiYm9ldSIsInVzZXJJZCI6IjZCMDQ5RkFGLUMzMTQtN0NDRi0wRDI4LTBEMjNGNEM0MjUzMSIsInVJZCI6Ijk2NTM0MjAyNzQ5NzYwNzE2OCIsInBlcm1pc3Npb24iOiIifQ==.a565952d942ac41a6258a187be48a9269a75d0bfc50c6f13eb42362fe2f3d76a";
|
||||||
|
// setCookie("token", cookie, 10);
|
||||||
});
|
});
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|||||||
@@ -195,7 +195,7 @@
|
|||||||
tree-default-expand-all
|
tree-default-expand-all
|
||||||
:tree-data="classifyList2"
|
:tree-data="classifyList2"
|
||||||
:fieldNames="{
|
:fieldNames="{
|
||||||
children: 'children',
|
children: 'treeChildList',
|
||||||
label: 'name',
|
label: 'name',
|
||||||
value: 'id',
|
value: 'id',
|
||||||
}"
|
}"
|
||||||
@@ -769,6 +769,7 @@ export default {
|
|||||||
{ value: 2, label: "将小米" },
|
{ value: 2, label: "将小米" },
|
||||||
{ value: 3, label: "刘孟君" },
|
{ value: 3, label: "刘孟君" },
|
||||||
]);
|
]);
|
||||||
|
//获取
|
||||||
|
|
||||||
//选择处理项目经理
|
//选择处理项目经理
|
||||||
let manager = "";
|
let manager = "";
|
||||||
|
|||||||
Reference in New Issue
Block a user