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