hookehuyr

fix 处理没有权限的跳转问题

......@@ -560,7 +560,8 @@ export default {
id: 0,
note: '',
type: null, // 操作方式 0:仅保存流程说明 1:删除,2:启用
}
},
showConfirmation: true,
});
/**
......@@ -670,11 +671,11 @@ export default {
// 显示提示框的标志位
onMounted(async () => {
var showConfirmation = true;
document.title = '可视化流程设计器'
localStorage.setItem('showConfirmation', '1'); // 打开刷新提示框
// 监听 beforeunload 事件
window.addEventListener('beforeunload', function (event) {
if (showConfirmation) {
if (localStorage.getItem('showConfirmation') === '1') {
// 取消事件的默认行为(弹出确认对话框)
event.preventDefault();
}
......@@ -682,7 +683,8 @@ export default {
// 监听 unload 事件
window.addEventListener('unload', function () {
// 设置标志位为 false,避免在刷新页面时再次显示提示框
showConfirmation = false;
// state.showConfirmation = false;
localStorage.setItem('showConfirmation', '0');
});
// 监听 resize 事件
// window.addEventListener('resize', function () {
......
/*
* @Date: 2023-10-27 11:12:24
* @LastEditors: hookehuyr hookehuyr@gmail.com
* @LastEditTime: 2023-11-30 18:12:27
* @LastEditTime: 2023-12-01 15:38:32
* @FilePath: /vue-flow-editor/doc/axios.js
* @Description: 文件描述
*/
......@@ -13,6 +13,16 @@ axios.defaults.params = {
p: 'authority_my',
};
const parseQueryString = url => {
var json = {};
var arr = url.indexOf('?') >= 0 ? url.substr(url.indexOf('?') + 1).split('&') : [];
arr.forEach(item => {
var tmp = item.split('=');
json[tmp[0]] = decodeURIComponent(tmp[1]);
});
return json;
}
/**
* @description 请求拦截器
*/
......@@ -26,7 +36,7 @@ axios.interceptors.request.use(
* 序列化POST请求时需要屏蔽上传相关接口,上传相关接口序列化后报错
*/
// 绑定默认请求头
config.params = { ...config.params, timestamp }
config.params = { ...config.params, timestamp };
return config;
},
error => {
......@@ -47,7 +57,11 @@ axios.interceptors.response.use(
callback: action => {
// session 失效需要重新登录
if (action === 'confirm') {
window.parent.location.href = location.origin + '/admin/' + window.parent.location.search;
localStorage.setItem('showConfirmation', '0');
// 拼接跳转地址,因为要返回到当前页面传入参数
let url_params = parseQueryString(location.href);
let str = `/admin/custom_flow/?form_id=${url_params.form_id}`;
window.location.href = location.origin + '/admin/' + window.location.search + `&refer_url=${encodeURIComponent(str)}`;
}
}
});
......