Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
陆宇天
/
config-center-front
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
1
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 5710d5b4
authored
Nov 07, 2023
by
胡悦
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
提交优化
1 parent
c7125f7d
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
83 additions
and
27 deletions
src/main.ts
src/shims-vue.d.ts
src/type/index.ts
src/views/condition/ConditionEditor.vue
src/views/project/AddProject.vue
src/views/project/Project.vue
src/views/projectApi/AddApi.vue
src/views/projectApi/ApiList.vue
src/main.ts
View file @
5710d5b
...
...
@@ -7,6 +7,7 @@ import "element-plus/theme-chalk/el-loading.css";
import
"element-plus/theme-chalk/el-message.css"
;
import
"element-plus/theme-chalk/el-notification.css"
;
import
"element-plus/theme-chalk/el-message-box.css"
;
import
"element-plus/theme-chalk/el-form.css"
;
const
app
=
createApp
(
App
);
// 防止重复快速点击自定义全局指令
app
.
directive
(
"preventReClick"
,
{
...
...
src/shims-vue.d.ts
View file @
5710d5b
/*
* @Description:
* @Author: huyue
* @Date: 2023-08-31 11:35:41
* @LastEditors: huyue
* @LastEditTime: 2023-11-01 14:06:23
*/
/* eslint-disable */
declare
module
'*.vue'
{
import
type
{
DefineComponent
}
from
'vue'
const
component
:
DefineComponent
<
{},
{},
any
>
export
default
component
}
declare
module
'*.js'
declare
module
'js-beautify'
{
// beautify_js:any
const
beautify_js
:(
a
:
any
)
=>
any
...
...
src/type/index.ts
View file @
5710d5b
...
...
@@ -4,7 +4,7 @@ import { ProjectApi } from './index';
* @Author: huyue
* @Date: 2023-01-16 17:23:14
* @LastEditors: huyue
* @LastEditTime: 2023-
07-24 14:21:35
* @LastEditTime: 2023-
11-01 15:08:46
*/
/**
* 存放公共的类型声明文件
...
...
@@ -30,7 +30,7 @@ export interface ProjectItem {
//项目分类里api
export
interface
ProjectApi
{
id
?:
number
;
projectId
:
number
;
projectId
?
:
number
;
method
:
string
;
url
:
string
;
baseUrl
?:
string
;
...
...
@@ -38,6 +38,8 @@ export interface ProjectApi {
content
:
string
;
createDate
?:
Date
;
updateDate
?:
Date
;
username
?:
string
;
businessType
:
number
|
string
;
}
//项目条件判断
...
...
@@ -66,6 +68,7 @@ export interface ProjectApiSearch {
size
:
number
;
projectId
:
any
;
url
?:
string
;
businessType
?:
string
;
}
export
interface
CopyProject
{
...
...
@@ -109,4 +112,17 @@ export interface ModelDelete {
export
interface
IsUnique
{
uniqueName
:
string
}
export
interface
DialogData
{
dialogFormVisible
:
boolean
,
form
?:
Partial
<
formData
>
,
environmentList
:
EnvList
[]
}
export
interface
formData
{
id
?:
number
,
addr
?:
string
}
export
interface
EnvList
{
id
:
number
;
addr
:
string
;
}
\ No newline at end of file
src/views/condition/ConditionEditor.vue
View file @
5710d5b
...
...
@@ -70,7 +70,7 @@
</
template
>
<
script
lang=
"ts"
>
import
{
defineComponent
,
ref
}
from
"vue"
;
import
{
defineComponent
,
nextTick
,
ref
}
from
"vue"
;
import
AceEditor
from
"@/components/AceEditor.vue"
;
import
{
ElMessage
,
ElMessageBox
}
from
"element-plus"
;
import
"element-plus/theme-chalk/el-message.css"
;
...
...
@@ -198,7 +198,7 @@ export default defineComponent({
};
//添加到编辑器内容区
const
addToEditor
=
()
=>
{
const
addToEditor
=
async
()
=>
{
if
(
!
editorIp
.
value
||
!
editorEnv
.
value
)
{
ElMessage
({
type
:
"error"
,
...
...
@@ -212,6 +212,8 @@ export default defineComponent({
[
editorIp
.
value
]:
editorEnv
.
value
,
});
editorDom
.
value
.
setEditorContent
();
await
nextTick
()
beautifulCodeFn
()
};
onBeforeRouteLeave
(()
=>
{
sessionStorage
.
removeItem
(
"conditionItem"
);
...
...
src/views/project/AddProject.vue
View file @
5710d5b
...
...
@@ -116,13 +116,14 @@ export default defineComponent({
id
:
parseInt
(
routerParams
.
id
as
string
),
};
let
{
code
}
=
await
projectEdit
(
params
);
statusCode
=
code
;
message
=
code
===
200
?
"编辑成功"
:
"编辑失败,请稍后再试"
;
statusCode
=
code
as
unknown
as
string
|
number
;
message
=
code
===
200
?
"编辑成功"
:
statusCode
==
'-1'
?
'存在相同的项目名称'
:
"编辑失败,请稍后再试"
;
}
else
{
//新增
let
{
code
}
=
await
projectAdd
(
ruleForm
);
statusCode
=
code
;
message
=
code
===
200
?
"添加成功"
:
"添加失败,请稍后再试"
;
// let { code } = await projectAdd(ruleForm);
let
result
=
await
projectAdd
(
ruleForm
)
statusCode
=
result
.
code
as
unknown
as
string
;
message
=
result
.
code
===
200
?
"添加成功"
:
statusCode
==
'-1'
?
'存在相同的项目名称'
:
"添加失败,请稍后再试"
;
}
if
(
statusCode
===
200
)
{
ElMessage
({
...
...
src/views/project/Project.vue
View file @
5710d5b
...
...
@@ -104,7 +104,7 @@ import { ElMessage, ElMessageBox } from "element-plus";
import
"element-plus/theme-chalk/el-message.css"
;
import
"element-plus/theme-chalk/el-message-box.css"
;
import
{
getProjectList
,
projectDel
}
from
"@/api/project"
;
import
{
getConfig
}
from
"@/api/config
"
;
import
{
projectApiAdd
}
from
"@/api/projectApi
"
;
import
{
getConditionList
}
from
"@/api/condition"
;
import
{
ProjectItem
,
ConditionItem
}
from
"@/type/index"
;
...
...
src/views/projectApi/AddApi.vue
View file @
5710d5b
...
...
@@ -9,7 +9,7 @@
/>
</div>
<div
class=
"rt-content"
>
<h3
class=
"info"
>
接口信息
</h3>
<h3
class=
"info"
>
{{
routerParams
.
baseUrl
}}
环境
接口信息
</h3>
<div
class=
"option"
>
<div
class=
"name"
>
method:get
</div>
<!--
<div
class=
"wrap"
>
...
...
@@ -36,7 +36,21 @@
</div>
</div>
<div
class=
"option"
>
<div
class=
"name"
>
模板
</div>
<div
class=
"name required"
>
业务类型
</div>
<div
class=
"wrap"
>
<!-- <el-input v-model="remark" placeholder="请输入描述"> </el-input> -->
<el-select
v-model=
"businessType"
class=
"m-2"
placeholder=
"Select"
>
<el-option
v-for=
"item in businessTypeList"
:key=
"item.value"
:label=
"item.name"
:value=
"item.value"
/>
</el-select>
</div>
</div>
<div
class=
"option"
>
<div
class=
"name"
>
选择模板
</div>
<div
class=
"wrap"
>
<!-- <el-input v-model="remark" placeholder="请输入描述"> </el-input> -->
<el-select
v-model=
"selectModel"
@
change=
"selectModelChange"
class=
"m-2"
placeholder=
"Select"
>
...
...
@@ -121,6 +135,25 @@ export default defineComponent({
modelList
.
push
(...
data
);
}
};
/** 业务类型 */
const
businessType
=
ref
(
""
)
const
businessTypeList
=
reactive
([{
name
:
'SCRM'
,
value
:
1
},{
name
:
'SAAS+'
,
value
:
2
},{
name
:
'小程序'
,
value
:
3
},{
name
:
'其他'
,
value
:
0
}])
/** */
//获取路由参数(新增的情况)
let
routerQuery
=
route
.
query
;
let
queryKeysLength
=
Object
.
keys
(
routerQuery
).
length
;
...
...
@@ -129,7 +162,7 @@ export default defineComponent({
let
storageEditItem
=
window
.
sessionStorage
.
getItem
(
"editApiItem"
)
&&
JSON
.
parse
(
window
.
sessionStorage
.
getItem
(
"editApiItem"
)
||
""
);
let
routerParams
=
storageEditItem
||
{};
let
routerParams
=
reactive
(
storageEditItem
||
{})
let
keysLength
=
Object
.
keys
(
routerParams
).
length
;
if
(
keysLength
>
0
)
{
//编辑
...
...
@@ -137,17 +170,11 @@ export default defineComponent({
remark
.
value
=
routerParams
.
remark
as
string
;
url
.
value
=
routerParams
.
url
as
string
;
method
.
value
=
routerParams
.
method
as
string
;
businessType
.
value
=
routerParams
.
businessType
as
string
;
}
const
userInfo
=
window
.
sessionStorage
.
getItem
(
"userInfo"
)
&&
JSON
.
parse
(
window
.
sessionStorage
.
getItem
(
"userInfo"
)
||
""
);
// 是否管理员
// const isAdmin = userInfo && userInfo.roleId === 1 ? true : false;
// const disabled = ref(
// storageEditItem && storageEditItem.projectId === 1 && !isAdmin
// ? true
// : false
// );
const
disabled
=
userInfo
.
auth
==
"readonly"
?
true
:
false
;
// 格式化代码
const
beautifulCodeFn
=
()
=>
{
...
...
@@ -155,9 +182,9 @@ export default defineComponent({
};
//保存代码
const
saveCodeFn
=
async
()
=>
{
if
(
!
url
.
value
||
!
remark
.
value
||
!
editorContent
.
value
)
{
if
(
!
url
.
value
||
!
remark
.
value
||
!
businessType
.
value
&&
businessType
.
value
!=
'0'
||
!
editorContent
.
value
)
{
return
ElMessage
({
message
:
"请把信息补充完整
url,content,描述
"
,
message
:
"请把信息补充完整"
,
type
:
"error"
,
});
}
...
...
@@ -177,6 +204,7 @@ export default defineComponent({
remark
:
remark
.
value
,
content
:
editorContent
.
value
,
username
:
userInfo
.
name
,
businessType
:
businessType
.
value
};
let
{
code
}
=
await
projectApiAdd
(
params
);
if
(
code
===
200
)
{
...
...
@@ -204,6 +232,7 @@ export default defineComponent({
url
:
url
.
value
,
remark
:
remark
.
value
,
username
:
userInfo
.
name
,
businessType
:
businessType
.
value
}
as
ProjectApi
;
let
{
code
}
=
await
projectApiEdit
(
params
);
if
(
code
===
200
)
{
...
...
@@ -261,10 +290,6 @@ export default defineComponent({
onBeforeRouteLeave
(()
=>
{
sessionStorage
.
removeItem
(
"editApiItem"
);
});
// watch(editorContent, (newVal, prevCount) => {
// console.log("newVal: ", newVal);
// // console.log("prevCount: ", prevCount);
// });
return
{
methodsOptions
,
method
,
...
...
@@ -278,7 +303,10 @@ export default defineComponent({
disabled
,
selectModel
,
modelList
,
selectModelChange
selectModelChange
,
businessType
,
businessTypeList
,
routerParams
};
},
components
:
{
...
...
src/views/projectApi/ApiList.vue
View file @
5710d5b
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment