@hlw-uni/mp-vue 2.1.59 → 2.1.69
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 +388 -213
- package/dist/composables/index.d.ts +0 -8
- package/dist/composables/request/service.d.ts +2 -6
- package/dist/core/index.d.ts +1 -0
- package/dist/core/theme.d.ts +21 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.js +113 -367
- package/dist/index.mjs +113 -367
- package/dist/stores/index.d.ts +1 -0
- package/dist/stores/theme.d.ts +26 -55
- package/package.json +1 -1
- package/src/components/hlw-add-mini/index.vue +147 -77
- package/src/components/hlw-avatar/index.vue +28 -20
- package/src/components/hlw-card-header/index.vue +3 -0
- package/src/components/hlw-cell/index.vue +6 -0
- package/src/components/hlw-custom/hlw-custom.vue +6 -5
- package/src/components/hlw-menu/index.vue +9 -3
- package/src/components/hlw-nav-bar/index.vue +181 -0
- package/src/components/hlw-page/index.vue +75 -105
- package/src/composables/index.ts +1 -31
- package/src/composables/request/service.ts +10 -3
- package/src/core/index.ts +1 -0
- package/src/core/theme.ts +62 -0
- package/src/env.d.ts +8 -0
- package/src/index.ts +10 -4
- package/src/stores/index.ts +1 -0
- package/src/stores/theme.ts +113 -101
- package/dist/composables/theme/appearance.d.ts +0 -55
- package/dist/composables/theme/font.d.ts +0 -32
- package/dist/composables/theme/index.d.ts +0 -46
- package/dist/composables/theme/palette.d.ts +0 -37
- package/dist/composables/theme/typography.d.ts +0 -41
- package/src/composables/theme/README.md +0 -131
- package/src/composables/theme/appearance.ts +0 -129
- package/src/composables/theme/font.ts +0 -95
- package/src/composables/theme/index.ts +0 -89
- package/src/composables/theme/palette.ts +0 -117
- package/src/composables/theme/typography.ts +0 -90
|
@@ -1,117 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 主题颜色配置项接口。
|
|
3
|
-
*/
|
|
4
|
-
export interface ThemeColor {
|
|
5
|
-
/** 颜色名称描述 */
|
|
6
|
-
label: string;
|
|
7
|
-
/** 主题色十六进制值 (Hex Color) */
|
|
8
|
-
value: string;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
/** 存储当前主题色设置的 LocalStorage 键名 */
|
|
12
|
-
export const THEME_COLOR_KEY = "hlw_theme_color";
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* 预设的语义化颜色。
|
|
16
|
-
* 包含成功、警告、错误和提示的默认色彩配置。
|
|
17
|
-
*/
|
|
18
|
-
export const THEME_SEMANTIC_COLORS = {
|
|
19
|
-
success: "#10b981",
|
|
20
|
-
warning: "#f59e0b",
|
|
21
|
-
error: "#ef4444",
|
|
22
|
-
info: "#64748b",
|
|
23
|
-
} as const;
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* 系统预设的默认主题色列表。
|
|
27
|
-
*/
|
|
28
|
-
export const DEFAULT_THEMES: ThemeColor[] = [
|
|
29
|
-
{ label: "翡翠绿", value: "#10b981" },
|
|
30
|
-
{ label: "活力橙", value: "#f97316" },
|
|
31
|
-
{ label: "默认蓝", value: "#3b82f6" },
|
|
32
|
-
{ label: "玫瑰粉", value: "#f43f5e" },
|
|
33
|
-
{ label: "紫罗兰", value: "#8b5cf6" },
|
|
34
|
-
{ label: "青石灰", value: "#64748b" },
|
|
35
|
-
];
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* 读取当前配置的主题色 Hex 字符串。
|
|
39
|
-
* 默认使用 `DEFAULT_THEMES` 数组中首位颜色的值。
|
|
40
|
-
* @returns 十六进制颜色字符串
|
|
41
|
-
*/
|
|
42
|
-
export function getCurrentThemeColor(): string {
|
|
43
|
-
try {
|
|
44
|
-
const v = uni.getStorageSync(THEME_COLOR_KEY);
|
|
45
|
-
if (v && typeof v === "string") return v;
|
|
46
|
-
} catch {}
|
|
47
|
-
return DEFAULT_THEMES[0].value;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
/**
|
|
51
|
-
* 获取当前主题色所对应的完整 CSS 颜色语义变量映射表。
|
|
52
|
-
* 会基于当前主题色,自动计算衍生出对应的亮色调、暗色调以及各状态色语义变量。
|
|
53
|
-
* @returns 包含各 CSS 变量名与对应颜色值键值对
|
|
54
|
-
*/
|
|
55
|
-
export function getCurrentThemeVars(): Record<string, string> {
|
|
56
|
-
const color = getCurrentThemeColor();
|
|
57
|
-
return {
|
|
58
|
-
"--primary-color": color,
|
|
59
|
-
"--primary-light": hexToRgba(color, 0.12),
|
|
60
|
-
"--primary-dark": darkenHex(color),
|
|
61
|
-
"--primary-success": THEME_SEMANTIC_COLORS.success,
|
|
62
|
-
"--primary-success-light": hexToRgba(THEME_SEMANTIC_COLORS.success, 0.12),
|
|
63
|
-
"--primary-success-dark": darkenHex(THEME_SEMANTIC_COLORS.success),
|
|
64
|
-
"--primary-warning": THEME_SEMANTIC_COLORS.warning,
|
|
65
|
-
"--primary-warning-light": hexToRgba(THEME_SEMANTIC_COLORS.warning, 0.12),
|
|
66
|
-
"--primary-warning-dark": darkenHex(THEME_SEMANTIC_COLORS.warning),
|
|
67
|
-
"--primary-error": THEME_SEMANTIC_COLORS.error,
|
|
68
|
-
"--primary-error-light": hexToRgba(THEME_SEMANTIC_COLORS.error, 0.12),
|
|
69
|
-
"--primary-error-dark": darkenHex(THEME_SEMANTIC_COLORS.error),
|
|
70
|
-
"--primary-info": THEME_SEMANTIC_COLORS.info,
|
|
71
|
-
"--primary-info-light": hexToRgba(THEME_SEMANTIC_COLORS.info, 0.12),
|
|
72
|
-
"--primary-info-dark": darkenHex(THEME_SEMANTIC_COLORS.info),
|
|
73
|
-
"--success-color": THEME_SEMANTIC_COLORS.success,
|
|
74
|
-
"--success-light": hexToRgba(THEME_SEMANTIC_COLORS.success, 0.12),
|
|
75
|
-
"--success-dark": darkenHex(THEME_SEMANTIC_COLORS.success),
|
|
76
|
-
"--warning-color": THEME_SEMANTIC_COLORS.warning,
|
|
77
|
-
"--warning-light": hexToRgba(THEME_SEMANTIC_COLORS.warning, 0.12),
|
|
78
|
-
"--warning-dark": darkenHex(THEME_SEMANTIC_COLORS.warning),
|
|
79
|
-
"--error-color": THEME_SEMANTIC_COLORS.error,
|
|
80
|
-
"--error-light": hexToRgba(THEME_SEMANTIC_COLORS.error, 0.12),
|
|
81
|
-
"--error-dark": darkenHex(THEME_SEMANTIC_COLORS.error),
|
|
82
|
-
"--info-color": THEME_SEMANTIC_COLORS.info,
|
|
83
|
-
"--info-light": hexToRgba(THEME_SEMANTIC_COLORS.info, 0.12),
|
|
84
|
-
"--info-dark": darkenHex(THEME_SEMANTIC_COLORS.info),
|
|
85
|
-
};
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
const HEX_RE = /^#[0-9a-fA-F]{6}$/;
|
|
89
|
-
|
|
90
|
-
/**
|
|
91
|
-
* 将 6 位 hex 颜色字符串转换为 RGB 三原色元组。
|
|
92
|
-
*/
|
|
93
|
-
function parseHex(hex: string): [number, number, number] {
|
|
94
|
-
if (!HEX_RE.test(hex)) throw new Error(`Invalid hex color: ${hex}`);
|
|
95
|
-
return [
|
|
96
|
-
parseInt(hex.slice(1, 3), 16),
|
|
97
|
-
parseInt(hex.slice(3, 5), 16),
|
|
98
|
-
parseInt(hex.slice(5, 7), 16),
|
|
99
|
-
];
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
/**
|
|
103
|
-
* 转换 Hex 颜色为 rgba 格式字符串。
|
|
104
|
-
*/
|
|
105
|
-
function hexToRgba(hex: string, alpha: number): string {
|
|
106
|
-
const [r, g, b] = parseHex(hex);
|
|
107
|
-
return `rgba(${r},${g},${b},${alpha})`;
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
/**
|
|
111
|
-
* 将 Hex 颜色调暗。
|
|
112
|
-
*/
|
|
113
|
-
function darkenHex(hex: string, amount = 0.15): string {
|
|
114
|
-
const [r, g, b] = parseHex(hex);
|
|
115
|
-
const darken = (value: number) => Math.max(0, Math.round(value * (1 - amount)));
|
|
116
|
-
return `#${darken(r).toString(16).padStart(2, "0")}${darken(g).toString(16).padStart(2, "0")}${darken(b).toString(16).padStart(2, "0")}`;
|
|
117
|
-
}
|
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 语义化排版 token — 把"字号 + 字重 + 行高 + 颜色"打包成角色,统一各页面文字样式。
|
|
3
|
-
*
|
|
4
|
-
* 使用指南:
|
|
5
|
-
* - 页面样式里用 `var(--text-title-size)` 等变量代替硬编码,自动响应字体档位/外观模式切换
|
|
6
|
-
* - 或通过全局 utility class(见 qz2 项目的 static/css/style.scss)直接加 class
|
|
7
|
-
*
|
|
8
|
-
* 6 个语义角色:
|
|
9
|
-
* - title-lg: 页面大标题 / hero
|
|
10
|
-
* - title: 卡片 / 分区主标题
|
|
11
|
-
* - subtitle: 次级标题
|
|
12
|
-
* - body: 正文
|
|
13
|
-
* - desc: 卡片描述 / 副文
|
|
14
|
-
* - caption: 角标 / 底部小字 / 时间戳
|
|
15
|
-
*/
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* 语义排版角色配置项接口。
|
|
19
|
-
*/
|
|
20
|
-
export interface TypographyRole {
|
|
21
|
-
/** 对应 `--text-{role}-size` 的值(通常引用字号档位 token) */
|
|
22
|
-
size: string;
|
|
23
|
-
/** 对应 `--text-{role}-weight` */
|
|
24
|
-
weight: string;
|
|
25
|
-
/** 对应 `--text-{role}-line-height` */
|
|
26
|
-
lineHeight: string;
|
|
27
|
-
/** 对应 `--text-{role}-color`(通常引用文字色 token) */
|
|
28
|
-
color: string;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* 全局预设排版角色的参数配置表。
|
|
33
|
-
*/
|
|
34
|
-
export const TYPOGRAPHY_ROLES: Record<string, TypographyRole> = {
|
|
35
|
-
"title-lg": {
|
|
36
|
-
size: "var(--font-xl)",
|
|
37
|
-
weight: "600",
|
|
38
|
-
lineHeight: "1.2",
|
|
39
|
-
color: "var(--text-primary)",
|
|
40
|
-
},
|
|
41
|
-
"title": {
|
|
42
|
-
size: "var(--font-md)",
|
|
43
|
-
weight: "500",
|
|
44
|
-
lineHeight: "1.3",
|
|
45
|
-
color: "var(--text-primary)",
|
|
46
|
-
},
|
|
47
|
-
"subtitle": {
|
|
48
|
-
size: "var(--font-base)",
|
|
49
|
-
weight: "500",
|
|
50
|
-
lineHeight: "1.3",
|
|
51
|
-
color: "var(--text-secondary)",
|
|
52
|
-
},
|
|
53
|
-
"body": {
|
|
54
|
-
size: "var(--font-base)",
|
|
55
|
-
weight: "400",
|
|
56
|
-
lineHeight: "1.5",
|
|
57
|
-
color: "var(--text-secondary)",
|
|
58
|
-
},
|
|
59
|
-
"desc": {
|
|
60
|
-
size: "var(--font-sm)",
|
|
61
|
-
weight: "400",
|
|
62
|
-
lineHeight: "1.4",
|
|
63
|
-
color: "var(--text-subtle)",
|
|
64
|
-
},
|
|
65
|
-
"caption": {
|
|
66
|
-
size: "var(--font-xs)",
|
|
67
|
-
weight: "500",
|
|
68
|
-
lineHeight: "1.3",
|
|
69
|
-
color: "var(--text-muted)",
|
|
70
|
-
},
|
|
71
|
-
};
|
|
72
|
-
|
|
73
|
-
/**
|
|
74
|
-
* 展开成 CSS 变量平铺 map,用于 buildThemeStyle 注入 page 元素。
|
|
75
|
-
*
|
|
76
|
-
* 每个角色产出 4 个变量:
|
|
77
|
-
* --text-${role}-size / -weight / -line-height / -color
|
|
78
|
-
*
|
|
79
|
-
* @returns 包含全部排版 CSS 变量键值对的对象
|
|
80
|
-
*/
|
|
81
|
-
export function getCurrentTypographyVars(): Record<string, string> {
|
|
82
|
-
const vars: Record<string, string> = {};
|
|
83
|
-
for (const [role, cfg] of Object.entries(TYPOGRAPHY_ROLES)) {
|
|
84
|
-
vars[`--text-${role}-size`] = cfg.size;
|
|
85
|
-
vars[`--text-${role}-weight`] = cfg.weight;
|
|
86
|
-
vars[`--text-${role}-line-height`] = cfg.lineHeight;
|
|
87
|
-
vars[`--text-${role}-color`] = cfg.color;
|
|
88
|
-
}
|
|
89
|
-
return vars;
|
|
90
|
-
}
|