This commit is contained in:
zhangxingye 2025-02-22 16:48:22 +08:00
parent 1655e40667
commit 04eba5dc30
4 changed files with 83 additions and 16 deletions

View File

@ -17,7 +17,7 @@ const router = createRouter({
*/
const originPush = router.push
router.push = (to: RouteLocationRaw) => {
const route = typeof to == 'string' ? urlToRouteRaw(to) : to
const route: any = typeof to == 'string' ? urlToRouteRaw(to) : to
if (route.path) {
const paths = route.path.split('/').filter((item: string) => { return item })
route.path = ['admin'].indexOf(paths[0]) == -1 ? `/${getAppType()}${route.path}` : route.path
@ -30,7 +30,7 @@ router.push = (to: RouteLocationRaw) => {
*/
const originResolve = router.resolve
router.resolve = (to: RouteLocationRaw, currentLocation?: RouteLocationNormalizedLoaded) => {
const route = typeof to == 'string' ? urlToRouteRaw(to) : to
const route: any = typeof to == 'string' ? urlToRouteRaw(to) : to
if (route.path) {
const paths = route.path.split('/').filter((item: string) => { return item })
route.path = ['admin'].indexOf(paths[0]) == -1 ? `/${getAppType()}${route.path}` : route.path
@ -39,7 +39,7 @@ router.resolve = (to: RouteLocationRaw, currentLocation?: RouteLocationNormalize
}
// 全局前置守卫
router.beforeEach(async (to, from, next) => {
router.beforeEach(async (to: any, from, next) => {
NProgress.configure({ showSpinner: false })
NProgress.start()

View File

@ -73,7 +73,8 @@ interface Route {
children?: [],
is_show: boolean,
app_type: string,
addon: string
addon: string,
menu_attr ?: String
}
/**
@ -94,6 +95,7 @@ const createRoute = function (route: Route, parentRoute: RouteRecordRaw | null =
app: route.app_type,
view: route.view_path,
addon: route.addon,
attr: route.menu_attr,
parent_route: parentRoute ? parentRoute.meta : parentRoute
}
}

View File

@ -43,6 +43,9 @@ const useDiyStore = defineStore('diy', {
position: ['top_fixed', 'right_fixed', 'bottom_fixed', 'left_fixed', 'fixed'],
global: {
title: "页面", // 页面标题(用于前台展示)
completeLayout: 'style-1', // 整体布局目前万能表单用到表单布局排版风格style-1单列平铺style-2左右排列
completeAlign: 'left', // 左右布局 对齐方式left左对齐right右对齐
borderControl: true, // 控制表单组件左右布局时,边框是否显示
pageStartBgColor: "", // 页面背景颜色(开始)
pageEndBgColor: "", // 页面背景颜色(结束)
@ -106,7 +109,8 @@ const useDiyStore = defineStore('diy', {
top: 0, // 上边距
bottom: 0, // 下边距
both: 0, // 左右边距
}
},
isHidden: false // 是否隐藏该组件 truefalse增加问号说明勾选后该组件将隐藏适用于你不希望看到该组件字段又不希望删除的情况
}
},
@ -128,6 +132,9 @@ const useDiyStore = defineStore('diy', {
init() {
this.global = {
title: "页面", // 页面标题
completeLayout: 'style-1',
completeAlign: 'left',
borderControl: true,
pageStartBgColor: "", // 页面背景颜色(开始)
pageEndBgColor: "", // 页面背景颜色(结束)
@ -191,7 +198,8 @@ const useDiyStore = defineStore('diy', {
top: 0, // 上边距
bottom: 0, // 下边距
both: 0, // 左右边距
}
},
isHidden: false // 是否隐藏该组件 truefalse增加问号说明勾选后该组件将隐藏适用于你不希望看到该组件字段又不希望删除的情况
}
};
@ -213,8 +221,9 @@ const useDiyStore = defineStore('diy', {
Object.assign(component, component.value);
delete component.title;
delete component.value;
delete component.type;
// delete component.type; // todo 考虑删除,没用到
delete component.icon;
delete component.render; // 渲染值,万能表单用到了
// 默认继承全局属性
let template = cloneDeep(this.global.template);
@ -238,20 +247,69 @@ const useDiyStore = defineStore('diy', {
// 置顶组件,只能在第一个位置中添加
if (component.position && this.position.indexOf(component.position) != -1) {
this.currentIndex = 0;
// 指定位置添加组件
this.value.splice(0, 0, component);
if (component.position == 'top_fixed') {
// 顶部置顶
this.currentIndex = 0;
// 指定位置添加组件
this.value.splice(0, 0, component);
} else if (component.position == 'bottom_fixed') {
// 底部置顶
// 指定位置添加组件
this.value.splice(this.value.length, 0, component);
this.currentIndex = this.value.length - 1;
}else{
this.currentIndex = 0;
// 指定位置添加组件
this.value.splice(0, 0, component);
}
} else if (this.currentIndex === -99) {
let index = this.currentIndex;
for (let i = this.value.length - 1; i >= 0; i--) {
if (this.value[i].position) {
index = i; // 在定位组件之前添加
break;
}
}
this.value.push(component);
// 添加组件后(不是编辑调用的),选择最后一个
this.currentIndex = this.value.length - 1;
if (index == -99) {
this.value.push(component);
// 添加组件后(不是编辑调用的),选择最后一个
this.currentIndex = this.value.length - 1;
} else {
// 指定位置添加组件
this.value.splice(index, 0, component);
this.currentIndex = index;
}
} else {
let index = -1;
for (let i = this.value.length - 1; i >= 0; i--) {
if (this.value[i].position && this.value[i].position == 'bottom_fixed') {
index = i; // 在定位组件之前添加
break;
}
}
// 指定位置添加组件
this.value.splice(++this.currentIndex, 0, component);
// 判断当前添加的位置跟定位组件是否相邻
if (index != -1 && (index == this.currentIndex || (index - this.currentIndex) == 1)) {
// 未找到定位组件,在当前下标之后添加组件
if (index == -1) {
this.value.splice(++this.currentIndex, 0, component);
} else {
// 指定位置添加组件
this.value.splice(index, 0, component);
this.currentIndex = index;
}
} else {
this.value.splice(++this.currentIndex, 0, component);
}
}
@ -348,6 +406,8 @@ const useDiyStore = defineStore('diy', {
var temp2 = cloneDeep(this.value[nextIndex]); // 下个组件
temp2.id = this.generateRandom(); // 更新id刷新组件数据
if (temp2.position && this.position.indexOf(temp2.position) != -1) return;
if (temp.position && this.position.indexOf(temp.position) != -1) {
ElMessage({
type: 'warning',
@ -473,4 +533,4 @@ const useDiyStore = defineStore('diy', {
}
})
export default useDiyStore
export default useDiyStore

View File

@ -4,6 +4,7 @@ import { login, getAuthMenus } from '@/app/api/auth'
import storage from '@/utils/storage'
import router from '@/router'
import { formatRouters, findFirstValidRoute } from '@/router/routers'
import useTabbarStore from './tabbar'
interface User {
token: string,
@ -42,11 +43,15 @@ const useUserStore = defineStore('user', {
this.routers = []
},
logout() {
if (!this.token) return
this.token = ''
this.userInfo = {}
removeToken()
storage.remove(['userinfo'])
this.routers = []
this.rules = []
// 清除tabbar
useTabbarStore().clearTab()
router.push('/login')
},
getAuthMenusFn() {