Browse Source

chore: 增加配置项

nmtuan 1 year ago
parent
commit
fae09ffc29
4 changed files with 62 additions and 17 deletions
  1. 4 3
      app.vue
  2. 12 9
      components/clock/board.vue
  3. 19 5
      components/header/index.vue
  4. 27 0
      stores/setting.ts

+ 4 - 3
app.vue

@@ -18,18 +18,19 @@
             </div>
             </div>
         </div>
         </div>
         <div class="w-full px-[4px] mt-[26px]">
         <div class="w-full px-[4px] mt-[26px]">
-            <div class="px-[4px]">
+            <div v-if="settingStore.showTimeLine" class="px-[4px]">
                 <TimeLine></TimeLine>
                 <TimeLine></TimeLine>
             </div>
             </div>
             <div class="my-[4px]">
             <div class="my-[4px]">
-                <DayLine></DayLine>
-                <MonthLine></MonthLine>
+                <DayLine v-if="settingStore.showDayLine"></DayLine>
+                <MonthLine v-if="settingStore.showMonthLine"></MonthLine>
             </div>
             </div>
         </div>
         </div>
     </div>
     </div>
 </template>
 </template>
 <script setup>
 <script setup>
 const dateStore = useDateStore()
 const dateStore = useDateStore()
+const settingStore = useSettingStore()
 let dt
 let dt
 
 
 onMounted(() => {
 onMounted(() => {

+ 12 - 9
components/clock/board.vue

@@ -2,22 +2,25 @@
  * @Author: NMTuan
  * @Author: NMTuan
  * @Email: NMTuan@qq.com
  * @Email: NMTuan@qq.com
  * @Date: 2024-02-18 11:48:34
  * @Date: 2024-02-18 11:48:34
- * @LastEditTime: 2024-02-19 22:17:35
+ * @LastEditTime: 2024-02-22 10:23:06
  * @LastEditors: NMTuan
  * @LastEditors: NMTuan
  * @Description: 
  * @Description: 
- * @FilePath: /timeNow/components/clock/board.vue
+ * @FilePath: \timeNow\components\clock\board.vue
 -->
 -->
 <template>
 <template>
-    <div
-        class="text-zinc-200 text-[22vw] leading-[24vw] text-center font-digital-dismay"
-    >
-        <span>{{ dateStore.hour }}</span>
-        <span>:</span>
+    <div class="text-zinc-200 text-[22vw] leading-[24vw] text-center font-digital-dismay">
+        <span>{{ settingStore.hour24 ? dateStore.hour : dateStore.hour % 12 }}</span>
+        <span class="transition-all"
+            :class="[settingStore.flicker && (dateStore.second % 2 === 0 ? 'opacity-1' : 'opacity-0')]">:</span>
         <span>{{ dateStore.minute }}</span>
         <span>{{ dateStore.minute }}</span>
-        <span>:</span>
-        <span>{{ dateStore.second }}</span>
+        <template v-if="settingStore.showSecond">
+            <span class="transition-all"
+                :class="[settingStore.flicker && (dateStore.second % 2 === 0 ? 'opacity-1' : 'opacity-0')]">:</span>
+            <span>{{ dateStore.second }}</span>
+        </template>
     </div>
     </div>
 </template>
 </template>
 <script setup>
 <script setup>
 const dateStore = useDateStore()
 const dateStore = useDateStore()
+const settingStore = useSettingStore()
 </script>
 </script>

+ 19 - 5
components/header/index.vue

@@ -2,7 +2,7 @@
  * @Author: NMTuan
  * @Author: NMTuan
  * @Email: NMTuan@qq.com
  * @Email: NMTuan@qq.com
  * @Date: 2024-02-20 16:11:39
  * @Date: 2024-02-20 16:11:39
- * @LastEditTime: 2024-02-20 21:22:21
+ * @LastEditTime: 2024-02-22 11:53:57
  * @LastEditors: NMTuan
  * @LastEditors: NMTuan
  * @Description: 
  * @Description: 
  * @FilePath: \timeNow\components\header\index.vue
  * @FilePath: \timeNow\components\header\index.vue
@@ -15,8 +15,8 @@
         <ClientOnly>
         <ClientOnly>
             <HeaderToggleFullScreen></HeaderToggleFullScreen>
             <HeaderToggleFullScreen></HeaderToggleFullScreen>
         </ClientOnly>
         </ClientOnly>
-        <HeaderIcon @click="optionsVisiable = true" name="i-ri-equalizer-line"></HeaderIcon>
         <!-- <HeaderIcon name="i-ri-twitter-line"></HeaderIcon> -->
         <!-- <HeaderIcon name="i-ri-twitter-line"></HeaderIcon> -->
+        <HeaderIcon @click="optionsVisiable = true" name="i-ri-equalizer-line"></HeaderIcon>
         <USlideover v-model="optionsVisiable">
         <USlideover v-model="optionsVisiable">
             <UCard class="flex flex-col flex-1"
             <UCard class="flex flex-col flex-1"
                 :ui="{ body: { base: 'flex-1' }, ring: '', divide: 'divide-y divide-zinc-100 dark:divide-zinc-800' }">
                 :ui="{ body: { base: 'flex-1' }, ring: '', divide: 'divide-y divide-zinc-100 dark:divide-zinc-800' }">
@@ -28,14 +28,28 @@
                         <UButton color="gray" variant="ghost" icon="i-ri-close-line" @click="optionsVisiable = false" />
                         <UButton color="gray" variant="ghost" icon="i-ri-close-line" @click="optionsVisiable = false" />
                     </div>
                     </div>
                 </template>
                 </template>
-                <p v-for="i in 100">{{ i }}</p>
-
+                <UFormGroup class="mb-6">
+                    <template #label>
+                        <div class="text-base">表盘</div>
+                    </template>
+                    <UCheckbox class="my-4" v-model="settingStore.hour24" label="24小时制"></UCheckbox>
+                    <UCheckbox class="my-4" v-model="settingStore.showSecond" label="显示秒数"></UCheckbox>
+                    <UCheckbox class="my-4" v-model="settingStore.flicker" label="冒号闪动"></UCheckbox>
+                </UFormGroup>
+                <UFormGroup class="mb-6">
+                    <template #label>
+                        <div class="text-base">底部</div>
+                    </template>
+                    <UCheckbox class="my-4" v-model="settingStore.showTimeLine" label="显示日进度"></UCheckbox>
+                    <UCheckbox class="my-4" v-model="settingStore.showDayLine" label="显示月进度"></UCheckbox>
+                    <UCheckbox class="my-4" v-model="settingStore.showMonthLine" label="显示年进度"></UCheckbox>
+                </UFormGroup>
             </UCard>
             </UCard>
         </USlideover>
         </USlideover>
     </div>
     </div>
 </template>
 </template>
 <script setup>
 <script setup>
-
+const settingStore = useSettingStore()
 const optionsVisiable = ref(false)
 const optionsVisiable = ref(false)
 
 
 </script>
 </script>

+ 27 - 0
stores/setting.ts

@@ -0,0 +1,27 @@
+/*
+ * @Author: NMTuan
+ * @Email: NMTuan@qq.com
+ * @Date: 2024-02-21 21:47:50
+ * @LastEditTime: 2024-02-21 21:56:15
+ * @LastEditors: NMTuan
+ * @Description:
+ * @FilePath: \timeNow\stores\setting.ts
+ */
+import { defineStore } from 'pinia'
+
+export const useSettingStore = defineStore('setting', () => {
+    const hour24 = ref(true) // 24小时制
+    const showSecond = ref(true) // 显示秒数
+    const flicker = ref(false) // 闪烁冒号
+    const showMonthLine = ref(true)
+    const showDayLine = ref(true)
+    const showTimeLine = ref(true)
+    return {
+        hour24,
+        showSecond,
+        flicker,
+        showMonthLine,
+        showDayLine,
+        showTimeLine
+    }
+})