refactor: 更换 ESLint 配置为 @antfu/eslint-config

This commit is contained in:
2024-05-10 22:29:45 +08:00
parent 5101dd12d9
commit bfc8e42bad
148 changed files with 7314 additions and 5046 deletions

View File

@@ -42,8 +42,8 @@
:loading="loading"
:scroll="{ x: '100%', y: 800, minWidth: 900 }"
:pagination="false"
:disabledTools="['setting', 'refresh']"
:disabledColumnKeys="['tableName']"
:disabled-tools="['setting', 'refresh']"
:disabled-column-keys="['tableName']"
>
<template #custom-left>
<a-popconfirm
@@ -57,7 +57,7 @@
status="success"
size="small"
title="同步"
:disabled="dataList.length !== 0 && dataList[0].createTime === null"
:disabled="dataList.length !== 0 && dataList[0].createTime == null"
>
<template #icon><icon-sync /></template>同步
</a-button>
@@ -111,13 +111,16 @@
</template>
<script setup lang="ts">
import { listFieldConfig, getGenConfig, saveGenConfig, type FieldConfigResp, type GeneratorConfigResp } from '@/apis'
import { Message, type FormInstance } from '@arco-design/web-vue'
import { type FormInstance, Message } from '@arco-design/web-vue'
import { useWindowSize } from '@vueuse/core'
import { type FieldConfigResp, type GeneratorConfigResp, getGenConfig, listFieldConfig, saveGenConfig } from '@/apis'
import type { TableInstanceColumns } from '@/components/GiTable/type'
import { useForm } from '@/hooks'
import { useDict } from '@/hooks/app'
import { useWindowSize } from '@vueuse/core'
const emit = defineEmits<{
(e: 'save-success'): void
}>()
const { width } = useWindowSize()
const { form_type_enum, query_type_enum } = useDict('form_type_enum', 'query_type_enum')
@@ -208,10 +211,6 @@ const save = async () => {
}
}
const emit = defineEmits<{
(e: 'save-success'): void
}>()
defineExpose({ onConfig })
</script>

View File

@@ -39,9 +39,9 @@
</template>
<script setup lang="ts">
import { genPreview, type GeneratePreviewResp, generate } from '@/apis'
import { Message, type TreeNodeData } from '@arco-design/web-vue'
import { useClipboard } from '@vueuse/core'
import { type GeneratePreviewResp, genPreview, generate } from '@/apis'
const { copy, copied } = useClipboard()
const currentPreview = ref<GeneratePreviewResp>()
@@ -51,20 +51,35 @@ const visible = ref(false)
const treeData = ref<TreeNodeData[]>([])
const previewTableName = ref<string>('')
// 打开
const onPreview = async (tableName: string) => {
treeData.value = []
previewTableName.value = tableName
const res = await genPreview(tableName)
genPreviewList.value = res.data
for (const genPreview of genPreviewList.value) {
assembleTree(genPreview)
const mergeDir = (parent: TreeNodeData) => {
// 合并目录
if (parent.children?.length === 1 && typeof parent.children[0].key === 'number') {
const mergeTitle = mergeDir(parent.children[0])
if (mergeTitle !== '') {
parent.title = `${parent.title}/${mergeTitle}`
}
parent.children = parent.children[0].children
return parent.title
}
for (const valueElement of treeData.value) {
mergeDir(valueElement)
// 合并子目录
if (parent?.children) {
for (const child of parent.children) {
mergeDir(child)
}
}
currentPreview.value = genPreviewList.value[0]
visible.value = true
return ''
}
const pushDir = (children: TreeNodeData[] | undefined, treeNode: TreeNodeData) => {
if (children) {
for (const child of children) {
if (child.title === treeNode.title) {
return child.children
}
}
}
children?.push(treeNode)
return treeNode.children
}
// 自增的一个key 因为key相同的节点会出现一些问题
@@ -80,35 +95,20 @@ const assembleTree = (genPreview: GeneratePreviewResp) => {
tempChildren?.push({ title: genPreview.fileName, key: genPreview.fileName, children: new Array<TreeNodeData>() })
}
const pushDir = (children: TreeNodeData[] | undefined, treeNode: TreeNodeData) => {
if (children) {
for (const child of children) {
if (child.title === treeNode.title) {
return child.children
}
}
// 打开
const onPreview = async (tableName: string) => {
treeData.value = []
previewTableName.value = tableName
const res = await genPreview(tableName)
genPreviewList.value = res.data
for (const genPreview of genPreviewList.value) {
assembleTree(genPreview)
}
children?.push(treeNode)
return treeNode.children
}
const mergeDir = (parent: TreeNodeData) => {
// 合并目录
if (parent.children?.length == 1 && typeof parent.children[0].key === 'number') {
const mergeTitle = mergeDir(parent.children[0])
if (mergeTitle != '') {
parent.title = parent.title + '/' + mergeTitle
}
parent.children = parent.children[0].children
return parent.title
for (const valueElement of treeData.value) {
mergeDir(valueElement)
}
// 合并子目录
if (parent?.children) {
for (const child of parent.children) {
mergeDir(child)
}
}
return ''
currentPreview.value = genPreviewList.value[0]
visible.value = true
}
// 选择文件预览
@@ -134,7 +134,7 @@ watch(copied, () => {
const onGenerate = async () => {
const res = await generate([previewTableName.value])
const contentDisposition = res.headers['content-disposition']
const pattern = new RegExp('filename=([^;]+\\.[^\.;]+);*')
const pattern = /filename=([^;]+\.[^.;]+);*/
const result = pattern.exec(contentDisposition) || ''
// 对名字进行解码
const fileName = window.decodeURI(result[1])

View File

@@ -8,8 +8,8 @@
:loading="loading"
:scroll="{ x: '100%', y: '100%', minWidth: 1000 }"
:pagination="pagination"
:disabledTools="['size', 'setting']"
:disabledColumnKeys="['tableName']"
:disabled-tools="['size', 'setting']"
:disabled-column-keys="['tableName']"
@refresh="search"
>
<template #custom-left>
@@ -25,8 +25,9 @@
:title="record.isConfiged ? '生成' : '请先进行生成配置'"
:disabled="!record.isConfiged"
@click="onPreview(record.tableName)"
>生成</a-link
>
生成
</a-link>
</a-space>
</template>
</GiTable>
@@ -38,15 +39,27 @@
</template>
<script setup lang="ts">
import { listGenerator } from '@/apis'
import GenConfigDrawer from './GenConfigDrawer.vue'
import GenPreviewModal from './GenPreviewModal.vue'
import { listGenerator } from '@/apis'
import type { TableInstanceColumns } from '@/components/GiTable/type'
import { useTable } from '@/hooks'
import { isMobile } from '@/utils'
defineOptions({ name: 'Generator' })
const queryForm = reactive({
tableName: undefined,
sort: ['createTime,desc']
})
const {
tableData: dataList,
loading,
pagination,
search
} = useTable((p) => listGenerator({ ...queryForm, page: p.page, size: p.size }), { immediate: true })
const columns: TableInstanceColumns[] = [
{
title: '序号',
@@ -62,18 +75,6 @@ const columns: TableInstanceColumns[] = [
{ title: '操作', slotName: 'action', width: 180, align: 'center', fixed: !isMobile() ? 'right' : undefined }
]
const queryForm = reactive({
tableName: undefined,
sort: ['createTime,desc']
})
const {
tableData: dataList,
loading,
pagination,
search
} = useTable((p) => listGenerator({ ...queryForm, page: p.page, size: p.size }), { immediate: true })
// 重置
const reset = () => {
queryForm.tableName = undefined