From f8e51648d31da3827e2991c6fe0b28e54a068f03 Mon Sep 17 00:00:00 2001 From: xiangheng <11675084@qq.com> Date: Fri, 7 Jun 2024 15:45:15 +0800 Subject: [PATCH] =?UTF-8?q?api=E5=A2=9E=E5=8A=A0ts?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- admin/package.json | 3 +- admin/src/api/album_cate.ts | 71 +++++++++++++++++++ .../components/verify/Verify/VerifyPoints.vue | 4 +- .../components/verify/Verify/VerifySlide.vue | 2 +- .../verify/utils/{ase.js => ase.ts} | 0 .../verify/utils/{axios.js => axios.ts} | 0 .../verify/utils/{util.js => util.ts} | 0 admin/src/utils/request/index.ts | 12 ++++ admin/src/utils/util.ts | 17 ++++- .../templates/gocode/controller.go.tpl | 8 +-- .../tpl_utils/templates/uniapp/api.ts.tpl | 47 +++++++++--- .../templates/uniapp/details.vue.tpl | 8 ++- .../tpl_utils/templates/uniapp/index.vue.tpl | 12 +++- .../tpl_utils/templates/vue/api.ts.tpl | 48 ++++++++++--- server/admin/generator/tpl_utils/tpl.go | 1 + server/core/response/response.go | 10 +-- server/util/tools.go | 28 ++++++++ x_admin_app/api/monitor_project.ts | 31 ++++---- x_admin_app/api/user.js | 29 -------- x_admin_app/api/user.ts | 44 ++++++++++++ x_admin_app/methods/index.ts | 4 +- x_admin_app/pages/index/index.vue | 4 +- x_admin_app/pages/login/login.vue | 9 +-- x_admin_app/pages/monitor_project/details.vue | 11 ++- x_admin_app/stores/{user.js => user.ts} | 10 +-- x_admin_app/tsconfig.json | 4 +- x_admin_app/typings/methods.d.ts | 4 +- x_admin_app/utils/{emtt.js => emtt.ts} | 0 x_admin_app/utils/{env.js => env.ts} | 0 x_admin_app/utils/{map.js => map.ts} | 13 +++- x_admin_app/utils/{num.js => number_util.ts} | 0 x_admin_app/utils/{perms.js => perms.ts} | 2 +- x_admin_app/utils/{request.js => request.ts} | 67 ++++++++++------- x_admin_app/utils/{storage.js => storage.ts} | 6 +- x_admin_app/utils/{utils.js => utils.ts} | 19 ++++- 35 files changed, 401 insertions(+), 127 deletions(-) create mode 100644 admin/src/api/album_cate.ts rename admin/src/components/verify/utils/{ase.js => ase.ts} (100%) rename admin/src/components/verify/utils/{axios.js => axios.ts} (100%) rename admin/src/components/verify/utils/{util.js => util.ts} (100%) delete mode 100644 x_admin_app/api/user.js create mode 100644 x_admin_app/api/user.ts rename x_admin_app/stores/{user.js => user.ts} (93%) rename x_admin_app/utils/{emtt.js => emtt.ts} (100%) rename x_admin_app/utils/{env.js => env.ts} (100%) rename x_admin_app/utils/{map.js => map.ts} (89%) rename x_admin_app/utils/{num.js => number_util.ts} (100%) rename x_admin_app/utils/{perms.js => perms.ts} (85%) rename x_admin_app/utils/{request.js => request.ts} (73%) rename x_admin_app/utils/{storage.js => storage.ts} (72%) rename x_admin_app/utils/{utils.js => utils.ts} (85%) diff --git a/admin/package.json b/admin/package.json index 60ea199..1503129 100644 --- a/admin/package.json +++ b/admin/package.json @@ -9,7 +9,8 @@ "preview": "vite preview --port 4173", "build": "node ./scripts/build.mjs", "type-check": "vue-tsc --noEmit --checkJs true --skipLibCheck", - "lint": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --fix --ignore-path .gitignore" + "lint": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --fix --ignore-path .gitignore", + "preinstall": "npx only-allow pnpm" }, "dependencies": { "@element-plus/icons-vue": "^2.3.1", diff --git a/admin/src/api/album_cate.ts b/admin/src/api/album_cate.ts new file mode 100644 index 0000000..ae014e1 --- /dev/null +++ b/admin/src/api/album_cate.ts @@ -0,0 +1,71 @@ +import request from '@/utils/request' +import type { Pages } from '@/utils/request' + +import config from '@/config' +import queryString from 'query-string' +import { getToken } from '@/utils/auth' + +type album_cate = { + id?: number + pid?: number + type?: number + name?: string + isDelete?: number + createTime?: string + updateTime?: string + deleteTime?: string +} +// 查询 +type album_cate_query = { + pid?: number + type?: number + name?: string + createTime?: string + updateTime?: string +} +// 添加编辑 +type album_cate_edit = { + id?: number + pid?: number + type?: number + name?: string +} + +// 相册分类列表 +export function album_cate_list(params?: album_cate_query) { + return request.get>({ url: '/album_cate/list', params }) +} +// 相册分类列表-所有 +export function album_cate_list_all(params?: album_cate_query) { + return request.get>({ url: '/album_cate/listAll', params }) +} + +// 相册分类详情 +export function album_cate_detail(id: number | string) { + return request.get({ url: '/album_cate/detail', params: { id } }) +} + +// 相册分类新增 +export function album_cate_add(data: album_cate_edit) { + return request.post({ url: '/album_cate/add', data }) +} + +// 相册分类编辑 +export function album_cate_edit(data: album_cate_edit) { + return request.post({ url: '/album_cate/edit', data }) +} + +// 相册分类删除 +export function album_cate_delete(id: number | string) { + return request.post({ url: '/album_cate/del', data: { id } }) +} + +// 相册分类导入 +export const album_cate_import_file = '/album_cate/ImportFile' + +// 相册分类导出 +export function album_cate_export_file(params: any) { + return (window.location.href = + `${config.baseUrl}${config.urlPrefix}/album_cate/ExportFile?token=${getToken()}&` + + queryString.stringify(params)) +} diff --git a/admin/src/components/verify/Verify/VerifyPoints.vue b/admin/src/components/verify/Verify/VerifyPoints.vue index bd0daf5..837ffb2 100644 --- a/admin/src/components/verify/Verify/VerifyPoints.vue +++ b/admin/src/components/verify/Verify/VerifyPoints.vue @@ -67,8 +67,8 @@ * VerifyPoints * @description 点选 * */ -import { resetSize } from './../utils/util' -import { aesEncrypt } from './../utils/ase' +import { resetSize } from '../utils/util' +import { aesEncrypt } from '../utils/ase' import { reqGet, reqCheck } from '../api/index' import { onMounted, reactive, ref, nextTick, toRefs, getCurrentInstance } from 'vue' export default { diff --git a/admin/src/components/verify/Verify/VerifySlide.vue b/admin/src/components/verify/Verify/VerifySlide.vue index f999e72..5af46b0 100644 --- a/admin/src/components/verify/Verify/VerifySlide.vue +++ b/admin/src/components/verify/Verify/VerifySlide.vue @@ -94,7 +94,7 @@ * VerifySlide * @description 滑块 * */ -import { aesEncrypt } from './../utils/ase' +import { aesEncrypt } from '../utils/ase' import { resetSize } from './../utils/util' import { reqGet, reqCheck } from './../api/index' import { computed, onMounted, reactive, ref, nextTick, toRefs, getCurrentInstance } from 'vue' diff --git a/admin/src/components/verify/utils/ase.js b/admin/src/components/verify/utils/ase.ts similarity index 100% rename from admin/src/components/verify/utils/ase.js rename to admin/src/components/verify/utils/ase.ts diff --git a/admin/src/components/verify/utils/axios.js b/admin/src/components/verify/utils/axios.ts similarity index 100% rename from admin/src/components/verify/utils/axios.js rename to admin/src/components/verify/utils/axios.ts diff --git a/admin/src/components/verify/utils/util.js b/admin/src/components/verify/utils/util.ts similarity index 100% rename from admin/src/components/verify/utils/util.js rename to admin/src/components/verify/utils/util.ts diff --git a/admin/src/utils/request/index.ts b/admin/src/utils/request/index.ts index 67a0ce3..f82522b 100644 --- a/admin/src/utils/request/index.ts +++ b/admin/src/utils/request/index.ts @@ -13,6 +13,18 @@ import type { AxiosResponse } from 'axios' import router from '@/router' import { PageEnum } from '@/enums/pageEnum' +export interface Pages { + count: number + lists: T[] + pageNo: number + pageSize: number +} +export interface Response { + code: number + message: string + data: T +} + // 处理axios的钩子函数 const axiosHooks: AxiosHooks = { requestInterceptorsHook(config) { diff --git a/admin/src/utils/util.ts b/admin/src/utils/util.ts index a3106c8..eedbf98 100644 --- a/admin/src/utils/util.ts +++ b/admin/src/utils/util.ts @@ -1,6 +1,21 @@ import { isObject } from '@vue/shared' import { cloneDeep } from 'lodash-es' - +// import { md5 } from 'js-md5' +import MD5 from 'crypto-js/md5' +/** + * 密码加密 + * @param {String} password 密码 + * @param {String} beforeSalt 前置盐 + * @param {String} afterSalt 后置盐 + * @returns {String} 加密后的密码 + */ +export const encryptPassword = ( + password: string, + beforeSalt = 'opuoaqwehjkyuisdf', + afterSalt = 'asdjioewurtjfgiopu' +): string => { + return MD5(beforeSalt + MD5(password).toString() + afterSalt).toString() +} /** * @description 添加单位 * @param {String | Number} value 值 100 diff --git a/server/admin/generator/tpl_utils/templates/gocode/controller.go.tpl b/server/admin/generator/tpl_utils/templates/gocode/controller.go.tpl index 1bd8b4c..78500a5 100644 --- a/server/admin/generator/tpl_utils/templates/gocode/controller.go.tpl +++ b/server/admin/generator/tpl_utils/templates/gocode/controller.go.tpl @@ -22,8 +22,8 @@ type {{{ title (toCamelCase .ModuleName) }}}Handler struct {} {{{- range .Columns }}} {{{- if .IsQuery }}} {{{- if eq .HtmlType "datetime" }}} -// @Param {{{ title (toCamelCase .ColumnName) }}}Start query {{{ .GoType }}} false "{{{ .ColumnComment }}}." -// @Param {{{ title (toCamelCase .ColumnName) }}}End query {{{ .GoType }}} false "{{{ .ColumnComment }}}." +// @Param {{{ toCamelCase .GoField }}}Start query {{{ .GoType }}} false "{{{ .ColumnComment }}}." +// @Param {{{ toCamelCase .GoField }}}End query {{{ .GoType }}} false "{{{ .ColumnComment }}}." {{{- else }}} // @Param {{{ toCamelCase .GoField }}} query {{{ .GoType }}} false "{{{ .ColumnComment }}}." {{{- end }}} @@ -51,8 +51,8 @@ func (hd {{{ title (toCamelCase .ModuleName) }}}Handler) List(c *gin.Context) { {{{- range .Columns }}} {{{- if .IsQuery }}} {{{- if eq .HtmlType "datetime" }}} -// @Param {{{ title (toCamelCase .ColumnName) }}}Start query {{{ .GoType }}} false "{{{ .ColumnComment }}}." -// @Param {{{ title (toCamelCase .ColumnName) }}}End query {{{ .GoType }}} false "{{{ .ColumnComment }}}." +// @Param {{{ toCamelCase .GoField }}}Start query {{{ .GoType }}} false "{{{ .ColumnComment }}}." +// @Param {{{ toCamelCase .GoField }}}End query {{{ .GoType }}} false "{{{ .ColumnComment }}}." {{{- else }}} // @Param {{{ toCamelCase .GoField }}} query {{{ .GoType }}} false "{{{ .ColumnComment }}}." {{{- end }}} diff --git a/server/admin/generator/tpl_utils/templates/uniapp/api.ts.tpl b/server/admin/generator/tpl_utils/templates/uniapp/api.ts.tpl index 4951f16..468306d 100644 --- a/server/admin/generator/tpl_utils/templates/uniapp/api.ts.tpl +++ b/server/admin/generator/tpl_utils/templates/uniapp/api.ts.tpl @@ -1,17 +1,44 @@ import { request } from '@/utils/request' +import type { Pages } from '@/utils/request' +type {{{.ModuleName}}} = { +{{{- range .Columns }}} +{{{ toCamelCase .GoField }}}: {{{goToTsType .GoType}}}; +{{{- end }}} +} +// 查询 +type {{{.ModuleName}}}_query = { +{{{- range .Columns }}} +{{{- if .IsQuery }}} +{{{- if eq .HtmlType "datetime" }}} +{{{ toCamelCase .GoField }}}Start: string; +{{{ toCamelCase .GoField }}}End: string; +{{{- else }}} +{{{ toCamelCase .GoField }}}?: {{{goToTsType .GoType}}}; +{{{- end }}} +{{{- end }}} +{{{- end }}} +} +// 添加编辑 +type {{{.ModuleName}}}_edit = { +{{{- range .Columns }}} +{{{- if or .IsEdit .IsInsert }}} +{{{ toCamelCase .GoField }}}?: {{{goToTsType .GoType}}}; +{{{- end }}} +{{{- end }}} +} // {{{.FunctionName}}}列表 -export function {{{.ModuleName}}}_list(params?: Record) { - return request({ +export function {{{.ModuleName}}}_list(params?: {{{.ModuleName}}}_query) { + return request>({ url: '/{{{.ModuleName}}}/list', method: 'GET', data: params }) } // {{{.FunctionName}}}列表-所有 -export function {{{.ModuleName}}}_list_all(params?: Record) { - return request({ +export function {{{.ModuleName}}}_list_all(params?: {{{.ModuleName}}}_query) { + return request<{{{.ModuleName}}}[]>({ url: '/{{{.ModuleName}}}/listAll', method: 'GET', data: params @@ -20,7 +47,7 @@ export function {{{.ModuleName}}}_list_all(params?: Record) { // {{{.FunctionName}}}详情 export function {{{.ModuleName}}}_detail({{{ .PrimaryKey }}}: number | string) { - return request({ + return request<{{{.ModuleName}}}>({ url: '/{{{.ModuleName}}}/detail', method: 'GET', data: { {{{ .PrimaryKey }}} } @@ -28,8 +55,8 @@ export function {{{.ModuleName}}}_detail({{{ .PrimaryKey }}}: number | string) { } // {{{.FunctionName}}}新增 -export function {{{.ModuleName}}}_add(data: Record) { - return request({ +export function {{{.ModuleName}}}_add(data: {{{.ModuleName}}}_edit) { + return request({ url: '/{{{.ModuleName}}}/add', method: "POST", data, @@ -37,8 +64,8 @@ export function {{{.ModuleName}}}_add(data: Record) { } // {{{.FunctionName}}}编辑 -export function {{{.ModuleName}}}_edit(data: Record) { - return request({ +export function {{{.ModuleName}}}_edit(data: {{{.ModuleName}}}_edit) { + return request({ url: '/{{{.ModuleName}}}/edit', method: "POST", data, @@ -47,7 +74,7 @@ export function {{{.ModuleName}}}_edit(data: Record) { // {{{.FunctionName}}}删除 export function {{{.ModuleName}}}_delete({{{ .PrimaryKey }}}: number | string) { - return request({ + return request({ url: '/{{{.ModuleName}}}/del', method: "POST", data:{ diff --git a/server/admin/generator/tpl_utils/templates/uniapp/details.vue.tpl b/server/admin/generator/tpl_utils/templates/uniapp/details.vue.tpl index 880defc..3eaf417 100644 --- a/server/admin/generator/tpl_utils/templates/uniapp/details.vue.tpl +++ b/server/admin/generator/tpl_utils/templates/uniapp/details.vue.tpl @@ -56,7 +56,13 @@ toPath } from "@/utils/utils"; - let form = ref({}); + let form = ref({ + {{{- range .Columns }}} + {{{- if or .IsList .IsPk }}} + {{{ toCamelCase .GoField }}}: "", + {{{- end }}} + {{{- end }}} + }); {{{- if ge (len .DictFields) 1 }}} {{{- $dictSize := sub (len .DictFields) 1 }}} const { dictData } = useDictData([{{{- range .DictFields }}}'{{{ . }}}'{{{- if ne (index $.DictFields $dictSize) . }}},{{{- end }}}{{{- end }}}]) diff --git a/server/admin/generator/tpl_utils/templates/uniapp/index.vue.tpl b/server/admin/generator/tpl_utils/templates/uniapp/index.vue.tpl index a4ee898..2d4305a 100644 --- a/server/admin/generator/tpl_utils/templates/uniapp/index.vue.tpl +++ b/server/admin/generator/tpl_utils/templates/uniapp/index.vue.tpl @@ -71,8 +71,16 @@ import { {{{ .ModuleName }}}_list } from "@/api/{{{ .ModuleName }}}"; import { usePaging } from "@/hooks/usePaging"; import { toPath } from "@/utils/utils"; const queryParams = reactive({ - key: "", - +{{{- range .Columns }}} +{{{- if .IsQuery }}} + {{{- if eq .HtmlType "datetime" }}} + {{{ (toCamelCase .GoField) }}}Start: '', + {{{ (toCamelCase .GoField) }}}End: '', + {{{- else }}} + {{{ (toCamelCase .GoField) }}}: '', + {{{- end }}} +{{{- end }}} +{{{- end }}} }); let fromSearch=ref(false); onLoad((e) => { diff --git a/server/admin/generator/tpl_utils/templates/vue/api.ts.tpl b/server/admin/generator/tpl_utils/templates/vue/api.ts.tpl index f524ce0..5f9e441 100644 --- a/server/admin/generator/tpl_utils/templates/vue/api.ts.tpl +++ b/server/admin/generator/tpl_utils/templates/vue/api.ts.tpl @@ -1,36 +1,64 @@ import request from '@/utils/request' +import type { Pages } from '@/utils/request' + import config from '@/config' import queryString from 'query-string' import { getToken } from '@/utils/auth' +type {{{.ModuleName}}} = { +{{{- range .Columns }}} +{{{ toCamelCase .GoField }}}: {{{goToTsType .GoType}}}; +{{{- end }}} +} +// 查询 +type {{{.ModuleName}}}_query = { +{{{- range .Columns }}} +{{{- if .IsQuery }}} +{{{- if eq .HtmlType "datetime" }}} +{{{ toCamelCase .GoField }}}Start: string; +{{{ toCamelCase .GoField }}}End:string; +{{{- else }}} +{{{ toCamelCase .GoField }}}?: {{{goToTsType .GoType}}}; +{{{- end }}} +{{{- end }}} +{{{- end }}} +} +// 添加编辑 +type {{{.ModuleName}}}_edit = { +{{{- range .Columns }}} +{{{- if or .IsEdit .IsInsert }}} +{{{ toCamelCase .GoField }}}?: {{{goToTsType .GoType}}}; +{{{- end }}} +{{{- end }}} +} // {{{.FunctionName}}}列表 -export function {{{.ModuleName}}}_list(params?: Record) { - return request.get({ url: '/{{{.ModuleName}}}/list', params }) +export function {{{.ModuleName}}}_list(params?: {{{.ModuleName}}}_query) { + return request.get>({ url: '/{{{.ModuleName}}}/list', params }) } // {{{.FunctionName}}}列表-所有 -export function {{{.ModuleName}}}_list_all(params?: Record) { - return request.get({ url: '/{{{.ModuleName}}}/listAll', params }) +export function {{{.ModuleName}}}_list_all(params?: {{{.ModuleName}}}_query) { + return request.get>({ url: '/{{{.ModuleName}}}/listAll', params }) } // {{{.FunctionName}}}详情 export function {{{.ModuleName}}}_detail({{{ .PrimaryKey }}}: number | string) { - return request.get({ url: '/{{{.ModuleName}}}/detail', { {{{ .PrimaryKey }}} } }) + return request.get<{{{.ModuleName}}}>({ url: '/{{{.ModuleName}}}/detail', params: { {{{ .PrimaryKey }}} } }) } // {{{.FunctionName}}}新增 -export function {{{.ModuleName}}}_add(data: Record) { - return request.post({ url: '/{{{.ModuleName}}}/add', data }) +export function {{{.ModuleName}}}_add(data: {{{.ModuleName}}}_edit) { + return request.post({ url: '/{{{.ModuleName}}}/add', data }) } // {{{.FunctionName}}}编辑 -export function {{{.ModuleName}}}_edit(data: Record) { - return request.post({ url: '/{{{.ModuleName}}}/edit', data }) +export function {{{.ModuleName}}}_edit(data: {{{.ModuleName}}}_edit) { + return request.post({ url: '/{{{.ModuleName}}}/edit', data }) } // {{{.FunctionName}}}删除 export function {{{.ModuleName}}}_delete({{{ .PrimaryKey }}}: number | string) { - return request.post({ url: '/{{{.ModuleName}}}/del', { {{{ .PrimaryKey }}} } }) + return request.post({ url: '/{{{.ModuleName}}}/del', data: { {{{ .PrimaryKey }}} } }) } // {{{.FunctionName}}}导入 diff --git a/server/admin/generator/tpl_utils/tpl.go b/server/admin/generator/tpl_utils/tpl.go index 24799be..0a2c519 100644 --- a/server/admin/generator/tpl_utils/tpl.go +++ b/server/admin/generator/tpl_utils/tpl.go @@ -23,6 +23,7 @@ var TemplateUtil = templateUtil{ "toSnakeCase": util.StringUtil.ToSnakeCase, "toCamelCase": util.StringUtil.ToCamelCase, "contains": util.ToolsUtil.Contains, + "goToTsType": util.ToolsUtil.GoToTsType, }), } diff --git a/server/core/response/response.go b/server/core/response/response.go index 6900889..dd12cbf 100644 --- a/server/core/response/response.go +++ b/server/core/response/response.go @@ -106,14 +106,14 @@ func Copy(toValue interface{}, fromValue interface{}) interface{} { // Ok 正常响应 func Ok(c *gin.Context) { - Result(c, Success, []string{}) + Result(c, Success, nil) } // OkWithMsg 正常响应附带msg func OkWithMsg(c *gin.Context, message string) { resp := Success resp.message = message - Result(c, resp, []string{}) + Result(c, resp, nil) } // OkWithData 正常响应附带data @@ -133,14 +133,14 @@ func respLogger(resp RespType, template string, args ...interface{}) { // Fail 错误响应 func Fail(c *gin.Context, resp RespType) { respLogger(resp, "Request Fail: url=[%s], resp=[%+v]", c.Request.URL.Path, resp) - Result(c, resp, []string{}) + Result(c, resp, nil) } // FailWithMsg 错误响应附带msg func FailWithMsg(c *gin.Context, resp RespType, message string) { resp.message = message respLogger(resp, "Request FailWithMsg: url=[%s], resp=[%+v]", c.Request.URL.Path, resp) - Result(c, resp, []string{}) + Result(c, resp, nil) } // FailWithData 错误响应附带data @@ -159,7 +159,7 @@ func IsFailWithResp(c *gin.Context, err error) bool { case RespType: data := v.Data() if data == nil { - data = []string{} + data = nil } FailWithData(c, v, data) // 其他类型 diff --git a/server/util/tools.go b/server/util/tools.go index b57611f..02f778e 100644 --- a/server/util/tools.go +++ b/server/util/tools.go @@ -69,6 +69,34 @@ func (tu toolsUtil) Contains(src interface{}, elem interface{}) bool { return false } +/** + * @description: Go类型转TS类型 + */ +func (tu toolsUtil) GoToTsType(s string) string { + if s == "int" || s == "int8" || s == "int16" || s == "int32" || s == "int64" { + return "number" + } else if s == "float" || s == "float32" || s == "float64" { + return "number" + } else if s == "string" { + return "string" + } else if s == "bool" { + return "boolean" + } else if s == "time.Time" { + return "Date" + } else if s == "[]byte" { + return "string" + } else if s == "[]string" { + return "string[]" + } else if s == "[]int" { + return "number[]" + } else if s == "[]float" { + return "number[]" + } else if s == "core.TsTime" { + return "string" + } + return "string" +} + // Round float四舍五入 func (tu toolsUtil) Round(val float64, n int) float64 { base := math.Pow(10, float64(n)) diff --git a/x_admin_app/api/monitor_project.ts b/x_admin_app/api/monitor_project.ts index c3ce785..687dd3d 100644 --- a/x_admin_app/api/monitor_project.ts +++ b/x_admin_app/api/monitor_project.ts @@ -1,17 +1,24 @@ import { request } from '@/utils/request' - - +import type { Pages } from '@/utils/request' +type monitor_project= { + id?: number; + projectName?: string; + projectType?: string; + projectKey?: string; + updateTime?: string; + createTime?: string; +} // 监控项目列表 -export function monitor_project_list(params?: Record) { - return request({ +export function monitor_project_list(params?: monitor_project) { + return request>({ url: '/monitor_project/list', method: 'GET', data: params }) } // 监控项目列表-所有 -export function monitor_project_list_all(params?: Record) { - return request({ +export function monitor_project_list_all(params?: monitor_project) { + return request({ url: '/monitor_project/listAll', method: 'GET', data: params @@ -20,7 +27,7 @@ export function monitor_project_list_all(params?: Record) { // 监控项目详情 export function monitor_project_detail(id: number | string) { - return request({ + return request({ url: '/monitor_project/detail', method: 'GET', data: { id } @@ -28,8 +35,8 @@ export function monitor_project_detail(id: number | string) { } // 监控项目新增 -export function monitor_project_add(data: Record) { - return request({ +export function monitor_project_add(data: monitor_project) { + return request({ url: '/monitor_project/add', method: "POST", data, @@ -37,8 +44,8 @@ export function monitor_project_add(data: Record) { } // 监控项目编辑 -export function monitor_project_edit(data: Record) { - return request({ +export function monitor_project_edit(data: monitor_project) { + return request({ url: '/monitor_project/edit', method: "POST", data, @@ -47,7 +54,7 @@ export function monitor_project_edit(data: Record) { // 监控项目删除 export function monitor_project_delete(id: number | string) { - return request({ + return request({ url: '/monitor_project/del', method: "POST", data:{ diff --git a/x_admin_app/api/user.js b/x_admin_app/api/user.js deleted file mode 100644 index 569ea13..0000000 --- a/x_admin_app/api/user.js +++ /dev/null @@ -1,29 +0,0 @@ -import {request} from '@/utils/request'; - - - -export function login(data) { - return request({ - url: '/system/login', - method: 'POST', - data - }) -} - -export function getInfo(token) { - return request({ - url: '/system/admin/self', - method: 'GET', - data: { - token - } - }) -} - -export function logout() { - return request({ - url: '/system/logout', - method: 'GET' - }) -} - diff --git a/x_admin_app/api/user.ts b/x_admin_app/api/user.ts new file mode 100644 index 0000000..1ef0266 --- /dev/null +++ b/x_admin_app/api/user.ts @@ -0,0 +1,44 @@ +import { request } from "@/utils/request"; +// import type {Response} from '@/utils/request'; + +export function login(data: any) { + return request<{ + token: string; + }>({ + url: "/system/login", + method: "POST", + data, + }); +} + +export function getInfo(token: string) { + return request<{ + permissions: string[]; + user: { + avatar: string; + createTime: string; + dept: string; + id: number; + isDisable: number; + lastLoginIp: string; + lastLoginTime: string; + nickname: string; + role: string; + updateTime: string; + username: string; + }; + }>({ + url: "/system/admin/self", + method: "GET", + data: { + token, + }, + }); +} + +export function logout() { + return request({ + url: "/system/logout", + method: "GET", + }); +} diff --git a/x_admin_app/methods/index.ts b/x_admin_app/methods/index.ts index d4b3e4f..d7e73bd 100644 --- a/x_admin_app/methods/index.ts +++ b/x_admin_app/methods/index.ts @@ -1,5 +1,5 @@ -import { perms } from "@/utils/perms.js"; -import { toPath } from "@/utils/utils.js"; +import { perms } from "@/utils/perms"; +import { toPath } from "@/utils/utils"; import env from "@/utils/env"; /** diff --git a/x_admin_app/pages/index/index.vue b/x_admin_app/pages/index/index.vue index 90669d4..30db725 100644 --- a/x_admin_app/pages/index/index.vue +++ b/x_admin_app/pages/index/index.vue @@ -13,7 +13,7 @@ -