File tree Expand file tree Collapse file tree 5 files changed +30
-10
lines changed Expand file tree Collapse file tree 5 files changed +30
-10
lines changed Original file line number Diff line number Diff line change 5
5
import { ref } from ' vue' ;
6
6
import CategorySecond from ' ../../components/CategorySecond.vue' ;
7
7
import { useRoute , useProps } from ' vue-router' ;
8
- import { setTitle } from ' ../../utils/utils.js' ;
9
- import { requestGetJson } from ' ../utils/utils.js' ;
10
- import { requestToYaml } from ' ../utils/utils.js' ;
8
+ import {
9
+ setTitle ,
10
+ requestGetJson ,
11
+ requestToYaml ,
12
+ handleCopyCodeSuccess
13
+ } from ' ../../utils/utils.js' ;
11
14
12
15
const props = useProps ([' mdPath' ]);
13
16
@@ -32,7 +35,7 @@ const newsDate = ref('');
32
35
:title =" yamlDoc['title']"
33
36
:right-text =" newsDate"
34
37
class =" absolute w-[calc(59.5vw-1px)]" />
35
- <v-md-preview :text =" mdRes" class =" pt-[50px]" ></ v-md-preview >
38
+ <v-md-preview :text =" mdRes" class =" pt-[50px]" @copy-code-success = " handleCopyCodeSuccess " / >
36
39
</div >
37
40
</template >
38
41
Original file line number Diff line number Diff line change @@ -9,6 +9,8 @@ import { install as VueMonacoEditorPlugin } from '@guolao/vue-monaco-editor';
9
9
import VMdPreview from '@kangc/v-md-editor/lib/preview' ;
10
10
import '@kangc/v-md-editor/lib/style/preview.css' ;
11
11
import vuepressTheme from '@kangc/v-md-editor/lib/theme/vuepress.js' ;
12
+ import createCopyCodePlugin from '@kangc/v-md-editor/lib/plugins/copy-code/index' ;
13
+ import '@kangc/v-md-editor/lib/plugins/copy-code/copy-code.css' ;
12
14
import '@kangc/v-md-editor/lib/theme/style/vuepress.css' ;
13
15
import './css/index.scss' ;
14
16
import './css/element-plus.scss' ;
@@ -47,6 +49,9 @@ VMdPreview.use(vuepressTheme, {
47
49
Prism
48
50
} ) ;
49
51
52
+ // copy code
53
+ VMdPreview . use ( createCopyCodePlugin ( ) ) ;
54
+
50
55
// highlightjs
51
56
import 'highlight.js/styles/stackoverflow-light.css' ;
52
57
// import hljs from 'highlight.js/lib/core';
Original file line number Diff line number Diff line change 2
2
import { ref } from ' vue' ;
3
3
import CategorySecond from ' ../../components/CategorySecond.vue' ;
4
4
import { useRoute } from ' vue-router' ;
5
- import { setTitle } from ' ../../utils/utils.js' ;
6
- import { requestToYaml , requestGetJson } from ' ../../utils/utils.js' ;
5
+ import {
6
+ setTitle ,
7
+ requestToYaml ,
8
+ requestGetJson ,
9
+ handleCopyCodeSuccess
10
+ } from ' ../../utils/utils.js' ;
7
11
8
12
const mdRes = ref ();
9
13
const route = useRoute ();
@@ -28,7 +32,7 @@ const newsDate = ref('');
28
32
:title =" yamlDoc['title']"
29
33
:right-text =" newsDate"
30
34
class =" absolute w-[calc(59.5vw-1px)]" />
31
- <v-md-preview :text =" mdRes" ></ v-md-preview >
35
+ <v-md-preview :text =" mdRes" @copy-code-success = " handleCopyCodeSuccess " / >
32
36
</div >
33
37
</template >
34
38
Original file line number Diff line number Diff line change 2
2
import { ref } from ' vue' ;
3
3
import CategorySecond from ' ../../components/CategorySecond.vue' ;
4
4
import { useRoute } from ' vue-router' ;
5
- import { setTitle } from ' ../../utils/utils.js' ;
6
- import { requestGetJson , requestToYaml } from ' ../../utils/utils.js' ;
5
+ import {
6
+ setTitle ,
7
+ requestGetJson ,
8
+ requestToYaml ,
9
+ handleCopyCodeSuccess
10
+ } from ' ../../utils/utils.js' ;
7
11
8
12
const mdRes = ref ();
9
13
const route = useRoute ();
@@ -29,7 +33,7 @@ const newsDate = ref('');
29
33
:title =" yamlDoc['title']"
30
34
:right-text =" newsDate"
31
35
class =" sticky top-0 z-1" />
32
- <v-md-preview :text =" mdRes" ></ v-md-preview >
36
+ <v-md-preview :text =" mdRes" @copy-code-success = " handleCopyCodeSuccess " / >
33
37
</div >
34
38
</template >
35
39
Original file line number Diff line number Diff line change @@ -140,3 +140,7 @@ export const useHighlightWatch = (switchHash) => {
140
140
switchHash ( ) ;
141
141
} ) ;
142
142
} ;
143
+
144
+ export const handleCopyCodeSuccess = ( ) => {
145
+ ElMessage . success ( '复制成功' ) ;
146
+ } ;
You can’t perform that action at this time.
0 commit comments