增加插件安装功能并提升其他功能稳定性 (#1155)

* 增加安装插件demo

* 前端上传demo

* 插件安装初版

* 调整菜单结构

* fix: 修改密码校验 jwt 中的用户 id

* router.go:fix  logger的中间件是默认的,这边日志可以删除;cors的日志打印应当在上面两行启用的时候再进行注释

* 登陆==>登录

* 抽离插件安装方法

* 调整插件功能 提升灵活度

Co-authored-by: zeromake <a390720046@gmail.com>
Co-authored-by: Lu JJ <275955589@qq.com>
Co-authored-by: pnck <hio131@gmail.com>
Co-authored-by: feixuanyu <994085848@qq.com>
This commit is contained in:
奇淼(piexlmax
2022-07-07 12:34:54 +08:00
committed by GitHub
co-authored by zeromake Lu JJ pnck feixuanyu
parent 063ceffb11
commit 4bf872d292
27 changed files with 290 additions and 61 deletions
+7
View File
@@ -124,3 +124,10 @@ export const createPlugApi = (data) => {
})
}
export const installPlug = (data) => {
return service({
url: '/autoCode/installPlug',
method: 'post',
data
})
}
-5
View File
@@ -41,11 +41,6 @@ export const viteLogo = (env) => {
`> 默认自动化文档地址:http://127.0.0.1:${env.VITE_SERVER_PORT}/swagger/index.html`
)
)
console.log(
chalk.green(
`> 默认自动化文档地址:http://127.0.0.1:${env.VITE_SERVER_PORT}/swagger/index.html`
)
)
console.log(
chalk.green(
`> 默认前端文件运行地址:http://127.0.0.1:${env.VITE_CLI_PORT}`
+16 -3
View File
@@ -49,12 +49,25 @@ router.beforeEach(async(to, from, next) => {
asyncRouterFlag++
await getRouter(userStore)
}
next({ name: userStore.userInfo.authority.defaultRouter })
// token 可以解析但是却是不存在的用户 id 或角色 id 会导致无限调用
if (userStore.userInfo?.authority?.defaultRouter != null) {
next({ name: userStore.userInfo.authority.defaultRouter })
} else {
// 强制退出账号
userStore.ClearStorage()
next({
name: 'Login',
query: {
redirect: document.location.hash
}
})
return
}
} else {
next()
}
} else {
// 不在白名单中并且已经登陆的时候
// 不在白名单中并且已经登录的时候
if (token) {
// 添加flag防止多次获取动态路由和栈溢出
if (!asyncRouterFlag && whiteList.indexOf(from.name) < 0) {
@@ -76,7 +89,7 @@ router.beforeEach(async(to, from, next) => {
}
}
}
// 不在白名单中并且未登陆的时候
// 不在白名单中并且未登录的时候
if (!token) {
next({
name: 'Login',
+9 -2
View File
@@ -52,7 +52,7 @@ export const useUserStore = defineStore('user', () => {
const LoginIn = async(loginInfo) => {
loadingInstance.value = ElLoading.service({
fullscreen: true,
text: '登陆中,请稍候...',
text: '登录中,请稍候...',
})
try {
const res = await login(loginInfo)
@@ -85,6 +85,12 @@ export const useUserStore = defineStore('user', () => {
window.location.reload()
}
}
/* 清理数据 */
const ClearStorage = async() => {
token.value = ''
sessionStorage.clear()
localStorage.clear()
}
/* 设置侧边栏模式*/
const changeSideMode = async(data) => {
const res = await setSelfInfo({ sideMode: data })
@@ -141,6 +147,7 @@ export const useUserStore = defineStore('user', () => {
setToken,
baseColor,
activeColor,
loadingInstance
loadingInstance,
ClearStorage
}
})
+6 -6
View File
@@ -6,7 +6,7 @@
width: 100%;
height: 100%;
position: relative;
.input-icon{
.input-icon {
padding-right: 6px;
padding-top: 4px;
}
@@ -47,10 +47,10 @@
padding-left: 20px;
}
}
.vPicBox{
display:flex;
justify-content:space-between;
width:100%;
.vPicBox {
display: flex;
justify-content: space-between;
width: 100%;
}
.vPic {
width: 33%;
@@ -83,7 +83,7 @@
}
}
//小屏幕不显示右侧,将登陆框居中
//小屏幕不显示右侧,将登录框居中
@media (max-width: 750px) {
.login_panle_right {
display: none;
+1 -1
View File
@@ -297,7 +297,7 @@ export default {
@include flex-center;
}
//小屏幕不显示右侧,将登陆框居中
//小屏幕不显示右侧,将登录框居中
@media (max-width: 750px) {
.gva-card {
padding: 20px 10px !important;
-1
View File
@@ -274,7 +274,6 @@ const savePassword = async() => {
modifyPwdForm.value.validate((valid) => {
if (valid) {
changePassword({
username: userStore.userInfo.userName,
password: pwdModify.value.password,
newPassword: pwdModify.value.newPassword,
}).then((res) => {
@@ -96,12 +96,14 @@
<el-button type="primary" @click="createPlug">创建</el-button>
</el-form-item>
</el-form>
</div>
</div>
</template>
<script setup>
import { toUpperCase } from '@/utils/stringFun'
import {
Plus,
Minus
@@ -0,0 +1,40 @@
<template>
<div>
<el-upload
class="upload-demo"
drag
:action="`${path}/autoCode/installPlugin`"
:headers="{'x-token':userStore.token}"
:show-file-list="false"
:on-success="handleSuccess"
:on-error="handleSuccess"
name="plug"
>
<el-icon class="el-icon--upload"><upload-filled /></el-icon>
<div class="el-upload__text">
拖拽或<em>点击上传</em>
</div>
<template #tip>
<div class="el-upload__tip">
请把安装包的zip拖拽至此处上传
</div>
</template>
</el-upload>
</div>
</template>
<script setup>
import { ref } from 'vue'
import { useUserStore } from '@/pinia/modules/user'
import { ElMessage } from 'element-plus'
const userStore = useUserStore()
const path = ref(import.meta.env.VITE_BASE_API)
const handleSuccess = (res) => {
if (res.code === 0) {
ElMessage.success(res.msg)
} else {
ElMessage.error(res.msg)
}
}
</script>