Skip to content

Commit 70f5811

Browse files
committed
fix: 修复 import_meta.glob is not a function
1 parent a344c1a commit 70f5811

File tree

6 files changed

+18
-14
lines changed

6 files changed

+18
-14
lines changed

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "vue3-hash-calendar",
3-
"version": "1.0.1",
3+
"version": "1.0.3",
44
"author": "HashTang",
55
"repository": {
66
"type": "git",

src/calendar/CalendarDate.tsx

+3-2
Original file line numberDiff line numberDiff line change
@@ -871,8 +871,9 @@ export default defineComponent({
871871
{item.map((date, j) => (
872872
<div
873873
class={`calendar_item ${
874-
formatDisabledDate(date) &&
875-
(props.disabledClassName || 'calendar_item_disable')
874+
formatDisabledDate(date)
875+
? props.disabledClassName || 'calendar_item_disable'
876+
: ''
876877
}`}
877878
ref={(el) => {
878879
calendarItemRef.length = 0;

src/calendar/index.less

+1
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,7 @@
158158
.fontSize(28px);
159159
.flexContent();
160160
margin-bottom: 8px;
161+
.mainFontColor(color);
161162
}
162163

163164
.calendar_first_today {

src/calendar/language/index.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
* @CreateDate: 2020/3/22 22:01
55
*/
66

7-
import CN from "./cn";
8-
import EN from "./en";
7+
import CN from './cn';
8+
import EN from './en';
99

1010
export type LanguageEntityType = {
1111
CONFIRM: string;
@@ -16,7 +16,7 @@ export type LanguageEntityType = {
1616
DEFAULT_TIME_FORMAT: string;
1717
};
1818

19-
export const LanguageTypes = ["CN", "EN"] as const;
19+
export const LanguageTypes = ['CN', 'EN'] as const;
2020

2121
export type LanguageType = typeof LanguageTypes[number];
2222

src/calendar/utils/basic.ts

+9-7
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
import { isLeap } from '.';
2+
import language from '../language';
3+
import { LangType } from '../types';
24

35
/**
46
* 日期格式化
@@ -9,14 +11,12 @@ import { isLeap } from '.';
911
export const formatDate = function (
1012
time: Date | string,
1113
format: string,
12-
lang = 'CN'
14+
lang: LangType = 'CN'
1315
) {
14-
lang = lang.toUpperCase();
15-
const models = import.meta.globEager('../language/index.ts');
16-
const model: any = models[Object.keys(models)[0]];
17-
const language = model.default[lang] || {};
16+
const languageEntiy = language[lang] || {};
1817
format =
19-
format || `${language.DEFAULT_DATE_FORMAT} ${language.DEFAULT_TIME_FORMAT}`;
18+
format ||
19+
`${languageEntiy.DEFAULT_DATE_FORMAT} ${languageEntiy.DEFAULT_TIME_FORMAT}`;
2020
const date = time ? new Date(time) : new Date();
2121
const year = date.getFullYear();
2222
const month = date.getMonth() + 1; // 月份是从0开始的
@@ -43,7 +43,9 @@ export const formatDate = function (
4343
.replace(/DD/g, preArr[day] || day + '')
4444
.replace(
4545
/MM/g,
46-
lang === 'EN' ? language.MONTH[month - 1] : preArr[month] || month
46+
lang === 'EN'
47+
? languageEntiy.MONTH[month - 1]
48+
: preArr[month] || month + ''
4749
);
4850

4951
return newTime;

vant.config.mjs

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ export default {
5050
site: {
5151
publicPath: '/calendar/',
5252
},
53-
// srcDir: process.env.BUILD_TARGET === 'site' ? './src' : './src/calendar',
53+
srcDir: process.env.BUILD_TARGET === 'site' ? './src' : './src/calendar',
5454
},
5555
site: {
5656
title: 'vue3-hash-calendar',

0 commit comments

Comments
 (0)