mirror of
https://codeup.aliyun.com/67762337eccfc218f6110e0e/vue/fe-manage.git
synced 2025-12-23 17:55:39 +08:00
Merge branch 'user-modify' of http://gitlab.dongwu-inc.com:10080/BOE/fe-manage into user-modify
# Conflicts: # src/App.vue # src/api/request.js # src/main.js
This commit is contained in:
29
src/App.vue
29
src/App.vue
@@ -42,7 +42,6 @@ let time1 = ref(0);
|
|||||||
let time2 = ref(0);
|
let time2 = ref(0);
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
init()
|
|
||||||
window.addEventListener('beforeunload', e => beforeunloadHandler(e));
|
window.addEventListener('beforeunload', e => beforeunloadHandler(e));
|
||||||
window.addEventListener('unload', e => unloadHandler(e));
|
window.addEventListener('unload', e => unloadHandler(e));
|
||||||
})
|
})
|
||||||
@@ -52,16 +51,7 @@ function beforeunloadHandler() {
|
|||||||
time1.value = new Date().getTime();
|
time1.value = new Date().getTime();
|
||||||
}
|
}
|
||||||
|
|
||||||
async function init() {
|
|
||||||
initDict("content_type"); //内容分类
|
|
||||||
initDict("project_level"); //项目级别
|
|
||||||
initDict("project_sys"); //培训分类
|
|
||||||
initDict("project_pic"); //项目封面
|
|
||||||
initDict("router_pic"); //路径图封面
|
|
||||||
initDict("course_pic"); //课程封面
|
|
||||||
initDict("job_type"); //岗位
|
|
||||||
initDict("band"); //band
|
|
||||||
}
|
|
||||||
|
|
||||||
function unloadHandler() {
|
function unloadHandler() {
|
||||||
time2.value = new Date().getTime() - time1.value;
|
time2.value = new Date().getTime() - time1.value;
|
||||||
@@ -71,23 +61,6 @@ function unloadHandler() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getUserInfo() {
|
|
||||||
const userInfo = await api2.userInfo();
|
|
||||||
store.commit("SET_USER", userInfo.data.data);
|
|
||||||
}
|
|
||||||
|
|
||||||
async function initDict(key) {
|
|
||||||
const list = await getDictList(key);
|
|
||||||
store.commit("SET_DICT", {key, data: list});
|
|
||||||
}
|
|
||||||
|
|
||||||
async function getUserPermission() {
|
|
||||||
return request(USER_PERMISSION, {permissionType: 'PAGE'}).then(res => {
|
|
||||||
store.commit("SET_PERMISSION", res.data?.map(s => s.url));
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
const getDictList = (param) => api1.getDictTree({code: param,}).then((res) => res.data.data);
|
|
||||||
</script>
|
</script>
|
||||||
<style lang="scss">
|
<style lang="scss">
|
||||||
#app {
|
#app {
|
||||||
|
|||||||
@@ -12,4 +12,7 @@ export const CASE_PAGE = "/systemapi/xboe/m/boe/cases/pagelist post formData";
|
|||||||
export const EXAM_PAPER_PAGE = "/systemapi/xboe/m/exam/paper/querylist post formData";
|
export const EXAM_PAPER_PAGE = "/systemapi/xboe/m/exam/paper/querylist post formData";
|
||||||
export const TEST_PAGE = "/api/b1/system/quiz/quiz-list post formData";
|
export const TEST_PAGE = "/api/b1/system/quiz/quiz-list post formData";
|
||||||
export const ONLINE_PAGE = "/systemapi/xboe/m/course/manage/pagelist post formData";
|
export const ONLINE_PAGE = "/systemapi/xboe/m/course/manage/pagelist post formData";
|
||||||
|
|
||||||
|
export const LOGOUT = "/userbasic/logout post";
|
||||||
|
|
||||||
export const ONLINE_COURSE_DEL = (id, courseId) => `/systemapi/xboe/school/study/course/delete-signup?id=${id}&couserId=${courseId} post`;
|
export const ONLINE_COURSE_DEL = (id, courseId) => `/systemapi/xboe/school/study/course/delete-signup?id=${id}&couserId=${courseId} post`;
|
||||||
@@ -34,3 +34,4 @@ export const AUDIENCE_LIST = "/admin/thirdApi/audience/userAudiences";
|
|||||||
export const USER_PERMISSION = "/admin/thirdApi/permission/listByUser";
|
export const USER_PERMISSION = "/admin/thirdApi/permission/listByUser";
|
||||||
export const VALIDATE_TOKEN = "/admin/thirdApi/validateToken";
|
export const VALIDATE_TOKEN = "/admin/thirdApi/validateToken";
|
||||||
export const REFRESH_TOKEN = "/admin/thirdApi/refreshToken";
|
export const REFRESH_TOKEN = "/admin/thirdApi/refreshToken";
|
||||||
|
export const USER_INFO = "/admin/CheckUser/userInfo";
|
||||||
|
|||||||
@@ -413,10 +413,8 @@ export async function request(_url, params) {
|
|||||||
localStorage.removeItem('refreshPage')
|
localStorage.removeItem('refreshPage')
|
||||||
return Promise.reject(res);
|
return Promise.reject(res);
|
||||||
}else if(res.code=== 1001){
|
}else if(res.code=== 1001){
|
||||||
setCookie('token',getCookieForName('refreshToken'))
|
return request(REFRESH_TOKEN).then((res)=>{
|
||||||
request(REFRESH_TOKEN).then((res)=>{
|
|
||||||
if(res.code===0 || res.code === 200){
|
if(res.code===0 || res.code === 200){
|
||||||
setCookie('token',res.data)
|
|
||||||
return request(_url, params)
|
return request(_url, params)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -49,6 +49,8 @@ import {computed, reactive} from "vue";
|
|||||||
import {studentUrl,teacherUrl} from "@/api/method";
|
import {studentUrl,teacherUrl} from "@/api/method";
|
||||||
import router from "@/router";
|
import router from "@/router";
|
||||||
import {useStore, createStore} from "vuex";
|
import {useStore, createStore} from "vuex";
|
||||||
|
import {boeRequest, request} from "@/api/request";
|
||||||
|
import {LOGOUT} from "@/api/ThirdApi";
|
||||||
|
|
||||||
const store = useStore();
|
const store = useStore();
|
||||||
|
|
||||||
@@ -83,9 +85,11 @@ const changeRole = (value) => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
const logOut = () => {
|
const logOut = async () => {
|
||||||
|
await boeRequest(LOGOUT,{from:'pc'})
|
||||||
store.replaceState(createStore({state: {openpages: []}}).state);
|
store.replaceState(createStore({state: {openpages: []}}).state);
|
||||||
localStorage.clear();
|
localStorage.clear();
|
||||||
|
sessionStorage.clear();
|
||||||
(process.env.NODE_ENV === 'development' || process.env.NODE_ENV === 'alpine') ? router.push({path: '/login'}) : (window.location.href = window.location.protocol + process.env.VUE_APP_LOGIN_URL)
|
(process.env.NODE_ENV === 'development' || process.env.NODE_ENV === 'alpine') ? router.push({path: '/login'}) : (window.location.href = window.location.protocol + process.env.VUE_APP_LOGIN_URL)
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
36
src/main.js
36
src/main.js
@@ -16,9 +16,10 @@ import 'element-plus/dist/index.css'
|
|||||||
import "@/assets/scss/common.scss"
|
import "@/assets/scss/common.scss"
|
||||||
import Antd from 'ant-design-vue';
|
import Antd from 'ant-design-vue';
|
||||||
import 'ant-design-vue/dist/antd.css';
|
import 'ant-design-vue/dist/antd.css';
|
||||||
import {getCookieForName} from "@/api/method";
|
|
||||||
import {request} from "@/api/request";
|
import {request} from "@/api/request";
|
||||||
import {VALIDATE_TOKEN} from "@/api/apis";
|
import {USER_INFO, USER_PERMISSION, VALIDATE_TOKEN} from "@/api/apis";
|
||||||
|
import * as api1 from "@/api/index1";
|
||||||
|
import {getCookieForName} from "@/api/method";
|
||||||
// import axios from 'axios'
|
// import axios from 'axios'
|
||||||
// axios.defaults.withCredentials = true;
|
// axios.defaults.withCredentials = true;
|
||||||
// import zhCN from 'ant-design-vue/es/locale/zh_CN';
|
// import zhCN from 'ant-design-vue/es/locale/zh_CN';
|
||||||
@@ -32,20 +33,47 @@ app.config.warnHandler = () => null;
|
|||||||
router.beforeEach(async (to, from, next) => {
|
router.beforeEach(async (to, from, next) => {
|
||||||
if (!getCookieForName("token")) {
|
if (!getCookieForName("token")) {
|
||||||
window.location.href = process.env.VUE_APP_LOGIN_URL + encodeURIComponent(window.location.protocol + process.env.VUE_APP_BOE_API_URL + process.env.VUE_APP_BASE + router.currentRoute.value.fullPath)
|
window.location.href = process.env.VUE_APP_LOGIN_URL + encodeURIComponent(window.location.protocol + process.env.VUE_APP_BOE_API_URL + process.env.VUE_APP_BASE + router.currentRoute.value.fullPath)
|
||||||
|
return
|
||||||
}
|
}
|
||||||
//第一次进入 没有用户信息
|
//第一次进入 没有用户信息
|
||||||
if(!store.state.userInfo.userId){
|
if(!store.state.userInfo.userId){
|
||||||
try{
|
try{
|
||||||
await request(VALIDATE_TOKEN)
|
await request(VALIDATE_TOKEN)
|
||||||
await getUserInfo();
|
await getUserInfo()
|
||||||
await getUserPermission();
|
await getUserPermission();
|
||||||
next();
|
init()
|
||||||
}catch (e){
|
}catch (e){
|
||||||
console.log('token失效 跳转到登录页')
|
console.log('token失效 跳转到登录页')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
next();
|
||||||
})
|
})
|
||||||
app.use(Antd);
|
app.use(Antd);
|
||||||
app.use(router);
|
app.use(router);
|
||||||
app.use(store);
|
app.use(store);
|
||||||
app.mount('#app');
|
app.mount('#app');
|
||||||
|
async function getUserPermission() {
|
||||||
|
return request(USER_PERMISSION, {permissionType: 'PAGE'}).then(res => {
|
||||||
|
store.commit("SET_PERMISSION", res.data?.map(s => s.url));
|
||||||
|
})
|
||||||
|
}
|
||||||
|
async function getUserInfo() {
|
||||||
|
const userInfo = await request(USER_INFO);
|
||||||
|
store.commit("SET_USER", userInfo.data);
|
||||||
|
}
|
||||||
|
async function initDict(key) {
|
||||||
|
const list = await getDictList(key);
|
||||||
|
store.commit("SET_DICT", {key, data: list});
|
||||||
|
}
|
||||||
|
const getDictList = (param) => api1.getDictTree({code: param,}).then((res) => res.data.data);
|
||||||
|
|
||||||
|
async function init() {
|
||||||
|
initDict("content_type"); //内容分类
|
||||||
|
initDict("project_level"); //项目级别
|
||||||
|
initDict("project_sys"); //培训分类
|
||||||
|
initDict("project_pic"); //项目封面
|
||||||
|
initDict("router_pic"); //路径图封面
|
||||||
|
initDict("course_pic"); //课程封面
|
||||||
|
initDict("job_type"); //岗位
|
||||||
|
initDict("band"); //band
|
||||||
|
}
|
||||||
@@ -16,7 +16,7 @@ module.exports = defineConfig({
|
|||||||
port: 8070,
|
port: 8070,
|
||||||
proxy: {
|
proxy: {
|
||||||
"/manageApi": {
|
"/manageApi": {
|
||||||
target: 'http:' + process.env.VUE_APP_PROXY_URL,
|
target: 'https:' + process.env.VUE_APP_PROXY_URL,
|
||||||
changeOrigin: true, //表示是否改变原域名
|
changeOrigin: true, //表示是否改变原域名
|
||||||
pathRewrite: {
|
pathRewrite: {
|
||||||
"^/manageApi": "",
|
"^/manageApi": "",
|
||||||
|
|||||||
Reference in New Issue
Block a user