From b07e8ac8f3dc82532142395e9664ce5d584d2012 Mon Sep 17 00:00:00 2001 From: wangxiang <1827945911@qq.com> Date: Sat, 16 Apr 2022 20:03:17 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=8E=9F=20=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- kicc-ui/src/api/gateway/api.ts | 22 --- kicc-ui/src/api/gateway/blacklist.ts | 22 --- kicc-ui/src/api/gateway/model/apiModel.ts | 29 ---- .../src/api/gateway/model/blacklistModel.ts | 24 ---- kicc-ui/src/api/gateway/model/routeModel.ts | 24 ---- kicc-ui/src/api/gateway/route.ts | 22 --- kicc-ui/src/utils/helper/treeHelper.ts | 79 ++++------ kicc-ui/src/views/gateway/api/ApiDrawer.vue | 54 ------- kicc-ui/src/views/gateway/api/RouteTree.vue | 45 ------ kicc-ui/src/views/gateway/api/api.data.ts | 136 ------------------ kicc-ui/src/views/gateway/api/index.vue | 94 ------------ .../gateway/blacklist/BlacklistDrawer.vue | 58 -------- .../views/gateway/blacklist/blacklist.data.ts | 128 ----------------- kicc-ui/src/views/gateway/blacklist/index.vue | 85 ----------- .../src/views/gateway/route/RouteDrawer.vue | 54 ------- kicc-ui/src/views/gateway/route/index.vue | 85 ----------- kicc-ui/src/views/gateway/route/route.data.ts | 109 -------------- 17 files changed, 27 insertions(+), 1043 deletions(-) delete mode 100644 kicc-ui/src/api/gateway/api.ts delete mode 100644 kicc-ui/src/api/gateway/blacklist.ts delete mode 100644 kicc-ui/src/api/gateway/model/apiModel.ts delete mode 100644 kicc-ui/src/api/gateway/model/blacklistModel.ts delete mode 100644 kicc-ui/src/api/gateway/model/routeModel.ts delete mode 100644 kicc-ui/src/api/gateway/route.ts delete mode 100644 kicc-ui/src/views/gateway/api/ApiDrawer.vue delete mode 100644 kicc-ui/src/views/gateway/api/RouteTree.vue delete mode 100644 kicc-ui/src/views/gateway/api/api.data.ts delete mode 100644 kicc-ui/src/views/gateway/api/index.vue delete mode 100644 kicc-ui/src/views/gateway/blacklist/BlacklistDrawer.vue delete mode 100644 kicc-ui/src/views/gateway/blacklist/blacklist.data.ts delete mode 100644 kicc-ui/src/views/gateway/blacklist/index.vue delete mode 100644 kicc-ui/src/views/gateway/route/RouteDrawer.vue delete mode 100644 kicc-ui/src/views/gateway/route/index.vue delete mode 100644 kicc-ui/src/views/gateway/route/route.data.ts diff --git a/kicc-ui/src/api/gateway/api.ts b/kicc-ui/src/api/gateway/api.ts deleted file mode 100644 index a77f521c..00000000 --- a/kicc-ui/src/api/gateway/api.ts +++ /dev/null @@ -1,22 +0,0 @@ -import { ApiVO, ApiDTO, Api as SysApi } from './model/apiModel'; -import { defHttp } from '/@/utils/http/axios'; - -enum Api { - Page = '/mate-system/api/page', - Set = '/mate-system/api/set', - Del = '/mate-system/api/del', - Sync = '/mate-system/api/sync', -} - -// 分页查询 -export const page = (params: ApiVO) => defHttp.get({ url: Api.Page, params }); - -// 保存 -export const set = (params: SysApi) => defHttp.post({ url: Api.Set, params }); - -// 同步 -export const sync = () => defHttp.post({ url: Api.Sync }); - -// 删除 -export const del = (params: { ids: String }) => - defHttp.post({ url: Api.Del + `?ids=${params.ids}` }); diff --git a/kicc-ui/src/api/gateway/blacklist.ts b/kicc-ui/src/api/gateway/blacklist.ts deleted file mode 100644 index bcdd5049..00000000 --- a/kicc-ui/src/api/gateway/blacklist.ts +++ /dev/null @@ -1,22 +0,0 @@ -import { BlacklistVO, BlacklistDTO, Blacklist } from './model/blacklistModel'; -import { defHttp } from '/@/utils/http/axios'; - -enum Api { - Page = '/mate-system/blacklist/page', - Set = '/mate-system/blacklist/set', - Del = '/mate-system/blacklist/del', - Tree = '/mate-system/blacklist/list-item', -} - -// 分页查询 -export const page = (params: BlacklistVO) => defHttp.get({ url: Api.Page, params }); - -// 树 -export const tree = () => defHttp.get({ url: Api.Tree }); - -// 保存 -export const set = (params: Blacklist) => defHttp.post({ url: Api.Set, params }); - -// 删除 -export const del = (params: { ids: String }) => - defHttp.post({ url: Api.Del + `?ids=${params.ids}` }); diff --git a/kicc-ui/src/api/gateway/model/apiModel.ts b/kicc-ui/src/api/gateway/model/apiModel.ts deleted file mode 100644 index 1edec140..00000000 --- a/kicc-ui/src/api/gateway/model/apiModel.ts +++ /dev/null @@ -1,29 +0,0 @@ -// 引入基础包 -import { BasicPageParams, BasicFetchResult } from '/@/api/model/baseModel'; - -// 定义查询参数 -export type ApiVO = BasicPageParams & { - keyword?: string; - startDate?: string; - endDate?: string; -}; - -// 定义系统接口对象 -export interface Api { - id: string; - code: string; - name: string; - notes: string; - method: string; - className: string; - methodName: string; - path: string; - contentType: string; - serviceId: string; - status: string; - auth: string; - createTime: string; -} - -// 根据字典对象生成响应模型 -export type ApiDTO = BasicFetchResult; diff --git a/kicc-ui/src/api/gateway/model/blacklistModel.ts b/kicc-ui/src/api/gateway/model/blacklistModel.ts deleted file mode 100644 index 477f6089..00000000 --- a/kicc-ui/src/api/gateway/model/blacklistModel.ts +++ /dev/null @@ -1,24 +0,0 @@ -// 引入基础包 -import { BasicPageParams, BasicFetchResult } from '/@/api/model/baseModel'; - -// 定义查询参数 -export type BlacklistVO = BasicPageParams & { - keyword?: string; - startDate?: string; - endDate?: string; -}; - -// 定义黑名单对象 -export interface Blacklist { - id: string; - ip: string; - requestUri: string; - requestMethod: string; - startTime: string; - endTime: string; - status: string; - createTime: string; -} - -// 根据字典对象生成响应模型 -export type BlacklistDTO = BasicFetchResult; diff --git a/kicc-ui/src/api/gateway/model/routeModel.ts b/kicc-ui/src/api/gateway/model/routeModel.ts deleted file mode 100644 index 6cddbb72..00000000 --- a/kicc-ui/src/api/gateway/model/routeModel.ts +++ /dev/null @@ -1,24 +0,0 @@ -// 引入基础包 -import { BasicPageParams, BasicFetchResult } from '/@/api/model/baseModel'; - -// 定义查询参数 -export type RouteVO = BasicPageParams & { - keyword?: string; - startDate?: string; - endDate?: string; -}; - -// 定义路由对象 -export interface Route { - id: string; - name: string; - path: string; - url: string; - serviceId: string; - status: string; - tenantId: string; - createTime: string; -} - -// 根据字典对象生成响应模型 -export type RouteDTO = BasicFetchResult; diff --git a/kicc-ui/src/api/gateway/route.ts b/kicc-ui/src/api/gateway/route.ts deleted file mode 100644 index d5ee68dd..00000000 --- a/kicc-ui/src/api/gateway/route.ts +++ /dev/null @@ -1,22 +0,0 @@ -import { RouteVO, RouteDTO, Route } from './model/routeModel'; -import { defHttp } from '/@/utils/http/axios'; - -enum Api { - Page = '/mate-system/route/page', - Set = '/mate-system/route/set', - Del = '/mate-system/route/del', - Tree = '/mate-system/route/list-item', -} - -// 分页查询 -export const page = (params: RouteVO) => defHttp.get({ url: Api.Page, params }); - -// 树 -export const tree = () => defHttp.get({ url: Api.Tree }); - -// 保存 -export const set = (params: Route) => defHttp.post({ url: Api.Set, params }); - -// 删除 -export const del = (params: { ids: String }) => - defHttp.post({ url: Api.Del + `?ids=${params.ids}` }); diff --git a/kicc-ui/src/utils/helper/treeHelper.ts b/kicc-ui/src/utils/helper/treeHelper.ts index 0a4acd3e..514fc670 100644 --- a/kicc-ui/src/utils/helper/treeHelper.ts +++ b/kicc-ui/src/utils/helper/treeHelper.ts @@ -18,7 +18,7 @@ const DEFAULT_CONFIG: TreeHelperConfig = { const getConfig = (config: Partial) => Object.assign({}, DEFAULT_CONFIG, config); -// 列表中的树 +/** 集合转换树形 */ export function listToTree(list: any[], config: Partial = {}): T[] { const conf = getConfig(config) as TreeHelperConfig; const nodeMap = new Map(); @@ -36,6 +36,7 @@ export function listToTree(list: any[], config: Partial(tree: any, config: Partial = {}): T { config = getConfig(config); const { children } = config; @@ -47,11 +48,8 @@ export function treeToList(tree: any, config: Partial return result; } -export function findNode( - tree: any, - func: Fn, - config: Partial = {} -): T | null { +/** 查找树形匹配的节点信息,只包含当前节点数据 */ +export function findNode(tree: any, func: Fn, config: Partial = {}): T | null { config = getConfig(config); const { children } = config; const list = [...tree]; @@ -62,11 +60,8 @@ export function findNode( return null; } -export function findNodeAll( - tree: any, - func: Fn, - config: Partial = {} -): T[] { +/** 查找树形匹配的节点信息,包含当前节点数据以及他父级的节点数据,以集合的形式返回 */ +export function findNodeAll(tree: any, func: Fn, config: Partial = {}): T[] { config = getConfig(config); const { children } = config; const list = [...tree]; @@ -78,11 +73,8 @@ export function findNodeAll( return result; } -export function findPath( - tree: any, - func: Fn, - config: Partial = {} -): T | T[] | null { +/** 查找树形集合父级元素,可以使用func函数进行控制 */ +export function findPath(tree: any, func: Fn, config: Partial = {}): T | T[] | null { config = getConfig(config); const path: T[] = []; const list = [...tree]; @@ -105,6 +97,7 @@ export function findPath( return null; } +/** 查找树形集合所有父级元素,不能使用func函数进行控制,只能利用func函数处理数据 */ export function findPathAll(tree: any, func: Fn, config: Partial = {}) { config = getConfig(config); const path: any[] = []; @@ -127,70 +120,52 @@ export function findPathAll(tree: any, func: Fn, config: Partial( - tree: T[], - func: (n: T) => boolean, - config: Partial = {} -): T[] { +/** 树形集合过滤,过滤后数据为父级元素加子级元素的形式 */ +export function filter(tree: T[], func: (n: T) => boolean, config: Partial = {}): T[] { config = getConfig(config); const children = config.children as string; function listFilter(list: T[]) { - return list - .map((node: any) => ({ ...node })) - .filter((node) => { - node[children] = node[children] && listFilter(node[children]); - return func(node) || (node[children] && node[children].length); - }); + return list.map((node: any) => ({ ...node })).filter((node) => { + node[children] = node[children] && listFilter(node[children]); + return func(node) || (node[children] && node[children].length); + }); } return listFilter(tree); } -export function forEach( - tree: T[], - func: (n: T) => any, - config: Partial = {} -): void { +/** 树形集合循环 */ +export function forEach(tree: T[], func: (n: T) => any, config: Partial = {}): void { config = getConfig(config); const list: any[] = [...tree]; const { children } = config; for (let i = 0; i < list.length; i++) { - //func 返回true就终止遍历,避免大量节点场景下无意义循环,引起浏览器卡顿 - if (func(list[i])) { - return; - } + // func返回true就终止遍历,避免大量节点场景下无意义循环,引起浏览器卡顿 + if (func(list[i])) return; children && list[i][children] && list.splice(i + 1, 0, ...list[i][children]); } } -/** - * 提取树指定结构 - */ +/** 提取树指定结构 */ export function treeMap(treeData: T[], opt: { children?: string; conversion: Fn }): T[] { return treeData.map((item) => treeMapEach(item, opt)); } -/** - * 提取树指定结构 - */ -export function treeMapEach( - data: any, - { children = 'children', conversion }: { children?: string; conversion: Fn } -) { +/** 进行循环转换指定树结构 */ +export function treeMapEach(data: any, { children = 'children', conversion }: { children?: string; conversion: Fn }) { const haveChildren = Array.isArray(data[children]) && data[children].length > 0; const conversionData = conversion(data) || {}; if (haveChildren) { return { ...conversionData, [children]: data[children].map((i: number) => - treeMapEach(i, { - children, - conversion, - }) - ), + treeMapEach(i, { + children, + conversion, + })) }; } else { return { - ...conversionData, + ...conversionData }; } } diff --git a/kicc-ui/src/views/gateway/api/ApiDrawer.vue b/kicc-ui/src/views/gateway/api/ApiDrawer.vue deleted file mode 100644 index 5bbf11aa..00000000 --- a/kicc-ui/src/views/gateway/api/ApiDrawer.vue +++ /dev/null @@ -1,54 +0,0 @@ - - diff --git a/kicc-ui/src/views/gateway/api/RouteTree.vue b/kicc-ui/src/views/gateway/api/RouteTree.vue deleted file mode 100644 index 997a3ce0..00000000 --- a/kicc-ui/src/views/gateway/api/RouteTree.vue +++ /dev/null @@ -1,45 +0,0 @@ - - diff --git a/kicc-ui/src/views/gateway/api/api.data.ts b/kicc-ui/src/views/gateway/api/api.data.ts deleted file mode 100644 index 1703ea74..00000000 --- a/kicc-ui/src/views/gateway/api/api.data.ts +++ /dev/null @@ -1,136 +0,0 @@ -import { BasicColumn } from '/@/components/Table'; -import { FormSchema } from '/@/components/Table'; -import { h } from 'vue'; -import { Tag } from 'ant-design-vue'; - -export const columns: BasicColumn[] = [ - { - title: '编码', - dataIndex: 'code', - width: 100, - }, - { - title: '服务ID', - dataIndex: 'serviceId', - width: 100, - }, - { - title: '名称', - dataIndex: 'name', - width: 100, - }, - { - title: '请求方法', - dataIndex: 'method', - width: 60, - }, - { - title: '请求路径', - dataIndex: 'path', - width: 130, - }, - { - title: '认证', - dataIndex: 'auth', - width: 60, - customRender: ({ record }) => { - const auth = record.auth; - const enable = ~~auth === 1; - const color = enable ? 'green' : 'red'; - const text = enable ? '认证' : '不认证'; - return h(Tag, { color: color }, () => text); - }, - }, - { - title: '状态', - dataIndex: 'status', - width: 60, - customRender: ({ record }) => { - const status = record.status; - const enable = ~~status === 0; - const color = enable ? 'green' : 'red'; - const text = enable ? '启用' : '停用'; - return h(Tag, { color: color }, () => text); - }, - }, - { - title: '创建时间', - dataIndex: 'createTime', - width: 100, - }, -]; - -export const searchFormSchema: FormSchema[] = [ - { - field: 'keyword', - label: '关键字', - component: 'Input', - componentProps: { - placeholder: '请输入编码/请求地址', - }, - colProps: { span: 8 }, - }, - { - field: 'startDate', - label: '起始时间', - component: 'DatePicker', - colProps: { span: 8 }, - }, - { - field: 'endDate', - label: '截止时间', - component: 'DatePicker', - colProps: { span: 8 }, - }, -]; - -export const formSchema: FormSchema[] = [ - { - field: 'id', - label: 'ID', - component: 'Input', - show: false, - }, - { - field: 'code', - label: '编码', - component: 'Input', - }, - { - field: 'serviceId', - label: '服务ID', - component: 'Input', - }, - { - field: 'name', - label: '名称', - component: 'Input', - }, - { - field: 'method', - label: '请求方法', - component: 'Input', - }, - { - field: 'className', - label: '类名', - component: 'Input', - }, - { - field: 'methodName', - label: '方法名', - component: 'Input', - }, - { - field: 'status', - label: '状态', - component: 'RadioButtonGroup', - defaultValue: '0', - componentProps: { - options: [ - { label: '启用', value: '0' }, - { label: '禁用', value: '1' }, - ], - }, - }, -]; diff --git a/kicc-ui/src/views/gateway/api/index.vue b/kicc-ui/src/views/gateway/api/index.vue deleted file mode 100644 index 574f4595..00000000 --- a/kicc-ui/src/views/gateway/api/index.vue +++ /dev/null @@ -1,94 +0,0 @@ - - diff --git a/kicc-ui/src/views/gateway/blacklist/BlacklistDrawer.vue b/kicc-ui/src/views/gateway/blacklist/BlacklistDrawer.vue deleted file mode 100644 index 8d551fa2..00000000 --- a/kicc-ui/src/views/gateway/blacklist/BlacklistDrawer.vue +++ /dev/null @@ -1,58 +0,0 @@ - - diff --git a/kicc-ui/src/views/gateway/blacklist/blacklist.data.ts b/kicc-ui/src/views/gateway/blacklist/blacklist.data.ts deleted file mode 100644 index 9c8a6255..00000000 --- a/kicc-ui/src/views/gateway/blacklist/blacklist.data.ts +++ /dev/null @@ -1,128 +0,0 @@ -import { BasicColumn } from '/@/components/Table'; -import { FormSchema } from '/@/components/Table'; -import { h } from 'vue'; -import { Tag } from 'ant-design-vue'; -import moment from 'moment'; - -export const columns: BasicColumn[] = [ - { - title: 'IP地址', - dataIndex: 'ip', - width: 100, - }, - { - title: '请求地址', - dataIndex: 'requestUri', - width: 130, - }, - { - title: '请求方法', - dataIndex: 'requestMethod', - width: 80, - }, - { - title: '开始时间', - dataIndex: 'startTime', - width: 90, - }, - { - title: '结束时间', - dataIndex: 'endTime', - width: 90, - }, - { - title: '状态', - dataIndex: 'status', - width: 80, - customRender: ({ record }) => { - const status = record.status; - const enable = ~~status === 0; - const color = enable ? 'green' : 'red'; - const text = enable ? '启用' : '停用'; - return h(Tag, { color: color }, () => text); - }, - }, - { - title: '创建时间', - dataIndex: 'createTime', - width: 100, - }, -]; - -export const searchFormSchema: FormSchema[] = [ - { - field: 'keyword', - label: '关键字', - component: 'Input', - componentProps: { - placeholder: '请输入名称/服务ID', - }, - colProps: { span: 8 }, - }, - { - field: 'startDate', - label: '起始时间', - component: 'DatePicker', - colProps: { span: 8 }, - }, - { - field: 'endDate', - label: '截止时间', - component: 'DatePicker', - colProps: { span: 8 }, - }, -]; - -export const formSchema: FormSchema[] = [ - { - field: 'id', - label: 'ID', - component: 'Input', - show: false, - }, - { - field: 'ip', - label: 'IP地址', - component: 'Input', - }, - { - field: 'requestUri', - label: '请求地址', - component: 'Input', - }, - { - field: 'requestMethod', - label: '请求方法', - component: 'Input', - }, - { - field: 'startTime', - label: '开始时间', - component: 'TimePicker', - defaultValue: moment('09:00:00', 'HH:mm:ss'), - componentProps: { - valueFormat: 'HH:mm:ss', - }, - }, - { - field: 'endTime', - label: '结束时间', - component: 'TimePicker', - defaultValue: moment('21:00:00', 'HH:mm:ss'), - componentProps: { - valueFormat: 'HH:mm:ss', - }, - }, - { - field: 'status', - label: '状态', - component: 'RadioButtonGroup', - defaultValue: '0', - componentProps: { - options: [ - { label: '启用', value: '0' }, - { label: '禁用', value: '1' }, - ], - }, - }, -]; diff --git a/kicc-ui/src/views/gateway/blacklist/index.vue b/kicc-ui/src/views/gateway/blacklist/index.vue deleted file mode 100644 index a2138e2c..00000000 --- a/kicc-ui/src/views/gateway/blacklist/index.vue +++ /dev/null @@ -1,85 +0,0 @@ - - diff --git a/kicc-ui/src/views/gateway/route/RouteDrawer.vue b/kicc-ui/src/views/gateway/route/RouteDrawer.vue deleted file mode 100644 index 76b83ad6..00000000 --- a/kicc-ui/src/views/gateway/route/RouteDrawer.vue +++ /dev/null @@ -1,54 +0,0 @@ - - diff --git a/kicc-ui/src/views/gateway/route/index.vue b/kicc-ui/src/views/gateway/route/index.vue deleted file mode 100644 index fab46027..00000000 --- a/kicc-ui/src/views/gateway/route/index.vue +++ /dev/null @@ -1,85 +0,0 @@ - - diff --git a/kicc-ui/src/views/gateway/route/route.data.ts b/kicc-ui/src/views/gateway/route/route.data.ts deleted file mode 100644 index d90517fa..00000000 --- a/kicc-ui/src/views/gateway/route/route.data.ts +++ /dev/null @@ -1,109 +0,0 @@ -import { BasicColumn } from '/@/components/Table'; -import { FormSchema } from '/@/components/Table'; -import { h } from 'vue'; -import { Tag } from 'ant-design-vue'; - -export const columns: BasicColumn[] = [ - { - title: '名称', - dataIndex: 'name', - width: 100, - }, - { - title: '服务ID', - dataIndex: 'serviceId', - width: 100, - }, - { - title: '服务路径', - dataIndex: 'path', - width: 130, - }, - { - title: 'URI', - dataIndex: 'url', - width: 90, - }, - { - title: '状态', - dataIndex: 'status', - width: 80, - customRender: ({ record }) => { - const status = record.status; - const enable = ~~status === 0; - const color = enable ? 'green' : 'red'; - const text = enable ? '启用' : '停用'; - return h(Tag, { color: color }, () => text); - }, - }, - { - title: '创建时间', - dataIndex: 'createTime', - width: 100, - }, -]; - -export const searchFormSchema: FormSchema[] = [ - { - field: 'keyword', - label: '关键字', - component: 'Input', - componentProps: { - placeholder: '请输入名称/服务ID', - }, - colProps: { span: 8 }, - }, - { - field: 'startDate', - label: '起始时间', - component: 'DatePicker', - colProps: { span: 8 }, - }, - { - field: 'endDate', - label: '截止时间', - component: 'DatePicker', - colProps: { span: 8 }, - }, -]; - -export const formSchema: FormSchema[] = [ - { - field: 'id', - label: 'ID', - component: 'Input', - show: false, - }, - { - field: 'name', - label: '名称', - component: 'Input', - }, - { - field: 'serviceId', - label: '服务ID', - component: 'Input', - }, - { - field: 'path', - label: '服务路径', - component: 'Input', - }, - { - field: 'url', - label: 'URI', - component: 'Input', - }, - { - field: 'status', - label: '状态', - component: 'RadioButtonGroup', - defaultValue: '0', - componentProps: { - options: [ - { label: '启用', value: '0' }, - { label: '禁用', value: '1' }, - ], - }, - }, -];