1-
2-
31<template >
4- <div class =" w-full p-2" >
5- <ElRow :gutter =" 0 " >
6- <ElCol
7- :xs =" {
8- span: 24 ,
9- } "
10- :sm =" {
11- span: 24 ,
12- } "
13- :md =" {
14- span: 24 ,
15- } "
16- :lg =" {
17- span: 12 ,
18- offset: 6 ,
19- } "
20- :xl =" {
21- span: 10 ,
22- offset: 7 ,
23- } "
24- >
25- <div class =" text-right p-2" >
26- <ElButton type="warning" size="small" @click =" handleClear "
27- >重置内容</ElButton
28- >
29- <ElButton
30- type="success"
31- size="small"
32- :disabled =" copyDisabled "
33- @click =" copy (content )"
34- ><span v-if =" !copied" >复制结果</span >
35- <span v-else >已复制</span ></ElButton
36- >
37- {{isDark}}
38- </div >
39- <div class =" flex justify-center items-center" >
40- <div class =" mx-2" >
41- <ElSelect
42- v-model =" type "
43- placeholder="Select"
44- size="large"
2+ <NCard :bordered =" false " class="card-class">
3+ <NGrid cols="24" item-responsive responsive="screen">
4+ <NGridItem span="24 m:12 l:12 " offset="0 m:6 l:6 ">
5+ <NSpace vertical>
6+ <NSpace justify="end" size="large">
7+ <NButton
8+ type="warning"
9+ size="small"
10+ @click =" handleClear "
11+ >重置内容</NButton
4512 >
46- <ElOption
47- v-for =" item in typeOptions "
48- :key =" item .value "
49- :label =" item .label + ' (' + item .value + ' )' "
50- :value =" item .value "
13+
14+ <NButton
15+ type="success"
16+ size="small"
17+ :disabled =" copyDisabled "
18+ @click =" handleCopy ()"
19+ ><span v-if =" !copied" >复制结果</span >
20+ <span v-else >已复制</span >
21+ </NButton >
22+ </NSpace >
23+ <NGrid cols="10">
24+ <NGridItem span="3 800:3 ">
25+ <NSelect
26+ v-model :value =" type "
27+ placeholder="类型"
28+ size="large"
29+ :options =" typeOptions "
5130 >
52- </ElOption >
53- </ElSelect >
54- </div >
31+ </NSelect >
32+ </NGridItem >
5533
56- <div class =" mx-2 w-full" >
57- <ElInput
58- v-model =" scope "
59- size="large"
60- placeholder="范围"
61- ></ElInput >
62- </div >
63- </div >
64- <div class =" p-2" >
65- <ElInput
66- v-model =" subject "
34+ <NGridItem span="6 800:6 " :offset =" 1 " >
35+ <NInput
36+ v-model :value =" scope "
37+ size="large"
38+ placeholder="范围(非必填)"
39+ ></NInput
40+ ></NGridItem >
41+ </NGrid >
42+ <NInput
43+ v-model :value =" subject "
6744 size="large"
68- placeholder="简短描述"
69- ></ElInput >
70- </div >
71- <div class =" p-2" >
72- <ElInput
73- v-model =" body "
45+ placeholder="简短描述(必填)"
46+ ></NInput >
47+
48+ <NInput
49+ v-model :value =" body "
7450 type="textarea"
7551 :rows =" 10 "
7652 size="large"
77- placeholder="具体内容"
78- ></ElInput >
79- </div >
80-
53+ placeholder="具体内容(非必填) "
54+ ></NInput >
55+ </NSpace >
56+ < NText depth="3">Ctrl + Shift + C 快速复制并关闭 </ NText >
8157 <!-- <ElFormItem label="最后">
82- <ElInput v-model="footer" type="textarea"></ElInput >
58+ <NInput v-model="footer" type="textarea"></NInput >
8359 </ElFormItem> -->
84-
85- <div class =" py-2" >
86- <div class =" text-right" ></div >
87- </div >
88- </ElCol >
89- </ElRow >
90- </div >
60+ </NGridItem >
61+ </NGrid >
62+ </NCard >
9163</template >
9264<script setup lang="ts">
93- import { ref , computed } from " vue" ;
65+ import { ref , computed , watch , onMounted , nextTick } from " vue" ;
9466import {
95- ElRow ,
96- ElCol ,
97- ElForm ,
98- ElFormItem ,
99- ElSelect ,
100- ElOption ,
101- ElButton ,
102- ElInput ,
103- } from " element-plus" ;
104- import { useClipboard } from " @vueuse/core" ;
105- import { usePreferredDark } from " @vueuse/core" ;
67+ NCard ,
68+ NGrid ,
69+ NGridItem ,
70+ NForm ,
71+ NFormItem ,
72+ NSelect ,
73+ NButton ,
74+ NInput ,
75+ NSpace ,
76+ NText ,
77+ useMessage ,
78+ } from " naive-ui" ;
79+ import { useClipboard , useMagicKeys } from " @vueuse/core" ;
80+ const message = useMessage ();
81+
82+ const keys = useMagicKeys ();
83+ const shiftCtrlC = keys [" Ctrl+Shift+C" ];
10684
107- const isDark = usePreferredDark ()
85+ watch (shiftCtrlC , (v ) => {
86+ if (v ) {
87+ handleCopy ();
88+ }
89+ });
10890const typeOptions = ref ([
10991 {
11092 value: " feat" ,
@@ -161,6 +143,19 @@ const content = computed(() => {
161143 }
162144 return commit ;
163145});
146+ const handleGetContent = () => {
147+ let commit = " " ;
148+ commit += type .value ;
149+ if (scope .value ) {
150+ commit += " (" + scope .value + " )" ;
151+ }
152+ commit += " : " + subject .value ;
153+
154+ if (body .value ) {
155+ commit += " \r\n\r\n " + body .value + " \r\n\r\n " ;
156+ }
157+ return commit ;
158+ };
164159const copyDisabled = computed ((): boolean => {
165160 return type .value && subject .value ? false : true ;
166161});
@@ -173,5 +168,28 @@ const handleClear = () => {
173168 body .value = " " ;
174169 type .value = typeOptions .value [0 ].value ;
175170};
171+ let utools = null ;
172+ onMounted (() => {
173+ if (window [" utools" ]) {
174+ utools = window [" utools" ];
175+ }
176+ });
177+ const handleCopy = async () => {
178+ if (! subject .value ) {
179+ message .error (" 必填项必填" );
180+ return ;
181+ }
182+ let content = handleGetContent ();
183+ await copy (content );
184+ message .success (" 复制成功" );
185+ nextTick (() => {
186+ utools && utools .hideMainWindow ();
187+ });
188+ };
176189 </script >
177-
190+ <style scoped>
191+ .card-class {
192+ width : 100% ;
193+ height : 100vh ;
194+ }
195+ </style >
0 commit comments