@lxlib/seed
Version:
This library was generated with [Angular CLI](https://github.com/angular/angular-cli) version 9.1.1.
206 lines (199 loc) • 5.86 kB
JavaScript
import { __assign, __decorate, __metadata, __spread } from 'tslib';
import { Injectable, ɵɵdefineInjectable, Directive, ElementRef, Input, NgModule } from '@angular/core';
import { InputNumber, LxlibUtilModule } from '@lxlib/util';
import { CommonModule } from '@angular/common';
/**
* @fileoverview added by tsickle
* Generated from: image.config.ts
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
var ImageConfig = /** @class */ (function () {
function ImageConfig() {
/**
* 默认大小,默认值:`64`,单位:px
*/
this.size = 64;
/**
* 错误图片
*/
this.error = './assets/img/logo.svg';
}
ImageConfig.decorators = [
{ type: Injectable, args: [{ providedIn: 'root' },] }
];
/** @nocollapse */ ImageConfig.ɵprov = ɵɵdefineInjectable({ factory: function ImageConfig_Factory() { return new ImageConfig(); }, token: ImageConfig, providedIn: "root" });
return ImageConfig;
}());
if (false) {
/**
* 默认大小,默认值:`64`,单位:px
* @type {?}
*/
ImageConfig.prototype.size;
/**
* 错误图片
* @type {?}
*/
ImageConfig.prototype.error;
}
/**
* @fileoverview added by tsickle
* Generated from: image.directive.ts
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
/**
* img标签
* + 支持微信、qq头像规则缩略图规则
* + 支持移除http&https协议http
* + 支持增加onerror事件
*/
var ImageDirective = /** @class */ (function () {
function ImageDirective(cog, el) {
this.size = 64;
this.error = './assets/img/logo.svg';
this.inited = false;
Object.assign(this, __assign(__assign({}, new ImageConfig()), cog));
this.imgEl = el.nativeElement;
}
/**
* @return {?}
*/
ImageDirective.prototype.ngOnInit = /**
* @return {?}
*/
function () {
this.update();
this.updateError();
this.inited = true;
};
/**
* @param {?} changes
* @return {?}
*/
ImageDirective.prototype.ngOnChanges = /**
* @param {?} changes
* @return {?}
*/
function (changes) {
if (!this.inited)
return;
if (changes.error) {
this.updateError();
}
this.update();
};
/**
* @private
* @return {?}
*/
ImageDirective.prototype.update = /**
* @private
* @return {?}
*/
function () {
/** @type {?} */
var newSrc = this.src;
var _a = this, size = _a.size, imgEl = _a.imgEl;
if (newSrc.includes('qlogo.cn')) {
/** @type {?} */
var arr = newSrc.split('/');
/** @type {?} */
var imgSize = arr[arr.length - 1];
arr[arr.length - 1] = imgSize === '0' || +imgSize !== size ? size.toString() : imgSize;
newSrc = arr.join('/');
}
newSrc = newSrc.replace(/^(?:https?:)/i, '');
imgEl.src = newSrc;
imgEl.height = size;
imgEl.width = size;
};
/**
* @private
* @return {?}
*/
ImageDirective.prototype.updateError = /**
* @private
* @return {?}
*/
function () {
var _a = this, imgEl = _a.imgEl, error = _a.error;
// tslint:disable-next-line: only-arrow-functions
imgEl.onerror = (/**
* @return {?}
*/
function () {
this.onerror = null;
this.src = error;
});
};
ImageDirective.decorators = [
{ type: Directive, args: [{
selector: '[_src]',
exportAs: '_src',
},] }
];
/** @nocollapse */
ImageDirective.ctorParameters = function () { return [
{ type: ImageConfig },
{ type: ElementRef }
]; };
ImageDirective.propDecorators = {
src: [{ type: Input, args: ['_src',] }],
size: [{ type: Input }],
error: [{ type: Input }]
};
__decorate([
InputNumber(),
__metadata("design:type", Object)
], ImageDirective.prototype, "size", void 0);
return ImageDirective;
}());
if (false) {
/** @type {?} */
ImageDirective.prototype.src;
/** @type {?} */
ImageDirective.prototype.size;
/** @type {?} */
ImageDirective.prototype.error;
/**
* @type {?}
* @private
*/
ImageDirective.prototype.inited;
/**
* @type {?}
* @private
*/
ImageDirective.prototype.imgEl;
}
/**
* @fileoverview added by tsickle
* Generated from: image.module.ts
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
/** @type {?} */
var DIRECTIVES = [ImageDirective];
var ImageModule = /** @class */ (function () {
function ImageModule() {
}
ImageModule.decorators = [
{ type: NgModule, args: [{
imports: [CommonModule, LxlibUtilModule],
declarations: __spread(DIRECTIVES),
exports: __spread(DIRECTIVES),
},] }
];
return ImageModule;
}());
/**
* @fileoverview added by tsickle
* Generated from: public_api.ts
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
/**
* @fileoverview added by tsickle
* Generated from: image.ts
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
export { ImageConfig, ImageDirective, ImageModule };
//# sourceMappingURL=image.js.map