Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
VueElementTemplate
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
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
黄瑜
VueElementTemplate
Commits
8d53ae12
Commit
8d53ae12
authored
Sep 27, 2017
by
Pan
Committed by
花裤衩
Sep 27, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add:add clipboard
parent
a1854124
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
110 additions
and
0 deletions
+110
-0
package.json
package.json
+1
-0
clipboard.js
src/directive/clipboard/clipboard.js
+49
-0
index.js
src/directive/clipboard/index.js
+13
-0
clipboard.svg
src/icons/svg/clipboard.svg
+1
-0
index.js
src/router/index.js
+8
-0
clipboard.js
src/utils/clipboard.js
+36
-0
index.vue
src/views/clipboard/index.vue
+2
-0
No files found.
package.json
View file @
8d53ae12
...
...
@@ -14,6 +14,7 @@
},
"dependencies"
:
{
"
axios
"
:
"
0.16.2
"
,
"
clipboard
"
:
"
1.7.1
"
,
"
codemirror
"
:
"
5.26.0
"
,
"
dropzone
"
:
"
5.1.0
"
,
"
echarts
"
:
"
3.6.2
"
,
...
...
src/directive/clipboard/clipboard.js
0 → 100644
View file @
8d53ae12
// Inspired by https://github.com/Inndy/vue-clipboard2
const
Clipboard
=
require
(
'clipboard'
)
if
(
!
Clipboard
)
{
throw
new
Error
(
'you shold npm install `clipboard` --save at first '
)
}
export
default
{
bind
(
el
,
binding
)
{
if
(
binding
.
arg
===
'success'
)
{
el
.
_v_clipboard_success
=
binding
.
value
}
else
if
(
binding
.
arg
===
'error'
)
{
el
.
_v_clipboard_error
=
binding
.
value
}
else
{
const
clipboard
=
new
Clipboard
(
el
,
{
text
()
{
return
binding
.
value
},
action
()
{
return
binding
.
arg
===
'cut'
?
'cut'
:
'copy'
}
})
clipboard
.
on
(
'success'
,
e
=>
{
const
callback
=
el
.
_v_clipboard_success
callback
&&
callback
(
e
)
// eslint-disable-line
})
clipboard
.
on
(
'error'
,
e
=>
{
const
callback
=
el
.
_v_clipboard_error
callback
&&
callback
(
e
)
// eslint-disable-line
})
el
.
_v_clipboard
=
clipboard
}
},
update
(
el
,
binding
)
{
if
(
binding
.
arg
===
'success'
)
{
el
.
_v_clipboard_success
=
binding
.
value
}
else
if
(
binding
.
arg
===
'error'
)
{
el
.
_v_clipboard_error
=
binding
.
value
}
else
{
el
.
_v_clipboard
.
text
=
function
()
{
return
binding
.
value
}
el
.
_v_clipboard
.
action
=
function
()
{
return
binding
.
arg
===
'cut'
?
'cut'
:
'copy'
}
}
},
unbind
(
el
,
binding
)
{
if
(
binding
.
arg
===
'success'
)
{
delete
el
.
_v_clipboard_success
}
else
if
(
binding
.
arg
===
'error'
)
{
delete
el
.
_v_clipboard_error
}
else
{
el
.
_v_clipboard
.
destroy
()
delete
el
.
_v_clipboard
}
}
}
src/directive/clipboard/index.js
0 → 100644
View file @
8d53ae12
import
Clipboard
from
'./clipboard'
const
install
=
function
(
Vue
)
{
Vue
.
directive
(
'Clipboard'
,
Clipboard
)
}
if
(
window
.
Vue
)
{
window
.
clipboard
=
Clipboard
Vue
.
use
(
install
);
// eslint-disable-line
}
Clipboard
.
install
=
install
export
default
Clipboard
src/icons/svg/clipboard.svg
0 → 100644
View file @
8d53ae12
<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg
t=
"1506419860538"
class=
"icon"
style=
""
viewBox=
"0 0 1024 1024"
version=
"1.1"
xmlns=
"http://www.w3.org/2000/svg"
p-id=
"4662"
xmlns:xlink=
"http://www.w3.org/1999/xlink"
width=
"64"
height=
"64"
><defs><style
type=
"text/css"
></style></defs><path
d=
"M438.857143 950.857143l512 0 0-365.714286-237.714286 0q-22.820571 0-38.838857-16.018286t-16.018286-38.838857l0-237.714286-219.428571 0 0 658.285714zM585.142857 128l0-36.571429q0-7.460571-5.412571-12.873143t-12.873143-5.412571l-402.285714 0q-7.460571 0-12.873143 5.412571t-5.412571 12.873143l0 36.571429q0 7.460571 5.412571 12.873143t12.873143 5.412571l402.285714 0q7.460571 0 12.873143-5.412571t5.412571-12.873143zM731.428571 512l170.861714 0-170.861714-170.861714 0 170.861714zM1024 585.142857l0 384q0 22.820571-16.018286 38.838857t-38.838857 16.018286l-548.571429 0q-22.820571 0-38.838857-16.018286t-16.018286-38.838857l0-91.428571-310.857143 0q-22.820571 0-38.838857-16.018286t-16.018286-38.838857l0-768q0-22.820571 16.018286-38.838857t38.838857-16.018286l621.714286 0q22.820571 0 38.838857 16.018286t16.018286 38.838857l0 187.465143q11.995429 7.460571 20.553143 16.018286l233.179429 233.179429q16.018286 16.018286 27.428571 43.446857t11.410286 50.322286z"
p-id=
"4663"
></path></svg>
\ No newline at end of file
src/router/index.js
View file @
8d53ae12
...
...
@@ -174,6 +174,14 @@ export const asyncRouterMap = [
noDropdown
:
true
,
children
:
[{
path
:
'index'
,
component
:
_import
(
'theme/index'
),
name
:
'换肤'
}]
},
{
path
:
'/clipboard'
,
component
:
Layout
,
redirect
:
'noredirect'
,
icon
:
'clipboard'
,
noDropdown
:
true
,
children
:
[{
path
:
'index'
,
component
:
_import
(
'clipboard/index'
),
name
:
'clipboard'
}]
},
{
path
:
'*'
,
redirect
:
'/404'
,
hidden
:
true
}
]
src/utils/clipboard.js
0 → 100644
View file @
8d53ae12
import
Clipboard
from
'clipboard'
import
Vue
from
'vue'
function
clipboardSuccess
()
{
Vue
.
prototype
.
$message
({
message
:
'复制成功'
,
type
:
'success'
,
duration
:
1500
})
}
function
clipboardError
()
{
Vue
.
prototype
.
$message
({
message
:
'复制失败'
,
type
:
'error'
})
}
export
default
function
handleClipboard
(
text
,
event
)
{
const
clipboard
=
new
Clipboard
(
event
.
target
,
{
text
:
()
=>
text
})
clipboard
.
on
(
'success'
,
()
=>
{
clipboardSuccess
()
clipboard
.
off
(
'error'
)
clipboard
.
off
(
'success'
)
clipboard
.
destroy
()
})
clipboard
.
on
(
'error'
,
()
=>
{
clipboardError
()
clipboard
.
off
(
'error'
)
clipboard
.
off
(
'success'
)
clipboard
.
destroy
()
})
clipboard
.
onClick
(
event
)
}
src/views/clipboard/index.vue
0 → 100644
View file @
8d53ae12
<
template
>
<div
class=
"app-container"
>
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