Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
saas
/
scrm-base
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 068dea78
authored
Apr 14, 2023
by
liimin
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
优化部分代码
1 parent
ef1a8385
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
46 additions
and
50 deletions
src/global/messenger.js
src/plugins/element.js
src/router/index.js
src/store/modules/init.js
src/views/404.vue
src/global/messenger.js
View file @
068dea7
...
@@ -9,12 +9,17 @@
...
@@ -9,12 +9,17 @@
*/
*/
import
{
push
}
from
'./history'
import
{
push
}
from
'./history'
import
{
Subject
}
from
'rxjs'
import
{
Subject
}
from
'rxjs'
/**
* Messenger类扩展了Subject类,用于发送和接收消息。
*/
class
Messenger
extends
Subject
{
class
Messenger
extends
Subject
{
constructor
()
{
/**
super
()
* send方法用于发送消息,并将消息推送到浏览器历史记录中。
}
* @param {Object} msg - 要发送的消息对象。
* @param {string} msg.route - 要推送到浏览器历史记录中的路由。
*/
send
(
msg
)
{
send
(
msg
)
{
if
(
!
msg
)
return
const
{
route
}
=
msg
const
{
route
}
=
msg
if
(
route
)
{
if
(
route
)
{
push
(
route
)
push
(
route
)
...
...
src/plugins/element.js
View file @
068dea7
import
Vue
from
'vue'
import
Vue
from
'vue'
import
{
Message
,
Button
,
ButtonGroup
,
Container
,
Aside
,
Menu
,
MenuItem
,
Submenu
,
MenuItemGroup
,
Header
,
Main
,
Footer
,
Avatar
,
Badge
,
Dropdown
,
DropdownMenu
,
DropdownItem
,
Scrollbar
,
Carousel
,
CarouselItem
,
Form
,
FormItem
,
Input
,
Image
,
Tabs
,
TabPane
,
Loading
,
Dialog
,
Alert
,
Popover
,
Tooltip
}
from
'element-ui'
import
{
Message
,
Button
,
ButtonGroup
,
Container
,
Aside
,
Menu
,
MenuItem
,
Submenu
,
MenuItemGroup
,
Header
,
Main
,
Footer
,
Avatar
,
Badge
,
Dropdown
,
DropdownMenu
,
DropdownItem
,
Scrollbar
,
Carousel
,
CarouselItem
,
Form
,
FormItem
,
Input
,
Image
,
Tabs
,
TabPane
,
Loading
,
Dialog
,
Alert
,
Popover
,
Tooltip
}
from
'element-ui'
Vue
.
use
(
Button
)
;[
Button
,
ButtonGroup
,
Container
,
Aside
,
Menu
,
MenuItem
,
Submenu
,
MenuItemGroup
,
Header
,
Main
,
Footer
,
Avatar
,
Badge
,
Dropdown
,
DropdownMenu
,
DropdownItem
,
Scrollbar
,
Carousel
,
CarouselItem
,
Form
,
FormItem
,
Input
,
Image
,
Tabs
,
TabPane
,
Loading
,
Dialog
,
Alert
,
Popover
,
Tooltip
].
forEach
(
component
=>
Vue
.
use
(
component
))
Vue
.
use
(
ButtonGroup
)
Vue
.
use
(
Container
)
Vue
.
use
(
Aside
)
Vue
.
use
(
Menu
)
Vue
.
use
(
MenuItem
)
Vue
.
use
(
Submenu
)
Vue
.
use
(
MenuItemGroup
)
Vue
.
use
(
Header
)
Vue
.
use
(
Main
)
Vue
.
use
(
Footer
)
Vue
.
use
(
Avatar
)
Vue
.
use
(
Badge
)
Vue
.
use
(
Dropdown
)
Vue
.
use
(
DropdownMenu
)
Vue
.
use
(
DropdownItem
)
Vue
.
use
(
Scrollbar
)
Vue
.
use
(
Carousel
)
Vue
.
use
(
CarouselItem
)
Vue
.
use
(
Form
)
Vue
.
use
(
FormItem
)
Vue
.
use
(
Input
)
Vue
.
use
(
Image
)
Vue
.
use
(
Tabs
)
Vue
.
use
(
TabPane
)
Vue
.
use
(
Loading
)
Vue
.
use
(
Dialog
)
Vue
.
use
(
Alert
)
Vue
.
use
(
Popover
)
Vue
.
use
(
Tooltip
)
export
{
Message
}
export
{
Message
}
src/router/index.js
View file @
068dea7
...
@@ -91,26 +91,47 @@ router.onError(err => {
...
@@ -91,26 +91,47 @@ router.onError(err => {
console
.
log
(
err
)
console
.
log
(
err
)
})
})
router
.
beforeEach
(
async
(
to
,
from
,
next
)
=>
{
router
.
beforeEach
(
async
(
to
,
from
,
next
)
=>
{
if
(
Object
.
values
(
Path
).
includes
(
to
.
path
))
return
next
()
const
isPathIncluded
=
Object
.
values
(
Path
).
includes
(
to
.
path
)
if
(
isPathIncluded
)
{
return
next
()
}
const
session
=
store
.
getters
.
auth
.
session
const
session
=
store
.
getters
.
auth
.
session
const
storeSession
=
utils
.
storage
.
getSession
(
constants
.
SCRM_BASE_SESSION
)
const
storeSession
=
utils
.
storage
.
getSession
(
constants
.
SCRM_BASE_SESSION
)
if
(
storeSession
&&
from
===
VueRouter
.
START_LOCATION
&&
session
===
null
)
{
await
store
.
dispatch
(
'init/init'
)
return
next
({
...
to
,
replace
:
true
})
}
if
(
storeSession
)
{
if
(
storeSession
)
{
if
(
from
===
VueRouter
.
START_LOCATION
&&
session
===
null
)
{
await
store
.
dispatch
(
'init/init'
)
return
next
({
...
to
,
replace
:
true
})
}
// if (router.hasRoute(to.path)) {
const
{
$title
}
=
to
.
query
const
{
$title
}
=
to
.
query
$title
&&
(
to
.
meta
.
title
=
$title
)
$title
&&
(
to
.
meta
.
title
=
$title
)
store
.
dispatch
(
'app/setCurrentPage'
,
to
.
meta
)
store
.
dispatch
(
'app/setCurrentPage'
,
to
.
meta
)
return
next
()
return
next
()
// }
// return next({ path: Path.E404, replace: true })
}
}
if
(
!
session
)
{
if
(
!
session
)
{
next
({
path
:
Path
.
LOGIN
})
return
next
({
path
:
Path
.
LOGIN
})
}
}
// next({ path: Path.LOGIN })
})
})
// router.beforeEach(async (to, from, next) => {
// if (Object.values(Path).includes(to.path)) return next()
// const session = store.getters.auth.session
// const storeSession = utils.storage.getSession(constants.SCRM_BASE_SESSION)
// if (storeSession) {
// if (from === VueRouter.START_LOCATION && session === null) {
// await store.dispatch('init/init')
// return next({ ...to, replace: true })
// }
// // if (router.hasRoute(to.path)) {
// const { $title } = to.query
// $title && (to.meta.title = $title)
// store.dispatch('app/setCurrentPage', to.meta)
// return next()
// // }
// // return next({ path: Path.E404, replace: true })
// }
// if (!session) {
// next({ path: Path.LOGIN })
// }
// // next({ path: Path.LOGIN })
// })
export
default
router
export
default
router
src/store/modules/init.js
View file @
068dea7
import
{
utils
}
from
'glsx-common'
import
{
utils
}
from
'glsx-common'
import
{
constants
}
from
'@/common'
import
{
constants
}
from
'@/common'
const
modulesFiles
=
require
const
modulesFiles
=
require
.
context
(
'.'
,
true
,
/^
(?!
.*
\/
init
\.
js$
)
.*
\.
js$/
)
.
context
(
'.'
,
true
,
/
\.
js$/
)
.
keys
()
.
filter
(
key
=>
key
!==
'./init.js'
)
const
init
=
{
const
init
=
{
namespaced
:
true
,
namespaced
:
true
,
actions
:
{
actions
:
{
...
...
src/views/404.vue
View file @
068dea7
<
template
>
<
template
>
<div
class=
"about"
>
<div
class=
"not-found"
>
<router-link
:to=
"
{ path: auth.session.defaultPath }">404
</router-link>
<h1
class=
"title"
>
404 - 页面未找到
</h1>
<p
class=
"message"
>
很抱歉,我们无法找到您要访问的页面。
</p>
<router-link
:to=
"
{ path: auth.session.defaultPath }" class="link">返回首页
</router-link>
</div>
</div>
</
template
>
</
template
>
<
script
>
<
script
>
...
...
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment