提交 e8cb26b3 作者: 方治民

feat: 新增示例页面、接口 Pont 及示例更新、忽略 src/api/services/api.d.ts eslint check

上级 20775130
...@@ -14,3 +14,4 @@ dist ...@@ -14,3 +14,4 @@ dist
Dockerfile Dockerfile
types/auto-imports.d.ts types/auto-imports.d.ts
src/api/services/api.d.ts
{ {
"originUrl": "http://localhost:8181/api/v2/api-docs", "originType": "SwaggerV2",
"originUrl": "http://127.0.0.1:8081/api/v2/api-docs",
"templateType": "fetch",
"templatePath": "./pont.template", "templatePath": "./pont.template",
"transformPath": "./pont.transform",
"outDir": "./src/api/services", "outDir": "./src/api/services",
"surrounding": "typeScript", "surrounding": "typeScript",
"mocks": { "mocks": {
...@@ -9,7 +12,6 @@ ...@@ -9,7 +12,6 @@
"port": 3101, "port": 3101,
"wrapper": "{\"status\": 200, \"body\": {response}, \"message\": \"OK\"}" "wrapper": "{\"status\": 200, \"body\": {response}, \"message\": \"OK\"}"
}, },
"templateType": "fetch",
"prettierConfig": { "prettierConfig": {
"printWidth": 120, "printWidth": 120,
"semi": false, "semi": false,
......
import * as Pont from 'pont-engine'
import { Interface, BaseClass, Property, CodeGenerator } from 'pont-engine' import { Interface, BaseClass, Property, CodeGenerator } from 'pont-engine'
// 接口 API 前缀 // 接口 API 前缀
// 通常与项目的 env 配置中的 VITE_GLOB_API_URL_PREFIX 相同 // 通常与项目的 env 配置中的 VITE_GLOB_API_URL_PREFIX 相同
const API_URL_PREFIX = '/api' const API_URL_PREFIX = '/api'
export class FileStructures extends Pont.FileStructures {
getModsDeclaration(originCode: string): string {
return originCode
}
}
export default class BasicGenerator extends CodeGenerator { export default class BasicGenerator extends CodeGenerator {
getParams(inter: Interface, paramsCode: string) { getParams(inter: Interface, paramsCode: string) {
let requestParams = inter.getRequestParams(this.surrounding) let requestParams = inter.getRequestParams(this.surrounding)
const prettier = require('prettier') const prettier = require('prettier')
if (prettier.format(paramsCode, { parser: 'typescript' }).includes('{}')) { if (prettier.format(paramsCode, { parser: 'typescript' }).includes('{}')) {
requestParams = requestParams.replace('params', 'params?') if (!requestParams.includes('form')) {
requestParams = requestParams.replace('params', 'params?')
}
} }
return `${requestParams.replace( return `${requestParams.replace(
...@@ -54,18 +63,19 @@ export default class BasicGenerator extends CodeGenerator { ...@@ -54,18 +63,19 @@ export default class BasicGenerator extends CodeGenerator {
const method = inter.method.toUpperCase() const method = inter.method.toUpperCase()
const paramsCode = inter.getParamsCode('Params', this.surrounding) const paramsCode = inter.getParamsCode('Params', this.surrounding)
const requestParams = this.getParams(inter, paramsCode) const requestParams = this.getParams(inter, paramsCode)
const undef = inter.response.getInitialValue() === 'undefined'
return ` return `
/** /**
* @desc ${inter.description} * @desc ${inter.description}
*/ */
import * as defs from '../../baseClass'; ${undef ? '' : `import * as defs from '../../baseClass';`}
import { defHttp } from '/@/utils/http/axios' import { defHttp } from '/@/utils/http/axios'
export ${paramsCode} export ${paramsCode}
export const init = ${inter.response.getInitialValue()}; ${undef ? '' : `export const init = ${inter.response.getInitialValue(true)};`}
export function request(${requestParams}) { export function request(${requestParams}) {
return defHttp.request({ return defHttp.request({
...@@ -76,6 +86,11 @@ export default class BasicGenerator extends CodeGenerator { ...@@ -76,6 +86,11 @@ export default class BasicGenerator extends CodeGenerator {
? 'params' ? 'params'
: `data: ${requestParams.includes('form') ? 'form || params' : 'params'}` : `data: ${requestParams.includes('form') ? 'form || params' : 'params'}`
}, },
${
requestParams.includes('form')
? `headers: { 'Content-Type': 'multipart/form-data;charset=UTF-8' },`
: ''
}
...config, ...config,
}, options); }, options);
......
import { StandardDataSource } from 'pont-engine'
export default function (dataSource: StandardDataSource): StandardDataSource {
return dataSource
}
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
{ {
"mods": [ "mods": [
{ {
"description": "", "description": "身份认证",
"interfaces": [ "interfaces": [
{ {
"consumes": [ "consumes": [
...@@ -244,13 +244,13 @@ ...@@ -244,13 +244,13 @@
"name": "auth" "name": "auth"
}, },
{ {
"description": "", "description": "示例",
"interfaces": [ "interfaces": [
{ {
"description": "hello", "description": "hello",
"name": "hello", "name": "hello",
"method": "get", "method": "get",
"path": "/api/hello/", "path": "/api/example/",
"response": { "response": {
"typeArgs": [ "typeArgs": [
{ {
...@@ -273,10 +273,26 @@ ...@@ -273,10 +273,26 @@
"parameters": [] "parameters": []
}, },
{ {
"description": "download",
"name": "download",
"method": "get",
"path": "/api/example/download",
"response": {
"typeArgs": [],
"typeName": "",
"isDefsType": false,
"templateIndex": -1,
"compileTemplateKeyword": "#/definitions/",
"enum": [],
"typeProperties": []
},
"parameters": []
},
{
"description": "fail", "description": "fail",
"name": "fail", "name": "fail",
"method": "get", "method": "get",
"path": "/api/hello/fail", "path": "/api/example/fail",
"response": { "response": {
"typeArgs": [ "typeArgs": [
{ {
...@@ -302,7 +318,7 @@ ...@@ -302,7 +318,7 @@
"description": "page", "description": "page",
"name": "page", "name": "page",
"method": "get", "method": "get",
"path": "/api/hello/page", "path": "/api/example/page",
"response": { "response": {
"typeArgs": [ "typeArgs": [
{ {
...@@ -402,7 +418,7 @@ ...@@ -402,7 +418,7 @@
"description": "测试 MyBatis Plus 查询", "description": "测试 MyBatis Plus 查询",
"name": "test", "name": "test",
"method": "get", "method": "get",
"path": "/api/hello/test", "path": "/api/example/test",
"response": { "response": {
"typeArgs": [ "typeArgs": [
{ {
...@@ -425,10 +441,10 @@ ...@@ -425,10 +441,10 @@
"parameters": [] "parameters": []
} }
], ],
"name": "hello" "name": "example"
}, },
{ {
"description": "", "description": "文件管理",
"interfaces": [ "interfaces": [
{ {
"consumes": [ "consumes": [
...@@ -437,7 +453,7 @@ ...@@ -437,7 +453,7 @@
"description": "文件上传", "description": "文件上传",
"name": "upload", "name": "upload",
"method": "post", "method": "post",
"path": "/api/common/minio/upload", "path": "/api/common/file/upload",
"response": { "response": {
"typeArgs": [ "typeArgs": [
{ {
...@@ -476,10 +492,10 @@ ...@@ -476,10 +492,10 @@
] ]
} }
], ],
"name": "minio" "name": "file"
}, },
{ {
"description": "", "description": "权限管理",
"interfaces": [ "interfaces": [
{ {
"consumes": [ "consumes": [
...@@ -621,7 +637,7 @@ ...@@ -621,7 +637,7 @@
"required": false, "required": false,
"dataType": { "dataType": {
"typeArgs": [], "typeArgs": [],
"typeName": "number", "typeName": "string",
"isDefsType": false, "isDefsType": false,
"templateIndex": -1, "templateIndex": -1,
"compileTemplateKeyword": "#/definitions/", "compileTemplateKeyword": "#/definitions/",
...@@ -730,7 +746,7 @@ ...@@ -730,7 +746,7 @@
"required": true, "required": true,
"dataType": { "dataType": {
"typeArgs": [], "typeArgs": [],
"typeName": "number", "typeName": "string",
"isDefsType": false, "isDefsType": false,
"templateIndex": -1, "templateIndex": -1,
"compileTemplateKeyword": "#/definitions/", "compileTemplateKeyword": "#/definitions/",
...@@ -772,7 +788,7 @@ ...@@ -772,7 +788,7 @@
"required": true, "required": true,
"dataType": { "dataType": {
"typeArgs": [], "typeArgs": [],
"typeName": "number", "typeName": "string",
"isDefsType": false, "isDefsType": false,
"templateIndex": -1, "templateIndex": -1,
"compileTemplateKeyword": "#/definitions/", "compileTemplateKeyword": "#/definitions/",
...@@ -877,7 +893,7 @@ ...@@ -877,7 +893,7 @@
"required": true, "required": true,
"dataType": { "dataType": {
"typeArgs": [], "typeArgs": [],
"typeName": "number", "typeName": "string",
"isDefsType": false, "isDefsType": false,
"templateIndex": -1, "templateIndex": -1,
"compileTemplateKeyword": "#/definitions/", "compileTemplateKeyword": "#/definitions/",
...@@ -937,7 +953,7 @@ ...@@ -937,7 +953,7 @@
"required": false, "required": false,
"dataType": { "dataType": {
"typeArgs": [], "typeArgs": [],
"typeName": "number", "typeName": "string",
"isDefsType": false, "isDefsType": false,
"templateIndex": -1, "templateIndex": -1,
"compileTemplateKeyword": "#/definitions/", "compileTemplateKeyword": "#/definitions/",
...@@ -1151,12 +1167,12 @@ ...@@ -1151,12 +1167,12 @@
"parameters": [ "parameters": [
{ {
"in": "query", "in": "query",
"description": "父级 id", "description": "pid",
"name": "pid", "name": "pid",
"required": false, "required": true,
"dataType": { "dataType": {
"typeArgs": [], "typeArgs": [],
"typeName": "number", "typeName": "string",
"isDefsType": false, "isDefsType": false,
"templateIndex": -1, "templateIndex": -1,
"compileTemplateKeyword": "#/definitions/", "compileTemplateKeyword": "#/definitions/",
...@@ -1170,7 +1186,7 @@ ...@@ -1170,7 +1186,7 @@
"name": "permission" "name": "permission"
}, },
{ {
"description": "", "description": "角色管理",
"interfaces": [ "interfaces": [
{ {
"consumes": [ "consumes": [
...@@ -1267,7 +1283,7 @@ ...@@ -1267,7 +1283,7 @@
"required": true, "required": true,
"dataType": { "dataType": {
"typeArgs": [], "typeArgs": [],
"typeName": "number", "typeName": "string",
"isDefsType": false, "isDefsType": false,
"templateIndex": -1, "templateIndex": -1,
"compileTemplateKeyword": "#/definitions/", "compileTemplateKeyword": "#/definitions/",
...@@ -1327,7 +1343,7 @@ ...@@ -1327,7 +1343,7 @@
"required": true, "required": true,
"dataType": { "dataType": {
"typeArgs": [], "typeArgs": [],
"typeName": "number", "typeName": "string",
"isDefsType": false, "isDefsType": false,
"templateIndex": -1, "templateIndex": -1,
"compileTemplateKeyword": "#/definitions/", "compileTemplateKeyword": "#/definitions/",
...@@ -1369,7 +1385,7 @@ ...@@ -1369,7 +1385,7 @@
"required": true, "required": true,
"dataType": { "dataType": {
"typeArgs": [], "typeArgs": [],
"typeName": "number", "typeName": "string",
"isDefsType": false, "isDefsType": false,
"templateIndex": -1, "templateIndex": -1,
"compileTemplateKeyword": "#/definitions/", "compileTemplateKeyword": "#/definitions/",
...@@ -1414,7 +1430,7 @@ ...@@ -1414,7 +1430,7 @@
"required": true, "required": true,
"dataType": { "dataType": {
"typeArgs": [], "typeArgs": [],
"typeName": "number", "typeName": "string",
"isDefsType": false, "isDefsType": false,
"templateIndex": -1, "templateIndex": -1,
"compileTemplateKeyword": "#/definitions/", "compileTemplateKeyword": "#/definitions/",
...@@ -1594,7 +1610,7 @@ ...@@ -1594,7 +1610,7 @@
"name": "role" "name": "role"
}, },
{ {
"description": "", "description": "用户管理",
"interfaces": [ "interfaces": [
{ {
"description": "获取用户菜单", "description": "获取用户菜单",
...@@ -1729,7 +1745,7 @@ ...@@ -1729,7 +1745,7 @@
"required": true, "required": true,
"dataType": { "dataType": {
"typeArgs": [], "typeArgs": [],
"typeName": "number", "typeName": "string",
"isDefsType": false, "isDefsType": false,
"templateIndex": -1, "templateIndex": -1,
"compileTemplateKeyword": "#/definitions/", "compileTemplateKeyword": "#/definitions/",
...@@ -1879,7 +1895,7 @@ ...@@ -1879,7 +1895,7 @@
{ {
"dataType": { "dataType": {
"typeArgs": [], "typeArgs": [],
"typeName": "number", "typeName": "string",
"isDefsType": false, "isDefsType": false,
"templateIndex": -1, "templateIndex": -1,
"compileTemplateKeyword": "#/definitions/", "compileTemplateKeyword": "#/definitions/",
...@@ -1887,7 +1903,7 @@ ...@@ -1887,7 +1903,7 @@
"typeProperties": [] "typeProperties": []
}, },
"name": "userId", "name": "userId",
"description": "主键", "description": "用户 ID",
"required": false "required": false
} }
], ],
...@@ -2013,6 +2029,7 @@ ...@@ -2013,6 +2029,7 @@
"templateArgs": [] "templateArgs": []
}, },
{ {
"description": "公共分页查询响应输出",
"name": "PageVo", "name": "PageVo",
"properties": [ "properties": [
{ {
...@@ -2037,7 +2054,7 @@ ...@@ -2037,7 +2054,7 @@
}, },
"name": "data", "name": "data",
"description": "数据", "description": "数据",
"required": false "required": true
}, },
{ {
"dataType": { "dataType": {
...@@ -2065,7 +2082,7 @@ ...@@ -2065,7 +2082,7 @@
}, },
"name": "total", "name": "total",
"description": "数据总数", "description": "数据总数",
"required": false "required": true
} }
], ],
"templateArgs": [ "templateArgs": [
...@@ -2166,7 +2183,7 @@ ...@@ -2166,7 +2183,7 @@
{ {
"dataType": { "dataType": {
"typeArgs": [], "typeArgs": [],
"typeName": "number", "typeName": "string",
"isDefsType": false, "isDefsType": false,
"templateIndex": -1, "templateIndex": -1,
"compileTemplateKeyword": "#/definitions/", "compileTemplateKeyword": "#/definitions/",
...@@ -2241,7 +2258,7 @@ ...@@ -2241,7 +2258,7 @@
{ {
"dataType": { "dataType": {
"typeArgs": [], "typeArgs": [],
"typeName": "number", "typeName": "string",
"isDefsType": false, "isDefsType": false,
"templateIndex": -1, "templateIndex": -1,
"compileTemplateKeyword": "#/definitions/", "compileTemplateKeyword": "#/definitions/",
...@@ -2435,7 +2452,7 @@ ...@@ -2435,7 +2452,7 @@
{ {
"dataType": { "dataType": {
"typeArgs": [], "typeArgs": [],
"typeName": "number", "typeName": "string",
"isDefsType": false, "isDefsType": false,
"templateIndex": -1, "templateIndex": -1,
"compileTemplateKeyword": "#/definitions/", "compileTemplateKeyword": "#/definitions/",
...@@ -2587,7 +2604,7 @@ ...@@ -2587,7 +2604,7 @@
{ {
"dataType": { "dataType": {
"typeArgs": [], "typeArgs": [],
"typeName": "number", "typeName": "string",
"isDefsType": false, "isDefsType": false,
"templateIndex": -1, "templateIndex": -1,
"compileTemplateKeyword": "#/definitions/", "compileTemplateKeyword": "#/definitions/",
...@@ -2691,7 +2708,7 @@ ...@@ -2691,7 +2708,7 @@
{ {
"dataType": { "dataType": {
"typeArgs": [], "typeArgs": [],
"typeName": "number", "typeName": "string",
"isDefsType": false, "isDefsType": false,
"templateIndex": -1, "templateIndex": -1,
"compileTemplateKeyword": "#/definitions/", "compileTemplateKeyword": "#/definitions/",
......
...@@ -7,8 +7,8 @@ declare namespace defs { ...@@ -7,8 +7,8 @@ declare namespace defs {
/** token */ /** token */
token?: string token?: string
/** 主键 */ /** 用户 ID */
userId?: number userId?: string
} }
export class MenuVo { export class MenuVo {
...@@ -59,7 +59,7 @@ declare namespace defs { ...@@ -59,7 +59,7 @@ declare namespace defs {
icon?: string icon?: string
/** 主键 */ /** 主键 */
id?: number id?: string
/** 元数据 */ /** 元数据 */
meta?: ObjectMap<any, object> meta?: ObjectMap<any, object>
...@@ -71,7 +71,7 @@ declare namespace defs { ...@@ -71,7 +71,7 @@ declare namespace defs {
path?: string path?: string
/** 父级ID */ /** 父级ID */
pid?: number pid?: string
/** 序号 */ /** 序号 */
serial?: number serial?: number
...@@ -111,7 +111,7 @@ declare namespace defs { ...@@ -111,7 +111,7 @@ declare namespace defs {
export class RoleVo { export class RoleVo {
/** 主键 */ /** 主键 */
id?: number id?: string
/** 名称 */ /** 名称 */
name?: string name?: string
...@@ -140,7 +140,7 @@ declare namespace defs { ...@@ -140,7 +140,7 @@ declare namespace defs {
roles?: Array<defs.RoleVo> roles?: Array<defs.RoleVo>
/** 主键 */ /** 主键 */
userId?: number userId?: string
/** 用户名 */ /** 用户名 */
username?: string username?: string
...@@ -163,7 +163,7 @@ declare namespace defs { ...@@ -163,7 +163,7 @@ declare namespace defs {
enabled?: boolean enabled?: boolean
/** 主键 */ /** 主键 */
id?: number id?: string
/** 最后登录IP地址 */ /** 最后登录IP地址 */
lastLoginIp?: string lastLoginIp?: string
...@@ -185,9 +185,9 @@ declare namespace defs { ...@@ -185,9 +185,9 @@ declare namespace defs {
} }
} }
declare namespace API { namespace API {
/** /**
* * 身份认证
*/ */
export namespace auth { export namespace auth {
/** /**
...@@ -268,12 +268,12 @@ declare namespace API { ...@@ -268,12 +268,12 @@ declare namespace API {
} }
/** /**
* * 示例
*/ */
export namespace hello { export namespace example {
/** /**
* hello * hello
* /api/hello/ * /api/example/
*/ */
export namespace hello { export namespace hello {
export class Params {} export class Params {}
...@@ -290,8 +290,26 @@ declare namespace API { ...@@ -290,8 +290,26 @@ declare namespace API {
} }
/** /**
* download
* /api/example/download
*/
export namespace download {
export class Params {}
export type Response = any
export const init: Response
export function request(
params?: Params,
config?: http.RequestConfig<Params>,
options?: http.RequestOptions,
): Promise<Response>
}
/**
* fail * fail
* /api/hello/fail * /api/example/fail
*/ */
export namespace fail { export namespace fail {
export class Params {} export class Params {}
...@@ -309,7 +327,7 @@ declare namespace API { ...@@ -309,7 +327,7 @@ declare namespace API {
/** /**
* page * page
* /api/hello/page * /api/example/page
*/ */
export namespace page { export namespace page {
export class Params { export class Params {
...@@ -336,7 +354,7 @@ declare namespace API { ...@@ -336,7 +354,7 @@ declare namespace API {
/** /**
* 测试 MyBatis Plus 查询 * 测试 MyBatis Plus 查询
* /api/hello/test * /api/example/test
*/ */
export namespace test { export namespace test {
export class Params {} export class Params {}
...@@ -354,12 +372,12 @@ declare namespace API { ...@@ -354,12 +372,12 @@ declare namespace API {
} }
/** /**
* * 文件管理
*/ */
export namespace minio { export namespace file {
/** /**
* 文件上传 * 文件上传
* /api/common/minio/upload * /api/common/file/upload
*/ */
export namespace upload { export namespace upload {
export class Params {} export class Params {}
...@@ -369,7 +387,7 @@ declare namespace API { ...@@ -369,7 +387,7 @@ declare namespace API {
export const init: Response export const init: Response
export function request( export function request(
params?: Params, params: Params,
form: FormData, form: FormData,
config?: http.RequestConfig<Params | FormData>, config?: http.RequestConfig<Params | FormData>,
options?: http.RequestOptions, options?: http.RequestOptions,
...@@ -378,7 +396,7 @@ declare namespace API { ...@@ -378,7 +396,7 @@ declare namespace API {
} }
/** /**
* * 权限管理
*/ */
export namespace permission { export namespace permission {
/** /**
...@@ -402,7 +420,7 @@ declare namespace API { ...@@ -402,7 +420,7 @@ declare namespace API {
/** 路径 */ /** 路径 */
path?: string path?: string
/** 父级ID */ /** 父级ID */
pid?: number pid?: string
/** 重定向 */ /** 重定向 */
redirect?: string redirect?: string
/** 序号 */ /** 序号 */
...@@ -431,7 +449,7 @@ declare namespace API { ...@@ -431,7 +449,7 @@ declare namespace API {
export namespace deleted { export namespace deleted {
export class Params { export class Params {
/** id */ /** id */
id: number id: string
} }
export type Response = string export type Response = string
...@@ -452,7 +470,7 @@ declare namespace API { ...@@ -452,7 +470,7 @@ declare namespace API {
export namespace find { export namespace find {
export class Params { export class Params {
/** id */ /** id */
id: number id: string
} }
export type Response = defs.PermissionVo export type Response = defs.PermissionVo
...@@ -481,7 +499,7 @@ declare namespace API { ...@@ -481,7 +499,7 @@ declare namespace API {
/** 图标 */ /** 图标 */
icon?: string icon?: string
/** id */ /** id */
id: number id: string
/** 元数据 */ /** 元数据 */
meta?: string meta?: string
/** 名称 */ /** 名称 */
...@@ -489,7 +507,7 @@ declare namespace API { ...@@ -489,7 +507,7 @@ declare namespace API {
/** 路径 */ /** 路径 */
path?: string path?: string
/** 父级ID */ /** 父级ID */
pid?: number pid?: string
/** 重定向 */ /** 重定向 */
redirect?: string redirect?: string
/** 序号 */ /** 序号 */
...@@ -544,8 +562,8 @@ declare namespace API { ...@@ -544,8 +562,8 @@ declare namespace API {
*/ */
export namespace tree { export namespace tree {
export class Params { export class Params {
/** 父级 id */ /** pid */
pid?: number pid: string
} }
export type Response = Array<defs.PermissionVo> export type Response = Array<defs.PermissionVo>
...@@ -561,7 +579,7 @@ declare namespace API { ...@@ -561,7 +579,7 @@ declare namespace API {
} }
/** /**
* * 角色管理
*/ */
export namespace role { export namespace role {
/** /**
...@@ -594,7 +612,7 @@ declare namespace API { ...@@ -594,7 +612,7 @@ declare namespace API {
export namespace assign { export namespace assign {
export class Params { export class Params {
/** id */ /** id */
id: number id: string
/** ids 多个以逗号分割 */ /** ids 多个以逗号分割 */
ids: string ids: string
} }
...@@ -617,7 +635,7 @@ declare namespace API { ...@@ -617,7 +635,7 @@ declare namespace API {
export namespace deleted { export namespace deleted {
export class Params { export class Params {
/** id */ /** id */
id: number id: string
} }
export type Response = string export type Response = string
...@@ -638,7 +656,7 @@ declare namespace API { ...@@ -638,7 +656,7 @@ declare namespace API {
export namespace find { export namespace find {
export class Params { export class Params {
/** id */ /** id */
id: number id: string
} }
export type Response = defs.RoleVo export type Response = defs.RoleVo
...@@ -659,7 +677,7 @@ declare namespace API { ...@@ -659,7 +677,7 @@ declare namespace API {
export namespace modify { export namespace modify {
export class Params { export class Params {
/** id */ /** id */
id: number id: string
/** 名称 */ /** 名称 */
name: string name: string
/** 标识 */ /** 标识 */
...@@ -724,7 +742,7 @@ declare namespace API { ...@@ -724,7 +742,7 @@ declare namespace API {
} }
/** /**
* * 用户管理
*/ */
export namespace user { export namespace user {
/** /**
...@@ -788,7 +806,7 @@ declare namespace API { ...@@ -788,7 +806,7 @@ declare namespace API {
export namespace assign { export namespace assign {
export class Params { export class Params {
/** id */ /** id */
id: number id: string
/** ids 多个以逗号分割 */ /** ids 多个以逗号分割 */
ids: string ids: string
} }
......
...@@ -2,8 +2,8 @@ export class LoginVo { ...@@ -2,8 +2,8 @@ export class LoginVo {
/** token */ /** token */
token = '' token = ''
/** 主键 */ /** 用户 ID */
userId = undefined userId = ''
} }
export class MenuVo { export class MenuVo {
...@@ -54,7 +54,7 @@ export class PermissionVo { ...@@ -54,7 +54,7 @@ export class PermissionVo {
icon = '' icon = ''
/** 主键 */ /** 主键 */
id = undefined id = ''
/** 元数据 */ /** 元数据 */
meta = undefined meta = undefined
...@@ -66,7 +66,7 @@ export class PermissionVo { ...@@ -66,7 +66,7 @@ export class PermissionVo {
path = '' path = ''
/** 父级ID */ /** 父级ID */
pid = undefined pid = ''
/** 序号 */ /** 序号 */
serial = undefined serial = undefined
...@@ -106,7 +106,7 @@ export class Result { ...@@ -106,7 +106,7 @@ export class Result {
export class RoleVo { export class RoleVo {
/** 主键 */ /** 主键 */
id = undefined id = ''
/** 名称 */ /** 名称 */
name = '' name = ''
...@@ -135,7 +135,7 @@ export class UserInfo { ...@@ -135,7 +135,7 @@ export class UserInfo {
roles = [] roles = []
/** 主键 */ /** 主键 */
userId = undefined userId = ''
/** 用户名 */ /** 用户名 */
username = '' username = ''
...@@ -158,7 +158,7 @@ export class UserVo { ...@@ -158,7 +158,7 @@ export class UserVo {
enabled = false enabled = false
/** 主键 */ /** 主键 */
id = undefined id = ''
/** 最后登录IP地址 */ /** 最后登录IP地址 */
lastLoginIp = '' lastLoginIp = ''
......
/** /**
* @description * @description 身份认证
*/ */
import * as login from './login' import * as login from './login'
import * as logout from './logout' import * as logout from './logout'
......
/**
* @desc download
*/
import { defHttp } from '/@/utils/http/axios'
export class Params {}
export function request(params?: Params, config?: http.RequestConfig<Params>, options?: http.RequestOptions) {
return defHttp.request(
{
url: '/example/download',
method: 'GET',
params,
...config,
},
options,
)
}
...@@ -12,7 +12,7 @@ export const init = new defs.Result() ...@@ -12,7 +12,7 @@ export const init = new defs.Result()
export function request(params?: Params, config?: http.RequestConfig<Params>, options?: http.RequestOptions) { export function request(params?: Params, config?: http.RequestConfig<Params>, options?: http.RequestOptions) {
return defHttp.request( return defHttp.request(
{ {
url: '/hello/fail', url: '/example/fail',
method: 'GET', method: 'GET',
params, params,
......
...@@ -12,7 +12,7 @@ export const init = new defs.Result() ...@@ -12,7 +12,7 @@ export const init = new defs.Result()
export function request(params?: Params, config?: http.RequestConfig<Params>, options?: http.RequestOptions) { export function request(params?: Params, config?: http.RequestConfig<Params>, options?: http.RequestOptions) {
return defHttp.request( return defHttp.request(
{ {
url: '/hello/', url: '/example/',
method: 'GET', method: 'GET',
params, params,
......
/** /**
* @description * @description 示例
*/ */
import * as hello from './hello' import * as hello from './hello'
import * as download from './download'
import * as fail from './fail' import * as fail from './fail'
import * as page from './page' import * as page from './page'
import * as test from './test' import * as test from './test'
export { hello, fail, page, test } export { hello, download, fail, page, test }
...@@ -21,7 +21,7 @@ export const init = new defs.Result() ...@@ -21,7 +21,7 @@ export const init = new defs.Result()
export function request(params: Params, config?: http.RequestConfig<Params>, options?: http.RequestOptions) { export function request(params: Params, config?: http.RequestConfig<Params>, options?: http.RequestOptions) {
return defHttp.request( return defHttp.request(
{ {
url: '/hello/page', url: '/example/page',
method: 'GET', method: 'GET',
params, params,
......
...@@ -12,7 +12,7 @@ export const init = new defs.Result() ...@@ -12,7 +12,7 @@ export const init = new defs.Result()
export function request(params?: Params, config?: http.RequestConfig<Params>, options?: http.RequestOptions) { export function request(params?: Params, config?: http.RequestConfig<Params>, options?: http.RequestOptions) {
return defHttp.request( return defHttp.request(
{ {
url: '/hello/test', url: '/example/test',
method: 'GET', method: 'GET',
params, params,
......
/** /**
* @description * @description 文件管理
*/ */
import * as upload from './upload' import * as upload from './upload'
......
...@@ -10,16 +10,17 @@ export class Params {} ...@@ -10,16 +10,17 @@ export class Params {}
export const init = new defs.Result() export const init = new defs.Result()
export function request( export function request(
params?: Params, params: Params,
form: FormData, form: FormData,
config?: http.RequestConfig<Params | FormData>, config?: http.RequestConfig<Params | FormData>,
options?: http.RequestOptions, options?: http.RequestOptions,
) { ) {
return defHttp.request( return defHttp.request(
{ {
url: '/common/minio/upload', url: '/common/file/upload',
method: 'POST', method: 'POST',
data: form || params, data: form || params,
headers: { 'Content-Type': 'multipart/form-data;charset=UTF-8' },
...config, ...config,
}, },
......
import * as auth from './auth' import * as auth from './auth'
import * as hello from './hello' import * as example from './example'
import * as minio from './minio' import * as file from './file'
import * as permission from './permission' import * as permission from './permission'
import * as role from './role' import * as role from './role'
import * as user from './user' import * as user from './user'
export const API = { export const API = {
auth, auth,
hello, example,
minio, file,
permission, permission,
role, role,
user, user,
......
...@@ -21,7 +21,7 @@ export class Params { ...@@ -21,7 +21,7 @@ export class Params {
/** 路径 */ /** 路径 */
path?: string path?: string
/** 父级ID */ /** 父级ID */
pid?: number pid?: string
/** 重定向 */ /** 重定向 */
redirect?: string redirect?: string
/** 序号 */ /** 序号 */
......
...@@ -7,7 +7,7 @@ import { defHttp } from '/@/utils/http/axios' ...@@ -7,7 +7,7 @@ import { defHttp } from '/@/utils/http/axios'
export class Params { export class Params {
/** id */ /** id */
id: number id: string
} }
export const init = new defs.Result() export const init = new defs.Result()
......
...@@ -7,7 +7,7 @@ import { defHttp } from '/@/utils/http/axios' ...@@ -7,7 +7,7 @@ import { defHttp } from '/@/utils/http/axios'
export class Params { export class Params {
/** id */ /** id */
id: number id: string
} }
export const init = new defs.Result() export const init = new defs.Result()
......
/** /**
* @description * @description 权限管理
*/ */
import * as add from './add' import * as add from './add'
import * as deleted from './deleted' import * as deleted from './deleted'
......
...@@ -15,7 +15,7 @@ export class Params { ...@@ -15,7 +15,7 @@ export class Params {
/** 图标 */ /** 图标 */
icon?: string icon?: string
/** id */ /** id */
id: number id: string
/** 元数据 */ /** 元数据 */
meta?: string meta?: string
/** 名称 */ /** 名称 */
...@@ -23,7 +23,7 @@ export class Params { ...@@ -23,7 +23,7 @@ export class Params {
/** 路径 */ /** 路径 */
path?: string path?: string
/** 父级ID */ /** 父级ID */
pid?: number pid?: string
/** 重定向 */ /** 重定向 */
redirect?: string redirect?: string
/** 序号 */ /** 序号 */
......
...@@ -6,8 +6,8 @@ import * as defs from '../../baseClass' ...@@ -6,8 +6,8 @@ import * as defs from '../../baseClass'
import { defHttp } from '/@/utils/http/axios' import { defHttp } from '/@/utils/http/axios'
export class Params { export class Params {
/** 父级 id */ /** pid */
pid?: number pid: string
} }
export const init = new defs.Result() export const init = new defs.Result()
......
...@@ -7,7 +7,7 @@ import { defHttp } from '/@/utils/http/axios' ...@@ -7,7 +7,7 @@ import { defHttp } from '/@/utils/http/axios'
export class Params { export class Params {
/** id */ /** id */
id: number id: string
/** ids 多个以逗号分割 */ /** ids 多个以逗号分割 */
ids: string ids: string
} }
......
...@@ -7,7 +7,7 @@ import { defHttp } from '/@/utils/http/axios' ...@@ -7,7 +7,7 @@ import { defHttp } from '/@/utils/http/axios'
export class Params { export class Params {
/** id */ /** id */
id: number id: string
} }
export const init = new defs.Result() export const init = new defs.Result()
......
...@@ -7,7 +7,7 @@ import { defHttp } from '/@/utils/http/axios' ...@@ -7,7 +7,7 @@ import { defHttp } from '/@/utils/http/axios'
export class Params { export class Params {
/** id */ /** id */
id: number id: string
} }
export const init = new defs.Result() export const init = new defs.Result()
......
/** /**
* @description * @description 角色管理
*/ */
import * as add from './add' import * as add from './add'
import * as assign from './assign' import * as assign from './assign'
......
...@@ -7,7 +7,7 @@ import { defHttp } from '/@/utils/http/axios' ...@@ -7,7 +7,7 @@ import { defHttp } from '/@/utils/http/axios'
export class Params { export class Params {
/** id */ /** id */
id: number id: string
/** 名称 */ /** 名称 */
name: string name: string
/** 标识 */ /** 标识 */
......
...@@ -7,7 +7,7 @@ import { defHttp } from '/@/utils/http/axios' ...@@ -7,7 +7,7 @@ import { defHttp } from '/@/utils/http/axios'
export class Params { export class Params {
/** id */ /** id */
id: number id: string
/** ids 多个以逗号分割 */ /** ids 多个以逗号分割 */
ids: string ids: string
} }
......
/** /**
* @description * @description 用户管理
*/ */
import * as getMenuList from './getMenuList' import * as getMenuList from './getMenuList'
import * as getPermCode from './getPermCode' import * as getPermCode from './getPermCode'
......
...@@ -160,6 +160,9 @@ export default { ...@@ -160,6 +160,9 @@ export default {
setup: { setup: {
page: '引导页', page: '引导页',
}, },
example: {
page: '示例页',
},
system: { system: {
moduleName: '系统管理', moduleName: '系统管理',
account: '账号管理', account: '账号管理',
......
import type { AppRouteModule } from '/@/router/types'
import { LAYOUT } from '/@/router/constant'
import { t } from '/@/hooks/web/useI18n'
const setup: AppRouteModule = {
path: '/example',
name: 'Example',
component: LAYOUT,
redirect: '/example/index',
meta: {
orderNo: 90001,
hideChildrenInMenu: true,
icon: 'healthicons:virus-lab-research-test-tube-outline',
title: t('routes.demo.example.page'),
},
children: [
{
path: 'index',
name: 'ExamplePage',
component: () => import('/@/views/demo/example/index.vue'),
meta: {
title: t('routes.demo.example.page'),
icon: 'healthicons:virus-lab-research-test-tube-outline',
hideMenu: true,
},
},
],
}
export default setup
<script lang="ts" setup>
import { PageWrapper } from '/@/components/Page'
const text = ref('Hello World! 👋')
onMounted(() => {
// TODO: 测试接口
API.example.hello.request().then((body) => {
console.log(body)
setTimeout(() => {
text.value = body
}, 1500)
})
})
</script>
<template>
<PageWrapper title="Example" content="示例展示页面">
<div class="title">{{ text }}</div>
</PageWrapper>
</template>
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论