miniapp-web-jsapi
Version:
JSAPI/View adapter for miniprogram running on the web
33 lines • 1.21 kB
JavaScript
import { asyncRun } from "../../../common";
import { getWebQueryParams } from "../..";
import { getAppId, getSiteName } from "../../utils/web-utils";
export function getAppIdSync() {
return getAppId() || '';
}
export function getLaunchOptionsSync() {
return getWebQueryParams();
}
export function getSiteInfo(options) {
var success = options.success,
fail = options.fail,
complete = options.complete;
asyncRun(function () {
var siteName = getSiteName();
if (siteName && siteName.length) {
success === null || success === void 0 ? void 0 : success({
siteName: siteName
});
} else {
fail === null || fail === void 0 ? void 0 : fail(new Error('siteName is empty!'));
}
complete === null || complete === void 0 ? void 0 : complete();
});
}
export function setNavigationBar(options) {
var _options$success, _options$complete;
if (options.title != null) {
document.title = options.title;
}
(_options$success = options.success) === null || _options$success === void 0 ? void 0 : _options$success.call(options);
(_options$complete = options.complete) === null || _options$complete === void 0 ? void 0 : _options$complete.call(options);
}