Skip to content

Commit 18bc6a1

Browse files
committed
fix some already know issue
1 parent 684fe2b commit 18bc6a1

File tree

14 files changed

+54
-21
lines changed

14 files changed

+54
-21
lines changed

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ The framework is available in js,ts, plus and electron versions
2727
- js version:[vue3-admin-template](https://github.com/jzfai/vue3-admin-template.git) -- basic version
2828
- ts version:[vue3-element-ts](https://github.com/jzfai/vue3-admin-ts.git)
2929
- ts version for plus:[vue3-element-plus](https://github.com/jzfai/vue3-admin-plus.git)
30-
- java Micro-service background data:[micro-service-plus](https://github.com/jzfai/micro-service-plus)
3130

3231

3332
## Build Setup

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "vue3-admin-electron",
3-
"version": "2.0.2",
3+
"version": "2.0.5",
44
"license": "ISC",
55
"author": "kuanghua(869653722@qq.com)",
66
"scripts": {

src/hooks/use-error-log.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,13 @@ import { jsErrorCollection } from 'js-error-collection'
33
import pack from '../../package.json'
44
import settings from '@/settings'
55
import bus from '@/utils/bus'
6-
import axiosReq from '@/utils/axios-req'
6+
//此处不要使用utils下的axios
7+
import axiosReq from 'axios'
78
const reqUrl = '/integration-front/errorCollection/insert'
9+
let repeatErrorLogJudge = ''
810
const errorLogReq = (errLog: string) => {
911
axiosReq({
10-
url: reqUrl,
12+
url: import.meta.env.VITE_APP_BASE_URL+reqUrl,
1113
data: {
1214
pageUrl: window.location.href,
1315
errorLog: errLog,
@@ -25,8 +27,11 @@ export const useErrorLog = () => {
2527
//判断该环境是否需要收集错误日志,由settings配置决定
2628
if (settings.errorLog?.includes(import.meta.env.VITE_APP_ENV)) {
2729
jsErrorCollection({ runtimeError: true, rejectError: true, consoleError: true }, (errLog) => {
28-
//判断是否是reqUrl错误,避免死循环
29-
if (!errLog.includes(reqUrl)) errorLogReq(errLog)
30+
if (!repeatErrorLogJudge || !errLog.includes(repeatErrorLogJudge)) {
31+
errorLogReq(errLog)
32+
//移除重复日志,fix重复提交错误日志,避免造成死循环
33+
repeatErrorLogJudge = errLog.slice(0, 20)
34+
}
3035
})
3136
}
3237
}

src/hooks/use-permission.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import router, { asyncRoutes, constantRoutes, roleCodeRoutes } from '@/router'
1616
import 'nprogress/nprogress.css'
1717
import { useBasicStore } from '@/store/basic'
1818

19-
const buttonCodes: Array<number> = [] //按钮权限
19+
const buttonCodes: Array<Number> = [] //按钮权限
2020
interface menuRow {
2121
category: number
2222
code: number

src/layout/app-main/TagsView.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ const { visible, top, left, selectedTag } = toRefs(state)
219219
height: var(--tag-view-height);
220220
width: 100%;
221221
background: var(--tags-view-background);
222-
border-bottom: 1px solid var(--tags-view-border-bottom-color);
222+
border-bottom: 1px solid var(--tags-view-border-bottom);
223223
box-shadow: var(--tags-view-box-shadow);
224224
.tags-view-wrapper {
225225
.tags-view-item {

src/layout/app-main/index.vue

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,16 +31,35 @@ const key = computed(() => route.path)
3131
// leaveRmCachePage: is true, keep-alive remote when page leave
3232
let oldRoute: rawConfig = {}
3333
let deepOldRouter: RouteLocationMatched | null = null
34+
let cacheGroup: any = []
3435
const basicStore = useBasicStore()
3536
const removeDeepChildren = (deepOldRouter) => {
3637
deepOldRouter.children?.forEach((fItem) => {
37-
basicStore.setCacheViewDeep(fItem.name)
38+
basicStore.delCacheViewDeep(fItem.name)
3839
})
3940
}
4041
watch(
4142
() => route.name,
4243
() => {
4344
const routerLevel = route.matched.length
45+
46+
//缓存组处理
47+
//first judge cacheGroup and then remove
48+
if (cacheGroup.length) {
49+
if (!cacheGroup.includes(route.name)) {
50+
cacheGroup.forEach((item) => {
51+
basicStore.delCachedView(item)
52+
})
53+
}
54+
}
55+
//and then cache the current router config page
56+
if (route.meta?.cacheGroup) {
57+
cacheGroup = route.meta?.cacheGroup || []
58+
cacheGroup.forEach((fItem) => {
59+
basicStore.addCachedView(fItem)
60+
})
61+
}
62+
4463
//二级路由处理
4564
if (routerLevel === 2) {
4665
if (deepOldRouter?.name) {
@@ -81,7 +100,7 @@ watch(
81100
//否则走正常两级路由处理流程
82101
if (oldRoute?.name) {
83102
if (oldRoute.meta?.leaveRmCachePage && oldRoute.meta?.cachePage) {
84-
basicStore.setCacheViewDeep(oldRoute.name)
103+
basicStore.delCacheViewDeep(oldRoute.name)
85104
}
86105
}
87106
}

src/layout/sidebar/index.vue

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,9 @@ import Logo from './Logo.vue'
2525
import SidebarItem from './SidebarItem.vue'
2626
import { useBasicStore } from '@/store/basic'
2727
const { settings, allRoutes, sidebar } = storeToRefs(useBasicStore())
28-
const { meta, path } = useRoute()
28+
const routeInstance = useRoute()
2929
const activeMenu = computed(() => {
30+
const { meta, path } = routeInstance
3031
// if set path, the sidebar will highlight the path you set
3132
if (meta.activeMenu) {
3233
return meta.activeMenu
@@ -39,4 +40,7 @@ const activeMenu = computed(() => {
3940
.el-menu-vertical {
4041
width: var(--side-bar-width);
4142
}
43+
.reset-menu-style{
44+
border-right: 1px solid var(--side-bar-border-right-color);
45+
}
4246
</style>

src/permission.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { filterAsyncRouter, progressClose, progressStart } from '@/hooks/use-per
33
import { useBasicStore } from '@/store/basic'
44
import { userInfoReq } from '@/api/user'
55
import { langTitle } from '@/hooks/use-common'
6+
import settings from "@/settings";
67

78
//路由进入前拦截
89
//to:将要进入的页面 vue-router4.0 不推荐使用next()
@@ -11,6 +12,11 @@ router.beforeEach(async (to) => {
1112
progressStart()
1213
document.title = langTitle(to.meta?.title) // i18 page title
1314
const basicStore = useBasicStore()
15+
//not login
16+
if (!settings.isNeedLogin) {
17+
basicStore.setFilterAsyncRoutes([])
18+
return true
19+
}
1420
//1.判断token
1521
if (basicStore.token) {
1622
if (to.path === '/login') {

src/router/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ export const constantRoutes: RouterTypes = [
5656
component: Layout,
5757
children: [
5858
{
59-
path: 'https://github.jzfai.top/low-code-platform/#/permission-center/user-table-query',
59+
path: 'https://github.jzfai.top/low-code-plateform',
6060
meta: { title: 'RBAC', icon: 'skill' }
6161
}
6262
]

src/store/basic.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ export const useBasicStore = defineStore('basic', {
102102
state.cachedViewsDeep.push(view)
103103
})
104104
},
105-
setCacheViewDeep(view) {
105+
delCacheViewDeep(view) {
106106
this.$patch((state) => {
107107
const index = state.cachedViewsDeep.indexOf(view)
108108
index > -1 && state.cachedViewsDeep.splice(index, 1)

0 commit comments

Comments
 (0)