@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.
Files changed (38) hide show
  1. package/README.md +388 -213
  2. package/dist/composables/index.d.ts +0 -8
  3. package/dist/composables/request/service.d.ts +2 -6
  4. package/dist/core/index.d.ts +1 -0
  5. package/dist/core/theme.d.ts +21 -0
  6. package/dist/index.d.ts +2 -2
  7. package/dist/index.js +113 -367
  8. package/dist/index.mjs +113 -367
  9. package/dist/stores/index.d.ts +1 -0
  10. package/dist/stores/theme.d.ts +26 -55
  11. package/package.json +1 -1
  12. package/src/components/hlw-add-mini/index.vue +147 -77
  13. package/src/components/hlw-avatar/index.vue +28 -20
  14. package/src/components/hlw-card-header/index.vue +3 -0
  15. package/src/components/hlw-cell/index.vue +6 -0
  16. package/src/components/hlw-custom/hlw-custom.vue +6 -5
  17. package/src/components/hlw-menu/index.vue +9 -3
  18. package/src/components/hlw-nav-bar/index.vue +181 -0
  19. package/src/components/hlw-page/index.vue +75 -105
  20. package/src/composables/index.ts +1 -31
  21. package/src/composables/request/service.ts +10 -3
  22. package/src/core/index.ts +1 -0
  23. package/src/core/theme.ts +62 -0
  24. package/src/env.d.ts +8 -0
  25. package/src/index.ts +10 -4
  26. package/src/stores/index.ts +1 -0
  27. package/src/stores/theme.ts +113 -101
  28. package/dist/composables/theme/appearance.d.ts +0 -55
  29. package/dist/composables/theme/font.d.ts +0 -32
  30. package/dist/composables/theme/index.d.ts +0 -46
  31. package/dist/composables/theme/palette.d.ts +0 -37
  32. package/dist/composables/theme/typography.d.ts +0 -41
  33. package/src/composables/theme/README.md +0 -131
  34. package/src/composables/theme/appearance.ts +0 -129
  35. package/src/composables/theme/font.ts +0 -95
  36. package/src/composables/theme/index.ts +0 -89
  37. package/src/composables/theme/palette.ts +0 -117
  38. package/src/composables/theme/typography.ts +0 -90
@@ -9,11 +9,3 @@ export { useShare, type ShareConfig, } from './share';
9
9
  export { useHlwAd, type AdRes } from './ad';
10
10
  export { useUtils, withQuery, toQuery, signText, toNumber, toBoolean, copy, paste, auth, saveImage, saveVideoFile, download, saveImageUrl, saveVideoUrl, type DownloadOpt, type DownloadRes, } from './utils';
11
11
  export { useNavigate, type NavigateType, type NavigateOptions } from './navigator';
12
- export type { FontScale, FontPreset } from './theme';
13
- export { FONT_SCALE_KEY, FONT_PRESETS, getCurrentFontScale, getCurrentFontVars, THEME_CHANGE_EVENT, buildThemeStyle, useThemePageStyle, } from './theme';
14
- export type { ThemeColor } from './theme';
15
- export { THEME_COLOR_KEY, THEME_SEMANTIC_COLORS, DEFAULT_THEMES, getCurrentThemeColor, getCurrentThemeVars, } from './theme';
16
- export type { Appearance, AppearanceMode, AppearancePreset } from './theme';
17
- export { APPEARANCE_KEY, APPEARANCE_PRESETS, APPEARANCE_VAR_MAP, getCurrentAppearance, getCurrentAppearanceMode, getCurrentAppearanceVars, resolveAppearance, } from './theme';
18
- export type { TypographyRole } from './theme';
19
- export { TYPOGRAPHY_ROLES, getCurrentTypographyVars } from './theme';
@@ -94,10 +94,6 @@ export declare function ServicePrefix(value: string | ServicePrefixOptions): (ta
94
94
  }) => void;
95
95
  /**
96
96
  * 插件服务类装饰器。
97
- * 自动使用 `import.meta.env.VITE_PLUGIN_NAME` 作为服务前缀。
97
+ * 自动使用 `import.meta.env.VITE_PLUGIN_NAME` 作为服务前缀(通过 globalThis 动态读取)。
98
98
  */
99
- export declare function PluginService(target: {
100
- prototype: {
101
- servicePrefix?: string;
102
- };
103
- }): void;
99
+ export declare function PluginService(target: any): void;
@@ -0,0 +1 @@
1
+ export * from './theme';
@@ -0,0 +1,21 @@
1
+ import { ComputedRef } from 'vue';
2
+ import { Store } from 'pinia';
3
+
4
+ export { themePresets, type ThemePreset, fontSizePresets, type FontSizePreset, fontFamilyPresets, type FontFamilyPreset } from '../stores/theme';
5
+ export declare function useTheme(): {
6
+ theme: ComputedRef<string>;
7
+ fontSize: ComputedRef<string>;
8
+ fontSizeClass: ComputedRef<string>;
9
+ setFontSize: (size: string) => void;
10
+ fontFamily: ComputedRef<string>;
11
+ fontFamilyClass: ComputedRef<string>;
12
+ setFontFamily: (font: string) => void;
13
+ store: Store<"theme", {
14
+ theme: string;
15
+ fontSize: string;
16
+ fontFamily: string;
17
+ }, {}, {
18
+ setFontSize(size: string): void;
19
+ setFontFamily(font: string): void;
20
+ }>;
21
+ };
package/dist/index.d.ts CHANGED
@@ -3,14 +3,14 @@
3
3
  *
4
4
  * 2.0 起合并了原 @hlw-uni/mp-core 全部内容。
5
5
  * 业务方一处 import,无需再分包:
6
- * import { useMsg, useThemePageStyle, ... } from "@hlw-uni/mp-vue";
6
+ * import { useMsg, useTheme, ... } from "@hlw-uni/mp-vue";
7
7
  *
8
8
  * UI 组件(hlw-page / hlw-button / hlw-ad 等)走 easycom 自动注册,不在这里 export。
9
9
  */
10
10
  export * from './composables';
11
+ export { useTheme, themePresets, type ThemePreset, fontFamilyPresets, type FontFamilyPreset, fontSizePresets, type FontSizePreset } from './core/theme';
11
12
  export type { HlwMenuItem } from './components/hlw-menu/types';
12
13
  export type { HlwPagingRef, HlwPagingInstance } from './components/hlw-paging/types';
13
- export { useThemeStore } from './stores/theme';
14
14
  export { useApp } from './app';
15
15
  export { hlw, type HlwInstance } from './hlw';
16
16
  export { vCopy } from './directives';
package/dist/index.js CHANGED
@@ -281,7 +281,6 @@ var __publicField = (obj, key, value) => {
281
281
  }
282
282
  return { uploading, upload };
283
283
  }
284
- var define_import_meta_env_default = {};
285
284
  class BaseService {
286
285
  /**
287
286
  * 发送服务请求。会自动拼接前缀与命名空间。
@@ -338,7 +337,13 @@ var __publicField = (obj, key, value) => {
338
337
  };
339
338
  }
340
339
  function PluginService(target) {
341
- target.prototype.servicePrefix = define_import_meta_env_default.VITE_PLUGIN_NAME || "";
340
+ Object.defineProperty(target.prototype, "servicePrefix", {
341
+ get() {
342
+ return globalThis.VITE_PLUGIN_NAME || "";
343
+ },
344
+ enumerable: true,
345
+ configurable: true
346
+ });
342
347
  }
343
348
  function useMsg() {
344
349
  function toast(opts) {
@@ -964,363 +969,122 @@ var __publicField = (obj, key, value) => {
964
969
  miniProgram: (appId, options) => navigate("miniprogram", appId, options)
965
970
  };
966
971
  }
967
- const useThemeStore = pinia.defineStore(
968
- "theme",
969
- () => {
970
- const scale = vue.ref("normal");
971
- function setScale(s) {
972
- scale.value = s;
973
- uni.setStorageSync(FONT_SCALE_KEY, s);
974
- uni.$emit(THEME_CHANGE_EVENT);
975
- }
976
- const fontOptions = Object.keys(FONT_PRESETS).map((key) => ({
977
- value: key,
978
- label: FONT_PRESETS[key].label
979
- }));
980
- const primaryColor = vue.ref(DEFAULT_THEMES[0].value);
981
- const themes = DEFAULT_THEMES;
982
- const activeTheme = vue.computed(
983
- () => themes.find((t) => t.value === primaryColor.value) ?? { label: "自定义", value: primaryColor.value }
984
- );
985
- function setTheme(color) {
986
- primaryColor.value = color;
987
- uni.setStorageSync(THEME_COLOR_KEY, color);
988
- uni.$emit(THEME_CHANGE_EVENT);
989
- }
990
- const appearance = vue.ref("auto");
991
- const appearanceOptions = APPEARANCE_PRESETS;
992
- const appearanceMode = vue.computed(() => resolveAppearance(appearance.value));
993
- const isDark = vue.computed(() => appearanceMode.value === "dark");
994
- function setAppearance(a) {
995
- appearance.value = a;
996
- uni.setStorageSync(APPEARANCE_KEY, a);
997
- uni.$emit(THEME_CHANGE_EVENT);
998
- }
999
- return {
1000
- // 字体
1001
- scale,
1002
- fontOptions,
1003
- setScale,
1004
- // 主题色
1005
- primaryColor,
1006
- themes,
1007
- activeTheme,
1008
- setTheme,
1009
- // 外观模式
1010
- appearance,
1011
- appearanceOptions,
1012
- appearanceMode,
1013
- isDark,
1014
- setAppearance
1015
- };
972
+ const themePresets = [
973
+ {
974
+ id: "white-theme",
975
+ name: "白色主题",
976
+ color: "#ffffff"
1016
977
  },
1017
- { unistorage: true }
1018
- );
1019
- const FONT_SCALE_KEY = "hlw_font_scale";
1020
- const FONT_PRESETS = {
1021
- small: {
1022
- label: "较小",
1023
- vars: {
1024
- "--font-xs": "16rpx",
1025
- "--font-sm": "20rpx",
1026
- "--font-base": "24rpx",
1027
- "--font-md": "28rpx",
1028
- "--font-lg": "32rpx",
1029
- "--font-xl": "36rpx"
1030
- }
978
+ {
979
+ id: "light-theme",
980
+ name: "简洁主题",
981
+ color: "var(--bg-page, #f8f8f8)"
1031
982
  },
1032
- compact: {
1033
- label: "略小",
1034
- vars: {
1035
- "--font-xs": "18rpx",
1036
- "--font-sm": "22rpx",
1037
- "--font-base": "26rpx",
1038
- "--font-md": "30rpx",
1039
- "--font-lg": "34rpx",
1040
- "--font-xl": "38rpx"
1041
- }
983
+ {
984
+ id: "mono-theme",
985
+ name: "单色主题",
986
+ color: "var(--primary-color, #3b82f6)"
1042
987
  },
1043
- normal: {
1044
- label: "标准",
1045
- vars: {
1046
- "--font-xs": "20rpx",
1047
- "--font-sm": "24rpx",
1048
- "--font-base": "28rpx",
1049
- "--font-md": "32rpx",
1050
- "--font-lg": "36rpx",
1051
- "--font-xl": "40rpx"
1052
- }
1053
- },
1054
- medium: {
1055
- label: "适中",
1056
- vars: {
1057
- "--font-xs": "22rpx",
1058
- "--font-sm": "28rpx",
1059
- "--font-base": "32rpx",
1060
- "--font-md": "36rpx",
1061
- "--font-lg": "42rpx",
1062
- "--font-xl": "46rpx"
1063
- }
988
+ {
989
+ id: "color-theme",
990
+ name: "颜色主题",
991
+ color: "var(--primary-color, #3b82f6)"
992
+ }
993
+ ];
994
+ const fontSizePresets = [
995
+ {
996
+ id: "small",
997
+ name: "较小",
998
+ class: "font-size-small"
1064
999
  },
1065
- large: {
1066
- label: "较大",
1067
- vars: {
1068
- "--font-xs": "24rpx",
1069
- "--font-sm": "30rpx",
1070
- "--font-base": "34rpx",
1071
- "--font-md": "40rpx",
1072
- "--font-lg": "46rpx",
1073
- "--font-xl": "52rpx"
1074
- }
1000
+ {
1001
+ id: "standard",
1002
+ name: "标准",
1003
+ class: "font-size-standard"
1075
1004
  },
1076
- xlarge: {
1077
- label: "超大",
1078
- vars: {
1079
- "--font-xs": "28rpx",
1080
- "--font-sm": "36rpx",
1081
- "--font-base": "42rpx",
1082
- "--font-md": "48rpx",
1083
- "--font-lg": "56rpx",
1084
- "--font-xl": "64rpx"
1085
- }
1005
+ {
1006
+ id: "large",
1007
+ name: "较大",
1008
+ class: "font-size-large"
1086
1009
  },
1087
- xxlarge: {
1088
- label: "特大",
1089
- vars: {
1090
- "--font-xs": "32rpx",
1091
- "--font-sm": "42rpx",
1092
- "--font-base": "48rpx",
1093
- "--font-md": "56rpx",
1094
- "--font-lg": "64rpx",
1095
- "--font-xl": "72rpx"
1096
- }
1010
+ {
1011
+ id: "extra-large",
1012
+ name: "超大",
1013
+ class: "font-size-extra-large"
1097
1014
  }
1098
- };
1099
- function getCurrentFontScale() {
1100
- try {
1101
- const v = uni.getStorageSync(FONT_SCALE_KEY);
1102
- if (v === "small" || v === "compact" || v === "medium" || v === "large" || v === "xlarge" || v === "xxlarge")
1103
- return v;
1104
- } catch {
1105
- }
1106
- return "normal";
1107
- }
1108
- function getCurrentFontVars() {
1109
- return FONT_PRESETS[getCurrentFontScale()].vars;
1110
- }
1111
- const THEME_COLOR_KEY = "hlw_theme_color";
1112
- const THEME_SEMANTIC_COLORS = {
1113
- success: "#10b981",
1114
- warning: "#f59e0b",
1115
- error: "#ef4444",
1116
- info: "#64748b"
1117
- };
1118
- const DEFAULT_THEMES = [
1119
- { label: "翡翠绿", value: "#10b981" },
1120
- { label: "活力橙", value: "#f97316" },
1121
- { label: "默认蓝", value: "#3b82f6" },
1122
- { label: "玫瑰粉", value: "#f43f5e" },
1123
- { label: "紫罗兰", value: "#8b5cf6" },
1124
- { label: "青石灰", value: "#64748b" }
1125
1015
  ];
1126
- function getCurrentThemeColor() {
1127
- try {
1128
- const v = uni.getStorageSync(THEME_COLOR_KEY);
1129
- if (v && typeof v === "string")
1130
- return v;
1131
- } catch {
1132
- }
1133
- return DEFAULT_THEMES[0].value;
1134
- }
1135
- function getCurrentThemeVars() {
1136
- const color = getCurrentThemeColor();
1137
- return {
1138
- "--primary-color": color,
1139
- "--primary-light": hexToRgba(color, 0.12),
1140
- "--primary-dark": darkenHex(color),
1141
- "--primary-success": THEME_SEMANTIC_COLORS.success,
1142
- "--primary-success-light": hexToRgba(THEME_SEMANTIC_COLORS.success, 0.12),
1143
- "--primary-success-dark": darkenHex(THEME_SEMANTIC_COLORS.success),
1144
- "--primary-warning": THEME_SEMANTIC_COLORS.warning,
1145
- "--primary-warning-light": hexToRgba(THEME_SEMANTIC_COLORS.warning, 0.12),
1146
- "--primary-warning-dark": darkenHex(THEME_SEMANTIC_COLORS.warning),
1147
- "--primary-error": THEME_SEMANTIC_COLORS.error,
1148
- "--primary-error-light": hexToRgba(THEME_SEMANTIC_COLORS.error, 0.12),
1149
- "--primary-error-dark": darkenHex(THEME_SEMANTIC_COLORS.error),
1150
- "--primary-info": THEME_SEMANTIC_COLORS.info,
1151
- "--primary-info-light": hexToRgba(THEME_SEMANTIC_COLORS.info, 0.12),
1152
- "--primary-info-dark": darkenHex(THEME_SEMANTIC_COLORS.info),
1153
- "--success-color": THEME_SEMANTIC_COLORS.success,
1154
- "--success-light": hexToRgba(THEME_SEMANTIC_COLORS.success, 0.12),
1155
- "--success-dark": darkenHex(THEME_SEMANTIC_COLORS.success),
1156
- "--warning-color": THEME_SEMANTIC_COLORS.warning,
1157
- "--warning-light": hexToRgba(THEME_SEMANTIC_COLORS.warning, 0.12),
1158
- "--warning-dark": darkenHex(THEME_SEMANTIC_COLORS.warning),
1159
- "--error-color": THEME_SEMANTIC_COLORS.error,
1160
- "--error-light": hexToRgba(THEME_SEMANTIC_COLORS.error, 0.12),
1161
- "--error-dark": darkenHex(THEME_SEMANTIC_COLORS.error),
1162
- "--info-color": THEME_SEMANTIC_COLORS.info,
1163
- "--info-light": hexToRgba(THEME_SEMANTIC_COLORS.info, 0.12),
1164
- "--info-dark": darkenHex(THEME_SEMANTIC_COLORS.info)
1165
- };
1166
- }
1167
- const HEX_RE = /^#[0-9a-fA-F]{6}$/;
1168
- function parseHex(hex) {
1169
- if (!HEX_RE.test(hex))
1170
- throw new Error(`Invalid hex color: ${hex}`);
1171
- return [
1172
- parseInt(hex.slice(1, 3), 16),
1173
- parseInt(hex.slice(3, 5), 16),
1174
- parseInt(hex.slice(5, 7), 16)
1175
- ];
1176
- }
1177
- function hexToRgba(hex, alpha) {
1178
- const [r, g, b] = parseHex(hex);
1179
- return `rgba(${r},${g},${b},${alpha})`;
1180
- }
1181
- function darkenHex(hex, amount = 0.15) {
1182
- const [r, g, b] = parseHex(hex);
1183
- const darken = (value) => Math.max(0, Math.round(value * (1 - amount)));
1184
- return `#${darken(r).toString(16).padStart(2, "0")}${darken(g).toString(16).padStart(2, "0")}${darken(b).toString(16).padStart(2, "0")}`;
1185
- }
1186
- const APPEARANCE_KEY = "hlw_appearance";
1187
- const APPEARANCE_PRESETS = [
1188
- { value: "light", label: "浅色模式" },
1189
- { value: "dark", label: "深色模式" },
1190
- { value: "auto", label: "跟随系统" }
1191
- ];
1192
- const LIGHT_VARS = {
1193
- "--bg-page": "#f6f6f6",
1194
- "--bg-elevated": "#ffffff",
1195
- "--surface-card": "#ffffff",
1196
- "--surface-card-muted": "#f8fafc",
1197
- "--surface-secondary": "#f1f5f9",
1198
- "--surface-tertiary": "#e2e8f0",
1199
- "--text-primary": "#0f172a",
1200
- "--text-secondary": "#334155",
1201
- "--text-muted": "#64748b",
1202
- "--text-subtle": "#94a3b8",
1203
- "--text-disabled": "#cbd5e1",
1204
- "--border-color": "#e2e8f0",
1205
- "--border-color-light": "#f1f5f9",
1206
- "--border-color-focus": "#bfdbfe",
1207
- "--shadow-soft": "0 2rpx 8rpx rgba(15, 23, 42, 0.04)",
1208
- "--shadow-card": "0 4rpx 16rpx rgba(15, 23, 42, 0.06)"
1209
- };
1210
- const DARK_VARS = {
1211
- "--bg-page": "#0b1020",
1212
- "--bg-elevated": "#111827",
1213
- "--surface-card": "#1e293b",
1214
- "--surface-card-muted": "#273549",
1215
- "--surface-secondary": "#273549",
1216
- "--surface-tertiary": "#334155",
1217
- "--text-primary": "#f8fafc",
1218
- "--text-secondary": "#cbd5e1",
1219
- "--text-muted": "#94a3b8",
1220
- "--text-subtle": "#64748b",
1221
- "--text-disabled": "#475569",
1222
- "--border-color": "#334155",
1223
- "--border-color-light": "#1e293b",
1224
- "--border-color-focus": "#3b82f6",
1225
- "--shadow-soft": "0 2rpx 8rpx rgba(0, 0, 0, 0.3)",
1226
- "--shadow-card": "0 4rpx 16rpx rgba(0, 0, 0, 0.35)"
1227
- };
1228
- const APPEARANCE_VAR_MAP = {
1229
- light: LIGHT_VARS,
1230
- dark: DARK_VARS
1231
- };
1232
- function getCurrentAppearance() {
1233
- try {
1234
- const v = uni.getStorageSync(APPEARANCE_KEY);
1235
- if (v === "light" || v === "dark" || v === "auto")
1236
- return v;
1237
- } catch {
1238
- }
1239
- return "auto";
1240
- }
1241
- function resolveAppearance(appearance) {
1242
- if (appearance === "light" || appearance === "dark")
1243
- return appearance;
1244
- try {
1245
- const info = uni.getSystemInfoSync();
1246
- if (info.theme === "dark")
1247
- return "dark";
1248
- } catch {
1249
- }
1250
- return "light";
1251
- }
1252
- function getCurrentAppearanceMode() {
1253
- return resolveAppearance(getCurrentAppearance());
1254
- }
1255
- function getCurrentAppearanceVars() {
1256
- return APPEARANCE_VAR_MAP[getCurrentAppearanceMode()];
1257
- }
1258
- const TYPOGRAPHY_ROLES = {
1259
- "title-lg": {
1260
- size: "var(--font-xl)",
1261
- weight: "600",
1262
- lineHeight: "1.2",
1263
- color: "var(--text-primary)"
1264
- },
1265
- "title": {
1266
- size: "var(--font-md)",
1267
- weight: "500",
1268
- lineHeight: "1.3",
1269
- color: "var(--text-primary)"
1270
- },
1271
- "subtitle": {
1272
- size: "var(--font-base)",
1273
- weight: "500",
1274
- lineHeight: "1.3",
1275
- color: "var(--text-secondary)"
1016
+ const fontFamilyPresets = [
1017
+ {
1018
+ id: "system",
1019
+ name: "系统默认",
1020
+ class: "font-family-system"
1276
1021
  },
1277
- "body": {
1278
- size: "var(--font-base)",
1279
- weight: "400",
1280
- lineHeight: "1.5",
1281
- color: "var(--text-secondary)"
1022
+ {
1023
+ id: "sans",
1024
+ name: "现代黑体",
1025
+ class: "font-family-sans"
1282
1026
  },
1283
- "desc": {
1284
- size: "var(--font-sm)",
1285
- weight: "400",
1286
- lineHeight: "1.4",
1287
- color: "var(--text-subtle)"
1027
+ {
1028
+ id: "serif",
1029
+ name: "经典宋体",
1030
+ class: "font-family-serif"
1288
1031
  },
1289
- "caption": {
1290
- size: "var(--font-xs)",
1291
- weight: "500",
1292
- lineHeight: "1.3",
1293
- color: "var(--text-muted)"
1032
+ {
1033
+ id: "kaiti",
1034
+ name: "优雅楷体",
1035
+ class: "font-family-kaiti"
1294
1036
  }
1295
- };
1296
- function getCurrentTypographyVars() {
1297
- const vars = {};
1298
- for (const [role, cfg] of Object.entries(TYPOGRAPHY_ROLES)) {
1299
- vars[`--text-${role}-size`] = cfg.size;
1300
- vars[`--text-${role}-weight`] = cfg.weight;
1301
- vars[`--text-${role}-line-height`] = cfg.lineHeight;
1302
- vars[`--text-${role}-color`] = cfg.color;
1303
- }
1304
- return vars;
1305
- }
1306
- const THEME_CHANGE_EVENT = "hlw:theme-change";
1307
- function buildThemeStyle() {
1308
- return varsToStyle({
1309
- ...getCurrentFontVars(),
1310
- ...getCurrentThemeVars()
1311
- });
1312
- }
1313
- function varsToStyle(vars) {
1314
- return Object.entries(vars).map(([key, value]) => `${key}:${value}`).join(";") + ";";
1315
- }
1316
- function useThemePageStyle() {
1037
+ ];
1038
+ const useThemeStore = pinia.defineStore("theme", {
1039
+ state: () => ({
1040
+ theme: "white-theme",
1041
+ fontSize: "standard",
1042
+ fontFamily: "system"
1043
+ }),
1044
+ getters: {},
1045
+ actions: {
1046
+ setFontSize(size) {
1047
+ if (["small", "standard", "large", "extra-large"].includes(size)) {
1048
+ this.fontSize = size;
1049
+ }
1050
+ },
1051
+ setFontFamily(font) {
1052
+ if (["system", "sans", "serif", "kaiti"].includes(font)) {
1053
+ this.fontFamily = font;
1054
+ }
1055
+ }
1056
+ },
1057
+ unistorage: true
1058
+ });
1059
+ function useTheme() {
1317
1060
  const store = useThemeStore();
1318
- const themePageStyle = vue.computed(() => {
1319
- void store.scale;
1320
- void store.primaryColor;
1321
- return buildThemeStyle();
1061
+ const theme = vue.computed(() => store.theme);
1062
+ const fontSize = vue.computed(() => store.fontSize);
1063
+ const fontSizeClass = vue.computed(() => {
1064
+ const found = fontSizePresets.find((p) => p.id === store.fontSize);
1065
+ return found ? found.class : "font-size-standard";
1066
+ });
1067
+ const fontFamily = vue.computed(() => store.fontFamily);
1068
+ const fontFamilyClass = vue.computed(() => {
1069
+ const found = fontFamilyPresets.find((p) => p.id === store.fontFamily);
1070
+ return found ? found.class : "font-family-system";
1322
1071
  });
1323
- return { themePageStyle };
1072
+ function setFontSize(size) {
1073
+ store.setFontSize(size);
1074
+ }
1075
+ function setFontFamily(font) {
1076
+ store.setFontFamily(font);
1077
+ }
1078
+ return {
1079
+ theme,
1080
+ fontSize,
1081
+ fontSizeClass,
1082
+ setFontSize,
1083
+ fontFamily,
1084
+ fontFamilyClass,
1085
+ setFontFamily,
1086
+ store
1087
+ };
1324
1088
  }
1325
1089
  let _msg = null;
1326
1090
  let _utils = null;
@@ -1396,47 +1160,30 @@ var __publicField = (obj, key, value) => {
1396
1160
  injectTap(vnode, binding);
1397
1161
  }
1398
1162
  };
1399
- exports2.APPEARANCE_KEY = APPEARANCE_KEY;
1400
- exports2.APPEARANCE_PRESETS = APPEARANCE_PRESETS;
1401
- exports2.APPEARANCE_VAR_MAP = APPEARANCE_VAR_MAP;
1402
1163
  exports2.BaseService = BaseService;
1403
- exports2.DEFAULT_THEMES = DEFAULT_THEMES;
1404
- exports2.FONT_PRESETS = FONT_PRESETS;
1405
- exports2.FONT_SCALE_KEY = FONT_SCALE_KEY;
1406
1164
  exports2.PluginService = PluginService;
1407
1165
  exports2.ServiceNamespace = ServiceNamespace;
1408
1166
  exports2.ServicePrefix = ServicePrefix;
1409
- exports2.THEME_CHANGE_EVENT = THEME_CHANGE_EVENT;
1410
- exports2.THEME_COLOR_KEY = THEME_COLOR_KEY;
1411
- exports2.THEME_SEMANTIC_COLORS = THEME_SEMANTIC_COLORS;
1412
- exports2.TYPOGRAPHY_ROLES = TYPOGRAPHY_ROLES;
1413
1167
  exports2.adapters = adapters;
1414
1168
  exports2.alistAdapter = alistAdapter;
1415
1169
  exports2.auth = auth;
1416
- exports2.buildThemeStyle = buildThemeStyle;
1417
1170
  exports2.clearDeviceCache = clearDeviceCache;
1418
1171
  exports2.copy = copy;
1419
1172
  exports2.cosAdapter = cosAdapter;
1420
1173
  exports2.download = download;
1174
+ exports2.fontFamilyPresets = fontFamilyPresets;
1175
+ exports2.fontSizePresets = fontSizePresets;
1421
1176
  exports2.getAdapter = getAdapter;
1422
- exports2.getCurrentAppearance = getCurrentAppearance;
1423
- exports2.getCurrentAppearanceMode = getCurrentAppearanceMode;
1424
- exports2.getCurrentAppearanceVars = getCurrentAppearanceVars;
1425
- exports2.getCurrentFontScale = getCurrentFontScale;
1426
- exports2.getCurrentFontVars = getCurrentFontVars;
1427
- exports2.getCurrentThemeColor = getCurrentThemeColor;
1428
- exports2.getCurrentThemeVars = getCurrentThemeVars;
1429
- exports2.getCurrentTypographyVars = getCurrentTypographyVars;
1430
1177
  exports2.hlw = hlw;
1431
1178
  exports2.ossAdapter = ossAdapter;
1432
1179
  exports2.paste = paste;
1433
1180
  exports2.qiniuAdapter = qiniuAdapter;
1434
- exports2.resolveAppearance = resolveAppearance;
1435
1181
  exports2.saveImage = saveImage;
1436
1182
  exports2.saveImageUrl = saveImageUrl;
1437
1183
  exports2.saveVideoFile = saveVideoFile;
1438
1184
  exports2.saveVideoUrl = saveVideoUrl;
1439
1185
  exports2.signText = signText;
1186
+ exports2.themePresets = themePresets;
1440
1187
  exports2.toBoolean = toBoolean;
1441
1188
  exports2.toNumber = toNumber;
1442
1189
  exports2.toQuery = toQuery;
@@ -1448,8 +1195,7 @@ var __publicField = (obj, key, value) => {
1448
1195
  exports2.useRefs = useRefs;
1449
1196
  exports2.useRequest = useRequest;
1450
1197
  exports2.useShare = useShare;
1451
- exports2.useThemePageStyle = useThemePageStyle;
1452
- exports2.useThemeStore = useThemeStore;
1198
+ exports2.useTheme = useTheme;
1453
1199
  exports2.useUpload = useUpload;
1454
1200
  exports2.useUtils = useUtils;
1455
1201
  exports2.vCopy = vCopy;