From 753018dda3b4053f0079ecf790114c5d59161433 Mon Sep 17 00:00:00 2001 From: npmrun <1549469775@qq.com> Date: Tue, 12 May 2026 23:32:27 +0800 Subject: [PATCH] add --- assets/style/common.scss | 9 +- components/x-calendar/context.uts | 5 + components/x-calendar/util.uts | 103 +++++++++ components/x-calendar/x-calendar--item.uvue | 15 ++ components/x-calendar/x-calendar.uvue | 63 +++++ components/x-editor/x-editor.uvue | 308 +++++++++++++++++++++++++ components/x-mask/x-mask.uvue | 30 +++ components/x-navbar/x-navbar.uvue | 9 +- components/x-page/x-page.uvue | 2 + components/x-slide-menu/x-slide-menu.uvue | 66 ++++++ hooks/createContext/Consumer.uvue | 26 +++ hooks/createContext/Provider - 副本.uvue | 17 ++ hooks/createContext/Provider.uvue | 21 ++ hooks/createContext/createContext - 副本.uts | 51 ++++ hooks/createContext/createContext.uts | 47 ++++ main.uts | 2 +- pages.json | 6 + pages/index/index - 副本.uvue | 233 +++++++++++++++++++ pages/index/index.uvue | 112 +-------- 19 files changed, 1002 insertions(+), 123 deletions(-) create mode 100644 components/x-calendar/context.uts create mode 100644 components/x-calendar/util.uts create mode 100644 components/x-calendar/x-calendar--item.uvue create mode 100644 components/x-calendar/x-calendar.uvue create mode 100644 components/x-editor/x-editor.uvue create mode 100644 components/x-mask/x-mask.uvue create mode 100644 components/x-slide-menu/x-slide-menu.uvue create mode 100644 hooks/createContext/Consumer.uvue create mode 100644 hooks/createContext/Provider - 副本.uvue create mode 100644 hooks/createContext/Provider.uvue create mode 100644 hooks/createContext/createContext - 副本.uts create mode 100644 hooks/createContext/createContext.uts create mode 100644 pages/index/index - 副本.uvue diff --git a/assets/style/common.scss b/assets/style/common.scss index 17c6d3e..f58ab30 100644 --- a/assets/style/common.scss +++ b/assets/style/common.scss @@ -1,6 +1,5 @@ -@font-face { - font-family: ZhanKuKuaiLeTi; - src: url('@/assets/fonts/ZhanKuKuaiLeTi2016XiuDingBan-1.ttf'); -} - \ No newline at end of file + @font-face { + font-family: ZhanKuKuaiLeTi; + src: url('@/assets/fonts/ZhanKuKuaiLeTi2016XiuDingBan-1.ttf'); + } \ No newline at end of file diff --git a/components/x-calendar/context.uts b/components/x-calendar/context.uts new file mode 100644 index 0000000..ff38e34 --- /dev/null +++ b/components/x-calendar/context.uts @@ -0,0 +1,5 @@ +import { createContext } from "@/hooks/createContext/createContext.uts" + +const key = "x-calendar--item" +const { Provider, Consumer, useContext } = createContext(key) +export { Provider, Consumer, useContext } diff --git a/components/x-calendar/util.uts b/components/x-calendar/util.uts new file mode 100644 index 0000000..2e482a6 --- /dev/null +++ b/components/x-calendar/util.uts @@ -0,0 +1,103 @@ + +export function getWeek(time : Date) { + let week = time.getDay() // 当前周几 + // week = (week - 1) < 0 ? 0 : (week - 1) + if(week == 0) week = 7 // 0 表示周日 + return week +} + +export function getCurrentMonth(time : Date) : number { + let month = time.getMonth() + 1 + return month +} + +export function getLastMonth(curDate : Date) { + let lastDate = new Date() + lastDate.setMonth(curDate.getMonth() - 1) + return lastDate +} + +export function getLastMonthDay(curDate : Date, offset : number) { + let lastDate = new Date(curDate.getTime()) + lastDate.setHours(-24 * offset); + return lastDate +} + +export function getNextMonthDay(curDate : Date, offset : number) { + let lastDate = new Date(curDate.getTime()) + lastDate.setHours(24 * offset); + return lastDate +} + + +export function format(time : Date) { + return `${time.getFullYear()}-${time.getMonth() + 1}-${time.getDate()}` +} + +export function formatFull(time : Date) { + const year = (time.getFullYear()) + "" + const month = (time.getMonth() + 1) + "" + const date = (time.getDate()) + "" + const hour = (time.getHours()) + "" + const minute = (time.getMinutes()) + "" + const second = (time.getSeconds()) + "" + return `${year}-${month.padStart(2, '0')}-${date.padStart(2, '0')} ${hour.padStart(2, '0')}:${minute.padStart(2, '0')}:${second.padStart(2, '0')}` +} + +// 获取当前月份应该有多少天 +export function getCurMonthDayNum(time : Date) : number { + let day = 31; + let month = time.getMonth() + 1 + let year = time.getFullYear() + if ([1, 3, 5, 7, 8, 10, 12].indexOf(month) != -1) { + day = 31; + } else if ([4, 6, 9, 11].indexOf(month) != -1) { + day = 30; + } else if (year % 4 == 0) { + day = 29 + } else { + day = 28 + } + return day +} + +export function generateDate(_nowDate : Date | string | number, format : (date : Date) => T = (v : Date) => (v as T)) { + if (typeof _nowDate === "string" || typeof _nowDate === "number") { + _nowDate = new Date(_nowDate as string) + } + + const allDate : T[] = [] + + let firstDate = new Date(_nowDate.getTime()) + firstDate.setDate(1) + const firstWeek = getWeek(firstDate) + console.log(firstDate.getTime()); + for (var i = 1; i < firstWeek; i++) { + const date = getLastMonthDay(firstDate, i) + allDate.unshift(format(new Date(date.getTime())) as T) + } + + let curDate = new Date(_nowDate.getTime()) + const allDay = getCurMonthDayNum(curDate) + for (var i = 1; i <= getCurMonthDayNum(curDate); i++) { + curDate.setDate(i) + allDate.push(format(new Date(curDate.getTime())) as T) + } + + let endDate = new Date(_nowDate.getTime()) + endDate.setDate(allDay) + const endWeek = 7 - getWeek(endDate) + for (var i = 1; i <= endWeek; i++) { + const date = getNextMonthDay(endDate, i) + allDate.push(format(new Date(date.getTime())) as T) + } + // 至少6行 + if (~~(allDate.length / 7) < 6) { + for (var i = endWeek + 1; i < endWeek + 1 + 7; i++) { + const date = getNextMonthDay(endDate, i) + allDate.push(format(new Date(date.getTime())) as T) + } + } + + return allDate +} \ No newline at end of file diff --git a/components/x-calendar/x-calendar--item.uvue b/components/x-calendar/x-calendar--item.uvue new file mode 100644 index 0000000..6269396 --- /dev/null +++ b/components/x-calendar/x-calendar--item.uvue @@ -0,0 +1,15 @@ + + + + + \ No newline at end of file diff --git a/components/x-calendar/x-calendar.uvue b/components/x-calendar/x-calendar.uvue new file mode 100644 index 0000000..4589d7c --- /dev/null +++ b/components/x-calendar/x-calendar.uvue @@ -0,0 +1,63 @@ + + + + + \ No newline at end of file diff --git a/components/x-editor/x-editor.uvue b/components/x-editor/x-editor.uvue new file mode 100644 index 0000000..95078f1 --- /dev/null +++ b/components/x-editor/x-editor.uvue @@ -0,0 +1,308 @@ + + + + + \ No newline at end of file diff --git a/components/x-mask/x-mask.uvue b/components/x-mask/x-mask.uvue new file mode 100644 index 0000000..0a3b94e --- /dev/null +++ b/components/x-mask/x-mask.uvue @@ -0,0 +1,30 @@ + + + + + \ No newline at end of file diff --git a/components/x-navbar/x-navbar.uvue b/components/x-navbar/x-navbar.uvue index f4a83cc..9a9fec7 100644 --- a/components/x-navbar/x-navbar.uvue +++ b/components/x-navbar/x-navbar.uvue @@ -32,9 +32,6 @@ \ No newline at end of file diff --git a/hooks/createContext/Consumer.uvue b/hooks/createContext/Consumer.uvue new file mode 100644 index 0000000..35380fb --- /dev/null +++ b/hooks/createContext/Consumer.uvue @@ -0,0 +1,26 @@ + + + + + \ No newline at end of file diff --git a/hooks/createContext/Provider - 副本.uvue b/hooks/createContext/Provider - 副本.uvue new file mode 100644 index 0000000..324ae05 --- /dev/null +++ b/hooks/createContext/Provider - 副本.uvue @@ -0,0 +1,17 @@ + + + + + \ No newline at end of file diff --git a/hooks/createContext/Provider.uvue b/hooks/createContext/Provider.uvue new file mode 100644 index 0000000..2157780 --- /dev/null +++ b/hooks/createContext/Provider.uvue @@ -0,0 +1,21 @@ + diff --git a/hooks/createContext/createContext - 副本.uts b/hooks/createContext/createContext - 副本.uts new file mode 100644 index 0000000..55f952a --- /dev/null +++ b/hooks/createContext/createContext - 副本.uts @@ -0,0 +1,51 @@ +import { renderSlot } from "vue" + +interface IProps { + value : object +} + +type ContextValue = { + Provider : any + useContext : () => any + Consumer : any +} + +type TCreateContext = (key : string) => ContextValue + +export const createContext : TCreateContext = (key) => { + const Provider = { + props: { + value: { + type: Object, + required: true + } + }, + setup(props : IProps) { + const slots = useSlots() + provide(key, props.value) + const FN : () => VNode = () => renderSlot(slots, 'default') + return () : VNode => h(FN) + } + } + const useContext : () => any = () : any => { + return inject(key) as any + } + const Consumer = { + setup() { + const slots = useSlots() + const data = useContext() + const FN : () => VNode = () => renderSlot(slots, 'default', data) + return () : VNode => h(FN, {}) + } + } + + const FnP = Provider + const FnC = Consumer + + const value: ContextValue = { + Provider: FnP, + useContext, + Consumer: FnC, + } + return value +} \ No newline at end of file diff --git a/hooks/createContext/createContext.uts b/hooks/createContext/createContext.uts new file mode 100644 index 0000000..0936712 --- /dev/null +++ b/hooks/createContext/createContext.uts @@ -0,0 +1,47 @@ +import { renderSlot } from "vue" +import ProviderComp from "./Provider.uvue" +import ConsumerComp from "./Consumer.uvue" + +interface IProps { + value : object +} + +type ContextValue = { + Provider : any + useContext : () => any + Consumer : any +} + +type TCreateContext = (key : string) => ContextValue + +export const createContext : TCreateContext = (key) => { + const useContext : () => any = () : any => { + return inject(key) as any + } + // const Consumer = { + // setup() { + // const slots = useSlots() + // const data = useContext() + // const FN : () => VNode = () => renderSlot(slots, 'default', data) + // return () : VNode => h(FN, {}) + // } + // } + + // const FnC = Consumer + + const value : ContextValue = { + Provider: (): VNode=> { + return h(ProviderComp, { contextKey: key },) + }, + useContext, + Consumer: h(ConsumerComp, { contextKey: key }), + // Consumer: (): VNode=>{ + // const slots = useSlots() + // const data = useContext() + // // const FN : () => VNode = () => renderSlot(slots, 'default', data) + // console.log(data); + // return renderSlot(slots, 'default', data) + // } + } + return value +} \ No newline at end of file diff --git a/main.uts b/main.uts index 3b8febc..905d6b5 100644 --- a/main.uts +++ b/main.uts @@ -1,5 +1,5 @@ import App from './App.uvue' -import "@/assets/style/common.scss" +// import "~@/assets/style/common.scss" import { createSSRApp } from 'vue' export function createApp() { diff --git a/pages.json b/pages.json index 55caef0..f0aa657 100644 --- a/pages.json +++ b/pages.json @@ -1,4 +1,10 @@ { + "easycom": { + "autoscan": true, + "custom": { + "^(.*)--(.*)": "@/components/$1/$1--$2.uvue" + } + }, "pages": [ //pages数组中第一项表示应用启动页,参考:https://uniapp.dcloud.io/collocation/pages { "path": "pages/index/index", diff --git a/pages/index/index - 副本.uvue b/pages/index/index - 副本.uvue new file mode 100644 index 0000000..9c977ac --- /dev/null +++ b/pages/index/index - 副本.uvue @@ -0,0 +1,233 @@ + + + + + \ No newline at end of file diff --git a/pages/index/index.uvue b/pages/index/index.uvue index 1e82fae..cef51cf 100644 --- a/pages/index/index.uvue +++ b/pages/index/index.uvue @@ -3,119 +3,13 @@ LuMi - - - {{nowYear}}年{{nowMonth}}月 - - - - - - - - {{ day.label }} - - - - - - - - - {{item.label}} - x - - - - 打卡 - + +