From 2cbcc62ec22aa7a97f2b41c8a08aaf958985a7bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E5=AE=81?= <18339727226@163.com> Date: Mon, 27 May 2024 11:43:19 +0800 Subject: [PATCH] =?UTF-8?q?=E5=85=A8=E5=B1=80=E6=97=B6=E9=97=B4=E8=B0=83?= =?UTF-8?q?=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package-lock.json | 2 +- package.json | 2 +- src/stores/index.ts | 11 +++++- src/stores/time/time.ts | 58 ++++++++++++++++++++++++++++++++ src/utils/common.ts | 20 +++++++++++ src/utils/index.ts | 2 +- src/views/header.vue | 11 ++++-- src/views/index/center-top.vue | 14 ++++---- src/views/index/index.vue | 34 +++++++++++++------ src/views/index/right-center.vue | 6 +++- 10 files changed, 136 insertions(+), 24 deletions(-) create mode 100644 src/stores/time/time.ts create mode 100644 src/utils/common.ts diff --git a/package-lock.json b/package-lock.json index 15c5ddd..400cdbe 100644 --- a/package-lock.json +++ b/package-lock.json @@ -5,7 +5,7 @@ "requires": true, "packages": { "": { - "name": "test", + "name": "test2", "version": "0.0.0", "dependencies": { "axios": "^1.6.8", diff --git a/package.json b/package.json index 8ec7634..e917acf 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "name": "test", + "name": "screen", "version": "0.0.0", "type": "module", "scripts": { diff --git a/src/stores/index.ts b/src/stores/index.ts index 7b3fdbb..27f5966 100644 --- a/src/stores/index.ts +++ b/src/stores/index.ts @@ -1 +1,10 @@ -export * from "./setting/setting" \ No newline at end of file +/* + * @Author: 张宁 18339727226@163.com + * @Date: 2024-05-22 08:40:56 + * @LastEditors: 张宁 18339727226@163.com + * @LastEditTime: 2024-05-27 10:28:20 + * @FilePath: \welcome-system-screen\src\stores\index.ts + * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE + */ +export * from "./setting/setting" +export * from "./time/time" \ No newline at end of file diff --git a/src/stores/time/time.ts b/src/stores/time/time.ts new file mode 100644 index 0000000..7d9ed11 --- /dev/null +++ b/src/stores/time/time.ts @@ -0,0 +1,58 @@ +/* + * @Author: 张宁 18339727226@163.com + * @Date: 2024-05-27 08:45:53 + * @LastEditors: 张宁 18339727226@163.com + * @LastEditTime: 2024-05-27 11:40:12 + * @FilePath: \welcome-system-screen\src\stores\time\time.ts + * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE + */ +import { ref } from "vue"; +import { defineStore } from "pinia"; +import {getCurrentDate} from "../../utils/common" +// import { storeToRefs } from 'pinia'; +// 创建一个Date对象,它将自动获取当前时间 +const now = new Date(); +// 获取当前日期 +const dates = getCurrentDate(); + +export const useTimeStore = defineStore("time", () => { + const years = ref(''); + const months = ref(''); + const nowDays = ref(dates); + const setYears = (year:any) => { + years.value = year; + }; + const setMounths = (month: any) => { + months.value = month; + } + const setNowDays = () => { + years.value = '' + months.value = '' + } + const computDate = computed(() => { + let dates = '今日' + if (years.value) { + dates = years.value + '年' + if (months.value) { + dates += months.value + '月' + } + } else { + dates = '今日' + } + return dates + }) + const nowTitle = computed(() => { + let titles = '当日' + if (years.value) { + titles = '当年' + if(months.value) { + titles = '当月' + } + }else{ + titles = '当日' + } + return titles + }) + + return { years, months,nowDays, setYears, setMounths,setNowDays,computDate,nowTitle }; +}); diff --git a/src/utils/common.ts b/src/utils/common.ts new file mode 100644 index 0000000..06d24ef --- /dev/null +++ b/src/utils/common.ts @@ -0,0 +1,20 @@ +/* + * @Author: 张宁 18339727226@163.com + * @Date: 2024-05-27 09:47:24 + * @LastEditors: 张宁 18339727226@163.com + * @LastEditTime: 2024-05-27 09:48:03 + * @FilePath: \welcome-system-screen\src\utils\common.ts + * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE + */ +export function getCurrentDate() { + const today = new Date(); + const year = today.getFullYear(); + let month:any = today.getMonth() + 1; // 月份从0开始,所以需加1 + let day:any = today.getDate(); + + // 将月份和日期转换为两位数 + month = month < 10 ? `0${month}` : month; + day = day < 10 ? `0${day}` : day; + + return `${year}-${month}-${day}`; + } \ No newline at end of file diff --git a/src/utils/index.ts b/src/utils/index.ts index f862011..bf86ede 100644 --- a/src/utils/index.ts +++ b/src/utils/index.ts @@ -1,2 +1,2 @@ export * from "./storage"; - +export * from "./common" diff --git a/src/views/header.vue b/src/views/header.vue index bac23e4..f4cf8e5 100644 --- a/src/views/header.vue +++ b/src/views/header.vue @@ -1,5 +1,8 @@ @@ -66,7 +71,7 @@ const clearSelect = () => {
-
选择今日
+
选择今日
diff --git a/src/views/index/center-top.vue b/src/views/index/center-top.vue index 38f55ad..5c2a625 100644 --- a/src/views/index/center-top.vue +++ b/src/views/index/center-top.vue @@ -1,5 +1,7 @@