@hlw-uni-mp/use 1.1.4 → 1.1.6
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/dist/index.d.mts +30 -103
- package/dist/index.d.ts +30 -103
- package/dist/index.js +41 -115
- package/dist/index.mjs +43 -115
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import * as vue from 'vue';
|
|
2
|
+
import { App, Ref } from 'vue';
|
|
1
3
|
import * as pinia from 'pinia';
|
|
2
|
-
import { App, Ref, ComputedRef } from 'vue';
|
|
3
4
|
|
|
4
5
|
declare module "pinia" {
|
|
5
6
|
interface DefineStoreOptionsBase<S, Store> {
|
|
@@ -7,114 +8,65 @@ declare module "pinia" {
|
|
|
7
8
|
unistorage?: boolean | object;
|
|
8
9
|
}
|
|
9
10
|
}
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* 外观模式型
|
|
13
|
-
*/
|
|
11
|
+
/** 外观模式 */
|
|
14
12
|
type ThemeMode = "light" | "dark" | "system";
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* 字体大小型
|
|
18
|
-
*/
|
|
13
|
+
/** 字体大小 */
|
|
19
14
|
type FontSize = "small" | "standard" | "large" | "extra-large";
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* 字体样式型
|
|
23
|
-
*/
|
|
15
|
+
/** 字体样式 */
|
|
24
16
|
type FontFamily = "system" | "sans" | "serif" | "kaiti";
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* 主题色彩项
|
|
28
|
-
*/
|
|
17
|
+
/** 主题色彩项 */
|
|
29
18
|
interface ThemeColor {
|
|
30
19
|
name: string;
|
|
31
20
|
value: string;
|
|
32
21
|
}
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* 主题状态表
|
|
36
|
-
*/
|
|
22
|
+
/** 主题状态表 */
|
|
37
23
|
interface ThemeState {
|
|
38
24
|
mode: ThemeMode;
|
|
39
25
|
color: string;
|
|
40
26
|
fontSize: FontSize;
|
|
41
27
|
fontFamily: FontFamily;
|
|
42
28
|
}
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* 初始配置项
|
|
46
|
-
*/
|
|
29
|
+
/** 初始配置项 */
|
|
47
30
|
interface InitThemeOptions {
|
|
48
31
|
sync?: boolean;
|
|
49
32
|
defaultTheme?: Partial<ThemeState>;
|
|
50
33
|
}
|
|
51
|
-
|
|
52
|
-
/**
|
|
53
|
-
* 字体大小项
|
|
54
|
-
*/
|
|
34
|
+
/** 字体大小预设项 */
|
|
55
35
|
interface FontSizePreset {
|
|
56
36
|
id: string;
|
|
57
37
|
name: string;
|
|
58
38
|
class: string;
|
|
59
39
|
}
|
|
60
|
-
|
|
61
|
-
/**
|
|
62
|
-
* 字体样式项
|
|
63
|
-
*/
|
|
40
|
+
/** 字体样式预设项 */
|
|
64
41
|
interface FontFamilyPreset {
|
|
65
42
|
id: string;
|
|
66
43
|
name: string;
|
|
67
44
|
class: string;
|
|
68
45
|
}
|
|
69
|
-
|
|
70
|
-
/**
|
|
71
|
-
* 字体大小表
|
|
72
|
-
*/
|
|
73
|
-
declare const fontSizePresets: FontSizePreset[];
|
|
74
|
-
/**
|
|
75
|
-
* 字体样式表
|
|
76
|
-
*/
|
|
77
|
-
declare const fontFamilyPresets: FontFamilyPreset[];
|
|
78
|
-
/**
|
|
79
|
-
* 主题状态库
|
|
80
|
-
*/
|
|
81
|
-
declare const useThemeStore: pinia.StoreDefinition<"theme", {
|
|
82
|
-
mode: string;
|
|
83
|
-
color: string;
|
|
84
|
-
fontSize: string;
|
|
85
|
-
fontFamily: string;
|
|
86
|
-
}, {}, {}>;
|
|
87
|
-
|
|
88
|
-
/**
|
|
89
|
-
* 默认主题配置
|
|
90
|
-
*/
|
|
46
|
+
/** 默认主题配置 */
|
|
91
47
|
declare const DEFAULT_THEME: ThemeState;
|
|
92
|
-
/**
|
|
93
|
-
* 预设色彩库
|
|
94
|
-
*/
|
|
48
|
+
/** 预设色彩库 */
|
|
95
49
|
declare const THEME_COLORS: ThemeColor[];
|
|
96
|
-
/**
|
|
97
|
-
|
|
98
|
-
*/
|
|
50
|
+
/** 字体大小预设表 */
|
|
51
|
+
declare const fontSizePresets: FontSizePreset[];
|
|
52
|
+
/** 字体样式预设表 */
|
|
53
|
+
declare const fontFamilyPresets: FontFamilyPreset[];
|
|
54
|
+
/** 主题状态 Store */
|
|
55
|
+
declare const useThemeStore: pinia.StoreDefinition<"theme", ThemeState, {}, {}>;
|
|
56
|
+
/** 获取存储配置 */
|
|
99
57
|
declare function getTheme(): ThemeState;
|
|
100
|
-
/**
|
|
101
|
-
* 应用主题状态
|
|
102
|
-
*/
|
|
58
|
+
/** 应用主题状态 */
|
|
103
59
|
declare function applyTheme(themeState: Partial<ThemeState>): void;
|
|
104
|
-
/**
|
|
105
|
-
* 注册主题器
|
|
106
|
-
*/
|
|
60
|
+
/** 初始化主题系统 */
|
|
107
61
|
declare function initTheme(app: App, options?: InitThemeOptions): void;
|
|
108
|
-
/**
|
|
109
|
-
* 主题组合钩子
|
|
110
|
-
*/
|
|
62
|
+
/** 主题组合式函数 */
|
|
111
63
|
declare function useTheme(): {
|
|
112
|
-
mode: Ref<ThemeMode, ThemeMode>;
|
|
113
|
-
color: Ref<string, string>;
|
|
114
|
-
fontSize: Ref<
|
|
115
|
-
fontSizeClass: ComputedRef<string>;
|
|
116
|
-
fontFamily: Ref<
|
|
117
|
-
fontFamilyClass: ComputedRef<string>;
|
|
64
|
+
mode: vue.Ref<ThemeMode, ThemeMode>;
|
|
65
|
+
color: vue.Ref<string, string>;
|
|
66
|
+
fontSize: vue.Ref<FontSize, FontSize>;
|
|
67
|
+
fontSizeClass: vue.ComputedRef<string>;
|
|
68
|
+
fontFamily: vue.Ref<FontFamily, FontFamily>;
|
|
69
|
+
fontFamilyClass: vue.ComputedRef<string>;
|
|
118
70
|
colors: ThemeColor[];
|
|
119
71
|
fontSizePresets: FontSizePreset[];
|
|
120
72
|
fontFamilyPresets: FontFamilyPreset[];
|
|
@@ -126,34 +78,9 @@ declare function useTheme(): {
|
|
|
126
78
|
applyTheme: typeof applyTheme;
|
|
127
79
|
getTheme: typeof getTheme;
|
|
128
80
|
initTheme: typeof initTheme;
|
|
129
|
-
store: pinia.Store<"theme", {
|
|
130
|
-
mode: string;
|
|
131
|
-
color: string;
|
|
132
|
-
fontSize: string;
|
|
133
|
-
fontFamily: string;
|
|
134
|
-
}, {}, {}>;
|
|
81
|
+
store: pinia.Store<"theme", ThemeState, {}, {}>;
|
|
135
82
|
};
|
|
136
83
|
|
|
137
|
-
/**
|
|
138
|
-
* 分享卡片配置项
|
|
139
|
-
*/
|
|
140
|
-
interface ShareConfig {
|
|
141
|
-
/** 分享标题 */
|
|
142
|
-
title?: string;
|
|
143
|
-
/** 分享页面路径 */
|
|
144
|
-
path?: string;
|
|
145
|
-
/** 分享卡片封面图 */
|
|
146
|
-
imageUrl?: string;
|
|
147
|
-
}
|
|
148
|
-
/**
|
|
149
|
-
* 显式调起分享菜单
|
|
150
|
-
*/
|
|
151
|
-
declare function showShareMenu(): void;
|
|
152
|
-
/**
|
|
153
|
-
* 分享组合式函数
|
|
154
|
-
*/
|
|
155
|
-
declare function useShare(config?: ShareConfig): void;
|
|
156
|
-
|
|
157
84
|
/**
|
|
158
85
|
* useRefs - 模板 Ref 批量管理
|
|
159
86
|
*
|
|
@@ -186,4 +113,4 @@ interface UseRefsReturn<T = unknown> {
|
|
|
186
113
|
*/
|
|
187
114
|
declare function useRefs<T = unknown>(): UseRefsReturn<T>;
|
|
188
115
|
|
|
189
|
-
export { DEFAULT_THEME, type FontFamily, type FontFamilyPreset, type FontSize, type FontSizePreset, type InitThemeOptions,
|
|
116
|
+
export { DEFAULT_THEME, type FontFamily, type FontFamilyPreset, type FontSize, type FontSizePreset, type InitThemeOptions, THEME_COLORS, type ThemeColor, type ThemeMode, type ThemeState, type UseRefsReturn, applyTheme, fontFamilyPresets, fontSizePresets, getTheme, initTheme, useRefs, useTheme, useThemeStore };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import * as vue from 'vue';
|
|
2
|
+
import { App, Ref } from 'vue';
|
|
1
3
|
import * as pinia from 'pinia';
|
|
2
|
-
import { App, Ref, ComputedRef } from 'vue';
|
|
3
4
|
|
|
4
5
|
declare module "pinia" {
|
|
5
6
|
interface DefineStoreOptionsBase<S, Store> {
|
|
@@ -7,114 +8,65 @@ declare module "pinia" {
|
|
|
7
8
|
unistorage?: boolean | object;
|
|
8
9
|
}
|
|
9
10
|
}
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* 外观模式型
|
|
13
|
-
*/
|
|
11
|
+
/** 外观模式 */
|
|
14
12
|
type ThemeMode = "light" | "dark" | "system";
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* 字体大小型
|
|
18
|
-
*/
|
|
13
|
+
/** 字体大小 */
|
|
19
14
|
type FontSize = "small" | "standard" | "large" | "extra-large";
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* 字体样式型
|
|
23
|
-
*/
|
|
15
|
+
/** 字体样式 */
|
|
24
16
|
type FontFamily = "system" | "sans" | "serif" | "kaiti";
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* 主题色彩项
|
|
28
|
-
*/
|
|
17
|
+
/** 主题色彩项 */
|
|
29
18
|
interface ThemeColor {
|
|
30
19
|
name: string;
|
|
31
20
|
value: string;
|
|
32
21
|
}
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* 主题状态表
|
|
36
|
-
*/
|
|
22
|
+
/** 主题状态表 */
|
|
37
23
|
interface ThemeState {
|
|
38
24
|
mode: ThemeMode;
|
|
39
25
|
color: string;
|
|
40
26
|
fontSize: FontSize;
|
|
41
27
|
fontFamily: FontFamily;
|
|
42
28
|
}
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* 初始配置项
|
|
46
|
-
*/
|
|
29
|
+
/** 初始配置项 */
|
|
47
30
|
interface InitThemeOptions {
|
|
48
31
|
sync?: boolean;
|
|
49
32
|
defaultTheme?: Partial<ThemeState>;
|
|
50
33
|
}
|
|
51
|
-
|
|
52
|
-
/**
|
|
53
|
-
* 字体大小项
|
|
54
|
-
*/
|
|
34
|
+
/** 字体大小预设项 */
|
|
55
35
|
interface FontSizePreset {
|
|
56
36
|
id: string;
|
|
57
37
|
name: string;
|
|
58
38
|
class: string;
|
|
59
39
|
}
|
|
60
|
-
|
|
61
|
-
/**
|
|
62
|
-
* 字体样式项
|
|
63
|
-
*/
|
|
40
|
+
/** 字体样式预设项 */
|
|
64
41
|
interface FontFamilyPreset {
|
|
65
42
|
id: string;
|
|
66
43
|
name: string;
|
|
67
44
|
class: string;
|
|
68
45
|
}
|
|
69
|
-
|
|
70
|
-
/**
|
|
71
|
-
* 字体大小表
|
|
72
|
-
*/
|
|
73
|
-
declare const fontSizePresets: FontSizePreset[];
|
|
74
|
-
/**
|
|
75
|
-
* 字体样式表
|
|
76
|
-
*/
|
|
77
|
-
declare const fontFamilyPresets: FontFamilyPreset[];
|
|
78
|
-
/**
|
|
79
|
-
* 主题状态库
|
|
80
|
-
*/
|
|
81
|
-
declare const useThemeStore: pinia.StoreDefinition<"theme", {
|
|
82
|
-
mode: string;
|
|
83
|
-
color: string;
|
|
84
|
-
fontSize: string;
|
|
85
|
-
fontFamily: string;
|
|
86
|
-
}, {}, {}>;
|
|
87
|
-
|
|
88
|
-
/**
|
|
89
|
-
* 默认主题配置
|
|
90
|
-
*/
|
|
46
|
+
/** 默认主题配置 */
|
|
91
47
|
declare const DEFAULT_THEME: ThemeState;
|
|
92
|
-
/**
|
|
93
|
-
* 预设色彩库
|
|
94
|
-
*/
|
|
48
|
+
/** 预设色彩库 */
|
|
95
49
|
declare const THEME_COLORS: ThemeColor[];
|
|
96
|
-
/**
|
|
97
|
-
|
|
98
|
-
*/
|
|
50
|
+
/** 字体大小预设表 */
|
|
51
|
+
declare const fontSizePresets: FontSizePreset[];
|
|
52
|
+
/** 字体样式预设表 */
|
|
53
|
+
declare const fontFamilyPresets: FontFamilyPreset[];
|
|
54
|
+
/** 主题状态 Store */
|
|
55
|
+
declare const useThemeStore: pinia.StoreDefinition<"theme", ThemeState, {}, {}>;
|
|
56
|
+
/** 获取存储配置 */
|
|
99
57
|
declare function getTheme(): ThemeState;
|
|
100
|
-
/**
|
|
101
|
-
* 应用主题状态
|
|
102
|
-
*/
|
|
58
|
+
/** 应用主题状态 */
|
|
103
59
|
declare function applyTheme(themeState: Partial<ThemeState>): void;
|
|
104
|
-
/**
|
|
105
|
-
* 注册主题器
|
|
106
|
-
*/
|
|
60
|
+
/** 初始化主题系统 */
|
|
107
61
|
declare function initTheme(app: App, options?: InitThemeOptions): void;
|
|
108
|
-
/**
|
|
109
|
-
* 主题组合钩子
|
|
110
|
-
*/
|
|
62
|
+
/** 主题组合式函数 */
|
|
111
63
|
declare function useTheme(): {
|
|
112
|
-
mode: Ref<ThemeMode, ThemeMode>;
|
|
113
|
-
color: Ref<string, string>;
|
|
114
|
-
fontSize: Ref<
|
|
115
|
-
fontSizeClass: ComputedRef<string>;
|
|
116
|
-
fontFamily: Ref<
|
|
117
|
-
fontFamilyClass: ComputedRef<string>;
|
|
64
|
+
mode: vue.Ref<ThemeMode, ThemeMode>;
|
|
65
|
+
color: vue.Ref<string, string>;
|
|
66
|
+
fontSize: vue.Ref<FontSize, FontSize>;
|
|
67
|
+
fontSizeClass: vue.ComputedRef<string>;
|
|
68
|
+
fontFamily: vue.Ref<FontFamily, FontFamily>;
|
|
69
|
+
fontFamilyClass: vue.ComputedRef<string>;
|
|
118
70
|
colors: ThemeColor[];
|
|
119
71
|
fontSizePresets: FontSizePreset[];
|
|
120
72
|
fontFamilyPresets: FontFamilyPreset[];
|
|
@@ -126,34 +78,9 @@ declare function useTheme(): {
|
|
|
126
78
|
applyTheme: typeof applyTheme;
|
|
127
79
|
getTheme: typeof getTheme;
|
|
128
80
|
initTheme: typeof initTheme;
|
|
129
|
-
store: pinia.Store<"theme", {
|
|
130
|
-
mode: string;
|
|
131
|
-
color: string;
|
|
132
|
-
fontSize: string;
|
|
133
|
-
fontFamily: string;
|
|
134
|
-
}, {}, {}>;
|
|
81
|
+
store: pinia.Store<"theme", ThemeState, {}, {}>;
|
|
135
82
|
};
|
|
136
83
|
|
|
137
|
-
/**
|
|
138
|
-
* 分享卡片配置项
|
|
139
|
-
*/
|
|
140
|
-
interface ShareConfig {
|
|
141
|
-
/** 分享标题 */
|
|
142
|
-
title?: string;
|
|
143
|
-
/** 分享页面路径 */
|
|
144
|
-
path?: string;
|
|
145
|
-
/** 分享卡片封面图 */
|
|
146
|
-
imageUrl?: string;
|
|
147
|
-
}
|
|
148
|
-
/**
|
|
149
|
-
* 显式调起分享菜单
|
|
150
|
-
*/
|
|
151
|
-
declare function showShareMenu(): void;
|
|
152
|
-
/**
|
|
153
|
-
* 分享组合式函数
|
|
154
|
-
*/
|
|
155
|
-
declare function useShare(config?: ShareConfig): void;
|
|
156
|
-
|
|
157
84
|
/**
|
|
158
85
|
* useRefs - 模板 Ref 批量管理
|
|
159
86
|
*
|
|
@@ -186,4 +113,4 @@ interface UseRefsReturn<T = unknown> {
|
|
|
186
113
|
*/
|
|
187
114
|
declare function useRefs<T = unknown>(): UseRefsReturn<T>;
|
|
188
115
|
|
|
189
|
-
export { DEFAULT_THEME, type FontFamily, type FontFamilyPreset, type FontSize, type FontSizePreset, type InitThemeOptions,
|
|
116
|
+
export { DEFAULT_THEME, type FontFamily, type FontFamilyPreset, type FontSize, type FontSizePreset, type InitThemeOptions, THEME_COLORS, type ThemeColor, type ThemeMode, type ThemeState, type UseRefsReturn, applyTheme, fontFamilyPresets, fontSizePresets, getTheme, initTheme, useRefs, useTheme, useThemeStore };
|
package/dist/index.js
CHANGED
|
@@ -27,9 +27,7 @@ __export(index_exports, {
|
|
|
27
27
|
fontSizePresets: () => fontSizePresets,
|
|
28
28
|
getTheme: () => getTheme,
|
|
29
29
|
initTheme: () => initTheme,
|
|
30
|
-
showShareMenu: () => showShareMenu,
|
|
31
30
|
useRefs: () => useRefs,
|
|
32
|
-
useShare: () => useShare,
|
|
33
31
|
useTheme: () => useTheme,
|
|
34
32
|
useThemeStore: () => useThemeStore
|
|
35
33
|
});
|
|
@@ -37,69 +35,7 @@ module.exports = __toCommonJS(index_exports);
|
|
|
37
35
|
|
|
38
36
|
// src/theme/index.ts
|
|
39
37
|
var import_vue = require("vue");
|
|
40
|
-
|
|
41
|
-
// src/theme/store.ts
|
|
42
|
-
var import_pinia2 = require("pinia");
|
|
43
|
-
|
|
44
|
-
// src/theme/types.d.ts
|
|
45
38
|
var import_pinia = require("pinia");
|
|
46
|
-
|
|
47
|
-
// src/theme/store.ts
|
|
48
|
-
var fontSizePresets = [
|
|
49
|
-
{
|
|
50
|
-
id: "small",
|
|
51
|
-
name: "\u8F83\u5C0F",
|
|
52
|
-
class: "font-size-small"
|
|
53
|
-
},
|
|
54
|
-
{
|
|
55
|
-
id: "standard",
|
|
56
|
-
name: "\u6807\u51C6",
|
|
57
|
-
class: "font-size-standard"
|
|
58
|
-
},
|
|
59
|
-
{
|
|
60
|
-
id: "large",
|
|
61
|
-
name: "\u8F83\u5927",
|
|
62
|
-
class: "font-size-large"
|
|
63
|
-
},
|
|
64
|
-
{
|
|
65
|
-
id: "extra-large",
|
|
66
|
-
name: "\u8D85\u5927",
|
|
67
|
-
class: "font-size-extra-large"
|
|
68
|
-
}
|
|
69
|
-
];
|
|
70
|
-
var fontFamilyPresets = [
|
|
71
|
-
{
|
|
72
|
-
id: "system",
|
|
73
|
-
name: "\u7CFB\u7EDF\u9ED8\u8BA4",
|
|
74
|
-
class: "font-family-system"
|
|
75
|
-
},
|
|
76
|
-
{
|
|
77
|
-
id: "sans",
|
|
78
|
-
name: "\u73B0\u4EE3\u9ED1\u4F53",
|
|
79
|
-
class: "font-family-sans"
|
|
80
|
-
},
|
|
81
|
-
{
|
|
82
|
-
id: "serif",
|
|
83
|
-
name: "\u7ECF\u5178\u5B8B\u4F53",
|
|
84
|
-
class: "font-family-serif"
|
|
85
|
-
},
|
|
86
|
-
{
|
|
87
|
-
id: "kaiti",
|
|
88
|
-
name: "\u4F18\u96C5\u6977\u4F53",
|
|
89
|
-
class: "font-family-kaiti"
|
|
90
|
-
}
|
|
91
|
-
];
|
|
92
|
-
var useThemeStore = (0, import_pinia2.defineStore)("theme", {
|
|
93
|
-
state: () => ({
|
|
94
|
-
mode: "light",
|
|
95
|
-
color: "#08c060",
|
|
96
|
-
fontSize: "standard",
|
|
97
|
-
fontFamily: "system"
|
|
98
|
-
}),
|
|
99
|
-
unistorage: true
|
|
100
|
-
});
|
|
101
|
-
|
|
102
|
-
// src/theme/index.ts
|
|
103
39
|
var DEFAULT_THEME = {
|
|
104
40
|
mode: "light",
|
|
105
41
|
color: "#08c060",
|
|
@@ -117,6 +53,27 @@ var THEME_COLORS = [
|
|
|
117
53
|
{ name: "\u7ECF\u5178\u9ED1", value: "#334155" },
|
|
118
54
|
{ name: "\u8537\u8587\u7C89", value: "#ec4899" }
|
|
119
55
|
];
|
|
56
|
+
var fontSizePresets = [
|
|
57
|
+
{ id: "small", name: "\u8F83\u5C0F", class: "font-size-small" },
|
|
58
|
+
{ id: "standard", name: "\u6807\u51C6", class: "font-size-standard" },
|
|
59
|
+
{ id: "large", name: "\u8F83\u5927", class: "font-size-large" },
|
|
60
|
+
{ id: "extra-large", name: "\u8D85\u5927", class: "font-size-extra-large" }
|
|
61
|
+
];
|
|
62
|
+
var fontFamilyPresets = [
|
|
63
|
+
{ id: "system", name: "\u7CFB\u7EDF\u9ED8\u8BA4", class: "font-family-system" },
|
|
64
|
+
{ id: "sans", name: "\u73B0\u4EE3\u9ED1\u4F53", class: "font-family-sans" },
|
|
65
|
+
{ id: "serif", name: "\u7ECF\u5178\u5B8B\u4F53", class: "font-family-serif" },
|
|
66
|
+
{ id: "kaiti", name: "\u4F18\u96C5\u6977\u4F53", class: "font-family-kaiti" }
|
|
67
|
+
];
|
|
68
|
+
var useThemeStore = (0, import_pinia.defineStore)("theme", {
|
|
69
|
+
state: () => ({
|
|
70
|
+
mode: "light",
|
|
71
|
+
color: "#08c060",
|
|
72
|
+
fontSize: "standard",
|
|
73
|
+
fontFamily: "system"
|
|
74
|
+
}),
|
|
75
|
+
unistorage: true
|
|
76
|
+
});
|
|
120
77
|
function getTheme() {
|
|
121
78
|
const store = useThemeStore();
|
|
122
79
|
return {
|
|
@@ -147,38 +104,13 @@ function initTheme(app, options = {}) {
|
|
|
147
104
|
}
|
|
148
105
|
function useTheme() {
|
|
149
106
|
const store = useThemeStore();
|
|
150
|
-
const mode = (0,
|
|
151
|
-
const color = (0, import_vue.toRef)(store, "color");
|
|
152
|
-
const fontSize = (0, import_vue.toRef)(store, "fontSize");
|
|
153
|
-
const fontFamily = (0, import_vue.toRef)(store, "fontFamily");
|
|
107
|
+
const { mode, color, fontSize, fontFamily } = (0, import_pinia.storeToRefs)(store);
|
|
154
108
|
const fontSizeClass = (0, import_vue.computed)(() => {
|
|
155
109
|
return fontSizePresets.find((item) => item.id === store.fontSize)?.class || "font-size-standard";
|
|
156
110
|
});
|
|
157
111
|
const fontFamilyClass = (0, import_vue.computed)(() => {
|
|
158
112
|
return fontFamilyPresets.find((item) => item.id === store.fontFamily)?.class || "font-family-system";
|
|
159
113
|
});
|
|
160
|
-
function setMode(targetMode) {
|
|
161
|
-
store.mode = targetMode;
|
|
162
|
-
}
|
|
163
|
-
function setColor(hexColor) {
|
|
164
|
-
store.color = hexColor;
|
|
165
|
-
}
|
|
166
|
-
function setFontSize(targetSize) {
|
|
167
|
-
if (["small", "standard", "large", "extra-large"].includes(targetSize)) {
|
|
168
|
-
store.fontSize = targetSize;
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
function setFontFamily(targetFont) {
|
|
172
|
-
if (["system", "sans", "serif", "kaiti"].includes(targetFont)) {
|
|
173
|
-
store.fontFamily = targetFont;
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
function resetTheme() {
|
|
177
|
-
store.mode = DEFAULT_THEME.mode;
|
|
178
|
-
store.color = DEFAULT_THEME.color;
|
|
179
|
-
store.fontSize = DEFAULT_THEME.fontSize;
|
|
180
|
-
store.fontFamily = DEFAULT_THEME.fontFamily;
|
|
181
|
-
}
|
|
182
114
|
return {
|
|
183
115
|
mode,
|
|
184
116
|
color,
|
|
@@ -189,11 +121,25 @@ function useTheme() {
|
|
|
189
121
|
colors: THEME_COLORS,
|
|
190
122
|
fontSizePresets,
|
|
191
123
|
fontFamilyPresets,
|
|
192
|
-
setMode
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
124
|
+
setMode: (targetMode) => {
|
|
125
|
+
store.mode = targetMode;
|
|
126
|
+
},
|
|
127
|
+
setColor: (hexColor) => {
|
|
128
|
+
store.color = hexColor;
|
|
129
|
+
},
|
|
130
|
+
setFontSize: (targetSize) => {
|
|
131
|
+
if (["small", "standard", "large", "extra-large"].includes(targetSize)) {
|
|
132
|
+
store.fontSize = targetSize;
|
|
133
|
+
}
|
|
134
|
+
},
|
|
135
|
+
setFontFamily: (targetFont) => {
|
|
136
|
+
if (["system", "sans", "serif", "kaiti"].includes(targetFont)) {
|
|
137
|
+
store.fontFamily = targetFont;
|
|
138
|
+
}
|
|
139
|
+
},
|
|
140
|
+
resetTheme: () => {
|
|
141
|
+
Object.assign(store, DEFAULT_THEME);
|
|
142
|
+
},
|
|
197
143
|
applyTheme,
|
|
198
144
|
getTheme,
|
|
199
145
|
initTheme,
|
|
@@ -201,24 +147,6 @@ function useTheme() {
|
|
|
201
147
|
};
|
|
202
148
|
}
|
|
203
149
|
|
|
204
|
-
// src/share/index.ts
|
|
205
|
-
var import_uni_app = require("@dcloudio/uni-app");
|
|
206
|
-
function showShareMenu() {
|
|
207
|
-
uni.showShareMenu({
|
|
208
|
-
withShareTicket: true,
|
|
209
|
-
menus: ["shareAppMessage", "shareTimeline"]
|
|
210
|
-
});
|
|
211
|
-
}
|
|
212
|
-
function useShare(config = {}) {
|
|
213
|
-
showShareMenu();
|
|
214
|
-
(0, import_uni_app.onShareAppMessage)(() => ({ ...config }));
|
|
215
|
-
(0, import_uni_app.onShareTimeline)(() => ({
|
|
216
|
-
title: config.title,
|
|
217
|
-
query: config.path?.split("?")[1],
|
|
218
|
-
imageUrl: config.imageUrl
|
|
219
|
-
}));
|
|
220
|
-
}
|
|
221
|
-
|
|
222
150
|
// src/refs/index.ts
|
|
223
151
|
var import_vue2 = require("vue");
|
|
224
152
|
function useRefs() {
|
|
@@ -243,9 +171,7 @@ function useRefs() {
|
|
|
243
171
|
fontSizePresets,
|
|
244
172
|
getTheme,
|
|
245
173
|
initTheme,
|
|
246
|
-
showShareMenu,
|
|
247
174
|
useRefs,
|
|
248
|
-
useShare,
|
|
249
175
|
useTheme,
|
|
250
176
|
useThemeStore
|
|
251
177
|
});
|
package/dist/index.mjs
CHANGED
|
@@ -1,68 +1,6 @@
|
|
|
1
1
|
// src/theme/index.ts
|
|
2
|
-
import { computed
|
|
3
|
-
|
|
4
|
-
// src/theme/store.ts
|
|
5
|
-
import { defineStore } from "pinia";
|
|
6
|
-
|
|
7
|
-
// src/theme/types.d.ts
|
|
8
|
-
import "pinia";
|
|
9
|
-
|
|
10
|
-
// src/theme/store.ts
|
|
11
|
-
var fontSizePresets = [
|
|
12
|
-
{
|
|
13
|
-
id: "small",
|
|
14
|
-
name: "\u8F83\u5C0F",
|
|
15
|
-
class: "font-size-small"
|
|
16
|
-
},
|
|
17
|
-
{
|
|
18
|
-
id: "standard",
|
|
19
|
-
name: "\u6807\u51C6",
|
|
20
|
-
class: "font-size-standard"
|
|
21
|
-
},
|
|
22
|
-
{
|
|
23
|
-
id: "large",
|
|
24
|
-
name: "\u8F83\u5927",
|
|
25
|
-
class: "font-size-large"
|
|
26
|
-
},
|
|
27
|
-
{
|
|
28
|
-
id: "extra-large",
|
|
29
|
-
name: "\u8D85\u5927",
|
|
30
|
-
class: "font-size-extra-large"
|
|
31
|
-
}
|
|
32
|
-
];
|
|
33
|
-
var fontFamilyPresets = [
|
|
34
|
-
{
|
|
35
|
-
id: "system",
|
|
36
|
-
name: "\u7CFB\u7EDF\u9ED8\u8BA4",
|
|
37
|
-
class: "font-family-system"
|
|
38
|
-
},
|
|
39
|
-
{
|
|
40
|
-
id: "sans",
|
|
41
|
-
name: "\u73B0\u4EE3\u9ED1\u4F53",
|
|
42
|
-
class: "font-family-sans"
|
|
43
|
-
},
|
|
44
|
-
{
|
|
45
|
-
id: "serif",
|
|
46
|
-
name: "\u7ECF\u5178\u5B8B\u4F53",
|
|
47
|
-
class: "font-family-serif"
|
|
48
|
-
},
|
|
49
|
-
{
|
|
50
|
-
id: "kaiti",
|
|
51
|
-
name: "\u4F18\u96C5\u6977\u4F53",
|
|
52
|
-
class: "font-family-kaiti"
|
|
53
|
-
}
|
|
54
|
-
];
|
|
55
|
-
var useThemeStore = defineStore("theme", {
|
|
56
|
-
state: () => ({
|
|
57
|
-
mode: "light",
|
|
58
|
-
color: "#08c060",
|
|
59
|
-
fontSize: "standard",
|
|
60
|
-
fontFamily: "system"
|
|
61
|
-
}),
|
|
62
|
-
unistorage: true
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
// src/theme/index.ts
|
|
2
|
+
import { computed } from "vue";
|
|
3
|
+
import { defineStore, storeToRefs } from "pinia";
|
|
66
4
|
var DEFAULT_THEME = {
|
|
67
5
|
mode: "light",
|
|
68
6
|
color: "#08c060",
|
|
@@ -80,6 +18,27 @@ var THEME_COLORS = [
|
|
|
80
18
|
{ name: "\u7ECF\u5178\u9ED1", value: "#334155" },
|
|
81
19
|
{ name: "\u8537\u8587\u7C89", value: "#ec4899" }
|
|
82
20
|
];
|
|
21
|
+
var fontSizePresets = [
|
|
22
|
+
{ id: "small", name: "\u8F83\u5C0F", class: "font-size-small" },
|
|
23
|
+
{ id: "standard", name: "\u6807\u51C6", class: "font-size-standard" },
|
|
24
|
+
{ id: "large", name: "\u8F83\u5927", class: "font-size-large" },
|
|
25
|
+
{ id: "extra-large", name: "\u8D85\u5927", class: "font-size-extra-large" }
|
|
26
|
+
];
|
|
27
|
+
var fontFamilyPresets = [
|
|
28
|
+
{ id: "system", name: "\u7CFB\u7EDF\u9ED8\u8BA4", class: "font-family-system" },
|
|
29
|
+
{ id: "sans", name: "\u73B0\u4EE3\u9ED1\u4F53", class: "font-family-sans" },
|
|
30
|
+
{ id: "serif", name: "\u7ECF\u5178\u5B8B\u4F53", class: "font-family-serif" },
|
|
31
|
+
{ id: "kaiti", name: "\u4F18\u96C5\u6977\u4F53", class: "font-family-kaiti" }
|
|
32
|
+
];
|
|
33
|
+
var useThemeStore = defineStore("theme", {
|
|
34
|
+
state: () => ({
|
|
35
|
+
mode: "light",
|
|
36
|
+
color: "#08c060",
|
|
37
|
+
fontSize: "standard",
|
|
38
|
+
fontFamily: "system"
|
|
39
|
+
}),
|
|
40
|
+
unistorage: true
|
|
41
|
+
});
|
|
83
42
|
function getTheme() {
|
|
84
43
|
const store = useThemeStore();
|
|
85
44
|
return {
|
|
@@ -110,38 +69,13 @@ function initTheme(app, options = {}) {
|
|
|
110
69
|
}
|
|
111
70
|
function useTheme() {
|
|
112
71
|
const store = useThemeStore();
|
|
113
|
-
const mode =
|
|
114
|
-
const color = toRef(store, "color");
|
|
115
|
-
const fontSize = toRef(store, "fontSize");
|
|
116
|
-
const fontFamily = toRef(store, "fontFamily");
|
|
72
|
+
const { mode, color, fontSize, fontFamily } = storeToRefs(store);
|
|
117
73
|
const fontSizeClass = computed(() => {
|
|
118
74
|
return fontSizePresets.find((item) => item.id === store.fontSize)?.class || "font-size-standard";
|
|
119
75
|
});
|
|
120
76
|
const fontFamilyClass = computed(() => {
|
|
121
77
|
return fontFamilyPresets.find((item) => item.id === store.fontFamily)?.class || "font-family-system";
|
|
122
78
|
});
|
|
123
|
-
function setMode(targetMode) {
|
|
124
|
-
store.mode = targetMode;
|
|
125
|
-
}
|
|
126
|
-
function setColor(hexColor) {
|
|
127
|
-
store.color = hexColor;
|
|
128
|
-
}
|
|
129
|
-
function setFontSize(targetSize) {
|
|
130
|
-
if (["small", "standard", "large", "extra-large"].includes(targetSize)) {
|
|
131
|
-
store.fontSize = targetSize;
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
function setFontFamily(targetFont) {
|
|
135
|
-
if (["system", "sans", "serif", "kaiti"].includes(targetFont)) {
|
|
136
|
-
store.fontFamily = targetFont;
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
function resetTheme() {
|
|
140
|
-
store.mode = DEFAULT_THEME.mode;
|
|
141
|
-
store.color = DEFAULT_THEME.color;
|
|
142
|
-
store.fontSize = DEFAULT_THEME.fontSize;
|
|
143
|
-
store.fontFamily = DEFAULT_THEME.fontFamily;
|
|
144
|
-
}
|
|
145
79
|
return {
|
|
146
80
|
mode,
|
|
147
81
|
color,
|
|
@@ -152,11 +86,25 @@ function useTheme() {
|
|
|
152
86
|
colors: THEME_COLORS,
|
|
153
87
|
fontSizePresets,
|
|
154
88
|
fontFamilyPresets,
|
|
155
|
-
setMode
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
89
|
+
setMode: (targetMode) => {
|
|
90
|
+
store.mode = targetMode;
|
|
91
|
+
},
|
|
92
|
+
setColor: (hexColor) => {
|
|
93
|
+
store.color = hexColor;
|
|
94
|
+
},
|
|
95
|
+
setFontSize: (targetSize) => {
|
|
96
|
+
if (["small", "standard", "large", "extra-large"].includes(targetSize)) {
|
|
97
|
+
store.fontSize = targetSize;
|
|
98
|
+
}
|
|
99
|
+
},
|
|
100
|
+
setFontFamily: (targetFont) => {
|
|
101
|
+
if (["system", "sans", "serif", "kaiti"].includes(targetFont)) {
|
|
102
|
+
store.fontFamily = targetFont;
|
|
103
|
+
}
|
|
104
|
+
},
|
|
105
|
+
resetTheme: () => {
|
|
106
|
+
Object.assign(store, DEFAULT_THEME);
|
|
107
|
+
},
|
|
160
108
|
applyTheme,
|
|
161
109
|
getTheme,
|
|
162
110
|
initTheme,
|
|
@@ -164,24 +112,6 @@ function useTheme() {
|
|
|
164
112
|
};
|
|
165
113
|
}
|
|
166
114
|
|
|
167
|
-
// src/share/index.ts
|
|
168
|
-
import { onShareAppMessage, onShareTimeline } from "@dcloudio/uni-app";
|
|
169
|
-
function showShareMenu() {
|
|
170
|
-
uni.showShareMenu({
|
|
171
|
-
withShareTicket: true,
|
|
172
|
-
menus: ["shareAppMessage", "shareTimeline"]
|
|
173
|
-
});
|
|
174
|
-
}
|
|
175
|
-
function useShare(config = {}) {
|
|
176
|
-
showShareMenu();
|
|
177
|
-
onShareAppMessage(() => ({ ...config }));
|
|
178
|
-
onShareTimeline(() => ({
|
|
179
|
-
title: config.title,
|
|
180
|
-
query: config.path?.split("?")[1],
|
|
181
|
-
imageUrl: config.imageUrl
|
|
182
|
-
}));
|
|
183
|
-
}
|
|
184
|
-
|
|
185
115
|
// src/refs/index.ts
|
|
186
116
|
import { ref, onBeforeUpdate, onUnmounted } from "vue";
|
|
187
117
|
function useRefs() {
|
|
@@ -205,9 +135,7 @@ export {
|
|
|
205
135
|
fontSizePresets,
|
|
206
136
|
getTheme,
|
|
207
137
|
initTheme,
|
|
208
|
-
showShareMenu,
|
|
209
138
|
useRefs,
|
|
210
|
-
useShare,
|
|
211
139
|
useTheme,
|
|
212
140
|
useThemeStore
|
|
213
141
|
};
|