Skip to content

Commit d1e9c96

Browse files
committed
refactor: eslint
1 parent 1611d85 commit d1e9c96

26 files changed

+111
-116
lines changed

frontend/src/stores/dashboard/dashboard.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,8 @@ export const dashboardStore = defineStore('dashboard', {
5656
},
5757
updateDashboardInfo(params: any) {
5858
Object.keys(params).forEach((key: string) => {
59-
// @ts-ignore
59+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
60+
// @ts-expect-error
6061
this.dashboardInfo[key] = params[key]
6162
})
6263
},

frontend/src/stores/dashboard/snapshot.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -53,13 +53,13 @@ export const snapshotStore = defineStore('snapshot', {
5353
this.snapshotIndex--
5454
const componentSnapshot =
5555
_.cloneDeep(this.snapshotData[this.snapshotIndex]) || getDefaultCanvasInfo()
56-
// @ts-ignore
56+
// @ts-expect-error eslint-disable-next-line @typescript-eslint/ban-ts-comment
5757
componentSnapshot.dashboardInfo.id = dashboardInfo.value.id
58-
// @ts-ignore
58+
// @ts-expect-error eslint-disable-next-line @typescript-eslint/ban-ts-comment
5959
componentSnapshot.dashboardInfo.pid = dashboardInfo.value.pid
60-
// @ts-ignore
60+
// @ts-expect-error eslint-disable-next-line @typescript-eslint/ban-ts-comment
6161
componentSnapshot.dashboardInfo.dataState = dashboardInfo.value.dataState
62-
// @ts-ignore
62+
// @ts-expect-error eslint-disable-next-line @typescript-eslint/ban-ts-comment
6363
componentSnapshot.dashboardInfo.contentId = dashboardInfo.value.contentId
6464
this.snapshotPublish(componentSnapshot)
6565
this.styleChangeTimes++
@@ -72,13 +72,13 @@ export const snapshotStore = defineStore('snapshot', {
7272
if (this.snapshotIndex < this.snapshotData.length - 1) {
7373
this.snapshotIndex++
7474
const snapshotInfo = _.cloneDeep(this.snapshotData[this.snapshotIndex])
75-
// @ts-ignore
75+
// @ts-expect-error eslint-disable-next-line @typescript-eslint/ban-ts-comment
7676
snapshotInfo.dashboardInfo.id = dashboardInfo.value.id
77-
// @ts-ignore
77+
// @ts-expect-error eslint-disable-next-line @typescript-eslint/ban-ts-comment
7878
snapshotInfo.dashboardInfo.pid = dashboardInfo.value.pid
79-
// @ts-ignore
79+
// @ts-expect-error eslint-disable-next-line @typescript-eslint/ban-ts-comment
8080
snapshotInfo.dashboardInfo.dataState = dashboardInfo.value.dataState
81-
// @ts-ignore
81+
// @ts-expect-error eslint-disable-next-line @typescript-eslint/ban-ts-comment
8282
snapshotInfo.dashboardInfo.contentId = dashboardInfo.value.contentId
8383
this.snapshotPublish(snapshotInfo)
8484
this.styleChangeTimes++
@@ -110,7 +110,7 @@ export const snapshotStore = defineStore('snapshot', {
110110
if (dataPrepareState.value) {
111111
this.styleChangeTimes = ++this.styleChangeTimes
112112
// Add a new snapshot
113-
// @ts-ignore
113+
// @ts-expect-error eslint-disable-next-line @typescript-eslint/ban-ts-comment
114114
this.snapshotData[++this.snapshotIndex] = {
115115
componentData: _.cloneDeep(componentData.value),
116116
canvasStyleData: _.cloneDeep(canvasStyleData.value),

frontend/src/utils/canvas.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// @ts-ignore
1+
// @ts-expect-error eslint-disable-next-line @typescript-eslint/ban-ts-comment
22
import SnowflakeID from 'snowflake-id'
33

44
const snowflake = new SnowflakeID({

frontend/src/views/dashboard/canvas/CanvasCore.vue

Lines changed: 23 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -11,22 +11,25 @@ const dashboardStore = dashboardStoreWithOut()
1111
const canvasLocked = ref(false) // Is the canvas movement locked, Default false
1212
const emits = defineEmits(['parentAddItemBox'])
1313
const { curComponentId, curComponent } = storeToRefs(dashboardStore)
14-
// @ts-ignore
14+
// @ts-expect-error eslint-disable-next-line @typescript-eslint/ban-ts-comment
1515
let currentInstance
1616
// Props
1717
const props = defineProps({
1818
canvasId: {
1919
type: String,
2020
default: 'canvas-main',
2121
},
22+
// eslint-disable-next-line vue/require-default-prop
2223
parentConfigItem: {
2324
type: Object as PropType<CanvasItem>,
2425
required: false,
2526
},
27+
// eslint-disable-next-line vue/require-default-prop
2628
dashboardInfo: {
2729
type: Object,
2830
required: false,
2931
},
32+
// eslint-disable-next-line vue/require-default-prop
3033
canvasStyleData: {
3134
type: Object,
3235
required: false,
@@ -191,7 +194,7 @@ function addItemToPositionBox(item: CanvasItem) {
191194
for (let j = item.y - 1; j < item.y - 1 + item.sizeY; j++) {
192195
if (pb[j] && pb[j][i]) {
193196
// Ensure the target location is valid
194-
// @ts-ignore
197+
// @ts-expect-error eslint-disable-next-line @typescript-eslint/ban-ts-comment
195198
pb[j][i].el = item // Place the item in the corresponding position
196199
}
197200
}
@@ -406,23 +409,21 @@ function removeItem(index: number) {
406409
moveItemUp(upItem, canGoUpRows)
407410
}
408411
})
409-
// @ts-ignore
410412
canvasComponentData.value.splice(index, 1)
411413
}
412414
413415
function getNextDragId() {
414416
if (!canvasComponentData.value || canvasComponentData.value.length === 0) {
415417
return 0
416418
}
417-
//@ts-ignore
418419
const validIds = canvasComponentData.value
419420
.map((item) => item._dragId)
420421
.filter((id) => id != null && id !== '') // 过滤 null、undefined 和空字符串
421422
422423
if (validIds.length === 0) {
423424
return 0
424425
}
425-
//@ts-ignore
426+
// @ts-expect-error eslint-disable-next-line @typescript-eslint/ban-ts-comment
426427
const maxDragId = Math.max(...validIds)
427428
return maxDragId + 1
428429
}
@@ -457,7 +458,7 @@ function changeToCoord(left: number, top: number, width: number, height: number)
457458
* Detect for collisions and take appropriate measures
458459
*
459460
* @param {CanvasItem} item comparison object
460-
* @param {CanvasCoord} tCord compares the coordinates of the object
461+
* @param {CanvasCoord} tCoord compares the coordinates of the object
461462
*/
462463
function findClosetCoords(item: CanvasItem, tCoord: CanvasCoord) {
463464
if (isOverlay) return
@@ -501,7 +502,7 @@ function findClosetCoords(item: CanvasItem, tCoord: CanvasCoord) {
501502
502503
/**
503504
* Generate coordinates
504-
* @param {CanvasItem} item: The item object to generate coordinates for
505+
* @param item
505506
*/
506507
function makeCoordinate(item: CanvasItem) {
507508
let width = cellWidth.value * item.sizeX - baseMarginLeft.value
@@ -524,7 +525,7 @@ function makeCoordinate(item: CanvasItem) {
524525
525526
/**
526527
* Change the coordinates of the item
527-
* @param {CanvasItem} item: The item object whose coordinates need to be changed
528+
* @param item
528529
*/
529530
function changeItemCoord(item: CanvasItem) {
530531
let width = cellWidth.value * item.sizeX - baseMarginLeft.value
@@ -686,7 +687,7 @@ function findBelowItems(item: CanvasItem) {
686687
for (let row = item.y - 1; row < positionBox.value.length; row++) {
687688
const target = positionBox.value[row][cell]
688689
if (target && target.el) {
689-
// @ts-ignore
690+
// @ts-expect-error eslint-disable-next-line @typescript-eslint/ban-ts-comment
690691
belowItems[target.el._dragId] = target.el
691692
break
692693
}
@@ -696,7 +697,6 @@ function findBelowItems(item: CanvasItem) {
696697
return _.sortBy(Object.values(belowItems), 'y')
697698
}
698699
699-
// @ts-ignore
700700
function startResize(e: MouseEvent, point: string, item: CanvasItem, index: number) {
701701
if (!resizable.value) return
702702
dashboardStore.setCurComponent(item)
@@ -706,7 +706,6 @@ function startResize(e: MouseEvent, point: string, item: CanvasItem, index: numb
706706
if (!infoBox.value) {
707707
infoBox.value = {} // Reinitialize
708708
}
709-
// Get the parent element of. tem
710709
infoBox.value.resizeItem = item
711710
infoBox.value.resizeItemIndex = index
712711
// Drag and drop coordinate points
@@ -724,7 +723,7 @@ function containerMouseDown(e: MouseEvent) {
724723
}
725724
infoBox.value.startX = e.pageX
726725
infoBox.value.startY = e.pageY
727-
// @ts-ignore
726+
// @ts-expect-error eslint-disable-next-line @typescript-eslint/ban-ts-comment
728727
if (curComponent.value?.component !== 'SQText') {
729728
e.preventDefault()
730729
e.stopPropagation()
@@ -792,7 +791,7 @@ function startMove(e: MouseEvent, item: CanvasItem, index: number) {
792791
}
793792
794793
const target = e.target
795-
// @ts-ignore
794+
// @ts-expect-error eslint-disable-next-line @typescript-eslint/ban-ts-comment
796795
let className = target.className || ''
797796
798797
if (
@@ -813,13 +812,13 @@ function startMove(e: MouseEvent, item: CanvasItem, index: number) {
813812
814813
infoBox.value.cloneItem = null
815814
infoBox.value.nowItemNode = null
816-
// @ts-ignore
815+
// @ts-expect-error eslint-disable-next-line @typescript-eslint/ban-ts-comment
817816
if (target.className.includes('item')) {
818817
infoBox.value.nowItemNode = target
819-
// @ts-ignore
818+
// @ts-expect-error eslint-disable-next-line @typescript-eslint/ban-ts-comment
820819
infoBox.value.cloneItem = target.cloneNode(true)
821820
} else {
822-
// @ts-ignore
821+
// @ts-expect-error eslint-disable-next-line @typescript-eslint/ban-ts-comment
823822
infoBox.value.nowItemNode = target.closest('.item')
824823
infoBox.value.cloneItem = infoBox.value.nowItemNode.cloneNode(true)
825824
}
@@ -936,7 +935,7 @@ function startMove(e: MouseEvent, item: CanvasItem, index: number) {
936935
if (curActiveMoveInSQTab) {
937936
if (curActiveMoveInSQTab.moveInActive) {
938937
const refTabInstance =
939-
// @ts-ignore
938+
// @ts-expect-error eslint-disable-next-line @typescript-eslint/ban-ts-comment
940939
currentInstance.refs['shape_component_' + curActiveMoveInSQTab.id][0]
941940
refTabInstance.addTabItem(moveItem)
942941
removeItemById(moveItem.id)
@@ -949,6 +948,7 @@ function startMove(e: MouseEvent, item: CanvasItem, index: number) {
949948
if (props.parentConfigItem && props.parentConfigItem.moveOutActive) {
950949
emits('parentAddItemBox', _.cloneDeep(moveItem))
951950
removeItemById(moveItem.id)
951+
// eslint-disable-next-line vue/no-mutating-props
952952
props.parentConfigItem.moveOutActive = false
953953
}
954954
}
@@ -991,18 +991,16 @@ function nowItemStyle(item: CanvasItem) {
991991
992992
function getList() {
993993
let returnList = _.sortBy(_.cloneDeep(canvasComponentData.value), 'y')
994-
// @ts-ignore
994+
// @ts-expect-error eslint-disable-next-line @typescript-eslint/ban-ts-comment
995995
let finalList = []
996-
// @ts-ignore
997-
_.forEach(returnList, function (item, index) {
996+
_.forEach(returnList, function (item) {
998997
if (_.isEmpty(item)) return
999-
// @ts-ignore
998+
// @ts-expect-error eslint-disable-next-line @typescript-eslint/ban-ts-comment
1000999
delete item['_dragId']
1001-
// @ts-ignore
10021000
delete item['show']
10031001
finalList.push(item)
10041002
})
1005-
// @ts-ignore
1003+
// @ts-expect-error eslint-disable-next-line @typescript-eslint/ban-ts-comment
10061004
return finalList
10071005
}
10081006
@@ -1014,7 +1012,7 @@ function getRenderState() {
10141012
return moveAnimate.value
10151013
}
10161014
1017-
// @ts-ignore
1015+
// @ts-expect-error eslint-disable-next-line @typescript-eslint/ban-ts-comment
10181016
function afterInitOk(func) {
10191017
let timeId = setInterval(() => {
10201018
if (moveAnimate.value) {
@@ -1064,30 +1062,14 @@ function getItemStylePosition(item: CanvasItem) {
10641062
}
10651063
}
10661064
1067-
// @ts-ignore
1068-
function tabMoveInCheck(cloneRefItem) {
1069-
//1. If the current cloneItem type is not a tab,
1070-
// check if there are any tab components with overlapping boundaries (about to overlap) in the top left and right directions of the current Item
1071-
//2.If there is, the original item of the current cloneItem is not moving (the entire dashboard will not be rearranged)
1072-
//3. Activate this tab item. At this time, the tab item displays the activation status
1073-
//4. Release this cloneItem from the main canvas and remove the canvas with the added item
1074-
const moveItem = infoBox.value.moveItem
1075-
if (moveItem && moveItem !== 'SQTab') {
1076-
canvasComponentData.value.forEach((item) => {
1077-
// Determine the position of SQTab components around moveItem
1078-
if (item.id !== moveItem.id && item.component === 'SQTab') {
1079-
}
1080-
})
1081-
}
1082-
}
1083-
10841065
function tabMoveOutCheckSQ() {
10851066
const { cloneItem, moveItem } = infoBox.value
10861067
if (cloneItem && moveItem && props.canvasId.includes('tab') && props.parentConfigItem) {
10871068
const left = cloneItem.offsetLeft
10881069
const width = cloneItem.offsetWidth
10891070
const top = cloneItem.offsetTop
10901071
const { tw } = getItemStylePosition(props.parentConfigItem)
1072+
// eslint-disable-next-line vue/no-mutating-props
10911073
props.parentConfigItem.moveOutActive =
10921074
left < -tabMoveOutXOffset || top < -tabMoveOutYOffset || left + width - tw > tabMoveOutXOffset
10931075
canvasLocked.value = props.parentConfigItem.moveOutActive

frontend/src/views/dashboard/canvas/DragHandle.vue

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ defineProps({
55
sizeList: {
66
type: Array as PropType<number[]>,
77
required: false,
8+
// eslint-disable-next-line vue/require-valid-default-prop
89
default: [12, 12, 12, 12],
910
},
1011
})
@@ -45,6 +46,7 @@ const shadowStyle = (size: number, index: number) => {
4546
<template>
4647
<div
4748
v-for="(size, index) in sizeList"
49+
:key="index"
4850
class="dragHandle dragArea"
4951
:style="shadowStyle(size, index)"
5052
></div>

frontend/src/views/dashboard/common/HandleMore.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ withDefaults(
1515
defineProps<{
1616
menuList: Menu[]
1717
placement?: Placement
18+
// eslint-disable-next-line vue/require-default-prop
1819
iconName?: any
1920
iconSize?: string
2021
inTable?: boolean
@@ -48,7 +49,7 @@ const emit = defineEmits(['handleCommand'])
4849
</el-icon>
4950
<template #dropdown>
5051
<el-dropdown-menu :persistent="false">
51-
<template v-for="ele in menuList">
52+
<template v-for="ele in menuList" :key="ele">
5253
<el-dropdown-item :divided="ele.divided" :command="ele.command" :disabled="ele.disabled">
5354
<el-icon v-if="ele.svgName" class="handle-icon" :style="{ fontSize: iconSize }">
5455
<Icon>

frontend/src/views/dashboard/common/ResourceGroupOpt.vue

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,15 +54,15 @@ const getTree = async () => {
5454
}
5555
5656
const optInit = (params: any) => {
57-
// @ts-ignore
57+
// @ts-expect-error eslint-disable-next-line @typescript-eslint/ban-ts-comment
5858
state.dialogTitle = getTitle(params.opt)
5959
state.opt = params.opt
6060
state.id = params.id
6161
state.parentSelect = params.parentSelect
6262
state.targetInfo = params.data
6363
state.nodeType = params.nodeType || 'folder'
6464
resourceDialogShow.value = true
65-
// @ts-ignore
65+
// @ts-expect-error eslint-disable-next-line @typescript-eslint/ban-ts-comment
6666
resourceForm.name = params.name || getResourceNewName(params.opt)
6767
resourceForm.pid = params.pid || 'root'
6868
if (params.parentSelect) {
@@ -119,7 +119,7 @@ const propsTree = {
119119
value: 'id',
120120
label: 'name',
121121
children: 'children',
122-
// @ts-ignore
122+
// @ts-expect-error eslint-disable-next-line @typescript-eslint/ban-ts-comment
123123
isLeaf: (node) => !node.children?.length,
124124
}
125125
@@ -154,7 +154,7 @@ const nodeClick = (data: SQTreeNode) => {
154154
}
155155
156156
const filterMethod = (value: any) => {
157-
// @ts-ignore
157+
// @ts-expect-error eslint-disable-next-line @typescript-eslint/ban-ts-comment
158158
state.tData = state.tDataSource.filter((item) => item.name.includes(value))
159159
}
160160

0 commit comments

Comments
 (0)