@sanguo-dev/calendar-ui-lunar 0.0.2 → 0.0.3
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/README.md +82 -82
- package/dist/index.cjs +7 -7
- package/dist/index.d.cts +3 -3
- package/dist/index.d.mts +3 -3
- package/dist/index.mjs +3 -3
- package/package.json +65 -65
- package/src/index.ts +177 -177
- package/theme.css +66 -66
package/README.md
CHANGED
|
@@ -1,82 +1,82 @@
|
|
|
1
|
-
# calendar-ui-lunar
|
|
2
|
-
|
|
3
|
-
`@
|
|
4
|
-
|
|
5
|
-
## 用法
|
|
6
|
-
|
|
7
|
-
```ts
|
|
8
|
-
import { createCalendarLunar } from "@
|
|
9
|
-
import "@
|
|
10
|
-
import "@
|
|
11
|
-
|
|
12
|
-
const instance = createCalendarLunar(container, {
|
|
13
|
-
weekStartsOn: 1,
|
|
14
|
-
onSelect: (day) => {
|
|
15
|
-
console.log(day.data?.lMonthCn, day.data?.nljr);
|
|
16
|
-
},
|
|
17
|
-
});
|
|
18
|
-
```
|
|
19
|
-
|
|
20
|
-
## 主题
|
|
21
|
-
|
|
22
|
-
自带一套农历喜庆红(淡色系)皮肤,`createCalendarLunar()` 会给根节点加 `cui--lunar` 类:
|
|
23
|
-
|
|
24
|
-
```ts
|
|
25
|
-
import "@
|
|
26
|
-
import "@
|
|
27
|
-
```
|
|
28
|
-
|
|
29
|
-
- light / dark / auto 三种主题都有对应配色;
|
|
30
|
-
- 只改某个实例时,用自己的容器包一层:`.my-calendar .cui--lunar { --cui-accent: #c2410c; }`;
|
|
31
|
-
- 不引入 `theme.css` 时就是 `@
|
|
32
|
-
|
|
33
|
-
## 选项
|
|
34
|
-
|
|
35
|
-
在 `@
|
|
36
|
-
|
|
37
|
-
| 选项 | 类型 | 说明 |
|
|
38
|
-
| ----------------- | --------------- | ------------------------------------------------------ |
|
|
39
|
-
| `holidays` | `HolidayConfig` | 本实例的节假日 / 调休配置 |
|
|
40
|
-
| `replaceHolidays` | `boolean` | 为 `true` 时忽略内置节日 / 调休数据,只使用 `holidays` |
|
|
41
|
-
|
|
42
|
-
不传 `holidays` 时使用**内置数据**,不再有全局 `setHolidays()`。
|
|
43
|
-
|
|
44
|
-
## 数据
|
|
45
|
-
|
|
46
|
-
- `day.subtitle`:节气 > 农历节日 > 公历节日 > 农历日;
|
|
47
|
-
- `day.badge`:`xiu` 为休、`ban` 为班,均来自配置数据,与周末无关;
|
|
48
|
-
- `day.data`:完整的 `LunarResult`,包括 `xiu`、`ban`、`gljr`、`nljr` 等。
|
|
49
|
-
|
|
50
|
-
`day.data` 在 1900-01-31 ~ 2100-12-31 之外为 `null`。
|
|
51
|
-
|
|
52
|
-
## 多套配置
|
|
53
|
-
|
|
54
|
-
```ts
|
|
55
|
-
const mainland = createCalendarLunar(hostA, { holidays: mainlandHolidays });
|
|
56
|
-
const hongKong = createCalendarLunar(hostB, { holidays: hongKongHolidays });
|
|
57
|
-
```
|
|
58
|
-
|
|
59
|
-
- 配置在 `createCalendarLunar()` 时校验并固定,之后修改对象内容不会生效;
|
|
60
|
-
- 不同配置对象互不影响;
|
|
61
|
-
- 多个实例传**同一个配置对象**时会共享月份缓存,建议把配置提到模块级常量。
|
|
62
|
-
|
|
63
|
-
## 直接使用适配器
|
|
64
|
-
|
|
65
|
-
```ts
|
|
66
|
-
import { createCalendarUI } from "@
|
|
67
|
-
import { createLunarAdapter } from "@
|
|
68
|
-
|
|
69
|
-
const adapter = createLunarAdapter({
|
|
70
|
-
holidays: { setRest: { 2027: { xiu: ["0101"], ban: ["0104"] } } },
|
|
71
|
-
});
|
|
72
|
-
|
|
73
|
-
const instance = createCalendarUI(container, { adapter });
|
|
74
|
-
```
|
|
75
|
-
|
|
76
|
-
## 开发
|
|
77
|
-
|
|
78
|
-
```bash
|
|
79
|
-
vp test
|
|
80
|
-
vp run build
|
|
81
|
-
vp check
|
|
82
|
-
```
|
|
1
|
+
# calendar-ui-lunar
|
|
2
|
+
|
|
3
|
+
`@sanguo-dev/calendar-ui` 的官方农历适配器,把 `@sanguo-dev/calendar` 的农历、节气、节日和调休数据接到纯公历核心上。
|
|
4
|
+
|
|
5
|
+
## 用法
|
|
6
|
+
|
|
7
|
+
```ts
|
|
8
|
+
import { createCalendarLunar } from "@sanguo-dev/calendar-ui-lunar";
|
|
9
|
+
import "@sanguo-dev/calendar-ui/style.css";
|
|
10
|
+
import "@sanguo-dev/calendar-ui-lunar/theme.css";
|
|
11
|
+
|
|
12
|
+
const instance = createCalendarLunar(container, {
|
|
13
|
+
weekStartsOn: 1,
|
|
14
|
+
onSelect: (day) => {
|
|
15
|
+
console.log(day.data?.lMonthCn, day.data?.nljr);
|
|
16
|
+
},
|
|
17
|
+
});
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## 主题
|
|
21
|
+
|
|
22
|
+
自带一套农历喜庆红(淡色系)皮肤,`createCalendarLunar()` 会给根节点加 `cui--lunar` 类:
|
|
23
|
+
|
|
24
|
+
```ts
|
|
25
|
+
import "@sanguo-dev/calendar-ui/style.css";
|
|
26
|
+
import "@sanguo-dev/calendar-ui-lunar/theme.css";
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
- light / dark / auto 三种主题都有对应配色;
|
|
30
|
+
- 只改某个实例时,用自己的容器包一层:`.my-calendar .cui--lunar { --cui-accent: #c2410c; }`;
|
|
31
|
+
- 不引入 `theme.css` 时就是 `@sanguo-dev/calendar-ui` 的默认皮肤。
|
|
32
|
+
|
|
33
|
+
## 选项
|
|
34
|
+
|
|
35
|
+
在 `@sanguo-dev/calendar-ui` 的全部选项之外,额外支持:
|
|
36
|
+
|
|
37
|
+
| 选项 | 类型 | 说明 |
|
|
38
|
+
| ----------------- | --------------- | ------------------------------------------------------ |
|
|
39
|
+
| `holidays` | `HolidayConfig` | 本实例的节假日 / 调休配置 |
|
|
40
|
+
| `replaceHolidays` | `boolean` | 为 `true` 时忽略内置节日 / 调休数据,只使用 `holidays` |
|
|
41
|
+
|
|
42
|
+
不传 `holidays` 时使用**内置数据**,不再有全局 `setHolidays()`。
|
|
43
|
+
|
|
44
|
+
## 数据
|
|
45
|
+
|
|
46
|
+
- `day.subtitle`:节气 > 农历节日 > 公历节日 > 农历日;
|
|
47
|
+
- `day.badge`:`xiu` 为休、`ban` 为班,均来自配置数据,与周末无关;
|
|
48
|
+
- `day.data`:完整的 `LunarResult`,包括 `xiu`、`ban`、`gljr`、`nljr` 等。
|
|
49
|
+
|
|
50
|
+
`day.data` 在 1900-01-31 ~ 2100-12-31 之外为 `null`。
|
|
51
|
+
|
|
52
|
+
## 多套配置
|
|
53
|
+
|
|
54
|
+
```ts
|
|
55
|
+
const mainland = createCalendarLunar(hostA, { holidays: mainlandHolidays });
|
|
56
|
+
const hongKong = createCalendarLunar(hostB, { holidays: hongKongHolidays });
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
- 配置在 `createCalendarLunar()` 时校验并固定,之后修改对象内容不会生效;
|
|
60
|
+
- 不同配置对象互不影响;
|
|
61
|
+
- 多个实例传**同一个配置对象**时会共享月份缓存,建议把配置提到模块级常量。
|
|
62
|
+
|
|
63
|
+
## 直接使用适配器
|
|
64
|
+
|
|
65
|
+
```ts
|
|
66
|
+
import { createCalendarUI } from "@sanguo-dev/calendar-ui";
|
|
67
|
+
import { createLunarAdapter } from "@sanguo-dev/calendar-ui-lunar";
|
|
68
|
+
|
|
69
|
+
const adapter = createLunarAdapter({
|
|
70
|
+
holidays: { setRest: { 2027: { xiu: ["0101"], ban: ["0104"] } } },
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
const instance = createCalendarUI(container, { adapter });
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
## 开发
|
|
77
|
+
|
|
78
|
+
```bash
|
|
79
|
+
vp test
|
|
80
|
+
vp run build
|
|
81
|
+
vp check
|
|
82
|
+
```
|
package/dist/index.cjs
CHANGED
|
@@ -20,13 +20,13 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
20
20
|
value: mod,
|
|
21
21
|
enumerable: true
|
|
22
22
|
}) : target, mod));
|
|
23
|
-
let
|
|
24
|
-
|
|
25
|
-
let
|
|
23
|
+
let _sanguo_dev_calendar = require("@sanguo-dev/calendar");
|
|
24
|
+
_sanguo_dev_calendar = __toESM(_sanguo_dev_calendar, 1);
|
|
25
|
+
let _sanguo_dev_calendar_ui = require("@sanguo-dev/calendar-ui");
|
|
26
26
|
// src/index.ts
|
|
27
27
|
const CACHE_LIMIT = 24;
|
|
28
28
|
const monthCache = /* @__PURE__ */ new Map();
|
|
29
|
-
const DEFAULT_CALENDAR = (0,
|
|
29
|
+
const DEFAULT_CALENDAR = (0, _sanguo_dev_calendar.default)();
|
|
30
30
|
const DEFAULT_SOURCE = {
|
|
31
31
|
id: 0,
|
|
32
32
|
solarToLunar: (year, month, day) => DEFAULT_CALENDAR.solarToLunar(year, month, day)
|
|
@@ -44,7 +44,7 @@ const resolveSource = function(holidays, replace = false) {
|
|
|
44
44
|
const mode = replace ? "replace" : "merge";
|
|
45
45
|
const cached = entry[mode];
|
|
46
46
|
if (cached) return cached;
|
|
47
|
-
const calendar = (0,
|
|
47
|
+
const calendar = (0, _sanguo_dev_calendar.default)(holidays, replace ? { replace: true } : {});
|
|
48
48
|
const source = {
|
|
49
49
|
id: nextSourceId++,
|
|
50
50
|
solarToLunar: (year, month, day) => calendar.solarToLunar(year, month, day)
|
|
@@ -79,7 +79,7 @@ const decorateDate = function(source, date) {
|
|
|
79
79
|
data: lunar
|
|
80
80
|
};
|
|
81
81
|
};
|
|
82
|
-
/** 创建使用 @
|
|
82
|
+
/** 创建使用 @sanguo-dev/calendar 的农历适配器 */
|
|
83
83
|
const createLunarAdapter = function(options = {}) {
|
|
84
84
|
const source = resolveSource(options.holidays, options.replaceHolidays === true);
|
|
85
85
|
return {
|
|
@@ -109,7 +109,7 @@ const createLunarAdapter = function(options = {}) {
|
|
|
109
109
|
*/
|
|
110
110
|
const createCalendarLunar = function(container, options = {}) {
|
|
111
111
|
const { holidays, replaceHolidays, adapter, ...rest } = options;
|
|
112
|
-
const instance = (0,
|
|
112
|
+
const instance = (0, _sanguo_dev_calendar_ui.createCalendarUI)(container, {
|
|
113
113
|
...rest,
|
|
114
114
|
adapter: adapter ?? createLunarAdapter({
|
|
115
115
|
holidays,
|
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { HolidayConfig, HolidayConfig as HolidayConfig$1, LunarResult, LunarResult as LunarResult$1 } from "@
|
|
2
|
-
import { CalendarAdapter, CalendarAdapter as CalendarAdapter$1, CalendarBadge, CalendarDate, CalendarDateInput, CalendarDay, CalendarDay as CalendarDay$1, CalendarInstance, CalendarInstance as CalendarInstance$1, CalendarMode, CalendarOptions, CalendarOptions as CalendarOptions$1, CalendarRange, CalendarTheme, DayDecoration, MonthInput, WeekStartsOn, YearMonth } from "@
|
|
1
|
+
import { HolidayConfig, HolidayConfig as HolidayConfig$1, LunarResult, LunarResult as LunarResult$1 } from "@sanguo-dev/calendar";
|
|
2
|
+
import { CalendarAdapter, CalendarAdapter as CalendarAdapter$1, CalendarBadge, CalendarDate, CalendarDateInput, CalendarDay, CalendarDay as CalendarDay$1, CalendarInstance, CalendarInstance as CalendarInstance$1, CalendarMode, CalendarOptions, CalendarOptions as CalendarOptions$1, CalendarRange, CalendarTheme, DayDecoration, MonthInput, WeekStartsOn, YearMonth } from "@sanguo-dev/calendar-ui";
|
|
3
3
|
export interface LunarAdapterOptions {
|
|
4
4
|
/** 本适配器使用的节假日 / 调休配置;不传时使用内置数据 */
|
|
5
5
|
holidays?: HolidayConfig$1;
|
|
@@ -14,7 +14,7 @@ export interface LunarCalendarOptions extends CalendarOptions$1<LunarResult$1> {
|
|
|
14
14
|
}
|
|
15
15
|
/** 带农历数据的日历格 */
|
|
16
16
|
export type LunarCalendarDay = CalendarDay$1<LunarResult$1>;
|
|
17
|
-
/** 创建使用 @
|
|
17
|
+
/** 创建使用 @sanguo-dev/calendar 的农历适配器 */
|
|
18
18
|
export declare const createLunarAdapter: (options?: LunarAdapterOptions) => CalendarAdapter$1<LunarResult$1>;
|
|
19
19
|
/**
|
|
20
20
|
* 创建带农历 / 节气 / 节日 / 调休的日历
|
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { HolidayConfig, HolidayConfig as HolidayConfig$1, LunarResult, LunarResult as LunarResult$1 } from "@
|
|
2
|
-
import { CalendarAdapter, CalendarAdapter as CalendarAdapter$1, CalendarBadge, CalendarDate, CalendarDateInput, CalendarDay, CalendarDay as CalendarDay$1, CalendarInstance, CalendarInstance as CalendarInstance$1, CalendarMode, CalendarOptions, CalendarOptions as CalendarOptions$1, CalendarRange, CalendarTheme, DayDecoration, MonthInput, WeekStartsOn, YearMonth } from "@
|
|
1
|
+
import { HolidayConfig, HolidayConfig as HolidayConfig$1, LunarResult, LunarResult as LunarResult$1 } from "@sanguo-dev/calendar";
|
|
2
|
+
import { CalendarAdapter, CalendarAdapter as CalendarAdapter$1, CalendarBadge, CalendarDate, CalendarDateInput, CalendarDay, CalendarDay as CalendarDay$1, CalendarInstance, CalendarInstance as CalendarInstance$1, CalendarMode, CalendarOptions, CalendarOptions as CalendarOptions$1, CalendarRange, CalendarTheme, DayDecoration, MonthInput, WeekStartsOn, YearMonth } from "@sanguo-dev/calendar-ui";
|
|
3
3
|
export interface LunarAdapterOptions {
|
|
4
4
|
/** 本适配器使用的节假日 / 调休配置;不传时使用内置数据 */
|
|
5
5
|
holidays?: HolidayConfig$1;
|
|
@@ -14,7 +14,7 @@ export interface LunarCalendarOptions extends CalendarOptions$1<LunarResult$1> {
|
|
|
14
14
|
}
|
|
15
15
|
/** 带农历数据的日历格 */
|
|
16
16
|
export type LunarCalendarDay = CalendarDay$1<LunarResult$1>;
|
|
17
|
-
/** 创建使用 @
|
|
17
|
+
/** 创建使用 @sanguo-dev/calendar 的农历适配器 */
|
|
18
18
|
export declare const createLunarAdapter: (options?: LunarAdapterOptions) => CalendarAdapter$1<LunarResult$1>;
|
|
19
19
|
/**
|
|
20
20
|
* 创建带农历 / 节气 / 节日 / 调休的日历
|
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import createCalendar from "@
|
|
2
|
-
import { createCalendarUI } from "@
|
|
1
|
+
import createCalendar from "@sanguo-dev/calendar";
|
|
2
|
+
import { createCalendarUI } from "@sanguo-dev/calendar-ui";
|
|
3
3
|
// src/index.ts
|
|
4
4
|
const CACHE_LIMIT = 24;
|
|
5
5
|
const monthCache = /* @__PURE__ */ new Map();
|
|
@@ -56,7 +56,7 @@ const decorateDate = function(source, date) {
|
|
|
56
56
|
data: lunar
|
|
57
57
|
};
|
|
58
58
|
};
|
|
59
|
-
/** 创建使用 @
|
|
59
|
+
/** 创建使用 @sanguo-dev/calendar 的农历适配器 */
|
|
60
60
|
const createLunarAdapter = function(options = {}) {
|
|
61
61
|
const source = resolveSource(options.holidays, options.replaceHolidays === true);
|
|
62
62
|
return {
|
package/package.json
CHANGED
|
@@ -1,65 +1,65 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@sanguo-dev/calendar-ui-lunar",
|
|
3
|
-
"version": "0.0.
|
|
4
|
-
"description": "把 @sanguo-dev/calendar 接入 calendar-ui 的官方农历适配器",
|
|
5
|
-
"keywords": [
|
|
6
|
-
"calendar",
|
|
7
|
-
"calendar-ui",
|
|
8
|
-
"lunar",
|
|
9
|
-
"农历"
|
|
10
|
-
],
|
|
11
|
-
"homepage": "https://github.com/sanguo-dev/calendar/tree/master/packages/calendar-ui-lunar#readme",
|
|
12
|
-
"bugs": {
|
|
13
|
-
"url": "https://github.com/sanguo-dev/calendar/issues"
|
|
14
|
-
},
|
|
15
|
-
"license": "MIT",
|
|
16
|
-
"author": "sanguogege@outlook.com",
|
|
17
|
-
"repository": {
|
|
18
|
-
"type": "git",
|
|
19
|
-
"url": "git+https://github.com/sanguo-dev/calendar.git",
|
|
20
|
-
"directory": "packages/calendar-ui-lunar"
|
|
21
|
-
},
|
|
22
|
-
"files": [
|
|
23
|
-
"dist",
|
|
24
|
-
"src",
|
|
25
|
-
"theme.css"
|
|
26
|
-
],
|
|
27
|
-
"type": "module",
|
|
28
|
-
"sideEffects": [
|
|
29
|
-
"*.css"
|
|
30
|
-
],
|
|
31
|
-
"main": "./dist/index.cjs",
|
|
32
|
-
"module": "./dist/index.mjs",
|
|
33
|
-
"types": "./src/index.ts",
|
|
34
|
-
"exports": {
|
|
35
|
-
".": {
|
|
36
|
-
"development": "./src/index.ts",
|
|
37
|
-
"types": "./src/index.ts",
|
|
38
|
-
"import": "./dist/index.mjs",
|
|
39
|
-
"require": "./dist/index.cjs"
|
|
40
|
-
},
|
|
41
|
-
"./theme.css": "./theme.css"
|
|
42
|
-
},
|
|
43
|
-
"publishConfig": {
|
|
44
|
-
"access": "public",
|
|
45
|
-
"registry": "https://registry.npmjs.org"
|
|
46
|
-
},
|
|
47
|
-
"scripts": {
|
|
48
|
-
"build": "vp pack",
|
|
49
|
-
"dev": "vp pack --watch",
|
|
50
|
-
"test": "vp test",
|
|
51
|
-
"typecheck": "vp check",
|
|
52
|
-
"prepublishOnly": "vp run build"
|
|
53
|
-
},
|
|
54
|
-
"dependencies": {
|
|
55
|
-
"@
|
|
56
|
-
"@
|
|
57
|
-
},
|
|
58
|
-
"devDependencies": {
|
|
59
|
-
"@types/node": "catalog:",
|
|
60
|
-
"jsdom": "^25.0.1",
|
|
61
|
-
"typescript": "catalog:",
|
|
62
|
-
"vite": "catalog:",
|
|
63
|
-
"vite-plus": "catalog:"
|
|
64
|
-
}
|
|
65
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@sanguo-dev/calendar-ui-lunar",
|
|
3
|
+
"version": "0.0.3",
|
|
4
|
+
"description": "把 @sanguo-dev/calendar 接入 calendar-ui 的官方农历适配器",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"calendar",
|
|
7
|
+
"calendar-ui",
|
|
8
|
+
"lunar",
|
|
9
|
+
"农历"
|
|
10
|
+
],
|
|
11
|
+
"homepage": "https://github.com/sanguo-dev/calendar/tree/master/packages/calendar-ui-lunar#readme",
|
|
12
|
+
"bugs": {
|
|
13
|
+
"url": "https://github.com/sanguo-dev/calendar/issues"
|
|
14
|
+
},
|
|
15
|
+
"license": "MIT",
|
|
16
|
+
"author": "sanguogege@outlook.com",
|
|
17
|
+
"repository": {
|
|
18
|
+
"type": "git",
|
|
19
|
+
"url": "git+https://github.com/sanguo-dev/calendar.git",
|
|
20
|
+
"directory": "packages/calendar-ui-lunar"
|
|
21
|
+
},
|
|
22
|
+
"files": [
|
|
23
|
+
"dist",
|
|
24
|
+
"src",
|
|
25
|
+
"theme.css"
|
|
26
|
+
],
|
|
27
|
+
"type": "module",
|
|
28
|
+
"sideEffects": [
|
|
29
|
+
"*.css"
|
|
30
|
+
],
|
|
31
|
+
"main": "./dist/index.cjs",
|
|
32
|
+
"module": "./dist/index.mjs",
|
|
33
|
+
"types": "./src/index.ts",
|
|
34
|
+
"exports": {
|
|
35
|
+
".": {
|
|
36
|
+
"development": "./src/index.ts",
|
|
37
|
+
"types": "./src/index.ts",
|
|
38
|
+
"import": "./dist/index.mjs",
|
|
39
|
+
"require": "./dist/index.cjs"
|
|
40
|
+
},
|
|
41
|
+
"./theme.css": "./theme.css"
|
|
42
|
+
},
|
|
43
|
+
"publishConfig": {
|
|
44
|
+
"access": "public",
|
|
45
|
+
"registry": "https://registry.npmjs.org"
|
|
46
|
+
},
|
|
47
|
+
"scripts": {
|
|
48
|
+
"build": "vp pack",
|
|
49
|
+
"dev": "vp pack --watch",
|
|
50
|
+
"test": "vp test",
|
|
51
|
+
"typecheck": "vp check",
|
|
52
|
+
"prepublishOnly": "vp run build"
|
|
53
|
+
},
|
|
54
|
+
"dependencies": {
|
|
55
|
+
"@sanguo-dev/calendar": "1.0.1",
|
|
56
|
+
"@sanguo-dev/calendar-ui": "0.0.3"
|
|
57
|
+
},
|
|
58
|
+
"devDependencies": {
|
|
59
|
+
"@types/node": "catalog:",
|
|
60
|
+
"jsdom": "^25.0.1",
|
|
61
|
+
"typescript": "catalog:",
|
|
62
|
+
"vite": "catalog:",
|
|
63
|
+
"vite-plus": "catalog:"
|
|
64
|
+
}
|
|
65
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -1,177 +1,177 @@
|
|
|
1
|
-
import createCalendar from "@
|
|
2
|
-
import type { HolidayConfig, LunarResult } from "@
|
|
3
|
-
import { createCalendarUI } from "@
|
|
4
|
-
import type {
|
|
5
|
-
CalendarAdapter,
|
|
6
|
-
CalendarDate,
|
|
7
|
-
CalendarDay,
|
|
8
|
-
CalendarInstance,
|
|
9
|
-
CalendarOptions,
|
|
10
|
-
DayDecoration,
|
|
11
|
-
MonthInput,
|
|
12
|
-
} from "@
|
|
13
|
-
|
|
14
|
-
export interface LunarAdapterOptions {
|
|
15
|
-
/** 本适配器使用的节假日 / 调休配置;不传时使用内置数据 */
|
|
16
|
-
holidays?: HolidayConfig;
|
|
17
|
-
/** 为 true 时忽略内置节日 / 调休数据,只使用 holidays */
|
|
18
|
-
replaceHolidays?: boolean;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export interface LunarCalendarOptions extends CalendarOptions<LunarResult> {
|
|
22
|
-
/** 本实例使用的节假日 / 调休配置,配置在创建时固定 */
|
|
23
|
-
holidays?: HolidayConfig;
|
|
24
|
-
/** 为 true 时忽略内置节日 / 调休数据,只使用 holidays */
|
|
25
|
-
replaceHolidays?: boolean;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
/** 带农历数据的日历格 */
|
|
29
|
-
export type LunarCalendarDay = CalendarDay<LunarResult>;
|
|
30
|
-
|
|
31
|
-
/** 不含选中/今天的那部分缓存,可以跨实例复用 */
|
|
32
|
-
type MonthDecorations = ReadonlyArray<DayDecoration<LunarResult> | null>;
|
|
33
|
-
|
|
34
|
-
const CACHE_LIMIT = 24;
|
|
35
|
-
const monthCache = new Map<string, MonthDecorations>();
|
|
36
|
-
|
|
37
|
-
interface Source {
|
|
38
|
-
id: number;
|
|
39
|
-
solarToLunar(year: number, month: number, day: number): LunarResult;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
const DEFAULT_CALENDAR = createCalendar();
|
|
43
|
-
|
|
44
|
-
const DEFAULT_SOURCE: Source = {
|
|
45
|
-
id: 0,
|
|
46
|
-
solarToLunar: (year, month, day) => DEFAULT_CALENDAR.solarToLunar(year, month, day),
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
interface SourceEntry {
|
|
50
|
-
merge?: Source;
|
|
51
|
-
replace?: Source;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
let nextSourceId = 1;
|
|
55
|
-
const sourceCache = new WeakMap<object, SourceEntry>();
|
|
56
|
-
|
|
57
|
-
/** 同一份配置对象 + 同样的 replace 语义只创建一个 converter */
|
|
58
|
-
const resolveSource = function (holidays?: HolidayConfig, replace = false): Source {
|
|
59
|
-
if (!holidays) return DEFAULT_SOURCE;
|
|
60
|
-
|
|
61
|
-
let entry = sourceCache.get(holidays);
|
|
62
|
-
if (!entry) {
|
|
63
|
-
entry = {};
|
|
64
|
-
sourceCache.set(holidays, entry);
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
const mode = replace ? "replace" : "merge";
|
|
68
|
-
const cached = entry[mode];
|
|
69
|
-
if (cached) return cached;
|
|
70
|
-
|
|
71
|
-
const calendar = createCalendar(holidays, replace ? { replace: true } : {});
|
|
72
|
-
const source: Source = {
|
|
73
|
-
id: nextSourceId++,
|
|
74
|
-
solarToLunar: (year, month, day) => calendar.solarToLunar(year, month, day),
|
|
75
|
-
};
|
|
76
|
-
entry[mode] = source;
|
|
77
|
-
return source;
|
|
78
|
-
};
|
|
79
|
-
|
|
80
|
-
/** 格子副标题的取值顺序:节气 > 农历节日 > 公历节日 > 农历日 */
|
|
81
|
-
const subtitleOf = function (lunar: LunarResult): string {
|
|
82
|
-
if (lunar.term) return lunar.term;
|
|
83
|
-
if (lunar.nljr.length > 0) return lunar.nljr[0] as string;
|
|
84
|
-
if (lunar.gljr.length > 0) return lunar.gljr[0] as string;
|
|
85
|
-
if (lunar.lDay === 1) return lunar.lMonthCn;
|
|
86
|
-
return lunar.lDayCn;
|
|
87
|
-
};
|
|
88
|
-
|
|
89
|
-
const decorateDate = function (
|
|
90
|
-
source: Source,
|
|
91
|
-
date: CalendarDate,
|
|
92
|
-
): DayDecoration<LunarResult> | null {
|
|
93
|
-
let lunar: LunarResult;
|
|
94
|
-
try {
|
|
95
|
-
lunar = source.solarToLunar(date.year, date.month, date.day);
|
|
96
|
-
} catch {
|
|
97
|
-
return null;
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
return {
|
|
101
|
-
subtitle: subtitleOf(lunar),
|
|
102
|
-
badge: lunar.ban
|
|
103
|
-
? { text: "班", tone: "work" }
|
|
104
|
-
: lunar.xiu
|
|
105
|
-
? { text: "休", tone: "rest" }
|
|
106
|
-
: undefined,
|
|
107
|
-
data: lunar,
|
|
108
|
-
};
|
|
109
|
-
};
|
|
110
|
-
|
|
111
|
-
/** 创建使用 @
|
|
112
|
-
export const createLunarAdapter = function (
|
|
113
|
-
options: LunarAdapterOptions = {},
|
|
114
|
-
): CalendarAdapter<LunarResult> {
|
|
115
|
-
const source = resolveSource(options.holidays, options.replaceHolidays === true);
|
|
116
|
-
|
|
117
|
-
return {
|
|
118
|
-
id: `lunar-${source.id}`,
|
|
119
|
-
decorateMonth(input: MonthInput): MonthDecorations {
|
|
120
|
-
const key = `${source.id}-${input.year}-${input.month}-${input.weekStartsOn}`;
|
|
121
|
-
const cached = monthCache.get(key);
|
|
122
|
-
if (cached) {
|
|
123
|
-
monthCache.delete(key);
|
|
124
|
-
monthCache.set(key, cached);
|
|
125
|
-
return cached;
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
const decorations = input.days.map((date) => decorateDate(source, date));
|
|
129
|
-
if (monthCache.size >= CACHE_LIMIT) {
|
|
130
|
-
const oldest = monthCache.keys().next();
|
|
131
|
-
if (!oldest.done) monthCache.delete(oldest.value);
|
|
132
|
-
}
|
|
133
|
-
monthCache.set(key, decorations);
|
|
134
|
-
return decorations;
|
|
135
|
-
},
|
|
136
|
-
};
|
|
137
|
-
};
|
|
138
|
-
|
|
139
|
-
/**
|
|
140
|
-
* 创建带农历 / 节气 / 节日 / 调休的日历
|
|
141
|
-
*
|
|
142
|
-
* 接口与纯公历版本一致,只是换成这个入口,并且多收 holidays / replaceHolidays。
|
|
143
|
-
*/
|
|
144
|
-
export const createCalendarLunar = function (
|
|
145
|
-
container: HTMLElement,
|
|
146
|
-
options: LunarCalendarOptions = {},
|
|
147
|
-
): CalendarInstance {
|
|
148
|
-
const { holidays, replaceHolidays, adapter, ...rest } = options;
|
|
149
|
-
|
|
150
|
-
const instance = createCalendarUI<LunarResult>(container, {
|
|
151
|
-
...rest,
|
|
152
|
-
adapter: adapter ?? createLunarAdapter({ holidays, replaceHolidays }),
|
|
153
|
-
});
|
|
154
|
-
|
|
155
|
-
// 农历皮肤类名,配合 theme.css 使用;用户不引入 theme.css 时没有副作用
|
|
156
|
-
instance.el.classList.add("cui--lunar");
|
|
157
|
-
|
|
158
|
-
return instance;
|
|
159
|
-
};
|
|
160
|
-
|
|
161
|
-
export type {
|
|
162
|
-
CalendarAdapter,
|
|
163
|
-
CalendarBadge,
|
|
164
|
-
CalendarDate,
|
|
165
|
-
CalendarDateInput,
|
|
166
|
-
CalendarDay,
|
|
167
|
-
CalendarInstance,
|
|
168
|
-
CalendarMode,
|
|
169
|
-
CalendarOptions,
|
|
170
|
-
CalendarRange,
|
|
171
|
-
CalendarTheme,
|
|
172
|
-
DayDecoration,
|
|
173
|
-
MonthInput,
|
|
174
|
-
WeekStartsOn,
|
|
175
|
-
YearMonth,
|
|
176
|
-
} from "@
|
|
177
|
-
export type { HolidayConfig, LunarResult } from "@
|
|
1
|
+
import createCalendar from "@sanguo-dev/calendar";
|
|
2
|
+
import type { HolidayConfig, LunarResult } from "@sanguo-dev/calendar";
|
|
3
|
+
import { createCalendarUI } from "@sanguo-dev/calendar-ui";
|
|
4
|
+
import type {
|
|
5
|
+
CalendarAdapter,
|
|
6
|
+
CalendarDate,
|
|
7
|
+
CalendarDay,
|
|
8
|
+
CalendarInstance,
|
|
9
|
+
CalendarOptions,
|
|
10
|
+
DayDecoration,
|
|
11
|
+
MonthInput,
|
|
12
|
+
} from "@sanguo-dev/calendar-ui";
|
|
13
|
+
|
|
14
|
+
export interface LunarAdapterOptions {
|
|
15
|
+
/** 本适配器使用的节假日 / 调休配置;不传时使用内置数据 */
|
|
16
|
+
holidays?: HolidayConfig;
|
|
17
|
+
/** 为 true 时忽略内置节日 / 调休数据,只使用 holidays */
|
|
18
|
+
replaceHolidays?: boolean;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export interface LunarCalendarOptions extends CalendarOptions<LunarResult> {
|
|
22
|
+
/** 本实例使用的节假日 / 调休配置,配置在创建时固定 */
|
|
23
|
+
holidays?: HolidayConfig;
|
|
24
|
+
/** 为 true 时忽略内置节日 / 调休数据,只使用 holidays */
|
|
25
|
+
replaceHolidays?: boolean;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/** 带农历数据的日历格 */
|
|
29
|
+
export type LunarCalendarDay = CalendarDay<LunarResult>;
|
|
30
|
+
|
|
31
|
+
/** 不含选中/今天的那部分缓存,可以跨实例复用 */
|
|
32
|
+
type MonthDecorations = ReadonlyArray<DayDecoration<LunarResult> | null>;
|
|
33
|
+
|
|
34
|
+
const CACHE_LIMIT = 24;
|
|
35
|
+
const monthCache = new Map<string, MonthDecorations>();
|
|
36
|
+
|
|
37
|
+
interface Source {
|
|
38
|
+
id: number;
|
|
39
|
+
solarToLunar(year: number, month: number, day: number): LunarResult;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const DEFAULT_CALENDAR = createCalendar();
|
|
43
|
+
|
|
44
|
+
const DEFAULT_SOURCE: Source = {
|
|
45
|
+
id: 0,
|
|
46
|
+
solarToLunar: (year, month, day) => DEFAULT_CALENDAR.solarToLunar(year, month, day),
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
interface SourceEntry {
|
|
50
|
+
merge?: Source;
|
|
51
|
+
replace?: Source;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
let nextSourceId = 1;
|
|
55
|
+
const sourceCache = new WeakMap<object, SourceEntry>();
|
|
56
|
+
|
|
57
|
+
/** 同一份配置对象 + 同样的 replace 语义只创建一个 converter */
|
|
58
|
+
const resolveSource = function (holidays?: HolidayConfig, replace = false): Source {
|
|
59
|
+
if (!holidays) return DEFAULT_SOURCE;
|
|
60
|
+
|
|
61
|
+
let entry = sourceCache.get(holidays);
|
|
62
|
+
if (!entry) {
|
|
63
|
+
entry = {};
|
|
64
|
+
sourceCache.set(holidays, entry);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
const mode = replace ? "replace" : "merge";
|
|
68
|
+
const cached = entry[mode];
|
|
69
|
+
if (cached) return cached;
|
|
70
|
+
|
|
71
|
+
const calendar = createCalendar(holidays, replace ? { replace: true } : {});
|
|
72
|
+
const source: Source = {
|
|
73
|
+
id: nextSourceId++,
|
|
74
|
+
solarToLunar: (year, month, day) => calendar.solarToLunar(year, month, day),
|
|
75
|
+
};
|
|
76
|
+
entry[mode] = source;
|
|
77
|
+
return source;
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
/** 格子副标题的取值顺序:节气 > 农历节日 > 公历节日 > 农历日 */
|
|
81
|
+
const subtitleOf = function (lunar: LunarResult): string {
|
|
82
|
+
if (lunar.term) return lunar.term;
|
|
83
|
+
if (lunar.nljr.length > 0) return lunar.nljr[0] as string;
|
|
84
|
+
if (lunar.gljr.length > 0) return lunar.gljr[0] as string;
|
|
85
|
+
if (lunar.lDay === 1) return lunar.lMonthCn;
|
|
86
|
+
return lunar.lDayCn;
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
const decorateDate = function (
|
|
90
|
+
source: Source,
|
|
91
|
+
date: CalendarDate,
|
|
92
|
+
): DayDecoration<LunarResult> | null {
|
|
93
|
+
let lunar: LunarResult;
|
|
94
|
+
try {
|
|
95
|
+
lunar = source.solarToLunar(date.year, date.month, date.day);
|
|
96
|
+
} catch {
|
|
97
|
+
return null;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
return {
|
|
101
|
+
subtitle: subtitleOf(lunar),
|
|
102
|
+
badge: lunar.ban
|
|
103
|
+
? { text: "班", tone: "work" }
|
|
104
|
+
: lunar.xiu
|
|
105
|
+
? { text: "休", tone: "rest" }
|
|
106
|
+
: undefined,
|
|
107
|
+
data: lunar,
|
|
108
|
+
};
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
/** 创建使用 @sanguo-dev/calendar 的农历适配器 */
|
|
112
|
+
export const createLunarAdapter = function (
|
|
113
|
+
options: LunarAdapterOptions = {},
|
|
114
|
+
): CalendarAdapter<LunarResult> {
|
|
115
|
+
const source = resolveSource(options.holidays, options.replaceHolidays === true);
|
|
116
|
+
|
|
117
|
+
return {
|
|
118
|
+
id: `lunar-${source.id}`,
|
|
119
|
+
decorateMonth(input: MonthInput): MonthDecorations {
|
|
120
|
+
const key = `${source.id}-${input.year}-${input.month}-${input.weekStartsOn}`;
|
|
121
|
+
const cached = monthCache.get(key);
|
|
122
|
+
if (cached) {
|
|
123
|
+
monthCache.delete(key);
|
|
124
|
+
monthCache.set(key, cached);
|
|
125
|
+
return cached;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
const decorations = input.days.map((date) => decorateDate(source, date));
|
|
129
|
+
if (monthCache.size >= CACHE_LIMIT) {
|
|
130
|
+
const oldest = monthCache.keys().next();
|
|
131
|
+
if (!oldest.done) monthCache.delete(oldest.value);
|
|
132
|
+
}
|
|
133
|
+
monthCache.set(key, decorations);
|
|
134
|
+
return decorations;
|
|
135
|
+
},
|
|
136
|
+
};
|
|
137
|
+
};
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* 创建带农历 / 节气 / 节日 / 调休的日历
|
|
141
|
+
*
|
|
142
|
+
* 接口与纯公历版本一致,只是换成这个入口,并且多收 holidays / replaceHolidays。
|
|
143
|
+
*/
|
|
144
|
+
export const createCalendarLunar = function (
|
|
145
|
+
container: HTMLElement,
|
|
146
|
+
options: LunarCalendarOptions = {},
|
|
147
|
+
): CalendarInstance {
|
|
148
|
+
const { holidays, replaceHolidays, adapter, ...rest } = options;
|
|
149
|
+
|
|
150
|
+
const instance = createCalendarUI<LunarResult>(container, {
|
|
151
|
+
...rest,
|
|
152
|
+
adapter: adapter ?? createLunarAdapter({ holidays, replaceHolidays }),
|
|
153
|
+
});
|
|
154
|
+
|
|
155
|
+
// 农历皮肤类名,配合 theme.css 使用;用户不引入 theme.css 时没有副作用
|
|
156
|
+
instance.el.classList.add("cui--lunar");
|
|
157
|
+
|
|
158
|
+
return instance;
|
|
159
|
+
};
|
|
160
|
+
|
|
161
|
+
export type {
|
|
162
|
+
CalendarAdapter,
|
|
163
|
+
CalendarBadge,
|
|
164
|
+
CalendarDate,
|
|
165
|
+
CalendarDateInput,
|
|
166
|
+
CalendarDay,
|
|
167
|
+
CalendarInstance,
|
|
168
|
+
CalendarMode,
|
|
169
|
+
CalendarOptions,
|
|
170
|
+
CalendarRange,
|
|
171
|
+
CalendarTheme,
|
|
172
|
+
DayDecoration,
|
|
173
|
+
MonthInput,
|
|
174
|
+
WeekStartsOn,
|
|
175
|
+
YearMonth,
|
|
176
|
+
} from "@sanguo-dev/calendar-ui";
|
|
177
|
+
export type { HolidayConfig, LunarResult } from "@sanguo-dev/calendar";
|
package/theme.css
CHANGED
|
@@ -1,66 +1,66 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* calendar-ui-lunar 的默认皮肤:农历喜庆红,淡色不刺眼。
|
|
3
|
-
*
|
|
4
|
-
* 用法(两个文件都要):
|
|
5
|
-
* import "@
|
|
6
|
-
* import "@
|
|
7
|
-
*
|
|
8
|
-
* 只想局部换色时,用自己的容器包一层,例如:
|
|
9
|
-
* .my-calendar .cui--lunar { --cui-accent: #c2410c; }
|
|
10
|
-
*/
|
|
11
|
-
.cui.cui--lunar {
|
|
12
|
-
--cui-bg: #fffbf9;
|
|
13
|
-
--cui-fg: #43302e;
|
|
14
|
-
--cui-muted: #a68c87;
|
|
15
|
-
--cui-border: #f2ded9;
|
|
16
|
-
--cui-accent: #c86055;
|
|
17
|
-
--cui-accent-fg: #fffdfc;
|
|
18
|
-
--cui-rest: #c94f45;
|
|
19
|
-
--cui-hover: #fbefec;
|
|
20
|
-
--cui-radius: 12px;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
/* 显式深色,或外层 data-theme="dark" 时跟随 */
|
|
24
|
-
.cui.cui--lunar[data-theme="dark"],
|
|
25
|
-
[data-theme="dark"] .cui.cui--lunar[data-theme="auto"] {
|
|
26
|
-
--cui-bg: #1b1413;
|
|
27
|
-
--cui-fg: #f3e6e3;
|
|
28
|
-
--cui-muted: #a98f8a;
|
|
29
|
-
--cui-border: #3a2b29;
|
|
30
|
-
--cui-accent: #e28277;
|
|
31
|
-
--cui-accent-fg: #2a1210;
|
|
32
|
-
--cui-rest: #ef8d83;
|
|
33
|
-
--cui-hover: #2a1e1d;
|
|
34
|
-
|
|
35
|
-
color-scheme: dark;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
/* auto 跟随系统 */
|
|
39
|
-
@media (prefers-color-scheme: dark) {
|
|
40
|
-
.cui.cui--lunar[data-theme="auto"] {
|
|
41
|
-
--cui-bg: #1b1413;
|
|
42
|
-
--cui-fg: #f3e6e3;
|
|
43
|
-
--cui-muted: #a98f8a;
|
|
44
|
-
--cui-border: #3a2b29;
|
|
45
|
-
--cui-accent: #e28277;
|
|
46
|
-
--cui-accent-fg: #2a1210;
|
|
47
|
-
--cui-rest: #ef8d83;
|
|
48
|
-
--cui-hover: #2a1e1d;
|
|
49
|
-
|
|
50
|
-
color-scheme: dark;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
/* 外层明确 light 时,系统深色不覆盖 */
|
|
54
|
-
[data-theme="light"] .cui.cui--lunar[data-theme="auto"] {
|
|
55
|
-
--cui-bg: #fffbf9;
|
|
56
|
-
--cui-fg: #43302e;
|
|
57
|
-
--cui-muted: #a68c87;
|
|
58
|
-
--cui-border: #f2ded9;
|
|
59
|
-
--cui-accent: #c86055;
|
|
60
|
-
--cui-accent-fg: #fffdfc;
|
|
61
|
-
--cui-rest: #c94f45;
|
|
62
|
-
--cui-hover: #fbefec;
|
|
63
|
-
|
|
64
|
-
color-scheme: light;
|
|
65
|
-
}
|
|
66
|
-
}
|
|
1
|
+
/*
|
|
2
|
+
* calendar-ui-lunar 的默认皮肤:农历喜庆红,淡色不刺眼。
|
|
3
|
+
*
|
|
4
|
+
* 用法(两个文件都要):
|
|
5
|
+
* import "@sanguo-dev/calendar-ui/style.css";
|
|
6
|
+
* import "@sanguo-dev/calendar-ui-lunar/theme.css";
|
|
7
|
+
*
|
|
8
|
+
* 只想局部换色时,用自己的容器包一层,例如:
|
|
9
|
+
* .my-calendar .cui--lunar { --cui-accent: #c2410c; }
|
|
10
|
+
*/
|
|
11
|
+
.cui.cui--lunar {
|
|
12
|
+
--cui-bg: #fffbf9;
|
|
13
|
+
--cui-fg: #43302e;
|
|
14
|
+
--cui-muted: #a68c87;
|
|
15
|
+
--cui-border: #f2ded9;
|
|
16
|
+
--cui-accent: #c86055;
|
|
17
|
+
--cui-accent-fg: #fffdfc;
|
|
18
|
+
--cui-rest: #c94f45;
|
|
19
|
+
--cui-hover: #fbefec;
|
|
20
|
+
--cui-radius: 12px;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/* 显式深色,或外层 data-theme="dark" 时跟随 */
|
|
24
|
+
.cui.cui--lunar[data-theme="dark"],
|
|
25
|
+
[data-theme="dark"] .cui.cui--lunar[data-theme="auto"] {
|
|
26
|
+
--cui-bg: #1b1413;
|
|
27
|
+
--cui-fg: #f3e6e3;
|
|
28
|
+
--cui-muted: #a98f8a;
|
|
29
|
+
--cui-border: #3a2b29;
|
|
30
|
+
--cui-accent: #e28277;
|
|
31
|
+
--cui-accent-fg: #2a1210;
|
|
32
|
+
--cui-rest: #ef8d83;
|
|
33
|
+
--cui-hover: #2a1e1d;
|
|
34
|
+
|
|
35
|
+
color-scheme: dark;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/* auto 跟随系统 */
|
|
39
|
+
@media (prefers-color-scheme: dark) {
|
|
40
|
+
.cui.cui--lunar[data-theme="auto"] {
|
|
41
|
+
--cui-bg: #1b1413;
|
|
42
|
+
--cui-fg: #f3e6e3;
|
|
43
|
+
--cui-muted: #a98f8a;
|
|
44
|
+
--cui-border: #3a2b29;
|
|
45
|
+
--cui-accent: #e28277;
|
|
46
|
+
--cui-accent-fg: #2a1210;
|
|
47
|
+
--cui-rest: #ef8d83;
|
|
48
|
+
--cui-hover: #2a1e1d;
|
|
49
|
+
|
|
50
|
+
color-scheme: dark;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/* 外层明确 light 时,系统深色不覆盖 */
|
|
54
|
+
[data-theme="light"] .cui.cui--lunar[data-theme="auto"] {
|
|
55
|
+
--cui-bg: #fffbf9;
|
|
56
|
+
--cui-fg: #43302e;
|
|
57
|
+
--cui-muted: #a68c87;
|
|
58
|
+
--cui-border: #f2ded9;
|
|
59
|
+
--cui-accent: #c86055;
|
|
60
|
+
--cui-accent-fg: #fffdfc;
|
|
61
|
+
--cui-rest: #c94f45;
|
|
62
|
+
--cui-hover: #fbefec;
|
|
63
|
+
|
|
64
|
+
color-scheme: light;
|
|
65
|
+
}
|
|
66
|
+
}
|