enr 2.0.5 → 2.0.7
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/components/ThemeContext/index.cjs.js +12 -14
- package/components/ThemeContext/index.es.js +1 -3
- package/customHooks/useRipples/class-event-action.cjs.js +1 -1
- package/customHooks/useRipples/class-event-action.d.ts +1 -1
- package/customHooks/useRipples/class-event-action.es.js +1 -1
- package/customHooks/useRipples/class-render-action.cjs.js +31 -26
- package/customHooks/useRipples/class-render-action.d.ts +3 -1
- package/customHooks/useRipples/class-render-action.es.js +31 -26
- package/customHooks/useRipples/class-render-data.cjs.js +49 -2
- package/customHooks/useRipples/class-render-data.d.ts +23 -2
- package/customHooks/useRipples/class-render-data.es.js +49 -2
- package/customHooks/useRipples/class-ripple.cjs.js +2 -2
- package/customHooks/useRipples/class-ripple.d.ts +1 -1
- package/customHooks/useRipples/class-ripple.es.js +2 -2
- package/customHooks/useRipples/types.d.ts +1 -1
- package/package.json +5 -5
- package/shared/dist/es/index.cjs.js +288 -0
- package/shared/dist/es/index.es.js +275 -0
- package/shared/dist/es/log-production.cjs.js +49 -2
- package/shared/dist/es/log-production.es.js +48 -1
- package/shared/dist/es/cookie.cjs.js +0 -80
- package/shared/dist/es/cookie.es.js +0 -78
- package/shared/dist/es/node_modules/.pnpm/@qqi_log@1.1.4/node_modules/@qqi/log/es/virtual-dog.cjs.js +0 -52
- package/shared/dist/es/node_modules/.pnpm/@qqi_log@1.1.4/node_modules/@qqi/log/es/virtual-dog.es.js +0 -50
- package/shared/dist/es/storage-store.cjs.js +0 -32
- package/shared/dist/es/storage-store.es.js +0 -30
- package/shared/dist/es/storage.cjs.js +0 -102
- package/shared/dist/es/storage.es.js +0 -92
- package/shared/dist/es/sys.cjs.js +0 -84
- package/shared/dist/es/sys.es.js +0 -82
|
@@ -0,0 +1,288 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var aTypeOfJs = require('a-type-of-js');
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* @module @zza/cookie
|
|
7
|
+
* @file cookie.ts
|
|
8
|
+
* @description cookie 管理
|
|
9
|
+
* @author Mr.MudBean <Mr.MudBean@outlook.com>
|
|
10
|
+
* @copyright 2026 ©️ Mr.MudBean
|
|
11
|
+
* @since 01/10/2025
|
|
12
|
+
* @version 0.0.0
|
|
13
|
+
* @lastModified 2026-03-25 16:10
|
|
14
|
+
*/
|
|
15
|
+
const manageCookie = {
|
|
16
|
+
getItem(keyItem) {
|
|
17
|
+
return (decodeURIComponent(document.cookie.replace(new RegExp('(?:(?:^|.*;)\\s*' +
|
|
18
|
+
encodeURIComponent(keyItem).replace(/[-.+*]/g, '\\$&') +
|
|
19
|
+
'\\s*\\=\\s*([^;]*).*$)|^.*$'), '$1')) || null);
|
|
20
|
+
},
|
|
21
|
+
setItem(option) {
|
|
22
|
+
const { keyItem, value, end, path, domain, secure } = option;
|
|
23
|
+
if (!keyItem || /^(?:expires|max-age|path|domain|secure)$/i.test(keyItem)) {
|
|
24
|
+
return false;
|
|
25
|
+
}
|
|
26
|
+
let expires = '';
|
|
27
|
+
switch (aTypeOfJs.typeOf(end)) {
|
|
28
|
+
case 'undefined':
|
|
29
|
+
expires = '; expires=Fri, 31 Dec 9999 23:59:59 GMT';
|
|
30
|
+
break;
|
|
31
|
+
case 'number':
|
|
32
|
+
expires =
|
|
33
|
+
end === Infinity
|
|
34
|
+
? '; expires=Fri, 31 Dec 9999 23:59:59 GMT'
|
|
35
|
+
: '; max-age=' + end;
|
|
36
|
+
break;
|
|
37
|
+
case 'string':
|
|
38
|
+
expires = '; expires=' + end;
|
|
39
|
+
break;
|
|
40
|
+
case 'date':
|
|
41
|
+
expires = '; expires=' + end.toUTCString();
|
|
42
|
+
break;
|
|
43
|
+
}
|
|
44
|
+
document.cookie = encodeURIComponent(keyItem)
|
|
45
|
+
.concat('=')
|
|
46
|
+
.concat(encodeURIComponent(value))
|
|
47
|
+
.concat(expires)
|
|
48
|
+
.concat(domain ? '; domain='.concat(domain) : '')
|
|
49
|
+
.concat(path ? '; path='.concat(path) : '')
|
|
50
|
+
.concat(secure ? '; secure' : '');
|
|
51
|
+
return true;
|
|
52
|
+
},
|
|
53
|
+
deleteItem(key, path, domain) {
|
|
54
|
+
if (!key || !this.exist(key))
|
|
55
|
+
return false;
|
|
56
|
+
document.cookie = encodeURIComponent(key)
|
|
57
|
+
.concat('=; expires=Thu, 01 Jan 1970 00:00:00 GMT')
|
|
58
|
+
.concat(domain ? '; domain='.concat(domain) : '')
|
|
59
|
+
.concat(path ? '; path='.concat(path) : '');
|
|
60
|
+
return true;
|
|
61
|
+
},
|
|
62
|
+
/** 校验当前 key 是否存在 */
|
|
63
|
+
exist(key) {
|
|
64
|
+
const result = new RegExp('(?:^|;\\s*)' +
|
|
65
|
+
encodeURIComponent(key).replace(/[-.+*]/g, '\\$&') +
|
|
66
|
+
'\\s*\\=').test(document.cookie);
|
|
67
|
+
return result;
|
|
68
|
+
},
|
|
69
|
+
keys() {
|
|
70
|
+
const keyList = document.cookie
|
|
71
|
+
.replace(/((?:^|\s*;)[^=]+)(?=;|$)|^\s*|\s*(?:=[^;]*)?(?:1|$)/g, '')
|
|
72
|
+
.split(/\s*(?:=[^;]*)?;\s*/);
|
|
73
|
+
for (let i = 0; i < keyList.length; i++) {
|
|
74
|
+
keyList[i] = decodeURIComponent(keyList[i]);
|
|
75
|
+
}
|
|
76
|
+
return keyList;
|
|
77
|
+
},
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* @packageDocumentation
|
|
82
|
+
* @module @zza/storage
|
|
83
|
+
* @file storage.ts
|
|
84
|
+
* @description 本地存储
|
|
85
|
+
* @author MrMudBean <Mr.MudBean@outlook.com>
|
|
86
|
+
* @license MIT
|
|
87
|
+
* @copyright 2026 ©️ MrMudBean
|
|
88
|
+
* @since 2026-01-20 12:25
|
|
89
|
+
* @version 0.0.0
|
|
90
|
+
* @lastModified 2026-01-20 12:40
|
|
91
|
+
*/
|
|
92
|
+
/**
|
|
93
|
+
*
|
|
94
|
+
* @param key
|
|
95
|
+
* @param value
|
|
96
|
+
*/
|
|
97
|
+
function set(key, value) {
|
|
98
|
+
localStorage.setItem(key, JSON.stringify(value));
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
*
|
|
102
|
+
* @param key
|
|
103
|
+
*/
|
|
104
|
+
function get(key) {
|
|
105
|
+
const value = localStorage.getItem(key);
|
|
106
|
+
try {
|
|
107
|
+
return (value != null && JSON.parse(value)) || '';
|
|
108
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
109
|
+
}
|
|
110
|
+
catch (error) {
|
|
111
|
+
return (value || '');
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
*
|
|
116
|
+
* @param key
|
|
117
|
+
*/
|
|
118
|
+
function getAndDel(key) {
|
|
119
|
+
const value = get(key);
|
|
120
|
+
del(key);
|
|
121
|
+
return value;
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
*
|
|
125
|
+
* @param key
|
|
126
|
+
*/
|
|
127
|
+
function del(key) {
|
|
128
|
+
return localStorage.removeItem(key);
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
*
|
|
132
|
+
*/
|
|
133
|
+
function clear() {
|
|
134
|
+
localStorage.clear();
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
*
|
|
138
|
+
* @param key
|
|
139
|
+
* @param value
|
|
140
|
+
*/
|
|
141
|
+
function setSession(key, value) {
|
|
142
|
+
sessionStorage.setItem(key, JSON.stringify(value));
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
*
|
|
146
|
+
* @param key
|
|
147
|
+
*/
|
|
148
|
+
function getSession(key) {
|
|
149
|
+
const value = sessionStorage.getItem(key);
|
|
150
|
+
return (value != null && JSON.parse(value)) || '';
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
*
|
|
154
|
+
* @param key
|
|
155
|
+
*/
|
|
156
|
+
function delSession(key) {
|
|
157
|
+
return sessionStorage.removeItem(key);
|
|
158
|
+
}
|
|
159
|
+
const storageMainLogic = {
|
|
160
|
+
del,
|
|
161
|
+
set,
|
|
162
|
+
get,
|
|
163
|
+
getAndDel,
|
|
164
|
+
clear,
|
|
165
|
+
setSession,
|
|
166
|
+
getSession,
|
|
167
|
+
delSession,
|
|
168
|
+
};
|
|
169
|
+
|
|
170
|
+
/**
|
|
171
|
+
* @packageDocumentation
|
|
172
|
+
* @module @zza/storage-store
|
|
173
|
+
* @file storage-store.ts
|
|
174
|
+
* @description 共用的 storage 数仓
|
|
175
|
+
* @author MrMudBean <Mr.MudBean@outlook.com>
|
|
176
|
+
* @license MIT
|
|
177
|
+
* @copyright 2026 ©️ MrMudBean
|
|
178
|
+
* @since 2026-01-20 12:41
|
|
179
|
+
* @version 0.0.0
|
|
180
|
+
* @lastModified 2026-01-20 12:41
|
|
181
|
+
*/
|
|
182
|
+
/** storage 的数据仓库 */
|
|
183
|
+
const storageStore = {
|
|
184
|
+
/** 获取本地的数据中的主题值 */
|
|
185
|
+
get theme() {
|
|
186
|
+
return storageMainLogic.get('theme');
|
|
187
|
+
},
|
|
188
|
+
/** 设置本地的数据的主题值 */
|
|
189
|
+
set theme(newTheme) {
|
|
190
|
+
if (['light', 'dark'].includes(newTheme))
|
|
191
|
+
storageMainLogic.set('theme', newTheme);
|
|
192
|
+
else if (aTypeOfJs.isBusinessEmptyString(newTheme))
|
|
193
|
+
storageMainLogic.del('theme');
|
|
194
|
+
}};
|
|
195
|
+
|
|
196
|
+
/**
|
|
197
|
+
*
|
|
198
|
+
*/
|
|
199
|
+
class SysInfo {
|
|
200
|
+
/**
|
|
201
|
+
*
|
|
202
|
+
*/
|
|
203
|
+
#getMedia(str) {
|
|
204
|
+
return (window?.matchMedia(/:/.test(str) && !/\(|\)/.test(str) ? `(${str})` : str)
|
|
205
|
+
.matches ?? false);
|
|
206
|
+
}
|
|
207
|
+
/**
|
|
208
|
+
* 设备振动
|
|
209
|
+
**/
|
|
210
|
+
vibrate() {
|
|
211
|
+
if (window?.navigator?.vibrate)
|
|
212
|
+
window.navigator.vibrate(200);
|
|
213
|
+
}
|
|
214
|
+
/**
|
|
215
|
+
* 分享网站
|
|
216
|
+
* @param [url='https://letmiseesee.pages.dev'] 网页地址 默认值 https://letmiseesee.pages.dev
|
|
217
|
+
* @param [text=''] text 文本
|
|
218
|
+
* @param [title='随笔记余生'] title 网站标题,缺省值
|
|
219
|
+
* @description
|
|
220
|
+
**/
|
|
221
|
+
share(url = 'https://letmiseesee.pages.dev', text = '', title = '慧土灵核') {
|
|
222
|
+
if (window?.navigator?.share)
|
|
223
|
+
window.navigator.share({ url, text, title });
|
|
224
|
+
}
|
|
225
|
+
/**
|
|
226
|
+
* 当前是否为手机设备
|
|
227
|
+
**/
|
|
228
|
+
isPhone() {
|
|
229
|
+
return (!this.#getMedia('any-hover: hover') &&
|
|
230
|
+
!this.#getMedia('any-pointer: fine') &&
|
|
231
|
+
window?.navigator?.maxTouchPoints > 0);
|
|
232
|
+
}
|
|
233
|
+
/**
|
|
234
|
+
* 当前设备是否为小平设备
|
|
235
|
+
**/
|
|
236
|
+
get isSmallScreen() {
|
|
237
|
+
return this.#getMedia('max-width: 576px')
|
|
238
|
+
? 'small'
|
|
239
|
+
: this.#getMedia('max-width: 996px')
|
|
240
|
+
? 'middle'
|
|
241
|
+
: 'large';
|
|
242
|
+
}
|
|
243
|
+
/**
|
|
244
|
+
* 是否为暗黑模式
|
|
245
|
+
**/
|
|
246
|
+
get isDark() {
|
|
247
|
+
return this.#getMedia('prefers-color-scheme: dark');
|
|
248
|
+
}
|
|
249
|
+
/**
|
|
250
|
+
* 设备当前的旋转状态
|
|
251
|
+
*
|
|
252
|
+
* 只返回是否旋转
|
|
253
|
+
**/
|
|
254
|
+
get isOrientation() {
|
|
255
|
+
const orientation = (screen.orientation || {}).type ||
|
|
256
|
+
/** @ts-expect-error: 兼容 moz 浏览器 */
|
|
257
|
+
screen.mozOrientation ||
|
|
258
|
+
/** @ts-expect-error: 兼容 ms 浏览器 */
|
|
259
|
+
screen.msOrientation;
|
|
260
|
+
/**
|
|
261
|
+
*
|
|
262
|
+
* - portrait-primary 旋转 360
|
|
263
|
+
* - portrait-secondary 旋转 180
|
|
264
|
+
* - landscape-primary 旋转 90
|
|
265
|
+
* - landscape-secondary 旋转 270
|
|
266
|
+
*
|
|
267
|
+
*
|
|
268
|
+
*/
|
|
269
|
+
if (orientation === 'landscape-primary' ||
|
|
270
|
+
orientation === 'landscape-secondary')
|
|
271
|
+
return false;
|
|
272
|
+
return true;
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
const sysInfo = new SysInfo();
|
|
276
|
+
|
|
277
|
+
exports.clearStorage = clear;
|
|
278
|
+
exports.delSessionStorage = delSession;
|
|
279
|
+
exports.delStorage = del;
|
|
280
|
+
exports.getSessionStorage = getSession;
|
|
281
|
+
exports.getStorage = get;
|
|
282
|
+
exports.getStorageAndDel = getAndDel;
|
|
283
|
+
exports.manageCookie = manageCookie;
|
|
284
|
+
exports.setSessionStorage = setSession;
|
|
285
|
+
exports.setStorage = set;
|
|
286
|
+
exports.storageMainLogic = storageMainLogic;
|
|
287
|
+
exports.storageStore = storageStore;
|
|
288
|
+
exports.sysInfo = sysInfo;
|
|
@@ -0,0 +1,275 @@
|
|
|
1
|
+
import { isBusinessEmptyString, typeOf } from 'a-type-of-js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @module @zza/cookie
|
|
5
|
+
* @file cookie.ts
|
|
6
|
+
* @description cookie 管理
|
|
7
|
+
* @author Mr.MudBean <Mr.MudBean@outlook.com>
|
|
8
|
+
* @copyright 2026 ©️ Mr.MudBean
|
|
9
|
+
* @since 01/10/2025
|
|
10
|
+
* @version 0.0.0
|
|
11
|
+
* @lastModified 2026-03-25 16:10
|
|
12
|
+
*/
|
|
13
|
+
const manageCookie = {
|
|
14
|
+
getItem(keyItem) {
|
|
15
|
+
return (decodeURIComponent(document.cookie.replace(new RegExp('(?:(?:^|.*;)\\s*' +
|
|
16
|
+
encodeURIComponent(keyItem).replace(/[-.+*]/g, '\\$&') +
|
|
17
|
+
'\\s*\\=\\s*([^;]*).*$)|^.*$'), '$1')) || null);
|
|
18
|
+
},
|
|
19
|
+
setItem(option) {
|
|
20
|
+
const { keyItem, value, end, path, domain, secure } = option;
|
|
21
|
+
if (!keyItem || /^(?:expires|max-age|path|domain|secure)$/i.test(keyItem)) {
|
|
22
|
+
return false;
|
|
23
|
+
}
|
|
24
|
+
let expires = '';
|
|
25
|
+
switch (typeOf(end)) {
|
|
26
|
+
case 'undefined':
|
|
27
|
+
expires = '; expires=Fri, 31 Dec 9999 23:59:59 GMT';
|
|
28
|
+
break;
|
|
29
|
+
case 'number':
|
|
30
|
+
expires =
|
|
31
|
+
end === Infinity
|
|
32
|
+
? '; expires=Fri, 31 Dec 9999 23:59:59 GMT'
|
|
33
|
+
: '; max-age=' + end;
|
|
34
|
+
break;
|
|
35
|
+
case 'string':
|
|
36
|
+
expires = '; expires=' + end;
|
|
37
|
+
break;
|
|
38
|
+
case 'date':
|
|
39
|
+
expires = '; expires=' + end.toUTCString();
|
|
40
|
+
break;
|
|
41
|
+
}
|
|
42
|
+
document.cookie = encodeURIComponent(keyItem)
|
|
43
|
+
.concat('=')
|
|
44
|
+
.concat(encodeURIComponent(value))
|
|
45
|
+
.concat(expires)
|
|
46
|
+
.concat(domain ? '; domain='.concat(domain) : '')
|
|
47
|
+
.concat(path ? '; path='.concat(path) : '')
|
|
48
|
+
.concat(secure ? '; secure' : '');
|
|
49
|
+
return true;
|
|
50
|
+
},
|
|
51
|
+
deleteItem(key, path, domain) {
|
|
52
|
+
if (!key || !this.exist(key))
|
|
53
|
+
return false;
|
|
54
|
+
document.cookie = encodeURIComponent(key)
|
|
55
|
+
.concat('=; expires=Thu, 01 Jan 1970 00:00:00 GMT')
|
|
56
|
+
.concat(domain ? '; domain='.concat(domain) : '')
|
|
57
|
+
.concat(path ? '; path='.concat(path) : '');
|
|
58
|
+
return true;
|
|
59
|
+
},
|
|
60
|
+
/** 校验当前 key 是否存在 */
|
|
61
|
+
exist(key) {
|
|
62
|
+
const result = new RegExp('(?:^|;\\s*)' +
|
|
63
|
+
encodeURIComponent(key).replace(/[-.+*]/g, '\\$&') +
|
|
64
|
+
'\\s*\\=').test(document.cookie);
|
|
65
|
+
return result;
|
|
66
|
+
},
|
|
67
|
+
keys() {
|
|
68
|
+
const keyList = document.cookie
|
|
69
|
+
.replace(/((?:^|\s*;)[^=]+)(?=;|$)|^\s*|\s*(?:=[^;]*)?(?:1|$)/g, '')
|
|
70
|
+
.split(/\s*(?:=[^;]*)?;\s*/);
|
|
71
|
+
for (let i = 0; i < keyList.length; i++) {
|
|
72
|
+
keyList[i] = decodeURIComponent(keyList[i]);
|
|
73
|
+
}
|
|
74
|
+
return keyList;
|
|
75
|
+
},
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* @packageDocumentation
|
|
80
|
+
* @module @zza/storage
|
|
81
|
+
* @file storage.ts
|
|
82
|
+
* @description 本地存储
|
|
83
|
+
* @author MrMudBean <Mr.MudBean@outlook.com>
|
|
84
|
+
* @license MIT
|
|
85
|
+
* @copyright 2026 ©️ MrMudBean
|
|
86
|
+
* @since 2026-01-20 12:25
|
|
87
|
+
* @version 0.0.0
|
|
88
|
+
* @lastModified 2026-01-20 12:40
|
|
89
|
+
*/
|
|
90
|
+
/**
|
|
91
|
+
*
|
|
92
|
+
* @param key
|
|
93
|
+
* @param value
|
|
94
|
+
*/
|
|
95
|
+
function set(key, value) {
|
|
96
|
+
localStorage.setItem(key, JSON.stringify(value));
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
*
|
|
100
|
+
* @param key
|
|
101
|
+
*/
|
|
102
|
+
function get(key) {
|
|
103
|
+
const value = localStorage.getItem(key);
|
|
104
|
+
try {
|
|
105
|
+
return (value != null && JSON.parse(value)) || '';
|
|
106
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
107
|
+
}
|
|
108
|
+
catch (error) {
|
|
109
|
+
return (value || '');
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
*
|
|
114
|
+
* @param key
|
|
115
|
+
*/
|
|
116
|
+
function getAndDel(key) {
|
|
117
|
+
const value = get(key);
|
|
118
|
+
del(key);
|
|
119
|
+
return value;
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
*
|
|
123
|
+
* @param key
|
|
124
|
+
*/
|
|
125
|
+
function del(key) {
|
|
126
|
+
return localStorage.removeItem(key);
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
*
|
|
130
|
+
*/
|
|
131
|
+
function clear() {
|
|
132
|
+
localStorage.clear();
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
*
|
|
136
|
+
* @param key
|
|
137
|
+
* @param value
|
|
138
|
+
*/
|
|
139
|
+
function setSession(key, value) {
|
|
140
|
+
sessionStorage.setItem(key, JSON.stringify(value));
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
*
|
|
144
|
+
* @param key
|
|
145
|
+
*/
|
|
146
|
+
function getSession(key) {
|
|
147
|
+
const value = sessionStorage.getItem(key);
|
|
148
|
+
return (value != null && JSON.parse(value)) || '';
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
*
|
|
152
|
+
* @param key
|
|
153
|
+
*/
|
|
154
|
+
function delSession(key) {
|
|
155
|
+
return sessionStorage.removeItem(key);
|
|
156
|
+
}
|
|
157
|
+
const storageMainLogic = {
|
|
158
|
+
del,
|
|
159
|
+
set,
|
|
160
|
+
get,
|
|
161
|
+
getAndDel,
|
|
162
|
+
clear,
|
|
163
|
+
setSession,
|
|
164
|
+
getSession,
|
|
165
|
+
delSession,
|
|
166
|
+
};
|
|
167
|
+
|
|
168
|
+
/**
|
|
169
|
+
* @packageDocumentation
|
|
170
|
+
* @module @zza/storage-store
|
|
171
|
+
* @file storage-store.ts
|
|
172
|
+
* @description 共用的 storage 数仓
|
|
173
|
+
* @author MrMudBean <Mr.MudBean@outlook.com>
|
|
174
|
+
* @license MIT
|
|
175
|
+
* @copyright 2026 ©️ MrMudBean
|
|
176
|
+
* @since 2026-01-20 12:41
|
|
177
|
+
* @version 0.0.0
|
|
178
|
+
* @lastModified 2026-01-20 12:41
|
|
179
|
+
*/
|
|
180
|
+
/** storage 的数据仓库 */
|
|
181
|
+
const storageStore = {
|
|
182
|
+
/** 获取本地的数据中的主题值 */
|
|
183
|
+
get theme() {
|
|
184
|
+
return storageMainLogic.get('theme');
|
|
185
|
+
},
|
|
186
|
+
/** 设置本地的数据的主题值 */
|
|
187
|
+
set theme(newTheme) {
|
|
188
|
+
if (['light', 'dark'].includes(newTheme))
|
|
189
|
+
storageMainLogic.set('theme', newTheme);
|
|
190
|
+
else if (isBusinessEmptyString(newTheme))
|
|
191
|
+
storageMainLogic.del('theme');
|
|
192
|
+
}};
|
|
193
|
+
|
|
194
|
+
/**
|
|
195
|
+
*
|
|
196
|
+
*/
|
|
197
|
+
class SysInfo {
|
|
198
|
+
/**
|
|
199
|
+
*
|
|
200
|
+
*/
|
|
201
|
+
#getMedia(str) {
|
|
202
|
+
return (window?.matchMedia(/:/.test(str) && !/\(|\)/.test(str) ? `(${str})` : str)
|
|
203
|
+
.matches ?? false);
|
|
204
|
+
}
|
|
205
|
+
/**
|
|
206
|
+
* 设备振动
|
|
207
|
+
**/
|
|
208
|
+
vibrate() {
|
|
209
|
+
if (window?.navigator?.vibrate)
|
|
210
|
+
window.navigator.vibrate(200);
|
|
211
|
+
}
|
|
212
|
+
/**
|
|
213
|
+
* 分享网站
|
|
214
|
+
* @param [url='https://letmiseesee.pages.dev'] 网页地址 默认值 https://letmiseesee.pages.dev
|
|
215
|
+
* @param [text=''] text 文本
|
|
216
|
+
* @param [title='随笔记余生'] title 网站标题,缺省值
|
|
217
|
+
* @description
|
|
218
|
+
**/
|
|
219
|
+
share(url = 'https://letmiseesee.pages.dev', text = '', title = '慧土灵核') {
|
|
220
|
+
if (window?.navigator?.share)
|
|
221
|
+
window.navigator.share({ url, text, title });
|
|
222
|
+
}
|
|
223
|
+
/**
|
|
224
|
+
* 当前是否为手机设备
|
|
225
|
+
**/
|
|
226
|
+
isPhone() {
|
|
227
|
+
return (!this.#getMedia('any-hover: hover') &&
|
|
228
|
+
!this.#getMedia('any-pointer: fine') &&
|
|
229
|
+
window?.navigator?.maxTouchPoints > 0);
|
|
230
|
+
}
|
|
231
|
+
/**
|
|
232
|
+
* 当前设备是否为小平设备
|
|
233
|
+
**/
|
|
234
|
+
get isSmallScreen() {
|
|
235
|
+
return this.#getMedia('max-width: 576px')
|
|
236
|
+
? 'small'
|
|
237
|
+
: this.#getMedia('max-width: 996px')
|
|
238
|
+
? 'middle'
|
|
239
|
+
: 'large';
|
|
240
|
+
}
|
|
241
|
+
/**
|
|
242
|
+
* 是否为暗黑模式
|
|
243
|
+
**/
|
|
244
|
+
get isDark() {
|
|
245
|
+
return this.#getMedia('prefers-color-scheme: dark');
|
|
246
|
+
}
|
|
247
|
+
/**
|
|
248
|
+
* 设备当前的旋转状态
|
|
249
|
+
*
|
|
250
|
+
* 只返回是否旋转
|
|
251
|
+
**/
|
|
252
|
+
get isOrientation() {
|
|
253
|
+
const orientation = (screen.orientation || {}).type ||
|
|
254
|
+
/** @ts-expect-error: 兼容 moz 浏览器 */
|
|
255
|
+
screen.mozOrientation ||
|
|
256
|
+
/** @ts-expect-error: 兼容 ms 浏览器 */
|
|
257
|
+
screen.msOrientation;
|
|
258
|
+
/**
|
|
259
|
+
*
|
|
260
|
+
* - portrait-primary 旋转 360
|
|
261
|
+
* - portrait-secondary 旋转 180
|
|
262
|
+
* - landscape-primary 旋转 90
|
|
263
|
+
* - landscape-secondary 旋转 270
|
|
264
|
+
*
|
|
265
|
+
*
|
|
266
|
+
*/
|
|
267
|
+
if (orientation === 'landscape-primary' ||
|
|
268
|
+
orientation === 'landscape-secondary')
|
|
269
|
+
return false;
|
|
270
|
+
return true;
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
const sysInfo = new SysInfo();
|
|
274
|
+
|
|
275
|
+
export { clear as clearStorage, delSession as delSessionStorage, del as delStorage, getSession as getSessionStorage, get as getStorage, getAndDel as getStorageAndDel, manageCookie, setSession as setSessionStorage, set as setStorage, storageMainLogic, storageStore, sysInfo };
|
|
@@ -1,6 +1,53 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var aJsTools = require('a-js-tools');
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* @packageDocumentation
|
|
7
|
+
* @module @qqi/log/virtual-dog
|
|
8
|
+
* @file virtual-dog.ts
|
|
9
|
+
* @description _
|
|
10
|
+
* @author MrMudBean <Mr.MudBean@outlook.com>
|
|
11
|
+
* @license MIT
|
|
12
|
+
* @copyright 2026 ©️ MrMudBean
|
|
13
|
+
* @since 2026-01-28 04:52
|
|
14
|
+
* @version 1.1.0
|
|
15
|
+
* @lastModified 2026-01-28 04:53
|
|
16
|
+
*/
|
|
17
|
+
function DogVirtualImt() {
|
|
18
|
+
var _dev = function () {
|
|
19
|
+
};
|
|
20
|
+
Object.setPrototypeOf(_dev, this);
|
|
21
|
+
Object.defineProperties(this, {
|
|
22
|
+
info: {
|
|
23
|
+
value: function () {
|
|
24
|
+
},
|
|
25
|
+
configurable: false,
|
|
26
|
+
writable: false,
|
|
27
|
+
},
|
|
28
|
+
warn: {
|
|
29
|
+
value: function () {
|
|
30
|
+
},
|
|
31
|
+
configurable: false,
|
|
32
|
+
writable: false,
|
|
33
|
+
},
|
|
34
|
+
error: {
|
|
35
|
+
value: function () {
|
|
36
|
+
},
|
|
37
|
+
configurable: false,
|
|
38
|
+
writable: false,
|
|
39
|
+
},
|
|
40
|
+
type: {
|
|
41
|
+
get: function () {
|
|
42
|
+
return false;
|
|
43
|
+
},
|
|
44
|
+
set: function (_) { },
|
|
45
|
+
},
|
|
46
|
+
});
|
|
47
|
+
return _dev;
|
|
48
|
+
}
|
|
49
|
+
DogVirtualImt.prototype.clear = console.clear;
|
|
50
|
+
var DogVirtualConstructor = aJsTools.createConstructor(DogVirtualImt);
|
|
4
51
|
|
|
5
52
|
/**
|
|
6
53
|
* @packageDocumentation
|
|
@@ -14,4 +61,4 @@ var virtualDog = require('./node_modules/.pnpm/@qqi_log@1.1.4/node_modules/@qqi/
|
|
|
14
61
|
* @version 0.0.0
|
|
15
62
|
* @lastModified 2026-01-30 04:00
|
|
16
63
|
*/
|
|
17
|
-
new
|
|
64
|
+
new DogVirtualConstructor();
|
|
@@ -1,4 +1,51 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { createConstructor } from 'a-js-tools';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @packageDocumentation
|
|
5
|
+
* @module @qqi/log/virtual-dog
|
|
6
|
+
* @file virtual-dog.ts
|
|
7
|
+
* @description _
|
|
8
|
+
* @author MrMudBean <Mr.MudBean@outlook.com>
|
|
9
|
+
* @license MIT
|
|
10
|
+
* @copyright 2026 ©️ MrMudBean
|
|
11
|
+
* @since 2026-01-28 04:52
|
|
12
|
+
* @version 1.1.0
|
|
13
|
+
* @lastModified 2026-01-28 04:53
|
|
14
|
+
*/
|
|
15
|
+
function DogVirtualImt() {
|
|
16
|
+
var _dev = function () {
|
|
17
|
+
};
|
|
18
|
+
Object.setPrototypeOf(_dev, this);
|
|
19
|
+
Object.defineProperties(this, {
|
|
20
|
+
info: {
|
|
21
|
+
value: function () {
|
|
22
|
+
},
|
|
23
|
+
configurable: false,
|
|
24
|
+
writable: false,
|
|
25
|
+
},
|
|
26
|
+
warn: {
|
|
27
|
+
value: function () {
|
|
28
|
+
},
|
|
29
|
+
configurable: false,
|
|
30
|
+
writable: false,
|
|
31
|
+
},
|
|
32
|
+
error: {
|
|
33
|
+
value: function () {
|
|
34
|
+
},
|
|
35
|
+
configurable: false,
|
|
36
|
+
writable: false,
|
|
37
|
+
},
|
|
38
|
+
type: {
|
|
39
|
+
get: function () {
|
|
40
|
+
return false;
|
|
41
|
+
},
|
|
42
|
+
set: function (_) { },
|
|
43
|
+
},
|
|
44
|
+
});
|
|
45
|
+
return _dev;
|
|
46
|
+
}
|
|
47
|
+
DogVirtualImt.prototype.clear = console.clear;
|
|
48
|
+
var DogVirtualConstructor = createConstructor(DogVirtualImt);
|
|
2
49
|
|
|
3
50
|
/**
|
|
4
51
|
* @packageDocumentation
|