|
1 | 1 | <script lang="ts" setup>
|
2 |
| -import { QuillEditor } from '@vueup/vue-quill' |
3 |
| -import { appWindow } from '@tauri-apps/api/window' |
4 |
| -import { isRegistered, register, unregister } from '@tauri-apps/api/globalShortcut' |
| 2 | +import { saveAs } from 'file-saver' |
5 | 3 | import { mainStore } from '../store'
|
| 4 | +import { useMessage } from 'naive-ui' |
6 | 5 | import { pdfExporter } from 'quill-to-pdf'
|
7 | 6 | import * as wordExporter from 'quill-to-word'
|
8 |
| -import { saveAs } from 'file-saver' |
9 |
| -import { useMessage } from 'naive-ui' |
| 7 | +import { QuillEditor } from '@vueup/vue-quill' |
| 8 | +import { appWindow } from '@tauri-apps/api/window' |
| 9 | +import { isRegistered, register, unregister } from '@tauri-apps/api/globalShortcut' |
10 | 10 | import '@vueup/vue-quill/dist/vue-quill.snow.css'
|
11 | 11 |
|
12 | 12 | const store = mainStore()
|
@@ -96,6 +96,31 @@ watch([() => store.opacity, () => store.theme], () => {
|
96 | 96 | text.value.style.backgroundColor = `rgba(${themeColor.value}, ${themeColor.value}, ${themeColor.value}, ${store.opacity / 100})`
|
97 | 97 | })
|
98 | 98 |
|
| 99 | +watch(() => store.content.ops.ops, () => { |
| 100 | + let arr: any = [] |
| 101 | + let count = 0 |
| 102 | + store.content.ops.ops.forEach((arrItem: any) => { |
| 103 | + if(typeof(arrItem.insert) === 'string') { |
| 104 | + if(!arrItem.insert.endsWith('\n')) { |
| 105 | + arr.push(arrItem.insert.split(' ')) |
| 106 | + } else { |
| 107 | + arr.push(arrItem.insert.split('\n')) |
| 108 | + } |
| 109 | + } |
| 110 | + }) |
| 111 | + arr.forEach((arrItem: any) => { |
| 112 | + arrItem.forEach((item: any) => { |
| 113 | + const words = item.split(" ") |
| 114 | + words.forEach((word: any) => { |
| 115 | + if(word.length > 0) { |
| 116 | + count++ |
| 117 | + } |
| 118 | + }) |
| 119 | + }) |
| 120 | + }) |
| 121 | + store.wordCount = count |
| 122 | +}) |
| 123 | +
|
99 | 124 | appWindow.listen("tauri://blur", () => {
|
100 | 125 | shortcutUnregister()
|
101 | 126 | })
|
@@ -123,6 +148,7 @@ await shortcutRegister()
|
123 | 148 | @changeSpellcheck="changeSpellcheck()"
|
124 | 149 | />
|
125 | 150 | <div :class="{ 'dark': store.theme === 'dark' }">
|
| 151 | + <div class="fixed right-1 mt-1 z-20 text-size-[12px] opacity-70 text-dark-900 dark:text-light-500 transition-colors duration-150 ease-linear">{{ store.wordCount }}</div> |
126 | 152 | <div v-show="settings" class="absolute z-10 w-8/10 h-20px bottom-100px transform translate-x-5vh">
|
127 | 153 | <n-h2 class="text-dark-900 dark:text-light-50">Opacity</n-h2>
|
128 | 154 | <n-slider :theme-overrides="store.themeOverrides" v-model:value="store.opacity" :step="1"></n-slider>
|
|
0 commit comments