-
Notifications
You must be signed in to change notification settings - Fork 5
feat: 新增 SkCountDown 倒计时组件 #47
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,73 @@ | ||
| <script setup lang="ts"> | ||
| import { ref } from 'vue' | ||
|
|
||
| const countDown = ref() | ||
| const time = ref(30 * 60 * 1000) // 30 minutes | ||
|
|
||
| function reset() { | ||
| countDown.value?.reset() | ||
| } | ||
|
|
||
| function start() { | ||
| countDown.value?.start() | ||
| } | ||
|
|
||
| function pause() { | ||
| countDown.value?.pause() | ||
| } | ||
|
|
||
| function onFinish() { | ||
| uni.showToast({ | ||
| title: '倒计时结束', | ||
| icon: 'none', | ||
| }) | ||
| } | ||
| </script> | ||
|
|
||
| <template> | ||
| <div class="flex flex-col items-center gap-4 p-4"> | ||
| <div class="text-lg font-bold mb-2"> | ||
| 基础用法 | ||
| </div> | ||
| <SkCountDown :time="time" @finish="onFinish" /> | ||
|
|
||
| <div class="text-lg font-bold mb-2 mt-4"> | ||
| 自定义格式 | ||
| </div> | ||
| <SkCountDown :time="time" format="HH:mm:ss" /> | ||
| <SkCountDown :time="time" format="DD天 HH时 mm分 ss秒" /> | ||
|
|
||
| <div class="text-lg font-bold mb-2 mt-4"> | ||
| 手动控制 | ||
| </div> | ||
| <SkCountDown | ||
| ref="countDown" | ||
| :time="5000" | ||
| :auto-start="false" | ||
| format="ss" | ||
| @finish="onFinish" | ||
| /> | ||
| <div class="flex gap-2"> | ||
| <SkButton size="mini" @click="start"> | ||
| 开始 | ||
| </SkButton> | ||
| <SkButton size="mini" @click="pause"> | ||
| 暂停 | ||
| </SkButton> | ||
| <SkButton size="mini" @click="reset"> | ||
| 重置 | ||
| </SkButton> | ||
| </div> | ||
|
|
||
| <div class="text-lg font-bold mb-2 mt-4"> | ||
| 自定义样式 | ||
| </div> | ||
| <SkCountDown :time="time"> | ||
| <template #default="{ hours, minutes, seconds }"> | ||
| <span class="block px-2 py-1 bg-blue-500 text-white rounded"> | ||
| {{ hours }}:{{ minutes }}:{{ seconds }} | ||
| </span> | ||
| </template> | ||
| </SkCountDown> | ||
| </div> | ||
| </template> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| <script setup lang="ts"> | ||
| import { ref } from 'vue'; | ||
|
|
||
| const countDown = ref(); | ||
| const time = ref(5000); | ||
|
|
||
| function start() { | ||
| countDown.value?.start(); | ||
| } | ||
|
|
||
| function pause() { | ||
| countDown.value?.pause(); | ||
| } | ||
|
|
||
| function reset() { | ||
| countDown.value?.reset(); | ||
| } | ||
|
|
||
| function onFinish() { | ||
| uni.showToast({ | ||
| title: '倒计时结束', | ||
| icon: 'none' | ||
| }); | ||
| } | ||
| </script> | ||
|
|
||
| <template> | ||
| <div class="flex flex-col gap-4 p-4"> | ||
| <div class="text-lg font-bold">手动控制</div> | ||
| <SkCountDown | ||
| ref="countDown" | ||
| :time="time" | ||
| :auto-start="false" | ||
| format="ss:SSS" | ||
| @finish="onFinish" | ||
| /> | ||
|
|
||
| <div class="flex gap-2 mt-4"> | ||
| <SkButton size="mini" @click="start">开始</SkButton> | ||
| <SkButton size="mini" @click="pause">暂停</SkButton> | ||
| <SkButton size="mini" @click="reset">重置</SkButton> | ||
| </div> | ||
| </div> | ||
| </template> | ||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,31 @@ | ||||||
| <script setup lang="ts"> | ||||||
| import { ref } from 'vue'; | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 修复代码风格问题。 ESLint 检测到多余的分号。为保持代码风格一致性,建议移除 import 语句末尾的分号。 应用以下修改: -import { ref } from 'vue';
+import { ref } from 'vue'📝 Committable suggestion
Suggested change
🧰 Tools🪛 ESLint[error] 2-2: Extra semicolon. (style/semi) 🤖 Prompt for AI Agents |
||||||
|
|
||||||
| const time = ref(30 * 60 * 1000); // 30 minutes | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 修复代码风格问题。 建议移除此行末尾的分号,与项目代码风格保持一致。 应用以下修改: -const time = ref(30 * 60 * 1000); // 30 minutes
+const time = ref(30 * 60 * 1000) // 30 minutes📝 Committable suggestion
Suggested change
🧰 Tools🪛 ESLint[error] 4-4: Extra semicolon. (style/semi) 🤖 Prompt for AI Agents |
||||||
| </script> | ||||||
|
|
||||||
| <template> | ||||||
| <div class="flex flex-col gap-4 p-4"> | ||||||
| <div class="text-lg font-bold">自定义样式</div> | ||||||
| <SkCountDown :time="time"> | ||||||
| <template #default="{ hours, minutes, seconds }"> | ||||||
| <span class="block px-2 py-1 bg-blue-500 text-white rounded"> | ||||||
| {{ hours }}:{{ minutes }}:{{ seconds }} | ||||||
| </span> | ||||||
| </template> | ||||||
| </SkCountDown> | ||||||
|
|
||||||
| <div class="text-lg font-bold mt-4">自定义块级样式</div> | ||||||
| <SkCountDown :time="time"> | ||||||
| <template #default="{ hours, minutes, seconds }"> | ||||||
| <div class="flex items-center gap-1"> | ||||||
| <span class="bg-red-500 text-white px-1 rounded">{{ hours }}</span> | ||||||
| <span>:</span> | ||||||
| <span class="bg-red-500 text-white px-1 rounded">{{ minutes }}</span> | ||||||
| <span>:</span> | ||||||
| <span class="bg-red-500 text-white px-1 rounded">{{ seconds }}</span> | ||||||
| </div> | ||||||
| </template> | ||||||
| </SkCountDown> | ||||||
| </div> | ||||||
| </template> | ||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| <script setup lang="ts"> | ||
| import { ref } from 'vue' | ||
|
|
||
| const time = ref(30 * 60 * 1000) // 30 minutes | ||
| </script> | ||
|
|
||
| <template> | ||
| <div class="flex flex-col gap-4 p-4"> | ||
| <div class="text-lg font-bold"> | ||
| 默认格式 (HH:mm:ss) | ||
| </div> | ||
| <SkCountDown :time="time" /> | ||
|
|
||
| <div class="text-lg font-bold mt-4"> | ||
| 自定义格式 (mm:ss) | ||
| </div> | ||
| <SkCountDown :time="time" format="mm:ss" /> | ||
|
|
||
| <div class="text-lg font-bold mt-4"> | ||
| 自定义格式 (DD天 HH时 mm分 ss秒) | ||
| </div> | ||
| <SkCountDown :time="2 * 24 * 60 * 60 * 1000 + time" format="DD天 HH时 mm分 ss秒" /> | ||
|
|
||
| <div class="text-lg font-bold mt-4"> | ||
| 带毫秒 (ss.S) | ||
| </div> | ||
| <SkCountDown :time="time" format="ss.S" /> | ||
|
|
||
| <div class="text-lg font-bold mt-4"> | ||
| 带毫秒 (ss.SS) | ||
| </div> | ||
| <SkCountDown :time="time" format="ss.SS" /> | ||
|
|
||
| <div class="text-lg font-bold mt-4"> | ||
| 带毫秒 (ss.SSS) | ||
| </div> | ||
| <SkCountDown :time="time" format="ss.SSS" /> | ||
| </div> | ||
| </template> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,7 @@ | ||
| { | ||
| "name": "@skiyee/workspace", | ||
| "type": "module", | ||
| "version": "1.1.0", | ||
| "version": "1.1.1", | ||
| "private": true, | ||
| "packageManager": "[email protected]", | ||
| "author": { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
修复代码风格问题。
ESLint 检测到多处额外的分号。请移除这些分号以符合项目的代码风格规范。
建议应用以下修改:
📝 Committable suggestion
🧰 Tools
🪛 ESLint
[error] 2-2: Extra semicolon.
(style/semi)
[error] 4-4: Extra semicolon.
(style/semi)
[error] 5-5: Extra semicolon.
(style/semi)
[error] 8-8: Extra semicolon.
(style/semi)
[error] 12-12: Extra semicolon.
(style/semi)
[error] 16-16: Extra semicolon.
(style/semi)
[error] 23-23: Extra semicolon.
(style/semi)
🤖 Prompt for AI Agents