Browse Source

graph: fix: 格式化 lint检查

haojianlong 4 years ago
parent
commit
ef60af6919

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

@@ -51,7 +51,7 @@ module.exports = {
         "max-lines-per-function": ["error", 200],       // 一个函数最多200行代码
         "max-statements-per-line": ["error", {max: 1}], // 一行只允许有一条语句
         // 缩进
-        "indent": ["error", 4],                         // 缩进控制4空格
+        "indent": ["error", 4, { SwitchCase: 1 }],                         // 缩进控制4空格
         "max-len": ["error", 120],                      // 每行字符不超过120
         "no-mixed-spaces-and-tabs": "error",            // 禁止使用空格和tab混合缩进
         // 语句

+ 1 - 1
persagy-web-draw/.eslintrc.js

@@ -51,7 +51,7 @@ module.exports = {
         "max-lines-per-function": ["error", 200],       // 一个函数最多200行代码
         "max-statements-per-line": ["error", {max: 1}], // 一行只允许有一条语句
         // 缩进
-        "indent": ["error", 4],                         // 缩进控制4空格
+        "indent": ["error", 4, { SwitchCase: 1 }],                         // 缩进控制4空格
         "max-len": ["error", 120],                      // 每行字符不超过120
         "no-mixed-spaces-and-tabs": "error",            // 禁止使用空格和tab混合缩进
         // 语句

+ 18 - 12
persagy-web-graph/.eslintrc.js

@@ -26,14 +26,14 @@
 
 module.exports = {
     root: true,
-    parser: '@typescript-eslint/parser',
+    parser: "@typescript-eslint/parser",
     extends: [
-        'plugin:@typescript-eslint/recommended',
+        "plugin:@typescript-eslint/recommended",
         // Uses eslint-config-prettier to disable ESLint rules from @typescript-eslint/eslint-plugin that would conflict with prettier
-        'prettier/@typescript-eslint',
+        "prettier/@typescript-eslint",
         // Enables eslint-plugin-prettier and eslint-config-prettier. This will display prettier errors as ESLint errors. Make sure this is always the last configuration in the extends array.
         // 此行必须在最后
-        'plugin:prettier/recommended'
+        "plugin:prettier/recommended"
     ],
     env: {
         es6: true,
@@ -42,17 +42,23 @@ module.exports = {
     parserOptions: {
         // 支持最新 JavaScript
         ecmaVersion: 2018,
-        sourceType: 'module'
+        sourceType: "module"
     },
     rules: {
+        // 注释
+        // 文件
+        "max-classes-per-file": ["error", 1],           // 一个文件中只能定义一个类
+        "max-lines-per-function": ["error", 200],       // 一个函数最多200行代码
+        "max-statements-per-line": ["error", {max: 1}], // 一行只允许有一条语句
         // 缩进
-        'indent': ['error', 4, { SwitchCase: 1 }],      // 缩进控制4空格
-        'max-len': ['error', 120],                      // 每行字符不超过120
-        'no-mixed-spaces-and-tabs': 'error',            // 禁止使用空格和tab混合缩进
+        "indent": ["error", 4, { SwitchCase: 1 }],                         // 缩进控制4空格
+        "max-len": ["error", 120],                      // 每行字符不超过120
+        "no-mixed-spaces-and-tabs": "error",            // 禁止使用空格和tab混合缩进
         // 语句
-        'curly': ["error", "multi-line"],               // if、else if、else、for、while强制使用大括号,但允许在单行中省略大括号。
-        'semi': ['error', 'always'],                    //不得省略语句结束的分号
-        '@typescript-eslint/no-unused-vars': 'off',     // 取消未使用变量检查
-        '@typescript-eslint/explicit-member-accessibility': ['error', { accessibility: 'no-public' }]       // public访问不需加访问修饰符
+        "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-unused-vars": ["off"],
     }
 };

+ 35 - 35
persagy-web-graph/src/SGraphItem.ts

@@ -207,7 +207,7 @@ export class SGraphItem extends SObject {
      * 构造函数
      *
      * @param parent      指向父对象
-    */
+     */
     constructor(parent: SGraphItem | null = null) {
         super();
         if (parent) {
@@ -220,7 +220,7 @@ export class SGraphItem extends SObject {
      *
      * @param painter   绘制对象
      * @param rect      绘制区域
-    */
+     */
     onPaint(painter: SPainter, rect: SRect): void {
         this.onDraw(painter);
         for (let item of this.children) {
@@ -263,26 +263,26 @@ export class SGraphItem extends SObject {
      * Item 绘制操作
      *
      * @param painter    绘制对象
-    */
+     */
     onDraw(painter: SPainter): void {} // Function onDraw()
 
     /**
      * 隐藏对象
-    */
+     */
     hide(): void {
         this.visible = false;
     } // Function hide()
 
     /**
      * 显示对象
-    */
+     */
     show(): void {
         this.visible = true;
     } // Function show()
 
     /**
      * 更新 Item
-    */
+     */
     update(): void {
         if (null != this.scene) {
             const view = this.scene.view;
@@ -296,7 +296,7 @@ export class SGraphItem extends SObject {
      * Item 对象边界区域
      *
      * @return 对象边界区域
-    */
+     */
     boundingRect(): SRect {
         return new SRect(0, 0, 10, 10);
     } // Function boundingRect()
@@ -306,7 +306,7 @@ export class SGraphItem extends SObject {
      *
      * @param x     新位置的 x 坐标
      * @param y     新位置的 y 坐标
-    */
+     */
     moveTo(x: number, y: number): void {
         this.x = x;
         this.y = y;
@@ -318,7 +318,7 @@ export class SGraphItem extends SObject {
      * @param x     横坐标(当前 item)
      * @param y     纵坐标(当前 item)
      * @return item 是否包含点 x, y
-    */
+     */
     contains(x: number, y: number): boolean {
         return this.boundingRect().contains(x, y);
     } // Function contains()
@@ -327,7 +327,7 @@ export class SGraphItem extends SObject {
      * 获得 item 的路径节点列表。(该节点被加载到场景中,如果未被加载到场景中,计算会出错)
      *
      * @return item 的路径节点列表
-    */
+     */
     itemPath(): SGraphItem[] {
         if (this.parent != null) {
             let list = this.parent.itemPath();
@@ -344,7 +344,7 @@ export class SGraphItem extends SObject {
      * @param x     场景中的横坐标
      * @param y     场景中的纵坐标
      * @return 在 item 中的坐标
-    */
+     */
     mapFromScene(x: number, y: number): SPoint {
         const m = this.scene2itemMattrix();
         return new SPoint(x, y).matrixTransform(m.inversed());
@@ -356,7 +356,7 @@ export class SGraphItem extends SObject {
      * @param x     item 中的横坐标
      * @param y     item 中的纵坐标
      * @return 在场景中的坐标
-    */
+     */
     mapToScene(x: number, y: number): SPoint {
         if (this.parent == null) {
             return new SPoint(x, y);
@@ -371,7 +371,7 @@ export class SGraphItem extends SObject {
      * 场景对象到 item 对象的转换矩阵
      *
      * @return 转换矩阵
-    */
+     */
     scene2itemMattrix(): SMatrix {
         let m = new SMatrix();
         let list = this.itemPath();
@@ -396,7 +396,7 @@ export class SGraphItem extends SObject {
      *
      * @param event     保存事件参数
      * @return 是否处理事件
-    */
+     */
     onClick(event: SMouseEvent): boolean {
         for (let i = this.children.length - 1; i >= 0; i--) {
             let item = this.children[i];
@@ -418,7 +418,7 @@ export class SGraphItem extends SObject {
      *
      * @param event   保存事件参数
      * @return 是否处理事件
-    */
+     */
     onDoubleClick(event: SMouseEvent): boolean {
         for (let i = this.children.length - 1; i >= 0; i--) {
             let item = this.children[i];
@@ -440,7 +440,7 @@ export class SGraphItem extends SObject {
      *
      * @param event   保存事件参数
      * @return 是否处理事件
-    */
+     */
     onMouseDown(event: SMouseEvent): boolean {
         for (let i = this.children.length - 1; i >= 0; i--) {
             try {
@@ -475,7 +475,7 @@ export class SGraphItem extends SObject {
      *
      * @param event   保存事件参数
      * @return 是否处理事件
-    */
+     */
     onMouseMove(event: SMouseEvent): boolean {
         for (let i = this.children.length - 1; i >= 0; i--) {
             let item = this.children[i];
@@ -525,7 +525,7 @@ export class SGraphItem extends SObject {
      *
      * @param event   保存事件参数
      * @return 是否处理事件
-    */
+     */
     onMouseUp(event: SMouseEvent): boolean {
         for (let i = this.children.length - 1; i >= 0; i--) {
             let item = this.children[i];
@@ -559,7 +559,7 @@ export class SGraphItem extends SObject {
      *
      * @param event   保存事件参数
      * @return 是否处理事件
-    */
+     */
     onMouseEnter(event: SMouseEvent): boolean {
         return false;
     } // Function onMouseEnter()
@@ -569,7 +569,7 @@ export class SGraphItem extends SObject {
      *
      * @param event   保存事件参数
      * @return 是否处理事件
-    */
+     */
     onMouseLeave(event: SMouseEvent): boolean {
         return false;
     } // Function onMouseLeave()
@@ -579,7 +579,7 @@ export class SGraphItem extends SObject {
      *
      * @param event       事件参数
      * @return 是否处理事件
-    */
+     */
     onContextMenu(event: SMouseEvent): boolean {
         for (let i = this.children.length - 1; i >= 0; i--) {
             let item = this.children[i];
@@ -599,33 +599,33 @@ export class SGraphItem extends SObject {
      * 按键按下事件
      *
      * @param event       事件参数
-    */
+     */
     onKeyDown(event: KeyboardEvent): void {} // Function onKeyDown()
 
     /**
      * 按键 press 事件
      *
      * @param event       事件参数
-    */
+     */
     onKeyPress(event: KeyboardEvent): void {} // Function onKeyPress()
 
     /**
      * 按键松开事件
      *
      * @param event       事件参数
-    */
+     */
     onKeyUp(event: KeyboardEvent): void {} // Function onKeyUp()
 
     /**
      * 取消操作 item 事件
-    */
+     */
     cancelOperate(): void {} // Function cancelOperate()
 
     /**
      * 返回 item 对应的数据对象
      *
      * @return  item 数据
-    */
+     */
     toData(): any | null {
         return null;
     } // Function toData()
@@ -635,10 +635,10 @@ export class SGraphItem extends SObject {
      *
      * @param x   x 坐标
      * @param y   y 坐标
-    */
+     */
     moveToOrigin(x: number, y: number): void {
         if (this.children && this.children.length) {
-            this.children.forEach(it => {
+            this.children.forEach((it): void => {
                 it.moveToOrigin(x, y);
             });
         }
@@ -652,7 +652,7 @@ export class SGraphItem extends SObject {
      * @param a   比较元素 1
      * @param b   比较元素 2
      * @return 2 个元素 zOrder 的差值
-    */
+     */
     private static sortItemZOrder(a: SGraphItem, b: SGraphItem): number {
         return a.zOrder - b.zOrder;
     } // Function sortItemZOrder()
@@ -663,7 +663,7 @@ export class SGraphItem extends SObject {
      * @param child   子对象
      * @param event   事件参数
      * @return 子对象鼠标事件
-    */
+     */
     private static toChildMouseEvent(
         child: SGraphItem,
         event: SMouseEvent
@@ -691,7 +691,7 @@ export class SGraphItem extends SObject {
      * 锁定 item
      *
      * @param item    被锁定的 item
-    */
+     */
     protected grabItem(item: SGraphItem): void {
         if (this.scene != null) {
             this.scene.grabItem = item;
@@ -700,7 +700,7 @@ export class SGraphItem extends SObject {
 
     /**
      * 释放被锁定的 item
-    */
+     */
     protected releaseItem(): void {
         if (this.scene != null) {
             this.scene.grabItem = null;
@@ -713,7 +713,7 @@ export class SGraphItem extends SObject {
      * @param x     X 轴
      * @param y     Y 轴
      * @return 在父节点的位置
-    */
+     */
     protected toParentChange(x: number, y: number): SPoint {
         const m = new SMatrix();
         m.scale(this.scale, this.scale);
@@ -730,7 +730,7 @@ export class SGraphItem extends SObject {
      * 判断是否处理事件
      *
      * @return 是否处理事件
-    */
+     */
     private acceptEvent(): boolean {
         return this.visible && this.enabled;
     } // Function acceptEvent()
@@ -740,7 +740,7 @@ export class SGraphItem extends SObject {
      *
      * @param event     事件参数
      * @return 是否处理事件
-    */
+     */
     private clickSelect(event: SMouseEvent): boolean {
         // 如果 Item 不可被选中,或没有按下鼠标左键,则直接返回
         if (!this.selectable) {

+ 19 - 19
persagy-web-graph/src/SGraphScene.ts

@@ -49,7 +49,7 @@ export class SGraphScene {
 
     /**
      * 构造函数
-    */
+     */
     constructor() {
         this.root.scene = this;
         this.addItem(this.selectContainer);
@@ -59,7 +59,7 @@ export class SGraphScene {
      * 添加 item 对象到场景。
      *
      * @param item        添加的对象
-    */
+     */
     addItem(item: SGraphItem): void {
         item.parent = this.root;
     } // Function addItem()
@@ -68,7 +68,7 @@ export class SGraphScene {
      * 从场景中移除 Item。
      *
      * @param item        被移除的对象
-    */
+     */
     removeItem(item: SGraphItem): void {
         item.parent = null;
     } // Function removeItem()
@@ -78,7 +78,7 @@ export class SGraphScene {
      *
      * @param painter     绘制对象
      * @param rect        更新绘制区域
-    */
+     */
     drawScene(painter: SPainter, rect: SRect): void {
         this.root.onPaint(painter, rect);
     } // Function drawScene()
@@ -88,8 +88,8 @@ export class SGraphScene {
      *
      * @param painter     绘制对象
      * @param rect        更新绘制区域
-    */
-    drawBackground(painter: SPainter, rect: SRect) {
+     */
+    drawBackground(painter: SPainter, rect: SRect): void {
         // DO NOTHING
     } // Function drawBackground()
 
@@ -98,8 +98,8 @@ export class SGraphScene {
      *
      * @param painter     绘制对象
      * @param rect        更新绘制区域
-    */
-    drawForeground(painter: SPainter, rect: SRect) {
+     */
+    drawForeground(painter: SPainter, rect: SRect): void {
         // DO NOTHING
     } // Function drawForeground()
 
@@ -108,7 +108,7 @@ export class SGraphScene {
      *
      * @param flag 是否只对可见 item 处理
      * @return 所有 item 占用的矩形区域
-    */
+     */
     allItemRect(flag: boolean = true): SRect | null {
         let rect: SRect | null = null;
         // 依次取 item 列中的所有 item。将所有 item 的边界做并焦处理。
@@ -133,7 +133,7 @@ export class SGraphScene {
      * 被选中 item 占用的矩形区域
      *
      * @return 被选中 item 占用的矩形区域
-    */
+     */
     selectedItemRect(): SRect | null {
         let rect: SRect | null = null;
 
@@ -160,7 +160,7 @@ export class SGraphScene {
      * 获得选中的对象列表
      *
      * @return 选中对象列表
-    */
+     */
     selectedItems(): SGraphItem[] {
         let itemList = Array<SGraphItem>();
         for (let item of this.root.children) {
@@ -180,7 +180,7 @@ export class SGraphScene {
      *
      * @param event   保存事件参数
      * @return 是否处理事件
-    */
+     */
     onDoubleClick(event: SMouseEvent): boolean {
         if (this.grabItem != null) {
             return this.grabItem.onDoubleClick(
@@ -195,7 +195,7 @@ export class SGraphScene {
      *
      * @param event   保存事件参数
      * @return 是否处理事件
-    */
+     */
     onMouseDown(event: SMouseEvent): boolean {
         if (this.grabItem != null) {
             return this.grabItem.onMouseDown(
@@ -214,7 +214,7 @@ export class SGraphScene {
      *
      * @param event   保存事件参数
      * @return 是否处理事件
-    */
+     */
     onMouseMove(event: SMouseEvent): boolean {
         if (this.grabItem != null) {
             return this.grabItem.onMouseMove(
@@ -229,7 +229,7 @@ export class SGraphScene {
      *
      * @param event       保存事件参数
      * @return 是否处理事件
-    */
+     */
     onMouseUp(event: SMouseEvent): boolean {
         if (this.grabItem != null) {
             return this.grabItem.onMouseUp(
@@ -244,7 +244,7 @@ export class SGraphScene {
      *
      * @param event       事件参数
      * @return 是否处理事件
-    */
+     */
     onContextMenu(event: SMouseEvent): boolean {
         if (this.grabItem != null) {
             return this.grabItem.onContextMenu(
@@ -259,7 +259,7 @@ export class SGraphScene {
      * 按键按下事件
      *
      * @param event       事件参数
-    */
+     */
     onKeyDown(event: KeyboardEvent): void {
         if (this.grabItem != null) {
             return this.grabItem.onKeyDown(event);
@@ -271,7 +271,7 @@ export class SGraphScene {
      * 按键松开事件
      *
      * @param event       事件参数
-    */
+     */
     onKeyUp(event: KeyboardEvent): void {
         if (this.grabItem != null) {
             return this.grabItem.onKeyUp(event);
@@ -285,7 +285,7 @@ export class SGraphScene {
      * @param item        指定的 item 对象
      * @param event       场景事件
      * @return 转换场景事件坐标到指定 Item 坐标事件
-    */
+     */
     private toGrabItemMotionEvent(
         item: SGraphItem,
         event: SMouseEvent

+ 14 - 14
persagy-web-graph/src/SGraphSelectContainer.ts

@@ -548,10 +548,10 @@ export class SGraphSelectContainer extends SGraphItem {
     private setTop(): void {
         const arr: SGraphItem[] = this.sortItemList(this.itemList, true);
         // 按顺序 zOrder 增加
-        arr.forEach(it => {
+        arr.forEach((it): void => {
             let max = it.zOrder;
             if (it.parent) {
-                it.parent.children.forEach(item => {
+                it.parent.children.forEach((item): void => {
                     if (
                         Number(max.toFixed()) == Number(item.zOrder.toFixed())
                     ) {
@@ -571,10 +571,10 @@ export class SGraphSelectContainer extends SGraphItem {
     private setBottom(): void {
         const arr: SGraphItem[] = this.sortItemList(this.itemList, false);
         // 按顺序 zOrder 增加
-        arr.forEach(it => {
+        arr.forEach((it): void => {
             let min = it.zOrder;
             if (it.parent) {
-                it.parent.children.forEach(item => {
+                it.parent.children.forEach((item): void => {
                     if (
                         Number(min.toFixed()) == Number(item.zOrder.toFixed())
                     ) {
@@ -593,11 +593,11 @@ export class SGraphSelectContainer extends SGraphItem {
      */
     private setBefore(): void {
         const arr: SGraphItem[] = this.sortItemList(this.itemList, false);
-        arr.forEach(it => {
+        arr.forEach((it): void => {
             if (it.parent) {
                 const min = it.zOrder;
                 let temp = it.parent.children
-                    .map(child => {
+                    .map((child): number | undefined => {
                         if (
                             Number(child.zOrder.toFixed()) ==
                             Number(min.toFixed())
@@ -605,7 +605,7 @@ export class SGraphSelectContainer extends SGraphItem {
                             return child.zOrder;
                         }
                     })
-                    .filter(c => c);
+                    .filter((c): number | undefined => c);
                 temp = [...new Set(temp)];
                 // 当前层有多个
                 const index = temp.indexOf(it.zOrder);
@@ -627,11 +627,11 @@ export class SGraphSelectContainer extends SGraphItem {
      */
     private setAfter(): void {
         const arr: SGraphItem[] = this.sortItemList(this.itemList, false);
-        arr.forEach(it => {
+        arr.forEach((it): void => {
             if (it.parent) {
                 const max = it.zOrder;
                 let temp = it.parent.children
-                    .map(child => {
+                    .map((child): number | undefined => {
                         if (
                             Number(child.zOrder.toFixed()) ==
                             Number(max.toFixed())
@@ -639,7 +639,7 @@ export class SGraphSelectContainer extends SGraphItem {
                             return child.zOrder;
                         }
                     })
-                    .filter(c => c);
+                    .filter((c): number | undefined => c);
                 temp = [...new Set(temp)].reverse();
                 // 当前层有多个
                 const index = temp.indexOf(it.zOrder);
@@ -664,7 +664,7 @@ export class SGraphSelectContainer extends SGraphItem {
      * @return 排序后的数组
      */
     sortItemList(arr: SGraphItem[], flag: boolean = true): SGraphItem[] {
-        const list: SGraphItem[] = arr.map(t => t);
+        const list: SGraphItem[] = arr.map((t): SGraphItem => t);
         list.sort(this.compare("zOrder", flag));
         return list;
     } // Function sortItemList()
@@ -678,7 +678,7 @@ export class SGraphSelectContainer extends SGraphItem {
     private compare(prop: string, flag: boolean): any {
         const f = flag ? 1 : -1;
         // eslint-disable-next-line @typescript-eslint/explicit-function-return-type
-        return (a: any, b: any) => {
+        return (a: any, b: any): number => {
             a = a[prop];
             b = b[prop];
             if (a < b) {
@@ -962,7 +962,7 @@ export class SGraphSelectContainer extends SGraphItem {
                         event.x - this._mouseDownPos.x,
                         event.y - this._mouseDownPos.y
                     );
-                    this.itemList.forEach(t => {
+                    this.itemList.forEach((t): void => {
                         t.moveTo(t.x + mp.x, t.y + mp.y);
                     });
                 }
@@ -1022,7 +1022,7 @@ export class SGraphSelectContainer extends SGraphItem {
 
             const r = painter.toPx(this.radius);
             painter.pen.lineDash = [];
-            this.pointList.forEach((t, i) => {
+            this.pointList.forEach((t, i): void => {
                 if (i == this.curIndex) {
                     painter.brush.color = this.fillColor;
                 } else {

+ 25 - 25
persagy-web-graph/src/SGraphView.ts

@@ -68,7 +68,7 @@ export class SGraphView extends SCanvasView {
      * 构造函数
      *
      * @param id      画布对象 ID
-    */
+     */
     constructor(id: string) {
         super(id);
     } // Function constructor()
@@ -79,7 +79,7 @@ export class SGraphView extends SCanvasView {
      * @param name    文件名
      * @param width   svg 宽度
      * @param height  svg 高度
-    */
+     */
     saveSceneSvg(name: string, width: number, height: number): void {
         let url = URL.createObjectURL(
             new Blob([this.sceneSvgData(width, height)], {
@@ -95,7 +95,7 @@ export class SGraphView extends SCanvasView {
      * @param width   svg 宽度
      * @param height  svg 高度
      * @return URL 地址
-    */
+     */
     sceneSvgData(width: number, height: number): string {
         if (null == this.scene) {
             return "";
@@ -123,7 +123,7 @@ export class SGraphView extends SCanvasView {
 
     /**
      * 适配视图到视图
-    */
+     */
     fitSceneToView(): void {
         if (null == this.scene) {
             return;
@@ -136,7 +136,7 @@ export class SGraphView extends SCanvasView {
 
     /**
      * 适配选中的对象在视图中可见
-    */
+     */
     fitSelectedToView(): void {
         if (null == this.scene) {
             return;
@@ -149,7 +149,7 @@ export class SGraphView extends SCanvasView {
 
     /**
      * 适配任意对象在视图中可见
-    */
+     */
     fitItemToView(itemList: SGraphItem[]): void {
         if (null == this.scene) {
             return;
@@ -176,7 +176,7 @@ export class SGraphView extends SCanvasView {
      * @param x     场景中的横坐标
      * @param y     场景中的纵坐标
      * @return 视图坐标
-    */
+     */
     mapFromScene(x: number, y: number): SPoint;
 
     /**
@@ -184,7 +184,7 @@ export class SGraphView extends SCanvasView {
      *
      * @param pos   场景中的坐标
      * @return 视图坐标
-    */
+     */
     mapFromScene(pos: SPoint): SPoint;
 
     /**
@@ -193,7 +193,7 @@ export class SGraphView extends SCanvasView {
      * @param x     场景中的横坐标
      * @param y     场景中的纵坐标
      * @return 视图坐标
-    */
+     */
     mapFromScene(x: number | SPoint, y?: number): SPoint {
         if (x instanceof SPoint) {
             // 如果传入的是 SPoint 对象
@@ -216,7 +216,7 @@ export class SGraphView extends SCanvasView {
      * @param x     视图横坐标
      * @param y     视图纵坐标
      * @return 场景坐标
-    */
+     */
     mapToScene(x: number, y: number): SPoint;
 
     /**
@@ -224,7 +224,7 @@ export class SGraphView extends SCanvasView {
      *
      * @param pos     视图坐标
      * @return 场景坐标
-    */
+     */
     mapToScene(pos: SPoint): SPoint;
 
     /**
@@ -233,7 +233,7 @@ export class SGraphView extends SCanvasView {
      * @param x       视图的横坐标或 SPoint 对象
      * @param y       视图的纵坐标
      * @return 场景坐标
-    */
+     */
     mapToScene(x: number | SPoint, y?: number): SPoint {
         if (x instanceof SPoint) {
             // 如果传入的是 SPoint 对象
@@ -256,7 +256,7 @@ export class SGraphView extends SCanvasView {
      * @param type    图像类型
      * @param width   要保存图形的宽
      * @param height  要保存图形的高
-    */
+     */
     saveImageSize(
         name: string,
         type: string,
@@ -290,7 +290,7 @@ export class SGraphView extends SCanvasView {
      * 绘制视图
      *
      * @param painter       绘制对象
-    */
+     */
     protected onDraw(painter: SPainter): void {
         painter.save();
         painter.clearRect(0, 0, this.width, this.height);
@@ -323,7 +323,7 @@ export class SGraphView extends SCanvasView {
      * 绘制场景背景
      *
      * @param painter     绘制对象
-    */
+     */
     protected drawBackground(painter: SPainter): void {
         painter.brush.color = this.backgroundColor;
         painter.pen.color = SColor.Transparent;
@@ -335,7 +335,7 @@ export class SGraphView extends SCanvasView {
      * 绘制场景前景
      *
      * @param painter     绘制对象
-    */
+     */
     protected drawForeground(painter: SPainter): void {
         // DO NOTHING
     } // Function drawForeground()
@@ -344,7 +344,7 @@ export class SGraphView extends SCanvasView {
      * 鼠标双击事件
      *
      * @param event       事件参数
-    */
+     */
     protected onDoubleClick(event: MouseEvent): void {
         if (this.scene != null) {
             let ce = this.toSceneMotionEvent(event);
@@ -356,7 +356,7 @@ export class SGraphView extends SCanvasView {
      * 鼠标按下事件
      *
      * @param event       事件参数
-    */
+     */
     protected onMouseDown(event: MouseEvent): void {
         super.onMouseDown(event);
         if (this.scene != null) {
@@ -369,7 +369,7 @@ export class SGraphView extends SCanvasView {
      * 鼠标移动事件
      *
      * @param event       事件参数
-    */
+     */
     protected onMouseMove(event: MouseEvent): void {
         super.onMouseMove(event);
         if (this.scene != null) {
@@ -382,7 +382,7 @@ export class SGraphView extends SCanvasView {
      * 鼠标松开事件
      *
      * @param event       事件参数
-    */
+     */
     protected onMouseUp(event: MouseEvent): void {
         super.onMouseUp(event);
         if (this.scene != null) {
@@ -395,7 +395,7 @@ export class SGraphView extends SCanvasView {
      * 上下文菜单事件
      *
      * @param event       事件参数
-    */
+     */
     protected onContextMenu(event: MouseEvent): void {
         if (this.scene != null) {
             let ce = this.toSceneMotionEvent(event);
@@ -407,7 +407,7 @@ export class SGraphView extends SCanvasView {
      * 按键按下事件
      *
      * @param event       事件参数
-    */
+     */
     protected onKeyDown(event: KeyboardEvent): void {
         if (this.scene != null) {
             this.scene.onKeyDown(event);
@@ -418,7 +418,7 @@ export class SGraphView extends SCanvasView {
      * 按键松开事件
      *
      * @param event       事件参数
-    */
+     */
     protected onKeyUp(event: KeyboardEvent): void {
         if (this.scene != null) {
             this.scene.onKeyUp(event);
@@ -431,7 +431,7 @@ export class SGraphView extends SCanvasView {
      * @param width       宽度
      * @param height      高度
      * @param rect        对象的矩阵大小
-    */
+     */
     private fitRectToSize(
         width: number,
         height: number,
@@ -455,7 +455,7 @@ export class SGraphView extends SCanvasView {
      *
      * @param event       事件参数
      * @return MouseEvent 事件转换成场景 SMouseEvent 事件
-    */
+     */
     private toSceneMotionEvent(event: MouseEvent): SMouseEvent {
         let se = new SMouseEvent(event);
         se.matrix.translate(this.origin.x, this.origin.y);

+ 4 - 4
persagy-web-graph/src/commands/SGraphAddCommand.ts

@@ -47,7 +47,7 @@ export class SGraphAddCommand extends SGraphCommand {
      *
      * @param scene   item 所在场景
      * @param item    命令 item 对象
-    */
+     */
     constructor(scene: SGraphScene, item: SGraphItem) {
         super(scene);
         this.item = item;
@@ -61,14 +61,14 @@ export class SGraphAddCommand extends SGraphCommand {
      *
      * @param command   指定命令
      * @return 是否已执行合并
-    */
+     */
     mergeWith(command: SUndoCommand): boolean {
         return false;
     } // Function mergeWith()
 
     /**
      * 重做
-    */
+     */
     redo(): void {
         this.item.parent = this.parent;
         // @ts-ignore
@@ -77,7 +77,7 @@ export class SGraphAddCommand extends SGraphCommand {
 
     /**
      * 撤销
-    */
+     */
     undo(): void {
         this.item.parent = null;
         // @ts-ignore

+ 1 - 1
persagy-web-graph/src/commands/SGraphCommand.ts

@@ -40,7 +40,7 @@ export abstract class SGraphCommand extends SUndoCommand {
      * 构造函数
      *
      * @param scene       命令所属的场景类
-    */
+     */
     protected constructor(scene: SGraphScene | null) {
         super();
         this.scene = scene;

+ 5 - 5
persagy-web-graph/src/commands/SGraphMoveCommand.ts

@@ -52,7 +52,7 @@ export class SGraphMoveCommand extends SGraphCommand {
      * @param item    item 对象
      * @param old     移动前位置
      * @param pos     移动后位置
-    */
+     */
     constructor(
         scene: SGraphScene,
         item: SGraphItem,
@@ -72,7 +72,7 @@ export class SGraphMoveCommand extends SGraphCommand {
      *
      * @param command   指定命令
      * @return 是否已执行合并命令
-    */
+     */
     mergeWith(command: SUndoCommand): boolean {
         if (command instanceof SGraphMoveCommand && command.item == this.item) {
             command.pos = this.pos;
@@ -83,7 +83,7 @@ export class SGraphMoveCommand extends SGraphCommand {
 
     /**
      * 重做
-    */
+     */
     redo(): void {
         this.item.pos = new SPoint(this.pos.x, this.pos.y);
         this.item.update();
@@ -91,7 +91,7 @@ export class SGraphMoveCommand extends SGraphCommand {
 
     /**
      * 撤销
-    */
+     */
     undo(): void {
         this.item.pos = new SPoint(this.old.x, this.old.y);
         this.item.update();
@@ -101,7 +101,7 @@ export class SGraphMoveCommand extends SGraphCommand {
      * 命令细节描述
      *
      * @return 将当前命令转为字符串
-    */
+     */
     toString(): string {
         return `oldPos=${JSON.stringify(this.old)};\nnewPos=${JSON.stringify(
             this.pos

+ 4 - 4
persagy-web-graph/src/commands/SGraphPointListDelete.ts

@@ -52,7 +52,7 @@ export class SGraphPointListDelete extends SGraphCommand {
      * @param pointList   顶点数组
      * @param pos         删除的点
      * @param index       索引
-    */
+     */
     constructor(
         scene: SGraphScene,
         item: SGraphItem,
@@ -71,7 +71,7 @@ export class SGraphPointListDelete extends SGraphCommand {
 
     /**
      * 执行重做操作执行
-    */
+     */
     redo(): void {
         if (this.index == null) {
             this.pointList.pop();
@@ -83,7 +83,7 @@ export class SGraphPointListDelete extends SGraphCommand {
 
     /**
      * 执行取消操作执行
-    */
+     */
     undo(): void {
         if (this.pos == null) return;
         if (this.index == null) {
@@ -98,7 +98,7 @@ export class SGraphPointListDelete extends SGraphCommand {
      * 命令细节描述
      *
      * @return 将命令转为字符串
-    */
+     */
     toString(): string {
         const pointList = `pointList=${JSON.stringify(this.pointList)}`;
         const pos = `pos=${JSON.stringify(this.pos)}`;

+ 4 - 4
persagy-web-graph/src/commands/SGraphPointListInsert.ts

@@ -52,7 +52,7 @@ export class SGraphPointListInsert extends SGraphCommand {
      * @param pointList   顶点数组
      * @param pos         当前位置
      * @param index       索引
-    */
+     */
     constructor(
         scene: SGraphScene,
         item: SGraphItem,
@@ -71,7 +71,7 @@ export class SGraphPointListInsert extends SGraphCommand {
 
     /**
      * 执行重做操作执行
-    */
+     */
     redo(): void {
         const point = new SPoint(this.pos.x, this.pos.y);
         if (this.index == null) {
@@ -84,7 +84,7 @@ export class SGraphPointListInsert extends SGraphCommand {
 
     /**
      * 执行取消操作执行
-    */
+     */
     undo(): void {
         if (this.index == null) {
             this.pointList.pop();
@@ -98,7 +98,7 @@ export class SGraphPointListInsert extends SGraphCommand {
      * 命令细节描述
      *
      * @return 将命令转为字符串
-    */
+     */
     toString(): string {
         const pointList = `pointList=${JSON.stringify(this.pointList)}`;
         const pos = `pos=${JSON.stringify(this.pos)}`;

+ 4 - 4
persagy-web-graph/src/commands/SGraphPointListUpdate.ts

@@ -55,7 +55,7 @@ export class SGraphPointListUpdate extends SGraphCommand {
      * @param old         原位置
      * @param pos         当前位置
      * @param index       索引
-    */
+     */
     constructor(
         scene: SGraphScene,
         item: SGraphItem,
@@ -76,7 +76,7 @@ export class SGraphPointListUpdate extends SGraphCommand {
 
     /**
      * 执行重做操作执行
-    */
+     */
     redo(): void {
         this.pointList[this.index].x = this.pos.x;
         this.pointList[this.index].y = this.pos.y;
@@ -85,7 +85,7 @@ export class SGraphPointListUpdate extends SGraphCommand {
 
     /**
      * 执行取消操作执行
-    */
+     */
     undo(): void {
         this.pointList[this.index].x = this.old.x;
         this.pointList[this.index].y = this.old.y;
@@ -96,7 +96,7 @@ export class SGraphPointListUpdate extends SGraphCommand {
      * 命令细节描述
      *
      * @return 将命令转为字符串
-    */
+     */
     toString(): string {
         const pointList = `pointList=${JSON.stringify(this.pointList)}`;
         const old = `old=${JSON.stringify(this.old)}`;

+ 4 - 4
persagy-web-graph/src/commands/SGraphPropertyCommand.ts

@@ -53,7 +53,7 @@ export class SGraphPropertyCommand<T> extends SGraphCommand {
      * @param propName    修改的属性名称
      * @param oldProp     修改前的属性值
      * @param newProp     修改后的属性值
-    */
+     */
     constructor(
         scene: SGraphScene,
         item: SGraphItem,
@@ -72,7 +72,7 @@ export class SGraphPropertyCommand<T> extends SGraphCommand {
 
     /**
      * redo 操作
-    */
+     */
     redo(): void {
         // @ts-ignore
         this.item[this.propName] = this.newProp;
@@ -81,7 +81,7 @@ export class SGraphPropertyCommand<T> extends SGraphCommand {
 
     /**
      * undo 操作
-    */
+     */
     undo(): void {
         // @ts-ignore
         this.item[this.propName] = this.oldProp;
@@ -92,7 +92,7 @@ export class SGraphPropertyCommand<T> extends SGraphCommand {
      * 命令细节描述
      *
      * @return 将命令转为字符串
-    */
+     */
     toString(): string {
         const propName = `propName=${this.propName}`;
         const oldProp = `oldProp=${JSON.stringify(this.oldProp)}`;

+ 2 - 2
persagy-web-graph/src/items/SAnchorItem.ts

@@ -49,7 +49,7 @@ export class SAnchorItem extends SGraphItem {
      * 构造函数
      *
      * @param parent      指向父对象
-    */
+     */
     constructor(parent: SGraphItem | null = null) {
         super(parent);
         this.id = uuidv1();
@@ -59,7 +59,7 @@ export class SAnchorItem extends SGraphItem {
      * Item 绘制操作
      *
      * @param painter   绘制对象
-    */
+     */
     onDraw(painter: SPainter): void {
         this.sceneDis = painter.toPx(this.dis);
         painter.pen.lineWidth = painter.toPx(1);

+ 4 - 4
persagy-web-graph/src/items/SGraphAreaGroupItem.ts

@@ -59,7 +59,7 @@ export class SGraphAreaGroupItem extends SGraphShape {
      *
      * @param parent  父类
      * @param data    轮廓线及风格数据
-    */
+     */
     constructor(parent: SGraphItem | null, data: AreaGroup) {
         super(parent, data.style);
         if (data.outline.length && data.outline[0] && data.outline[0].length) {
@@ -104,7 +104,7 @@ export class SGraphAreaGroupItem extends SGraphShape {
      * Item 对象边界区域
      *
      * @return 对象边界区域
-    */
+     */
     boundingRect(): SRect {
         return new SRect(
             this.minX,
@@ -120,7 +120,7 @@ export class SGraphAreaGroupItem extends SGraphShape {
      * @param x 点 x 坐标
      * @param y 点 y 坐标
      * @return 是否在区域内
-    */
+     */
     contains(x: number, y: number): boolean {
         for (let j = 0; j < this.pointList.length; j++) {
             let arr = this.pointList[j];
@@ -149,7 +149,7 @@ export class SGraphAreaGroupItem extends SGraphShape {
      * Item 绘制操作
      *
      * @param painter    绘制对象
-    */
+     */
     onDraw(painter: SPainter): void {
         super.onDraw(painter);
         this.pathList.forEach((t): void => {

+ 3 - 3
persagy-web-graph/src/items/SGraphLineItem.ts

@@ -56,7 +56,7 @@ export class SGraphLineItem extends SGraphItem {
      * @param width     线的宽度
      * @param color     线的颜色
      * @param parent    是否为虚线
-    */
+     */
     constructor(
         parent: SGraphItem | null,
         x1: number,
@@ -77,7 +77,7 @@ export class SGraphLineItem extends SGraphItem {
      * Item 对象边界区域
      *
      * @return 边界区域
-    */
+     */
     boundingRect(): SRect {
         let minX = Math.min(this.x1, this.x2);
         let minY = Math.min(this.y1, this.y2);
@@ -95,7 +95,7 @@ export class SGraphLineItem extends SGraphItem {
      * 绘制 Item
      *
      * @param painter 绘制对象
-    */
+     */
     onDraw(painter: SPainter): void {
         painter.pen = new SPen(this.color, this.width);
         painter.drawLine(this.x1, this.y1, this.x2, this.y2);

+ 4 - 4
persagy-web-graph/src/items/SGraphPolyGroupItem.ts

@@ -51,7 +51,7 @@ export class SGraphPolyGroupItem extends SGraphShape {
      *
      * @param parent  父类
      * @param data    轮廓线及风格数据
-    */
+     */
     constructor(parent: SGraphItem | null, data: PolyGroup) {
         super(parent, data.style);
         if (data.outline.length && data.outline[0] && data.outline[0].length) {
@@ -87,7 +87,7 @@ export class SGraphPolyGroupItem extends SGraphShape {
      * Item 对象边界区域
      *
      * @return 边界区域
-    */
+     */
     boundingRect(): SRect {
         return new SRect(
             this.minX,
@@ -103,7 +103,7 @@ export class SGraphPolyGroupItem extends SGraphShape {
      * @param x     点 x 坐标
      * @param y     点 y 坐标
      * @return 是否在区域内
-    */
+     */
     contains(x: number, y: number): boolean {
         let arr = this.pointList;
         for (let i = 0; i < arr.length; i++) {
@@ -118,7 +118,7 @@ export class SGraphPolyGroupItem extends SGraphShape {
      * Item 绘制操作
      *
      * @param painter    绘制对象
-    */
+     */
     onDraw(painter: SPainter): void {
         super.onDraw(painter);
         this.pointList.forEach((t): void => {

+ 3 - 3
persagy-web-graph/src/items/SGraphRectItem.ts

@@ -77,7 +77,7 @@ export class SGraphRectItem extends SGraphShape {
      *
      * @param parent    指向父对象
      * @param data      矩形数据
-    */
+     */
     constructor(parent: SGraphItem | null, data: SGraphRect) {
         super(parent, data.style);
         this.width = data.width;
@@ -92,7 +92,7 @@ export class SGraphRectItem extends SGraphShape {
      * Item 对象边界区域
      *
      * @return	边界区域
-    */
+     */
     boundingRect(): SRect {
         return new SRect(0, 0, this.width, this.height);
     } // Function boundingRect()
@@ -101,7 +101,7 @@ export class SGraphRectItem extends SGraphShape {
      * 绘制
      *
      * @param painter   绘制对象
-    */
+     */
     onDraw(painter: SPainter): void {
         super.onDraw(painter);
         if (this.radius != 0) {

+ 4 - 4
persagy-web-graph/src/items/SGraphShape.ts

@@ -48,7 +48,7 @@ export class SGraphShape extends SGraphItem {
      *
      * @param parent  父类
      * @param style   item 各种状态的样式
-    */
+     */
     constructor(parent: SGraphItem | null, style?: Style) {
         super(parent);
         this.style = style;
@@ -58,7 +58,7 @@ export class SGraphShape extends SGraphItem {
      * 绘制前设置绘制样式
      *
      * @return 当前 item 状态值
-    */
+     */
     setStyle(): string {
         let status = "default";
         if (this.style) {
@@ -79,7 +79,7 @@ export class SGraphShape extends SGraphItem {
      *
      * @param str   渐变存储的字符串
      * @return 渐变颜色转为的字符串
-    */
+     */
     parseFill(str: string): SGradient | undefined {
         const index1 = str.indexOf("{");
         const index2 = str.indexOf("}");
@@ -125,7 +125,7 @@ export class SGraphShape extends SGraphItem {
      * 绘制
      *
      * @param painter   绘制对象
-    */
+     */
     onDraw(painter: SPainter): void {
         const status = this.setStyle();
         if (this.style && this.style[status]) {

+ 3 - 3
persagy-web-graph/src/items/SGraphSvgItem.ts

@@ -90,7 +90,7 @@ export class SGraphSvgItem extends SGraphShape {
      *
      * @param parent  父类
      * @param data    传入数据
-    */
+     */
     constructor(parent: SGraphItem | null, data: SGraphSvg) {
         super(parent, data.style);
         if (data.url) {
@@ -115,7 +115,7 @@ export class SGraphSvgItem extends SGraphShape {
      * Item 对象边界区域
      *
      * @return 边界区域
-    */
+     */
     boundingRect(): SRect {
         return new SRect(0, 0, this.width, this.height);
     } // Function boundingRect()
@@ -124,7 +124,7 @@ export class SGraphSvgItem extends SGraphShape {
      * Item 绘制操作
      *
      * @param painter   绘制对象
-    */
+     */
     onDraw(painter: SPainter): void {
         if (this.isLoadOver) {
             // @ts-ignore

+ 1 - 1
persagy-web-graph/src/items/SObjectItem.ts

@@ -80,6 +80,6 @@ export abstract class SObjectItem extends SGraphItem {
      *
      * @param oldSize   改之前的大小
      * @param newSize   改之后大小
-    */
+     */
     protected onResize(oldSize: SSize, newSize: SSize): void {} // Function onResize()
 } // Class SObjectItem

+ 8 - 8
persagy-web-graph/src/items/STextItem.ts

@@ -133,7 +133,7 @@ export class STextItem extends SObjectItem {
      *
      * @param parent      指向父 Item
      * @param str         文本内容
-    */
+     */
     constructor(parent: SGraphItem | null, str: string = "") {
         super(parent);
         this._text = str;
@@ -145,7 +145,7 @@ export class STextItem extends SObjectItem {
      * 对象边界区域
      *
      * @return 边界区域
-    */
+     */
     boundingRect(): SRect {
         return new SRect(
             -this.origin.x,
@@ -160,7 +160,7 @@ export class STextItem extends SObjectItem {
      *
      * @param x   x 坐标
      * @param y   y 坐标
-    */
+     */
     moveToOrigin(x: number, y: number): void {
         this.moveTo(this.x + x, this.y + y);
     } // Function moveToOrigin()
@@ -169,7 +169,7 @@ export class STextItem extends SObjectItem {
      * 绘制显示状态文本 Item
      *
      * @param painter    绘制对象
-    */
+     */
     protected drawShowText(painter: SPainter): void {
         painter.translate(-this.origin.x, -this.origin.y);
         //绘制矩形轮廓,是否选中
@@ -190,7 +190,7 @@ export class STextItem extends SObjectItem {
         painter.brush.color = new SColor(this.color);
         painter.shadow.shadowColor = SColor.Transparent;
         painter.font = this.font;
-        this._textArr.forEach((text: string, index: number) => {
+        this._textArr.forEach((text: string, index: number): void => {
             painter.drawText(
                 text,
                 this.font.size / 4,
@@ -202,14 +202,14 @@ export class STextItem extends SObjectItem {
 
     /**
      * 根据换行切割文本,绘制多行并计算外轮廓宽高
-    */
+     */
     protected drawFormatText(): void {
         if (this._painter instanceof SPainter) {
             this._painter.save();
             this._painter.font = this.font;
             let textMaxWidth = 0;
             let fontSize: number = this.font.size;
-            this._textArr.forEach((text: string, index: number) => {
+            this._textArr.forEach((text: string, index: number): void => {
                 let textWidth: number = this._painter
                     ? this._painter.textWidth(text) + fontSize / 2
                     : fontSize / 2;
@@ -232,7 +232,7 @@ export class STextItem extends SObjectItem {
      * Item 绘制操作
      *
      * @param painter   绘画对象
-    */
+     */
     onDraw(painter: SPainter): void {
         if (!(this._painter instanceof SPainter)) {
             this._painter = painter;

+ 6 - 6
persagy-web-graph/src/utils/SMathUtil.ts

@@ -39,7 +39,7 @@ export class SMathUtil {
      * @param x2    点 2 的 x 坐标
      * @param y2    点 2 的 y 坐标
      * @return 距离
-    */
+     */
     static pointDistance(
         x1: number,
         y1: number,
@@ -55,7 +55,7 @@ export class SMathUtil {
      * @param rect1   矩形 1
      * @param rect2   矩形 2
      * @return 矩形是否有交集
-    */
+     */
     static rectIntersection(rect1: SRect, rect2: SRect): boolean {
         let minX = rect1.x < rect2.x ? rect1.x : rect2.x;
         let minY = rect1.y < rect2.y ? rect1.y : rect2.y;
@@ -73,7 +73,7 @@ export class SMathUtil {
      * @param line1   线段 1
      * @param line2   线段 2
      * @return 交点 null 平行但不重合 'repeat' 重合
-    */
+     */
     static lineIntersection(
         line1: SLine,
         line2: SLine
@@ -103,7 +103,7 @@ export class SMathUtil {
      *
      * @param  sp  SPoint 类型点数组
      * @return 二维数组类型点数组
-    */
+     */
     static transferToArray(sp: SPoint[]): number[][] {
         return sp.map((t): number[] => {
             return [t.x, t.y];
@@ -115,7 +115,7 @@ export class SMathUtil {
      *
      * @param arr   二维数组类型点数组
      * @return SPoint 类型点数组
-    */
+     */
     static transferToSPoint(arr: number[][]): SPoint[] {
         return arr.map(
             (t): SPoint => {
@@ -129,7 +129,7 @@ export class SMathUtil {
      *
      * @param arr   轮廓线数组
      * @return 面积
-    */
+     */
     static calculateArea(arr: SPoint[]): number {
         let sum = 0;
         let n = arr.length;