@lxlib/theme
Version:
This library was generated with [Angular CLI](https://github.com/angular/angular-cli) version 9.1.1.
1,423 lines (1,388 loc) • 170 kB
JavaScript
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('@lxlib/acl'), require('rxjs'), require('rxjs/operators'), require('@angular/common'), require('@angular/platform-browser'), require('@angular/router'), require('@lxlib/util'), require('ng-zorro-antd/modal'), require('ng-zorro-antd/drawer'), require('@angular/common/http'), require('date-fns/format'), require('date-fns/formatDistanceToNow'), require('date-fns/parse'), require('ng-zorro-antd/i18n'), require('@angular/cdk/overlay'), require('@ant-design/icons-angular/icons'), require('ng-zorro-antd/icon')) :
typeof define === 'function' && define.amd ? define('@lxlib/theme', ['exports', '@angular/core', '@lxlib/acl', 'rxjs', 'rxjs/operators', '@angular/common', '@angular/platform-browser', '@angular/router', '@lxlib/util', 'ng-zorro-antd/modal', 'ng-zorro-antd/drawer', '@angular/common/http', 'date-fns/format', 'date-fns/formatDistanceToNow', 'date-fns/parse', 'ng-zorro-antd/i18n', '@angular/cdk/overlay', '@ant-design/icons-angular/icons', 'ng-zorro-antd/icon'], factory) :
(global = global || self, factory((global.lxlib = global.lxlib || {}, global.lxlib.theme = {}), global.ng.core, global.lxlib.acl, global.rxjs, global.rxjs.operators, global.ng.common, global.ng.platformBrowser, global.ng.router, global.lxlib.util, global['ng-zorro-antd/modal'], global['ng-zorro-antd/drawer'], global.ng.common.http, global.format, global.formatDistanceToNow, global.parse, global['ng-zorro-antd/i18n'], global.ng.cdk.overlay, global.icons, global['ng-zorro-antd/icon']));
}(this, (function (exports, core, acl, rxjs, operators, common, platformBrowser, router, util, modal, drawer, http, format, formatDistanceToNow, parse, i18n, overlay, icons, icon) { 'use strict';
format = format && Object.prototype.hasOwnProperty.call(format, 'default') ? format['default'] : format;
formatDistanceToNow = formatDistanceToNow && Object.prototype.hasOwnProperty.call(formatDistanceToNow, 'default') ? formatDistanceToNow['default'] : formatDistanceToNow;
parse = parse && Object.prototype.hasOwnProperty.call(parse, 'default') ? parse['default'] : parse;
/*! *****************************************************************************
Copyright (c) Microsoft Corporation. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
this file except in compliance with the License. You may obtain a copy of the
License at http://www.apache.org/licenses/LICENSE-2.0
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
MERCHANTABLITY OR NON-INFRINGEMENT.
See the Apache Version 2.0 License for specific language governing permissions
and limitations under the License.
***************************************************************************** */
/* global Reflect, Promise */
var extendStatics = function(d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
function __extends(d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
}
var __assign = function() {
__assign = Object.assign || function __assign(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
function __rest(s, e) {
var t = {};
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
t[p] = s[p];
if (s != null && typeof Object.getOwnPropertySymbols === "function")
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
t[p[i]] = s[p[i]];
}
return t;
}
function __decorate(decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
}
function __param(paramIndex, decorator) {
return function (target, key) { decorator(target, key, paramIndex); }
}
function __metadata(metadataKey, metadataValue) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
}
function __awaiter(thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
}
function __generator(thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (_) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
}
function __exportStar(m, exports) {
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
}
function __values(o) {
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
if (m) return m.call(o);
if (o && typeof o.length === "number") return {
next: function () {
if (o && i >= o.length) o = void 0;
return { value: o && o[i++], done: !o };
}
};
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
}
function __read(o, n) {
var m = typeof Symbol === "function" && o[Symbol.iterator];
if (!m) return o;
var i = m.call(o), r, ar = [], e;
try {
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
}
catch (error) { e = { error: error }; }
finally {
try {
if (r && !r.done && (m = i["return"])) m.call(i);
}
finally { if (e) throw e.error; }
}
return ar;
}
function __spread() {
for (var ar = [], i = 0; i < arguments.length; i++)
ar = ar.concat(__read(arguments[i]));
return ar;
}
function __spreadArrays() {
for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
for (var r = Array(s), k = 0, i = 0; i < il; i++)
for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
r[k] = a[j];
return r;
};
function __await(v) {
return this instanceof __await ? (this.v = v, this) : new __await(v);
}
function __asyncGenerator(thisArg, _arguments, generator) {
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
var g = generator.apply(thisArg, _arguments || []), i, q = [];
return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
function fulfill(value) { resume("next", value); }
function reject(value) { resume("throw", value); }
function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
}
function __asyncDelegator(o) {
var i, p;
return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; } : f; }
}
function __asyncValues(o) {
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
var m = o[Symbol.asyncIterator], i;
return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
}
function __makeTemplateObject(cooked, raw) {
if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
return cooked;
};
function __importStar(mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
result.default = mod;
return result;
}
function __importDefault(mod) {
return (mod && mod.__esModule) ? mod : { default: mod };
}
function __classPrivateFieldGet(receiver, privateMap) {
if (!privateMap.has(receiver)) {
throw new TypeError("attempted to get private field on non-instance");
}
return privateMap.get(receiver);
}
function __classPrivateFieldSet(receiver, privateMap, value) {
if (!privateMap.has(receiver)) {
throw new TypeError("attempted to set private field on non-instance");
}
privateMap.set(receiver, value);
return value;
}
/**
* @fileoverview added by tsickle
* Generated from: src/win_tokens.ts
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
/**
* @return {?}
*/
function WINDOW_FACTORY() {
return window;
}
/** @type {?} */
var WINDOW = new core.InjectionToken('Window', {
providedIn: 'root',
factory: WINDOW_FACTORY,
});
/**
* @fileoverview added by tsickle
* Generated from: src/services/preloader/preloader.ts
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
/**
* @return {?}
*/
function preloaderFinished() {
/** @type {?} */
var body = (/** @type {?} */ (document.querySelector('body')));
/** @type {?} */
var preloader = (/** @type {?} */ (document.querySelector('.preloader')));
body.style.overflow = 'hidden';
/**
* @return {?}
*/
function remove() {
// preloader value null when running --hmr
if (!preloader)
return;
preloader.addEventListener('transitionend', (/**
* @return {?}
*/
function () {
preloader.className = 'preloader-hidden';
}));
preloader.className += ' preloader-hidden-add preloader-hidden-add-active';
}
((/** @type {?} */ (window))).appBootstrap = (/**
* @return {?}
*/
function () {
setTimeout((/**
* @return {?}
*/
function () {
remove();
body.style.overflow = '';
}), 100);
});
}
/**
* @fileoverview added by tsickle
* Generated from: src/services/menu/interface.ts
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
/**
* @record
*/
function MenuIcon() { }
if (false) {
/**
* Type for icon
* @type {?}
*/
MenuIcon.prototype.type;
/**
* Value for the icon, can be set Class Name, nz-icon of `nzType`, image
* @type {?|undefined}
*/
MenuIcon.prototype.value;
/**
* Type of the ant design icon, default: `outline`
* @type {?|undefined}
*/
MenuIcon.prototype.theme;
/**
* Rotate icon with animation, default: `false`
* @type {?|undefined}
*/
MenuIcon.prototype.spin;
/**
* Only support the two-tone icon. Specific the primary color
* @type {?|undefined}
*/
MenuIcon.prototype.twoToneColor;
/**
* Type of the icon from iconfont
* @type {?|undefined}
*/
MenuIcon.prototype.iconfont;
}
/**
* @record
*/
function Menu() { }
if (false) {
/**
* Text of menu item, can be choose one of `text` or `i18n` (Support HTML)
* @type {?|undefined}
*/
Menu.prototype.text;
/**
* I18n key of menu item, can be choose one of `text` or `i18n` (Support HTML)
* @type {?|undefined}
*/
Menu.prototype.i18n;
/**
* Whether to display the group name, default: `true`
* @type {?|undefined}
*/
Menu.prototype.group;
/**
* Routing for the menu item, can be choose one of `link` or `externalLink`
* @type {?|undefined}
*/
Menu.prototype.link;
/**
* External link for the menu item, can be choose one of `link` or `externalLink`
* @type {?|undefined}
*/
Menu.prototype.externalLink;
/**
* Specifies `externalLink` where to display the linked URL
* @type {?|undefined}
*/
Menu.prototype.target;
/**
* Icon for the menu item, only valid for the first level menu
* @type {?|undefined}
*/
Menu.prototype.icon;
/**
* Badget for the menu item when `group` is `true`
* @type {?|undefined}
*/
Menu.prototype.badge;
/**
* Whether to display a red dot instead of `badge` value
* @type {?|undefined}
*/
Menu.prototype.badgeDot;
/**
* Badge [color](https://ng.ant.design/components/badge/en#nz-badge)
* @type {?|undefined}
*/
Menu.prototype.badgeStatus;
/**
* Whether disable for the menu item
* @type {?|undefined}
*/
Menu.prototype.disabled;
/**
* Whether hidden for the menu item
* @type {?|undefined}
*/
Menu.prototype.hide;
/**
* Whether hide in breadcrumbs, which are valid when the `page-header` component automatically generates breadcrumbs
* @type {?|undefined}
*/
Menu.prototype.hideInBreadcrumb;
/**
* ACL configuration, it's equivalent to `ACLService.can(roleOrAbility: ACLCanType)` parameter value
* @type {?|undefined}
*/
Menu.prototype.acl;
/**
* Whether shortcut menu item
* @type {?|undefined}
*/
Menu.prototype.shortcut;
/**
* Wheter shortcut menu root node
* @type {?|undefined}
*/
Menu.prototype.shortcutRoot;
/**
* Whether to allow reuse, need to cooperate with the `reuse-tab` component
* @type {?|undefined}
*/
Menu.prototype.reuse;
/**
* Whether to expand, when `checkStrictly` is valid in `sidebar-nav` component
* @type {?|undefined}
*/
Menu.prototype.open;
/**
* Unique identifier of the menu item, can be used in `getItem`,` setItem` to update a menu
* @type {?|undefined}
*/
Menu.prototype.key;
/**
* Children menu of menu item
* @type {?|undefined}
*/
Menu.prototype.children;
/* Skipping unhandled member: [key: string]: any;*/
}
/**
* @fileoverview added by tsickle
* Generated from: src/services/i18n/i18n.ts
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
/**
* @record
*/
function LxlibI18NService() { }
if (false) {
/**
* 调用 `use` 触发变更通知
* @type {?}
*/
LxlibI18NService.prototype.change;
/* Skipping unhandled member: [key: string]: any;*/
/**
* 变更语言
* @param {?} lang 语言代码
* @param {?=} emit 是否触发 `change`,默认:true
* @return {?}
*/
LxlibI18NService.prototype.use = function (lang, emit) { };
/**
* 返回当前语言列表
* @return {?}
*/
LxlibI18NService.prototype.getLangs = function () { };
/**
* 翻译
* - `params` 模板所需要的参数对象
* - `isSafe` 是否返回安全字符,自动调用 `bypassSecurityTrustHtml`
* @param {?} key
* @param {?=} params
* @param {?=} isSafe
* @return {?}
*/
LxlibI18NService.prototype.fanyi = function (key, params, isSafe) { };
}
/** @type {?} */
var LXLIB_I18N_TOKEN = new core.InjectionToken('lxlibTranslatorToken', {
providedIn: 'root',
factory: LXLIB_I18N_TOKEN_FACTORY,
});
/**
* @return {?}
*/
function LXLIB_I18N_TOKEN_FACTORY() {
return new LxlibI18NServiceFake();
}
var LxlibI18NServiceFake = /** @class */ (function () {
function LxlibI18NServiceFake() {
this.change$ = new rxjs.BehaviorSubject(null);
}
Object.defineProperty(LxlibI18NServiceFake.prototype, "change", {
get: /**
* @return {?}
*/
function () {
return (/** @type {?} */ (this.change$.asObservable().pipe(operators.filter((/**
* @param {?} w
* @return {?}
*/
function (w) { return w != null; })))));
},
enumerable: true,
configurable: true
});
/**
* @param {?} lang
* @return {?}
*/
LxlibI18NServiceFake.prototype.use = /**
* @param {?} lang
* @return {?}
*/
function (lang) {
this.change$.next(lang);
};
/**
* @return {?}
*/
LxlibI18NServiceFake.prototype.getLangs = /**
* @return {?}
*/
function () {
return [];
};
/**
* @param {?} key
* @return {?}
*/
LxlibI18NServiceFake.prototype.fanyi = /**
* @param {?} key
* @return {?}
*/
function (key) {
return key;
};
LxlibI18NServiceFake.decorators = [
{ type: core.Injectable, args: [{ providedIn: 'root' },] }
];
/** @nocollapse */ LxlibI18NServiceFake.ɵprov = core.ɵɵdefineInjectable({ factory: function LxlibI18NServiceFake_Factory() { return new LxlibI18NServiceFake(); }, token: LxlibI18NServiceFake, providedIn: "root" });
return LxlibI18NServiceFake;
}());
if (false) {
/**
* @type {?}
* @private
*/
LxlibI18NServiceFake.prototype.change$;
}
/**
* @fileoverview added by tsickle
* Generated from: src/services/menu/menu.service.ts
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
/**
* 菜单服务,[在线文档](https://ng-alain.com/theme/menu)
*/
var MenuService = /** @class */ (function () {
function MenuService(i18nSrv, aclService) {
var _this = this;
this.i18nSrv = i18nSrv;
this.aclService = aclService;
this._change$ = new rxjs.BehaviorSubject([]);
this.data = [];
this.i18n$ = this.i18nSrv.change.subscribe((/**
* @return {?}
*/
function () { return _this.resume(); }));
}
Object.defineProperty(MenuService.prototype, "change", {
get: /**
* @return {?}
*/
function () {
return this._change$.pipe(operators.share());
},
enumerable: true,
configurable: true
});
/**
* @param {?} data
* @param {?} callback
* @return {?}
*/
MenuService.prototype.visit = /**
* @param {?} data
* @param {?} callback
* @return {?}
*/
function (data, callback) {
/** @type {?} */
var inFn = (/**
* @param {?} list
* @param {?} parentMenu
* @param {?} depth
* @return {?}
*/
function (list, parentMenu, depth) {
var e_1, _a;
try {
for (var list_1 = __values(list), list_1_1 = list_1.next(); !list_1_1.done; list_1_1 = list_1.next()) {
var item = list_1_1.value;
callback(item, parentMenu, depth);
if (item.children && item.children.length > 0) {
inFn(item.children, item, depth + 1);
}
else {
item.children = [];
}
}
}
catch (e_1_1) { e_1 = { error: e_1_1 }; }
finally {
try {
if (list_1_1 && !list_1_1.done && (_a = list_1.return)) _a.call(list_1);
}
finally { if (e_1) throw e_1.error; }
}
});
inFn(data, null, 0);
};
/**
* @param {?} items
* @return {?}
*/
MenuService.prototype.add = /**
* @param {?} items
* @return {?}
*/
function (items) {
this.data = items;
this.resume();
};
/**
* 重置菜单,可能I18N、用户权限变动时需要调用刷新
*/
/**
* 重置菜单,可能I18N、用户权限变动时需要调用刷新
* @param {?=} callback
* @return {?}
*/
MenuService.prototype.resume = /**
* 重置菜单,可能I18N、用户权限变动时需要调用刷新
* @param {?=} callback
* @return {?}
*/
function (callback) {
var _this = this;
/** @type {?} */
var i = 1;
/** @type {?} */
var shortcuts = [];
this.visit(this.data, (/**
* @param {?} item
* @param {?} parent
* @param {?} depth
* @return {?}
*/
function (item, parent, depth) {
item.__id = i++;
item.__parent = parent;
item._depth = depth;
if (!item.link)
item.link = '';
if (!item.externalLink)
item.externalLink = '';
// badge
if (item.badge) {
if (item.badgeDot !== true) {
item.badgeDot = false;
}
if (!item.badgeStatus) {
item.badgeStatus = 'error';
}
}
item._type = item.externalLink ? 2 : 1;
if (item.children && item.children.length > 0) {
item._type = 3;
}
// icon
if (typeof item.icon === 'string') {
/** @type {?} */
var type = 'class';
/** @type {?} */
var value = item.icon;
// compatible `anticon anticon-user`
if (~item.icon.indexOf("anticon-")) {
type = 'icon';
value = value.split('-').slice(1).join('-');
}
else if (/^https?:\/\//.test(item.icon)) {
type = 'img';
}
item.icon = (/** @type {?} */ ({ type: type, value: value }));
}
if (item.icon != null) {
item.icon = __assign({ theme: 'outline', spin: false }, ((/** @type {?} */ (item.icon))));
}
item.text = item.i18n && _this.i18nSrv ? _this.i18nSrv.fanyi(item.i18n) : item.text;
// group
item.group = item.group !== false;
// hidden
item._hidden = typeof item.hide === 'undefined' ? false : item.hide;
// disabled
item.disabled = typeof item.disabled === 'undefined' ? false : item.disabled;
// acl
item._aclResult = item.acl && _this.aclService ? _this.aclService.can(item.acl) : true;
// shortcut
if (parent && item.shortcut === true && parent.shortcutRoot !== true) {
shortcuts.push(item);
}
if (callback)
callback(item, parent, depth);
}));
this.loadShortcut(shortcuts);
this._change$.next(this.data);
};
/**
* 加载快捷菜单,加载位置规则如下:
* 1、统一在下标0的节点下(即【主导航】节点下方)
* 1、若 children 存在 【shortcutRoot: true】则最优先【推荐】这种方式
* 2、否则查找带有【dashboard】字样链接,若存在则在此菜单的下方创建快捷入口
* 3、否则放在0节点位置
*/
/**
* 加载快捷菜单,加载位置规则如下:
* 1、统一在下标0的节点下(即【主导航】节点下方)
* 1、若 children 存在 【shortcutRoot: true】则最优先【推荐】这种方式
* 2、否则查找带有【dashboard】字样链接,若存在则在此菜单的下方创建快捷入口
* 3、否则放在0节点位置
* @private
* @param {?} shortcuts
* @return {?}
*/
MenuService.prototype.loadShortcut = /**
* 加载快捷菜单,加载位置规则如下:
* 1、统一在下标0的节点下(即【主导航】节点下方)
* 1、若 children 存在 【shortcutRoot: true】则最优先【推荐】这种方式
* 2、否则查找带有【dashboard】字样链接,若存在则在此菜单的下方创建快捷入口
* 3、否则放在0节点位置
* @private
* @param {?} shortcuts
* @return {?}
*/
function (shortcuts) {
if (shortcuts.length === 0 || this.data.length === 0) {
return;
}
/** @type {?} */
var ls = (/** @type {?} */ (this.data[0].children));
/** @type {?} */
var pos = ls.findIndex((/**
* @param {?} w
* @return {?}
*/
function (w) { return w.shortcutRoot === true; }));
if (pos === -1) {
pos = ls.findIndex((/**
* @param {?} w
* @return {?}
*/
function (w) { return (/** @type {?} */ (w.link)).includes('dashboard'); }));
pos = (pos !== -1 ? pos : -1) + 1;
/** @type {?} */
var shortcutMenu = (/** @type {?} */ ({
text: '快捷菜单',
i18n: 'shortcut',
icon: 'icon-rocket',
children: [],
}));
(/** @type {?} */ (this.data[0].children)).splice(pos, 0, shortcutMenu);
}
/** @type {?} */
var _data = (/** @type {?} */ (this.data[0].children))[pos];
if (_data.i18n && this.i18nSrv)
_data.text = this.i18nSrv.fanyi(_data.i18n);
// tslint:disable-next-line:prefer-object-spread
_data = Object.assign(_data, {
shortcutRoot: true,
__id: -1,
__parent: null,
_type: 3,
_depth: 1,
});
_data.children = shortcuts.map((/**
* @param {?} i
* @return {?}
*/
function (i) {
i._depth = 2;
i.__parent = _data;
return i;
}));
};
Object.defineProperty(MenuService.prototype, "menus", {
get: /**
* @return {?}
*/
function () {
return this.data;
},
enumerable: true,
configurable: true
});
/**
* 清空菜单
*/
/**
* 清空菜单
* @return {?}
*/
MenuService.prototype.clear = /**
* 清空菜单
* @return {?}
*/
function () {
this.data = [];
this._change$.next(this.data);
};
/**
* @param {?} data
* @param {?} url
* @param {?=} recursive
* @param {?=} cb
* @return {?}
*/
MenuService.prototype.getHit = /**
* @param {?} data
* @param {?} url
* @param {?=} recursive
* @param {?=} cb
* @return {?}
*/
function (data, url, recursive, cb) {
if (recursive === void 0) { recursive = false; }
if (cb === void 0) { cb = null; }
/** @type {?} */
var item = null;
while (!item && url) {
this.visit(data, (/**
* @param {?} i
* @return {?}
*/
function (i) {
if (cb) {
cb(i);
}
if (i.link != null && i.link === url) {
item = i;
}
}));
if (!recursive)
break;
if (url.includes('?')) {
url = url.split('?')[0];
}
else {
url = url.split('/').slice(0, -1).join('/');
}
}
return item;
};
/**
* 根据URL设置菜单 `_open` 属性
* - 若 `recursive: true` 则会自动向上递归查找
* - 菜单数据源包含 `/ware`,则 `/ware/1` 也视为 `/ware` 项
*/
/**
* 根据URL设置菜单 `_open` 属性
* - 若 `recursive: true` 则会自动向上递归查找
* - 菜单数据源包含 `/ware`,则 `/ware/1` 也视为 `/ware` 项
* @param {?} url
* @param {?=} recursive
* @return {?}
*/
MenuService.prototype.openedByUrl = /**
* 根据URL设置菜单 `_open` 属性
* - 若 `recursive: true` 则会自动向上递归查找
* - 菜单数据源包含 `/ware`,则 `/ware/1` 也视为 `/ware` 项
* @param {?} url
* @param {?=} recursive
* @return {?}
*/
function (url, recursive) {
if (recursive === void 0) { recursive = false; }
if (!url)
return;
/** @type {?} */
var findItem = this.getHit(this.data, url, recursive, (/**
* @param {?} i
* @return {?}
*/
function (i) {
i._selected = false;
i._open = false;
}));
if (findItem == null)
return;
do {
findItem._selected = true;
findItem._open = true;
findItem = findItem.__parent;
} while (findItem);
};
/**
* 根据url获取菜单列表
* - 若 `recursive: true` 则会自动向上递归查找
* - 菜单数据源包含 `/ware`,则 `/ware/1` 也视为 `/ware` 项
*/
/**
* 根据url获取菜单列表
* - 若 `recursive: true` 则会自动向上递归查找
* - 菜单数据源包含 `/ware`,则 `/ware/1` 也视为 `/ware` 项
* @param {?} url
* @param {?=} recursive
* @return {?}
*/
MenuService.prototype.getPathByUrl = /**
* 根据url获取菜单列表
* - 若 `recursive: true` 则会自动向上递归查找
* - 菜单数据源包含 `/ware`,则 `/ware/1` 也视为 `/ware` 项
* @param {?} url
* @param {?=} recursive
* @return {?}
*/
function (url, recursive) {
if (recursive === void 0) { recursive = false; }
/** @type {?} */
var ret = [];
/** @type {?} */
var item = this.getHit(this.data, url, recursive);
if (!item)
return ret;
do {
ret.splice(0, 0, item);
item = item.__parent;
} while (item);
return ret;
};
/**
* Get menu based on `key`
*/
/**
* Get menu based on `key`
* @param {?} key
* @return {?}
*/
MenuService.prototype.getItem = /**
* Get menu based on `key`
* @param {?} key
* @return {?}
*/
function (key) {
/** @type {?} */
var res = null;
this.visit(this.data, (/**
* @param {?} item
* @return {?}
*/
function (item) {
if (res == null && item.key === key) {
res = item;
}
}));
return res;
};
/**
* Set menu based on `key`
*/
/**
* Set menu based on `key`
* @param {?} key
* @param {?} value
* @return {?}
*/
MenuService.prototype.setItem = /**
* Set menu based on `key`
* @param {?} key
* @param {?} value
* @return {?}
*/
function (key, value) {
/** @type {?} */
var item = this.getItem(key);
if (item == null)
return;
Object.keys(value).forEach((/**
* @param {?} k
* @return {?}
*/
function (k) {
item[k] = value[k];
}));
this._change$.next(this.data);
};
/**
* @return {?}
*/
MenuService.prototype.ngOnDestroy = /**
* @return {?}
*/
function () {
this._change$.unsubscribe();
this.i18n$.unsubscribe();
};
MenuService.decorators = [
{ type: core.Injectable, args: [{ providedIn: 'root' },] }
];
/** @nocollapse */
MenuService.ctorParameters = function () { return [
{ type: undefined, decorators: [{ type: core.Optional }, { type: core.Inject, args: [LXLIB_I18N_TOKEN,] }] },
{ type: acl.ACLService, decorators: [{ type: core.Optional }] }
]; };
/** @nocollapse */ MenuService.ɵprov = core.ɵɵdefineInjectable({ factory: function MenuService_Factory() { return new MenuService(core.ɵɵinject(LXLIB_I18N_TOKEN, 8), core.ɵɵinject(acl.ACLService, 8)); }, token: MenuService, providedIn: "root" });
return MenuService;
}());
if (false) {
/**
* @type {?}
* @private
*/
MenuService.prototype._change$;
/**
* @type {?}
* @private
*/
MenuService.prototype.i18n$;
/**
* @type {?}
* @private
*/
MenuService.prototype.data;
/**
* @type {?}
* @private
*/
MenuService.prototype.i18nSrv;
/**
* @type {?}
* @private
*/
MenuService.prototype.aclService;
}
/**
* @fileoverview added by tsickle
* Generated from: src/services/scroll/scroll.service.ts
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
var ScrollService = /** @class */ (function () {
function ScrollService(win, doc) {
this.win = win;
this.doc = doc;
}
/**
* 获取滚动条位置
* @param element 指定元素,默认 `window`
*/
/**
* 获取滚动条位置
* @param {?=} element 指定元素,默认 `window`
* @return {?}
*/
ScrollService.prototype.getScrollPosition = /**
* 获取滚动条位置
* @param {?=} element 指定元素,默认 `window`
* @return {?}
*/
function (element) {
if (element && element !== this.win) {
return [element.scrollLeft, element.scrollTop];
}
else {
return [this.win.pageXOffset, this.win.pageYOffset];
}
};
/**
* 设置滚动条位置
* @param element 指定元素
*/
/**
* 设置滚动条位置
* @param {?} element 指定元素
* @param {?} position
* @return {?}
*/
ScrollService.prototype.scrollToPosition = /**
* 设置滚动条位置
* @param {?} element 指定元素
* @param {?} position
* @return {?}
*/
function (element, position) {
(element || this.win).scrollTo(position[0], position[1]);
};
/**
* 设置滚动条至指定元素
* @param element 指定元素,默认 `document.body`
* @param topOffset 偏移值,默认 `0`
*/
/**
* 设置滚动条至指定元素
* @param {?=} element 指定元素,默认 `document.body`
* @param {?=} topOffset 偏移值,默认 `0`
* @return {?}
*/
ScrollService.prototype.scrollToElement = /**
* 设置滚动条至指定元素
* @param {?=} element 指定元素,默认 `document.body`
* @param {?=} topOffset 偏移值,默认 `0`
* @return {?}
*/
function (element, topOffset) {
if (topOffset === void 0) { topOffset = 0; }
if (!element)
element = this.doc.body;
(/** @type {?} */ (element)).scrollIntoView();
/** @type {?} */
var w = this.win;
if (w && w.scrollBy) {
w.scrollBy(0, (/** @type {?} */ (element)).getBoundingClientRect().top - topOffset);
if (w.pageYOffset < 20) {
w.scrollBy(0, -w.pageYOffset);
}
}
};
/**
* 滚动至顶部
* @param topOffset 偏移值,默认 `0`
*/
/**
* 滚动至顶部
* @param {?=} topOffset 偏移值,默认 `0`
* @return {?}
*/
ScrollService.prototype.scrollToTop = /**
* 滚动至顶部
* @param {?=} topOffset 偏移值,默认 `0`
* @return {?}
*/
function (topOffset) {
if (topOffset === void 0) { topOffset = 0; }
this.scrollToElement(this.doc.body, topOffset);
};
ScrollService.decorators = [
{ type: core.Injectable, args: [{ providedIn: 'root' },] }
];
/** @nocollapse */
ScrollService.ctorParameters = function () { return [
{ type: undefined, decorators: [{ type: core.Inject, args: [WINDOW,] }] },
{ type: undefined, decorators: [{ type: core.Inject, args: [common.DOCUMENT,] }] }
]; };
/** @nocollapse */ ScrollService.ɵprov = core.ɵɵdefineInjectable({ factory: function ScrollService_Factory() { return new ScrollService(core.ɵɵinject(WINDOW), core.ɵɵinject(common.DOCUMENT)); }, token: ScrollService, providedIn: "root" });
return ScrollService;
}());
if (false) {
/**
* @type {?}
* @private
*/
ScrollService.prototype.win;
/**
* @type {?}
* @private
*/
ScrollService.prototype.doc;
}
/**
* @fileoverview added by tsickle
* Generated from: src/services/settings/interface.ts
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
/**
* @record
*/
function App() { }
if (false) {
/**
* Name for app
* @type {?|undefined}
*/
App.prototype.name;
/**
* Description for app
* @type {?|undefined}
*/
App.prototype.description;
/* Skipping unhandled member: [key: string]: any;*/
}
/**
* @record
*/
function User() { }
if (false) {
/**
* Name for current user
* @type {?|undefined}
*/
User.prototype.name;
/**
* Avatar for current user
* @type {?|undefined}
*/
User.prototype.avatar;
/**
* Email for current user
* @type {?|undefined}
*/
User.prototype.email;
/* Skipping unhandled member: [key: string]: any;*/
}
/**
* @record
*/
function Layout() { }
if (false) {
/**
* Whether to fold menu
* @type {?}
*/
Layout.prototype.collapsed;
/**
* Current language
* @type {?}
*/
Layout.prototype.lang;
/**
* Color weak
* @type {?}
*/
Layout.prototype.colorWeak;
/* Skipping unhandled member: [key: string]: any;*/
}
/**
* @record
*/
function Company() { }
if (false) {
/**
* 公司名称
* @type {?}
*/
Company.prototype.name;
/**
* 公司简称
* @type {?}
*/
Company.prototype.shot_name;
/* Skipping unhandled member: [key: string]: any;*/
}
/**
* @record
*/
function SettingsNotify() { }
if (false) {
/** @type {?} */
SettingsNotify.prototype.type;
/**
* Update `key` name, limited `layout` type
* @type {?|undefined}
*/
SettingsNotify.prototype.name;
/** @type {?} */
SettingsNotify.prototype.value;
}
/**
* @fileoverview added by tsickle
* Generated from: src/services/settings/settings.service.ts
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
/** @type {?} */
var LAYOUT = 'layout';
/** @type {?} */
var USER = 'user';
/** @type {?} */
var APP = 'app';
/** @type {?} */
var COMPANY = 'company';
var SettingsService = /** @class */ (function () {
function SettingsService() {
this.notify$ = new rxjs.Subject();
this._app = null;
this._user = null;
this._layout = null;
this._company = null;
}
/**
* @private
* @param {?} key
* @return {?}
*/
SettingsService.prototype.get = /**
* @private
* @param {?} key
* @return {?}
*/
function (key) {
return JSON.parse(localStorage.getItem(key) || 'null') || null;
};
/**
* @private
* @param {?} key
* @param {?} value
* @return {?}
*/
SettingsService.prototype.set = /**
* @private
* @param {?} key
* @param {?} value
* @return {?}
*/
function (key, value) {
localStorage.setItem(key, JSON.stringify(value));
};
Object.defineProperty(SettingsService.prototype, "layout", {
get: /**
* @return {?}
*/
function () {
if (!this._layout) {
this._layout = __assign({ fixed: true, collapsed: false, boxed: false, lang: null }, this.get(LAYOUT));
this.set(LAYOUT, this._layout);
}
return (/** @type {?} */ (this._layout));
},
enumerable: true,
configurable: true
});
Object.defineProperty(SettingsService.prototype, "app", {
get: /**
* @return {?}
*/
function () {
if (!this._app) {
this._app = __assign({ year: new Date().getFullYear() }, this.get(APP));
this.set(APP, this._app);
}
return (/** @type {?} */ (this._app));
},
enumerable: true,
configurable: true
});
Object.defineProperty(SettingsService.prototype, "company", {
get: /**
* @return {?}
*/
function () {
if (!this._company) {
this._company = __assign({ last_login: new Date() }, this.get(COMPANY));
this.set(COMPANY, this._company);
}
return (/** @type {?} */ (this._company));
},
enumerable: true,
configurable: true
});
Object.defineProperty(SettingsService.prototype, "user", {
get: /**
* @return {?}
*/
function () {
if (!this._user) {
this._user = __assign({}, this.get(USER));
this.set(USER, this._user);
}
return (/** @type {?} */ (this._user));
},
enumerable: true,
configurable: true
});
Object.defineProperty(SettingsService.prototype, "notify", {
get: /**
* @return {?}
*/
function () {
return this.notify$.asObservable();
},
enumerable: true,
configurable: true
});
/**
* @param {?} name
* @param {?=} value
* @return {?}
*/
SettingsService.prototype.setLayout = /**
* @param {?} name
* @param {?=} value
* @return {?}
*/
function (name, value) {
if (typeof name === 'string') {
this.layout[name] = value;
}
else {
this._layout = name;
}
this.set(LAYOUT, this._layout);
this.notify$.next((/** @type {?} */ ({ type: 'layout', name: name, value: value })));
return true;
};
/**
* @param {?} value
* @return {?}
*/
SettingsService.prototype.setApp = /**
* @param {?} value
* @return {?}
*/
function (value) {
this._app = value;
this.set(APP, value);
this.notify$.next({ type: 'app', value: value });
return true;
};
/**
* @param {?} value
* @return {?}
*/
SettingsService.prototype.setUser = /**
* @param {?} value
* @return {?}
*/
f