@hhfenpm/micro-app 1.0.0 → 1.0.1
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.esm.js +87 -1
- package/dist/index.js +87 -0
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -126,6 +126,92 @@ const initBridge = ({
|
|
|
126
126
|
});
|
|
127
127
|
};
|
|
128
128
|
|
|
129
|
+
var uiHandler = vm => ({
|
|
130
|
+
$message: (...args) => vm.$message(...args),
|
|
131
|
+
$success: msg => vm.$message.success(msg),
|
|
132
|
+
$warning: msg => vm.$message.warning(msg),
|
|
133
|
+
$error: msg => vm.$message.error(msg),
|
|
134
|
+
$notify: options => vm.$notify(options),
|
|
135
|
+
$confirm: (...args) =>
|
|
136
|
+
vm
|
|
137
|
+
.$confirm(...args)
|
|
138
|
+
.then(() => true)
|
|
139
|
+
.catch(() => false),
|
|
140
|
+
$alert: (...args) =>
|
|
141
|
+
vm
|
|
142
|
+
.$alert(...args)
|
|
143
|
+
.then(() => true)
|
|
144
|
+
.catch(() => false),
|
|
145
|
+
$prompt: (...args) =>
|
|
146
|
+
vm
|
|
147
|
+
.$prompt(...args)
|
|
148
|
+
.then(res => res.value)
|
|
149
|
+
.catch(() => null),
|
|
150
|
+
$loading: options => {
|
|
151
|
+
const loading = vm.$loading(options);
|
|
152
|
+
return () => loading.close()
|
|
153
|
+
},
|
|
154
|
+
});
|
|
155
|
+
|
|
156
|
+
const noop = () => console.warn('[bridge] electron 不可用');
|
|
157
|
+
|
|
158
|
+
const KEYS = [
|
|
159
|
+
'renderer_listen',
|
|
160
|
+
'web_send',
|
|
161
|
+
'web_send_path',
|
|
162
|
+
'show',
|
|
163
|
+
'hide',
|
|
164
|
+
'quit',
|
|
165
|
+
'showAlertDialog',
|
|
166
|
+
'closeAlertDialog',
|
|
167
|
+
'closeAlertDialogAndJump',
|
|
168
|
+
'set_bounds',
|
|
169
|
+
'get_bounds',
|
|
170
|
+
'workarea',
|
|
171
|
+
'center',
|
|
172
|
+
'maximize',
|
|
173
|
+
'unmaximize',
|
|
174
|
+
'is_maximized',
|
|
175
|
+
'minimize',
|
|
176
|
+
'open_top',
|
|
177
|
+
'close_top',
|
|
178
|
+
'update',
|
|
179
|
+
'collapse',
|
|
180
|
+
'unfold',
|
|
181
|
+
'unfoldMax',
|
|
182
|
+
'get_version',
|
|
183
|
+
];
|
|
184
|
+
|
|
185
|
+
/** @param {Object} [electron] 宿主传入的 electron 模块,无或 require 失败时传 {} */
|
|
186
|
+
function createCs(electron = {}) {
|
|
187
|
+
const base = Object.fromEntries(
|
|
188
|
+
KEYS.map(k => [k, typeof electron[k] === 'function' ? electron[k] : noop])
|
|
189
|
+
);
|
|
190
|
+
return {
|
|
191
|
+
...electron,
|
|
192
|
+
...base,
|
|
193
|
+
is_app:
|
|
194
|
+
typeof electron.is_app === 'function'
|
|
195
|
+
? electron.is_app()
|
|
196
|
+
: !!electron.is_app,
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
/**
|
|
201
|
+
* @param {() => Object} [getElectron] 返回 electron 模块,如 () => require('@/utils/electron')
|
|
202
|
+
*/
|
|
203
|
+
function createRegisterHandlers(getElectron) {
|
|
204
|
+
let electron = {};
|
|
205
|
+
try {
|
|
206
|
+
if (typeof getElectron === 'function') electron = getElectron();
|
|
207
|
+
} catch {}
|
|
208
|
+
|
|
209
|
+
return vm => ({
|
|
210
|
+
ui: uiHandler(vm),
|
|
211
|
+
cs: createCs(electron),
|
|
212
|
+
})
|
|
213
|
+
}
|
|
214
|
+
|
|
129
215
|
/**
|
|
130
216
|
* 微前端核心功能
|
|
131
217
|
* 提供模块路由映射、URL 生成、部署检测等功能
|
|
@@ -413,4 +499,4 @@ var index = {
|
|
|
413
499
|
baseSyncPlugin,
|
|
414
500
|
};
|
|
415
501
|
|
|
416
|
-
export { baseSyncPlugin, createDefaultMicroAppCore, createMicroAppCore, index as default, initBridge };
|
|
502
|
+
export { baseSyncPlugin, createDefaultMicroAppCore, createMicroAppCore, createRegisterHandlers, index as default, initBridge };
|
package/dist/index.js
CHANGED
|
@@ -130,6 +130,92 @@ const initBridge = ({
|
|
|
130
130
|
});
|
|
131
131
|
};
|
|
132
132
|
|
|
133
|
+
var uiHandler = vm => ({
|
|
134
|
+
$message: (...args) => vm.$message(...args),
|
|
135
|
+
$success: msg => vm.$message.success(msg),
|
|
136
|
+
$warning: msg => vm.$message.warning(msg),
|
|
137
|
+
$error: msg => vm.$message.error(msg),
|
|
138
|
+
$notify: options => vm.$notify(options),
|
|
139
|
+
$confirm: (...args) =>
|
|
140
|
+
vm
|
|
141
|
+
.$confirm(...args)
|
|
142
|
+
.then(() => true)
|
|
143
|
+
.catch(() => false),
|
|
144
|
+
$alert: (...args) =>
|
|
145
|
+
vm
|
|
146
|
+
.$alert(...args)
|
|
147
|
+
.then(() => true)
|
|
148
|
+
.catch(() => false),
|
|
149
|
+
$prompt: (...args) =>
|
|
150
|
+
vm
|
|
151
|
+
.$prompt(...args)
|
|
152
|
+
.then(res => res.value)
|
|
153
|
+
.catch(() => null),
|
|
154
|
+
$loading: options => {
|
|
155
|
+
const loading = vm.$loading(options);
|
|
156
|
+
return () => loading.close()
|
|
157
|
+
},
|
|
158
|
+
});
|
|
159
|
+
|
|
160
|
+
const noop = () => console.warn('[bridge] electron 不可用');
|
|
161
|
+
|
|
162
|
+
const KEYS = [
|
|
163
|
+
'renderer_listen',
|
|
164
|
+
'web_send',
|
|
165
|
+
'web_send_path',
|
|
166
|
+
'show',
|
|
167
|
+
'hide',
|
|
168
|
+
'quit',
|
|
169
|
+
'showAlertDialog',
|
|
170
|
+
'closeAlertDialog',
|
|
171
|
+
'closeAlertDialogAndJump',
|
|
172
|
+
'set_bounds',
|
|
173
|
+
'get_bounds',
|
|
174
|
+
'workarea',
|
|
175
|
+
'center',
|
|
176
|
+
'maximize',
|
|
177
|
+
'unmaximize',
|
|
178
|
+
'is_maximized',
|
|
179
|
+
'minimize',
|
|
180
|
+
'open_top',
|
|
181
|
+
'close_top',
|
|
182
|
+
'update',
|
|
183
|
+
'collapse',
|
|
184
|
+
'unfold',
|
|
185
|
+
'unfoldMax',
|
|
186
|
+
'get_version',
|
|
187
|
+
];
|
|
188
|
+
|
|
189
|
+
/** @param {Object} [electron] 宿主传入的 electron 模块,无或 require 失败时传 {} */
|
|
190
|
+
function createCs(electron = {}) {
|
|
191
|
+
const base = Object.fromEntries(
|
|
192
|
+
KEYS.map(k => [k, typeof electron[k] === 'function' ? electron[k] : noop])
|
|
193
|
+
);
|
|
194
|
+
return {
|
|
195
|
+
...electron,
|
|
196
|
+
...base,
|
|
197
|
+
is_app:
|
|
198
|
+
typeof electron.is_app === 'function'
|
|
199
|
+
? electron.is_app()
|
|
200
|
+
: !!electron.is_app,
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
/**
|
|
205
|
+
* @param {() => Object} [getElectron] 返回 electron 模块,如 () => require('@/utils/electron')
|
|
206
|
+
*/
|
|
207
|
+
function createRegisterHandlers(getElectron) {
|
|
208
|
+
let electron = {};
|
|
209
|
+
try {
|
|
210
|
+
if (typeof getElectron === 'function') electron = getElectron();
|
|
211
|
+
} catch {}
|
|
212
|
+
|
|
213
|
+
return vm => ({
|
|
214
|
+
ui: uiHandler(vm),
|
|
215
|
+
cs: createCs(electron),
|
|
216
|
+
})
|
|
217
|
+
}
|
|
218
|
+
|
|
133
219
|
/**
|
|
134
220
|
* 微前端核心功能
|
|
135
221
|
* 提供模块路由映射、URL 生成、部署检测等功能
|
|
@@ -420,5 +506,6 @@ var index = {
|
|
|
420
506
|
exports.baseSyncPlugin = baseSyncPlugin;
|
|
421
507
|
exports.createDefaultMicroAppCore = createDefaultMicroAppCore;
|
|
422
508
|
exports.createMicroAppCore = createMicroAppCore;
|
|
509
|
+
exports.createRegisterHandlers = createRegisterHandlers;
|
|
423
510
|
exports.default = index;
|
|
424
511
|
exports.initBridge = initBridge;
|