浏览代码

fix: 格式化

haojianlong 4 年之前
父节点
当前提交
0d2b1bc797

+ 2 - 1
persagy-web-base/.eslintrc.js

@@ -58,6 +58,7 @@ module.exports = {
         "curly": ["error", "multi-line"],               // if、else if、else、for、while强制使用大括号,但允许在单行中省略大括号。
         "semi": ["error", "always"],                    // 不得省略语句结束的分号
         "@typescript-eslint/explicit-member-accessibility": ["error", { accessibility: "no-public" }],       // public访问不需加访问修饰符
-        "@typescript-eslint/no-explicit-any": ["off"]
+        "@typescript-eslint/no-explicit-any": ["off"],
+        "@typescript-eslint/no-unused-vars": ["off"],
     }
 };

+ 13 - 13
persagy-web-base/src/SMatrix.ts

@@ -97,14 +97,14 @@ export class SMatrix {
 
     /**
      * 是否为 2D 矩阵
-    */
+     */
     get is2D(): boolean {
         return true;
     } // Get is2D
 
     /**
      * 是否为单位矩阵
-    */
+     */
     get isIdentity(): boolean {
         return (
             this.m11 == 1 &&
@@ -130,7 +130,7 @@ export class SMatrix {
      * 重置变换矩阵
      *
      * @return 返回自身
-    */
+     */
     reset(): SMatrix {
         this.m11 = 1;
         this.m21 = 0;
@@ -159,7 +159,7 @@ export class SMatrix {
      *
      * @param mat   给定的变换矩阵
      * @return 返回自身
-    */
+     */
     multiply(mat: SMatrix): SMatrix {
         [
             this.m11,
@@ -260,7 +260,7 @@ export class SMatrix {
      * @param dy    Y 轴位移
      * @param dz    Z 轴位移
      * @return 返回自身
-    */
+     */
     translate(dx: number, dy: number, dz = 0): SMatrix {
         const mat = new SMatrix();
         mat.m41 = dx;
@@ -276,7 +276,7 @@ export class SMatrix {
      * @param sx    X 轴缩放比例
      * @param sy    Y 轴缩放比例
      * @return 返回自身
-    */
+     */
     scale(sx: number, sy: number): SMatrix {
         const mat = new SMatrix();
         mat.m11 = sx;
@@ -290,7 +290,7 @@ export class SMatrix {
      *
      * @param angle     绕 Z 轴旋转角度(单位角度度)
      * @return 返回自身
-    */
+     */
     rotate(angle: number): SMatrix;
 
     /**
@@ -300,7 +300,7 @@ export class SMatrix {
      * @param rotY  绕 X 轴旋转角度(单位角度 度)
      * @param rotZ  绕 X 轴旋转角度(单位角度 度)
      * @return 返回自身
-    */
+     */
     rotate(rotX: number, rotY: number, rotZ: number): SMatrix;
 
     /**
@@ -310,7 +310,7 @@ export class SMatrix {
      * @param rotY  绕 X 轴旋转角度(单位度)
      * @param rotZ  绕 X 轴旋转角度(单位度)
      * @return 返回自身
-    */
+     */
     rotate(rotX: number, rotY?: number, rotZ?: number): SMatrix {
         const matZ = new SMatrix();
         if (rotY != undefined && rotZ != undefined) {
@@ -348,7 +348,7 @@ export class SMatrix {
      * 转置当前矩阵
      *
      * @return 返回自身
-    */
+     */
     transpose(): SMatrix {
         [this.m12, this.m21] = [this.m21, this.m12];
         [this.m13, this.m31] = [this.m31, this.m13];
@@ -365,7 +365,7 @@ export class SMatrix {
      * 返回当前矩阵的逆矩阵
      *
      * @return 当前矩阵的逆矩阵
-    */
+     */
     inversed(): SMatrix {
         const detMat = this.det();
         const d = this.value();
@@ -396,7 +396,7 @@ export class SMatrix {
      * 返回当前矩阵的伴随矩阵
      *
      * @return 当前矩阵的伴随矩阵
-    */
+     */
     det(): SMatrix {
         const m = new SMatrix();
         m.m11 =
@@ -529,7 +529,7 @@ export class SMatrix {
      * 返回当前矩阵的值
      *
      * @return 当前矩阵的值
-    */
+     */
     value(): number {
         return (
             this.m11 *

+ 1 - 1
persagy-web-base/src/SMouseEvent.ts

@@ -65,7 +65,7 @@ export class SMouseEvent {
      * 构造函数
      *
      * @param event     系统鼠标事件
-    */
+     */
     constructor(event: MouseEvent | SMouseEvent) {
         // let bbox = (this.type = event.type); //event.srcElement.getBoundingClientRect()
         this.type = event.type;

+ 2 - 2
persagy-web-base/src/SObject.ts

@@ -70,7 +70,7 @@ export class SObject {
      *
      * @param name        信息名称
      * @param receiver    信号接收者
-    */
+     */
     // eslint-disable-next-line @typescript-eslint/no-explicit-any
     disconnect(name: string, receiver: any): void {
         // @ts-ignore
@@ -98,7 +98,7 @@ export class SObject {
      *
      * @param name    事件名称
      * @param args    参数
-    */
+     */
     // eslint-disable-next-line @typescript-eslint/no-explicit-any
     $emit(name: string, ...args: any): void {
         // @ts-ignore

+ 3 - 3
persagy-web-base/src/SObjectObserver.ts

@@ -41,7 +41,7 @@ export class SObjectObserver {
      *
      * @param receiver  信号接收者
      * @param callback  回调函数
-    */
+     */
     // eslint-disable-next-line @typescript-eslint/no-explicit-any
     constructor(receiver: any, callback: Function) {
         this.receiver = receiver;
@@ -52,7 +52,7 @@ export class SObjectObserver {
      * 发送通知
      *
      * @param args  参数
-    */
+     */
     // eslint-disable-next-line @typescript-eslint/no-explicit-any
     notify(...args: any): void {
         this.callback.call(this.receiver, ...args);
@@ -63,7 +63,7 @@ export class SObjectObserver {
      *
      * @param receiver  信号接收者
      * @return 是否相同
-    */
+     */
     // eslint-disable-next-line @typescript-eslint/no-explicit-any
     compar(receiver: any): boolean {
         return receiver == this.receiver;

+ 0 - 1
persagy-web-base/src/enums/SKeyCode.ts

@@ -91,4 +91,3 @@ export enum SKeyCode {
     y = 121,
     z = 122
 } // Enum SKeyCode
-

+ 6 - 6
persagy-web-base/src/undo/SUndoCommand.ts

@@ -39,17 +39,17 @@ export abstract class SUndoCommand {
      * 构造函数
      *
      * @param  parent   指向父命令
-    */
+     */
     protected constructor(parent: SUndoCommand | null = null) {} // Constructor
 
     /**
      * undo回调
-    */
+     */
     abstract undo(): void;
 
     /**
      * redo回调
-    */
+     */
     abstract redo(): void;
 
     /**
@@ -57,21 +57,21 @@ export abstract class SUndoCommand {
      *
      * @param command     合并的命令
      * @return 成功能返回true,否则返回false
-    */
+     */
     mergeWith(command: SUndoCommand): boolean {
         return false;
     } // Function mergeWith()
 
     /**
      * 命令 ID 。如果命令不能合并,则返回 -1 。如果支持合并则返回一个正整数。
-    */
+     */
     id(): number {
         return -1;
     } // Function id()
 
     /**
      * 命令转为描述谢姐
-    */
+     */
     toString(): string {
         return "";
     } // toString()

+ 15 - 12
persagy-web-base/src/undo/SUndoStack.ts

@@ -53,9 +53,10 @@ export class SUndoStack extends SObject {
 
     /**
      * 执行 redo 操作
-    */
+     */
     redo(): void {
-        if (!this.canRedo()) { // 不能执行 redo ,直接返回
+        if (!this.canRedo()) {
+            // 不能执行 redo ,直接返回
             return;
         }
 
@@ -66,9 +67,10 @@ export class SUndoStack extends SObject {
 
     /**
      * 执行 undo 操作
-    */
+     */
     undo(): void {
-        if (!this.canUndo()) { // 不能执行 undo ,直接返回
+        if (!this.canUndo()) {
+            // 不能执行 undo ,直接返回
             return;
         }
 
@@ -81,7 +83,7 @@ export class SUndoStack extends SObject {
      * 是否可以执行 Redo 操作
      *
      * @return 可以执行,返回 true ;否则返回 false 。
-    */
+     */
     canRedo(): boolean {
         return this.index + 1 < this.cmdStack.length;
     } // Function canRedo()
@@ -90,14 +92,14 @@ export class SUndoStack extends SObject {
      * 是否可以执行 Undo 操作
      *
      * @return 可以执行,返回 true ;否则返回 false 。
-    */
+     */
     canUndo(): boolean {
         return this.index >= 0;
     } // Function canUndo()
 
     /**
      * 清空堆栈
-    */
+     */
     clear(): void {
         this.cmdStack.length = 0;
         this._index = -1;
@@ -108,9 +110,10 @@ export class SUndoStack extends SObject {
      * 返回指定索引的命令
      *
      * @param index     命令在栈中的索引
-    */
+     */
     command(index: number): SUndoCommand | null {
-        if (index < 0 || index >= this.cmdStack.length) { // 如果索引越界
+        if (index < 0 || index >= this.cmdStack.length) {
+            // 如果索引越界
             // 返回null
             return null;
         }
@@ -120,7 +123,7 @@ export class SUndoStack extends SObject {
 
     /**
      * 统计命令栈中命令的数量
-    */
+     */
     count(): number {
         return this.cmdStack.length;
     } // Function count()
@@ -129,7 +132,7 @@ export class SUndoStack extends SObject {
      * 将命令添加到命令栈
      *
      * @param cmd     被添加的命令
-    */
+     */
     push(cmd: SUndoCommand): void {
         this.cmdStack.length = this._index + 1;
         if (this._index >= 0 && cmd.mergeWith(this.cmdStack[this._index])) {
@@ -143,7 +146,7 @@ export class SUndoStack extends SObject {
 
     /**
      * 将命令堆栈转为日志(命令数组)
-    */
+     */
     toLog(): SCommandLog[] {
         let stackList: SCommandLog[] = [];
         for (let i = 0; i <= this.index; i++) {

+ 1 - 1
persagy-web-base/src/utils/SNetUtil.ts

@@ -34,7 +34,7 @@ export class SNetUtil {
      *
      * @param name  下载文件名称
      * @param url   下载url地址
-    */
+     */
     static downLoad(name: string, url: string): void {
         let oA = document.createElement("a");
         oA.download = name;

+ 3 - 3
persagy-web-base/src/utils/SStringBuilder.ts

@@ -37,7 +37,7 @@ export class SStringBuilder {
      * 构造函数
      *
      * @param msg   初始字符串
-    */
+     */
     constructor(msg?: string) {
         if (msg != undefined) {
             this.append(msg);
@@ -49,7 +49,7 @@ export class SStringBuilder {
      *
      * @param msg   追加的字符串
      * @return 字符串 builder 对象
-    */
+     */
     append(msg: string): SStringBuilder {
         this._strArray.push(msg);
         return this;
@@ -60,7 +60,7 @@ export class SStringBuilder {
      *
      * @param gap   分隔符,默认换行 (\n)
      * @return 转换后的字符串
-    */
+     */
     toString(gap: string = "\n"): string {
         return this._strArray.join(gap);
     } // Function toString()

+ 1 - 1
persagy-web-base/src/utils/SStringUtil.ts

@@ -35,7 +35,7 @@ export class SStringUtil {
      * @param n         要转换的数值
      * @param len       转换后的长度(默认为 2)
      * @return 转换后的数据
-    */
+     */
     static num2Hex(n: number, len: number = 2): string {
         let hex = "";
         let numStr: string[] = [

+ 2 - 1
persagy-web-base/src/utils/SUuid.ts

@@ -26,6 +26,7 @@
 
 /**
  * 生成uuid工具
+ *
  * @author 郝洁 <haojie@persagy.com>
  */
 export class SUuid {
@@ -34,7 +35,7 @@ export class SUuid {
      *
      * @param len       要生成的 uuid 的长度
      * @param radix     生成 uuid 的基数
-    */
+     */
     static uuid(len: number, radix: number): string {
         const chars = "0123456789abcdef".split("");
         let uuid = [],

+ 19 - 15
persagy-web-big/src/items/SIconTextItem.ts

@@ -31,8 +31,8 @@ import {
     SAnchorItem,
     SGraphItem
 } from "@persagy-web/graph";
-import {SItemStatus, ItemOrder} from "..";
-import {SMouseEvent} from "@persagy-web/base";
+import { SItemStatus, ItemOrder } from "..";
+import { SMouseEvent } from "@persagy-web/base";
 import {
     SSize,
     SRect,
@@ -41,7 +41,7 @@ import {
     SFont,
     SPoint
 } from "@persagy-web/draw";
-import {Anchor} from "../types/topology/Anchor";
+import { Anchor } from "../types/topology/Anchor";
 
 /**
  * 图例 item
@@ -61,11 +61,13 @@ export class SIconTextItem extends SObjectItem {
             this.moveable = true;
             this.textItem.moveable = false;
             this.img.moveable = false;
-        } else if (v == SItemStatus.Edit) { // 编辑状态时
+        } else if (v == SItemStatus.Edit) {
+            // 编辑状态时
             this.moveable = false;
             this.textItem.moveable = true;
             this.img.moveable = true;
-        } else if (v == SItemStatus.Create) { // 创建状态时
+        } else if (v == SItemStatus.Create) {
+            // 创建状态时
             this.moveable = true;
             this.textItem.moveable = false;
             this.img.moveable = false;
@@ -275,10 +277,10 @@ export class SIconTextItem extends SObjectItem {
             });
         } else {
             anchorPoint = [
-                {x: this.img.x, y: this.img.y, id: ""},
-                {x: this.img.x, y: this.img.y, id: ""},
-                {x: this.img.x, y: this.img.y, id: ""},
-                {x: this.img.x, y: this.img.y, id: ""}
+                { x: this.img.x, y: this.img.y, id: "" },
+                { x: this.img.x, y: this.img.y, id: "" },
+                { x: this.img.x, y: this.img.y, id: "" },
+                { x: this.img.x, y: this.img.y, id: "" }
                 // { x: this.img.x, y: this.img.y + this.img.height / 2, id: "" },
                 // { x: this.img.x, y: this.img.y - this.img.height / 2, id: "" },
                 // { x: this.img.x - this.img.width / 2, y: this.img.y, id: "" },
@@ -312,10 +314,10 @@ export class SIconTextItem extends SObjectItem {
         // 判断是否有锚点
         if (this.anchorList.length) {
             let anchorPoint = [
-                {x: this.img.x, y: this.img.y},
-                {x: this.img.x, y: this.img.y},
-                {x: this.img.x, y: this.img.y},
-                {x: this.img.x, y: this.img.y}
+                { x: this.img.x, y: this.img.y },
+                { x: this.img.x, y: this.img.y },
+                { x: this.img.x, y: this.img.y },
+                { x: this.img.x, y: this.img.y }
                 // { x: this.img.x, y: this.img.y + this.img.height / 2 },
                 // { x: this.img.x, y: this.img.y - this.img.height / 2 },
                 // { x: this.img.x - this.img.width / 2, y: this.img.y },
@@ -337,7 +339,8 @@ export class SIconTextItem extends SObjectItem {
         // 如果为show状态 双击改对象则需改为编辑状态
         if (this.status == SItemStatus.Normal) {
             return super.onMouseDown(event);
-        } else if (this.status == SItemStatus.Edit) { // 编辑状态时
+        } else if (this.status == SItemStatus.Edit) {
+            // 编辑状态时
             return super.onMouseDown(event);
         }
         return true;
@@ -364,7 +367,8 @@ export class SIconTextItem extends SObjectItem {
         if (SItemStatus.Normal == this.status) {
             this.status = SItemStatus.Edit;
             this.grabItem(this);
-        } else if (SItemStatus.Edit == this.status) { // 处于编辑状态时
+        } else if (SItemStatus.Edit == this.status) {
+            // 处于编辑状态时
             this.status = SItemStatus.Normal;
             this.releaseItem();
         }

+ 7 - 7
persagy-web-graph/src/items/SImageItem.ts

@@ -124,7 +124,7 @@ export class SImageItem extends SObjectItem {
      *
      * @param parent      指向父 Item
      * @param url         图片地址
-    */
+     */
     constructor(parent: SGraphItem | null, url?: string) {
         super(parent);
         if (url) this.url = url;
@@ -132,7 +132,7 @@ export class SImageItem extends SObjectItem {
 
     /**
      * 根据显示模式计算图片的宽高
-    */
+     */
     computeImgSize(): void {
         if (this.isLoadOver) {
             // 要绘制图片的宽度
@@ -185,7 +185,7 @@ export class SImageItem extends SObjectItem {
      *
      * @param imgUrl        图片回调地址
      * @return 当前地址和回调地址是否相同
-    */
+     */
     private isUrlIdentical(imgUrl: string): boolean {
         if (this.url.indexOf("://") == -1) {
             // eslint-disable-next-line max-len
@@ -205,7 +205,7 @@ export class SImageItem extends SObjectItem {
      *
      * @param url      绝对路径
      * @return 截取出的绝对路径中的相对路径
-    */
+     */
     private GetUrlRelativePath(url: string): string {
         const arrUrl = url.split("//");
         const start = arrUrl[1].indexOf("/");
@@ -217,7 +217,7 @@ export class SImageItem extends SObjectItem {
      * Item 对象边界区域
      *
      * @return 边界区域
-    */
+     */
     boundingRect(): SRect {
         return new SRect(
             -this.origin.x,
@@ -232,7 +232,7 @@ export class SImageItem extends SObjectItem {
      *
      * @param oldSize   改之前的大小
      * @param newSize   改之后大小
-    */
+     */
     protected onResize(oldSize: SSize, newSize: SSize): void {
         this.computeImgSize();
         this.update();
@@ -242,7 +242,7 @@ export class SImageItem extends SObjectItem {
      * Item 绘制操作
      *
      * @param painter   绘制对象
-    */
+     */
     onDraw(painter: SPainter): void {
         painter.translate(-this.origin.x, -this.origin.y);
         if (this.isLoadOver) {