Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
standalone-anyremote
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
qlintonger xeno
standalone-anyremote
Commits
218865ba
Commit
218865ba
authored
May 08, 2024
by
pangchong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 样式调整
parent
e19db2da
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
167 additions
and
7 deletions
+167
-7
src/hooks/eventBus.ts
+156
-0
src/views/remote/contacts/constants/data.config.ts
+11
-7
No files found.
src/hooks/eventBus.ts
0 → 100644
View file @
218865ba
import
{
cloneDeep
}
from
'lodash'
import
{
onUnmounted
,
onActivated
,
onDeactivated
,
getCurrentInstance
}
from
'vue'
interface
Event
{
readonly
uid
:
string
cb
:
(
data
:
any
)
=>
void
alive
?:
boolean
del
?:
boolean
only
?:
boolean
}
class
EventBus
{
protected
eventMap
:
{
[
key
:
string
]:
Array
<
Event
>
}
constructor
()
{
this
.
eventMap
=
{}
}
// 发布事件
emit
(
eventName
:
string
,
...
args
:
Array
<
any
>
)
{
let
eventList
=
this
.
eventMap
[
eventName
]
if
(
eventList
)
{
let
delIndexs
:
Array
<
number
>
=
[]
for
(
let
i
=
0
;
i
<
eventList
.
length
;
i
++
)
{
let
{
cb
,
del
=
false
,
only
=
false
,
alive
}
=
eventList
[
i
]
if
(
!
alive
)
{
continue
}
cb
(...(
args
as
[
any
]))
if
(
del
)
{
delIndexs
.
push
(
i
)
}
if
(
only
)
{
break
}
}
if
(
delIndexs
.
length
)
{
this
.
eventMap
[
eventName
]
=
eventList
.
filter
((
event
,
i
)
=>
{
return
!
delIndexs
.
includes
(
i
)
})
}
}
else
if
(
import
.
meta
.
env
.
MODE
===
'development'
)
{
console
.
warn
(
eventName
+
' not found!'
)
}
}
// 订阅事件
on
(
eventName
:
string
,
opt
:
Event
)
{
if
(
!
this
.
eventMap
[
eventName
])
{
this
.
eventMap
[
eventName
]
=
[]
}
let
uid
=
opt
.
uid
let
index
=
this
.
eventMap
[
eventName
].
findIndex
((
item
)
=>
{
return
uid
==
item
.
uid
})
if
(
index
>=
0
)
{
this
.
eventMap
[
eventName
].
splice
(
index
,
1
,
opt
)
return
}
this
.
eventMap
[
eventName
].
unshift
(
opt
)
}
// 取消订阅时间
off
(
eventName
:
string
,
uid
:
string
)
{
if
(
this
.
eventMap
[
eventName
])
{
let
index
=
this
.
eventMap
[
eventName
].
findIndex
((
item
)
=>
{
return
uid
==
item
.
uid
})
if
(
index
>=
0
)
{
this
.
eventMap
[
eventName
].
splice
(
index
,
1
)
if
(
!
this
.
eventMap
[
eventName
].
length
)
{
delete
this
.
eventMap
[
eventName
]
}
}
}
// console.log(this.eventMap)
}
// 只订阅一次
one
(
eventName
:
string
,
opt
:
Event
)
{
opt
.
del
=
true
return
this
.
on
(
eventName
,
opt
)
}
// 激活
enable
(
eventName
:
string
,
uid
:
string
)
{
if
(
this
.
eventMap
[
eventName
])
{
let
index
=
this
.
eventMap
[
eventName
].
findIndex
((
item
)
=>
{
return
uid
==
item
.
uid
})
if
(
index
==
0
)
{
this
.
eventMap
[
eventName
][
index
].
alive
=
true
}
else
if
(
index
>
0
)
{
const
newEvent
=
cloneDeep
(
this
.
eventMap
[
eventName
][
index
])
this
.
eventMap
[
eventName
].
splice
(
index
,
1
)
newEvent
.
alive
=
true
this
.
eventMap
[
eventName
].
unshift
(
newEvent
)
}
}
}
// 禁用
disable
(
eventName
:
string
,
uid
:
string
,
alive
:
boolean
=
false
)
{
if
(
this
.
eventMap
[
eventName
])
{
let
index
=
this
.
eventMap
[
eventName
].
findIndex
((
item
)
=>
{
return
uid
==
item
.
uid
})
if
(
index
>=
0
)
{
this
.
eventMap
[
eventName
][
index
].
alive
=
alive
}
}
}
}
const
eventBus
=
new
EventBus
()
export
function
useBusOn
(
eventName
:
string
,
cb
:
(
value
:
any
)
=>
void
,
opt
?:
{
del
?:
boolean
;
only
?:
boolean
;
alive
?:
boolean
})
{
const
currentInstance
=
getCurrentInstance
()
const
_opt
=
{
uid
:
String
(
currentInstance
?.
uid
),
cb
:
cb
as
(
value
:
any
)
=>
void
,
alive
:
true
,
...
opt
}
eventBus
.
on
(
eventName
,
_opt
)
onActivated
(()
=>
{
eventBus
.
on
(
eventName
,
_opt
)
})
function
off
()
{
eventBus
.
off
(
eventName
,
_opt
.
uid
)
}
onUnmounted
(()
=>
off
())
onDeactivated
(()
=>
{
off
()
})
return
{
off
,
enable
:
()
=>
{
eventBus
.
enable
(
eventName
,
_opt
.
uid
)
},
disable
:
()
=>
{
eventBus
.
disable
(
eventName
,
_opt
.
uid
)
}
}
}
export
function
useBusOne
(
eventName
:
string
,
cb
:
(
value
:
any
)
=>
void
,
opt
?:
{
del
?:
boolean
;
only
?:
boolean
})
{
let
_opt
=
{
...
opt
,
del
:
true
}
return
useBusOn
(
eventName
,
cb
,
_opt
)
}
export
function
useBusOff
(
eventName
:
string
)
{
const
currentInstance
=
getCurrentInstance
()
const
uid
=
String
(
currentInstance
?.
uid
)
eventBus
.
off
(
eventName
,
uid
)
}
export
function
useBusEmit
(
eventName
:
string
,
...
args
:
Array
<
any
>
)
{
eventBus
.
emit
(
eventName
,
...(
args
as
Array
<
any
>
))
}
src/views/remote/contacts/constants/data.config.ts
View file @
218865ba
...
@@ -6,23 +6,25 @@ export const eventListColumns: TableColumnData[] = [
...
@@ -6,23 +6,25 @@ export const eventListColumns: TableColumnData[] = [
title
:
'序号'
,
title
:
'序号'
,
align
:
'center'
,
align
:
'center'
,
dataIndex
:
'index'
,
dataIndex
:
'index'
,
slotName
:
'index'
slotName
:
'index'
,
width
:
80
},
},
{
{
title
:
'事件名称'
,
title
:
'事件名称'
,
dataIndex
:
'title'
,
dataIndex
:
'title'
,
slotName
:
'title'
,
slotName
:
'title'
width
:
400
},
},
{
{
title
:
'发起人'
,
title
:
'发起人'
,
dataIndex
:
'initiator'
,
dataIndex
:
'initiator'
,
slotName
:
'initiator'
slotName
:
'initiator'
,
width
:
150
},
},
{
{
title
:
'参与人'
,
title
:
'参与人'
,
dataIndex
:
'participants'
,
dataIndex
:
'participants'
,
slotName
:
'participants'
slotName
:
'participants'
,
width
:
210
},
},
// {
// {
// title: '职位',
// title: '职位',
...
@@ -32,13 +34,15 @@ export const eventListColumns: TableColumnData[] = [
...
@@ -32,13 +34,15 @@ export const eventListColumns: TableColumnData[] = [
{
{
title
:
'会议时间'
,
title
:
'会议时间'
,
dataIndex
:
'createdTime'
,
dataIndex
:
'createdTime'
,
slotName
:
'createdTime'
slotName
:
'createdTime'
,
width
:
180
},
},
{
{
title
:
'操作'
,
title
:
'操作'
,
align
:
'center'
,
align
:
'center'
,
dataIndex
:
'operation'
,
dataIndex
:
'operation'
,
slotName
:
'operation'
slotName
:
'operation'
,
width
:
150
}
}
// {
// {
// title: '结束时间',
// title: '结束时间',
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
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 comment