@puresnake/snake-ui 0.0.0-stage → 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/changelog.md +1 -0
- package/components/snake-activity-list/snake-activity-list.vue +365 -0
- package/components/snake-activity-list/types.ts +29 -0
- package/components/snake-auxiliary-segmentation/snake-auxiliary-segmentation.vue +44 -0
- package/components/snake-auxiliary-segmentation/types.ts +5 -0
- package/components/snake-button/snake-button.vue +357 -0
- package/components/snake-button/types.ts +103 -0
- package/components/snake-button-sort/snake-button-sort.vue +72 -0
- package/components/snake-button-sort/types.ts +22 -0
- package/components/snake-calendar/snake-calendar.vue +998 -0
- package/components/snake-calendar/types.ts +189 -0
- package/components/snake-cell-group/snake-cell-group.vue +55 -0
- package/components/snake-cell-group/types.ts +19 -0
- package/components/snake-cell-item/snake-cell-item.vue +159 -0
- package/components/snake-cell-item/types.ts +66 -0
- package/components/snake-checkbox/snake-checkbox.vue +264 -0
- package/components/snake-checkbox/types.ts +70 -0
- package/components/snake-checkbox-group/snake-checkbox-group.vue +154 -0
- package/components/snake-checkbox-group/types.ts +52 -0
- package/components/snake-cms/blocks/v2/cms-v2-carousel.vue +87 -0
- package/components/snake-cms/blocks/v2/cms-v2-coupon.vue +25 -0
- package/components/snake-cms/blocks/v2/cms-v2-custom.vue +12 -0
- package/components/snake-cms/blocks/v2/cms-v2-divider.vue +33 -0
- package/components/snake-cms/blocks/v2/cms-v2-floatbutton.vue +28 -0
- package/components/snake-cms/blocks/v2/cms-v2-goods-list.vue +150 -0
- package/components/snake-cms/blocks/v2/cms-v2-hotzone.vue +41 -0
- package/components/snake-cms/blocks/v2/cms-v2-images.vue +41 -0
- package/components/snake-cms/blocks/v2/cms-v2-magiccube.vue +93 -0
- package/components/snake-cms/blocks/v2/cms-v2-notice.vue +80 -0
- package/components/snake-cms/blocks/v2/cms-v2-popup.vue +46 -0
- package/components/snake-cms/blocks/v2/cms-v2-richtext.vue +18 -0
- package/components/snake-cms/blocks/v2/cms-v2-search.vue +115 -0
- package/components/snake-cms/blocks/v2/cms-v2-video.vue +25 -0
- package/components/snake-cms/blocks/v2/shared.ts +84 -0
- package/components/snake-cms/snake-cms.vue +409 -0
- package/components/snake-cms/types.ts +50 -0
- package/components/snake-commodity-search/snake-commodity-search.vue +234 -0
- package/components/snake-commodity-search/types.ts +11 -0
- package/components/snake-config-provider/snake-config-provider.vue +61 -0
- package/components/snake-config-provider/types.ts +22 -0
- package/components/snake-count-down/snake-count-down.vue +231 -0
- package/components/snake-count-down/types.ts +103 -0
- package/components/snake-coupon/snake-coupon.vue +209 -0
- package/components/snake-coupon/types.ts +21 -0
- package/components/snake-custom-module/snake-custom-module.vue +25 -0
- package/components/snake-custom-module/types.ts +11 -0
- package/components/snake-drop-menu/snake-drop-menu.vue +123 -0
- package/components/snake-drop-menu/types.ts +95 -0
- package/components/snake-drop-menu-item/snake-drop-menu-item.vue +181 -0
- package/components/snake-drop-menu-item/types.ts +48 -0
- package/components/snake-empty/snake-empty.vue +100 -0
- package/components/snake-empty/types.ts +48 -0
- package/components/snake-filter-sorts/filter-page.vue +695 -0
- package/components/snake-filter-sorts/snake-filter-sorts.vue +185 -0
- package/components/snake-filter-sorts/types.ts +57 -0
- package/components/snake-floating-bubble/snake-floating-bubble.vue +157 -0
- package/components/snake-floating-bubble/types.ts +43 -0
- package/components/snake-follow/snake-follow.vue +18 -0
- package/components/snake-follow/types.ts +2 -0
- package/components/snake-form/snake-form.vue +124 -0
- package/components/snake-form/types.ts +96 -0
- package/components/snake-form-item/snake-form-item.vue +331 -0
- package/components/snake-form-item/types.ts +70 -0
- package/components/snake-goods-list/snake-goods-list.vue +792 -0
- package/components/snake-goods-list/types.ts +55 -0
- package/components/snake-graphic-navigation/snake-graphic-navigation.vue +198 -0
- package/components/snake-graphic-navigation/types.ts +43 -0
- package/components/snake-icon/icon-names.ts +222 -0
- package/components/snake-icon/snake-icon.vue +220 -0
- package/components/snake-icon/types.ts +45 -0
- package/components/snake-image/snake-image.vue +230 -0
- package/components/snake-image/types.ts +70 -0
- package/components/snake-images/snake-images.vue +80 -0
- package/components/snake-images/types.ts +5 -0
- package/components/snake-index-anchor/snake-index-anchor.vue +83 -0
- package/components/snake-index-anchor/types.ts +14 -0
- package/components/snake-index-list/anchor-registry.ts +80 -0
- package/components/snake-index-list/snake-index-list.vue +259 -0
- package/components/snake-index-list/types.ts +115 -0
- package/components/snake-index-list-panel/snake-index-list-panel.vue +277 -0
- package/components/snake-index-list-panel/types.ts +10 -0
- package/components/snake-input/snake-input.vue +225 -0
- package/components/snake-input/types.ts +99 -0
- package/components/snake-jump-applet/snake-jump-applet.vue +99 -0
- package/components/snake-jump-applet/types.ts +17 -0
- package/components/snake-line/snake-line.vue +42 -0
- package/components/snake-line/types.ts +30 -0
- package/components/snake-line-progress/snake-line-progress.vue +105 -0
- package/components/snake-line-progress/types.ts +26 -0
- package/components/snake-link/snake-link.vue +74 -0
- package/components/snake-link/types.ts +30 -0
- package/components/snake-list-switching/components/tree-select/index.vue +156 -0
- package/components/snake-list-switching/snake-list-switching.vue +1285 -0
- package/components/snake-list-switching/types.ts +11 -0
- package/components/snake-loading/snake-loading.vue +241 -0
- package/components/snake-loading/types.ts +34 -0
- package/components/snake-loadmore/snake-loadmore.vue +103 -0
- package/components/snake-loadmore/types.ts +56 -0
- package/components/snake-magic-cube/snake-magic-cube.vue +622 -0
- package/components/snake-magic-cube/types.ts +5 -0
- package/components/snake-modal/snake-modal.vue +434 -0
- package/components/snake-modal/types.ts +71 -0
- package/components/snake-navbar/snake-navbar.vue +194 -0
- package/components/snake-navbar/types.ts +54 -0
- package/components/snake-no-network/snake-no-network.vue +125 -0
- package/components/snake-no-network/types.ts +27 -0
- package/components/snake-notice/snake-notice.vue +44 -0
- package/components/snake-notice/types.ts +5 -0
- package/components/snake-notice-bar/snake-notice-bar.vue +336 -0
- package/components/snake-notice-bar/types.ts +82 -0
- package/components/snake-overlay/snake-overlay.vue +73 -0
- package/components/snake-overlay/types.ts +35 -0
- package/components/snake-page-popup/snake-page-popup.vue +146 -0
- package/components/snake-page-popup/types.ts +28 -0
- package/components/snake-parse/audio/audio.vue +286 -0
- package/components/snake-parse/audio/context.js +11 -0
- package/components/snake-parse/audio/index.js +34 -0
- package/components/snake-parse/node/node.vue +830 -0
- package/components/snake-parse/parser.js +1480 -0
- package/components/snake-parse/snake-parse.vue +548 -0
- package/components/snake-parse/static/app-plus/snake-parse/js/handler.js +109 -0
- package/components/snake-parse/static/app-plus/snake-parse/js/uni.webview.js +0 -0
- package/components/snake-parse/static/app-plus/snake-parse/js/uni.webview.min.js +1 -0
- package/components/snake-parse/static/app-plus/snake-parse/local.html +3 -0
- package/components/snake-parse/style/index.js +132 -0
- package/components/snake-parse/style/parser.js +175 -0
- package/components/snake-parse/types.ts +49 -0
- package/components/snake-picture-ads/snake-picture-ads.vue +292 -0
- package/components/snake-picture-ads/types.ts +5 -0
- package/components/snake-popup/snake-popup.vue +348 -0
- package/components/snake-popup/types.ts +88 -0
- package/components/snake-qr-code/qrcode.ts +1214 -0
- package/components/snake-qr-code/snake-qr-code.vue +408 -0
- package/components/snake-qr-code/types.ts +78 -0
- package/components/snake-radio/snake-radio.vue +271 -0
- package/components/snake-radio/types.ts +64 -0
- package/components/snake-radio-group/snake-radio-group.vue +98 -0
- package/components/snake-radio-group/types.ts +48 -0
- package/components/snake-read-more/snake-read-more.vue +140 -0
- package/components/snake-read-more/types.ts +53 -0
- package/components/snake-rich-text/snake-rich-text.vue +24 -0
- package/components/snake-rich-text/types.ts +5 -0
- package/components/snake-root-portal/snake-root-portal.vue +92 -0
- package/components/snake-root-portal/types.ts +9 -0
- package/components/snake-search/snake-search.vue +202 -0
- package/components/snake-search/types.ts +84 -0
- package/components/snake-select/snake-select.vue +371 -0
- package/components/snake-select/types.ts +75 -0
- package/components/snake-skeleton/snake-skeleton.vue +104 -0
- package/components/snake-skeleton/types.ts +32 -0
- package/components/snake-skeleton-item/snake-skeleton-item.vue +90 -0
- package/components/snake-skeleton-item/types.ts +30 -0
- package/components/snake-slider/snake-slider.vue +249 -0
- package/components/snake-slider/types.ts +59 -0
- package/components/snake-sticky/snake-sticky.vue +178 -0
- package/components/snake-sticky/types.ts +48 -0
- package/components/snake-subsection/snake-subsection.vue +188 -0
- package/components/snake-subsection/types.ts +54 -0
- package/components/snake-swiper/snake-swiper.vue +229 -0
- package/components/snake-swiper/types.ts +79 -0
- package/components/snake-switch/snake-switch.vue +100 -0
- package/components/snake-switch/types.ts +41 -0
- package/components/snake-tabbar/snake-tabbar.vue +306 -0
- package/components/snake-tabbar/types.ts +93 -0
- package/components/snake-tabs/snake-tabs.vue +305 -0
- package/components/snake-tabs/types.ts +79 -0
- package/components/snake-text/snake-text.vue +292 -0
- package/components/snake-text/types.ts +100 -0
- package/components/snake-textarea/snake-textarea.vue +171 -0
- package/components/snake-textarea/types.ts +79 -0
- package/components/snake-toast/snake-toast.vue +330 -0
- package/components/snake-toast/types.ts +55 -0
- package/components/snake-tooltip/position.ts +33 -0
- package/components/snake-tooltip/snake-tooltip.vue +339 -0
- package/components/snake-tooltip/types.ts +80 -0
- package/components/snake-transition/snake-transition.vue +315 -0
- package/components/snake-transition/types.ts +65 -0
- package/components/snake-upload/snake-upload.vue +1801 -0
- package/components/snake-upload/types.ts +256 -0
- package/components/snake-videos/snake-videos.vue +122 -0
- package/components/snake-videos/types.ts +7 -0
- package/iconfont.css +881 -0
- package/index.d.ts +7 -0
- package/index.scss +26 -0
- package/index.ts +94 -0
- package/libs/cms/blocks.ts +103 -0
- package/libs/cms/config.ts +25 -0
- package/libs/cms/index.ts +7 -0
- package/libs/cms/normalize.ts +135 -0
- package/libs/cms/resolve.ts +12 -0
- package/libs/cms/types.ts +164 -0
- package/libs/cms/use-commerce.ts +385 -0
- package/libs/cms/v2.ts +193 -0
- package/libs/config/index.ts +4 -0
- package/libs/config/modal.ts +93 -0
- package/libs/config/state.ts +33 -0
- package/libs/config/theme.ts +351 -0
- package/libs/config/toast.ts +71 -0
- package/libs/config/types.ts +135 -0
- package/libs/config/zIndex.ts +44 -0
- package/libs/css/color.scss +105 -0
- package/libs/css/common.scss +171 -0
- package/libs/css/style.h5.scss +7 -0
- package/libs/css/style.mp.scss +7 -0
- package/libs/css/style.theme.scss +70 -0
- package/libs/css/style.vue.scss +140 -0
- package/libs/form/async-validator.min.d.ts +75 -0
- package/libs/form/async-validator.min.js +3 -0
- package/libs/form/index.ts +3 -0
- package/libs/form/path.ts +40 -0
- package/libs/form/types.ts +51 -0
- package/libs/form/validate.ts +149 -0
- package/libs/foundation.ts +96 -0
- package/libs/function/$parent.ts +33 -0
- package/libs/function/clipboard.ts +13 -0
- package/libs/function/color.ts +55 -0
- package/libs/function/debounce.ts +34 -0
- package/libs/function/deepClone.ts +30 -0
- package/libs/function/deepMerge.ts +25 -0
- package/libs/function/emitter.ts +30 -0
- package/libs/function/format.ts +27 -0
- package/libs/function/getParent.ts +53 -0
- package/libs/function/getRect.ts +29 -0
- package/libs/function/guid.ts +11 -0
- package/libs/function/index.ts +31 -0
- package/libs/function/queryParams.ts +73 -0
- package/libs/function/random.ts +6 -0
- package/libs/function/randomArray.ts +14 -0
- package/libs/function/route.ts +155 -0
- package/libs/function/sleep.ts +7 -0
- package/libs/function/style.ts +58 -0
- package/libs/function/styleUtils.ts +83 -0
- package/libs/function/system.ts +14 -0
- package/libs/function/test.ts +202 -0
- package/libs/function/throttle.ts +36 -0
- package/libs/function/timeFormat.ts +27 -0
- package/libs/function/timeFrom.ts +27 -0
- package/libs/function/toast.ts +10 -0
- package/libs/function/trim.ts +11 -0
- package/libs/function/type2icon.ts +11 -0
- package/libs/function/unit.ts +45 -0
- package/libs/hooks/index.ts +11 -0
- package/libs/hooks/useChildren.ts +125 -0
- package/libs/hooks/useColor.ts +5 -0
- package/libs/hooks/useDebounce.ts +5 -0
- package/libs/hooks/useLocale.ts +13 -0
- package/libs/hooks/useModal.ts +131 -0
- package/libs/hooks/useParent.ts +62 -0
- package/libs/hooks/useRect.ts +44 -0
- package/libs/hooks/useRouter.ts +5 -0
- package/libs/hooks/useTheme.ts +31 -0
- package/libs/hooks/useThrottle.ts +5 -0
- package/libs/hooks/useToast.ts +116 -0
- package/libs/index.ts +18 -0
- package/libs/request/auto-http.ts +1 -0
- package/libs/request/index.ts +343 -0
- package/libs/runtime/accessors.ts +55 -0
- package/libs/runtime/context.ts +40 -0
- package/libs/runtime/index.ts +18 -0
- package/libs/runtime/types.ts +49 -0
- package/libs/util/calendar.ts +6 -0
- package/locale/index.ts +130 -0
- package/locale/lang/en-US.ts +67 -0
- package/locale/lang/zh-CN.ts +67 -0
- package/package.json +130 -5
- package/plugins/index.ts +1 -0
- package/plugins/root/README.md +86 -0
- package/plugins/root/index.ts +123 -0
- package/plugins/root/page.ts +77 -0
- package/plugins/root/root.ts +53 -0
- package/plugins/root/utils.ts +137 -0
- package/readme.md +79 -0
- package/theme.scss +118 -0
- package/types/components.d.ts +236 -0
- package/types/global.d.ts +21 -0
- package/types/index.d.ts +6 -0
- package/types/uni-app.d.ts +16 -0
- package/README.md +0 -3
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
2
|
+
/**
|
|
3
|
+
* 农历/公历互转,内联自 jjonline/calendar.js,保持原样不修改。
|
|
4
|
+
* 提供 solar2lunar / lunar2solar 等换算能力,供日历组件展示农历使用。
|
|
5
|
+
*/
|
|
6
|
+
export default {lunarInfo:[19416,19168,42352,21717,53856,55632,91476,22176,39632,21970,19168,42422,42192,53840,119381,46400,54944,44450,38320,84343,18800,42160,46261,27216,27968,109396,11104,38256,21234,18800,25958,54432,59984,28309,23248,11104,100067,37600,116951,51536,54432,120998,46416,22176,107956,9680,37584,53938,43344,46423,27808,46416,86869,19872,42416,83315,21168,43432,59728,27296,44710,43856,19296,43748,42352,21088,62051,55632,23383,22176,38608,19925,19152,42192,54484,53840,54616,46400,46752,103846,38320,18864,43380,42160,45690,27216,27968,44870,43872,38256,19189,18800,25776,29859,59984,27480,23232,43872,38613,37600,51552,55636,54432,55888,30034,22176,43959,9680,37584,51893,43344,46240,47780,44368,21977,19360,42416,86390,21168,43312,31060,27296,44368,23378,19296,42726,42208,53856,60005,54576,23200,30371,38608,19195,19152,42192,118966,53840,54560,56645,46496,22224,21938,18864,42359,42160,43600,111189,27936,44448,84835,37744,18936,18800,25776,92326,59984,27424,108228,43744,41696,53987,51552,54615,54432,55888,23893,22176,42704,21972,21200,43448,43344,46240,46758,44368,21920,43940,42416,21168,45683,26928,29495,27296,44368,84821,19296,42352,21732,53600,59752,54560,55968,92838,22224,19168,43476,41680,53584,62034,54560],solarMonth:[31,28,31,30,31,30,31,31,30,31,30,31],Gan:["甲","乙","丙","丁","戊","己","庚","辛","壬","癸"],Zhi:["子","丑","寅","卯","辰","巳","午","未","申","酉","戌","亥"],Animals:["鼠","牛","虎","兔","龙","蛇","马","羊","猴","鸡","狗","猪"],solarTerm:["小寒","大寒","立春","雨水","惊蛰","春分","清明","谷雨","立夏","小满","芒种","夏至","小暑","大暑","立秋","处暑","白露","秋分","寒露","霜降","立冬","小雪","大雪","冬至"],sTermInfo:["9778397bd097c36b0b6fc9274c91aa","97b6b97bd19801ec9210c965cc920e","97bcf97c3598082c95f8c965cc920f","97bd0b06bdb0722c965ce1cfcc920f","b027097bd097c36b0b6fc9274c91aa","97b6b97bd19801ec9210c965cc920e","97bcf97c359801ec95f8c965cc920f","97bd0b06bdb0722c965ce1cfcc920f","b027097bd097c36b0b6fc9274c91aa","97b6b97bd19801ec9210c965cc920e","97bcf97c359801ec95f8c965cc920f","97bd0b06bdb0722c965ce1cfcc920f","b027097bd097c36b0b6fc9274c91aa","9778397bd19801ec9210c965cc920e","97b6b97bd19801ec95f8c965cc920f","97bd09801d98082c95f8e1cfcc920f","97bd097bd097c36b0b6fc9210c8dc2","9778397bd197c36c9210c9274c91aa","97b6b97bd19801ec95f8c965cc920e","97bd09801d98082c95f8e1cfcc920f","97bd097bd097c36b0b6fc9210c8dc2","9778397bd097c36c9210c9274c91aa","97b6b97bd19801ec95f8c965cc920e","97bcf97c3598082c95f8e1cfcc920f","97bd097bd097c36b0b6fc9210c8dc2","9778397bd097c36c9210c9274c91aa","97b6b97bd19801ec9210c965cc920e","97bcf97c3598082c95f8c965cc920f","97bd097bd097c35b0b6fc920fb0722","9778397bd097c36b0b6fc9274c91aa","97b6b97bd19801ec9210c965cc920e","97bcf97c3598082c95f8c965cc920f","97bd097bd097c35b0b6fc920fb0722","9778397bd097c36b0b6fc9274c91aa","97b6b97bd19801ec9210c965cc920e","97bcf97c359801ec95f8c965cc920f","97bd097bd097c35b0b6fc920fb0722","9778397bd097c36b0b6fc9274c91aa","97b6b97bd19801ec9210c965cc920e","97bcf97c359801ec95f8c965cc920f","97bd097bd097c35b0b6fc920fb0722","9778397bd097c36b0b6fc9274c91aa","97b6b97bd19801ec9210c965cc920e","97bcf97c359801ec95f8c965cc920f","97bd097bd07f595b0b6fc920fb0722","9778397bd097c36b0b6fc9210c8dc2","9778397bd19801ec9210c9274c920e","97b6b97bd19801ec95f8c965cc920f","97bd07f5307f595b0b0bc920fb0722","7f0e397bd097c36b0b6fc9210c8dc2","9778397bd097c36c9210c9274c920e","97b6b97bd19801ec95f8c965cc920f","97bd07f5307f595b0b0bc920fb0722","7f0e397bd097c36b0b6fc9210c8dc2","9778397bd097c36c9210c9274c91aa","97b6b97bd19801ec9210c965cc920e","97bd07f1487f595b0b0bc920fb0722","7f0e397bd097c36b0b6fc9210c8dc2","9778397bd097c36b0b6fc9274c91aa","97b6b97bd19801ec9210c965cc920e","97bcf7f1487f595b0b0bb0b6fb0722","7f0e397bd097c35b0b6fc920fb0722","9778397bd097c36b0b6fc9274c91aa","97b6b97bd19801ec9210c965cc920e","97bcf7f1487f595b0b0bb0b6fb0722","7f0e397bd097c35b0b6fc920fb0722","9778397bd097c36b0b6fc9274c91aa","97b6b97bd19801ec9210c965cc920e","97bcf7f1487f531b0b0bb0b6fb0722","7f0e397bd097c35b0b6fc920fb0722","9778397bd097c36b0b6fc9274c91aa","97b6b97bd19801ec9210c965cc920e","97bcf7f1487f531b0b0bb0b6fb0722","7f0e397bd07f595b0b6fc920fb0722","9778397bd097c36b0b6fc9274c91aa","97b6b97bd19801ec9210c9274c920e","97bcf7f0e47f531b0b0bb0b6fb0722","7f0e397bd07f595b0b0bc920fb0722","9778397bd097c36b0b6fc9210c91aa","97b6b97bd197c36c9210c9274c920e","97bcf7f0e47f531b0b0bb0b6fb0722","7f0e397bd07f595b0b0bc920fb0722","9778397bd097c36b0b6fc9210c8dc2","9778397bd097c36c9210c9274c920e","97b6b7f0e47f531b0723b0b6fb0722","7f0e37f5307f595b0b0bc920fb0722","7f0e397bd097c36b0b6fc9210c8dc2","9778397bd097c36b0b70c9274c91aa","97b6b7f0e47f531b0723b0b6fb0721","7f0e37f1487f595b0b0bb0b6fb0722","7f0e397bd097c35b0b6fc9210c8dc2","9778397bd097c36b0b6fc9274c91aa","97b6b7f0e47f531b0723b0b6fb0721","7f0e27f1487f595b0b0bb0b6fb0722","7f0e397bd097c35b0b6fc920fb0722","9778397bd097c36b0b6fc9274c91aa","97b6b7f0e47f531b0723b0b6fb0721","7f0e27f1487f531b0b0bb0b6fb0722","7f0e397bd097c35b0b6fc920fb0722","9778397bd097c36b0b6fc9274c91aa","97b6b7f0e47f531b0723b0b6fb0721","7f0e27f1487f531b0b0bb0b6fb0722","7f0e397bd097c35b0b6fc920fb0722","9778397bd097c36b0b6fc9274c91aa","97b6b7f0e47f531b0723b0b6fb0721","7f0e27f1487f531b0b0bb0b6fb0722","7f0e397bd07f595b0b0bc920fb0722","9778397bd097c36b0b6fc9274c91aa","97b6b7f0e47f531b0723b0787b0721","7f0e27f0e47f531b0b0bb0b6fb0722","7f0e397bd07f595b0b0bc920fb0722","9778397bd097c36b0b6fc9210c91aa","97b6b7f0e47f149b0723b0787b0721","7f0e27f0e47f531b0723b0b6fb0722","7f0e397bd07f595b0b0bc920fb0722","9778397bd097c36b0b6fc9210c8dc2","977837f0e37f149b0723b0787b0721","7f07e7f0e47f531b0723b0b6fb0722","7f0e37f5307f595b0b0bc920fb0722","7f0e397bd097c35b0b6fc9210c8dc2","977837f0e37f14998082b0787b0721","7f07e7f0e47f531b0723b0b6fb0721","7f0e37f1487f595b0b0bb0b6fb0722","7f0e397bd097c35b0b6fc9210c8dc2","977837f0e37f14998082b0787b06bd","7f07e7f0e47f531b0723b0b6fb0721","7f0e27f1487f531b0b0bb0b6fb0722","7f0e397bd097c35b0b6fc920fb0722","977837f0e37f14998082b0787b06bd","7f07e7f0e47f531b0723b0b6fb0721","7f0e27f1487f531b0b0bb0b6fb0722","7f0e397bd097c35b0b6fc920fb0722","977837f0e37f14998082b0787b06bd","7f07e7f0e47f531b0723b0b6fb0721","7f0e27f1487f531b0b0bb0b6fb0722","7f0e397bd07f595b0b0bc920fb0722","977837f0e37f14998082b0787b06bd","7f07e7f0e47f531b0723b0b6fb0721","7f0e27f1487f531b0b0bb0b6fb0722","7f0e397bd07f595b0b0bc920fb0722","977837f0e37f14998082b0787b06bd","7f07e7f0e47f149b0723b0787b0721","7f0e27f0e47f531b0b0bb0b6fb0722","7f0e397bd07f595b0b0bc920fb0722","977837f0e37f14998082b0723b06bd","7f07e7f0e37f149b0723b0787b0721","7f0e27f0e47f531b0723b0b6fb0722","7f0e397bd07f595b0b0bc920fb0722","977837f0e37f14898082b0723b02d5","7ec967f0e37f14998082b0787b0721","7f07e7f0e47f531b0723b0b6fb0722","7f0e37f1487f595b0b0bb0b6fb0722","7f0e37f0e37f14898082b0723b02d5","7ec967f0e37f14998082b0787b0721","7f07e7f0e47f531b0723b0b6fb0722","7f0e37f1487f531b0b0bb0b6fb0722","7f0e37f0e37f14898082b0723b02d5","7ec967f0e37f14998082b0787b06bd","7f07e7f0e47f531b0723b0b6fb0721","7f0e37f1487f531b0b0bb0b6fb0722","7f0e37f0e37f14898082b072297c35","7ec967f0e37f14998082b0787b06bd","7f07e7f0e47f531b0723b0b6fb0721","7f0e27f1487f531b0b0bb0b6fb0722","7f0e37f0e37f14898082b072297c35","7ec967f0e37f14998082b0787b06bd","7f07e7f0e47f531b0723b0b6fb0721","7f0e27f1487f531b0b0bb0b6fb0722","7f0e37f0e366aa89801eb072297c35","7ec967f0e37f14998082b0787b06bd","7f07e7f0e47f149b0723b0787b0721","7f0e27f1487f531b0b0bb0b6fb0722","7f0e37f0e366aa89801eb072297c35","7ec967f0e37f14998082b0723b06bd","7f07e7f0e47f149b0723b0787b0721","7f0e27f0e47f531b0723b0b6fb0722","7f0e37f0e366aa89801eb072297c35","7ec967f0e37f14998082b0723b06bd","7f07e7f0e37f14998083b0787b0721","7f0e27f0e47f531b0723b0b6fb0722","7f0e37f0e366aa89801eb072297c35","7ec967f0e37f14898082b0723b02d5","7f07e7f0e37f14998082b0787b0721","7f07e7f0e47f531b0723b0b6fb0722","7f0e36665b66aa89801e9808297c35","665f67f0e37f14898082b0723b02d5","7ec967f0e37f14998082b0787b0721","7f07e7f0e47f531b0723b0b6fb0722","7f0e36665b66a449801e9808297c35","665f67f0e37f14898082b0723b02d5","7ec967f0e37f14998082b0787b06bd","7f07e7f0e47f531b0723b0b6fb0721","7f0e36665b66a449801e9808297c35","665f67f0e37f14898082b072297c35","7ec967f0e37f14998082b0787b06bd","7f07e7f0e47f531b0723b0b6fb0721","7f0e26665b66a449801e9808297c35","665f67f0e37f1489801eb072297c35","7ec967f0e37f14998082b0787b06bd","7f07e7f0e47f531b0723b0b6fb0721","7f0e27f1487f531b0b0bb0b6fb0722"],nStr1:["日","一","二","三","四","五","六","七","八","九","十"],nStr2:["初","十","廿","卅"],nStr3:["正","二","三","四","五","六","七","八","九","十","冬","腊"],lYearDays:function(b){for(var f=348,c=32768;8<c;c>>=1)f+=this.lunarInfo[b-1900]&c?1:0;return f+this.leapDays(b)},leapMonth:function(b){return 15&this.lunarInfo[b-1900]},leapDays:function(b){return this.leapMonth(b)?65536&this.lunarInfo[b-1900]?30:29:0},monthDays:function(b,f){return 12<f||f<1?-1:this.lunarInfo[b-1900]&65536>>f?30:29},solarDays:function(b,f){if(12<f||f<1)return-1;--f;return 1==f?b%4==0&&b%100!=0||b%400==0?29:28:this.solarMonth[f]},toGanZhiYear:function(b){var f=(b-3)%10,b=(b-3)%12;return 0==f&&(f=10),0==b&&(b=12),this.Gan[f-1]+this.Zhi[b-1]},toAstro:function(b,f){return"魔羯水瓶双鱼白羊金牛双子巨蟹狮子处女天秤天蝎射手魔羯".substr(2*b-(f<[20,19,21,21,21,22,23,23,23,23,22,22][b-1]?2:0),2)+"座"},toGanZhi:function(b){return this.Gan[b%10]+this.Zhi[b%12]},getTerm:function(b,f){if(b<1900||2100<b)return-1;if(f<1||24<f)return-1;b=this.sTermInfo[b-1900],b=[parseInt("0x"+b.substr(0,5)).toString(),parseInt("0x"+b.substr(5,5)).toString(),parseInt("0x"+b.substr(10,5)).toString(),parseInt("0x"+b.substr(15,5)).toString(),parseInt("0x"+b.substr(20,5)).toString(),parseInt("0x"+b.substr(25,5)).toString()],b=[b[0].substr(0,1),b[0].substr(1,2),b[0].substr(3,1),b[0].substr(4,2),b[1].substr(0,1),b[1].substr(1,2),b[1].substr(3,1),b[1].substr(4,2),b[2].substr(0,1),b[2].substr(1,2),b[2].substr(3,1),b[2].substr(4,2),b[3].substr(0,1),b[3].substr(1,2),b[3].substr(3,1),b[3].substr(4,2),b[4].substr(0,1),b[4].substr(1,2),b[4].substr(3,1),b[4].substr(4,2),b[5].substr(0,1),b[5].substr(1,2),b[5].substr(3,1),b[5].substr(4,2)];return parseInt(b[f-1])},toChinaMonth:function(b){if(12<b||b<1)return-1;b=this.nStr3[b-1];return b+="月"},toChinaDay:function(b){var f;switch(b){case 10:f="初十";break;case 20:f="二十";break;case 30:f="三十";break;default:f=this.nStr2[Math.floor(b/10)],f+=this.nStr1[b%10]}return f},getAnimal:function(b){return this.Animals[(b-4)%12]},solar2lunar:function(b,f,c){if(b<1900||2100<b)return-1;if(1900==b&&1==f&&c<31)return-1;for(var e=0,b=(M=b?new Date(b,parseInt(f)-1,c):new Date).getFullYear(),f=M.getMonth()+1,c=M.getDate(),t=(Date.UTC(M.getFullYear(),M.getMonth(),M.getDate())-Date.UTC(1900,0,31))/864e5,a=1900;a<2101&&0<t;a++)t-=e=this.lYearDays(a);t<0&&(t+=e,a--);var r=new Date,s=!1;r.getFullYear()==b&&r.getMonth()+1==f&&r.getDate()==c&&(s=!0);var d=M.getDay(),n=this.nStr1[d];0==d&&(d=7);var i=a,u=this.leapMonth(a),o=!1;for(a=1;a<13&&0<t;a++)e=0<u&&a==u+1&&0==o?(--a,o=!0,this.leapDays(i)):this.monthDays(i,a),1==o&&a==u+1&&(o=!1),t-=e;0==t&&0<u&&a==u+1&&(o?o=!1:(o=!0,--a)),t<0&&(t+=e,--a);var h=a,l=t+1,D=f-1,g=this.toGanZhiYear(i),y=this.getTerm(b,2*f-1),p=this.getTerm(b,2*f),m=this.toGanZhi(12*(b-1900)+f+11);y<=c&&(m=this.toGanZhi(12*(b-1900)+f+12));var r=!1,M=null;y==c&&(r=!0,M=this.solarTerm[2*f-2]),p==c&&(r=!0,M=this.solarTerm[2*f-1]);p=Date.UTC(b,D,1,0,0,0,0)/864e5+25567+10,D=this.toGanZhi(p+c-1),p=this.toAstro(f,c);return{lYear:i,lMonth:h,lDay:l,Animal:this.getAnimal(i),IMonthCn:(o?"闰":"")+this.toChinaMonth(h),IDayCn:this.toChinaDay(l),cYear:b,cMonth:f,cDay:c,gzYear:g,gzMonth:m,gzDay:D,isToday:s,isLeap:o,nWeek:d,ncWeek:"星期"+n,isTerm:r,Term:M,astro:p}},lunar2solar:function(b,f,c,e){var e=!!e,t=this.leapMonth(b);this.leapDays(b);if(e&&t!=f)return-1;if(2100==b&&12==f&&1<c||1900==b&&1==f&&c<31)return-1;var a=this.monthDays(b,f),t=a;if(e&&(t=this.leapDays(b,f)),b<1900||2100<b||t<c)return-1;for(var r=0,s=1900;s<b;s++)r+=this.lYearDays(s);for(var d,n=!1,s=1;s<f;s++)d=this.leapMonth(b),n||d<=s&&0<d&&(r+=this.leapDays(b),n=!0),r+=this.monthDays(b,s);e&&(r+=a);e=Date.UTC(1900,1,30,0,0,0),a=new Date(864e5*(r+c-31)+e),c=a.getUTCFullYear(),e=a.getUTCMonth()+1,a=a.getUTCDate();return this.solar2lunar(c,e,a)}};
|
package/locale/index.ts
ADDED
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import { ref } from 'vue';
|
|
2
|
+
import { isDebugMode, config } from '../libs/config/state';
|
|
3
|
+
import type { Locale, LocaleOption } from '../libs/config/types';
|
|
4
|
+
import enUS from './lang/en-US';
|
|
5
|
+
import zhCN from './lang/zh-CN';
|
|
6
|
+
|
|
7
|
+
const LOCALE_STORAGE_KEY = 'snake-ui-locale';
|
|
8
|
+
|
|
9
|
+
export { enUS, zhCN };
|
|
10
|
+
|
|
11
|
+
export const locales = ref<Locale[]>([zhCN, enUS]);
|
|
12
|
+
export const currentLocale = ref<Locale>(zhCN);
|
|
13
|
+
|
|
14
|
+
let initialized = false;
|
|
15
|
+
|
|
16
|
+
function readLocale(): string | undefined {
|
|
17
|
+
try {
|
|
18
|
+
if (typeof uni !== 'undefined' && typeof uni.getStorageSync === 'function') {
|
|
19
|
+
return uni.getStorageSync(LOCALE_STORAGE_KEY) || undefined;
|
|
20
|
+
}
|
|
21
|
+
} catch (error) {
|
|
22
|
+
if (isDebugMode('warn')) console.warn('[Snake UI] failed to read locale', error);
|
|
23
|
+
}
|
|
24
|
+
return undefined;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function writeLocale(name: string): void {
|
|
28
|
+
try {
|
|
29
|
+
if (typeof uni !== 'undefined' && typeof uni.setStorageSync === 'function') {
|
|
30
|
+
uni.setStorageSync(LOCALE_STORAGE_KEY, name);
|
|
31
|
+
}
|
|
32
|
+
} catch (error) {
|
|
33
|
+
if (isDebugMode('warn')) console.warn('[Snake UI] failed to persist locale', error);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function deepMergeMessages(base: Record<string, unknown>, patch: Record<string, unknown>): Record<string, unknown> {
|
|
38
|
+
const result = { ...base };
|
|
39
|
+
Object.entries(patch).forEach(([key, value]) => {
|
|
40
|
+
const previous = result[key];
|
|
41
|
+
result[key] =
|
|
42
|
+
previous && value && typeof previous === 'object' && typeof value === 'object'
|
|
43
|
+
? deepMergeMessages(previous as Record<string, unknown>, value as Record<string, unknown>)
|
|
44
|
+
: value;
|
|
45
|
+
});
|
|
46
|
+
return result;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function mergeLocales(custom: Locale[]): Locale[] {
|
|
50
|
+
const map = new Map<string, Locale>([
|
|
51
|
+
[zhCN.name, zhCN],
|
|
52
|
+
[enUS.name, enUS]
|
|
53
|
+
]);
|
|
54
|
+
custom.forEach(locale => {
|
|
55
|
+
const base = map.get(locale.name);
|
|
56
|
+
map.set(locale.name, {
|
|
57
|
+
...base,
|
|
58
|
+
...locale,
|
|
59
|
+
messages: deepMergeMessages(base?.messages || {}, locale.messages || {})
|
|
60
|
+
});
|
|
61
|
+
});
|
|
62
|
+
return Array.from(map.values());
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export function initLocale(option?: LocaleOption): void {
|
|
66
|
+
let localeEntries: Locale[] = [];
|
|
67
|
+
let defaultLocale = config.defaultLocale;
|
|
68
|
+
let force = false;
|
|
69
|
+
if (typeof option === 'string') {
|
|
70
|
+
defaultLocale = option;
|
|
71
|
+
} else if (Array.isArray(option)) {
|
|
72
|
+
localeEntries = option;
|
|
73
|
+
} else if (option) {
|
|
74
|
+
localeEntries = option.locales || [];
|
|
75
|
+
defaultLocale = option.defaultLocale || defaultLocale;
|
|
76
|
+
force = Boolean(option.force);
|
|
77
|
+
}
|
|
78
|
+
if (!initialized || force || localeEntries.length) locales.value = mergeLocales(localeEntries);
|
|
79
|
+
const initialName = (force ? undefined : readLocale()) || defaultLocale;
|
|
80
|
+
currentLocale.value =
|
|
81
|
+
locales.value.find(locale => locale.name === initialName) ||
|
|
82
|
+
locales.value.find(locale => locale.name === 'zh-CN') ||
|
|
83
|
+
locales.value[0];
|
|
84
|
+
initialized = true;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export function setLocale(name: string): boolean {
|
|
88
|
+
const locale = locales.value.find(item => item.name === name);
|
|
89
|
+
if (!locale) return false;
|
|
90
|
+
currentLocale.value = locale;
|
|
91
|
+
writeLocale(name);
|
|
92
|
+
return true;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
function readMessage(locale: Locale | undefined, key: string): string | undefined {
|
|
96
|
+
let current: unknown = locale?.messages;
|
|
97
|
+
for (const part of key.split('.')) {
|
|
98
|
+
if (!current || typeof current !== 'object') return undefined;
|
|
99
|
+
current = (current as Record<string, unknown>)[part];
|
|
100
|
+
}
|
|
101
|
+
return typeof current === 'string' ? current : undefined;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
export function translate(
|
|
105
|
+
key: string,
|
|
106
|
+
replacements?: Record<string, unknown> | unknown[],
|
|
107
|
+
localeName?: string
|
|
108
|
+
): string {
|
|
109
|
+
const selected = localeName
|
|
110
|
+
? locales.value.find(locale => locale.name === localeName)
|
|
111
|
+
: currentLocale.value;
|
|
112
|
+
const fallback = locales.value.find(locale => locale.name === 'zh-CN');
|
|
113
|
+
let result = readMessage(selected, key) || readMessage(fallback, key) || key;
|
|
114
|
+
if (Array.isArray(replacements)) {
|
|
115
|
+
replacements.forEach((value, index) => {
|
|
116
|
+
result = result.split(`{${index}}`).join(String(value));
|
|
117
|
+
});
|
|
118
|
+
} else if (replacements) {
|
|
119
|
+
Object.entries(replacements).forEach(([name, value]) => {
|
|
120
|
+
result = result.split(`{${name}}`).join(String(value));
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
return result;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
export function resetLocale(): void {
|
|
127
|
+
initialized = false;
|
|
128
|
+
locales.value = [zhCN, enUS];
|
|
129
|
+
currentLocale.value = zhCN;
|
|
130
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import type { Locale } from '../../libs/config/types';
|
|
2
|
+
|
|
3
|
+
const enUS: Locale = {
|
|
4
|
+
name: 'en-US',
|
|
5
|
+
label: 'English',
|
|
6
|
+
messages: {
|
|
7
|
+
common: {
|
|
8
|
+
confirm: 'Confirm',
|
|
9
|
+
cancel: 'Cancel',
|
|
10
|
+
close: 'Close',
|
|
11
|
+
loading: 'Loading',
|
|
12
|
+
loadMore: 'Load more',
|
|
13
|
+
noMore: 'No more data',
|
|
14
|
+
empty: 'No data',
|
|
15
|
+
retry: 'Retry'
|
|
16
|
+
},
|
|
17
|
+
image: { loading: 'Loading image', error: 'Image failed to load' },
|
|
18
|
+
modal: { title: 'Prompt', confirmText: 'Confirm', cancelText: 'Cancel' },
|
|
19
|
+
network: { error: 'Network request failed', canceled: 'Request canceled' },
|
|
20
|
+
search: { placeholder: 'Please enter keywords', actionText: 'Search' },
|
|
21
|
+
select: { cancelText: 'Cancel', confirmText: 'Confirm' },
|
|
22
|
+
noNetwork: {
|
|
23
|
+
tips: 'Ooops, network disconnected',
|
|
24
|
+
retry: 'Retry',
|
|
25
|
+
noConnection: 'No network connection',
|
|
26
|
+
connected: 'Network connected'
|
|
27
|
+
},
|
|
28
|
+
readMore: { openText: 'Collapse', closeText: 'Read More' },
|
|
29
|
+
link: { mpTips: 'Link copied, please open it in browser' },
|
|
30
|
+
calendar: {
|
|
31
|
+
startText: 'Start',
|
|
32
|
+
endText: 'End',
|
|
33
|
+
toolTip: 'Select date',
|
|
34
|
+
outOfRange: 'Date out of range',
|
|
35
|
+
year: '/',
|
|
36
|
+
month: '',
|
|
37
|
+
sun: 'Sun',
|
|
38
|
+
mon: 'Mon',
|
|
39
|
+
tue: 'Tue',
|
|
40
|
+
wed: 'Wed',
|
|
41
|
+
thu: 'Thu',
|
|
42
|
+
fri: 'Fri',
|
|
43
|
+
sat: 'Sat',
|
|
44
|
+
confirmText: 'Confirm',
|
|
45
|
+
to: ' to ',
|
|
46
|
+
holiday: '休',
|
|
47
|
+
workday: '班'
|
|
48
|
+
},
|
|
49
|
+
countDown: {
|
|
50
|
+
day: 'd',
|
|
51
|
+
hour: 'h',
|
|
52
|
+
minute: 'm',
|
|
53
|
+
second: 's'
|
|
54
|
+
},
|
|
55
|
+
upload: {
|
|
56
|
+
uploadImage: 'Upload image', uploadVideo: 'Upload video', uploadFile: 'Upload file', uploadMedia: 'Upload media',
|
|
57
|
+
retry: 'Retry', reUpload: 'Uploading again', fileNotSupported: 'File selection is not supported on this platform',
|
|
58
|
+
overSize: 'File size exceeds the limit', overMaxCount: 'File count exceeds the limit',
|
|
59
|
+
noAction: 'Configure an upload action or uploadRequest', uploadFailed: 'Upload failed',
|
|
60
|
+
modalTitle: 'Prompt', deleteConfirm: 'Delete this file?', modalCancelText: 'Cancel', modalConfirmText: 'Confirm',
|
|
61
|
+
terminatedRemove: 'Removal canceled', removeSuccess: 'Removed', previewFailed: 'Preview failed',
|
|
62
|
+
openFailed: 'Unable to open this file', notAllowedExt: 'Unsupported file type: {ext}'
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
export default enUS;
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import type { Locale } from '../../libs/config/types';
|
|
2
|
+
|
|
3
|
+
const zhCN: Locale = {
|
|
4
|
+
name: 'zh-CN',
|
|
5
|
+
label: '简体中文',
|
|
6
|
+
messages: {
|
|
7
|
+
common: {
|
|
8
|
+
confirm: '确定',
|
|
9
|
+
cancel: '取消',
|
|
10
|
+
close: '关闭',
|
|
11
|
+
loading: '加载中',
|
|
12
|
+
loadMore: '加载更多',
|
|
13
|
+
noMore: '没有更多了',
|
|
14
|
+
empty: '暂无数据',
|
|
15
|
+
retry: '重试'
|
|
16
|
+
},
|
|
17
|
+
image: { loading: '图片加载中', error: '图片加载失败' },
|
|
18
|
+
modal: { title: '提示', confirmText: '确认', cancelText: '取消' },
|
|
19
|
+
network: { error: '网络请求失败', canceled: '请求已取消' },
|
|
20
|
+
search: { placeholder: '请输入关键字', actionText: '搜索' },
|
|
21
|
+
select: { cancelText: '取消', confirmText: '确认' },
|
|
22
|
+
noNetwork: {
|
|
23
|
+
tips: '哎呀,网络信号丢失',
|
|
24
|
+
retry: '重试',
|
|
25
|
+
noConnection: '无网络连接',
|
|
26
|
+
connected: '网络已连接'
|
|
27
|
+
},
|
|
28
|
+
readMore: { openText: '收起', closeText: '展开阅读全文' },
|
|
29
|
+
link: { mpTips: '链接已复制,请在浏览器打开' },
|
|
30
|
+
calendar: {
|
|
31
|
+
startText: '开始',
|
|
32
|
+
endText: '结束',
|
|
33
|
+
toolTip: '选择日期',
|
|
34
|
+
outOfRange: '日期超出范围啦~',
|
|
35
|
+
year: '年',
|
|
36
|
+
month: '月',
|
|
37
|
+
sun: '日',
|
|
38
|
+
mon: '一',
|
|
39
|
+
tue: '二',
|
|
40
|
+
wed: '三',
|
|
41
|
+
thu: '四',
|
|
42
|
+
fri: '五',
|
|
43
|
+
sat: '六',
|
|
44
|
+
confirmText: '确定',
|
|
45
|
+
to: '至',
|
|
46
|
+
holiday: '休',
|
|
47
|
+
workday: '班'
|
|
48
|
+
},
|
|
49
|
+
countDown: {
|
|
50
|
+
day: '天',
|
|
51
|
+
hour: '时',
|
|
52
|
+
minute: '分',
|
|
53
|
+
second: '秒'
|
|
54
|
+
},
|
|
55
|
+
upload: {
|
|
56
|
+
uploadImage: '上传图片', uploadVideo: '上传视频', uploadFile: '上传文件', uploadMedia: '上传媒体',
|
|
57
|
+
retry: '重试', reUpload: '重新上传', fileNotSupported: '当前平台暂不支持文件选择',
|
|
58
|
+
overSize: '文件大小超出限制', overMaxCount: '文件数量超出限制',
|
|
59
|
+
noAction: '请配置上传地址或自定义上传函数', uploadFailed: '上传失败',
|
|
60
|
+
modalTitle: '提示', deleteConfirm: '确认删除该文件吗?', modalCancelText: '取消', modalConfirmText: '确认',
|
|
61
|
+
terminatedRemove: '已取消删除', removeSuccess: '删除成功', previewFailed: '预览失败',
|
|
62
|
+
openFailed: '无法打开此文件', notAllowedExt: '不支持该文件类型:{ext}'
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
export default zhCN;
|
package/package.json
CHANGED
|
@@ -1,6 +1,131 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
"id": "snake-ui",
|
|
3
|
+
"name": "@puresnake/snake-ui",
|
|
4
|
+
"displayName": "Snake UI",
|
|
5
|
+
"version": "0.0.1",
|
|
6
|
+
"description": "面向 uni-app 商城与 CMS 场景的 Vue 组件库",
|
|
7
|
+
"license": "MIT",
|
|
8
|
+
"author": "PURESNAKE",
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "git+https://github.com/zwbcode/snake-ui.git",
|
|
12
|
+
"directory": "src/uni_modules/snake-ui"
|
|
13
|
+
},
|
|
14
|
+
"bugs": {
|
|
15
|
+
"url": "https://github.com/zwbcode/snake-ui/issues"
|
|
16
|
+
},
|
|
17
|
+
"homepage": "https://github.com/zwbcode/snake-ui#readme",
|
|
18
|
+
"publishConfig": {
|
|
19
|
+
"access": "public"
|
|
20
|
+
},
|
|
21
|
+
"type": "module",
|
|
22
|
+
"main": "index.ts",
|
|
23
|
+
"module": "index.ts",
|
|
24
|
+
"browser": "index.ts",
|
|
25
|
+
"types": "index.d.ts",
|
|
26
|
+
"exports": {
|
|
27
|
+
".": {
|
|
28
|
+
"types": "./index.d.ts",
|
|
29
|
+
"import": "./index.ts",
|
|
30
|
+
"default": "./index.ts"
|
|
31
|
+
},
|
|
32
|
+
"./components/*": "./components/*",
|
|
33
|
+
"./libs": {
|
|
34
|
+
"types": "./libs/index.ts",
|
|
35
|
+
"import": "./libs/index.ts",
|
|
36
|
+
"default": "./libs/index.ts"
|
|
37
|
+
},
|
|
38
|
+
"./request": {
|
|
39
|
+
"types": "./libs/request/index.ts",
|
|
40
|
+
"import": "./libs/request/index.ts",
|
|
41
|
+
"default": "./libs/request/index.ts"
|
|
42
|
+
},
|
|
43
|
+
"./types": "./types/index.d.ts",
|
|
44
|
+
"./types/*": "./types/*.d.ts",
|
|
45
|
+
"./plugins": {
|
|
46
|
+
"types": "./plugins/index.ts",
|
|
47
|
+
"import": "./plugins/index.ts",
|
|
48
|
+
"default": "./plugins/index.ts"
|
|
49
|
+
},
|
|
50
|
+
"./locale": "./locale/index.ts",
|
|
51
|
+
"./index.scss": "./index.scss",
|
|
52
|
+
"./theme.scss": "./theme.scss",
|
|
53
|
+
"./package.json": "./package.json"
|
|
54
|
+
},
|
|
55
|
+
"files": [
|
|
56
|
+
"components",
|
|
57
|
+
"libs",
|
|
58
|
+
"locale",
|
|
59
|
+
"plugins",
|
|
60
|
+
"types",
|
|
61
|
+
"index.ts",
|
|
62
|
+
"index.d.ts",
|
|
63
|
+
"index.scss",
|
|
64
|
+
"theme.scss",
|
|
65
|
+
"iconfont.css",
|
|
66
|
+
"LICENSE",
|
|
67
|
+
"readme.md",
|
|
68
|
+
"changelog.md"
|
|
69
|
+
],
|
|
70
|
+
"keywords": [
|
|
71
|
+
"snake-ui",
|
|
72
|
+
"uni-app",
|
|
73
|
+
"vue3",
|
|
74
|
+
"cms"
|
|
75
|
+
],
|
|
76
|
+
"engines": {
|
|
77
|
+
"uni-app": "*"
|
|
78
|
+
},
|
|
79
|
+
"dcloudext": {
|
|
80
|
+
"type": "component-vue"
|
|
81
|
+
},
|
|
82
|
+
"peerDependencies": {
|
|
83
|
+
"@dcloudio/uni-app": ">=3.0.0",
|
|
84
|
+
"vue": ">=3.4.0"
|
|
85
|
+
},
|
|
86
|
+
"uni_modules": {
|
|
87
|
+
"dependencies": [],
|
|
88
|
+
"encrypt": [],
|
|
89
|
+
"platforms": {
|
|
90
|
+
"cloud": {
|
|
91
|
+
"tcb": "-",
|
|
92
|
+
"aliyun": "-",
|
|
93
|
+
"alipay": "-"
|
|
94
|
+
},
|
|
95
|
+
"client": {
|
|
96
|
+
"uni-app": {
|
|
97
|
+
"vue": {
|
|
98
|
+
"vue2": "x",
|
|
99
|
+
"vue3": "√"
|
|
100
|
+
},
|
|
101
|
+
"web": {
|
|
102
|
+
"safari": "-",
|
|
103
|
+
"chrome": "-"
|
|
104
|
+
},
|
|
105
|
+
"app": {
|
|
106
|
+
"vue": "-",
|
|
107
|
+
"nvue": "x",
|
|
108
|
+
"android": "-",
|
|
109
|
+
"ios": "-",
|
|
110
|
+
"harmony": "-"
|
|
111
|
+
},
|
|
112
|
+
"mp": {
|
|
113
|
+
"weixin": "-",
|
|
114
|
+
"alipay": "-",
|
|
115
|
+
"toutiao": "-",
|
|
116
|
+
"baidu": "-",
|
|
117
|
+
"kuaishou": "-",
|
|
118
|
+
"jd": "-",
|
|
119
|
+
"harmony": "-",
|
|
120
|
+
"qq": "-",
|
|
121
|
+
"lark": "-"
|
|
122
|
+
},
|
|
123
|
+
"quickapp": {
|
|
124
|
+
"huawei": "-",
|
|
125
|
+
"union": "-"
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
}
|
package/plugins/index.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './root';
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
# vite-plugin-snake-root
|
|
2
|
+
|
|
3
|
+
Snake UI 虚拟根组件 Vite 插件,零额外依赖,纯字符串操作实现。
|
|
4
|
+
|
|
5
|
+
## 解决的问题
|
|
6
|
+
|
|
7
|
+
UniApp 不支持原生的根组件包裹机制,无法在全局统一注入 `snake-config-provider`、toast、modal 等需要在每个页面根部存在的组件。传统方案需要在每个页面手动添加,维护成本高。
|
|
8
|
+
|
|
9
|
+
本插件通过 Vite 构建时注入,自动为每个页面包裹 `<global-root-view>` 根组件,无需修改任何页面代码本身。
|
|
10
|
+
|
|
11
|
+
## 技术方案
|
|
12
|
+
|
|
13
|
+
```
|
|
14
|
+
App.root.vue(源码) → 在 main.ts 中导入并注册为全局组件 global-root-view
|
|
15
|
+
→ 页面模板被包裹 <global-root-view> 页面内容 </global-root-view>
|
|
16
|
+
→ 渲染时页面内容填入 <slot />
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
三步实现:
|
|
20
|
+
|
|
21
|
+
1. **main.ts 注入**(`root.ts -> registerRootApp`)
|
|
22
|
+
- 注入 `import GlobalRootView from "./App.root.vue"` 与 `app.component("global-root-view", GlobalRootView)`
|
|
23
|
+
2. **页面模板包裹**(`page.ts -> transformPage`)
|
|
24
|
+
- 解析 SFC,提取 PageMeta 节点(如有则放到包裹层外部),模板内容包裹 `<global-root-view>`
|
|
25
|
+
3. **App.root.vue 加载**(`index.ts -> load`)
|
|
26
|
+
- 拦截 `App.root.vue` 的模块请求,从文件读取并返回;模板中的 `<slot />` 接收页面内容
|
|
27
|
+
|
|
28
|
+
## 使用方式
|
|
29
|
+
|
|
30
|
+
### 1. 创建 App.root.vue(应用级,放在 src/ 下)
|
|
31
|
+
|
|
32
|
+
```vue
|
|
33
|
+
<script setup lang="ts">
|
|
34
|
+
import ConfigProvider from './uni_modules/snake-ui/components/snake-config-provider/snake-config-provider.vue';
|
|
35
|
+
</script>
|
|
36
|
+
|
|
37
|
+
<template>
|
|
38
|
+
<ConfigProvider>
|
|
39
|
+
<slot />
|
|
40
|
+
</ConfigProvider>
|
|
41
|
+
</template>
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
关键点:`<slot />` 是页面内容的渲染位置,必须保留。
|
|
45
|
+
|
|
46
|
+
### 2. 配置 vite.config.ts
|
|
47
|
+
|
|
48
|
+
```ts
|
|
49
|
+
import { Root } from './src/uni_modules/snake-ui/plugins';
|
|
50
|
+
|
|
51
|
+
export default defineConfig({
|
|
52
|
+
plugins: [Root(), uni()]
|
|
53
|
+
});
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
### 3. 运行
|
|
57
|
+
|
|
58
|
+
不需要修改任何页面代码,所有页面自动被 `<global-root-view>` 包裹。
|
|
59
|
+
|
|
60
|
+
## 配置项
|
|
61
|
+
|
|
62
|
+
```ts
|
|
63
|
+
Root({
|
|
64
|
+
rootFileName: 'App.root' // 根组件文件名(不含扩展名),默认 App.root
|
|
65
|
+
});
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
## 跨端兼容
|
|
69
|
+
|
|
70
|
+
纯 Vite 构建时插件,在 UniApp 编译之前完成源代码转换,不依赖任何平台特定 API:
|
|
71
|
+
|
|
72
|
+
H5 / 微信小程序 / 支付宝小程序 / 头条抖音小程序 / Android App / iOS App / 鸿蒙 App 均支持。
|
|
73
|
+
|
|
74
|
+
## HMR 支持
|
|
75
|
+
|
|
76
|
+
修改 `pages.json` 后自动重载页面列表,无需手动重启开发服务器。
|
|
77
|
+
|
|
78
|
+
## 注意事项
|
|
79
|
+
|
|
80
|
+
- Vue 版本需 >= 3.2.13(使用 `vue/compiler-sfc` 的 `parse` API,HBuilderX 环境下自动降级为正则匹配)
|
|
81
|
+
- 页面模板中如有 `<page-meta>` 组件,会被提取到包裹层外部,确保微信小程序兼容
|
|
82
|
+
- 页面模板中如有嵌套 `<template #slot>` 具名插槽,不影响根模板的正确识别
|
|
83
|
+
|
|
84
|
+
## 致谢
|
|
85
|
+
|
|
86
|
+
- 实现参考了 [@uni-ku/root](https://github.com/uni-ku/root)(MIT License,作者 skiyee),核心思路受其启发并进行了重新实现。
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import type { Plugin } from 'vite';
|
|
2
|
+
import { resolve, join } from 'node:path';
|
|
3
|
+
import process from 'node:process';
|
|
4
|
+
import { watch, readFileSync } from 'node:fs';
|
|
5
|
+
import { normalizePath } from 'vite';
|
|
6
|
+
import { registerRootApp, rebuildRootApp } from './root';
|
|
7
|
+
import { transformPage } from './page';
|
|
8
|
+
import { loadPagesJson, normalizePlatformPath, debounce } from './utils';
|
|
9
|
+
|
|
10
|
+
interface RootOptions {
|
|
11
|
+
/** 根组件文件名(不含扩展名),默认 App.root */
|
|
12
|
+
rootFileName?: string;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* 规范化模块 ID:统一路径分隔符,统一 Windows 盘符为小写
|
|
17
|
+
*/
|
|
18
|
+
function normalizeId(id: string) {
|
|
19
|
+
return normalizePath(id).replace(/^[A-Z]:/, match => match.toLowerCase());
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Snake UI 虚拟根组件 Vite 插件(uni-root 实现)
|
|
24
|
+
*
|
|
25
|
+
* ## 解决的问题
|
|
26
|
+
* UniApp 不支持原生的根组件包裹机制,导致无法在全局统一注入
|
|
27
|
+
* snake-config-provider、toast、modal 等需要在每个页面根部存在的组件。
|
|
28
|
+
*
|
|
29
|
+
* ## 工作原理
|
|
30
|
+
* 1. 在 main.ts 中注入 App.root.vue 的导入,并注册为全局组件 global-root-view
|
|
31
|
+
* 2. 在每个页面的 <template> 中包裹 <global-root-view> 标签
|
|
32
|
+
* 3. App.root.vue 中的 <slot /> 渲染页面内容
|
|
33
|
+
*
|
|
34
|
+
* ## 支持 HMR
|
|
35
|
+
* pages.json 变更时自动重载页面列表,无需手动重启
|
|
36
|
+
*
|
|
37
|
+
* ## 跨端兼容
|
|
38
|
+
* 纯 Vite 构建时插件,在所有 UniApp 支持的平台(H5、微信小程序、支付宝小程序、
|
|
39
|
+
* 头条小程序、Android App、iOS App、鸿蒙 App)均可正常工作
|
|
40
|
+
*/
|
|
41
|
+
export function Root(options?: RootOptions): Plugin {
|
|
42
|
+
const resolvedOptions: Required<RootOptions> = {
|
|
43
|
+
rootFileName: 'App.root',
|
|
44
|
+
...options
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
const rootPath = process.env.UNI_INPUT_DIR || join(process.cwd(), 'src');
|
|
48
|
+
const appRootPath = resolve(rootPath, `${resolvedOptions.rootFileName}.vue`);
|
|
49
|
+
const pagesPath = resolve(rootPath, 'pages.json');
|
|
50
|
+
|
|
51
|
+
let pagesJson = loadPagesJson(pagesPath, rootPath);
|
|
52
|
+
let watcher: ReturnType<typeof watch> | null = null;
|
|
53
|
+
let hasPlatformPlugin = false;
|
|
54
|
+
|
|
55
|
+
const normalizedAppRoot = normalizeId(appRootPath);
|
|
56
|
+
|
|
57
|
+
return {
|
|
58
|
+
name: 'vite-plugin-snake-root',
|
|
59
|
+
enforce: 'pre', // 在其他插件之前执行,确保页面模板先被包裹
|
|
60
|
+
|
|
61
|
+
configResolved({ plugins }) {
|
|
62
|
+
// 检测是否有 uni-platform 插件,用于处理平台特定页面路径(如 .mp-weixin.vue)
|
|
63
|
+
hasPlatformPlugin = plugins.some(v => v.name === 'vite-plugin-uni-platform');
|
|
64
|
+
},
|
|
65
|
+
|
|
66
|
+
configureServer(server) {
|
|
67
|
+
// 监听 pages.json 变更,HMR 热重载页面列表
|
|
68
|
+
const reload = debounce(() => {
|
|
69
|
+
try {
|
|
70
|
+
pagesJson = loadPagesJson(pagesPath, rootPath);
|
|
71
|
+
server.ws.send({ type: 'full-reload' });
|
|
72
|
+
} catch (e) {
|
|
73
|
+
console.error('[vite-plugin-snake-root] pages.json reload failed:', e);
|
|
74
|
+
}
|
|
75
|
+
}, 100);
|
|
76
|
+
|
|
77
|
+
watcher = watch(pagesPath, eventType => {
|
|
78
|
+
if (eventType === 'change') reload();
|
|
79
|
+
});
|
|
80
|
+
},
|
|
81
|
+
|
|
82
|
+
load(id) {
|
|
83
|
+
const normalizedId = normalizeId(id);
|
|
84
|
+
// 只拦截根 SFC 请求,不拦截 Vue 子模块请求(如 ?vue&type=script)
|
|
85
|
+
if (normalizedId === normalizedAppRoot) {
|
|
86
|
+
const code = readFileSync(appRootPath, 'utf-8');
|
|
87
|
+
return rebuildRootApp(code).code;
|
|
88
|
+
}
|
|
89
|
+
},
|
|
90
|
+
|
|
91
|
+
async transform(code, id) {
|
|
92
|
+
const normalizedId = normalizeId(id);
|
|
93
|
+
const normalizedRootPath = normalizeId(rootPath);
|
|
94
|
+
|
|
95
|
+
// 注入 App.root.vue 的导入,并注册为全局组件 global-root-view
|
|
96
|
+
if (normalizedId === `${normalizedRootPath}/main.ts` || normalizedId === `${normalizedRootPath}/main.js`) {
|
|
97
|
+
return registerRootApp(code, resolvedOptions.rootFileName);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
// App.root.vue 兜底处理(已在 load 中处理,此处只处理根 SFC)
|
|
101
|
+
if (normalizedId === normalizedAppRoot) {
|
|
102
|
+
return rebuildRootApp(code);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
// 页面模板包裹 <global-root-view>
|
|
106
|
+
const pageId = hasPlatformPlugin ? normalizePlatformPath(normalizedId) : normalizedId;
|
|
107
|
+
const isPage = pagesJson.some(p => pageId === p || pageId.startsWith(`${p}?`));
|
|
108
|
+
if (isPage) {
|
|
109
|
+
return transformPage(code);
|
|
110
|
+
}
|
|
111
|
+
},
|
|
112
|
+
|
|
113
|
+
buildEnd() {
|
|
114
|
+
if (watcher) {
|
|
115
|
+
watcher.close();
|
|
116
|
+
watcher = null;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
export default Root;
|
|
123
|
+
export type { RootOptions };
|