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 836f8b97
authored
Aug 07, 2023
by
前端
Browse Files
Options
Browse Files
Tag
Download
Plain Diff
Merge branch 'develop' into 'master'
第四期优化 See merge request
!3
2 parents
23f8b6e2
5bb7f30c
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
144 additions
and
16 deletions
src/api/projectApi.ts
src/config/index.ts
src/type/index.ts
src/utils/util.js
src/views/account/accountList.vue
src/views/account/createAccount.vue
src/views/condition/ConditionEditor.vue
src/views/login.vue
src/views/project/AddProject.vue
src/views/project/Project.vue
src/views/projectApi/ApiList.vue
src/api/projectApi.ts
View file @
836f8b9
...
...
@@ -3,17 +3,18 @@
* @Author: huyue
* @Date: 2023-01-30 16:10:23
* @LastEditors: huyue
* @LastEditTime: 2023-0
5-25 19:21:13
* @LastEditTime: 2023-0
7-24 11:45:24
*/
import
request
from
"@/api/request"
;
import
qs
from
"qs"
;
import
{
ProjectApi
,
ProjectApiSearch
}
from
"@/type/index"
;
import
{
ProjectApi
,
ProjectApiSearch
,
CopyProject
}
from
"@/type/index"
;
const
serverUrl
=
{
list
:
"/projectApi/list"
,
add
:
"/projectApi/add"
,
edit
:
"/projectApi/edit"
,
del
:
"/projectApi/delete"
,
copy
:
"/projectApi/copy"
};
export
const
getProjectApiList
=
(
params
:
ProjectApiSearch
)
=>
{
...
...
@@ -28,3 +29,6 @@ export const projectApiEdit = (params: ProjectApi) => {
export
const
projectApiDel
=
(
params
:
{
id
:
number
})
=>
{
return
request
.
post
(
serverUrl
.
del
,
params
);
};
export
const
getCopyApi
=
(
params
:
CopyProject
)
=>
{
return
request
.
get
(
serverUrl
.
copy
+
"?"
+
qs
.
stringify
(
params
));
};
src/config/index.ts
View file @
836f8b9
...
...
@@ -3,7 +3,7 @@
* @Author: huyue
* @Date: 2023-01-30 16:10:23
* @LastEditors: huyue
* @LastEditTime: 2023-0
6-13 22:19:53
* @LastEditTime: 2023-0
8-04 22:38:44
*/
/**
* 公共配置模块
...
...
src/type/index.ts
View file @
836f8b9
...
...
@@ -4,7 +4,7 @@ import { ProjectApi } from './index';
* @Author: huyue
* @Date: 2023-01-16 17:23:14
* @LastEditors: huyue
* @LastEditTime: 2023-0
5-25 21:53:22
* @LastEditTime: 2023-0
7-24 14:21:35
*/
/**
* 存放公共的类型声明文件
...
...
@@ -66,4 +66,9 @@ export interface ProjectApiSearch {
size
:
number
;
projectId
:
any
;
url
?:
string
;
}
export
interface
CopyProject
{
moduleUrl
?:
string
;
env
?:
string
;
}
\ No newline at end of file
src/utils/util.js
0 → 100644
View file @
836f8b9
/*
* @Description:
* @Author: huyue
* @Date: 2023-07-24 17:44:17
* @LastEditors: huyue
* @LastEditTime: 2023-07-24 17:46:45
*/
const
deepClone
=
obj
=>
{
// Handle the 3 simple types, and null or undefined or function
if
(
obj
==
null
||
typeof
obj
!==
'object'
)
return
obj
// Handle Date
if
(
obj
instanceof
Date
)
{
const
copy
=
new
Date
()
copy
.
setTime
(
obj
.
getTime
())
return
copy
}
// Handle Array or Object
if
((
obj
instanceof
Array
)
|
(
obj
instanceof
Object
))
{
const
copy
=
obj
instanceof
Array
?
[]
:
{}
for
(
var
attr
in
obj
)
{
// eslint-disable-next-line no-prototype-builtins
if
(
obj
.
hasOwnProperty
(
attr
))
{
copy
[
attr
]
=
deepClone
(
obj
[
attr
])
}
}
return
copy
}
throw
new
Error
(
"Unable to clone obj! Its type isn't supported."
)
}
const
utils
=
{
deepClone
}
export
default
utils
src/views/account/accountList.vue
View file @
836f8b9
...
...
@@ -3,7 +3,7 @@
* @Author: huyue
* @Date: 2023-02-21 17:16:18
* @LastEditors: huyue
* @LastEditTime: 2023-0
2-22 17:25:57
* @LastEditTime: 2023-0
7-24 18:23:05
-->
<
template
>
<div
class=
"wrapper-content"
>
...
...
@@ -33,6 +33,11 @@
>
<el-table-column
prop=
"updateDate"
label=
"更新时间"
width=
"250"
/>
<el-table-column
prop=
"acount"
label=
"用户名"
width=
"180"
/>
<el-table-column
prop=
"auth"
label=
"权限"
width=
"180"
>
<template
#
default=
"scope"
>
{{
scope
.
row
.
auth
==
'write'
?
'编辑'
:
'查看'
}}
</
template
>
</el-table-column>
<el-table-column
label=
"操作"
>
<
template
#
default=
"scope"
>
<el-input
...
...
@@ -86,6 +91,7 @@ interface User {
acount
:
string
;
name
:
string
;
updateDate
:
string
;
auth
:
string
;
}
// data数据接口
interface
DataType
{
...
...
src/views/account/createAccount.vue
View file @
836f8b9
...
...
@@ -31,6 +31,13 @@
placeholder=
"请输入密码"
/>
</el-form-item>
<el-form-item
label=
"权限"
prop=
"auth"
>
<el-switch
v-model=
"form.auth"
active-text=
"编辑"
inactive-text=
"查看"
>
</el-switch>
</el-form-item>
</el-form>
<template
#
footer
>
<div
class=
"dialog-footer"
>
...
...
@@ -44,6 +51,7 @@
</template>
<
script
lang=
"ts"
setup
>
import
{
reactive
,
defineEmits
,
ref
}
from
"vue"
;
import
utils
from
"../../utils/util.js"
;
import
{
register
}
from
"@/api/login"
;
import
type
{
FormInstance
,
FormRules
}
from
"element-plus"
;
import
{
ElMessage
}
from
"element-plus"
;
...
...
@@ -53,6 +61,7 @@ const form = reactive({
password
:
""
,
acount
:
""
,
name
:
""
,
auth
:
false
});
const
rules
=
reactive
<
FormRules
>
({
name
:
[{
required
:
true
,
message
:
"请输入用户名"
,
trigger
:
"blur"
}],
...
...
@@ -70,8 +79,11 @@ const sure = async (formEl: FormInstance | undefined) => {
await
formEl
.
validate
(
async
(
valid
:
any
)
=>
{
if
(
valid
)
{
console
.
log
(
"提交"
,
form
);
const
params
=
utils
.
deepClone
(
form
)
const
{
auth
}
=
form
params
.
auth
=
auth
?
'write'
:
'readonly'
requestAnimationFrame
(
async
()
=>
{
let
{
code
,
message
}
=
await
register
(
form
);
let
{
code
,
message
}
=
await
register
(
params
);
if
(
code
==
200
)
{
emits
(
"update:modelValue"
,
false
);
emits
(
"confirm"
);
...
...
src/views/condition/ConditionEditor.vue
View file @
836f8b9
...
...
@@ -114,6 +114,7 @@ export default defineComponent({
options
.
value
=
allOptions
.
filter
((
i
:
OptionType
)
=>
{
return
routerParams
.
id
==
1
?
i
.
isPro
:
!
i
.
isPro
})
console
.
log
(
routerParams
);
if
(
keysLength
>
0
)
{
//编辑
editorContent
.
value
=
routerParams
.
content
as
string
;
...
...
@@ -124,7 +125,9 @@ export default defineComponent({
JSON
.
parse
(
window
.
sessionStorage
.
getItem
(
"userInfo"
)
||
""
);
// 是否管理员
const
isAdmin
=
userInfo
&&
userInfo
.
roleId
===
1
?
true
:
false
;
const
disabled
=
ref
(
storageEditItem
.
id
===
1
&&
!
isAdmin
?
true
:
false
);
const
isProduction
=
storageEditItem
.
id
===
1
const
canEdit
=
userInfo
.
auth
==
"write"
let
disabled
=
isProduction
&&
!
isAdmin
||
!
isProduction
&&
!
canEdit
;
// 格式化代码
const
beautifulCodeFn
=
()
=>
{
editorDom
.
value
?.
codeFormat
();
...
...
src/views/login.vue
View file @
836f8b9
...
...
@@ -42,6 +42,7 @@
<el-button
class=
"btn_login"
v-preventReClick
@
keyup
.
enter=
"loginEvent(ruleFormRef)"
@
click
.
prevent=
"loginEvent(ruleFormRef)"
>
登 录
...
...
@@ -65,6 +66,12 @@ const loginForm = reactive({
acount
:
""
,
password
:
""
,
});
document
.
onkeydown
=
function
(
e
)
{
let
key
=
(
window
as
any
).
event
.
keyCode
;
if
(
key
===
13
)
{
loginEvent
(
ruleFormRef
.
value
)
}
}
const
validateAcount
=
(
rule
:
any
,
value
:
any
,
callback
:
any
)
=>
{
let
reg
=
new
RegExp
(
"[`~!@#$^&*=|{}':;./%',\\[\\]<>?~!@#¥……&*——|{}【】‘;:”“'。,、? ]"
...
...
@@ -86,6 +93,7 @@ const rules = reactive<FormRules>({
password
:
[{
required
:
true
,
message
:
"请输入密码"
,
trigger
:
"blur"
}],
});
const
loginEvent
=
async
(
formEl
:
FormInstance
|
undefined
)
=>
{
console
.
log
(
formEl
);
if
(
!
formEl
)
return
;
await
formEl
.
validate
(
async
(
valid
)
=>
{
if
(
valid
)
{
...
...
@@ -133,6 +141,8 @@ const loginEvent = async (formEl: FormInstance | undefined) => {
}
});
};
</
script
>
<
style
scoped
lang=
"scss"
>
.page
{
...
...
src/views/project/AddProject.vue
View file @
836f8b9
...
...
@@ -22,6 +22,9 @@
<el-form-item
label=
"是否是生产环境"
prop=
"isPro"
>
<el-switch
v-model=
"ruleForm.isPro"
/>
</el-form-item>
<el-form-item
label=
"是否是固定项"
prop=
"flag"
>
<el-switch
v-model=
"ruleForm.flag"
/>
</el-form-item>
<el-form-item
label=
"备注"
prop=
"remark"
>
<el-input
v-model=
"ruleForm.remark"
type=
"textarea"
/>
</el-form-item>
...
...
@@ -69,6 +72,7 @@ export default defineComponent({
addr
:
""
,
isPro
:
false
,
remark
:
""
,
flag
:
false
});
// 获取编辑数据
...
...
@@ -83,14 +87,14 @@ export default defineComponent({
ruleForm
.
addr
=
routerParams
.
addr
as
string
;
ruleForm
.
remark
=
routerParams
.
remark
as
string
;
ruleForm
.
isPro
=
routerParams
.
isPro
as
boolean
;
ruleForm
.
flag
=
routerParams
.
flag
as
boolean
;
}
const
userInfo
=
window
.
sessionStorage
.
getItem
(
"userInfo"
)
&&
JSON
.
parse
(
window
.
sessionStorage
.
getItem
(
"userInfo"
)
||
""
);
// 是否管理员
const
isAdmin
=
userInfo
&&
userInfo
.
roleId
===
1
?
true
:
false
;
const
disabled
=
storageEditItem
&&
storageEditItem
.
id
===
1
&&
!
isAdmin
?
true
:
false
;
const
disabled
=
userInfo
.
auth
==
"readonly"
?
true
:
false
;
const
rules
=
reactive
<
FormRules
>
({
name
:
[{
required
:
true
,
message
:
"请输入名字"
,
trigger
:
"blur"
}],
addr
:
{
required
:
true
,
message
:
"请输入addr"
,
trigger
:
"blur"
},
...
...
src/views/project/Project.vue
View file @
836f8b9
...
...
@@ -30,6 +30,7 @@
class=
"button"
v-preventReClick
v-if=
"!item.disabled"
:disabled=
"isShow"
type=
"text"
@
click
.
stop=
"editFn(item)"
>
编辑
</el-button
...
...
@@ -38,6 +39,7 @@
class=
"button"
v-preventReClick
v-if=
"!item.disabled"
:disabled=
"isShow"
type=
"text"
@
click
.
stop=
"deleteFn(item)"
>
删除
</el-button
...
...
@@ -89,7 +91,7 @@
</el-card>
</el-col>
</el-row>
<AddButton
@
click=
"handerAddFn"
/>
<AddButton
v-if=
"!isShow"
@
click=
"handerAddFn"
/>
</div>
</
template
>
...
...
@@ -133,6 +135,7 @@ export default defineComponent({
JSON
.
parse
(
window
.
sessionStorage
.
getItem
(
"userInfo"
)
||
""
);
// 是否管理员
const
isAdmin
=
userInfo
&&
userInfo
.
roleId
===
1
?
true
:
false
;
const
isShow
=
userInfo
.
auth
==
"readonly"
?
true
:
false
;
const
addFn
=
(
flag
=
true
,
editorItem
?:
ProjectItem
)
=>
{
// 判断是编辑还是新增
if
(
flag
)
{
...
...
@@ -259,6 +262,7 @@ export default defineComponent({
editConditionFn
,
deleteConditionFn
,
goToEdit
,
isShow
};
},
components
:
{
...
...
src/views/projectApi/ApiList.vue
View file @
836f8b9
...
...
@@ -3,7 +3,7 @@
* @Author: huyue
* @Date: 2023-01-30 16:10:23
* @LastEditors: huyue
* @LastEditTime: 2023-0
5-25 22:13:00
* @LastEditTime: 2023-0
7-31 14:51:34
-->
<
template
>
<div
class=
"api-list"
>
...
...
@@ -18,7 +18,7 @@
<el-table-column
prop=
"remark"
label=
"remark"
/>
<el-table-column
prop=
"username"
label=
"操作人"
/>
<el-table-column
prop=
"updateDate"
label=
"更新时间"
/>
<el-table-column
label=
"操作"
>
<el-table-column
label=
"操作"
width=
"300"
>
<template
#
default=
"scope"
>
<el-button
type=
"text"
...
...
@@ -37,6 +37,22 @@
>
删除
</el-button>
<el-button
type=
"text"
size=
"small"
v-preventReClick
@
click
.
prevent=
"copy(scope.row)"
>
WEB复制链接
</el-button>
<el-button
type=
"text"
size=
"small"
v-preventReClick
@
click
.
prevent=
"copy(scope.row, 'env')"
>
小程序复制链接
</el-button>
</
template
>
</el-table-column>
</el-table>
...
...
@@ -57,10 +73,10 @@ import { ElMessage, ElMessageBox } from "element-plus";
import
"element-plus/theme-chalk/el-message.css"
;
import
"element-plus/theme-chalk/el-message-box.css"
;
import
router
from
"@/router"
;
import
{
ProjectApi
,
ProjectApiSearch
}
from
"@/type/index"
;
import
{
ProjectApi
,
ProjectApiSearch
,
CopyProject
}
from
"@/type/index"
;
import
{
useRoute
}
from
"vue-router"
;
import
{
getProjectApiList
,
projectApiDel
}
from
"@/api/projectApi"
;
import
{
getProjectApiList
,
projectApiDel
,
getCopyApi
}
from
"@/api/projectApi"
;
import
config
from
'../../config/index'
export
default
{
name
:
"ApiList"
,
setup
()
{
...
...
@@ -71,7 +87,8 @@ export default {
page
:
1
,
size
:
20
},
tableData
:
[]
tableData
:
[],
copyText
:
''
})
//获取路由对象
const
route
=
useRoute
();
...
...
@@ -160,6 +177,33 @@ export default {
apiData
.
pager
.
page
=
value
getdata
()
}
// 复制链接
const
copy
=
async
(
row
:
ProjectApi
,
env
?:
string
)
=>
{
let
text
=
`
${
config
.
baseUrl
.
pro
}
/glsxAdmin/config?moduleUrl=
${
row
.
url
}
`
if
(
env
)
{
text
+=
`&env=
${
row
.
baseUrl
}
`
}
copyText
(
text
)
}
const
copyText
=
(
e
:
any
)
=>
{
//创建一个input框
const
input
=
document
.
createElement
(
"input"
);
//将指定的DOM节点添加到body的末尾
document
.
body
.
appendChild
(
input
);
//设置input框的value值为直播地址
input
.
setAttribute
(
"value"
,
e
);
//选取文本域中的内容
input
.
select
();
//copy的意思是拷贝当前选中内容到剪贴板
//document.execCommand()方法操纵可编辑内容区域的元素
//返回值为一个Boolean,如果是 false 则表示操作不被支持或未被启用
if
(
document
.
execCommand
(
"copy"
))
{
document
.
execCommand
(
"copy"
);
}
//删除这个节点
document
.
body
.
removeChild
(
input
);
}
getdata
();
return
{
...
...
@@ -170,6 +214,7 @@ export default {
disabled
,
search
,
currentChange
,
copy
};
},
};
...
...
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