Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
江名洋
/
linkwe-scrm
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 1a102063
authored
Jun 17, 2023
by
xinla
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
优化store写法
1 parent
e11a2bea
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
25 additions
and
28 deletions
vue3-lw-pc/src/directive/permission/hasPermi.js
vue3-lw-pc/src/directive/permission/hasRole.js
vue3-lw-pc/src/directive/preventReClick.js
vue3-lw-pc/src/layout/components/Sidebar/index.vue
vue3-lw-pc/src/layout/components/TopBar/index.vue
vue3-lw-pc/src/layout/index.vue
vue3-lw-pc/src/main.js
vue3-lw-pc/src/stores/index.js
vue3-lw-pc/src/utils/permission.js
vue3-lw-pc/src/utils/request.js
vue3-lw-pc/src/views/system/user/profile/userAvatar.vue
vue3-lw-pc/src/directive/permission/hasPermi.js
View file @
1a10206
...
...
@@ -2,13 +2,13 @@
* 操作权限处理
*/
import
store
from
'@/stores'
import
store
s
from
'@/stores'
export
default
{
inser
ted
(
el
,
binding
,
vnode
)
{
moun
ted
(
el
,
binding
,
vnode
)
{
const
{
value
}
=
binding
const
all_permission
=
'*:*:*'
const
permissions
=
store
&&
store
.
permissions
const
permissions
=
store
s
()
&&
stores
()
.
permissions
if
(
value
&&
value
instanceof
Array
&&
value
.
length
>
0
)
{
const
permissionFlag
=
value
...
...
vue3-lw-pc/src/directive/permission/hasRole.js
View file @
1a10206
...
...
@@ -2,13 +2,13 @@
* 角色权限处理
*/
import
store
from
'@/stores'
import
store
s
from
'@/stores'
export
default
{
inser
ted
(
el
,
binding
,
vnode
)
{
moun
ted
(
el
,
binding
,
vnode
)
{
const
{
value
}
=
binding
const
super_admin
=
'admin'
const
roles
=
store
&&
store
.
roles
const
roles
=
store
s
()
&&
stores
()
.
roles
if
(
value
&&
value
instanceof
Array
&&
value
.
length
>
0
)
{
const
roleFlag
=
value
...
...
vue3-lw-pc/src/directive/preventReClick.js
View file @
1a10206
...
...
@@ -3,7 +3,7 @@
* 使用 <div @click="search" v-preventReClick="1000">搜索</div>
*/
export
default
{
inser
ted
(
el
,
binding
)
{
moun
ted
(
el
,
binding
)
{
el
.
addEventListener
(
'click'
,
()
=>
{
el
.
style
.
pointerEvents
=
'none'
setTimeout
(()
=>
{
...
...
vue3-lw-pc/src/layout/components/Sidebar/index.vue
View file @
1a10206
...
...
@@ -70,7 +70,7 @@
<
script
>
import
{
mapState
}
from
'pinia'
import
{
appStore
}
from
'@/stores'
import
stores
from
'@/stores'
import
SidebarItem
from
'./SidebarItem'
...
...
@@ -78,7 +78,7 @@ export default {
components
:
{
SidebarItem
},
computed
:
{
// ...mapState(['settings']),
...
mapState
(
appStore
,
[
'permission_routes'
,
'sidebarRouters'
,
'sidebar'
]),
...
mapState
(
stores
,
[
'permission_routes'
,
'sidebarRouters'
,
'sidebar'
]),
activeMenu
()
{
const
route
=
this
.
$route
const
{
meta
,
path
}
=
route
...
...
vue3-lw-pc/src/layout/components/TopBar/index.vue
View file @
1a10206
...
...
@@ -115,7 +115,7 @@
import
Settings
from
'./Settings'
import
{
isExternal
}
from
'@/utils/validate'
import
{
mapState
}
from
'pinia'
import
{
appStore
}
from
'@/stores'
import
stores
from
'@/stores'
import
Logo
from
'./Logo'
// import { getCustomerServiceQrUrl } from "@/api/login";
...
...
@@ -138,7 +138,7 @@ export default {
Settings
,
},
computed
:
{
...
mapState
(
appStore
,
[
'avatar'
,
'name'
,
'permission_routes'
]),
...
mapState
(
stores
,
[
'avatar'
,
'name'
,
'permission_routes'
]),
},
mounted
()
{
// console.log(this.permission_routes)
...
...
vue3-lw-pc/src/layout/index.vue
View file @
1a10206
...
...
@@ -28,7 +28,7 @@ import CustomerService from './components/CustomerService'
import
ResizeMixin
from
'./mixin/ResizeHandler'
import
{
mapState
}
from
'pinia'
import
{
appStore
}
from
'@/stores'
import
stores
from
'@/stores'
export
default
{
name
:
'Layout'
,
...
...
@@ -43,7 +43,7 @@ export default {
mixins
:
[
ResizeMixin
],
computed
:
{
// ...mapGetters(['sidebar', 'avatar', 'device']),
...
mapState
(
appStore
,
{
...
mapState
(
stores
,
{
sidebar
:
(
state
)
=>
state
.
app
.
sidebar
,
device
:
(
state
)
=>
state
.
app
.
device
,
showSettings
:
(
state
)
=>
state
.
settings
.
showSettings
,
...
...
vue3-lw-pc/src/main.js
View file @
1a10206
...
...
@@ -133,11 +133,10 @@ initAMapApiLoader({
import
directive
from
'./directive'
app
.
use
(
directive
)
// import { createPinia, defineStore } from 'pinia'
import
store
,
{
stores
}
from
'@/stores'
import
stores
,
{
store
}
from
'@/stores'
app
.
use
(
store
s
)
app
.
use
(
store
)
app
.
use
(
router
)
app
.
config
.
globalProperties
.
$store
=
store
()
app
.
config
.
globalProperties
.
$store
=
store
s
()
app
.
mount
(
'#app'
)
vue3-lw-pc/src/stores/index.js
View file @
1a10206
...
...
@@ -6,9 +6,9 @@ import permission from './modules/permission'
import
settings
from
'./modules/settings'
import
getters
from
'./getters'
export
const
store
s
=
createPinia
()
export
const
store
=
createPinia
()
export
const
appStore
=
defineStore
(
'app'
,
{
export
default
defineStore
(
'app'
,
{
state
:
()
=>
({
app
:
{
...
app
.
state
},
user
:
{
...
user
.
state
},
...
...
@@ -25,5 +25,3 @@ export const appStore = defineStore('app', {
},
getters
,
})
export
default
appStore
vue3-lw-pc/src/utils/permission.js
View file @
1a10206
import
store
from
'@/stores'
import
store
s
from
'@/stores'
/**
* 字符权限校验
...
...
@@ -7,7 +7,7 @@ import store from '@/stores'
*/
export
function
checkPermi
(
value
)
{
if
(
value
&&
value
instanceof
Array
&&
value
.
length
>
0
)
{
const
permissions
=
store
&&
store
.
permissions
const
permissions
=
store
s
()
&&
stores
()
.
permissions
const
permissionDatas
=
value
const
hasPermission
=
permissions
.
some
((
permission
)
=>
{
...
...
vue3-lw-pc/src/utils/request.js
View file @
1a10206
import
axios
from
'axios'
import
{
ElNotification
as
Notification
,
ElMessageBox
as
MessageBox
,
ElMessage
as
Message
}
from
'element-plus'
import
_store
from
'@/stores'
import
stores
from
'@/stores'
import
{
getToken
,
setToken
}
from
'@/utils/auth'
import
errorCode
from
'@/utils/errorCode'
...
...
@@ -34,7 +34,7 @@ service.interceptors.request.use(
// 响应拦截器
service
.
interceptors
.
response
.
use
(
(
res
)
=>
{
let
store
=
_store
()
let
store
=
stores
()
// 未设置状态码则默认成功状态
const
code
=
res
.
data
.
code
||
200
// 获取错误信息
...
...
vue3-lw-pc/src/views/system/user/profile/userAvatar.vue
View file @
1a10206
...
...
@@ -53,7 +53,7 @@
</
template
>
<
script
>
import
store
from
'@/stores'
import
store
s
from
'@/stores'
import
'vue-cropper/dist/index.css'
import
{
VueCropper
}
from
'vue-cropper'
import
{
uploadAvatar
}
from
'@/api/system/user'
...
...
@@ -75,7 +75,7 @@ export default {
title
:
'修改头像'
,
options
:
{
outputType
:
'png'
,
// 裁剪生成图片的格式 jpeg, png, webp
img
:
store
().
avatar
,
//裁剪图片的地址
img
:
store
s
().
avatar
,
//裁剪图片的地址
autoCrop
:
true
,
// 是否默认生成截图框
autoCropWidth
:
200
,
// 默认生成截图框宽度
autoCropHeight
:
200
,
// 默认生成截图框高度
...
...
@@ -129,7 +129,7 @@ export default {
if
(
response
.
code
===
200
)
{
this
.
open
=
false
this
.
options
.
img
=
response
.
imgUrl
store
.
avatar
=
this
.
options
.
img
store
s
.
avatar
=
this
.
options
.
img
this
.
msgSuccess
(
'修改成功'
)
}
this
.
visible
=
false
...
...
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