@@ -10,13 +10,9 @@ import { useMessage } from 'naive-ui'
10
10
import ' @vueup/vue-quill/dist/vue-quill.snow.css'
11
11
12
12
const store = mainStore ()
13
- const alwaysTop = ref (false )
14
- const opacity = ref (50 )
15
13
const text = ref <any >(null )
16
14
const settings = ref (false )
17
- const theme = ref (' dark' )
18
15
const themeColor = ref (0 )
19
- const exportName = ref (' export' )
20
16
const toolbar = ref <any >(null )
21
17
const shortcutModal = ref (false )
22
18
const exportModal_1 = ref (false )
@@ -44,19 +40,19 @@ const themeOverrides = {
44
40
}
45
41
46
42
const changeTheme = () => {
47
- themeColor .value = theme . value === ' dark' ? 255 : 0
48
- theme . value = theme . value === ' dark' ? ' light' : ' dark'
43
+ themeColor .value = store . theme === ' dark' ? 255 : 0
44
+ store . theme = store . theme === ' dark' ? ' light' : ' dark'
49
45
}
50
46
51
47
const changeAlwaysTop = () => {
52
- alwaysTop . value = ! alwaysTop . value
53
- appWindow .setAlwaysOnTop (alwaysTop . value )
48
+ store . alwaysTop = ! store . alwaysTop
49
+ appWindow .setAlwaysOnTop (store . alwaysTop )
54
50
}
55
51
56
52
const export2PDF = async () => {
57
53
try {
58
54
const pdfBlob = await pdfExporter .generatePdf (store .content .ops )
59
- saveAs (pdfBlob , ` ${exportName . value }.pdf ` )
55
+ saveAs (pdfBlob , ` ${store . exportName }.pdf ` )
60
56
exportModal_1 .value = false
61
57
} catch (e ) {
62
58
message .error (' PDF export failed, file is empty' )
@@ -66,7 +62,7 @@ const export2PDF = async () => {
66
62
const export2Word = async () => {
67
63
try {
68
64
const wordBlob: any = await wordExporter .generateWord (store .content .ops , {exportAs: ' blob' })
69
- saveAs (wordBlob , ` ${exportName . value }.docx ` )
65
+ saveAs (wordBlob , ` ${store . exportName }.docx ` )
70
66
exportModal_2 .value = false
71
67
} catch (e ) {
72
68
message .error (' Word export failed, file is empty' )
@@ -75,11 +71,11 @@ const export2Word = async () => {
75
71
76
72
onMounted (() => {
77
73
toolbar .value .style .backgroundColor = ` rgba(255, 255, 255, 0.95) `
78
- text .value .style .backgroundColor = ` rgba(0, 0, 0, ${opacity . value / 100 }) `
74
+ text .value .style .backgroundColor = ` rgba(0, 0, 0, ${store . opacity / 100 }) `
79
75
})
80
76
81
- watch ([opacity , theme ], () => {
82
- text .value .style .backgroundColor = ` rgba(${themeColor .value }, ${themeColor .value }, ${themeColor .value }, ${opacity . value / 100 }) `
77
+ watch ([() => store . opacity , () => store . theme ], () => {
78
+ text .value .style .backgroundColor = ` rgba(${themeColor .value }, ${themeColor .value }, ${themeColor .value }, ${store . opacity / 100 }) `
83
79
})
84
80
85
81
appWindow .listen (" tauri://blur" , () => {
@@ -155,22 +151,22 @@ await shortcutRegister()
155
151
</div >
156
152
<div
157
153
:class =" {
158
- 'dark': theme === 'dark',
154
+ 'dark': store. theme === 'dark',
159
155
}"
160
156
>
161
157
<div v-show =" settings" class =" absolute z-10 w-8/10 h-20px bottom-100px transform translate-x-5vh" >
162
158
<n-h2 class =" text-dark-900 dark:text-light-50" >Opacity</n-h2 >
163
- <n-slider :theme-overrides =" themeOverrides" v-model:value =" opacity" :step =" 1" ></n-slider >
159
+ <n-slider :theme-overrides =" themeOverrides" v-model:value =" store. opacity" :step =" 1" ></n-slider >
164
160
</div >
165
161
<n-tooltip placement =" top-start" trigger =" hover" >
166
162
<template #trigger >
167
163
<i-mdi:arrow-top-left-thin-circle-outline
168
164
class =" fixed z-10 right-10px bottom-135px text-size-35px transition-colors duration-150 ease-linear"
169
165
:class =" {
170
- 'text-green-500': alwaysTop,
171
- 'text-dark-900': !alwaysTop,
172
- 'dark:text-light-50': !alwaysTop,
173
- 'dark:text-green-500': alwaysTop
166
+ 'text-green-500': store. alwaysTop,
167
+ 'text-dark-900': !store. alwaysTop,
168
+ 'dark:text-light-50': !store. alwaysTop,
169
+ 'dark:text-green-500': store. alwaysTop
174
170
}"
175
171
@click =" changeAlwaysTop()"
176
172
/>
@@ -199,7 +195,7 @@ await shortcutRegister()
199
195
preset =" card"
200
196
title =" Save as"
201
197
>
202
- <n-input type =" text" v-model:value =" exportName" ></n-input >
198
+ <n-input type =" text" v-model:value =" store. exportName" ></n-input >
203
199
<div class =" text-size-[30px] flex justify-end p-2" >
204
200
<button :theme-overridess =" themeOverrides" ><i-mdi:file-pdf class =" m-[0.7rem]" @click =" export2PDF()" ></i-mdi:file-pdf ></button >
205
201
<button :theme-overridess =" themeOverrides" ><i-mdi:file-word class =" m-[0.7rem]" @click =" export2Word()" ></i-mdi:file-word ></button >
@@ -212,7 +208,7 @@ await shortcutRegister()
212
208
preset =" card"
213
209
title =" Save as"
214
210
>
215
- <n-input type =" text" v-model:value =" exportName" ></n-input >
211
+ <n-input type =" text" v-model:value =" store. exportName" ></n-input >
216
212
<div class =" text-size-[30px] flex justify-end p-2" >
217
213
<button :theme-overridess =" themeOverrides" ><i-mdi:file-pdf class =" m-[0.7rem]" @click =" export2PDF()" ></i-mdi:file-pdf ></button >
218
214
</div >
@@ -224,7 +220,7 @@ await shortcutRegister()
224
220
preset =" card"
225
221
title =" Save as"
226
222
>
227
- <n-input type =" text" v-model:value =" exportName" ></n-input >
223
+ <n-input type =" text" v-model:value =" store. exportName" ></n-input >
228
224
<div class =" text-size-[30px] flex justify-end p-2" >
229
225
<button :theme-overridess =" themeOverrides" ><i-mdi:file-word class =" m-[0.7rem]" @click =" export2Word()" ></i-mdi:file-word ></button >
230
226
</div >
0 commit comments