Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
S
sts网站
Project
Project
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
liyang
sts网站
Commits
b911d7f7
Commit
b911d7f7
authored
Dec 09, 2021
by
RuoYi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
自定义文字复制剪贴指令
parent
4644176e
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
56 additions
and
0 deletions
+56
-0
index.js
ruoyi-ui/src/directive/index.js
+2
-0
clipboard.js
ruoyi-ui/src/directive/module/clipboard.js
+54
-0
No files found.
ruoyi-ui/src/directive/index.js
View file @
b911d7f7
...
@@ -3,10 +3,12 @@ import hasPermi from './permission/hasPermi'
...
@@ -3,10 +3,12 @@ import hasPermi from './permission/hasPermi'
import
dialogDrag
from
'./dialog/drag'
import
dialogDrag
from
'./dialog/drag'
import
dialogDragWidth
from
'./dialog/dragWidth'
import
dialogDragWidth
from
'./dialog/dragWidth'
import
dialogDragHeight
from
'./dialog/dragHeight'
import
dialogDragHeight
from
'./dialog/dragHeight'
import
clipboard
from
'./module/clipboard'
const
install
=
function
(
Vue
)
{
const
install
=
function
(
Vue
)
{
Vue
.
directive
(
'hasRole'
,
hasRole
)
Vue
.
directive
(
'hasRole'
,
hasRole
)
Vue
.
directive
(
'hasPermi'
,
hasPermi
)
Vue
.
directive
(
'hasPermi'
,
hasPermi
)
Vue
.
directive
(
'clipboard'
,
clipboard
)
Vue
.
directive
(
'dialogDrag'
,
dialogDrag
)
Vue
.
directive
(
'dialogDrag'
,
dialogDrag
)
Vue
.
directive
(
'dialogDragWidth'
,
dialogDragWidth
)
Vue
.
directive
(
'dialogDragWidth'
,
dialogDragWidth
)
Vue
.
directive
(
'dialogDragHeight'
,
dialogDragHeight
)
Vue
.
directive
(
'dialogDragHeight'
,
dialogDragHeight
)
...
...
ruoyi-ui/src/directive/module/clipboard.js
0 → 100644
View file @
b911d7f7
/**
* v-clipboard 文字复制剪贴
* Copyright (c) 2021 ruoyi
*/
import
Clipboard
from
'clipboard'
export
default
{
bind
(
el
,
binding
,
vnode
)
{
switch
(
binding
.
arg
)
{
case
'success'
:
el
.
_vClipBoard_success
=
binding
.
value
;
break
;
case
'error'
:
el
.
_vClipBoard_error
=
binding
.
value
;
break
;
default
:
{
const
clipboard
=
new
Clipboard
(
el
,
{
text
:
()
=>
binding
.
value
,
action
:
()
=>
binding
.
arg
===
'cut'
?
'cut'
:
'copy'
});
clipboard
.
on
(
'success'
,
e
=>
{
const
callback
=
el
.
_vClipBoard_success
;
callback
&&
callback
(
e
);
});
clipboard
.
on
(
'error'
,
e
=>
{
const
callback
=
el
.
_vClipBoard_error
;
callback
&&
callback
(
e
);
});
el
.
_vClipBoard
=
clipboard
;
}
}
},
update
(
el
,
binding
)
{
if
(
binding
.
arg
===
'success'
)
{
el
.
_vClipBoard_success
=
binding
.
value
;
}
else
if
(
binding
.
arg
===
'error'
)
{
el
.
_vClipBoard_error
=
binding
.
value
;
}
else
{
el
.
_vClipBoard
.
text
=
function
()
{
return
binding
.
value
;
};
el
.
_vClipBoard
.
action
=
()
=>
binding
.
arg
===
'cut'
?
'cut'
:
'copy'
;
}
},
unbind
(
el
,
binding
)
{
if
(
!
el
.
_vClipboard
)
return
if
(
binding
.
arg
===
'success'
)
{
delete
el
.
_vClipBoard_success
;
}
else
if
(
binding
.
arg
===
'error'
)
{
delete
el
.
_vClipBoard_error
;
}
else
{
el
.
_vClipBoard
.
destroy
();
delete
el
.
_vClipBoard
;
}
}
}
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