@hlw-uni/mp-vue 2.1.51 → 2.1.52
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.
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* 外观模式 — 浅色 / 深色 / 跟随系统
|
|
3
3
|
*
|
|
4
|
-
* 提供一套语义化 CSS 变量(--bg-page, --surface-card, --text-primary
|
|
5
|
-
*
|
|
4
|
+
* 提供一套语义化 CSS 变量(--bg-page, --surface-card, --text-primary ...)。
|
|
5
|
+
* 默认不通过 useThemePageStyle 注入,业务项目应在全局 CSS 中声明这些变量,
|
|
6
|
+
* 避免运行时 page-meta 覆盖业务侧样式。
|
|
6
7
|
*
|
|
7
8
|
* 使用指南:
|
|
8
9
|
* - 业务样式里用 `var(--text-primary)` 代替硬编码 `#0f172a`
|
|
@@ -5,22 +5,20 @@ import { ComputedRef } from 'vue';
|
|
|
5
5
|
*/
|
|
6
6
|
export declare const THEME_CHANGE_EVENT = "hlw:theme-change";
|
|
7
7
|
/**
|
|
8
|
-
*
|
|
8
|
+
* 只注入运行时配置变量(字号档位、主题色)。
|
|
9
9
|
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
* 放在项目的全局 CSS(static/css/style.scss)里作为 page{} 默认值即可,
|
|
13
|
-
* 让业务侧可以自由 override,不被运行时注入覆盖。
|
|
10
|
+
* 页面背景、卡片色、文字色、边框色等业务视觉变量统一由项目全局 CSS
|
|
11
|
+
* (static/css/style.scss)控制,避免 page-meta 运行时样式覆盖业务侧配置。
|
|
14
12
|
*/
|
|
15
13
|
export declare function buildThemeStyle(): string;
|
|
16
14
|
/**
|
|
17
15
|
* 获取主题样式字符串,用于注入 <page-meta :page-style>。
|
|
18
16
|
*
|
|
19
|
-
* 实现走 pinia store 响应式:store.scale / primaryColor
|
|
17
|
+
* 实现走 pinia store 响应式:store.scale / primaryColor 任一变化
|
|
20
18
|
* → computed 重算 → page-meta 自动 setData。
|
|
21
19
|
*
|
|
22
20
|
* 注:早期版本用 uni.$emit + onMounted+uni.$on 事件总线驱动,在 vue3 + 小程序部分
|
|
23
|
-
* 基础库下 emit 后 ref 不响应(导致字号 /
|
|
21
|
+
* 基础库下 emit 后 ref 不响应(导致字号 / 主题色切换不生效)。已改成响应式驱动。
|
|
24
22
|
*/
|
|
25
23
|
export declare function useThemePageStyle(): {
|
|
26
24
|
themePageStyle: ComputedRef<string>;
|
package/dist/index.js
CHANGED
|
@@ -1485,22 +1485,11 @@ var __publicField = (obj, key, value) => {
|
|
|
1485
1485
|
return vars;
|
|
1486
1486
|
}
|
|
1487
1487
|
const { varsToStyle } = useColor();
|
|
1488
|
-
const CSS_CONTROLLED_THEME_VARS = /* @__PURE__ */ new Set(["--border-color", "--border-color-light", "--border-color-focus"]);
|
|
1489
1488
|
const THEME_CHANGE_EVENT = "hlw:theme-change";
|
|
1490
|
-
function omitCssControlledThemeVars(vars) {
|
|
1491
|
-
const next = {};
|
|
1492
|
-
Object.entries(vars).forEach(([name, value]) => {
|
|
1493
|
-
if (!CSS_CONTROLLED_THEME_VARS.has(name)) {
|
|
1494
|
-
next[name] = value;
|
|
1495
|
-
}
|
|
1496
|
-
});
|
|
1497
|
-
return next;
|
|
1498
|
-
}
|
|
1499
1489
|
function buildThemeStyle() {
|
|
1500
1490
|
return varsToStyle({
|
|
1501
1491
|
...getCurrentFontVars(),
|
|
1502
|
-
...getCurrentThemeVars()
|
|
1503
|
-
...omitCssControlledThemeVars(getCurrentAppearanceVars())
|
|
1492
|
+
...getCurrentThemeVars()
|
|
1504
1493
|
});
|
|
1505
1494
|
}
|
|
1506
1495
|
function useThemePageStyle() {
|
|
@@ -1508,7 +1497,6 @@ var __publicField = (obj, key, value) => {
|
|
|
1508
1497
|
const themePageStyle = vue.computed(() => {
|
|
1509
1498
|
void store.scale;
|
|
1510
1499
|
void store.primaryColor;
|
|
1511
|
-
void store.appearance;
|
|
1512
1500
|
return buildThemeStyle();
|
|
1513
1501
|
});
|
|
1514
1502
|
return { themePageStyle };
|
package/dist/index.mjs
CHANGED
|
@@ -1484,22 +1484,11 @@ function getCurrentTypographyVars() {
|
|
|
1484
1484
|
return vars;
|
|
1485
1485
|
}
|
|
1486
1486
|
const { varsToStyle } = useColor();
|
|
1487
|
-
const CSS_CONTROLLED_THEME_VARS = /* @__PURE__ */ new Set(["--border-color", "--border-color-light", "--border-color-focus"]);
|
|
1488
1487
|
const THEME_CHANGE_EVENT = "hlw:theme-change";
|
|
1489
|
-
function omitCssControlledThemeVars(vars) {
|
|
1490
|
-
const next = {};
|
|
1491
|
-
Object.entries(vars).forEach(([name, value]) => {
|
|
1492
|
-
if (!CSS_CONTROLLED_THEME_VARS.has(name)) {
|
|
1493
|
-
next[name] = value;
|
|
1494
|
-
}
|
|
1495
|
-
});
|
|
1496
|
-
return next;
|
|
1497
|
-
}
|
|
1498
1488
|
function buildThemeStyle() {
|
|
1499
1489
|
return varsToStyle({
|
|
1500
1490
|
...getCurrentFontVars(),
|
|
1501
|
-
...getCurrentThemeVars()
|
|
1502
|
-
...omitCssControlledThemeVars(getCurrentAppearanceVars())
|
|
1491
|
+
...getCurrentThemeVars()
|
|
1503
1492
|
});
|
|
1504
1493
|
}
|
|
1505
1494
|
function useThemePageStyle() {
|
|
@@ -1507,7 +1496,6 @@ function useThemePageStyle() {
|
|
|
1507
1496
|
const themePageStyle = computed(() => {
|
|
1508
1497
|
void store.scale;
|
|
1509
1498
|
void store.primaryColor;
|
|
1510
|
-
void store.appearance;
|
|
1511
1499
|
return buildThemeStyle();
|
|
1512
1500
|
});
|
|
1513
1501
|
return { themePageStyle };
|
package/package.json
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* 外观模式 — 浅色 / 深色 / 跟随系统
|
|
3
3
|
*
|
|
4
|
-
* 提供一套语义化 CSS 变量(--bg-page, --surface-card, --text-primary
|
|
5
|
-
*
|
|
4
|
+
* 提供一套语义化 CSS 变量(--bg-page, --surface-card, --text-primary ...)。
|
|
5
|
+
* 默认不通过 useThemePageStyle 注入,业务项目应在全局 CSS 中声明这些变量,
|
|
6
|
+
* 避免运行时 page-meta 覆盖业务侧样式。
|
|
6
7
|
*
|
|
7
8
|
* 使用指南:
|
|
8
9
|
* - 业务样式里用 `var(--text-primary)` 代替硬编码 `#0f172a`
|
|
@@ -5,9 +5,6 @@ import { useThemeStore } from "../../stores/theme";
|
|
|
5
5
|
const { varsToStyle } = useColor();
|
|
6
6
|
import { getCurrentFontVars } from "./font";
|
|
7
7
|
import { getCurrentThemeVars } from "./palette";
|
|
8
|
-
import { getCurrentAppearanceVars } from "./appearance";
|
|
9
|
-
|
|
10
|
-
const CSS_CONTROLLED_THEME_VARS = new Set(["--border-color", "--border-color-light", "--border-color-focus"]);
|
|
11
8
|
|
|
12
9
|
/**
|
|
13
10
|
* @deprecated 历史事件名;现已改用 pinia store 响应式驱动,emit 不再有效。
|
|
@@ -15,52 +12,36 @@ const CSS_CONTROLLED_THEME_VARS = new Set(["--border-color", "--border-color-lig
|
|
|
15
12
|
*/
|
|
16
13
|
export const THEME_CHANGE_EVENT = "hlw:theme-change";
|
|
17
14
|
|
|
18
|
-
function omitCssControlledThemeVars(vars: Record<string, string>) {
|
|
19
|
-
const next: Record<string, string> = {};
|
|
20
|
-
|
|
21
|
-
Object.entries(vars).forEach(([name, value]) => {
|
|
22
|
-
if (!CSS_CONTROLLED_THEME_VARS.has(name)) {
|
|
23
|
-
next[name] = value;
|
|
24
|
-
}
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
return next;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
15
|
/**
|
|
31
|
-
*
|
|
16
|
+
* 只注入运行时配置变量(字号档位、主题色)。
|
|
32
17
|
*
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
* 放在项目的全局 CSS(static/css/style.scss)里作为 page{} 默认值即可,
|
|
36
|
-
* 让业务侧可以自由 override,不被运行时注入覆盖。
|
|
18
|
+
* 页面背景、卡片色、文字色、边框色等业务视觉变量统一由项目全局 CSS
|
|
19
|
+
* (static/css/style.scss)控制,避免 page-meta 运行时样式覆盖业务侧配置。
|
|
37
20
|
*/
|
|
38
21
|
export function buildThemeStyle(): string {
|
|
39
22
|
return varsToStyle({
|
|
40
23
|
...getCurrentFontVars(),
|
|
41
24
|
...getCurrentThemeVars(),
|
|
42
|
-
...omitCssControlledThemeVars(getCurrentAppearanceVars()),
|
|
43
25
|
});
|
|
44
26
|
}
|
|
45
27
|
|
|
46
28
|
/**
|
|
47
29
|
* 获取主题样式字符串,用于注入 <page-meta :page-style>。
|
|
48
30
|
*
|
|
49
|
-
* 实现走 pinia store 响应式:store.scale / primaryColor
|
|
31
|
+
* 实现走 pinia store 响应式:store.scale / primaryColor 任一变化
|
|
50
32
|
* → computed 重算 → page-meta 自动 setData。
|
|
51
33
|
*
|
|
52
34
|
* 注:早期版本用 uni.$emit + onMounted+uni.$on 事件总线驱动,在 vue3 + 小程序部分
|
|
53
|
-
* 基础库下 emit 后 ref 不响应(导致字号 /
|
|
35
|
+
* 基础库下 emit 后 ref 不响应(导致字号 / 主题色切换不生效)。已改成响应式驱动。
|
|
54
36
|
*/
|
|
55
37
|
export function useThemePageStyle() {
|
|
56
38
|
const store = useThemeStore();
|
|
57
39
|
const themePageStyle = computed(() => {
|
|
58
|
-
// 显式 track
|
|
59
|
-
// setScale / setTheme
|
|
40
|
+
// 显式 track 两个响应字段,触发 computed 重算
|
|
41
|
+
// setScale / setTheme 内部已先 set storage 再改 ref,
|
|
60
42
|
// 所以 buildThemeStyle 从 storage 读到的一定是最新值
|
|
61
43
|
void store.scale;
|
|
62
44
|
void store.primaryColor;
|
|
63
|
-
void store.appearance;
|
|
64
45
|
return buildThemeStyle();
|
|
65
46
|
});
|
|
66
47
|
return { themePageStyle };
|