commit ac114a5f101309d92b2778d2af034383c0456941 Author: chorblack Date: Tue Apr 22 20:58:44 2025 +0800 first commit diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000..5b788c1 Binary files /dev/null and b/.DS_Store differ diff --git a/app.ux b/app.ux new file mode 100644 index 0000000..1ea1f9a --- /dev/null +++ b/app.ux @@ -0,0 +1,26 @@ + diff --git a/assets/.DS_Store b/assets/.DS_Store new file mode 100644 index 0000000..bd8361e Binary files /dev/null and b/assets/.DS_Store differ diff --git a/assets/images/.DS_Store b/assets/images/.DS_Store new file mode 100644 index 0000000..5008ddf Binary files /dev/null and b/assets/images/.DS_Store differ diff --git a/assets/images/logo.png b/assets/images/logo.png new file mode 100644 index 0000000..9410c0a Binary files /dev/null and b/assets/images/logo.png differ diff --git a/assets/styles/mixins.scss b/assets/styles/mixins.scss new file mode 100644 index 0000000..56fbb5e --- /dev/null +++ b/assets/styles/mixins.scss @@ -0,0 +1,5 @@ +@mixin flex-box-mixins($direction: row, $justify: center, $align-items: center) { + flex-direction: $direction; + justify-content: $justify; + align-items: $align-items; +} diff --git a/assets/styles/style.scss b/assets/styles/style.scss new file mode 100644 index 0000000..088ebfa --- /dev/null +++ b/assets/styles/style.scss @@ -0,0 +1,2 @@ +@import './variables.scss'; +@import './mixins.scss'; diff --git a/assets/styles/variables.scss b/assets/styles/variables.scss new file mode 100644 index 0000000..04a6053 --- /dev/null +++ b/assets/styles/variables.scss @@ -0,0 +1,9 @@ +$brand: #09ba07; + +$white: #ffffff; +$black: #000000; +$grey: #9393aa; +$red: #fa0101; +$green: #ffff00; + +$size-factor: 5px; diff --git a/common/logo-256.png b/common/logo-256.png new file mode 100644 index 0000000..9410c0a Binary files /dev/null and b/common/logo-256.png differ diff --git a/common/logo.png b/common/logo.png new file mode 100644 index 0000000..9410c0a Binary files /dev/null and b/common/logo.png differ diff --git a/common/utils/dayjs.js b/common/utils/dayjs.js new file mode 100644 index 0000000..61916d8 --- /dev/null +++ b/common/utils/dayjs.js @@ -0,0 +1 @@ +!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t="undefined"!=typeof globalThis?globalThis:t||self).dayjs=e()}(this,(function(){"use strict";var t=1e3,e=6e4,n=36e5,r="millisecond",i="second",s="minute",u="hour",a="day",o="week",c="month",f="quarter",h="year",d="date",l="Invalid Date",$=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,y=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,M={name:"en",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),ordinal:function(t){var e=["th","st","nd","rd"],n=t%100;return"["+t+(e[(n-20)%10]||e[n]||e[0])+"]"}},m=function(t,e,n){var r=String(t);return!r||r.length>=e?t:""+Array(e+1-r.length).join(n)+t},v={s:m,z:function(t){var e=-t.utcOffset(),n=Math.abs(e),r=Math.floor(n/60),i=n%60;return(e<=0?"+":"-")+m(r,2,"0")+":"+m(i,2,"0")},m:function t(e,n){if(e.date()1)return t(u[0])}else{var a=e.name;D[a]=e,i=a}return!r&&i&&(g=i),i||!r&&g},O=function(t,e){if(S(t))return t.clone();var n="object"==typeof e?e:{};return n.date=t,n.args=arguments,new _(n)},b=v;b.l=w,b.i=S,b.w=function(t,e){return O(t,{locale:e.$L,utc:e.$u,x:e.$x,$offset:e.$offset})};var _=function(){function M(t){this.$L=w(t.locale,null,!0),this.parse(t),this.$x=this.$x||t.x||{},this[p]=!0}var m=M.prototype;return m.parse=function(t){this.$d=function(t){var e=t.date,n=t.utc;if(null===e)return new Date(NaN);if(b.u(e))return new Date;if(e instanceof Date)return new Date(e);if("string"==typeof e&&!/Z$/i.test(e)){var r=e.match($);if(r){var i=r[2]-1||0,s=(r[7]||"0").substring(0,3);return n?new Date(Date.UTC(r[1],i,r[3]||1,r[4]||0,r[5]||0,r[6]||0,s)):new Date(r[1],i,r[3]||1,r[4]||0,r[5]||0,r[6]||0,s)}}return new Date(e)}(t),this.init()},m.init=function(){var t=this.$d;this.$y=t.getFullYear(),this.$M=t.getMonth(),this.$D=t.getDate(),this.$W=t.getDay(),this.$H=t.getHours(),this.$m=t.getMinutes(),this.$s=t.getSeconds(),this.$ms=t.getMilliseconds()},m.$utils=function(){return b},m.isValid=function(){return!(this.$d.toString()===l)},m.isSame=function(t,e){var n=O(t);return this.startOf(e)<=n&&n<=this.endOf(e)},m.isAfter=function(t,e){return O(t) -1)) { + lm = `闰${lunarMonth[/\d/.exec(lm) - 1]}` + } else { + lm = lunarMonth[lm - 1]; + } + + // 将计算出来的农历年份转换为天干地支年 + ly = getTianGan(ly) + getDiZhi(ly); + + // 将计算出来的农历天数转换成汉字 + if (ld < 11) { + ld = `${lunarDay[10]}${lunarDay[ld-1]}` + } else if (ld > 10 && ld < 20) { + ld = `${lunarDay[9]}${lunarDay[ld-11]}` + } else if (ld === 20) { + ld = `${lunarDay[1]}${lunarDay[9]}` + } else if (ld > 20 && ld < 30) { + ld = `${lunarDay[11]}${lunarDay[ld-21]}` + } else if (ld === 30) { + ld = `${lunarDay[2]}${lunarDay[9]}` + } + + // console.log(ly, lm, ld); + + return { + lunarYear: ly, + lunarMonth: lm, + lunarDay: ld, + } +} + +// 计算农历年是否有闰月,参数为存储农历年的16进制 +// 农历年份信息用16进制存储,其中16进制的最后1位可以用于判断是否有闰月 +function hasLeapMonth(ly) { + // 获取16进制的最后1位,需要用到&与运算符 + if (ly & 0xf) { + return ly & 0xf + } else { + return false + } +} + +// 如果有闰月,计算农历闰月天数,参数为存储农历年的16进制 +// 农历年份信息用16进制存储,其中16进制的第1位(0x除外)可以用于表示闰月是大月还是小月 +function leapMonthDays(ly) { + if (hasLeapMonth(ly)) { + // 获取16进制的第1位(0x除外) + return (ly & 0xf0000) ? 30 : 29 + } else { + return 0 + } +} + +// 计算农历一年的总天数,参数为存储农历年的16进制 +// 农历年份信息用16进制存储,其中16进制的第2-4位(0x除外)可以用于表示正常月是大月还是小月 +function lunarYearDays(ly) { + let totalDays = 0; + + // 获取正常月的天数,并累加 + // 获取16进制的第2-4位,需要用到>>移位运算符 + for (let i = 0x8000; i > 0x8; i >>= 1) { + let monthDays = (ly & i) ? 30 : 29; + totalDays += monthDays; + } + // 如果有闰月,需要把闰月的天数加上 + if (hasLeapMonth(ly)) { + totalDays += leapMonthDays(ly); + } + + return totalDays +} + +// 获取农历每个月的天数 +// 参数需传入16进制数值 +function lunarYearMonths(ly) { + let monthArr = []; + + // 获取正常月的天数,并添加到monthArr数组中 + // 获取16进制的第2-4位,需要用到>>移位运算符 + for (let i = 0x8000; i > 0x8; i >>= 1) { + monthArr.push((ly & i) ? 30 : 29); + } + // 如果有闰月,需要把闰月的天数加上 + if (hasLeapMonth(ly)) { + monthArr.splice(hasLeapMonth(ly), 0, leapMonthDays(ly)); + } + + return monthArr +} + +// 将农历年转换为天干,参数为农历年 +function getTianGan(ly) { + let tianGanKey = (ly - 3) % 10; + if (tianGanKey === 0) tianGanKey = 10; + return tianGan[tianGanKey - 1] +} + +// 将农历年转换为地支,参数为农历年 +function getDiZhi(ly) { + let diZhiKey = (ly - 3) % 12; + if (diZhiKey === 0) diZhiKey = 12; + return diZhi[diZhiKey - 1] +} + +export default sloarToLunar \ No newline at end of file diff --git a/manifest.json b/manifest.json new file mode 100644 index 0000000..1523828 --- /dev/null +++ b/manifest.json @@ -0,0 +1,44 @@ +{ + "package": "top.chorblack.calendar", + "name": "日历", + "versionName": "2.0.1", + "versionCode": 3, + "appCategory": [ + "other" + ], + "icon": "/assets/images/logo.png", + "features": [ + { + "name": "blueos.app.appmanager.router" + }, + { + "name": "blueos.hardware.deviceInfo" + } + ], + "deviceTypeList": [ + "watch", + "watch-square" + ], + "config": { + "designWidth": 466 + }, + "router": { + "entry": "pages/index", + "pages": { + "pages/index": { + "component": "index" + }, + "pages/detail": { + "component": "index" + } + } + }, + "display": { + "backgroundColor": "#000000" + }, + "permissions": [ + { + "name": "watch.permission.DEVICE_INFO" + } + ] +} diff --git a/pages/.DS_Store b/pages/.DS_Store new file mode 100644 index 0000000..0348ccc Binary files /dev/null and b/pages/.DS_Store differ diff --git a/pages/detail/index.ux b/pages/detail/index.ux new file mode 100644 index 0000000..0906617 --- /dev/null +++ b/pages/detail/index.ux @@ -0,0 +1,121 @@ + + + + + \ No newline at end of file diff --git a/pages/index/index.ux b/pages/index/index.ux new file mode 100644 index 0000000..7f7221b --- /dev/null +++ b/pages/index/index.ux @@ -0,0 +1,286 @@ + + + + + \ No newline at end of file