@pisell/pisellos 0.0.220 → 0.0.221
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 +180 -180
- package/dist/core/index.js +4 -4
- package/dist/index.js +3 -3
- package/dist/modules/Account/types.js +6 -6
- package/dist/modules/AccountList/index.js +14 -14
- package/dist/modules/AccountList/types.js +14 -14
- package/dist/modules/AccountList/utils.js +5 -5
- package/dist/modules/Cart/index.js +35 -35
- package/dist/modules/Cart/types.js +14 -14
- package/dist/modules/Cart/utils/cartAccount.js +8 -8
- package/dist/modules/Cart/utils/cartDate.js +12 -12
- package/dist/modules/Cart/utils/cartDiscount.js +8 -8
- package/dist/modules/Cart/utils/cartNote.js +8 -8
- package/dist/modules/Cart/utils/cartProduct.js +39 -39
- package/dist/modules/Cart/utils/cartRelationForms.js +8 -8
- package/dist/modules/Cart/utils/cartResource.js +8 -8
- package/dist/modules/Cart/utils/index.js +4 -4
- package/dist/modules/Customer/index.js +67 -67
- package/dist/modules/Customer/types.js +18 -18
- package/dist/modules/Date/types.js +6 -6
- package/dist/modules/Date/utils.js +25 -25
- package/dist/modules/Guests/types.js +8 -8
- package/dist/modules/Order/types.js +4 -4
- package/dist/modules/Order/utils.js +8 -8
- package/dist/modules/Payment/cash.js +2 -2
- package/dist/modules/Payment/eftpos.js +2 -2
- package/dist/modules/Payment/index.js +135 -135
- package/dist/modules/Payment/types.js +50 -50
- package/dist/modules/Payment/wallet.js +2 -2
- package/dist/modules/Product/index.js +22 -22
- package/dist/modules/Product/utils.js +12 -12
- package/dist/modules/ProductList/index.js +4 -4
- package/dist/modules/Resource/types.js +8 -8
- package/dist/modules/Resource/utils.js +14 -14
- package/dist/modules/Schedule/index.js +4 -4
- package/dist/modules/Schedule/utils.js +73 -73
- package/dist/modules/Step/index.js +18 -18
- package/dist/modules/Summary/index.js +4 -4
- package/dist/modules/Summary/utils.js +15 -15
- package/dist/plugins/app-types/app/app.d.ts +83 -83
- package/dist/plugins/app-types/app/const.d.ts +4 -4
- package/dist/plugins/app-types/app/index.d.ts +14 -14
- package/dist/plugins/app-types/applicationManager/application.d.ts +50 -50
- package/dist/plugins/app-types/applicationManager/index.d.ts +13 -13
- package/dist/plugins/app-types/config.d.ts +3 -3
- package/dist/plugins/app-types/cookie/index.d.ts +13 -13
- package/dist/plugins/app-types/data/index.d.ts +8 -8
- package/dist/plugins/app-types/history/config.d.ts +24 -24
- package/dist/plugins/app-types/history/index.d.ts +20 -20
- package/dist/plugins/app-types/history/type.d.ts +2 -2
- package/dist/plugins/app-types/hooks/index.d.ts +12 -12
- package/dist/plugins/app-types/hooks/useDelayedValue/index.d.ts +2 -2
- package/dist/plugins/app-types/hooks/useDispatch/index.d.ts +2 -2
- package/dist/plugins/app-types/hooks/useLowCode/index.d.ts +13 -13
- package/dist/plugins/app-types/hooks/useStore/index.d.ts +6 -6
- package/dist/plugins/app-types/index.d.ts +6 -6
- package/dist/plugins/app-types/indexDB/index.d.ts +178 -178
- package/dist/plugins/app-types/locales/en.d.ts +3 -3
- package/dist/plugins/app-types/locales/index.d.ts +37 -37
- package/dist/plugins/app-types/locales/original.d.ts +3 -3
- package/dist/plugins/app-types/locales/type.d.ts +19 -19
- package/dist/plugins/app-types/locales/zh-CN.d.ts +3 -3
- package/dist/plugins/app-types/locales/zh-HK.d.ts +3 -3
- package/dist/plugins/app-types/logger/feishu.d.ts +11 -11
- package/dist/plugins/app-types/logger/index.d.ts +122 -122
- package/dist/plugins/app-types/menuManager/hooks.d.ts +17 -17
- package/dist/plugins/app-types/menuManager/index.d.ts +28 -28
- package/dist/plugins/app-types/models/global.d.ts +32 -32
- package/dist/plugins/app-types/models/index.d.ts +45 -45
- package/dist/plugins/app-types/models/type.d.ts +2 -2
- package/dist/plugins/app-types/package.json +14 -14
- package/dist/plugins/app-types/pubsub/example.d.ts +5 -5
- package/dist/plugins/app-types/pubsub/index.d.ts +63 -63
- package/dist/plugins/app-types/request/cache.d.ts +46 -46
- package/dist/plugins/app-types/request/cancelToken.d.ts +38 -38
- package/dist/plugins/app-types/request/config.d.ts +3 -3
- package/dist/plugins/app-types/request/constants.d.ts +2 -2
- package/dist/plugins/app-types/request/index.d.ts +24 -24
- package/dist/plugins/app-types/request/pisell2Request.d.ts +6 -6
- package/dist/plugins/app-types/request/type.d.ts +41 -41
- package/dist/plugins/app-types/request/utils.d.ts +46 -46
- package/dist/plugins/app-types/routes/config.d.ts +7 -7
- package/dist/plugins/app-types/routes/index.d.ts +28 -28
- package/dist/plugins/app-types/socket/components/SocketMonitorPage.d.ts +6 -6
- package/dist/plugins/app-types/socket/components/index.d.ts +2 -2
- package/dist/plugins/app-types/socket/constants.d.ts +33 -33
- package/dist/plugins/app-types/socket/events.d.ts +31 -31
- package/dist/plugins/app-types/socket/heartbeat.d.ts +66 -66
- package/dist/plugins/app-types/socket/index.d.ts +61 -61
- package/dist/plugins/app-types/socket/monitor.d.ts +169 -169
- package/dist/plugins/app-types/socket/reconnect.d.ts +61 -61
- package/dist/plugins/app-types/socket/socket.d.ts +129 -129
- package/dist/plugins/app-types/socket/types.d.ts +85 -85
- package/dist/plugins/app-types/storage/index.d.ts +17 -17
- package/dist/plugins/app-types/tasks/index.d.ts +77 -77
- package/dist/plugins/app-types/tasks/type.d.ts +62 -62
- package/dist/plugins/app-types/tasks/useTasks.d.ts +5 -5
- package/dist/plugins/app-types/type.d.ts +2 -2
- package/dist/plugins/app-types/variables/VariablesProvider.d.ts +7 -7
- package/dist/plugins/app-types/variables/config.d.ts +3 -3
- package/dist/plugins/app-types/variables/index.d.ts +6 -6
- package/dist/plugins/app-types/variables/type.d.ts +2 -2
- package/dist/plugins/app-types/website/index.d.ts +6 -6
- package/dist/plugins/request.js +33 -33
- package/dist/plugins/window.js +16 -16
- package/dist/solution/BookingByStep/index.js +126 -126
- package/dist/solution/BookingByStep/utils/capacity.js +30 -30
- package/dist/solution/BookingByStep/utils/products.js +4 -4
- package/dist/solution/BookingByStep/utils/resources.js +146 -146
- package/dist/solution/BookingByStep/utils/timeslots.js +20 -20
- package/dist/solution/BookingTicket/index.d.ts +1 -1
- package/dist/solution/BookingTicket/index.js +82 -86
- package/dist/solution/BookingTicket/types.js +8 -8
- package/dist/solution/BookingTicket/utils/scan/cloudSearch.js +6 -6
- package/dist/solution/BookingTicket/utils/scan/handleScan.d.ts +1 -4
- package/dist/solution/BookingTicket/utils/scan/handleScan.js +20 -28
- package/dist/solution/BookingTicket/utils/scan/index.js +19 -19
- package/dist/solution/BookingTicket/utils/scan/scanCache.js +52 -52
- package/dist/solution/BuyTickets/types.js +4 -4
- package/dist/utils/task.js +11 -11
- package/dist/utils/watch.js +59 -59
- package/lib/plugins/app-types/app/app.d.ts +83 -83
- package/lib/plugins/app-types/app/const.d.ts +4 -4
- package/lib/plugins/app-types/app/index.d.ts +14 -14
- package/lib/plugins/app-types/applicationManager/application.d.ts +50 -50
- package/lib/plugins/app-types/applicationManager/index.d.ts +13 -13
- package/lib/plugins/app-types/config.d.ts +3 -3
- package/lib/plugins/app-types/cookie/index.d.ts +13 -13
- package/lib/plugins/app-types/data/index.d.ts +8 -8
- package/lib/plugins/app-types/history/config.d.ts +24 -24
- package/lib/plugins/app-types/history/index.d.ts +20 -20
- package/lib/plugins/app-types/history/type.d.ts +2 -2
- package/lib/plugins/app-types/hooks/index.d.ts +12 -12
- package/lib/plugins/app-types/hooks/useDelayedValue/index.d.ts +2 -2
- package/lib/plugins/app-types/hooks/useDispatch/index.d.ts +2 -2
- package/lib/plugins/app-types/hooks/useLowCode/index.d.ts +13 -13
- package/lib/plugins/app-types/hooks/useStore/index.d.ts +6 -6
- package/lib/plugins/app-types/index.d.ts +6 -6
- package/lib/plugins/app-types/indexDB/index.d.ts +178 -178
- package/lib/plugins/app-types/locales/en.d.ts +3 -3
- package/lib/plugins/app-types/locales/index.d.ts +37 -37
- package/lib/plugins/app-types/locales/original.d.ts +3 -3
- package/lib/plugins/app-types/locales/type.d.ts +19 -19
- package/lib/plugins/app-types/locales/zh-CN.d.ts +3 -3
- package/lib/plugins/app-types/locales/zh-HK.d.ts +3 -3
- package/lib/plugins/app-types/logger/feishu.d.ts +11 -11
- package/lib/plugins/app-types/logger/index.d.ts +122 -122
- package/lib/plugins/app-types/menuManager/hooks.d.ts +17 -17
- package/lib/plugins/app-types/menuManager/index.d.ts +28 -28
- package/lib/plugins/app-types/models/global.d.ts +32 -32
- package/lib/plugins/app-types/models/index.d.ts +45 -45
- package/lib/plugins/app-types/models/type.d.ts +2 -2
- package/lib/plugins/app-types/package.json +14 -14
- package/lib/plugins/app-types/pubsub/example.d.ts +5 -5
- package/lib/plugins/app-types/pubsub/index.d.ts +63 -63
- package/lib/plugins/app-types/request/cache.d.ts +46 -46
- package/lib/plugins/app-types/request/cancelToken.d.ts +38 -38
- package/lib/plugins/app-types/request/config.d.ts +3 -3
- package/lib/plugins/app-types/request/constants.d.ts +2 -2
- package/lib/plugins/app-types/request/index.d.ts +24 -24
- package/lib/plugins/app-types/request/pisell2Request.d.ts +6 -6
- package/lib/plugins/app-types/request/type.d.ts +41 -41
- package/lib/plugins/app-types/request/utils.d.ts +46 -46
- package/lib/plugins/app-types/routes/config.d.ts +7 -7
- package/lib/plugins/app-types/routes/index.d.ts +28 -28
- package/lib/plugins/app-types/socket/components/SocketMonitorPage.d.ts +6 -6
- package/lib/plugins/app-types/socket/components/index.d.ts +2 -2
- package/lib/plugins/app-types/socket/constants.d.ts +33 -33
- package/lib/plugins/app-types/socket/events.d.ts +31 -31
- package/lib/plugins/app-types/socket/heartbeat.d.ts +66 -66
- package/lib/plugins/app-types/socket/index.d.ts +61 -61
- package/lib/plugins/app-types/socket/monitor.d.ts +169 -169
- package/lib/plugins/app-types/socket/reconnect.d.ts +61 -61
- package/lib/plugins/app-types/socket/socket.d.ts +129 -129
- package/lib/plugins/app-types/socket/types.d.ts +85 -85
- package/lib/plugins/app-types/storage/index.d.ts +17 -17
- package/lib/plugins/app-types/tasks/index.d.ts +77 -77
- package/lib/plugins/app-types/tasks/type.d.ts +62 -62
- package/lib/plugins/app-types/tasks/useTasks.d.ts +5 -5
- package/lib/plugins/app-types/type.d.ts +2 -2
- package/lib/plugins/app-types/variables/VariablesProvider.d.ts +7 -7
- package/lib/plugins/app-types/variables/config.d.ts +3 -3
- package/lib/plugins/app-types/variables/index.d.ts +6 -6
- package/lib/plugins/app-types/variables/type.d.ts +2 -2
- package/lib/plugins/app-types/website/index.d.ts +6 -6
- package/lib/solution/BookingTicket/index.d.ts +1 -1
- package/lib/solution/BookingTicket/index.js +1 -2
- package/lib/solution/BookingTicket/utils/scan/handleScan.d.ts +1 -4
- package/lib/solution/BookingTicket/utils/scan/handleScan.js +2 -14
- package/package.json +1 -1
|
@@ -1,178 +1,178 @@
|
|
|
1
|
-
import App from "../app";
|
|
2
|
-
/**
|
|
3
|
-
* IndexDB 管理器模块
|
|
4
|
-
*
|
|
5
|
-
* 这个模块提供了对浏览器 IndexedDB 的简单封装,并在不支持 IndexedDB 的环境中
|
|
6
|
-
* 自动降级使用 localStorage 作为备选存储方案。
|
|
7
|
-
*/
|
|
8
|
-
/**
|
|
9
|
-
* 数据库配置选项接口
|
|
10
|
-
* @interface DBOptions
|
|
11
|
-
* @property {string} dbName - 数据库名称
|
|
12
|
-
* @property {number} version - 数据库版本号
|
|
13
|
-
* @property {Array} stores - 存储对象配置数组
|
|
14
|
-
* @property {string} stores[].name - 存储对象名称
|
|
15
|
-
* @property {string} stores[].keyPath - 主键路径
|
|
16
|
-
* @property {Array} [stores[].indexes] - 索引配置数组(可选)
|
|
17
|
-
* @property {string} stores[].indexes[].name - 索引名称
|
|
18
|
-
* @property {string} stores[].indexes[].keyPath - 索引键路径
|
|
19
|
-
* @property {IDBIndexParameters} [stores[].indexes[].options] - 索引选项(可选)
|
|
20
|
-
*/
|
|
21
|
-
export interface DBOptions {
|
|
22
|
-
dbName: string;
|
|
23
|
-
version: number;
|
|
24
|
-
stores: {
|
|
25
|
-
name: string;
|
|
26
|
-
keyPath: string;
|
|
27
|
-
indexes?: {
|
|
28
|
-
name: string;
|
|
29
|
-
keyPath: string;
|
|
30
|
-
options?: IDBIndexParameters;
|
|
31
|
-
}[];
|
|
32
|
-
}[];
|
|
33
|
-
}
|
|
34
|
-
/**
|
|
35
|
-
* IndexDB 管理器类
|
|
36
|
-
* 提供对 IndexedDB 的简单封装,支持自动降级到 localStorage
|
|
37
|
-
* @class IndexDBManager
|
|
38
|
-
*/
|
|
39
|
-
declare class IndexDBManager {
|
|
40
|
-
/**
|
|
41
|
-
* 检查环境是否支持 IndexedDB
|
|
42
|
-
* @returns {boolean} 是否支持 IndexedDB
|
|
43
|
-
* @private
|
|
44
|
-
*/
|
|
45
|
-
private static isSupported;
|
|
46
|
-
private db;
|
|
47
|
-
private dbName;
|
|
48
|
-
private version;
|
|
49
|
-
private stores;
|
|
50
|
-
private useIndexDB;
|
|
51
|
-
private app;
|
|
52
|
-
/**
|
|
53
|
-
* 创建 IndexDBManager 实例
|
|
54
|
-
* @param {DBOptions} options - 数据库配置选项
|
|
55
|
-
*/
|
|
56
|
-
constructor(app: App, options: DBOptions);
|
|
57
|
-
/**
|
|
58
|
-
* 初始化数据库连接
|
|
59
|
-
* 如果环境不支持 IndexedDB,将自动使用 localStorage
|
|
60
|
-
* @returns {Promise<boolean>} 连接是否成功
|
|
61
|
-
*/
|
|
62
|
-
connect(): Promise<boolean>;
|
|
63
|
-
/**
|
|
64
|
-
* 生成用于 localStorage 的存储键
|
|
65
|
-
* @param {string} storeName - 存储对象名称
|
|
66
|
-
* @param {string|number} [key] - 可选的键值
|
|
67
|
-
* @returns {string} 格式化的存储键
|
|
68
|
-
* @private
|
|
69
|
-
*/
|
|
70
|
-
private getStorageKey;
|
|
71
|
-
/**
|
|
72
|
-
* 添加数据到指定的存储对象
|
|
73
|
-
* @param {string} storeName - 存储对象名称
|
|
74
|
-
* @param {T} data - 要添加的数据
|
|
75
|
-
* @returns {Promise<T>} 添加的数据
|
|
76
|
-
* @template T
|
|
77
|
-
*/
|
|
78
|
-
add<T>(storeName: string, data: T): Promise<T>;
|
|
79
|
-
/**
|
|
80
|
-
* 获取指定存储对象中的数据
|
|
81
|
-
* @param {string} storeName - 存储对象名称
|
|
82
|
-
* @param {string|number} key - 数据主键
|
|
83
|
-
* @returns {Promise<T|null>} 获取的数据,不存在则返回 null
|
|
84
|
-
* @template T
|
|
85
|
-
*/
|
|
86
|
-
get<T>(storeName: string, key: string | number): Promise<T | null>;
|
|
87
|
-
/**
|
|
88
|
-
* 更新指定存储对象中的数据
|
|
89
|
-
* @param {string} storeName - 存储对象名称
|
|
90
|
-
* @param {T} data - 要更新的数据
|
|
91
|
-
* @returns {Promise<T>} 更新后的数据
|
|
92
|
-
* @template T
|
|
93
|
-
*/
|
|
94
|
-
update<T>(storeName: string, data: T): Promise<T>;
|
|
95
|
-
/**
|
|
96
|
-
* 删除指定存储对象中的数据
|
|
97
|
-
* @param {string} storeName - 存储对象名称
|
|
98
|
-
* @param {string|number} key - 数据主键
|
|
99
|
-
* @returns {Promise<boolean>} 删除是否成功
|
|
100
|
-
*/
|
|
101
|
-
delete(storeName: string, key: string | number): Promise<boolean>;
|
|
102
|
-
/**
|
|
103
|
-
* 获取指定存储对象中的所有数据
|
|
104
|
-
* @param {string} storeName - 存储对象名称
|
|
105
|
-
* @returns {Promise<T[]>} 数据数组
|
|
106
|
-
* @template T
|
|
107
|
-
*/
|
|
108
|
-
getAll<T>(storeName: string): Promise<T[]>;
|
|
109
|
-
/**
|
|
110
|
-
* 清空指定存储对象中的所有数据
|
|
111
|
-
* @param {string} storeName - 存储对象名称
|
|
112
|
-
* @returns {Promise<boolean>} 清空是否成功
|
|
113
|
-
*/
|
|
114
|
-
clear(storeName: string): Promise<boolean>;
|
|
115
|
-
/**
|
|
116
|
-
* 关闭数据库连接
|
|
117
|
-
* 在不再需要使用数据库时调用,释放资源
|
|
118
|
-
*/
|
|
119
|
-
close(): void;
|
|
120
|
-
/**
|
|
121
|
-
* 获取当前使用的存储方式
|
|
122
|
-
* @returns {'indexDB'|'localStorage'} 当前使用的存储方式
|
|
123
|
-
*/
|
|
124
|
-
getCurrentStorage(): 'indexDB' | 'localStorage';
|
|
125
|
-
}
|
|
126
|
-
/**
|
|
127
|
-
* 使用示例:
|
|
128
|
-
*
|
|
129
|
-
* // 1. 创建数据库配置
|
|
130
|
-
* const dbOptions: DBOptions = {
|
|
131
|
-
* dbName: 'myApp',
|
|
132
|
-
* version: 1,
|
|
133
|
-
* stores: [
|
|
134
|
-
* {
|
|
135
|
-
* name: 'users',
|
|
136
|
-
* keyPath: 'id',
|
|
137
|
-
* indexes: [
|
|
138
|
-
* { name: 'email', keyPath: 'email', options: { unique: true } }
|
|
139
|
-
* ]
|
|
140
|
-
* },
|
|
141
|
-
* {
|
|
142
|
-
* name: 'products',
|
|
143
|
-
* keyPath: 'id'
|
|
144
|
-
* }
|
|
145
|
-
* ]
|
|
146
|
-
* };
|
|
147
|
-
*
|
|
148
|
-
* // 2. 创建并连接数据库
|
|
149
|
-
* const db = new IndexDBManager(dbOptions);
|
|
150
|
-
* await db.connect();
|
|
151
|
-
*
|
|
152
|
-
* // 3. 添加数据
|
|
153
|
-
* const user = { id: '1', name: '张三', email: 'zhangsan@example.com' };
|
|
154
|
-
* await db.add('users', user);
|
|
155
|
-
*
|
|
156
|
-
* // 4. 获取数据
|
|
157
|
-
* const retrievedUser = await db.get('users', '1');
|
|
158
|
-
*
|
|
159
|
-
* // 5. 更新数据
|
|
160
|
-
* user.name = '张三 (已更新)';
|
|
161
|
-
* await db.update('users', user);
|
|
162
|
-
*
|
|
163
|
-
* // 6. 获取所有数据
|
|
164
|
-
* const allUsers = await db.getAll('users');
|
|
165
|
-
*
|
|
166
|
-
* // 7. 删除数据
|
|
167
|
-
* await db.delete('users', '1');
|
|
168
|
-
*
|
|
169
|
-
* // 8. 清空存储对象
|
|
170
|
-
* await db.clear('users');
|
|
171
|
-
*
|
|
172
|
-
* // 9. 关闭数据库连接
|
|
173
|
-
* db.close();
|
|
174
|
-
*
|
|
175
|
-
* // 10. 检查当前使用的存储方式
|
|
176
|
-
* const storageType = db.getCurrentStorage(); // 'indexDB' 或 'localStorage'
|
|
177
|
-
*/
|
|
178
|
-
export default IndexDBManager;
|
|
1
|
+
import App from "../app";
|
|
2
|
+
/**
|
|
3
|
+
* IndexDB 管理器模块
|
|
4
|
+
*
|
|
5
|
+
* 这个模块提供了对浏览器 IndexedDB 的简单封装,并在不支持 IndexedDB 的环境中
|
|
6
|
+
* 自动降级使用 localStorage 作为备选存储方案。
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* 数据库配置选项接口
|
|
10
|
+
* @interface DBOptions
|
|
11
|
+
* @property {string} dbName - 数据库名称
|
|
12
|
+
* @property {number} version - 数据库版本号
|
|
13
|
+
* @property {Array} stores - 存储对象配置数组
|
|
14
|
+
* @property {string} stores[].name - 存储对象名称
|
|
15
|
+
* @property {string} stores[].keyPath - 主键路径
|
|
16
|
+
* @property {Array} [stores[].indexes] - 索引配置数组(可选)
|
|
17
|
+
* @property {string} stores[].indexes[].name - 索引名称
|
|
18
|
+
* @property {string} stores[].indexes[].keyPath - 索引键路径
|
|
19
|
+
* @property {IDBIndexParameters} [stores[].indexes[].options] - 索引选项(可选)
|
|
20
|
+
*/
|
|
21
|
+
export interface DBOptions {
|
|
22
|
+
dbName: string;
|
|
23
|
+
version: number;
|
|
24
|
+
stores: {
|
|
25
|
+
name: string;
|
|
26
|
+
keyPath: string;
|
|
27
|
+
indexes?: {
|
|
28
|
+
name: string;
|
|
29
|
+
keyPath: string;
|
|
30
|
+
options?: IDBIndexParameters;
|
|
31
|
+
}[];
|
|
32
|
+
}[];
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* IndexDB 管理器类
|
|
36
|
+
* 提供对 IndexedDB 的简单封装,支持自动降级到 localStorage
|
|
37
|
+
* @class IndexDBManager
|
|
38
|
+
*/
|
|
39
|
+
declare class IndexDBManager {
|
|
40
|
+
/**
|
|
41
|
+
* 检查环境是否支持 IndexedDB
|
|
42
|
+
* @returns {boolean} 是否支持 IndexedDB
|
|
43
|
+
* @private
|
|
44
|
+
*/
|
|
45
|
+
private static isSupported;
|
|
46
|
+
private db;
|
|
47
|
+
private dbName;
|
|
48
|
+
private version;
|
|
49
|
+
private stores;
|
|
50
|
+
private useIndexDB;
|
|
51
|
+
private app;
|
|
52
|
+
/**
|
|
53
|
+
* 创建 IndexDBManager 实例
|
|
54
|
+
* @param {DBOptions} options - 数据库配置选项
|
|
55
|
+
*/
|
|
56
|
+
constructor(app: App, options: DBOptions);
|
|
57
|
+
/**
|
|
58
|
+
* 初始化数据库连接
|
|
59
|
+
* 如果环境不支持 IndexedDB,将自动使用 localStorage
|
|
60
|
+
* @returns {Promise<boolean>} 连接是否成功
|
|
61
|
+
*/
|
|
62
|
+
connect(): Promise<boolean>;
|
|
63
|
+
/**
|
|
64
|
+
* 生成用于 localStorage 的存储键
|
|
65
|
+
* @param {string} storeName - 存储对象名称
|
|
66
|
+
* @param {string|number} [key] - 可选的键值
|
|
67
|
+
* @returns {string} 格式化的存储键
|
|
68
|
+
* @private
|
|
69
|
+
*/
|
|
70
|
+
private getStorageKey;
|
|
71
|
+
/**
|
|
72
|
+
* 添加数据到指定的存储对象
|
|
73
|
+
* @param {string} storeName - 存储对象名称
|
|
74
|
+
* @param {T} data - 要添加的数据
|
|
75
|
+
* @returns {Promise<T>} 添加的数据
|
|
76
|
+
* @template T
|
|
77
|
+
*/
|
|
78
|
+
add<T>(storeName: string, data: T): Promise<T>;
|
|
79
|
+
/**
|
|
80
|
+
* 获取指定存储对象中的数据
|
|
81
|
+
* @param {string} storeName - 存储对象名称
|
|
82
|
+
* @param {string|number} key - 数据主键
|
|
83
|
+
* @returns {Promise<T|null>} 获取的数据,不存在则返回 null
|
|
84
|
+
* @template T
|
|
85
|
+
*/
|
|
86
|
+
get<T>(storeName: string, key: string | number): Promise<T | null>;
|
|
87
|
+
/**
|
|
88
|
+
* 更新指定存储对象中的数据
|
|
89
|
+
* @param {string} storeName - 存储对象名称
|
|
90
|
+
* @param {T} data - 要更新的数据
|
|
91
|
+
* @returns {Promise<T>} 更新后的数据
|
|
92
|
+
* @template T
|
|
93
|
+
*/
|
|
94
|
+
update<T>(storeName: string, data: T): Promise<T>;
|
|
95
|
+
/**
|
|
96
|
+
* 删除指定存储对象中的数据
|
|
97
|
+
* @param {string} storeName - 存储对象名称
|
|
98
|
+
* @param {string|number} key - 数据主键
|
|
99
|
+
* @returns {Promise<boolean>} 删除是否成功
|
|
100
|
+
*/
|
|
101
|
+
delete(storeName: string, key: string | number): Promise<boolean>;
|
|
102
|
+
/**
|
|
103
|
+
* 获取指定存储对象中的所有数据
|
|
104
|
+
* @param {string} storeName - 存储对象名称
|
|
105
|
+
* @returns {Promise<T[]>} 数据数组
|
|
106
|
+
* @template T
|
|
107
|
+
*/
|
|
108
|
+
getAll<T>(storeName: string): Promise<T[]>;
|
|
109
|
+
/**
|
|
110
|
+
* 清空指定存储对象中的所有数据
|
|
111
|
+
* @param {string} storeName - 存储对象名称
|
|
112
|
+
* @returns {Promise<boolean>} 清空是否成功
|
|
113
|
+
*/
|
|
114
|
+
clear(storeName: string): Promise<boolean>;
|
|
115
|
+
/**
|
|
116
|
+
* 关闭数据库连接
|
|
117
|
+
* 在不再需要使用数据库时调用,释放资源
|
|
118
|
+
*/
|
|
119
|
+
close(): void;
|
|
120
|
+
/**
|
|
121
|
+
* 获取当前使用的存储方式
|
|
122
|
+
* @returns {'indexDB'|'localStorage'} 当前使用的存储方式
|
|
123
|
+
*/
|
|
124
|
+
getCurrentStorage(): 'indexDB' | 'localStorage';
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* 使用示例:
|
|
128
|
+
*
|
|
129
|
+
* // 1. 创建数据库配置
|
|
130
|
+
* const dbOptions: DBOptions = {
|
|
131
|
+
* dbName: 'myApp',
|
|
132
|
+
* version: 1,
|
|
133
|
+
* stores: [
|
|
134
|
+
* {
|
|
135
|
+
* name: 'users',
|
|
136
|
+
* keyPath: 'id',
|
|
137
|
+
* indexes: [
|
|
138
|
+
* { name: 'email', keyPath: 'email', options: { unique: true } }
|
|
139
|
+
* ]
|
|
140
|
+
* },
|
|
141
|
+
* {
|
|
142
|
+
* name: 'products',
|
|
143
|
+
* keyPath: 'id'
|
|
144
|
+
* }
|
|
145
|
+
* ]
|
|
146
|
+
* };
|
|
147
|
+
*
|
|
148
|
+
* // 2. 创建并连接数据库
|
|
149
|
+
* const db = new IndexDBManager(dbOptions);
|
|
150
|
+
* await db.connect();
|
|
151
|
+
*
|
|
152
|
+
* // 3. 添加数据
|
|
153
|
+
* const user = { id: '1', name: '张三', email: 'zhangsan@example.com' };
|
|
154
|
+
* await db.add('users', user);
|
|
155
|
+
*
|
|
156
|
+
* // 4. 获取数据
|
|
157
|
+
* const retrievedUser = await db.get('users', '1');
|
|
158
|
+
*
|
|
159
|
+
* // 5. 更新数据
|
|
160
|
+
* user.name = '张三 (已更新)';
|
|
161
|
+
* await db.update('users', user);
|
|
162
|
+
*
|
|
163
|
+
* // 6. 获取所有数据
|
|
164
|
+
* const allUsers = await db.getAll('users');
|
|
165
|
+
*
|
|
166
|
+
* // 7. 删除数据
|
|
167
|
+
* await db.delete('users', '1');
|
|
168
|
+
*
|
|
169
|
+
* // 8. 清空存储对象
|
|
170
|
+
* await db.clear('users');
|
|
171
|
+
*
|
|
172
|
+
* // 9. 关闭数据库连接
|
|
173
|
+
* db.close();
|
|
174
|
+
*
|
|
175
|
+
* // 10. 检查当前使用的存储方式
|
|
176
|
+
* const storageType = db.getCurrentStorage(); // 'indexDB' 或 'localStorage'
|
|
177
|
+
*/
|
|
178
|
+
export default IndexDBManager;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { LibraryItem } from './type';
|
|
2
|
-
declare const _default: LibraryItem;
|
|
3
|
-
export default _default;
|
|
1
|
+
import { LibraryItem } from './type';
|
|
2
|
+
declare const _default: LibraryItem;
|
|
3
|
+
export default _default;
|
|
@@ -1,37 +1,37 @@
|
|
|
1
|
-
import { Locale, LibraryItem, LoadLibraryByUrlParams } from "./type";
|
|
2
|
-
import App from "../app";
|
|
3
|
-
export interface LocalesOptions {
|
|
4
|
-
locale?: Locale;
|
|
5
|
-
library?: {
|
|
6
|
-
[key in Locale]: LibraryItem;
|
|
7
|
-
};
|
|
8
|
-
}
|
|
9
|
-
export declare class Locales {
|
|
10
|
-
private app;
|
|
11
|
-
locale: string;
|
|
12
|
-
library: {
|
|
13
|
-
[key in Locale]: LibraryItem;
|
|
14
|
-
};
|
|
15
|
-
constructor(app: App, options?: LocalesOptions);
|
|
16
|
-
getLocale: () => string;
|
|
17
|
-
getCurrentTexts: (locale?: Locale) => {
|
|
18
|
-
[key: string]: string;
|
|
19
|
-
};
|
|
20
|
-
setLocale: (locale: Locale, reload?: boolean) => void;
|
|
21
|
-
getText: (id: string, locale?: Locale) => string;
|
|
22
|
-
isCN: () => boolean;
|
|
23
|
-
loadLibraryByUrl: (urls: LoadLibraryByUrlParams) => Promise<{
|
|
24
|
-
[x: string]: LibraryItem;
|
|
25
|
-
}>;
|
|
26
|
-
loadLibraryByItems(libraryList: LibraryItem[]): void;
|
|
27
|
-
loadLibrary: (urls: LoadLibraryByUrlParams) => Promise<{
|
|
28
|
-
[x: string]: LibraryItem;
|
|
29
|
-
}>;
|
|
30
|
-
translation: (text: string | {
|
|
31
|
-
[key: Locale]: string;
|
|
32
|
-
}, locale?: Locale) => string | number;
|
|
33
|
-
getLibraryByData: (data: LibraryItem[]) => LibraryItem;
|
|
34
|
-
createTextsByLibrary: (id: string, library?: { [key in Locale]: LibraryItem; }) => {
|
|
35
|
-
[x: string]: string;
|
|
36
|
-
};
|
|
37
|
-
}
|
|
1
|
+
import { Locale, LibraryItem, LoadLibraryByUrlParams } from "./type";
|
|
2
|
+
import App from "../app";
|
|
3
|
+
export interface LocalesOptions {
|
|
4
|
+
locale?: Locale;
|
|
5
|
+
library?: {
|
|
6
|
+
[key in Locale]: LibraryItem;
|
|
7
|
+
};
|
|
8
|
+
}
|
|
9
|
+
export declare class Locales {
|
|
10
|
+
private app;
|
|
11
|
+
locale: string;
|
|
12
|
+
library: {
|
|
13
|
+
[key in Locale]: LibraryItem;
|
|
14
|
+
};
|
|
15
|
+
constructor(app: App, options?: LocalesOptions);
|
|
16
|
+
getLocale: () => string;
|
|
17
|
+
getCurrentTexts: (locale?: Locale) => {
|
|
18
|
+
[key: string]: string;
|
|
19
|
+
};
|
|
20
|
+
setLocale: (locale: Locale, reload?: boolean) => void;
|
|
21
|
+
getText: (id: string, locale?: Locale) => string;
|
|
22
|
+
isCN: () => boolean;
|
|
23
|
+
loadLibraryByUrl: (urls: LoadLibraryByUrlParams) => Promise<{
|
|
24
|
+
[x: string]: LibraryItem;
|
|
25
|
+
}>;
|
|
26
|
+
loadLibraryByItems(libraryList: LibraryItem[]): void;
|
|
27
|
+
loadLibrary: (urls: LoadLibraryByUrlParams) => Promise<{
|
|
28
|
+
[x: string]: LibraryItem;
|
|
29
|
+
}>;
|
|
30
|
+
translation: (text: string | {
|
|
31
|
+
[key: Locale]: string;
|
|
32
|
+
}, locale?: Locale) => string | number;
|
|
33
|
+
getLibraryByData: (data: LibraryItem[]) => LibraryItem;
|
|
34
|
+
createTextsByLibrary: (id: string, library?: { [key in Locale]: LibraryItem; }) => {
|
|
35
|
+
[x: string]: string;
|
|
36
|
+
};
|
|
37
|
+
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { LibraryItem } from './type';
|
|
2
|
-
declare const _default: LibraryItem;
|
|
3
|
-
export default _default;
|
|
1
|
+
import { LibraryItem } from './type';
|
|
2
|
+
declare const _default: LibraryItem;
|
|
3
|
+
export default _default;
|
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
export type Locale = 'original' | 'en' | 'zh-CN' | 'zh-HK' | string;
|
|
2
|
-
export type MultiLanguage = {
|
|
3
|
-
[key in Locale]: string;
|
|
4
|
-
};
|
|
5
|
-
export interface LibraryItem {
|
|
6
|
-
locale: Locale;
|
|
7
|
-
name: string;
|
|
8
|
-
translations: {
|
|
9
|
-
[key: string]: string;
|
|
10
|
-
};
|
|
11
|
-
[key: string]: any;
|
|
12
|
-
}
|
|
13
|
-
export interface LocaleConfig {
|
|
14
|
-
locale: Locale;
|
|
15
|
-
library: {
|
|
16
|
-
[key in Locale]: LibraryItem;
|
|
17
|
-
};
|
|
18
|
-
}
|
|
19
|
-
export type LoadLibraryByUrlParams = (string | Promise<LibraryItem> | (() => Promise<LibraryItem>) | LibraryItem)[];
|
|
1
|
+
export type Locale = 'original' | 'en' | 'zh-CN' | 'zh-HK' | string;
|
|
2
|
+
export type MultiLanguage = {
|
|
3
|
+
[key in Locale]: string;
|
|
4
|
+
};
|
|
5
|
+
export interface LibraryItem {
|
|
6
|
+
locale: Locale;
|
|
7
|
+
name: string;
|
|
8
|
+
translations: {
|
|
9
|
+
[key: string]: string;
|
|
10
|
+
};
|
|
11
|
+
[key: string]: any;
|
|
12
|
+
}
|
|
13
|
+
export interface LocaleConfig {
|
|
14
|
+
locale: Locale;
|
|
15
|
+
library: {
|
|
16
|
+
[key in Locale]: LibraryItem;
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
export type LoadLibraryByUrlParams = (string | Promise<LibraryItem> | (() => Promise<LibraryItem>) | LibraryItem)[];
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { LibraryItem } from './type';
|
|
2
|
-
declare const _default: LibraryItem;
|
|
3
|
-
export default _default;
|
|
1
|
+
import { LibraryItem } from './type';
|
|
2
|
+
declare const _default: LibraryItem;
|
|
3
|
+
export default _default;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { LibraryItem } from './type';
|
|
2
|
-
declare const _default: LibraryItem;
|
|
3
|
-
export default _default;
|
|
1
|
+
import { LibraryItem } from './type';
|
|
2
|
+
declare const _default: LibraryItem;
|
|
3
|
+
export default _default;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
interface contentItem {
|
|
2
|
-
key: string;
|
|
3
|
-
value: string;
|
|
4
|
-
}
|
|
5
|
-
interface sendWebhookProps {
|
|
6
|
-
title: string;
|
|
7
|
-
content: contentItem[];
|
|
8
|
-
webhook: string;
|
|
9
|
-
}
|
|
10
|
-
export declare const sendWarningLog: ({ title, content, webhook }: sendWebhookProps) => Promise<any>;
|
|
11
|
-
export {};
|
|
1
|
+
interface contentItem {
|
|
2
|
+
key: string;
|
|
3
|
+
value: string;
|
|
4
|
+
}
|
|
5
|
+
interface sendWebhookProps {
|
|
6
|
+
title: string;
|
|
7
|
+
content: contentItem[];
|
|
8
|
+
webhook: string;
|
|
9
|
+
}
|
|
10
|
+
export declare const sendWarningLog: ({ title, content, webhook }: sendWebhookProps) => Promise<any>;
|
|
11
|
+
export {};
|