@hlw-uni/mp-vue 2.1.50 → 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,21 +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
|
-
* 让业务侧可以自由 override,不被运行时注入覆盖。
|
|
10
|
+
* 页面背景、卡片色、文字色、边框色等业务视觉变量统一由项目全局 CSS
|
|
11
|
+
* (static/css/style.scss)控制,避免 page-meta 运行时样式覆盖业务侧配置。
|
|
13
12
|
*/
|
|
14
13
|
export declare function buildThemeStyle(): string;
|
|
15
14
|
/**
|
|
16
15
|
* 获取主题样式字符串,用于注入 <page-meta :page-style>。
|
|
17
16
|
*
|
|
18
|
-
* 实现走 pinia store 响应式:store.scale / primaryColor
|
|
17
|
+
* 实现走 pinia store 响应式:store.scale / primaryColor 任一变化
|
|
19
18
|
* → computed 重算 → page-meta 自动 setData。
|
|
20
19
|
*
|
|
21
20
|
* 注:早期版本用 uni.$emit + onMounted+uni.$on 事件总线驱动,在 vue3 + 小程序部分
|
|
22
|
-
* 基础库下 emit 后 ref 不响应(导致字号 /
|
|
21
|
+
* 基础库下 emit 后 ref 不响应(导致字号 / 主题色切换不生效)。已改成响应式驱动。
|
|
23
22
|
*/
|
|
24
23
|
export declare function useThemePageStyle(): {
|
|
25
24
|
themePageStyle: ComputedRef<string>;
|
package/dist/index.js
CHANGED
|
@@ -1489,8 +1489,7 @@ var __publicField = (obj, key, value) => {
|
|
|
1489
1489
|
function buildThemeStyle() {
|
|
1490
1490
|
return varsToStyle({
|
|
1491
1491
|
...getCurrentFontVars(),
|
|
1492
|
-
...getCurrentThemeVars()
|
|
1493
|
-
...getCurrentAppearanceVars()
|
|
1492
|
+
...getCurrentThemeVars()
|
|
1494
1493
|
});
|
|
1495
1494
|
}
|
|
1496
1495
|
function useThemePageStyle() {
|
|
@@ -1498,7 +1497,6 @@ var __publicField = (obj, key, value) => {
|
|
|
1498
1497
|
const themePageStyle = vue.computed(() => {
|
|
1499
1498
|
void store.scale;
|
|
1500
1499
|
void store.primaryColor;
|
|
1501
|
-
void store.appearance;
|
|
1502
1500
|
return buildThemeStyle();
|
|
1503
1501
|
});
|
|
1504
1502
|
return { themePageStyle };
|
package/dist/index.mjs
CHANGED
|
@@ -1488,8 +1488,7 @@ const THEME_CHANGE_EVENT = "hlw:theme-change";
|
|
|
1488
1488
|
function buildThemeStyle() {
|
|
1489
1489
|
return varsToStyle({
|
|
1490
1490
|
...getCurrentFontVars(),
|
|
1491
|
-
...getCurrentThemeVars()
|
|
1492
|
-
...getCurrentAppearanceVars()
|
|
1491
|
+
...getCurrentThemeVars()
|
|
1493
1492
|
});
|
|
1494
1493
|
}
|
|
1495
1494
|
function useThemePageStyle() {
|
|
@@ -1497,7 +1496,6 @@ function useThemePageStyle() {
|
|
|
1497
1496
|
const themePageStyle = computed(() => {
|
|
1498
1497
|
void store.scale;
|
|
1499
1498
|
void store.primaryColor;
|
|
1500
|
-
void store.appearance;
|
|
1501
1499
|
return buildThemeStyle();
|
|
1502
1500
|
});
|
|
1503
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,7 +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
8
|
|
|
10
9
|
/**
|
|
11
10
|
* @deprecated 历史事件名;现已改用 pinia store 响应式驱动,emit 不再有效。
|
|
@@ -14,38 +13,35 @@ import { getCurrentAppearanceVars } from "./appearance";
|
|
|
14
13
|
export const THEME_CHANGE_EVENT = "hlw:theme-change";
|
|
15
14
|
|
|
16
15
|
/**
|
|
17
|
-
*
|
|
16
|
+
* 只注入运行时配置变量(字号档位、主题色)。
|
|
18
17
|
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
* 让业务侧可以自由 override,不被运行时注入覆盖。
|
|
18
|
+
* 页面背景、卡片色、文字色、边框色等业务视觉变量统一由项目全局 CSS
|
|
19
|
+
* (static/css/style.scss)控制,避免 page-meta 运行时样式覆盖业务侧配置。
|
|
22
20
|
*/
|
|
23
21
|
export function buildThemeStyle(): string {
|
|
24
22
|
return varsToStyle({
|
|
25
23
|
...getCurrentFontVars(),
|
|
26
24
|
...getCurrentThemeVars(),
|
|
27
|
-
...getCurrentAppearanceVars(),
|
|
28
25
|
});
|
|
29
26
|
}
|
|
30
27
|
|
|
31
28
|
/**
|
|
32
29
|
* 获取主题样式字符串,用于注入 <page-meta :page-style>。
|
|
33
30
|
*
|
|
34
|
-
* 实现走 pinia store 响应式:store.scale / primaryColor
|
|
31
|
+
* 实现走 pinia store 响应式:store.scale / primaryColor 任一变化
|
|
35
32
|
* → computed 重算 → page-meta 自动 setData。
|
|
36
33
|
*
|
|
37
34
|
* 注:早期版本用 uni.$emit + onMounted+uni.$on 事件总线驱动,在 vue3 + 小程序部分
|
|
38
|
-
* 基础库下 emit 后 ref 不响应(导致字号 /
|
|
35
|
+
* 基础库下 emit 后 ref 不响应(导致字号 / 主题色切换不生效)。已改成响应式驱动。
|
|
39
36
|
*/
|
|
40
37
|
export function useThemePageStyle() {
|
|
41
38
|
const store = useThemeStore();
|
|
42
39
|
const themePageStyle = computed(() => {
|
|
43
|
-
// 显式 track
|
|
44
|
-
// setScale / setTheme
|
|
40
|
+
// 显式 track 两个响应字段,触发 computed 重算
|
|
41
|
+
// setScale / setTheme 内部已先 set storage 再改 ref,
|
|
45
42
|
// 所以 buildThemeStyle 从 storage 读到的一定是最新值
|
|
46
43
|
void store.scale;
|
|
47
44
|
void store.primaryColor;
|
|
48
|
-
void store.appearance;
|
|
49
45
|
return buildThemeStyle();
|
|
50
46
|
});
|
|
51
47
|
return { themePageStyle };
|