增加修改logo,横幅,华为云ECS展示到期日(感谢@anatsking),consul一键部署优化
parent
047bf07848
commit
aead7fcff4
|
@ -173,7 +173,7 @@ def ecs(account,region,isextip=False):
|
|||
'ostype':i['metadata']['os_type'].lower(),
|
||||
'cpu':i['flavor']['vcpus'] + '核',
|
||||
'mem':f"{str(round(int(i['flavor']['ram'])/1024,1)).rstrip('.0')}GB",
|
||||
'exp': exp_dict[i['id']]
|
||||
'exp': exp_dict.get(i['id'], '-')
|
||||
} for i in info}
|
||||
|
||||
if isextip:
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
from flask import Blueprint
|
||||
from flask_restful import reqparse, Resource, Api
|
||||
from itsdangerous import TimedJSONWebSignatureSerializer
|
||||
import sys
|
||||
from werkzeug.datastructures import FileStorage
|
||||
import sys,base64,traceback
|
||||
sys.path.append("..")
|
||||
from config import admin_passwd
|
||||
from units import token_auth, consul_kv
|
||||
|
@ -17,7 +18,40 @@ parser = reqparse.RequestParser()
|
|||
parser.add_argument('username',type=str)
|
||||
parser.add_argument('password',type=str)
|
||||
parser.add_argument('ldap',type=str)
|
||||
parser.add_argument('file',type=FileStorage, location="files", help="File is wrong.")
|
||||
|
||||
class Logo(Resource):
|
||||
@token_auth.auth.login_required
|
||||
def post(self, logo_opt):
|
||||
if logo_opt == 'biglogo':
|
||||
consul_kv_path = 'ConsulManager/img/biglogo'
|
||||
isbig = True
|
||||
elif logo_opt == 'smallogo':
|
||||
consul_kv_path = 'ConsulManager/img/smallogo'
|
||||
isbig = False
|
||||
img = parser.parse_args().get("file")
|
||||
try:
|
||||
b64img = base64.b64encode(img.read()).decode('utf-8')
|
||||
consul_kv.put_kv(consul_kv_path,b64img)
|
||||
consul_kv.put_kv(f'ConsulManager/img/isbig',isbig)
|
||||
return {"code": 20000, "data": f"导入成功!"}
|
||||
except Exception as e:
|
||||
logger.error(f"【logo】导入失败,{e}\n{traceback.format_exc()}")
|
||||
return {"code": 50000, "data": f"导入失败!"}
|
||||
def get(self, logo_opt):
|
||||
if logo_opt == 'logo':
|
||||
isbig = consul_kv.get_value(f'ConsulManager/img/isbig')
|
||||
if isbig == {}:
|
||||
isbig = True
|
||||
if isbig:
|
||||
consul_kv_path = 'ConsulManager/img/biglogo'
|
||||
else:
|
||||
consul_kv_path = 'ConsulManager/img/smallogo'
|
||||
b64logo = consul_kv.get_value(consul_kv_path)
|
||||
if b64logo:
|
||||
return {"code": 20000, "isbig": isbig, "data": 'data:image/png;base64,' + b64logo}
|
||||
else:
|
||||
return {"code": 20000, "isbig": isbig, "data": 'default'}
|
||||
class User(Resource):
|
||||
@token_auth.auth.login_required
|
||||
def get(self, user_opt):
|
||||
|
@ -58,3 +92,5 @@ class User(Resource):
|
|||
return {"code": 20000,"data": "success"}
|
||||
|
||||
api.add_resource(User, '/api/user/<user_opt>')
|
||||
api.add_resource(Logo,'/api/login/<logo_opt>')
|
||||
|
||||
|
|
|
@ -35,7 +35,7 @@ acl = {
|
|||
}
|
||||
}
|
||||
EOF
|
||||
|
||||
chmod 777 -R $tsspath/consul/config
|
||||
cat <<EOF > $tsspath/docker-compose.yaml
|
||||
version: '3.6'
|
||||
services:
|
||||
|
|
|
@ -33,7 +33,7 @@ acl = {
|
|||
}
|
||||
}
|
||||
EOF
|
||||
|
||||
chmod 777 -R /opt/consul/config
|
||||
cat <<EOF > /opt/consul/docker-compose.yaml
|
||||
version: '3.6'
|
||||
services:
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
import request from '@/utils/request-ops'
|
||||
|
||||
export function logo() {
|
||||
return request({
|
||||
url: '/api/login/logo',
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
|
|
@ -279,6 +279,12 @@ export const constantRoutes = [
|
|||
name: '系统设置',
|
||||
meta: { title: '系统设置', icon: 'el-icon-setting' },
|
||||
children: [
|
||||
{
|
||||
path: 'logo',
|
||||
name: '修改Logo',
|
||||
component: () => import('@/views/ldap/logo'),
|
||||
meta: { title: '修改Logo', icon: 'el-icon-lock' }
|
||||
},
|
||||
{
|
||||
path: 'ldap',
|
||||
name: '统一认证',
|
||||
|
|
|
@ -0,0 +1,80 @@
|
|||
<template>
|
||||
<div>
|
||||
<el-upload
|
||||
class="avatar-uploader"
|
||||
action="/api/login/biglogo"
|
||||
:headers="myHeaders"
|
||||
:show-file-list="false"
|
||||
:on-success="handleAvatarSuccess"
|
||||
:before-upload="beforeAvatarUpload"
|
||||
>
|
||||
<img v-if="imageUrl" :src="imageUrl" class="avatar">
|
||||
<i v-else class="el-icon-plus avatar-uploader-icon" />
|
||||
</el-upload>
|
||||
<el-upload
|
||||
class="avatar-uploader"
|
||||
action="/api/login/smallogo"
|
||||
:headers="myHeaders"
|
||||
:show-file-list="false"
|
||||
:on-success="handleAvatarSuccess"
|
||||
:before-upload="beforeAvatarUpload"
|
||||
>
|
||||
<img v-if="imageUrl" :src="imageUrl" class="avatar">
|
||||
<i v-else class="el-icon-plus avatar-uploader-icon" />
|
||||
</el-upload>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
myHeaders: { Authorization: this.$store.getters.token },
|
||||
imageUrl: ''
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
handleAvatarSuccess(res, file) {
|
||||
this.imageUrl = URL.createObjectURL(file.raw)
|
||||
this.$message.success('LOGO设置成功!')
|
||||
},
|
||||
beforeAvatarUpload(file) {
|
||||
const isJPG = file.type === 'image/jpeg' || file.type === 'image/png'
|
||||
const isLt2M = file.size / 1024 / 1024 < 2
|
||||
if (!isJPG) {
|
||||
this.$message.error('上传LOGO图片只能是 JPG/PNG 格式!')
|
||||
}
|
||||
if (!isLt2M) {
|
||||
this.$message.error('上传LOGO图片大小不能超过 2MB!')
|
||||
}
|
||||
return isJPG && isLt2M
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style>
|
||||
.avatar-uploader .el-upload {
|
||||
border: 1px dashed #d9d9d9;
|
||||
border-radius: 6px;
|
||||
cursor: pointer;
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
}
|
||||
.avatar-uploader .el-upload:hover {
|
||||
border-color: #409EFF;
|
||||
}
|
||||
.avatar-uploader-icon {
|
||||
font-size: 28px;
|
||||
color: #8c939d;
|
||||
width: 178px;
|
||||
height: 178px;
|
||||
line-height: 178px;
|
||||
text-align: center;
|
||||
}
|
||||
.avatar {
|
||||
width: 178px;
|
||||
height: 178px;
|
||||
display: block;
|
||||
}
|
||||
</style>
|
|
@ -1,12 +1,15 @@
|
|||
<template>
|
||||
<div class="login-container">
|
||||
<el-form ref="loginForm" :model="loginForm" :rules="loginRules" class="login-form" auto-complete="on" label-position="left">
|
||||
|
||||
<div class="title-container" style="text-align:center">
|
||||
<img src="../../assets/login_images/SLH.png" width="90" height="90"><br><br>
|
||||
<h3 style="font-size:35px" class="title">Consul Manager</h3><br>
|
||||
</div>
|
||||
|
||||
<div v-if="isbig" class="title-container" style="text-align:center">
|
||||
<br><br>
|
||||
<img :src="loginlogo" width="720" height="330">
|
||||
<br><br>
|
||||
</div>
|
||||
<div v-else class="title-container" style="text-align:center; padding: 160px 70px 0;">
|
||||
<img :src="loginlogo" width="100" height="100"><br><br><br><br>
|
||||
<h3 style="font-size:45px" class="title">Consul Manager</h3><br>
|
||||
</div>
|
||||
<el-form ref="loginForm" :model="loginForm" :rules="loginRules" class="login-form" auto-complete="on" label-position="left" style="padding: 10px 70px 0;">
|
||||
<el-form-item prop="username">
|
||||
<span class="svg-container">
|
||||
<svg-icon icon-class="user" />
|
||||
|
@ -47,11 +50,16 @@
|
|||
<div align="center" class="title-container">
|
||||
<span style="font-size:12px" class="title">{{ VER }}</span>
|
||||
</div>
|
||||
<div class="footer">
|
||||
<p style="width:100%"><center><el-link href="https://StarsL.cn" :underline="false" target="_blank">Powered by StarsL.cn</el-link></center></p>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
|
||||
import { logo } from '@/api/login'
|
||||
import smallogo from '@/assets/login_images/SLH.png'
|
||||
import biglogo from '@/assets/login_images/tensuns.png'
|
||||
export default {
|
||||
name: 'Login',
|
||||
data() {
|
||||
|
@ -81,6 +89,8 @@ export default {
|
|||
},
|
||||
loading: false,
|
||||
passwordType: 'password',
|
||||
loginlogo: '',
|
||||
isbig: true,
|
||||
redirect: undefined
|
||||
}
|
||||
},
|
||||
|
@ -92,7 +102,26 @@ export default {
|
|||
immediate: true
|
||||
}
|
||||
},
|
||||
created() {
|
||||
this.getlogo()
|
||||
},
|
||||
methods: {
|
||||
getlogo() {
|
||||
logo().then(response => {
|
||||
if (response.data === 'default') {
|
||||
if (response.isbig === true) {
|
||||
this.loginlogo = biglogo
|
||||
this.isbig = true
|
||||
} else {
|
||||
this.loginlogo = smallogo
|
||||
this.isbig = false
|
||||
}
|
||||
} else {
|
||||
this.loginlogo = response.data
|
||||
this.isbig = response.isbig
|
||||
}
|
||||
})
|
||||
},
|
||||
showPwd() {
|
||||
if (this.passwordType === 'password') {
|
||||
this.passwordType = ''
|
||||
|
@ -232,6 +261,14 @@ $light_gray:#eee;
|
|||
}
|
||||
}
|
||||
|
||||
.footer {
|
||||
p {
|
||||
position:absolute;
|
||||
bottom:0px;
|
||||
padding:0px;
|
||||
margin:0px;
|
||||
}
|
||||
}
|
||||
.show-pwd {
|
||||
position: absolute;
|
||||
right: 10px;
|
||||
|
|
|
@ -0,0 +1,268 @@
|
|||
<template>
|
||||
<div class="login-container">
|
||||
<el-form ref="loginForm" :model="loginForm" :rules="loginRules" class="login-form" auto-complete="on" label-position="left">
|
||||
<div class="title-container" style="text-align:center">
|
||||
<img :src="loginlogo" width="100" height="100"><br><br><br>
|
||||
<h3 style="font-size:45px" class="title">后羿运维平台</h3><br><br>
|
||||
</div>
|
||||
<el-form-item prop="username">
|
||||
<span class="svg-container">
|
||||
<svg-icon icon-class="user" />
|
||||
</span>
|
||||
<el-input
|
||||
ref="username"
|
||||
v-model="loginForm.username"
|
||||
placeholder="Username"
|
||||
name="username"
|
||||
type="text"
|
||||
tabindex="1"
|
||||
auto-complete="on"
|
||||
/>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item prop="password">
|
||||
<span class="svg-container">
|
||||
<svg-icon icon-class="password" />
|
||||
</span>
|
||||
<el-input
|
||||
:key="passwordType"
|
||||
ref="password"
|
||||
v-model="loginForm.password"
|
||||
:type="passwordType"
|
||||
placeholder="Password"
|
||||
name="password"
|
||||
tabindex="2"
|
||||
auto-complete="on"
|
||||
@keyup.enter.native="handleLogin"
|
||||
/>
|
||||
<span class="show-pwd" @click="showPwd">
|
||||
<svg-icon :icon-class="passwordType === 'password' ? 'eye' : 'eye-open'" />
|
||||
</span>
|
||||
</el-form-item>
|
||||
<!-- <el-checkbox v-model="loginForm.Ldapchecked" label="启动ldap验证" border class="ldap" /> -->
|
||||
<el-button :loading="loading" type="primary" style="width:100%;margin-bottom:30px;" @click.native.prevent="handleLogin">登 录</el-button>
|
||||
</el-form>
|
||||
<div align="center" class="title-container">
|
||||
<span style="font-size:12px" class="title">{{ VER }}</span>
|
||||
</div>
|
||||
<div class="footer">
|
||||
<p style="width:100%"><center><el-link href="https://StarsL.cn" :underline="false" target="_blank">Powered by StarsL.cn</el-link></center></p>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { logo } from '@/api/login'
|
||||
import logosl from '@/assets/login_images/SLH.png'
|
||||
export default {
|
||||
name: 'Login',
|
||||
data() {
|
||||
const validateUsername = (rule, value, callback) => {
|
||||
if (!value) {
|
||||
callback(new Error('Please enter the correct user name'))
|
||||
} else {
|
||||
callback()
|
||||
}
|
||||
}
|
||||
const validatePassword = (rule, value, callback) => {
|
||||
if (value.length < 6) {
|
||||
callback(new Error('The password can not be less than 6 digits'))
|
||||
} else {
|
||||
callback()
|
||||
}
|
||||
}
|
||||
return {
|
||||
loginForm: {
|
||||
username: 'admin',
|
||||
password: '',
|
||||
Ldapchecked: false // ldap验证开关
|
||||
},
|
||||
loginRules: {
|
||||
username: [{ required: true, trigger: 'blur', validator: validateUsername }],
|
||||
password: [{ required: true, trigger: 'blur', validator: validatePassword }]
|
||||
},
|
||||
loading: false,
|
||||
passwordType: 'password',
|
||||
loginlogo: '',
|
||||
redirect: undefined
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
$route: {
|
||||
handler: function(route) {
|
||||
this.redirect = route.query && route.query.redirect
|
||||
},
|
||||
immediate: true
|
||||
}
|
||||
},
|
||||
created() {
|
||||
this.getlogo()
|
||||
},
|
||||
methods: {
|
||||
getlogo() {
|
||||
logo().then(response => {
|
||||
if (response.data === 'default') {
|
||||
this.loginlogo = logosl
|
||||
} else {
|
||||
this.loginlogo = response.data
|
||||
}
|
||||
})
|
||||
},
|
||||
showPwd() {
|
||||
if (this.passwordType === 'password') {
|
||||
this.passwordType = ''
|
||||
} else {
|
||||
this.passwordType = 'password'
|
||||
}
|
||||
this.$nextTick(() => {
|
||||
this.$refs.password.focus()
|
||||
})
|
||||
},
|
||||
handleLogin() {
|
||||
this.$refs.loginForm.validate(valid => {
|
||||
if (valid) {
|
||||
this.loading = true
|
||||
this.$store.dispatch('user/login', this.loginForm).then(() => {
|
||||
this.$router.push({ path: this.redirect || '/' })
|
||||
this.loading = false
|
||||
}).catch(() => {
|
||||
this.loading = false
|
||||
})
|
||||
} else {
|
||||
console.log('error submit!!')
|
||||
return false
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
/* 修复input 背景不协调 和光标变色 */
|
||||
/* Detail see https://github.com/PanJiaChen/vue-element-admin/pull/927 */
|
||||
|
||||
$bg:#283443;
|
||||
$light_gray:#fff;
|
||||
$cursor: #fff;
|
||||
|
||||
@supports (-webkit-mask: none) and (not (cater-color: $cursor)) {
|
||||
.login-container .el-input input {
|
||||
color: $cursor;
|
||||
}
|
||||
}
|
||||
|
||||
/* reset element-ui css */
|
||||
.login-container {
|
||||
.el-input {
|
||||
display: inline-block;
|
||||
height: 47px;
|
||||
width: 85%;
|
||||
|
||||
input {
|
||||
background: transparent;
|
||||
border: 0px;
|
||||
-webkit-appearance: none;
|
||||
border-radius: 0px;
|
||||
padding: 12px 5px 12px 15px;
|
||||
color: $light_gray;
|
||||
height: 47px;
|
||||
caret-color: $cursor;
|
||||
|
||||
&:-webkit-autofill {
|
||||
box-shadow: 0 0 0px 1000px $bg inset !important;
|
||||
-webkit-text-fill-color: $cursor !important;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.el-form-item {
|
||||
border: 2px solid rgba(255, 255, 255, 0.3);
|
||||
background: rgba(0, 0, 0, 0.1);
|
||||
border-radius: 5px;
|
||||
color: #454545;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
$bg:#2d3a4b;
|
||||
$dark_gray:#889aa4;
|
||||
$light_gray:#eee;
|
||||
|
||||
.ldap{
|
||||
margin-bottom: 9px;
|
||||
}
|
||||
|
||||
.login-container {
|
||||
// min-height: 100%;
|
||||
// width: 100%;
|
||||
// background-color: $bg;
|
||||
// overflow: hidden;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
background-image: url("../../assets/login_images/bg.png");
|
||||
background-size: cover;
|
||||
background-position: center;
|
||||
position: relative;
|
||||
|
||||
.login-form {
|
||||
position: relative;
|
||||
width: 460px;
|
||||
max-width: 100%;
|
||||
padding: 160px 35px 0;
|
||||
margin: 0 auto;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.tips {
|
||||
font-size: 14px;
|
||||
color: #fff;
|
||||
margin-bottom: 10px;
|
||||
|
||||
span {
|
||||
&:first-of-type {
|
||||
margin-right: 16px;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.svg-container {
|
||||
padding: 6px 5px 6px 15px;
|
||||
color: $dark_gray;
|
||||
vertical-align: middle;
|
||||
width: 30px;
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
.title-container {
|
||||
position: relative;
|
||||
|
||||
.title {
|
||||
font-size: 26px;
|
||||
color: $light_gray;
|
||||
margin: 0px auto 20px auto;
|
||||
text-align: center;
|
||||
font-weight: bold;
|
||||
}
|
||||
}
|
||||
|
||||
.footer {
|
||||
p {
|
||||
position:absolute;
|
||||
bottom:0px;
|
||||
padding:0px;
|
||||
margin:0px;
|
||||
}
|
||||
}
|
||||
.show-pwd {
|
||||
position: absolute;
|
||||
right: 10px;
|
||||
top: 7px;
|
||||
font-size: 16px;
|
||||
color: $dark_gray;
|
||||
cursor: pointer;
|
||||
user-select: none;
|
||||
}
|
||||
}
|
||||
</style>
|
Loading…
Reference in New Issue