|
@@ -115,12 +115,14 @@ export class SImageItem extends SObjectItem {
|
|
|
/\(i[^;]+;( U;)? CPU.+Mac OS X/
|
|
|
); //ios终端
|
|
|
try {
|
|
|
+ // ios终端
|
|
|
if (isiOS) {
|
|
|
this.isLoadOver = true;
|
|
|
this.computeImgSize();
|
|
|
this.$emit("imgLoadOver");
|
|
|
this.update();
|
|
|
} else {
|
|
|
+ // 否则
|
|
|
// @ts-ignore
|
|
|
const imgSrc = e.path[0].src;
|
|
|
if (this.isUrlIdentical(imgSrc)) {
|
|
@@ -143,12 +145,14 @@ export class SImageItem extends SObjectItem {
|
|
|
try {
|
|
|
const isiOS = !!navigator.userAgent.match(
|
|
|
/\(i[^;]+;( U;)? CPU.+Mac OS X/
|
|
|
- ); //ios终端
|
|
|
+ );
|
|
|
+ // ios终端
|
|
|
if (isiOS) {
|
|
|
this.isLoadOver = false;
|
|
|
this.$emit("imgLoadOver");
|
|
|
this.update();
|
|
|
} else {
|
|
|
+ // 否则
|
|
|
// @ts-ignore
|
|
|
const imgSrc = e.path[0].src;
|
|
|
if (this.isUrlIdentical(imgSrc)) {
|
|
@@ -184,6 +188,7 @@ export class SImageItem extends SObjectItem {
|
|
|
* 根据显示模式计算图片的宽高
|
|
|
*/
|
|
|
computeImgSize(): void {
|
|
|
+ // 加载图片成功
|
|
|
if (this.isLoadOver) {
|
|
|
// 要绘制图片的宽度
|
|
|
let width = 0;
|
|
@@ -199,21 +204,28 @@ export class SImageItem extends SObjectItem {
|
|
|
let imgHwRatio: number =
|
|
|
// @ts-ignore
|
|
|
(this.img.height as number) / (this.img.width as number);
|
|
|
+ // 图片展示类型铺满
|
|
|
if (this.showType == SImageShowType.Full) {
|
|
|
width = this.width;
|
|
|
height = this.height;
|
|
|
} else if (this.showType == SImageShowType.Equivalency) {
|
|
|
+ // 等比缩放
|
|
|
+
|
|
|
+ // 比较宽高比-图片item的高较小,以小的为准
|
|
|
if (itemAspectRatio > imgAspectRatio) {
|
|
|
height = this.height;
|
|
|
width = imgAspectRatio * height;
|
|
|
} else if (itemAspectRatio < imgAspectRatio) {
|
|
|
+ // 图片item 的宽较小
|
|
|
width = this.width;
|
|
|
height = width * imgHwRatio;
|
|
|
} else {
|
|
|
+ // 两者相等
|
|
|
width = this.width;
|
|
|
height = this.height;
|
|
|
}
|
|
|
} else if (this.showType == SImageShowType.AutoFit) {
|
|
|
+ // 图片展示类型自适应
|
|
|
// @ts-ignore
|
|
|
this.width = this.img.width as number;
|
|
|
// @ts-ignore
|
|
@@ -237,12 +249,15 @@ export class SImageItem extends SObjectItem {
|
|
|
* @return 当前地址和回调地址是否相同
|
|
|
*/
|
|
|
private isUrlIdentical(imgUrl: string): boolean {
|
|
|
+ // 如果 url 包含该符号
|
|
|
if (this.url.indexOf("://") == -1) {
|
|
|
// eslint-disable-next-line max-len
|
|
|
const reg = /^\s*data:([a-z]+\/[a-z0-9-+.]+(;[a-z-]+=[a-z0-9-]+)?)?(;base64)?,([a-z0-9!$&',()*+;=\-._~:@\/?%\s]*?)\s*$/i;
|
|
|
if (reg.test(this.url)) {
|
|
|
+ // base64 格式
|
|
|
return this.url == imgUrl;
|
|
|
} else {
|
|
|
+ // 否则
|
|
|
return this.url == this.GetUrlRelativePath(imgUrl);
|
|
|
}
|
|
|
} else {
|
|
@@ -295,6 +310,7 @@ export class SImageItem extends SObjectItem {
|
|
|
*/
|
|
|
onDraw(painter: SPainter): void {
|
|
|
painter.translate(-this.origin.x, -this.origin.y);
|
|
|
+ // 图片加载成功
|
|
|
if (this.isLoadOver) {
|
|
|
// @ts-ignore
|
|
|
painter.drawImage(this.img, 0, 0, this.imgWidth, this.imgHeight);
|
|
@@ -310,12 +326,14 @@ export class SImageItem extends SObjectItem {
|
|
|
painter.shadow.shadowColor = SColor.Transparent;
|
|
|
}
|
|
|
|
|
|
+ // 虚线
|
|
|
if (this.lineStyle == SLineStyle.Dashed) {
|
|
|
painter.pen.lineDash = [
|
|
|
painter.toPx(this.lineWidth * 3),
|
|
|
painter.toPx(this.lineWidth * 7)
|
|
|
];
|
|
|
} else if (this.lineStyle == SLineStyle.Dotted) {
|
|
|
+ // 点线
|
|
|
painter.pen.lineDash = [
|
|
|
painter.toPx(2 * this.lineWidth),
|
|
|
painter.toPx(2 * this.lineWidth)
|