This commit is contained in:
2025-10-06 17:23:52 +08:00
parent b3f65c61ec
commit e9101b5c07
44 changed files with 7067 additions and 0 deletions

388
src/mac/index.vue Normal file
View File

@@ -0,0 +1,388 @@
<template>
<div class="mac_bg"></div>
<div class="desktop">
<div class="top">
<el-dropdown trigger="click">
<div class="logo"><i class="iconfont iconicon_setting"></i></div>
<template #dropdown>
<el-dropdown-menu>
<el-dropdown-item>
<div>{{ userInfo.userName }}</div>
</el-dropdown-item>
<el-dropdown-item>
<div @click="switchTheme">退出主题</div>
</el-dropdown-item>
<el-dropdown-item @click="logout">{{ $t('navbar.logOut') }}</el-dropdown-item>
</el-dropdown-menu>
</template>
</el-dropdown>
<div class="space"></div>
<div class="status">
<div class="audio">
<i class="iconfont icon-changyongtubiao-xianxingdaochu-zhuanqu-39"></i>
</div>
<div class="datetime">{{ timeString }}</div>
<div class="notification">
<i class="iconfont icon-changyongtubiao-xianxingdaochu-zhuanqu-25"></i>
</div>
</div>
</div>
<div class="body">
<div class="desktop-app">
<template v-for="item in deskTopAppList" :key="item.key">
<div class="app-item" @click="openApp(item)" v-if="!item.hideInDesktop">
<div class="icon" :style="{ backgroundColor: item.iconBgColor, color: item.iconColor }">
<i class="iconfont" :class="item[iconKey]"></i>
</div>
<div class="title">{{ item[labelKey] }}</div>
</div>
</template>
</div>
</div>
<div class="footer">
<div class="space"></div>
<div class="dock">
<template v-for="item in openAppList" :key="item.key">
<div class="item" @click="openApp(item)">
<i
:style="{ backgroundColor: item.iconBgColor, color: item.iconColor }"
class="iconfont"
:class="item[iconKey]"
></i>
<small style="margin-top: 5px; font-size: 10px">{{ item[labelKey] }}</small>
</div>
</template>
</div>
<div class="space"></div>
</div>
</div>
</template>
<script>
import { mapGetters } from 'vuex';
import $Mode from './mode/index';
import index from '@/mixins/index';
import topLock from '@/page/index/top/top-lock.vue';
export default {
mixins: [index],
components: {
topLock,
},
data() {
return {
app: false,
timeString: '',
};
},
computed: {
...mapGetters(['menu', 'tagList', 'tagWel', 'tag', 'userInfo', 'isMacOs']),
labelKey() {
return this.website.menu.label;
},
pathKey() {
return this.website.menu.path;
},
hrefKey() {
return this.website.menu.href;
},
childrenKey() {
return this.website.menu.children;
},
queryKey() {
return this.website.menu.query;
},
iconKey() {
return this.website.menu.icon;
},
menuList() {
let result = [];
const findMenu = list => {
list.forEach(ele => {
if (ele[this.childrenKey] && ele[this.childrenKey].length !== 0) {
findMenu(ele[this.childrenKey]);
} else {
result.push(ele);
}
});
};
findMenu(this.menu);
return result;
},
deskTopAppList() {
return this.menuList;
},
openAppList() {
return [];
},
},
created() {
this.startTimer();
this.$store.dispatch('GetMenu');
},
methods: {
switchTheme() {
this.$store.commit('SET_THEME_NAME', '');
this.$router.push(this.tagWel);
setTimeout(() => location.reload());
},
logout() {
this.$store.commit('SET_THEME_NAME', '');
this.$store.dispatch('LogOut').then(() => {
this.$router.push({ path: '/login' });
setTimeout(() => location.reload());
});
},
startTimer() {
setInterval(() => {
this.timeString = this.$dayjs().format('YYYY年MM月DD日 HH:mm');
}, 1000);
},
openApp(item) {
$Mode({
title: item[this.labelKey],
path: item[this.hrefKey] ? item[this.hrefKey] : item[this.pathKey],
});
},
},
};
</script>
<style>
.top .el-dropdown {
color: white !important;
height: 100% !important;
}
</style>
<style scoped>
.desktop {
display: flex;
flex-direction: column;
position: absolute;
left: 0;
right: 0;
top: 0;
bottom: 0;
color: white;
overflow: hidden;
text-shadow: 0px 2px 2px rgba(0, 0, 0, 0.1);
}
.top {
height: 28px;
background-color: rgba(0, 0, 0, 0.3);
backdrop-filter: blur(20px);
display: flex;
flex-direction: row;
font-size: 14px;
align-items: center;
justify-content: center;
padding: 0px 5px;
z-index: 100;
}
.space {
flex-grow: 1;
}
.logo {
height: 100%;
align-items: center;
justify-content: center;
padding: 0px 15px;
cursor: pointer;
position: relative;
display: flex;
align-items: center;
justify-content: center;
}
.logo .el-select {
position: absolute;
opacity: 0;
}
.logo:hover {
background-color: rgba(255, 255, 255, 0.1);
}
.logo .iconfont {
font-size: 16px;
margin-top: -3px;
}
.menu .item:hover {
background-color: rgba(255, 255, 255, 0.1);
}
.status {
display: flex;
flex-direction: row;
justify-content: center;
align-items: center;
height: 100%;
}
.audio .iconfont,
.notification .iconfont {
font-size: 20px;
}
.datetime,
.audio,
.notification {
cursor: pointer;
padding: 0px 10px;
height: 100%;
display: flex;
justify-content: center;
align-items: center;
text-align: center;
}
.datetime:hover,
.audio:hover,
.notification:hover {
background-color: rgba(255, 255, 255, 0.1);
}
.body {
flex-grow: 1;
display: flex;
flex-direction: row;
justify-content: center;
align-items: center;
position: relative;
}
.footer {
position: fixed;
left: 5px;
right: 5px;
bottom: 5px;
justify-content: center;
align-items: center;
display: flex;
flex-direction: row;
z-index: 100;
}
.footer .dock {
background-color: rgba(255, 255, 255, 0.1);
border: 1px solid rgba(255, 255, 255, 0.1);
box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.2);
backdrop-filter: blur(20px);
border-radius: 10px;
flex-direction: row;
display: flex;
padding: 2px;
}
.dock .item {
padding: 3px;
display: flex;
justify-content: center;
align-items: center;
flex-direction: column;
}
.dock .dot {
width: 3px;
height: 3px;
background: rgba(0, 0, 0, 0.8);
position: absolute;
bottom: 0px;
border-radius: 5px;
display: inline-block;
font-size: 0;
}
.dock .item .iconfont {
cursor: pointer;
border-radius: 20px;
padding: 2px;
display: inline-block;
background-color: rgba(255, 255, 255, 0.1);
border-radius: 10px;
height: 30px;
width: 30px;
text-align: center;
font-size: 24px;
display: flex;
align-items: center;
justify-content: center;
transition: transform 0.3s, margin 0.3s;
}
.dock .item:hover .iconfont {
transform: scale(2) translateY(-10px);
margin: 0px 15px;
box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.3);
}
.dock .nearby .iconfont {
transform: scale(1.6) translateY(-8px);
margin: 0px 12px;
box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.3);
}
.dock .nearby1 .iconfont {
transform: scale(1.2) translateY(-6px);
margin: 0px 9px;
box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.3);
}
.dock .nearby2 .iconfont {
transform: scale(1.1) translateY(-5px);
margin: 0px 7px;
box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.3);
}
.desktop-app {
position: absolute;
right: 0;
top: 0;
bottom: 0;
display: flex;
flex-direction: column;
justify-content: flex-start;
align-items: flex-end;
padding: 20px;
flex-wrap: wrap-reverse;
}
.app-item {
margin: 5px 10px;
padding: 5px;
flex-direction: column;
text-align: center;
text-shadow: 0px 0px 2px rgb(0 0 0 / 50%);
cursor: pointer;
border-radius: 10px;
border: 2px solid transparent;
}
.app-item .icon {
border-radius: 10px;
width: 50px;
height: 50px;
display: flex;
justify-content: center;
align-items: center;
}
.app-item .iconfont {
font-size: 36px;
}
.app-item .title {
font-size: 12px;
width: 50px;
margin-top: 5px;
white-space: nowrap;
text-overflow: ellipsis;
overflow: hidden;
}
.app-item:hover {
border: 2px solid rgba(255, 255, 255, 0.5);
}
</style>

62
src/mac/lock.vue Normal file
View File

@@ -0,0 +1,62 @@
<template>
<div class="mac_bg"></div>
<div class="login animate__animated" :class="{ animate__bounceOut: pass }">
<div class="head">
<img
src="https://bladex.cn/images/logo-small.png"
alt=""
/>
</div>
<div class="message">{{ userInfo.username }}</div>
<div class="form">
<div class="item" style="width: 320px" :class="passwdError ? 'error' : ''">
<input class="password" placeholder="password here..." v-model="passwd" type="password" />
<i class="iconfont el-icon-unlock" @click="handleLogin"></i>
<i class="iconfont icon-tuichu" @click="handleLogout"></i>
</div>
</div>
</div>
</template>
<script>
import { mapGetters } from 'vuex';
export default {
data() {
return {
passwdError: false,
passwd: '',
pass: false,
};
},
computed: {
...mapGetters(['userInfo', 'tag', 'lockPasswd']),
},
methods: {
handleLogout() {
this.$store.dispatch('LogOut').then(() => {
this.$router.push({ path: '/login' });
});
},
handleLogin() {
if (this.passwd !== this.lockPasswd) {
this.passwd = '';
this.passwdError = true;
setTimeout(() => {
this.passwdError = false;
}, 1000);
return;
}
this.pass = true;
setTimeout(() => {
this.$store.commit('CLEAR_LOCK');
this.$router.push({
path: this.tag.value,
});
}, 1000);
},
},
};
</script>
<style lang="scss" scoped>
@use './login.scss';
</style>

134
src/mac/login.scss Normal file
View File

@@ -0,0 +1,134 @@
@keyframes loginErrorAnimation {
0% {
margin-left: -30px;
}
50% {
margin-left: 30px;
}
100% {
margin-left: 0;
}
}
.login {
position: fixed;
left: 0;
right: 0;
top: 0;
bottom: 0;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
color: white;
margin-top: -100px;
z-index: 99999;
backdrop-filter: blur(20px);
}
.head {
padding: 3px;
background-size: 40% auto;
background-position: center center;
height: 150px;
width: 150px;
border-radius: 100%;
box-sizing: border-box;
box-shadow: 0px 0px 5px 5px rgba(0, 0, 0, 0.1);
margin-top: -50px;
overflow: hidden;
}
.head img {
border-radius: 100%;
width: 100%;
height: 100%;
}
.message {
margin-top: 20px;
font-size: 20px;
text-shadow: 0px 0px 2px 2px rgba(0, 0, 0, 0.3);
color: #eee;
margin-bottom: 50px;
}
.password {
transition: width 0.3s;
}
.password-in {
width: 155px;
}
.login-button {
position: absolute;
top: 5px;
right: -50px;
transition: right 0.3s;
}
.click-enable {
right: 0;
}
.error {
animation: loginErrorAnimation 0.2s ease 3;
}
::-webkit-input-placeholder {
color: #fff;
}
::-moz-placeholder {
color: #fff;
}
:-ms-input-placeholder {
color: #fff;
}
.form {
display: flex;
flex-direction: column;
align-items: center;
}
.item {
position: relative;
width: 280px;
display: flex;
align-items: center;
}
.item input {
color: white;
outline: none;
border: none;
margin: 5px 0;
font-size: 16px;
background-color: rgba(255, 255, 255, 0.3);
padding: 8px 24px;
border-radius: 20px;
box-shadow: 0px 0px 5px rgba(0, 0, 0, 0.1);
flex: 1;
}
.item .iconfont {
margin-left: 10px;
vertical-align: middle;
display: inline-block;
background-color: rgba(255, 255, 255, 0.3);
font-size: 18px;
border-radius: 100%;
width: 36px;
height: 36px;
text-align: center;
line-height: 36px;
cursor: pointer;
box-shadow: 0px 0px 5px rgba(0, 0, 0, 0.1);
}
.item .iconfont:hover {
background-color: rgba(255, 255, 255, 0.5);
}

72
src/mac/login.vue Normal file
View File

@@ -0,0 +1,72 @@
<template>
<div class="mac_bg"></div>
<div class="login animate__animated" :class="{ animate__bounceOut: pass }">
<div class="head">
<img
src="https://memoryblock.com.au/cdn/shop/files/logo_c191c786-0ec8-42b5-909f-0a15df4a8325.png"
alt=""
/>
</div>
<div class="message">Login Please</div>
<div class="form">
<div class="item" :class="isUserNameError ? 'error' : ''">
<input class="account" placeholder="account here..." v-model="form.username" type="email" />
</div>
<div class="item" :class="isUserPasswordError ? 'error' : ''">
<input
class="password"
placeholder="password here..."
v-model="form.password"
type="password"
/>
<i class="iconfont icon-send" @click="handleLogin"></i>
</div>
</div>
</div>
</template>
<script>
import { mapGetters } from 'vuex';
export default {
data() {
return {
pass: false,
isUserNameError: false,
isUserPasswordError: false,
form: {
username: '',
password: '',
},
};
},
computed: {
...mapGetters(['tagWel']),
},
methods: {
handleLogin() {
if (this.form.username === '') {
this.isUserNameError = true;
setTimeout(() => {
this.isUserNameError = false;
}, 1000);
return;
} else if (this.form.password === '') {
this.isUserPasswordError = true;
setTimeout(() => {
this.isUserPasswordError = false;
}, 1000);
return;
}
this.$store.dispatch('LoginByUsername', this.loginForm).then(() => {
this.pass = true;
setTimeout(() => {
this.$router.push(this.tagWel);
}, 1000);
});
},
},
};
</script>
<style lang="scss" scoped>
@use './login.scss';
</style>

18
src/mac/mode/index.js Normal file
View File

@@ -0,0 +1,18 @@
import MessageConstructor from './index.vue';
import { createVNode, render } from 'vue';
export default (function () {
return (opts = {}) => {
let options = {
app: opts,
};
const parent = document.createElement('div');
let instance = createVNode(MessageConstructor, options);
instance.props.onDestroy = () => {
render(null, parent);
};
render(instance, parent);
document.body.appendChild(parent.firstElementChild);
return instance;
};
})();

483
src/mac/mode/index.vue Normal file
View File

@@ -0,0 +1,483 @@
<template>
<div
class="moveBg"
v-show="isShow"
@click="handleFocus"
@mousemove="mouseMove"
@mouseup="mouseUp"
@mouseleave.stop="mouseLeave"
:style="{ pointerEvents: isBoxResizing || isBoxMoving ? 'auto' : 'none' }"
>
<div
class="box"
:style="{
left: nowRect.left + 'px',
top: nowRect.top + 'px',
bottom: nowRect.bottom + 'px',
right: nowRect.right + 'px',
}"
:class="getExtBoxClasses()"
>
<div class="box-top">
<div class="box-top-left" @mousedown="resizeMouseDown"></div>
<div class="box-top-center" @mousedown="resizeMouseDown"></div>
<div class="box-top-right" @mousedown="resizeMouseDown"></div>
</div>
<div class="box-center">
<div class="box-center-left" @mousedown="resizeMouseDown"></div>
<div class="box-center-center loader">
<div
class="app-bar"
:style="{ backgroundColor: app.tabbarBgColor }"
@mousedown.stop="positionMouseDown"
v-on:dblclick="appBarDoubleClicked"
>
<div class="controll">
<div class="close" @click.stop="close"></div>
<div
class="full"
:class="app.disableResize ? 'full-disabled' : ''"
@click.stop="switchFullScreen"
></div>
</div>
<div class="title" :style="{ color: app.tabbarTextColor }">{{ app.title }}</div>
</div>
<iframe :src="location + app.path" frameborder="0" class="iframe"></iframe>
</div>
<div class="box-center-right" @mousedown="resizeMouseDown"></div>
</div>
<div class="box-bottom">
<div class="box-bottom-left" @mousedown="resizeMouseDown"></div>
<div class="box-bottom-center" @mousedown="resizeMouseDown"></div>
<div class="box-bottom-right" @mousedown="resizeMouseDown"></div>
</div>
</div>
</div>
</template>
<script>
import { isURL } from 'utils/validate';
import { defineAsyncComponent } from 'vue';
export default {
props: {
app: Object,
onDestroy: Function,
},
data() {
return {
isShow: true,
defaultIndex: 10,
activeIndex: 20,
isBoxMoving: false,
startPosition: { x: 0, y: 0 },
nowRect: {
left: 100,
right: 100,
top: 100,
bottom: 100,
},
startRect: {
left: 0,
right: 0,
top: 0,
bottom: 0,
},
isBoxResizing: false,
moveDirection: false,
isMaxShowing: false,
isFullScreen: false,
};
},
computed: {
location() {
return isURL(this.app.path) ? '' : window.location.origin;
},
},
created() {
if (this.app.width) {
this.nowRect.left = this.nowRect.right = (document.body.clientWidth - this.app.width) / 2;
}
if (this.app.height) {
this.nowRect.bottom = (document.body.clientHeight - this.app.height) / 2 + 50;
this.nowRect.top = (document.body.clientHeight - this.app.height) / 2 - 50;
}
},
methods: {
handleFocus() {
let list = document.getElementsByClassName('moveBg');
if (list.length == 1) return;
let max = 0;
for (let i = 0; i < list.length; i++) {
let ele = list[i];
let box = ele.getElementsByClassName('box')[0].style;
let zIndex = Number(box.zIndex);
if (max < zIndex) {
max = zIndex;
}
}
max = max + 1;
this.$el.getElementsByClassName('box')[0].style.zIndex = max;
},
close() {
this.isShow = false;
this.onDestroy();
},
switchFullScreen() {
if (this.app.disableResize) {
return;
}
this.isFullScreen = !this.isFullScreen;
if (this.isFullScreen) {
this.isMaxShowing = true;
} else {
this.isMaxShowing = false;
}
},
getExtBoxClasses() {
let str = '';
if (!this.isBoxResizing && !this.isBoxMoving) {
str += 'box-animation ';
}
if (this.isMaxShowing) {
str += 'isMaxShowing ';
}
if (this.isFullScreen) {
str += 'isFullScreen ';
}
if (this.app.disableResize) {
str += 'resize-disabled ';
}
if (this.app.isTop) {
str += 'isTop ';
}
return str;
},
appBarDoubleClicked() {
if (this.app.disableResize) {
return;
}
this.isMaxShowing = !this.isMaxShowing;
if (!this.isMaxShowing) {
this.isFullScreen = false;
}
},
positionMouseDown(e) {
if (this.isFullScreen || this.isMaxShowing) {
return;
}
this.startRect = {
left: this.nowRect.left,
right: this.nowRect.right,
top: this.nowRect.top,
bottom: this.nowRect.bottom,
};
this.startPosition.x = e.clientX;
this.startPosition.y = e.clientY;
this.isBoxMoving = true;
},
mouseUp() {
this.isBoxMoving = false;
this.isBoxResizing = false;
this.moveDirection = false;
},
mouseLeave() {
this.isBoxMoving = false;
this.isBoxResizing = false;
this.moveDirection = false;
},
mouseMove(e) {
if (this.isBoxResizing) {
this.isFullScreen = false;
this.isMaxShowing = false;
switch (this.moveDirection) {
case 'box-top-left':
this.nowRect.top = this.startRect.top + (e.clientY - this.startPosition.y);
this.nowRect.left = this.startRect.left + (e.clientX - this.startPosition.x);
break;
case 'box-top-center':
this.nowRect.top = this.startRect.top + (e.clientY - this.startPosition.y);
break;
case 'box-top-right':
this.nowRect.top = this.startRect.top + (e.clientY - this.startPosition.y);
this.nowRect.right = this.startRect.right - (e.clientX - this.startPosition.x);
break;
case 'box-center-left':
this.nowRect.left = this.startRect.left + (e.clientX - this.startPosition.x);
break;
case 'box-bottom-left':
this.nowRect.left = this.startRect.left + (e.clientX - this.startPosition.x);
this.nowRect.bottom = this.startRect.bottom - (e.clientY - this.startPosition.y);
break;
case 'box-bottom-center':
this.nowRect.bottom = this.startRect.bottom - (e.clientY - this.startPosition.y);
break;
case 'box-center-right':
this.nowRect.right = this.startRect.right - (e.clientX - this.startPosition.x);
break;
case 'box-bottom-right':
this.nowRect.right = this.startRect.right - (e.clientX - this.startPosition.x);
this.nowRect.bottom = this.startRect.bottom - (e.clientY - this.startPosition.y);
break;
default:
}
return;
}
if (this.isBoxMoving) {
this.isFullScreen = false;
this.isMaxShowing = false;
this.nowRect.left = this.startRect.left + (e.clientX - this.startPosition.x);
this.nowRect.right = this.startRect.right - (e.clientX - this.startPosition.x);
this.nowRect.top = this.startRect.top + (e.clientY - this.startPosition.y);
this.nowRect.bottom = this.startRect.bottom - (e.clientY - this.startPosition.y);
return;
}
},
resizeMouseDown(e) {
if (this.app.disableResize) {
return;
}
if (this.isFullScreen || this.isMaxShowing) {
return;
}
this.startRect = {
left: this.nowRect.left,
top: this.nowRect.top,
right: this.nowRect.right,
bottom: this.nowRect.bottom,
};
this.startPosition.x = e.clientX;
this.startPosition.y = e.clientY;
this.isBoxResizing = true;
this.moveDirection = e.target.className;
},
},
};
</script>
<style scoped>
.iframe {
width: 100%;
height: calc(100% - 50px);
margin-top: 5px;
border-right: 5px;
}
.moveBg {
position: absolute;
left: 0;
right: 0;
top: 0;
bottom: 0;
}
.box {
--resize: 5px;
--resize-bg: transparent;
--resize-main: transparent;
--resize-bg-main: transparent;
}
.box {
position: absolute;
pointer-events: auto;
display: flex;
flex-direction: column;
}
.box-top {
display: flex;
flex-direction: row;
}
.box-top-left {
width: var(--resize);
height: var(--resize);
background: var(--resize-bg);
cursor: nw-resize;
}
.box-top-center {
height: var(--resize);
background: var(--resize-bg-main);
cursor: n-resize;
flex-grow: 1;
}
.box-top-right {
width: var(--resize);
height: var(--resize);
background: var(--resize-bg);
cursor: ne-resize;
}
.box-center {
display: flex;
flex-direction: row;
flex-grow: 1;
}
.box-center-left {
width: var(--resize);
height: 100%;
background: var(--resize-bg-main);
cursor: w-resize;
}
.box-center-center {
height: 100%;
flex-grow: 1;
display: flex;
flex-direction: column;
border-radius: 10px;
box-shadow: 0px 0px 3px #999;
background: rgba(255, 255, 255, 0.8);
backdrop-filter: blur(20px);
overflow: hidden;
}
.isTop .box-center-center {
box-shadow: 0px 0px 20px rgba(0, 0, 0, 0.5);
filter: none;
}
.box-animation {
transition: width 0.1s, height 0.1s, left 0.1s, right 0.1s, top 0.1s, bottom 0.1s;
}
.isMaxShowing {
left: -5px !important;
right: -5px !important;
top: 24px !important;
bottom: 47px !important;
height: calc(100% - 24px);
}
.isFullScreen {
position: fixed !important;
z-index: 999 !important;
bottom: -5px !important;
}
.isMaxShowing .box-center-center,
.isFullScreen .box-center-center {
border-radius: 0px !important;
}
.box-center-right {
width: var(--resize);
height: 100%;
background: var(--resize-bg-main);
cursor: e-resize;
}
.box-bottom {
display: flex;
flex-direction: row;
}
.box-bottom-left {
width: var(--resize);
height: var(--resize);
background: var(--resize-bg);
cursor: sw-resize;
}
.box-bottom-center {
height: var(--resize);
background: var(--resize-bg-main);
cursor: s-resize;
flex-grow: 1;
}
.box-bottom-right {
width: var(--resize);
height: var(--resize);
background: var(--resize-bg);
cursor: se-resize;
}
.loader {
display: flex;
flex-grow: 1;
flex-direction: column;
width: 100%;
}
.app-bar {
height: 40px;
background: rgba(255, 255, 255, 0.5);
backdrop-filter: blur(20px);
display: flex;
flex-direction: row;
justify-content: center;
align-items: center;
white-space: nowrap;
text-overflow: ellipsis;
overflow: hidden;
}
.app-bar .controll {
display: flex;
justify-content: center;
align-items: center;
margin-left: 15px;
}
.app-bar .controll div {
border-radius: 100%;
height: 11px;
width: 11px;
margin-right: 8px;
cursor: pointer;
}
.app-bar .title {
flex-grow: 1;
text-align: center;
margin-right: 80px;
font-weight: 500;
text-shadow: none;
font-size: 13px;
cursor: move;
color: #333;
}
.controll .close {
background: #fc605c;
border: 1px solid #fc635d;
}
.controll .min {
background: #fcbb40;
border: 1px solid #f8b438;
}
.controll .full {
background: #34c648;
border: 1px solid #2bc03f;
}
.full-disabled {
background: #ccc !important;
border: 1px solid #ccc !important;
}
.resize-disabled .box-top-left,
.resize-disabled .box-top-center,
.resize-disabled .box-top-right,
.resize-disabled .box-center-left,
.resize-disabled .box-center-right,
.resize-disabled .box-bottom-left,
.resize-disabled .box-bottom-center,
.resize-disabled .box-bottom-right {
cursor: default;
}
.app-body {
flex-grow: 1;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
}
</style>

217
src/mixins/crud.js Normal file
View File

@@ -0,0 +1,217 @@
import { mapGetters } from 'vuex';
export default (app, option = {}) => {
let optionObj = import.meta.glob(`../option/**/**`)[`../option/${option.name}.js`];
let apiObj = import.meta.glob(`../api/**/**`)[`../api/${option.name}.js`];
let mixins = {
data() {
return {
data: [],
form: {},
params: {},
option: {},
api: {},
loading: false,
page: {},
};
},
created() {
optionObj().then(mode => (this.option = mode.default));
apiObj().then(mode => {
this.api = mode;
this.getList();
});
},
computed: {
...mapGetters(['userInfo', 'permission', 'roles']),
ids() {
const ids = [];
this.selectionList.forEach(ele => {
ids.push(ele[this.rowKey]);
});
return ids.join(',');
},
bindVal() {
return {
ref: 'crud',
option: this.option,
data: this.data,
tableLoading: this.loading,
};
},
onEvent() {
return {
'size-change': this.sizeChange,
'current-change': this.currentChange,
'row-save': this.rowSave,
'row-update': this.rowUpdate,
'row-del': this.rowDel,
'refresh-change': this.refreshChange,
'search-reset': this.searchChange,
'search-change': this.searchChange,
};
},
rowKey() {
return option.rowKey || 'id';
},
},
methods: {
getList() {
const callback = () => {
this.loading = true;
this.data = [];
this.api[option.list || 'getList'](
this.page.currentPage,
this.page.pageSize,
this.params
).then(res => {
this.loading = false;
let data;
if (option.res) {
data = option.res(res.data);
} else {
data = res.data.data;
}
this.page.total = data[option.total || 'total'];
const result = data[option.data || 'records'];
this.data = result;
if (this.listAfter) {
this.listAfter(data);
}
});
};
if (this.listBefore) {
this.listBefore();
}
callback();
},
rowSave(row, done, loading) {
const callback = () => {
delete this.form.params;
this.api[option.add || 'add'](this.form)
.then(data => {
this.getList();
if (this.addAfter) {
this.addAfter(data);
} else {
this.$message.success('新增成功');
}
done();
})
.catch(() => {
loading();
});
};
if (this.addBefore) {
this.addBefore();
}
callback();
},
rowUpdate(row, index, done, loading) {
const callback = () => {
delete this.form.params;
this.api[option.update || 'update'](this.form)
.then(data => {
this.getList();
if (this.updateAfter) {
this.updateAfter(data);
} else {
this.$message.success('更新成功');
}
done();
})
.catch(() => {
loading();
});
};
if (this.updateBefore) {
this.updateBefore();
}
callback();
},
rowDel(row, index) {
const callback = () => {
this.api[option.del || 'del'](row[this.rowKey], row).then(data => {
this.getList();
if (this.delAfter) {
this.delAfter(data, row, index);
} else {
this.$message.success('删除成功');
}
});
};
if (this.delBefore) {
this.delBefore();
callback();
} else {
this.$confirm('确定将选择数据删除?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
}).then(() => {
callback();
});
}
},
handleDelete() {
if (this.selectionList.length === 0) {
this.$message.warning('请选择至少一条数据');
return;
}
this.$confirm('确定将选择数据删除?', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
}).then(() => {
this.api[option.del || 'remove'](this.ids).then(data => {
this.getList();
if (this.delMultiAfter) {
this.delMultiAfter(data, this.ids);
} else {
this.$message.success('删除成功');
}
});
});
},
searchChange(params, done) {
if (done) done();
this.params = params;
this.page.currentPage = 1;
this.getList();
},
dateChange(date) {
if (date) {
this.params.createTime_dategt = date[0];
this.params.createTime_datelt = date[1];
} else {
delete this.params.createTime_dategt;
delete this.params.createTime_datelt;
}
this.page.currentPage = 1;
this.getList();
},
selectionChange(list) {
this.selectionList = list;
},
selectionClear() {
this.selectionList = [];
this.$refs.crud.toggleSelection();
},
refreshChange() {
this.getList();
},
sizeChange(val) {
this.page.currentPage = 1;
this.page.pageSize = val;
this.getList();
},
currentChange(val) {
this.page.currentPage = val;
this.getList();
},
},
};
app.mixins = app.mixins || [];
app.mixins.push(mixins);
return app;
};

45
src/mixins/index.js Normal file
View File

@@ -0,0 +1,45 @@
import { validatenull } from '@/utils/validate';
import { getStore } from '@/utils/store.js';
export default {
data() {
return {
//刷新token锁
refreshLock: false,
//刷新token的时间
refreshTime: '',
};
},
created() {
//实时检测刷新token
//this.refreshToken();
},
methods: {
//实时检测刷新token
refreshToken() {
this.refreshTime = setInterval(() => {
const token =
getStore({
name: 'token',
debug: true,
}) || {};
let date1 = this.$dayjs(token.datetime);
let date2 = this.$dayjs();
const date = date2.diff(date1, 'seconds');
if (validatenull(date)) return;
if (date >= this.website.tokenTime && !this.refreshLock) {
this.refreshLock = true;
this.$store
.dispatch('RefreshToken')
.then(() => {
this.refreshLock = false;
})
.catch(err => {
console.log(err);
this.refreshLock = false;
});
}
}, 1000);
},
},
};

515
src/option/job/jobinfo.js Normal file
View File

@@ -0,0 +1,515 @@
export const timeExpressionTypeDic = [
{
label: 'API',
value: 1,
},
{
label: 'CRON',
value: 2,
},
{
label: '固定频率(毫秒)',
value: 3,
},
{
label: '固定延迟(毫秒)',
value: 4,
},
{
label: '工作流',
value: 5,
},
];
export const executeTypeDic = [
{
label: '单机执行',
value: 1,
},
{
label: '广播执行',
value: 2,
},
{
label: 'MapReduce',
value: 3,
},
];
export const processorTypeDic = [
{
label: '内建处理器',
value: 1,
},
{
label: '外部处理器(动态加载)',
value: 4,
},
];
export const dispatchStrategyDic = [
{
label: 'HEALTH_FIRST',
value: 1,
},
{
label: 'RANDOM',
value: 2,
},
];
export const enableDic = [
{
label: '暂停',
value: 0,
},
{
label: '启用',
value: 1,
},
];
export const logTypeDic = [
{
label: 'ONLINE',
value: 1,
},
{
label: 'LOCAL',
value: 2,
},
{
label: 'STDOUT',
value: 3,
},
{
label: 'LOCAL_AND_ONLINE',
value: 4,
},
{
label: 'NULL',
value: 999,
},
];
export const logLevelDic = [
{
label: 'DEBUG',
value: 1,
},
{
label: 'INFO',
value: 2,
},
{
label: 'WARN',
value: 3,
},
{
label: 'ERROR',
value: 4,
},
{
label: 'OFF',
value: 99,
},
];
export default {
height: 'auto',
calcHeight: 30,
tip: false,
searchShow: true,
searchMenuSpan: 6,
border: true,
index: true,
viewBtn: true,
selection: true,
grid: true,
labelWidth: 180,
menuWidth: 350,
dialogWidth: 1200,
dialogClickModal: false,
tabs: true,
column: [
{
label: '任务应用',
prop: 'jobServerId',
type: 'select',
dicUrl: '/blade-job/job-server/select',
props: {
label: 'jobAppName',
value: 'id',
},
search: true,
display: false,
},
{
label: '任务ID',
prop: 'jobId',
type: 'input',
search: true,
width: 80,
display: false,
},
{
label: '任务名称',
prop: 'jobName',
type: 'input',
search: true,
width: 200,
display: false,
},
{
label: '定时信息',
labelTip: '时间表达式类型',
prop: 'timeExpressionType',
type: 'select',
dicData: timeExpressionTypeDic,
rules: [
{
required: true,
message: '请选择定时信息',
trigger: 'blur',
},
],
width: 120,
display: false,
},
{
label: '执行类型',
labelTip: '枚举值',
prop: 'executeType',
type: 'select',
dicData: executeTypeDic,
rules: [
{
required: true,
message: '请选择执行器类型',
trigger: 'blur',
},
],
width: 110,
display: false,
},
{
label: '处理器类型',
labelTip: '枚举值',
prop: 'processorType',
type: 'select',
dicData: processorTypeDic,
rules: [
{
required: true,
message: '请选择处理器类型',
trigger: 'blur',
},
],
width: 180,
display: false,
},
{
label: '任务状态',
labelTip: '未启用的任务不会被调度',
prop: 'enable',
type: 'switch',
dicData: enableDic,
slot: true,
width: 100,
display: false,
},
],
group: [
{
label: '基础配置',
prop: 'modelSetting',
icon: 'el-icon-tickets',
column: [
{
label: '任务应用',
prop: 'jobServerId',
type: 'select',
dicUrl: '/blade-job/job-server/select',
props: {
label: 'jobAppName',
value: 'id',
},
editDisabled: true,
rules: [
{
required: true,
message: '请选择任务应用',
trigger: 'blur',
},
],
},
{
label: '任务状态',
labelTip: '未启用的任务不会被调度',
prop: 'enable',
type: 'switch',
value: 1,
rules: [
{
required: true,
message: '请选择是否开启',
trigger: 'blur',
},
],
},
{
label: '任务名称',
prop: 'jobName',
type: 'input',
rules: [
{
required: true,
message: '请输入任务名称',
trigger: 'blur',
},
],
},
{
label: '生命周期',
labelTip: '预留,用于指定定时调度任务的生效时间范围)',
prop: 'lifecycle',
type: 'datetimerange',
format: 'YYYY-MM-DD HH:mm:ss',
valueFormat: 'YYYY-MM-DD HH:mm:ss',
startPlaceholder: '任务开始时间',
endPlaceholder: '任务结束时间',
},
{
label: '定时类型',
labelTip: '时间表达式类型',
prop: 'timeExpressionType',
type: 'select',
dicData: timeExpressionTypeDic,
value: 2,
rules: [
{
required: true,
message: '请选择定时信息',
trigger: 'blur',
},
],
},
{
label: '时间表达式',
labelTip: '填写类型由 定时类型 决定,比如 CRON 需要填写 CRON 表达式',
prop: 'timeExpression',
type: 'input',
},
{
label: '执行类型',
labelTip: '枚举值',
prop: 'executeType',
type: 'select',
dicData: executeTypeDic,
value: 1,
rules: [
{
required: true,
message: '请选择执行器类型',
trigger: 'blur',
},
],
},
{
label: '运行时配置',
labelTip: '目前支持随机(RANDOM)和健康度优先(HEALTH_FIRST)',
prop: 'dispatchStrategy',
type: 'select',
dicData: dispatchStrategyDic,
value: 1,
rules: [
{
required: true,
message: '请选择运行时配置',
trigger: 'blur',
},
],
},
{
label: '处理器类型',
labelTip: '枚举值',
prop: 'processorType',
type: 'select',
dicData: processorTypeDic,
value: 1,
rules: [
{
required: true,
message: '请选择处理器类型',
trigger: 'blur',
},
],
},
{
label: '处理器参数',
labelTip:
'如Java处理器需要填写全限定类名,如:org.springblade.demo.MapReduceProcessorDemo',
prop: 'processorInfo',
type: 'input',
rules: [
{
required: true,
message: '请输入处理器参数',
trigger: 'blur',
},
],
},
{
label: '任务参数',
labelTip: '方法入参 TaskContext 对象的 json 字段',
prop: 'jobParams',
type: 'input',
span: 24,
},
{
label: '任务描述',
prop: 'jobDescription',
type: 'textarea',
minRows: 3,
span: 24,
},
],
},
{
label: '高级配置',
prop: 'templateSetting',
icon: 'el-icon-copy-document',
column: [
{
label: '最大实例数',
labelTip:
'该任务同时执行的数量(任务和实例就像是类和对象的关系,任务被调度执行后被称为实例)',
prop: 'maxInstanceNum',
type: 'number',
value: 0,
},
{
label: '单机线程并发数',
labelTip: '该实例执行过程中每个 Worker 使用的线程数量',
prop: 'concurrency',
type: 'number',
value: 5,
},
{
label: '任务实例运行时间限制',
labelTip: '0 代表无任何限制,超时会被打断并判定为执行失败',
prop: 'instanceTimeLimit',
type: 'number',
value: 0,
},
{
label: '任务实例重试次数',
labelTip: '任务实例重试次数,整个任务失败时重试,代价大,不推荐使用',
prop: 'instanceRetryNum',
type: 'number',
value: 0,
},
{
label: '任务作业重试次数',
labelTip: 'Task 重试次数,每个子 Task 失败后单独重试,代价小,推荐使用',
prop: 'taskRetryNum',
type: 'number',
value: 0,
},
{
label: '最低CPU核心',
labelTip:
'最小可用 CPU 核心数,CPU 可用核心数小于该值的 Worker 将不会执行该任务,0 代表无任何限制',
prop: 'minCpuCores',
type: 'number',
value: 0,
},
{
label: '最低内存(GB)',
labelTip: '可用内存小于该值的Worker 将不会执行该任务,0 代表无任何限制',
prop: 'minMemorySpace',
type: 'number',
value: 0,
},
{
label: '最低磁盘空间(GB)',
labelTip: '可用磁盘空间小于该值的Worker 将不会执行该任务,0 代表无任何限制',
prop: 'minDiskSpace',
type: 'number',
value: 0,
},
{
label: '执行机器地址',
labelTip: '设置该参数后只有列表中的机器允许执行该任务,空代表不指定机器',
prop: 'designatedWorkers',
type: 'input',
},
{
label: '最大执行机器数量',
labelTip: '限定调动执行的机器数量,0代表无限制',
prop: 'maxWorkerCount',
type: 'number',
value: 0,
},
],
},
{
label: '其他配置',
prop: 'codingSetting',
icon: 'el-icon-printer',
column: [
{
label: '报警人员ID列表',
labelTip: '接收报警的用户ID列表',
prop: 'notifyUserIds',
type: 'input',
},
{
label: '错误阈值',
labelTip: '错误阈值,0代表不限制',
prop: 'alertThreshold',
type: 'number',
value: 0,
},
{
label: '统计窗口(s)',
labelTip: '统计的窗口长度(s),0代表不限制',
prop: 'statisticWindowLen',
type: 'number',
value: 0,
},
{
label: '沉默窗口(s)',
labelTip: '沉默时间窗口(s),0代表不限制',
prop: 'silenceWindowLen',
type: 'number',
value: 0,
},
{
label: '日志配置',
labelTip: '日志配置',
prop: 'logType',
type: 'select',
value: 1,
dicData: logTypeDic,
},
{
label: '日志级别',
labelTip: '日志级别',
prop: 'logLevel',
type: 'select',
value: 2,
dicData: logLevelDic,
},
{
label: '扩展字段',
labelTip: '供开发者使用,用于功能扩展,powerjob 自身不会使用该字段',
prop: 'extra',
type: 'textarea',
minRows: 3,
span: 24,
},
],
},
],
};

View File

@@ -0,0 +1,78 @@
export default {
height: 'auto',
calcHeight: 30,
tip: false,
searchShow: true,
searchMenuSpan: 6,
border: true,
index: true,
viewBtn: true,
selection: true,
grid: true,
labelWidth: 100,
menuWidth: 350,
dialogClickModal: false,
column: [
{
label: '服务名称',
prop: 'jobServerName',
type: 'input',
span: 24,
search: true,
rules: [
{
required: true,
message: '请输入服务名称',
trigger: 'blur',
},
],
},
{
label: '服务器地址',
prop: 'jobServerUrl',
type: 'input',
span: 24,
rules: [
{
required: true,
message: '请输入服务器地址',
trigger: 'blur',
},
],
},
{
label: '应用名称',
prop: 'jobAppName',
type: 'input',
span: 24,
search: true,
rules: [
{
required: true,
message: '请输入应用名称',
trigger: 'blur',
},
],
},
{
label: '应用密码',
prop: 'jobAppPassword',
type: 'input',
span: 24,
rules: [
{
required: true,
message: '请输入应用密码',
trigger: 'blur',
},
],
},
{
label: '任务备注',
prop: 'jobRemark',
type: 'textarea',
minRows: 3,
span: 24,
},
],
};

View File

@@ -0,0 +1,120 @@
export default {
height:'auto',
calcHeight: 30,
tip: false,
searchShow: true,
searchMenuSpan: 6,
border: true,
index: true,
viewBtn: true,
selection: true,
dialogClickModal: false,
column: [
{
label: "主键",
prop: "id",
type: "input",
addDisplay: false,
editDisplay: false,
viewDisplay: false,
hide: true,
},
{
label: "租户ID",
prop: "tenantId",
type: "input",
addDisplay: false,
editDisplay: false,
viewDisplay: false,
hide: true,
},
{
label: "类型 1:单张,2:组合 3:配件",
prop: "type",
type: "radio",
},
{
label: "产品名称",
prop: "name",
type: "input",
},
{
label: "目录图片地址",
prop: "imageUrl",
type: "input",
},
{
label: "照片数量",
prop: "photoLimit",
type: "input",
},
{
label: "形状",
prop: "shape",
type: "checkbox",
},
{
label: "创建人",
prop: "createUser",
type: "input",
addDisplay: false,
editDisplay: false,
viewDisplay: false,
hide: true,
},
{
label: "创建部门",
prop: "createDept",
type: "input",
addDisplay: false,
editDisplay: false,
viewDisplay: false,
hide: true,
},
{
label: "创建时间",
prop: "createTime",
type: "input",
addDisplay: false,
editDisplay: false,
viewDisplay: false,
hide: true,
},
{
label: "修改人",
prop: "updateUser",
type: "input",
addDisplay: false,
editDisplay: false,
viewDisplay: false,
hide: true,
},
{
label: "修改时间",
prop: "updateTime",
type: "input",
addDisplay: false,
editDisplay: false,
viewDisplay: false,
hide: true,
},
{
label: "状态",
prop: "status",
type: "input",
addDisplay: false,
editDisplay: false,
viewDisplay: false,
hide: true,
},
{
label: "是否已删除",
prop: "isDeleted",
type: "input",
addDisplay: false,
editDisplay: false,
viewDisplay: false,
hide: true,
},
]
}

210
src/option/system/dict.js Normal file
View File

@@ -0,0 +1,210 @@
export const optionParent = {
height: 'auto',
calcHeight: 32,
tip: false,
searchShow: true,
searchMenuSpan: 10,
border: true,
index: true,
selection: true,
viewBtn: true,
menuWidth: 250,
dialogWidth: 880,
dialogClickModal: false,
column: [
{
label: '字典编号',
prop: 'code',
search: true,
slot: true,
span: 24,
rules: [
{
required: true,
message: '请输入字典编号',
trigger: 'blur',
},
],
},
{
label: '字典名称',
prop: 'dictValue',
search: true,
align: 'center',
rules: [
{
required: true,
message: '请输入字典名称',
trigger: 'blur',
},
],
},
{
label: '字典排序',
prop: 'sort',
type: 'number',
align: 'right',
width: 100,
rules: [
{
required: true,
message: '请输入字典排序',
trigger: 'blur',
},
],
},
{
label: '封存',
prop: 'isSealed',
type: 'switch',
align: 'center',
width: 100,
dicData: [
{
label: '否',
value: 0,
},
{
label: '是',
value: 1,
},
],
value: 0,
slot: true,
rules: [
{
required: true,
message: '请选择封存',
trigger: 'blur',
},
],
},
{
label: '字典备注',
prop: 'remark',
hide: true,
},
],
};
export const optionChild = {
height: 'auto',
calcHeight: 95,
tip: false,
searchShow: true,
searchMenuSpan: 10,
tree: true,
border: true,
index: true,
selection: true,
viewBtn: true,
menuWidth: 300,
dialogWidth: 880,
dialogClickModal: false,
column: [
{
label: '字典编号',
prop: 'code',
addDisabled: true,
editDisabled: true,
search: true,
span: 24,
rules: [
{
required: true,
message: '请输入字典编号',
trigger: 'blur',
},
],
},
{
label: '字典名称',
prop: 'dictValue',
search: true,
align: 'center',
rules: [
{
required: true,
message: '请输入字典名称',
trigger: 'blur',
},
],
},
{
label: '上级字典',
prop: 'parentId',
type: 'tree',
dicData: [],
hide: true,
props: {
label: 'title',
},
addDisabled: true,
editDisabled: true,
rules: [
{
required: false,
message: '请选择上级字典',
trigger: 'click',
},
],
},
{
label: '字典键值',
prop: 'dictKey',
width: 85,
rules: [
{
required: true,
message: '请输入字典键值',
trigger: 'blur',
},
],
},
{
label: '字典排序',
prop: 'sort',
type: 'number',
align: 'right',
hide: true,
rules: [
{
required: true,
message: '请输入字典排序',
trigger: 'blur',
},
],
},
{
label: '封存',
prop: 'isSealed',
type: 'switch',
align: 'center',
width: 80,
dicData: [
{
label: '否',
value: 0,
},
{
label: '是',
value: 1,
},
],
value: 0,
slot: true,
rules: [
{
required: true,
message: '请选择封存',
trigger: 'blur',
},
],
},
{
label: '字典备注',
prop: 'remark',
hide: true,
},
],
};

View File

@@ -0,0 +1,211 @@
export const optionParent = {
height: 'auto',
calcHeight: 32,
tip: false,
searchShow: true,
searchMenuSpan: 10,
border: true,
index: true,
selection: true,
viewBtn: true,
menuWidth: 250,
dialogWidth: 880,
dialogClickModal: false,
column: [
{
label: '字典编号',
prop: 'code',
search: true,
slot: true,
span: 24,
rules: [
{
required: true,
message: '请输入字典编号',
trigger: 'blur',
},
],
},
{
label: '字典名称',
prop: 'dictValue',
search: true,
align: 'center',
rules: [
{
required: true,
message: '请输入字典名称',
trigger: 'blur',
},
],
},
{
label: '字典排序',
prop: 'sort',
type: 'number',
align: 'right',
width: 100,
hide: true,
rules: [
{
required: true,
message: '请输入字典排序',
trigger: 'blur',
},
],
},
{
label: '封存',
prop: 'isSealed',
type: 'switch',
align: 'center',
width: 100,
dicData: [
{
label: '否',
value: 0,
},
{
label: '是',
value: 1,
},
],
value: 0,
slot: true,
rules: [
{
required: true,
message: '请选择封存',
trigger: 'blur',
},
],
},
{
label: '字典备注',
prop: 'remark',
hide: true,
},
],
};
export const optionChild = {
height: 'auto',
calcHeight: 95,
tip: false,
searchShow: true,
searchMenuSpan: 10,
tree: true,
border: true,
index: true,
selection: true,
viewBtn: true,
menuWidth: 300,
dialogWidth: 880,
dialogClickModal: false,
column: [
{
label: '字典编号',
prop: 'code',
addDisabled: true,
editDisabled: true,
search: true,
span: 24,
rules: [
{
required: true,
message: '请输入字典编号',
trigger: 'blur',
},
],
},
{
label: '字典名称',
prop: 'dictValue',
search: true,
align: 'center',
rules: [
{
required: true,
message: '请输入字典名称',
trigger: 'blur',
},
],
},
{
label: '上级字典',
prop: 'parentId',
type: 'tree',
dicData: [],
hide: true,
props: {
label: 'title',
},
addDisabled: true,
editDisabled: true,
rules: [
{
required: false,
message: '请选择上级字典',
trigger: 'click',
},
],
},
{
label: '字典键值',
prop: 'dictKey',
width: 85,
rules: [
{
required: true,
message: '请输入字典键值',
trigger: 'blur',
},
],
},
{
label: '字典排序',
prop: 'sort',
type: 'number',
align: 'right',
hide: true,
rules: [
{
required: true,
message: '请输入字典排序',
trigger: 'blur',
},
],
},
{
label: '封存',
prop: 'isSealed',
type: 'switch',
align: 'center',
width: 80,
dicData: [
{
label: '否',
value: 0,
},
{
label: '是',
value: 1,
},
],
value: 0,
slot: true,
rules: [
{
required: true,
message: '请选择封存',
trigger: 'blur',
},
],
},
{
label: '字典备注',
prop: 'remark',
hide: true,
},
],
};

501
src/option/system/user.js Normal file
View File

@@ -0,0 +1,501 @@
import website from '@/config/website';
import { getDeptLazyTree } from '@/api/system/dept';
export const userOption = safe => {
const validatePass = (rule, value, callback) => {
if (value === '') {
callback(new Error('please input password'));
} else {
callback();
}
};
const validatePass2 = (rule, value, callback) => {
if (value === '') {
callback(new Error('please input password again'));
} else if (value !== safe.form.password) {
callback(new Error('password is different!'));
} else {
callback();
}
};
return {
height: 'auto',
calcHeight: 150,
tip: false,
searchShow: true,
searchMenuSpan: 6,
border: true,
index: true,
selection: true,
addBtn: false,
viewBtn: true,
dialogType: 'drawer',
dialogWidth: 1000,
dialogClickModal: false,
column: [
{
label: 'Account',
prop: 'account',
search: true,
display: false,
},
{
label: 'Tenant',
prop: 'tenantName',
slot: true,
display: false,
hide: true,
},
{
label: 'Username',
prop: 'realName',
search: true,
display: false,
},
{
label: 'Role',
prop: 'roleName',
slot: true,
overHidden: true,
display: false,
},
{
label: 'Store',
prop: 'deptName',
slot: true,
overHidden: true,
display: false,
},
{
label: 'Platform',
prop: 'userTypeName',
width: 100,
slot: true,
display: false,
},
{
label: 'Platform',
type: 'select',
dicUrl: '/blade-system/dict/dictionary?code=user_type',
props: {
label: 'dictValue',
value: 'dictKey',
},
dataType: 'number',
search: true,
hide: true,
display: false,
prop: 'userType',
rules: [
{
required: true,
message: 'please select platform',
trigger: 'blur',
},
],
},
],
group: [
{
label: 'BaseInfo',
prop: 'baseInfo',
icon: 'el-icon-user-solid',
column: [
{
label: 'Tenant',
prop: 'tenantId',
type: 'tree',
dicUrl: '/blade-system/tenant/select',
props: {
label: 'tenantName',
value: 'tenantId',
},
hide: !website.tenantMode,
addDisplay: website.tenantMode,
editDisplay: website.tenantMode,
viewDisplay: website.tenantMode,
rules: [
{
required: true,
message: 'please input Tenant',
trigger: 'click',
},
],
span: 24,
},
{
label: 'Account',
prop: 'account',
rules: [
{
required: true,
message: 'please input account',
trigger: 'blur',
},
],
},
{
label: 'Platform',
type: 'select',
dicUrl: '/blade-system/dict/dictionary?code=user_type',
props: {
label: 'dictValue',
value: 'dictKey',
},
dataType: 'number',
slot: true,
prop: 'userType',
rules: [
{
required: true,
message: 'please select platform',
trigger: 'blur',
},
],
},
{
label: 'Password',
prop: 'password',
hide: true,
editDisplay: false,
viewDisplay: false,
rules: [{ required: true, validator: validatePass, trigger: 'blur' }],
},
{
label: 'Password Confirm',
prop: 'password2',
hide: true,
editDisplay: false,
viewDisplay: false,
rules: [{ required: true, validator: validatePass2, trigger: 'blur' }],
},
],
},
{
label: 'DetailInfo',
prop: 'detailInfo',
icon: 'el-icon-s-order',
column: [
{
label: 'Nickname',
prop: 'name',
hide: true,
rules: [
{
required: true,
message: 'please input nickname',
trigger: 'blur',
},
],
},
{
label: 'Name',
prop: 'realName',
rules: [
{
required: true,
message: 'please input name',
trigger: 'blur',
},
{
min: 2,
max: 200,
message: '姓名长度在2到5个字符',
},
],
},
{
label: 'Phone',
prop: 'phone',
overHidden: true,
},
{
label: 'EMail',
prop: 'email',
hide: true,
overHidden: true,
},
{
label: 'Gender',
prop: 'sex',
type: 'select',
dicData: [
{
label: 'Male',
value: 1,
},
{
label: 'Female',
value: 2,
},
{
label: 'Unknown',
value: 3,
},
],
hide: true,
},
{
label: 'Birthday',
type: 'date',
prop: 'birthday',
format: 'YYYY-MM-DD HH:mm:ss',
valueFormat: 'YYYY-MM-DD HH:mm:ss',
hide: true,
},
{
label: 'Status',
prop: 'statusName',
hide: true,
display: false,
},
],
},
{
label: 'DutyInfo',
prop: 'dutyInfo',
icon: 'el-icon-s-custom',
column: [
{
label: 'Code',
prop: 'code',
},
{
label: 'Role',
prop: 'roleId',
multiple: true,
type: 'tree',
dicData: [],
props: {
label: 'title',
},
checkStrictly: true,
slot: true,
rules: [
{
required: true,
message: 'please select role',
trigger: 'click',
},
],
},
{
label: 'Store',
prop: 'deptId',
type: 'tree',
multiple: true,
dicData: [],
props: {
label: 'title',
},
checkStrictly: true,
slot: true,
rules: [
{
required: true,
message: 'please select store',
trigger: 'click',
},
],
},
{
label: 'Position',
prop: 'postId',
type: 'tree',
multiple: true,
dicData: [],
props: {
label: 'postName',
value: 'id',
},
rules: [
{
required: true,
message: 'please select position',
trigger: 'click',
},
],
},
{
label: 'Leader',
prop: 'leaderId',
type: 'tree',
multiple: true,
filterable: true,
dicData: [],
props: {
label: 'realName',
value: 'id',
},
clearable: true,
},
{
label: 'isLeader',
prop: 'isLeader',
type: 'switch',
dicData: [
{
label: 'No',
value: 0,
},
{
label: 'Yes',
value: 1,
},
],
value: 0,
},
],
},
],
};
};
export const platformOption = {
tip: false,
searchShow: true,
searchMenuSpan: 6,
border: true,
index: true,
selection: true,
viewBtn: true,
dialogClickModal: false,
menuWidth: 120,
editBtnText: 'Config',
column: [
{
label: 'Account',
prop: 'account',
search: true,
display: false,
},
{
label: 'Tenant',
prop: 'tenantName',
slot: true,
display: false,
},
{
label: 'Name',
prop: 'realName',
search: true,
display: false,
},
{
label: '用户平台',
prop: 'userTypeName',
slot: true,
display: false,
},
{
label: '用户平台',
type: 'select',
dicUrl: '/blade-system/dict/dictionary?code=user_type',
props: {
label: 'dictValue',
value: 'dictKey',
},
dataType: 'number',
search: true,
hide: true,
display: false,
prop: 'userType',
rules: [
{
required: true,
message: '请选择用户平台',
trigger: 'blur',
},
],
},
{
label: 'Extension',
prop: 'userExt',
type: 'textarea',
minRows: 8,
span: 24,
overHidden: true,
row: true,
hide: true,
},
],
};
export const excelOption = {
submitBtn: false,
emptyBtn: false,
column: [
{
label: '模板上传',
prop: 'excelFile',
type: 'upload',
drag: true,
loadText: '模板上传中,请稍等',
span: 24,
propsHttp: {
res: 'data',
},
tip: '请上传 .xls,.xlsx 标准格式文件',
action: '/blade-system/user/import-user',
},
{
label: '数据覆盖',
prop: 'isCovered',
type: 'switch',
align: 'center',
width: 80,
dicData: [
{
label: '否',
value: 0,
},
{
label: '是',
value: 1,
},
],
value: 0,
slot: true,
rules: [
{
required: true,
message: '请选择是否覆盖',
trigger: 'blur',
},
],
},
{
label: '模板下载',
prop: 'excelTemplate',
formslot: true,
span: 24,
},
],
};
export const treeOption = {
nodeKey: 'id',
lazy: true,
treeLoad: function (node, resolve) {
const parentId = node.level === 0 ? 0 : node.data.id;
getDeptLazyTree(parentId).then(res => {
resolve(
res.data.data.map(item => {
return {
...item,
leaf: !item.hasChildren,
};
})
);
});
},
addBtn: false,
menu: false,
size: 'small',
props: {
labelText: 'Title',
label: 'title',
value: 'value',
children: 'children',
},
};

665
src/option/tool/code.js Normal file
View File

@@ -0,0 +1,665 @@
import { templateDic } from '@/const/tool/model';
export const codeOption = {
height: 'auto',
calcHeight: 32,
dialogWidth: 900,
tip: false,
searchShow: true,
searchMenuSpan: 6,
border: true,
index: true,
selection: true,
labelWidth: 120,
menuWidth: 350,
viewBtn: true,
dialogClickModal: false,
tabs: true,
column: [
{
label: '模块名',
prop: 'codeName',
search: true,
display: false,
},
{
label: '模版类型',
prop: 'templateType',
type: 'select',
dicData: templateDic,
display: false,
},
{
label: '表名',
prop: 'tableName',
search: true,
display: false,
},
{
label: '服务名',
prop: 'serviceName',
search: true,
display: false,
},
{
label: '包名',
prop: 'packageName',
display: false,
},
],
group: [
{
label: '模型配置',
prop: 'modelSetting',
icon: 'el-icon-tickets',
column: [
{
label: '上级菜单',
prop: 'menuId',
type: 'tree',
dicData: [],
span: 24,
hide: true,
addDisabled: false,
props: {
label: 'title',
},
rules: [
{
required: true,
message: '请选择上级菜单',
trigger: 'click',
},
],
},
{
label: '数据模型',
prop: 'modelId',
search: true,
span: 24,
type: 'select',
dicUrl: '/blade-develop/model/select',
props: {
label: 'modelName',
value: 'id',
},
rules: [
{
required: true,
message: '请选择数据模型',
trigger: 'blur',
},
],
},
{
label: '模块名',
prop: 'codeName',
search: true,
rules: [
{
required: true,
message: '请输入模块名',
trigger: 'blur',
},
],
},
{
label: '表名',
prop: 'tableName',
rules: [
{
required: true,
message: '请输入表名',
trigger: 'blur',
},
],
},
{
label: '表前缀',
prop: 'tablePrefix',
hide: true,
rules: [
{
required: true,
message: '请输入表前缀',
trigger: 'blur',
},
],
},
{
label: '主键名',
prop: 'pkName',
hide: true,
rules: [
{
required: true,
message: '请输入主键名',
trigger: 'blur',
},
],
},
{
label: '服务名',
prop: 'serviceName',
search: true,
rules: [
{
required: true,
message: '请输入服务名',
trigger: 'blur',
},
],
},
{
label: '包名',
prop: 'packageName',
overHidden: true,
rules: [
{
required: true,
message: '请输入包名',
trigger: 'blur',
},
],
},
],
},
{
label: '模版配置',
prop: 'templateSetting',
icon: 'el-icon-copy-document',
column: [
{
label: '模版类型',
prop: 'templateType',
type: 'select',
dicData: templateDic,
value: 'crud',
rules: [
{
required: true,
message: '请选择模版类型',
trigger: 'blur',
},
],
},
{
label: '作者信息',
prop: 'author',
value: 'BladeX',
rules: [
{
required: true,
message: '请输入作者',
trigger: 'blur',
},
],
},
{
label: '子表模型',
prop: 'subModelId',
type: 'select',
dicUrl: '/blade-develop/model/select',
props: {
label: 'modelName',
value: 'id',
},
display: false,
hide: true,
},
{
label: '子表外键',
prop: 'subFkId',
display: false,
hide: true,
},
{
label: '树主键字段',
prop: 'treeId',
type: 'select',
dicData: [],
props: {
label: 'jdbcComment',
value: 'jdbcName',
},
display: false,
hide: true,
},
{
label: '树父主键字段',
prop: 'treePid',
type: 'select',
dicData: [],
props: {
label: 'jdbcComment',
value: 'jdbcName',
},
display: false,
hide: true,
},
{
label: '树名称字段',
prop: 'treeName',
type: 'select',
dicData: [],
props: {
label: 'jdbcComment',
value: 'jdbcName',
},
display: false,
hide: true,
},
],
},
{
label: '生成配置',
prop: 'codingSetting',
icon: 'el-icon-printer',
column: [
{
label: '基础业务',
labelTip: '配置是否使用BladeX封装的BaseService解锁更多功能',
prop: 'baseMode',
type: 'radio',
dicUrl: '/blade-system/dict/dictionary?code=yes_no',
props: {
label: 'dictValue',
value: 'dictKey',
},
value: 2,
dataType: 'number',
hide: true,
rules: [
{
required: true,
message: '请选择基础业务',
trigger: 'blur',
},
],
},
{
label: '包装器',
labelTip: '配置是否使用Wrapper包装器来拓展Controller返回列表的字段',
prop: 'wrapMode',
type: 'radio',
dicUrl: '/blade-system/dict/dictionary?code=yes_no',
props: {
label: 'dictValue',
value: 'dictKey',
},
value: 2,
dataType: 'number',
hide: true,
rules: [
{
required: true,
message: '请选择包装器',
trigger: 'blur',
},
],
},
{
label: '远程调用',
labelTip: '配置是否使用Feign远程调用',
prop: 'feignMode',
type: 'radio',
dicUrl: '/blade-system/dict/dictionary?code=yes_no',
props: {
label: 'dictValue',
value: 'dictKey',
},
value: 1,
dataType: 'number',
hide: true,
rules: [
{
required: true,
message: '请选择基础业务',
trigger: 'blur',
},
],
},
{
label: '代码风格',
labelTip: '选择不同底层实现的代码模版',
prop: 'codeStyle',
type: 'radio',
dicData: [
{
label: 'saber3',
value: 'saber3',
},
{
label: 'element-plus',
value: 'element-plus',
},
],
value: 'saber3',
hide: true,
rules: [
{
required: true,
message: '请选择代码风格',
trigger: 'blur',
},
],
},
{
label: '后端生成路径',
prop: 'apiPath',
span: 24,
hide: true,
rules: [
{
required: true,
message: '请输入后端生成路径',
trigger: 'blur',
},
],
},
{
label: '前端生成路径',
prop: 'webPath',
span: 24,
hide: true,
rules: [
{
required: true,
message: '请输入前端生成路径',
trigger: 'blur',
},
],
},
],
},
],
};
export const genOption = {
labelWidth: 120,
column: [
{
label: '上级菜单',
prop: 'menuId',
type: 'tree',
dicData: [],
span: 24,
hide: true,
addDisabled: false,
props: {
label: 'title',
},
rules: [
{
required: true,
message: '请选择上级菜单',
trigger: 'click',
},
],
},
{
label: '数据源',
prop: 'datasourceId',
search: true,
span: 24,
type: 'select',
dicUrl: '/blade-develop/datasource/select',
props: {
label: 'name',
value: 'id',
},
rules: [
{
required: true,
message: '请选择数据源',
trigger: 'blur',
},
],
},
{
label: '物理表名',
prop: 'modelTable',
type: 'tree',
slot: true,
filterable: true,
span: 24,
display: true,
dicData: [],
props: {
label: 'comment',
value: 'name',
},
rules: [
{
required: true,
message: '请输入数据库表名',
trigger: 'blur',
},
],
},
{
label: '表单设计',
prop: 'modelForm',
type: 'select',
props: {
label: 'name',
value: 'id',
},
dicData: [],
filterable: true,
display: false,
span: 24,
},
{
label: '模型类名',
prop: 'modelClass',
display: false,
disabled: true,
rules: [
{
required: true,
message: '请输入模型类名',
trigger: 'blur',
},
],
},
{
label: '模型编号',
prop: 'modelCode',
display: false,
rules: [
{
required: true,
message: '请输入模型编号',
trigger: 'blur',
},
],
},
{
label: '模块名',
prop: 'codeName',
display: false,
rules: [
{
required: true,
message: '请输入模块名',
trigger: 'blur',
},
],
},
{
label: '表名',
prop: 'tableName',
display: false,
rules: [
{
required: true,
message: '请输入表名',
trigger: 'blur',
},
],
},
{
label: '表前缀',
prop: 'tablePrefix',
display: false,
rules: [
{
required: true,
message: '请输入表前缀',
trigger: 'blur',
},
],
},
{
label: '主键名',
prop: 'pkName',
display: false,
rules: [
{
required: true,
message: '请输入主键名',
trigger: 'blur',
},
],
},
{
label: '服务名',
prop: 'serviceName',
search: true,
rules: [
{
required: true,
message: '请输入服务名',
trigger: 'blur',
},
],
},
{
label: '包名',
prop: 'packageName',
overHidden: true,
rules: [
{
required: true,
message: '请输入包名',
trigger: 'blur',
},
],
},
{
label: '基础业务',
labelTip: '配置是否使用BladeX封装的BaseService解锁更多功能',
prop: 'baseMode',
type: 'radio',
dicUrl: '/blade-system/dict/dictionary?code=yes_no',
props: {
label: 'dictValue',
value: 'dictKey',
},
value: 2,
dataType: 'number',
hide: true,
rules: [
{
required: true,
message: '请选择基础业务',
trigger: 'blur',
},
],
},
{
label: '包装器',
labelTip: '配置是否使用Wrapper包装器来拓展Controller返回列表的字段',
prop: 'wrapMode',
type: 'radio',
dicUrl: '/blade-system/dict/dictionary?code=yes_no',
props: {
label: 'dictValue',
value: 'dictKey',
},
value: 2,
dataType: 'number',
hide: true,
rules: [
{
required: true,
message: '请选择包装器',
trigger: 'blur',
},
],
},
{
label: '远程调用',
labelTip: '配置是否使用Feign远程调用',
prop: 'feignMode',
type: 'radio',
dicUrl: '/blade-system/dict/dictionary?code=yes_no',
props: {
label: 'dictValue',
value: 'dictKey',
},
value: 1,
dataType: 'number',
hide: true,
rules: [
{
required: true,
message: '请选择基础业务',
trigger: 'blur',
},
],
},
{
label: '代码风格',
labelTip: '选择不同底层实现的代码模版',
prop: 'codeStyle',
type: 'radio',
dicData: [
{
label: 'saber3',
value: 'saber3',
},
{
label: 'element-plus',
value: 'element-plus',
},
],
value: 'saber3',
hide: true,
rules: [
{
required: true,
message: '请选择代码风格',
trigger: 'blur',
},
],
},
{
label: '后端生成路径',
prop: 'apiPath',
span: 24,
hide: true,
rules: [
{
required: true,
message: '请输入后端生成路径',
trigger: 'blur',
},
],
},
{
label: '前端生成路径',
prop: 'webPath',
span: 24,
hide: true,
rules: [
{
required: true,
message: '请输入前端生成路径',
trigger: 'blur',
},
],
},
],
};

View File

@@ -0,0 +1,229 @@
export default {
height: 'auto',
calcHeight: 50,
tip: false,
searchShow: true,
searchMenuSpan: 6,
border: true,
index: true,
viewBtn: true,
grid: true,
selection: true,
labelWidth: 120,
searchLabelWidth: 100,
menuWidth: 320,
dialogClickModal: false,
column: [
{
label: '配置名称',
labelTip: '用于定义本配置的代表名称,实际不参与代码生成',
prop: 'name',
gridRow: true,
search: true,
rules: [
{
required: true,
message: '请输入配置名称',
trigger: 'blur',
},
],
},
{
label: '配置编号',
labelTip: '用于定义本配置的代表编号,实际不参与代码生成',
prop: 'code',
gridRow: true,
search: true,
rules: [
{
required: true,
message: '请输入配置编号',
trigger: 'blur',
},
],
},
{
label: '上级菜单',
prop: 'menuId',
type: 'tree',
dicData: [],
span: 24,
hide: true,
addDisabled: false,
props: {
label: 'title',
},
rules: [
{
required: true,
message: '请选择上级菜单',
trigger: 'click',
},
],
},
{
label: '是否启用',
prop: 'status',
span: 24,
width: 85,
align: 'center',
slot: true,
gridRow: true,
addDisplay: false,
editDisplay: false,
viewDisplay: false,
},
{
label: '配置参数',
prop: 'settings',
display: false,
gridRow: true,
overHidden: true,
rules: [
{
required: true,
message: '请输入服务名',
trigger: 'blur',
},
],
},
{
label: '服务名',
prop: 'serviceName',
hide: true,
rules: [
{
required: true,
message: '请输入服务名',
trigger: 'blur',
},
],
},
{
label: '包名',
prop: 'packageName',
hide: true,
rules: [
{
required: true,
message: '请输入包名',
trigger: 'blur',
},
],
},
{
label: '基础业务',
labelTip: '配置是否使用BladeX封装的BaseService解锁更多功能',
prop: 'baseMode',
type: 'radio',
dicUrl: '/blade-system/dict/dictionary?code=yes_no',
props: {
label: 'dictValue',
value: 'dictKey',
},
value: 2,
dataType: 'number',
hide: true,
rules: [
{
required: true,
message: '请选择基础业务',
trigger: 'blur',
},
],
},
{
label: '包装器',
labelTip: '配置是否使用Wrapper包装器来拓展Controller返回列表的字段',
prop: 'wrapMode',
type: 'radio',
dicUrl: '/blade-system/dict/dictionary?code=yes_no',
props: {
label: 'dictValue',
value: 'dictKey',
},
value: 2,
dataType: 'number',
hide: true,
rules: [
{
required: true,
message: '请选择包装器',
trigger: 'blur',
},
],
},
{
label: '远程调用',
labelTip: '配置是否使用Feign远程调用',
prop: 'feignMode',
type: 'radio',
dicUrl: '/blade-system/dict/dictionary?code=yes_no',
props: {
label: 'dictValue',
value: 'dictKey',
},
value: 1,
dataType: 'number',
hide: true,
rules: [
{
required: true,
message: '请选择基础业务',
trigger: 'blur',
},
],
},
{
label: '代码风格',
labelTip: '选择不同底层实现的代码模版',
prop: 'codeStyle',
type: 'radio',
dicData: [
{
label: 'saber3',
value: 'saber3',
},
{
label: 'element-plus',
value: 'element-plus',
},
],
value: 'saber3',
hide: true,
rules: [
{
required: true,
message: '请选择代码风格',
trigger: 'blur',
},
],
},
{
label: '后端生成路径',
prop: 'apiPath',
span: 24,
hide: true,
rules: [
{
required: true,
message: '请输入后端生成路径',
trigger: 'blur',
},
],
},
{
label: '前端生成路径',
prop: 'webPath',
span: 24,
hide: true,
rules: [
{
required: true,
message: '请输入前端生成路径',
trigger: 'blur',
},
],
},
],
};

View File

@@ -0,0 +1,95 @@
export default {
height: 'auto',
calcHeight: 50,
tip: false,
searchShow: true,
searchMenuSpan: 6,
border: true,
index: true,
viewBtn: true,
grid: true,
selection: true,
labelWidth: 120,
searchLabelWidth: 100,
menuWidth: 320,
dialogWidth: 500,
dialogClickModal: false,
column: [
{
label: '数据源',
labelTip: '数据源管理配置的数据源列表',
prop: 'datasourceId',
hide: true,
editDisplay: false,
viewDisplay: false,
span: 24,
type: 'select',
dicUrl: '/blade-develop/datasource/select',
props: {
label: 'name',
value: 'id',
},
rules: [
{
required: true,
message: '请选择数据源',
trigger: 'blur',
},
],
},
{
label: '物理表名',
labelTip: '从数据源列表选择的物理表名',
filterable: true,
prop: 'modelTable',
type: 'tree',
span: 24,
hide: true,
editDisplay: false,
viewDisplay: false,
dicData: [],
props: {
label: 'comment',
value: 'name',
},
rules: [
{
required: true,
message: '请输入数据库表名',
trigger: 'blur',
},
],
},
{
label: '表单名称',
labelTip: '用于定义本配置的代表名称,默认为数据库表说明',
prop: 'name',
gridRow: true,
search: true,
span: 24,
rules: [
{
required: true,
message: '请输入表单名称',
trigger: 'blur',
},
],
},
{
label: '关联表名',
labelTip: '用于定义本配置的代表编号,默认为数据库表名,在代码快速生成时会关联匹配',
prop: 'code',
gridRow: true,
search: true,
disabled: true,
span: 24,
rules: [
{
required: true,
message: '请输入表单编号',
trigger: 'blur',
},
],
},
],
};

84
src/option/user/info.js Normal file
View File

@@ -0,0 +1,84 @@
export default {
tabs: true,
tabsActive: 1,
group: [
{
label: 'Info',
prop: 'info',
column: [
{
label: 'Avatar',
type: 'upload',
listType: 'picture-img',
propsHttp: {
res: 'data',
url: 'link',
},
action: '/blade-resource/oss/endpoint/put-file',
tip: 'Only JPG/PNG user avatars can be uploaded, and the size must not exceed 500KB.',
span: 12,
row: true,
prop: 'avatar',
},
{
prefixIcon: 'el-icon-bell',
label: 'Name',
span: 12,
row: true,
prop: 'realName',
},
{
prefixIcon: 'el-icon-user',
label: 'Username',
span: 12,
row: true,
prop: 'name',
},
{
prefixIcon: 'el-icon-iphone',
label: 'Mobile',
span: 12,
row: true,
prop: 'phone',
},
{
prefixIcon: 'el-icon-message',
label: 'EMail',
prop: 'email',
span: 12,
row: true,
},
],
},
{
label: 'Change Password',
prop: 'password',
column: [
{
prefixIcon: 'el-icon-lock',
label: 'Origin',
span: 12,
row: true,
type: 'password',
prop: 'oldPassword',
},
{
prefixIcon: 'el-icon-lock',
label: 'New',
span: 12,
row: true,
type: 'password',
prop: 'newPassword',
},
{
prefixIcon: 'el-icon-lock',
label: 'Confirm',
span: 12,
row: true,
type: 'password',
prop: 'newPassword1',
},
],
},
],
};

111
src/page/index/index.vue Executable file
View File

@@ -0,0 +1,111 @@
<template>
<el-watermark :content="watermark" style="height: 100%">
<div class="avue-contail" :class="{ 'avue--collapse': isCollapse }">
<div class="avue-layout" :class="{ 'avue-layout--horizontal': isHorizontal }">
<div class="avue-sidebar" v-show="validSidebar">
<!-- 左侧导航栏 -->
<logo />
<sidebar />
</div>
<div class="avue-main">
<!-- 顶部导航栏 -->
<top ref="top" />
<!-- 顶部标签卡 -->
<tags />
<search class="avue-view" v-show="isSearch"></search>
<!-- 主体视图层 -->
<div id="avue-view" v-show="!isSearch" v-if="isRefresh">
<router-view #="{ Component }">
<keep-alive :include="$store.getters.tagsKeep">
<component :is="Component" />
</keep-alive>
</router-view>
</div>
</div>
</div>
<!-- <wechat></wechat> -->
</div>
</el-watermark>
</template>
<script>
import index from '@/mixins/index';
import wechat from './wechat.vue';
//import { validatenull } from 'utils/validate';
import { mapGetters } from 'vuex';
import tags from './tags.vue';
import search from './search.vue';
import logo from './logo.vue';
import top from './top/index.vue';
import sidebar from './sidebar/index.vue';
import website from '@/config/website';
export default {
mixins: [index],
components: {
top,
logo,
tags,
search,
sidebar,
wechat,
},
name: 'index',
provide() {
return {
index: this,
};
},
computed: {
...mapGetters([
'isHorizontal',
'isRefresh',
'isLock',
'isCollapse',
'isSearch',
'menu',
'setting',
]),
validSidebar() {
return !(
(this.$route.meta || {}).menu === false || (this.$route.query || {}).menu === 'false'
);
},
watermark() {
return website.watermark.mode ? website.watermark.text : '';
},
},
props: [],
methods: {
//打开菜单
openMenu(item = {}) {
this.$store.dispatch('GetMenu', item.id).then(data => {
if (data.length !== 0) {
this.$router.$avueRouter.formatRoutes(data, true);
}
//当点击顶部菜单后默认打开第一个菜单
/*if (!this.validatenull(item)) {
let itemActive = {},
childItemActive = 0;
if (item.path) {
itemActive = item;
} else {
if (this.menu[childItemActive].length === 0) {
itemActive = this.menu[childItemActive];
} else {
itemActive = this.menu[childItemActive].children[childItemActive];
}
}
this.$store.commit('SET_MENU_ID', item);
this.$router.push({
path: this.$router.$avueRouter.getPath({
name: (itemActive.label || itemActive.name),
src: itemActive.path
}, itemActive.meta)
});
}*/
});
},
},
};
</script>

7
src/page/index/layout.vue Executable file
View File

@@ -0,0 +1,7 @@
<template>
<router-view #="{ Component }">
<keep-alive :include="$store.getters.tagsKeep">
<component :is="Component" />
</keep-alive>
</router-view>
</template>

44
src/page/index/logo.vue Executable file
View File

@@ -0,0 +1,44 @@
<template>
<div class="avue-logo">
<transition name="fade">
<span v-if="getScreen(isCollapse)" class="avue-logo_subtitle" key="0">
<img class="logo-img" src="/img/logo.png" />
</span>
</transition>
<transition-group name="fade">
<template v-if="getScreen(!isCollapse)">
<span class="logo-title" key="1">{{ website.indexTitle }} </span>
</template>
</transition-group>
</div>
</template>
<script>
import { mapGetters } from 'vuex';
export default {
name: 'logo',
data() {
return {};
},
created() {},
computed: {
...mapGetters(['isCollapse']),
},
methods: {},
};
</script>
<style scoped>
.logo-title {
font-size: 20px;
background-image: linear-gradient(120deg, #54b6d0 16%, #3f8bdb, #2c77f1);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
font-weight: 700;
padding-left: 30px;
}
.logo-img {
width: 40px;
margin-top: 5px;
}
</style>

178
src/page/index/search.vue Executable file
View File

@@ -0,0 +1,178 @@
<template>
<div class="avue-searchs" @click.self="handleEsc">
<div class="avue-searchs__title">菜单搜索</div>
<div class="avue-searchs__content">
<div class="avue-searchs__form">
<el-input :placeholder="$t('search')" v-model="value" @keydown.esc="handleEsc">
<template #append>
<el-button icon="el-icon-search"></el-button>
</template>
</el-input>
<p>
<el-tag>你可以使用快捷键esc 关闭</el-tag>
</p>
</div>
<div class="avue-searchs__list">
<el-scrollbar class="avue-searchs__scrollbar">
<div
class="avue-searchs__item"
v-for="(item, index) in menus"
:key="index"
@click="handleSelect(item)"
>
<i :class="[item[iconKey], 'avue-searchs__item-icon']"></i>
<span class="avue-searchs__item-title">{{ item[labelKey] }}</span>
<div class="avue-searchs__item-path">
{{ item[pathKey] }}
</div>
</div>
</el-scrollbar>
</div>
</div>
</div>
</template>
<script>
import { mapGetters } from 'vuex';
export default {
data() {
return {
value: '',
menus: [],
menuList: [],
};
},
created() {
this.getMenuList();
},
watch: {
value() {
this.querySearch();
},
menu() {
this.getMenuList();
},
},
computed: {
labelKey() {
return this.website.menu.label;
},
pathKey() {
return this.website.menu.path;
},
iconKey() {
return this.website.menu.icon;
},
childrenKey() {
return this.website.menu.children;
},
...mapGetters(['menu']),
},
methods: {
handleEsc() {
this.$store.commit('SET_IS_SEARCH', false);
},
getMenuList() {
const findMenu = list => {
for (let i = 0; i < list.length; i++) {
const ele = Object.assign({}, list[i]);
if (this.validatenull(ele[this.childrenKey])) {
this.menuList.push(ele);
} else {
findMenu(ele[this.childrenKey]);
}
}
};
this.menuList = [];
findMenu(this.menu);
this.menus = this.menuList;
},
querySearch() {
var restaurants = this.menuList;
var queryString = this.value;
this.menus = queryString ? this.menuList.filter(this.createFilter(queryString)) : restaurants;
},
createFilter(queryString) {
return restaurant => {
return restaurant[this.labelKey].toLowerCase().indexOf(queryString.toLowerCase()) === 0;
};
},
handleSelect(item) {
this.value = '';
this.$router.push({
path: item[this.pathKey],
query: item.query,
});
},
},
};
</script>
<style lang="scss" scoped>
.avue-searchs {
padding-top: 50px;
width: 100%;
height: 100%;
background-color: #fff;
z-index: 1024;
&__title {
margin-bottom: 60px;
text-align: center;
font-size: 42px;
font-weight: bold;
letter-spacing: 2px;
text-indent: 2px;
}
&__form {
margin: 0 auto 50px auto;
width: 50%;
text-align: center;
p {
margin-top: 20px;
}
}
&__scrollbar {
height: 400px;
}
&__list {
box-sizing: border-box;
padding: 20px 30px;
margin: 0 auto;
width: 70%;
border-radius: 4px;
border: 1px solid #ebeef5;
background-color: #fff;
overflow: hidden;
color: #303133;
transition: 0.3s;
box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
}
&__item {
padding: 5px 0;
border-bottom: 1px dashed #eee;
&-icon {
margin-right: 5px;
font-size: 18px;
}
&-title {
font-size: 20px;
font-weight: 500;
color: #333;
}
&-path {
line-height: 30px;
color: #666;
}
}
}
</style>

173
src/page/index/setting.vue Executable file
View File

@@ -0,0 +1,173 @@
<template>
<el-button
@click="show = true"
class="setting-icon"
type="primary"
icon="el-icon-setting"
circle
></el-button>
<el-drawer append-to-body :with-header="false" v-model="show" size="30%">
<div class="setting">
<h5>Navigator</h5>
<div class="setting-checkbox">
<el-tooltip class="item" effect="dark" content="Side Menu" placement="top">
<div
@click="setting.sidebar = 'vertical'"
class="setting-checkbox-item setting-checkbox-item--side"
></div>
</el-tooltip>
<el-tooltip class="item" effect="dark" content="Top Menu" placement="top">
<div
@click="setting.sidebar = 'horizontal'"
class="setting-checkbox-item setting-checkbox-item--top"
></div>
</el-tooltip>
</div>
<h5>Layout</h5>
<div class="setting-checkbox">
<div class="setting-item" v-for="(item, index) in list1" :key="index">
{{ item.label }}:
<el-switch v-model="setting[item.value]"></el-switch>
</div>
</div>
<h5>Debug</h5>
<div class="setting-checkbox">
<div class="setting-item" v-for="(item, index) in list2" :key="index">
{{ item.label }}:
<el-switch v-model="setting[item.value]"></el-switch>
</div>
</div>
</div>
</el-drawer>
</template>
<script>
import { mapGetters } from 'vuex';
export default {
data() {
return {
show: false,
list1: [
{
label: 'Tag',
value: 'tag',
},
{
label: 'Collapse',
value: 'collapse',
},
{
label: 'Search',
value: 'search',
},
{
label: 'Fullscreen',
value: 'fullscreen',
},
{
label: 'Theme',
value: 'theme',
},
{
label: 'Menu',
value: 'menu',
},
],
list2: [
{
label: 'Debug',
value: 'debug',
},
{
label: 'Lock',
value: 'lock',
},
],
};
},
computed: {
...mapGetters(['isHorizontal', 'setting']),
},
};
</script>
<style lang="scss">
.setting {
&-icon {
color: #666;
position: fixed;
bottom: 200px;
right: 20px;
z-index: 2048;
}
&-item {
display: flex;
justify-content: space-between;
font-size: 14px;
margin-bottom: 8px;
}
&-checkbox {
&--check {
position: absolute;
color: var(--el-color-primary);
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
}
&-item {
display: inline-block;
position: relative;
width: 44px;
height: 36px;
margin-right: 16px;
overflow: hidden;
background-color: #f0f2f5;
border-radius: 4px;
box-shadow: 0 1px 2.5px 0 rgba(0, 0, 0, 0.18);
cursor: pointer;
&:before {
position: absolute;
top: 0;
left: 0;
width: 33%;
height: 100%;
background-color: #fff;
content: '';
}
&:after {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 25%;
background-color: #fff;
content: '';
}
&--side {
&:before {
z-index: 1;
background-color: #001529;
content: '';
}
&:after {
background-color: #fff;
}
}
&--top {
&:after {
background-color: #001529;
}
}
}
}
}
</style>

View File

@@ -0,0 +1,41 @@
<template>
<el-scrollbar class="avue-menu">
<div v-if="menu && menu.length == 0 && !isHorizontal" class="avue-sidebar--tip">
{{ $t('menuTip') }}
</div>
<el-menu
unique-opened
:default-active="activeMenu"
:mode="setting.sidebar"
:collapse="getScreen(isCollapse)"
>
<sidebar-item :menu="menu"></sidebar-item>
</el-menu>
</el-scrollbar>
</template>
<script>
import { mapGetters } from 'vuex';
import sidebarItem from './sidebarItem.vue';
export default {
name: 'sidebar',
components: { sidebarItem },
inject: ['index'],
created() {
this.index.openMenu();
},
computed: {
...mapGetters(['isHorizontal', 'setting', 'menu', 'tag', 'isCollapse', 'menuId']),
activeMenu() {
const route = this.$route;
const { meta, path } = route;
if (meta.activeMenu) {
return meta.activeMenu;
}
return path;
},
},
};
</script>
<style lang="scss" scoped></style>

View File

@@ -0,0 +1,92 @@
<template>
<template v-for="item in menu">
<el-menu-item
v-if="validatenull(item[childrenKey]) && validRoles(item)"
:index="getPath(item)"
@click="open(item)"
:key="item[labelKey]"
>
<i :class="item[iconKey]"></i>
<template #title>
<span :alt="item[pathKey]">{{ getTitle(item) }}</span>
</template>
</el-menu-item>
<el-sub-menu
v-else-if="!validatenull(item[childrenKey]) && validRoles(item)"
:index="getPath(item)"
:key="item[labelKey]"
>
<template #title>
<i :class="item[iconKey]"></i>
<span>{{ getTitle(item) }}</span>
</template>
<template v-for="(child, cindex) in item[childrenKey]" :key="child[labelKey]">
<el-menu-item
:index="getPath(child)"
@click="open(child)"
v-if="validatenull(child[childrenKey])"
>
<i :class="child[iconKey]"></i>
<template #title>
<span>{{ getTitle(child) }}</span>
</template>
</el-menu-item>
<sidebar-item v-else :menu="[child]" :key="cindex"></sidebar-item>
</template>
</el-sub-menu>
</template>
</template>
<script>
import { mapGetters } from 'vuex';
import { validatenull } from 'utils/validate';
import website from '@/config/website';
export default {
name: 'sidebarItem',
data() {
return {
props: website.menu,
};
},
props: {
menu: Array,
},
computed: {
...mapGetters(['roles']),
labelKey() {
return this.props.label;
},
pathKey() {
return this.props.path;
},
queryKey() {
return this.props.query;
},
iconKey() {
return this.props.icon;
},
childrenKey() {
return this.props.children;
},
},
methods: {
validatenull,
getPath(item) {
return item[this.pathKey];
},
getTitle(item) {
return this.$router.$avueRouter.generateTitle(item, this.props);
},
validRoles(item) {
item.meta = item.meta || {};
return item.meta.roles ? item.meta.roles.includes(this.roles) : true;
},
open(item) {
this.$router.push({
path: item[this.pathKey],
query: item[this.queryKey],
});
},
},
};
</script>

192
src/page/index/tags.vue Executable file
View File

@@ -0,0 +1,192 @@
<template>
<div class="avue-tags" v-if="setting.tag" @click="contextmenuFlag = false">
<!-- tag盒子 -->
<div
v-if="contextmenuFlag"
class="avue-tags__contentmenu"
:style="{ left: contentmenuX + 'px', top: contentmenuY + 'px' }"
>
<div class="item" @click="closeOthersTags">{{ $t('tagsView.closeOthers') }}</div>
<div class="item" @click="closeAllTags">{{ $t('tagsView.closeAll') }}</div>
<div class="item" @click="clearCacheTags">{{ $t('tagsView.clearCache') }}</div>
</div>
<div class="avue-tags__box">
<el-tabs
v-model="active"
type="card"
@contextmenu="handleContextmenu"
:closable="tagLen !== 1"
@tab-click="openTag"
@edit="menuTag"
>
<el-tab-pane
v-for="(item, index) in tagList"
:key="index"
:label="generateTitle(item)"
:name="item.fullPath"
>
<template #label>
<span>
{{ generateTitle(item) }}
<i
class="el-icon-refresh"
:class="{ turn: refresh }"
@click="handleRefresh"
v-if="active === item.fullPath"
></i>
</span>
</template>
</el-tab-pane>
</el-tabs>
<el-dropdown class="avue-tags__menu">
<el-button type="primary">
{{ $t('tagsView.menu') }}
<i class="el-icon-arrow-down el-icon--right"></i>
</el-button>
<template #dropdown>
<el-dropdown-menu>
<el-dropdown-item @click="openSearch"
><i class="icon-fangda" /> {{ $t('tagsView.search') }}</el-dropdown-item
>
<el-dropdown-item @click="closeOthersTags"
><i class="icon-fangkuai1" /> {{ $t('tagsView.closeOthers') }}
</el-dropdown-item>
<el-dropdown-item @click="closeAllTags"
><i class="icon-cuowukongxin" /> {{ $t('tagsView.closeAll') }}</el-dropdown-item
>
<el-dropdown-item @click="clearCacheTags"
><i class="icon-dingwei" /> {{ $t('tagsView.clearCache') }}
</el-dropdown-item>
</el-dropdown-menu>
</template>
</el-dropdown>
</div>
</div>
</template>
<script>
import { mapGetters } from 'vuex';
import { clearCache } from '@/api/user';
export default {
name: 'tags',
data() {
return {
refresh: false,
active: '',
contentmenuX: '',
contentmenuY: '',
contextmenuFlag: false,
};
},
watch: {
tag: {
handler(val) {
this.active = val.fullPath;
},
immediate: true,
},
contextmenuFlag() {
window.addEventListener('mousedown', this.watchContextmenu);
},
},
computed: {
...mapGetters(['tagWel', 'tagList', 'tag', 'setting']),
tagLen() {
return this.tagList.length || 0;
},
},
methods: {
openSearch() {
this.$store.commit('SET_IS_SEARCH', true);
},
handleRefresh() {
this.refresh = true;
this.$store.commit('SET_IS_REFRESH', false);
setTimeout(() => {
this.$store.commit('SET_IS_REFRESH', true);
}, 100);
setTimeout(() => {
this.refresh = false;
}, 500);
},
generateTitle(item) {
return this.$router.$avueRouter.generateTitle({
...item,
...{
label: item.name,
},
});
},
watchContextmenu(event) {
if (!this.$el.contains(event.target) || event.button !== 0) {
this.contextmenuFlag = false;
}
window.removeEventListener('mousedown', this.watchContextmenu);
},
handleContextmenu(event) {
let target = event.target;
let flag = false;
if (target.className.indexOf('el-tabs__item') > -1) flag = true;
else if (target.parentNode.className.indexOf('el-tabs__item') > -1) {
target = target.parentNode;
flag = true;
}
if (flag) {
event.preventDefault();
event.stopPropagation();
this.contentmenuX = event.clientX;
this.contentmenuY = event.clientY;
this.tagName = target.getAttribute('aria-controls').slice(5);
this.contextmenuFlag = true;
}
},
menuTag(value, action) {
if (action === 'remove') {
let { tag, key } = this.findTag(value);
this.$store.commit('DEL_TAG', tag);
if (tag.fullPath === this.tag.fullPath) {
tag = this.tagList[key - 1];
this.$router.push({
path: tag.path,
query: tag.query,
});
}
}
},
openTag(item) {
let value = item.props.name;
let { tag } = this.findTag(value);
this.$router.push({
path: tag.path,
query: tag.query,
});
},
findTag(fullPath) {
let tag = this.tagList.find(item => item.fullPath === fullPath);
let key = this.tagList.findIndex(item => item.fullPath === fullPath);
return { tag, key };
},
closeOthersTags() {
this.contextmenuFlag = false;
this.$store.commit('DEL_TAG_OTHER');
},
closeAllTags() {
this.contextmenuFlag = false;
this.$store.commit('DEL_ALL_TAG');
this.$router.push(this.tagWel);
},
clearCacheTags() {
this.$confirm('是否需要清除缓存?', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
}).then(() => {
clearCache().then(() => {
this.contextmenuFlag = false;
this.$message.success('清除完毕');
});
});
},
},
};
</script>

356
src/page/index/top/index.vue Executable file
View File

@@ -0,0 +1,356 @@
<template>
<div class="avue-top">
<div class="top-bar__left">
<div
class="avue-breadcrumb"
:class="[{ 'avue-breadcrumb--active': isCollapse }]"
v-if="setting.collapse && !isHorizontal"
>
<i class="icon-navicon" @click="setCollapse"></i>
</div>
</div>
<div class="top-bar__title">
<top-menu ref="topMenu" v-if="setting.menu"></top-menu>
<top-search class="top-bar__item" v-if="setting.search"></top-search>
</div>
<div class="top-bar__right">
<div v-if="setting.color" class="top-bar__item">
<top-color></top-color>
</div>
<div v-if="setting.theme" class="top-bar__item">
<top-theme></top-theme>
</div>
<div v-if="setting.lock" class="top-bar__item">
<top-lock></top-lock>
</div>
<div class="top-bar__item">
<top-lang></top-lang>
</div>
<div class="top-bar__item" v-if="setting.fullscreen">
<top-full></top-full>
</div>
<div class="top-bar__item" v-if="setting.debug">
<top-logs></top-logs>
</div>
<div class="top-user">
<img class="top-bar__img" :src="userInfo.avatar" />
<el-dropdown :hide-on-click="false">
<span class="el-dropdown-link">
{{ userInfo.real_name }}
<el-icon class="el-icon--right">
<arrow-down />
</el-icon>
</span>
<template #dropdown>
<el-dropdown-menu>
<el-dropdown-item @click="toDashboard">
<i class="icon-zuzhixiaxia" /> {{ $t('navbar.dashboard') }}
</el-dropdown-item>
<el-dropdown-item @click="toInfo">
<i class="icon-yonghu" />{{ $t('navbar.userinfo') }}
</el-dropdown-item>
<el-dropdown-item divided>
<i class="icon-hezuohuobanmiyueguanli" />
<el-tooltip :content="roleName" placement="top" trigger="click">
<strong>
{{
func.contains(roleId, ',')
? $t('navbar.roleName')
: $t('navbar.currentRoleName')
}}: {{ func.truncateString(roleName) }}
</strong>
</el-tooltip>
</el-dropdown-item>
<el-dropdown-item
v-if="Object.keys(roleObj).length < 5"
v-for="(name, id) in roleObj"
:key="id"
@click="toRole(id, name)"
>
<i class="icon-changjingguanli" />
{{ $t('navbar.switchRoleTo') }}: {{ name }}
</el-dropdown-item>
<el-dropdown-item v-if="Object.keys(roleObj).length >= 5" @click="switchRole">
<i class="icon-changjingguanli" />
{{ $t('navbar.switchRole') }}
</el-dropdown-item>
<el-dropdown-item divided>
<i class="iconfont iconicon_group" />
<el-tooltip :content="deptName" placement="top" trigger="click">
<strong>
{{
func.contains(deptId, ',')
? $t('navbar.deptName')
: $t('navbar.currentDeptName')
}}: {{ func.truncateString(deptName) }}
</strong>
</el-tooltip>
</el-dropdown-item>
<el-dropdown-item
v-if="Object.keys(deptObj).length < 5"
v-for="(name, id) in deptObj"
:key="id"
@click="toDept(id, name)"
>
<i class="icon-guanlianshebei" />
{{ $t('navbar.switchDeptTo') }}: {{ name }}
</el-dropdown-item>
<el-dropdown-item v-if="Object.keys(deptObj).length >= 5" @click="switchDept">
<i class="icon-guanlianshebei" />
{{ $t('navbar.switchDept') }}
</el-dropdown-item>
<el-dropdown-item @click="logout" divided>
<i class="icon-tuichu" /> {{ $t('navbar.logOut') }}
</el-dropdown-item>
</el-dropdown-menu>
</template>
</el-dropdown>
<top-setting></top-setting>
<el-dialog title="请选择身份信息后切换" append-to-body v-model="userBox" width="400px">
<avue-form :option="userOption" v-model="userForm" @submit="toAll" />
</el-dialog>
</div>
</div>
</div>
</template>
<script>
import { mapGetters } from 'vuex';
import topLock from './top-lock.vue';
import topMenu from './top-menu.vue';
import topSearch from './top-search.vue';
import topTheme from './top-theme.vue';
import topLogs from './top-logs.vue';
import topColor from './top-color.vue';
import topLang from './top-lang.vue';
import topFull from './top-full.vue';
import topSetting from '../setting.vue';
import { getUserInfo as getUerDetailInfo } from '@/api/system/user';
import { getUserInfo as getUerOauthInfo } from '@/api/user';
import { validatenull } from '@/utils/validate';
import func from '@/utils/func';
export default {
components: {
topLock,
topMenu,
topSearch,
topTheme,
topLogs,
topColor,
topLang,
topFull,
topSetting,
},
name: 'top',
data() {
return {
userId: '',
roleId: '',
roleName: '',
roleObj: {},
deptId: '',
deptName: '',
deptObj: {},
userBox: false,
userForm: {
deptId: '',
roleId: '',
},
userOption: {
labelWidth: 70,
submitBtn: true,
emptyBtn: false,
submitText: '切 换',
column: [
{
label: '部门',
prop: 'deptId',
type: 'select',
props: {
label: 'deptName',
value: 'id',
},
dicUrl: '/blade-system/dept/select',
filterable: true,
span: 24,
display: false,
rules: [
{
required: true,
message: '请选择部门',
trigger: 'blur',
},
],
},
{
label: '角色',
prop: 'roleId',
type: 'select',
props: {
label: 'roleName',
value: 'id',
},
dicUrl: '/blade-system/role/select',
filterable: true,
span: 24,
display: false,
rules: [
{
required: true,
message: '请选择角色',
trigger: 'blur',
},
],
},
],
},
};
},
filters: {},
created() {
this.init();
},
computed: {
func() {
return func;
},
...mapGetters([
'setting',
'userInfo',
'tagWel',
'tagList',
'isCollapse',
'tag',
'logsLen',
'logsFlag',
'isHorizontal',
]),
},
methods: {
init() {
getUerDetailInfo().then(res => {
// 获取绑定信息
const roleId = res.data.data.roleId;
const roleName = res.data.data.roleName;
const roleIds = roleId.split(',');
const roleNames = roleName.split(',');
const deptId = res.data.data.deptId;
const deptName = res.data.data.deptName;
const deptIds = deptId.split(',');
const deptNames = deptName.split(',');
roleIds.forEach((id, index) => {
if (id === this.roleId) {
this.roleName = roleNames[index];
} else {
this.roleObj[id] = roleNames[index];
}
});
deptIds.forEach((id, index) => {
if (id === this.deptId) {
this.deptName = deptNames[index];
} else {
this.deptObj[id] = deptNames[index];
}
});
if (validatenull(this.roleName)) {
this.roleName = roleName;
}
if (validatenull(this.deptName)) {
this.deptName = deptName;
}
});
getUerOauthInfo().then(res => {
this.userId = res.data.userId;
this.roleId = res.data.roleId;
this.deptId = res.data.deptId;
});
},
toDashboard() {
this.$router.push({ path: '/' });
},
toInfo() {
this.$router.push({ path: '/info/index' });
},
toRole(roleId, name) {
const userInfo = { roleId, deptId: this.deptId };
this.switchTo(userInfo, name);
},
toDept(deptId, name) {
const userInfo = { roleId: this.roleId, deptId };
this.switchTo(userInfo, name);
},
toAll(form, done) {
let userInfo;
if (!validatenull(form.deptId)) {
userInfo = { roleId: this.roleId, deptId: form.deptId };
}
if (!validatenull(form.roleId)) {
userInfo = { roleId: form.roleId, deptId: this.deptId };
}
this.switchTo(userInfo);
done();
},
switchRole() {
const columnRole = this.findObject(this.userOption.column, 'roleId');
const columnDept = this.findObject(this.userOption.column, 'deptId');
columnRole.dicUrl = `/blade-system/role/select?userId=${this.userId}`;
columnRole.display = true;
columnDept.dicUrl = '';
columnDept.display = false;
this.userBox = true;
},
switchDept() {
const columnDept = this.findObject(this.userOption.column, 'deptId');
const columnRole = this.findObject(this.userOption.column, 'roleId');
columnDept.dicUrl = `/blade-system/dept/select?userId=${this.userId}`;
columnDept.display = true;
columnRole.dicUrl = '';
columnRole.display = false;
this.userBox = true;
},
switchTo(userInfo, name) {
const tipMessage = validatenull(name)
? this.$t('navbar.switchTip') + ' ? '
: this.$t('navbar.switchTip') + ` [${name}] ?`;
this.$confirm(tipMessage, this.$t('confirmTip'), {
confirmButtonText: this.$t('submitText'),
cancelButtonText: this.$t('cancelText'),
type: 'warning',
}).then(() => {
this.$store
.dispatch('RefreshToken', userInfo)
.then(() => {
this.$message.success(this.$t('navbar.switchSuccess'));
location.reload();
})
.catch(err => {
console.log(err);
});
});
},
setCollapse() {
this.$store.commit('SET_COLLAPSE');
},
logout() {
this.$confirm(this.$t('logoutTip'), this.$t('confirmTip'), {
confirmButtonText: this.$t('submitText'),
cancelButtonText: this.$t('cancelText'),
type: 'warning',
}).then(() => {
this.$store.dispatch('LogOut').then(() => {
if (this.website.oauth2.ssoMode) {
window.location.href =
this.website.oauth2.ssoBaseUrl +
this.website.oauth2.ssoLogoutUrl +
this.website.oauth2.redirectUri;
} else {
this.$router.push({ path: '/login' });
}
});
});
},
},
};
</script>
<style lang="scss" scoped></style>

View File

@@ -0,0 +1,75 @@
<template>
<el-color-picker
size="small"
class="theme-picker"
popper-class="theme-picker-dropdown"
v-model="themeVal"
></el-color-picker>
</template>
<script>
import { mapGetters } from 'vuex'; // default color
export default {
name: 'topColor',
data() {
return {
themeVal: '',
};
},
created() {
this.themeVal = this.colorName || '#2C77F1';
},
watch: {
themeVal(val, oldVal) {
this.$store.commit('SET_COLOR_NAME', val);
this.updateTheme(val, oldVal);
},
},
computed: {
...mapGetters(['colorName']),
},
methods: {
hexToRgb(str) {
let hexs = '';
str = str.replace('#', '');
hexs = str.match(/../g);
for (let i = 0; i < 3; i++) hexs[i] = parseInt(hexs[i], 16);
return hexs;
},
// r 代表红色 | g 代表绿色 | b 代表蓝色
rgbToHex(r, g, b) {
let hexs = [r.toString(16), g.toString(16), b.toString(16)];
for (let i = 0; i < 3; i++) if (hexs[i].length == 1) hexs[i] = `0${hexs[i]}`;
return `#${hexs.join('')}`;
},
getDarkColor(color, level) {
let rgb = this.hexToRgb(color);
for (let i = 0; i < 3; i++) rgb[i] = Math.floor(rgb[i] * (1 - level));
return this.rgbToHex(rgb[0], rgb[1], rgb[2]);
},
// color 颜色值字符串 | level 加深的程度,限0-1之间
getLightColor(color, level) {
let rgb = this.hexToRgb(color);
for (let i = 0; i < 3; i++) rgb[i] = Math.floor((255 - rgb[i]) * level + rgb[i]);
return this.rgbToHex(rgb[0], rgb[1], rgb[2]);
},
updateTheme(e) {
if (!e) return;
// e就是选择了的颜色
const pre = '--el-color-primary';
const el = document.documentElement;
el.style.setProperty(pre, e);
// 这里是覆盖原有颜色的核心代码
for (let i = 1; i < 10; i += 1) {
document.documentElement.style.setProperty(
`${pre}-light-${i}`,
`${this.getLightColor(e, i / 10)}`
);
}
},
},
};
</script>

View File

@@ -0,0 +1,24 @@
<template>
<i :class="isFullScren ? 'icon-tuichuquanping' : 'icon-quanping'" @click="handleScreen"></i>
</template>
<script>
import { mapGetters } from 'vuex';
import { fullscreenToggel, listenfullscreen } from 'utils/util';
export default {
computed: {
...mapGetters(['isFullScren']),
},
mounted() {
listenfullscreen(this.setScreen);
},
methods: {
setScreen() {
this.$store.commit('SET_FULLSCREN');
},
handleScreen() {
fullscreenToggel();
},
},
};
</script>

40
src/page/index/top/top-lang.vue Executable file
View File

@@ -0,0 +1,40 @@
<template>
<el-dropdown trigger="click" @command="handleSetLanguage">
<i class="icon-zhongyingwen"></i>
<template #dropdown>
<el-dropdown-menu>
<el-dropdown-item :disabled="language === 'zh-cn'" command="zh-cn">中文</el-dropdown-item>
<el-dropdown-item :disabled="language === 'en'" command="en">English</el-dropdown-item>
</el-dropdown-menu>
</template>
</el-dropdown>
</template>
<script>
import { mapGetters } from 'vuex';
export default {
name: 'top-lang',
data() {
return {};
},
created() {},
mounted() {},
computed: {
...mapGetters(['language', 'tag']),
},
props: [],
methods: {
handleSetLanguage(lang) {
this.$i18n.locale = lang;
this.$store.commit('SET_LANGUAGE', lang);
let tag = this.tag;
let title = this.$router.$avueRouter.generateTitle(tag);
//根据当前的标签也获取label的值动态设置浏览器标题
this.$router.$avueRouter.setTitle(title);
},
},
};
</script>
<style lang="scss" scoped></style>

67
src/page/index/top/top-lock.vue Executable file
View File

@@ -0,0 +1,67 @@
<template>
<span v-if="text" @click="handleLock">{{ text }}</span>
<i v-else class="icon-suoping" @click="handleLock"></i>
<el-dialog title="Set Lock Code" v-model="box" width="30%" append-to-body>
<el-form :model="form" ref="form" label-width="80px">
<el-form-item
label="Code"
prop="passwd"
:rules="[{ required: true, message: 'Code can not be empty' }]"
>
<el-input v-model="form.passwd" placeholder="Please input code">
<template #append>
<el-button @click="handleSetLock" icon="el-icon-lock"></el-button>
</template>
</el-input>
</el-form-item>
</el-form>
</el-dialog>
</template>
<script>
import { validatenull } from 'utils/validate';
import { mapGetters } from 'vuex';
export default {
name: 'top-lock',
data() {
return {
box: false,
form: {
passwd: '',
},
};
},
created() {},
mounted() {},
computed: {
...mapGetters(['lockPasswd']),
},
props: {
text: String,
},
methods: {
handleSetLock() {
this.$refs['form'].validate(valid => {
if (valid) {
this.$store.commit('SET_LOCK_PASSWD', this.form.passwd);
this.handleLock();
}
});
},
handleLock() {
if (validatenull(this.lockPasswd)) {
this.box = true;
return;
}
this.$store.commit('SET_LOCK');
setTimeout(() => {
this.$router.push({ path: '/lock' });
}, 100);
},
},
components: {},
};
</script>
<style lang="scss" scoped></style>

86
src/page/index/top/top-logs.vue Executable file
View File

@@ -0,0 +1,86 @@
<template>
<span @click="logsFlag ? '' : handleOpen()">
<el-badge :value="logsFlag ? '' : logsLen" :max="99">
<i class="icon-rizhi1"></i>
</el-badge>
<el-dialog title="日志" v-model="box" width="60%" append-to-body>
<el-button type="primary" icon="el-icon-upload" @click="send">上传服务器</el-button>
<el-button type="danger" icon="el-icon-delete" @click="clear">清空本地日志</el-button>
<el-table :data="logsList">
<el-table-column prop="type" label="类型" width="50px"> </el-table-column>
<el-table-column prop="url" label="地址" show-overflow-tooltip width="180">
</el-table-column>
<el-table-column prop="message" show-overflow-tooltip label="内容"> </el-table-column>
<el-table-column prop="stack" show-overflow-tooltip label="错误堆栈"> </el-table-column>
<el-table-column prop="time" label="时间"> </el-table-column>
</el-table>
</el-dialog>
</span>
</template>
<script>
import { mapGetters } from 'vuex';
export default {
name: 'top-logs',
data() {
return {
box: false,
};
},
created() {},
mounted() {},
computed: {
...mapGetters(['logsList', 'logsFlag', 'logsLen']),
},
props: [],
methods: {
handleOpen() {
this.box = true;
},
send() {
this.$confirm('确定上传本地日志到服务器?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
})
.then(() => {
this.$store.dispatch('SendLogs').then(() => {
this.box = false;
this.$message({
type: 'success',
message: '发送成功!',
});
});
})
.catch(() => {});
},
clear() {
this.$confirm('确定清空本地日志记录?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
})
.then(() => {
this.$store.commit('CLEAR_LOGS');
this.box = false;
this.$message({
type: 'success',
message: '清空成功!',
});
})
.catch(() => {});
},
},
};
</script>
<style lang="scss" scoped>
.code {
font-size: 12px;
display: block;
font-family: monospace;
white-space: pre;
margin: 1em 0px;
}
</style>

58
src/page/index/top/top-menu.vue Executable file
View File

@@ -0,0 +1,58 @@
<template>
<el-menu class="top-menu" :default-active="activeIndex" mode="horizontal" text-color="#333">
<el-menu-item index="0" @click="openHome(itemHome)">
<template #title>
<i :class="itemHome.source" style="padding-right: 5px"></i>
<span>{{ itemHome.name }}</span>
</template>
</el-menu-item>
<template v-for="(item, index) in items" :key="index">
<el-menu-item :index="item.id + ''" @click="openMenu(item)">
<template #title>
<i :class="item.source" style="padding-right: 5px"></i>
<span>{{ item.name }}</span>
</template>
</el-menu-item>
</template>
</el-menu>
</template>
<script>
import { mapGetters } from 'vuex';
export default {
name: 'top-menu',
data() {
return {
itemHome: {
name: 'Index',
source: 'iconfont iconicon_work',
},
activeIndex: '0',
items: [],
};
},
inject: ['index'],
created() {
this.getMenu();
},
computed: {
...mapGetters(['tagCurrent', 'menu', 'tagWel']),
},
methods: {
openMenu(item) {
this.index.openMenu(item);
},
openHome(itemHome) {
this.index.openMenu(itemHome);
this.$router.push(this.tagWel);
},
getMenu() {
this.$store.dispatch('GetTopMenu').then(res => {
this.items = res;
});
},
},
};
</script>

120
src/page/index/top/top-search.vue Executable file
View File

@@ -0,0 +1,120 @@
<template>
<el-autocomplete
class="top-search"
popper-class="my-autocomplete"
v-model="value"
:fetch-suggestions="querySearch"
:placeholder="$t('search')"
@select="handleSelect"
>
<template #="{ item }">
<i :class="[item[iconKey], 'icon']"></i>
<div class="name">{{ item[labelKey] }}</div>
<div class="addr">{{ item[pathKey] }}</div>
</template>
</el-autocomplete>
</template>
<script>
import { mapGetters } from 'vuex';
export default {
data() {
return {
value: '',
menuList: [],
};
},
created() {
this.getMenuList();
},
watch: {
menu() {
this.getMenuList();
},
},
computed: {
labelKey() {
return this.website.menu.label;
},
pathKey() {
return this.website.menu.path;
},
iconKey() {
return this.website.menu.icon;
},
childrenKey() {
return this.website.menu.children;
},
...mapGetters(['menu']),
},
methods: {
getMenuList() {
const findMenu = list => {
for (let i = 0; i < list.length; i++) {
const ele = Object.assign({}, list[i]);
if (this.validatenull(ele[this.childrenKey])) {
this.menuList.push(ele);
} else {
findMenu(ele[this.childrenKey]);
}
}
};
this.menuList = [];
findMenu(this.menu);
},
querySearch(queryString, cb) {
var restaurants = this.menuList;
var results = queryString ? restaurants.filter(this.createFilter(queryString)) : restaurants;
// 调用 callback 返回建议列表的数据
cb(results);
},
createFilter(queryString) {
return restaurant => {
return restaurant[this.labelKey].toLowerCase().indexOf(queryString.toLowerCase()) === 0;
};
},
handleSelect(item) {
this.value = '';
this.$router.push({
path: item[this.pathKey],
query: item.query,
});
},
},
};
</script>
<style lang="scss">
.my-autocomplete {
li {
line-height: normal !important;
padding: 7px !important;
.icon {
margin-right: 5px;
display: inline-block;
vertical-align: middle;
}
.name {
display: inline-block;
text-overflow: ellipsis;
overflow: hidden;
vertical-align: middle;
}
.addr {
padding-top: 5px;
width: 100%;
font-size: 12px;
color: #b4b4b4;
}
.highlighted .addr {
color: #ddd;
}
}
}
</style>

119
src/page/index/top/top-theme.vue Executable file
View File

@@ -0,0 +1,119 @@
<template>
<div>
<el-dialog title="Option" v-model="box" width="50%">
<el-radio-group v-model="text" class="list">
<el-row :span="24">
<el-col v-for="(item, index) in list" :key="index" :md="4" :xs="12" :sm="4">
<el-radio :label="item.value">{{ item.name }}</el-radio>
</el-col>
</el-row>
</el-radio-group>
</el-dialog>
<span>
<i class="icon-zhuti" @click="open"></i>
</span>
</div>
</template>
<script>
import { setTheme } from 'utils/util';
import { mapGetters } from 'vuex';
export default {
data() {
return {
box: false,
text: '',
list: [
{
name: 'default',
value: 'default',
},
{
name: 'theme-white',
value: 'theme-white',
},
{
name: 'theme-dark',
value: 'theme-dark',
},
{
name: 'theme-go',
value: 'theme-go',
},
{
name: 'theme-hey',
value: 'theme-hey',
},
{
name: 'theme-star',
value: 'theme-star',
},
{
name: 'theme-vip',
value: 'theme-vip',
},
{
name: 'theme-bule',
value: 'theme-bule',
},
{
name: 'theme-iview',
value: 'theme-iview',
},
{
name: 'theme-cool',
value: 'theme-cool',
},
{
name: 'theme-d2',
value: 'theme-d2',
},
{
name: 'theme-lte',
value: 'theme-lte',
},
{
name: 'theme-beautiful',
value: 'theme-beautiful',
},
{
name: 'mac-os',
value: 'mac-os',
},
],
};
},
watch: {
text: function (val) {
this.$store.commit('SET_THEME_NAME', val);
setTheme(val);
if (this.$store.getters.isMacOs) {
this.$router.push(this.tagWel);
setTimeout(() => location.reload());
}
},
},
computed: {
...mapGetters(['themeName', 'tagWel']),
},
mounted() {
this.text = this.themeName;
if (!this.text) {
this.text = '';
}
},
methods: {
open() {
this.box = true;
},
},
};
</script>
<style lang="scss" scoped>
.list {
width: 100%;
}
</style>

59
src/page/index/wechat.vue Normal file
View File

@@ -0,0 +1,59 @@
<template>
<el-dialog
center
:show-close="false"
:close-on-press-escape="false"
:close-on-click-modal="false"
append-to-body
v-model="dialogVisible"
title="人机识别"
width="400px"
>
<center>
<span>
扫码下方二维码,回复<b>【验证码】</b><br />
<span style="color: red">获得「验证码 + 交流群(一起摸🐟)」</span>
</span>
<br />
<br />
<img width="200" src="https://avuejs.com/images/icon/wechat.png" />
<br />
<br />
<el-input v-model="value" placeholder="请输入验证码"></el-input>
</center>
<template #footer>
<span class="dialog-footer">
<el-button type="primary" @click="submit">确 认</el-button>
</span>
</template>
</el-dialog>
</template>
<script>
export default {
data() {
return {
value: '',
dialogVisible: false,
};
},
created() {
if (window.localStorage.getItem('avue_lock')) {
return;
}
this.dialogVisible = true;
},
methods: {
submit() {
if (this.value == '') {
this.$message.error('验证码不能为空');
return;
} else if (this.value != 'avue') {
this.$message.error('验证码不正确');
return;
}
this.dialogVisible = false;
window.localStorage.setItem('avue_lock', true);
},
},
};
</script>

108
src/page/lock/index.vue Executable file
View File

@@ -0,0 +1,108 @@
<template>
<div class="login-container" @keyup.enter="handleLogin">
<div class="login-time">
{{ time }}
</div>
<div class="login-weaper">
<div class="login-left animate__animated animate__fadeInLeft">
<img class="img" src="/img/logo.png" alt="" />
<p class="title">{{ $t('login.info') }}</p>
</div>
<div class="login-border animate__animated animate__fadeInRight">
<div class="login-main">
<div class="lock-form animate__animated animate__bounceInDown">
<div
class="animate__animated"
:class="{ shake: passwdError, animate__bounceOut: pass }"
>
<h3 style="color: #333">{{ userInfo.username }}</h3>
<el-input
placeholder="please input code"
type="password"
class="input-with-select animated"
v-model="passwd"
@keyup.enter="handleLogin"
>
<template #append>
<i class="icon-bofangqi-suoping" @click="handleLogin"></i>
&nbsp; &nbsp;
<i class="icon-tuichu" @click="handleLogout"></i>
</template>
</el-input>
</div>
</div>
</div>
</div>
</div>
</div>
</template>
<script>
import { mapGetters } from 'vuex';
import { removeRefreshToken, removeToken } from '@/utils/auth';
export default {
name: 'lock',
data() {
return {
time: '',
passwd: '',
passwdError: false,
pass: false,
};
},
created() {
this.getTime();
setInterval(() => {
this.getTime();
}, 1000);
},
mounted() {},
computed: {
...mapGetters(['userInfo', 'tag', 'lockPasswd']),
},
props: [],
methods: {
getTime() {
this.time = this.$dayjs().format('YYYY-MM-DD HH:mm:ss');
},
handleLogout() {
this.$confirm('Quit system, to be continue?', 'Tips', {
confirmButtonText: 'Confirm',
cancelButtonText: 'Cancel',
type: 'warning',
}).then(() => {
this.$store.dispatch('LogOut').then(() => {
// 清除token信息
removeToken();
removeRefreshToken();
this.$router.push({ path: '/login' });
});
});
},
handleLogin() {
if (this.passwd !== this.lockPasswd) {
this.passwd = '';
this.$message({
message: 'Error code, please retry!',
type: 'error',
});
this.passwdError = true;
setTimeout(() => {
this.passwdError = false;
}, 1000);
return;
}
this.pass = true;
setTimeout(() => {
this.$store.commit('CLEAR_LOCK');
this.$router.push({
path: this.tag.path,
});
}, 1000);
},
},
components: {},
};
</script>
<style lang="scss"></style>

18
src/page/login/authredirect.vue Executable file
View File

@@ -0,0 +1,18 @@
<template>
<div></div>
</template>
<script>
export default {
name: 'authredirect',
created() {
window.close();
const params = this.$route.query;
const state = params.state;
const code = params.code;
window.opener.location.href = `${window.location.origin}/#/login?state=${state}&code=${code}`;
},
};
</script>
<style></style>

193
src/page/login/codelogin.vue Executable file
View File

@@ -0,0 +1,193 @@
<template>
<el-form
class="login-form"
status-icon
:rules="loginRules"
ref="loginForm"
:model="loginForm"
label-width="0"
>
<el-form-item v-if="tenantMode" prop="tenantId">
<el-input
@keyup.enter="handleLogin"
v-model="loginForm.tenantId"
auto-complete="off"
:placeholder="$t('login.tenantId')"
>
<template #prefix>
<i class="icon-quanxian" />
</template>
</el-input>
</el-form-item>
<el-form-item prop="phone">
<el-input
@keyup.enter="handleLogin"
v-model="loginForm.phone"
auto-complete="off"
:placeholder="$t('login.phone')"
>
<template #prefix>
<i class="icon-shouji" />
</template>
</el-input>
</el-form-item>
<el-form-item prop="code">
<el-input
@keyup.enter="handleLogin"
v-model="loginForm.codeValue"
auto-complete="off"
:placeholder="$t('login.code')"
>
<template #prefix>
<i class="icon-yanzhengma"></i>
</template>
<template #append>
<span @click="handleSend" class="msg-text" :class="[{ display: msgKey }]">{{
msgText
}}</span>
</template>
</el-input>
</el-form-item>
<el-form-item>
<el-button type="primary" @click.prevent="handleLogin" class="login-submit">{{
$t('login.submit')
}}</el-button>
</el-form-item>
</el-form>
</template>
<script>
import { isvalidatemobile } from '@/utils/validate';
import { mapGetters } from 'vuex';
import { sendSms } from '@/api/user';
import { getTopUrl } from '@/utils/util';
import { info } from '@/api/system/tenant';
import { encrypt } from '@/utils/sm2';
export default {
name: 'codelogin',
data() {
const validatePhone = (rule, value, callback) => {
if (isvalidatemobile(value)[0]) {
callback(new Error(isvalidatemobile(value)[1]));
} else {
callback();
}
};
return {
tenantMode: this.website.tenantMode,
msgText: '',
msgTime: '',
msgKey: false,
loginForm: {
tenantId: '000000',
phone: '',
codeValue: '',
codeId: '',
},
loginRules: {
phone: [{ required: true, trigger: 'blur', validator: validatePhone }],
codeValue: [{ required: true, trigger: 'blur' }],
},
};
},
created() {
this.getTenant();
this.getMsg();
},
mounted() {},
computed: {
...mapGetters(['tagWel']),
config() {
return {
MSGINIT: this.$t('login.msgText'),
MSGSCUCCESS: this.$t('login.msgSuccess'),
MSGTIME: 60,
};
},
},
props: [],
methods: {
handleSend() {
this.$refs.loginForm.validate(valid => {
if (valid) {
if (this.msgKey) return;
this.msgText = this.msgTime + this.config.MSGSCUCCESS;
this.msgKey = true;
const time = setInterval(() => {
this.msgTime--;
this.msgText = this.msgTime + this.config.MSGSCUCCESS;
if (this.msgTime === 0) {
this.msgTime = this.config.MSGTIME;
this.msgText = this.config.MSGINIT;
this.msgKey = false;
clearInterval(time);
}
}, 1000);
sendSms(this.loginForm.tenantId, encrypt(this.loginForm.phone)).then(res => {
const data = res.data;
if (data.success) {
this.loginForm.codeId = data.data.id;
this.$message.success(data.msg);
} else {
this.$message.error(data.msg);
}
});
}
});
},
handleLogin() {
this.$refs.loginForm.validate(valid => {
if (valid) {
const loading = this.$loading({
lock: true,
text: 'Loading...',
background: 'rgba(0, 0, 0, 0.7)',
});
this.$store
.dispatch('LoginByPhone', this.loginForm)
.then(() => {
loading.close();
this.$router.push(this.tagWel);
})
.catch(err => {
console.log(err);
loading.close();
});
}
});
},
getMsg() {
this.msgText = this.config.MSGINIT;
this.msgTime = this.config.MSGTIME;
},
getTenant() {
let domain = getTopUrl();
// 临时指定域名,方便测试
//domain = "https://bladex.cn";
info(domain).then(res => {
const data = res.data;
if (data.success && data.data.tenantId) {
this.tenantMode = false;
this.loginForm.tenantId = data.data.tenantId;
this.$parent.$refs.login.style.backgroundImage = `url(${data.data.backgroundUrl})`;
}
});
},
},
};
</script>
<style>
.msg-text {
display: block;
width: 60px;
font-size: 12px;
text-align: center;
cursor: pointer;
}
.msg-text.display {
color: #ccc;
}
</style>

39
src/page/login/facelogin.vue Executable file
View File

@@ -0,0 +1,39 @@
<template>
<basic-video ref="video" :width="350"></basic-video>
</template>
<script>
import { mapGetters } from 'vuex';
import basicVideo from '@/components/basic-video/main.vue';
export default {
components: {
basicVideo,
},
data() {
return {
loginForm: {
username: 'admin',
password: '123456',
},
};
},
created() {
setTimeout(() => {
this.handleLogin();
}, 6000);
},
computed: {
...mapGetters(['tagWel']),
},
methods: {
handleLogin() {
this.$store.dispatch('LoginByUsername', this.loginForm).then(() => {
this.$router.push(this.tagWel);
});
},
},
};
</script>
<style></style>

160
src/page/login/index.vue Executable file
View File

@@ -0,0 +1,160 @@
<template>
<div class="login-container" @keyup.enter="handleLogin">
<div class="login-time">
{{ time }}
</div>
<div class="login-weaper">
<div class="login-left animate__animated animate__fadeInLeft">
<img class="img" src="/img/logo.png" alt="" />
<p class="title">{{ $t('login.info') }}</p>
</div>
<div class="login-border animate__animated animate__fadeInRight">
<div class="login-main">
<p class="login-title">
{{ $t('login.title') }}{{ website.title }}
<top-lang></top-lang>
</p>
<userLogin v-if="activeName === 'user'"></userLogin>
<codeLogin v-else-if="activeName === 'code'"></codeLogin>
<thirdLogin v-else-if="activeName === 'third'"></thirdLogin>
<registerLogin v-else-if="activeName === 'register'"></registerLogin>
<!-- <div class="login-menu">-->
<!-- <el-link href="#" @click.stop="activeName = 'user'">{{-->
<!-- $t('login.userLogin')-->
<!-- }}</el-link>-->
<!-- <el-link href="#" @click.stop="activeName = 'code'">{{-->
<!-- $t('login.phoneLogin')-->
<!-- }}</el-link>-->
<!-- <el-link href="#" @click.stop="activeName = 'third'">{{-->
<!-- $t('login.thirdLogin')-->
<!-- }}</el-link>-->
<!-- <el-link-->
<!-- :href="-->
<!-- website.oauth2.ssoBaseUrl + website.oauth2.ssoAuthUrl + website.oauth2.redirectUri-->
<!-- "-->
<!-- >{{ $t('login.ssoLogin') }}</el-link-->
<!-- >-->
<!-- </div>-->
</div>
</div>
</div>
</div>
</template>
<script>
import userLogin from './userlogin.vue';
import registerLogin from './registerlogin.vue';
import codeLogin from './codelogin.vue';
import thirdLogin from './thirdlogin.vue';
import { mapGetters } from 'vuex';
import { validatenull } from '@/utils/validate';
import topLang from '@/page/index/top/top-lang.vue';
import { getQueryString, getTopUrl } from '@/utils/util';
import website from '@/config/website';
export default {
name: 'login',
components: {
userLogin,
registerLogin,
codeLogin,
thirdLogin,
topLang,
},
data() {
return {
website: website,
time: '',
activeName: 'user',
socialForm: {
tenantId: '000000',
source: '',
code: '',
state: '',
},
};
},
watch: {
$route() {
this.handleLogin();
},
},
created() {
this.handleLogin();
this.getTime();
},
mounted() {},
computed: {
...mapGetters(['tagWel']),
},
props: [],
methods: {
getTime() {
setInterval(() => {
this.time = this.$dayjs().format('YYYY-MM-DD HH:mm:ss');
}, 1000);
},
handleLogin() {
const topUrl = getTopUrl();
const redirectUrl = '/oauth/redirect/';
const ssoCode = '?code=';
this.socialForm.source = getQueryString('source');
this.socialForm.code = getQueryString('code');
this.socialForm.state = getQueryString('state');
if (validatenull(this.socialForm.source) && topUrl.includes(redirectUrl)) {
let source = topUrl.split('?')[0];
source = source.split(redirectUrl)[1];
this.socialForm.source = source;
}
if (
topUrl.includes(redirectUrl) &&
!validatenull(this.socialForm.source) &&
!validatenull(this.socialForm.code) &&
!validatenull(this.socialForm.state)
) {
const loading = this.$loading({
lock: true,
text: 'Loading...',
background: 'rgba(0, 0, 0, 0.7)',
});
this.$store
.dispatch('LoginBySocial', this.socialForm)
.then(() => {
window.location.href = topUrl.split(redirectUrl)[0];
//加载工作流路由集
this.loadFlowRoutes();
this.$router.push(this.tagWel);
loading.close();
})
.catch(() => {
loading.close();
});
} else if (
!topUrl.includes(redirectUrl) &&
!validatenull(this.socialForm.code) &&
!validatenull(this.socialForm.state)
) {
const loading = this.$loading({
lock: true,
text: 'Loading...',
background: 'rgba(0, 0, 0, 0.7)',
});
this.$store
.dispatch('LoginBySso', this.socialForm)
.then(() => {
window.location.href = topUrl.split(ssoCode)[0];
//加载工作流路由集
this.loadFlowRoutes();
this.$router.push(this.tagWel);
loading.close();
})
.catch(() => {
loading.close();
});
}
},
loadFlowRoutes() {
this.$store.dispatch('FlowRoutes').then(() => {});
},
},
};
</script>

221
src/page/login/registerlogin.vue Executable file
View File

@@ -0,0 +1,221 @@
<template>
<el-form
class="login-form"
status-icon
:rules="loginRules"
ref="loginForm"
:model="loginForm"
label-width="0"
>
<el-form-item v-if="tenantMode" prop="tenantId">
<el-input
@keyup.enter="handleRegister"
v-model="loginForm.tenantId"
auto-complete="off"
:placeholder="$t('login.tenantId')"
>
<template #prefix>
<i class="icon-quanxian" />
</template>
</el-input>
</el-form-item>
<el-form-item prop="name">
<el-input
@keyup.enter="handleRegister"
v-model="loginForm.name"
auto-complete="off"
:placeholder="$t('login.name')"
>
<template #prefix>
<i class="icon-zhanghaoquanxianguanli" />
</template>
</el-input>
</el-form-item>
<el-form-item prop="account">
<el-input
@keyup.enter="handleRegister"
v-model="loginForm.account"
auto-complete="off"
:placeholder="$t('login.username')"
>
<template #prefix>
<i class="icon-yonghu" />
</template>
</el-input>
</el-form-item>
<el-form-item prop="phone">
<el-input
@keyup.enter="handleRegister"
v-model="loginForm.phone"
auto-complete="off"
:placeholder="$t('login.phone')"
>
<template #prefix>
<i class="icon-shouji" />
</template>
</el-input>
</el-form-item>
<el-form-item prop="email">
<el-input
@keyup.enter="handleRegister"
v-model="loginForm.email"
auto-complete="off"
:placeholder="$t('login.email')"
>
<template #prefix>
<i class="icon-xiaoxitongzhi" />
</template>
</el-input>
</el-form-item>
<el-form-item prop="password">
<el-input
@keyup.enter="handleRegister"
type="password"
show-password
v-model="loginForm.password"
auto-complete="off"
:placeholder="$t('login.password')"
>
<template #prefix>
<i class="icon-mima" />
</template>
</el-input>
</el-form-item>
<el-form-item prop="password1">
<el-input
@keyup.enter="handleRegister"
type="password"
show-password
v-model="loginForm.password1"
auto-complete="off"
:placeholder="$t('login.password1')"
>
<template #prefix>
<i class="icon-mima" />
</template>
</el-input>
</el-form-item>
<el-form-item>
<el-button type="primary" @click.prevent="handleRegister" class="login-submit"
>{{ $t('login.register') }}
</el-button>
<el-button @click.prevent="handleBack" class="register-submit"
>{{ $t('login.back') }}
</el-button>
</el-form-item>
</el-form>
</template>
<script>
import { mapGetters } from 'vuex';
import { info } from '@/api/system/tenant';
import { getTopUrl } from '@/utils/util';
export default {
name: 'userlogin',
data() {
return {
tenantMode: this.website.tenantMode,
captchaMode: this.website.captchaMode,
registerMode: this.website.oauth2.registerMode,
loginForm: {
//租户ID
tenantId: '',
//部门ID
deptId: '',
//角色ID
roleId: '',
//用户名
account: '',
//手机号
phone: '',
//邮箱
email: '',
//密码
password: '',
//确认密码
password1: '',
//账号类型
type: 'account',
//预加载白色背景
image: 'data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7',
},
loginRules: {
tenantId: [{ required: true, message: 'please input tenantId', trigger: 'blur' }],
name: [{ required: true, message: 'please input name', trigger: 'blur' }],
account: [{ required: true, message: 'please input account', trigger: 'blur' }],
phone: [{ required: true, message: 'please input phone', trigger: 'blur' }],
email: [{ required: true, message: 'please input email', trigger: 'blur' }],
password: [{ required: true, message: 'please input password', trigger: 'blur' }],
password1: [{ required: true, message: 'please confirm password', trigger: 'blur' }],
},
passwordType: 'password',
};
},
created() {
this.getTenant();
},
mounted() {
this.$nextTick(() => {});
},
watch: {},
computed: {
...mapGetters(['tagWel', 'userInfo']),
},
props: [],
methods: {
handleRegister() {
if (this.loginForm.password !== this.loginForm.password1) {
this.$message.error('passwords dismatch');
return;
}
this.$refs.loginForm.validate(valid => {
if (valid) {
const loading = this.$loading({
lock: true,
text: 'signing up...please wait',
background: 'rgba(0, 0, 0, 0.7)',
});
this.$store
.dispatch('RegisterUser', this.loginForm)
.then(() => {
this.$alert(
'Registration successful. Please wait for an administrator to review your account and assign permissions.',
'Registration Successful',
{
confirmButtonText: 'Confirm',
callback: () => {
this.$parent.activeName = 'user';
},
}
);
})
.catch(err => {
console.log(err);
});
loading.close();
}
});
},
handleBack() {
this.$parent.activeName = 'user';
},
getTenant() {
let domain = getTopUrl();
console.log(domain)
// 临时指定域名,方便测试
// domain = 'https://admin.tttzai.com';
info(domain).then(res => {
const data = res.data;
if (data.success && data.data.tenantId) {
this.tenantMode = false;
this.loginForm.tenantId = data.data.tenantId;
this.$parent.$refs.login.style.backgroundImage = `url(${data.data.backgroundUrl})`;
}
});
},
},
};
</script>
<style></style>

67
src/page/login/thirdlogin.vue Executable file
View File

@@ -0,0 +1,67 @@
<template>
<div class="social-container">
<div @click="handleClick('github')">
<span class="container" :style="{ backgroundColor: '#61676D' }">
<i icon-class="github" class="iconfont icongithub"></i>
</span>
</div>
<div @click="handleClick('gitee')">
<span class="container" :style="{ backgroundColor: '#c35152' }">
<i icon-class="gitee" class="iconfont icongitee2"></i>
</span>
</div>
<div @click="handleClick('wechat_open')">
<span class="container" :style="{ backgroundColor: '#8dc349' }">
<i icon-class="wechat" class="iconfont icon-weixin" />
</span>
</div>
<div @click="handleClick('qq')">
<span class="container" :style="{ backgroundColor: '#6ba2d6' }">
<i icon-class="qq" class="iconfont icon-qq" />
</span>
</div>
</div>
</template>
<script>
import website from '@/config/website';
export default {
name: 'thirdLogin',
methods: {
handleClick(source) {
window.location.href = `${website.oauth2.authUrl}/${source}`;
},
},
};
</script>
<style rel="stylesheet/scss" lang="scss" scoped>
.social-container {
margin: 20px 0;
display: flex;
align-items: center;
justify-content: space-around;
.iconfont {
color: #fff;
font-size: 30px;
}
.container {
$height: 50px;
cursor: pointer;
display: inline-block;
width: $height;
height: $height;
line-height: $height;
text-align: center;
border-radius: 4px;
margin-bottom: 10px;
}
.title {
text-align: center;
}
}
</style>

292
src/page/login/userlogin.vue Executable file
View File

@@ -0,0 +1,292 @@
<template>
<el-form
class="login-form"
status-icon
:rules="loginRules"
ref="loginForm"
:model="loginForm"
label-width="0"
>
<el-form-item v-if="tenantMode" prop="tenantId">
<el-input
@keyup.enter="handleLogin"
v-model="loginForm.tenantId"
auto-complete="off"
:placeholder="$t('login.tenantId')"
>
<template #prefix>
<i class="icon-quanxian" />
</template>
</el-input>
</el-form-item>
<el-form-item prop="username">
<el-input
@keyup.enter="handleLogin"
v-model="loginForm.username"
auto-complete="off"
:placeholder="$t('login.username')"
>
<template #prefix>
<i class="icon-yonghu" />
</template>
</el-input>
</el-form-item>
<el-form-item prop="password">
<el-input
@keyup.enter="handleLogin"
type="password"
show-password
v-model="loginForm.password"
auto-complete="off"
:placeholder="$t('login.password')"
>
<template #prefix>
<i class="icon-mima" />
</template>
</el-input>
</el-form-item>
<el-form-item prop="code" class="login-code" v-if="captchaMode">
<el-input
@keyup.enter="handleLogin"
v-model="loginForm.code"
auto-complete="off"
:placeholder="$t('login.code')"
>
<template #prefix>
<i class="icon-yanzhengma"></i>
</template>
<template #append>
<div class="login-code-box">
<img :src="loginForm.image" class="login-code-img" @click="refreshCode" />
</div>
</template>
</el-input>
</el-form-item>
<el-form-item>
<el-button type="primary" @click.prevent="handleLogin" class="login-submit"
>{{ $t('login.submit') }}
</el-button>
<el-button
v-if="this.registerMode"
type="danger"
@click.prevent="handleRegister"
class="register-submit"
>{{ $t('login.register') }}
</el-button>
</el-form-item>
<el-dialog title="请选择身份信息后登录" append-to-body v-model="userBox" width="400px">
<avue-form :option="userOption" v-model="userForm" @submit="submitLogin" />
</el-dialog>
</el-form>
</template>
<script>
import { mapGetters } from 'vuex';
import { info } from '@/api/system/tenant';
import { getCaptcha } from '@/api/user';
import { getTopUrl } from '@/utils/util';
import { validatenull } from '@/utils/validate';
export default {
name: 'userlogin',
data() {
return {
tenantMode: this.website.tenantMode,
captchaMode: this.website.captchaMode,
registerMode: this.website.oauth2.registerMode,
loginForm: {
//租户ID
tenantId: '000000',
//部门ID
deptId: '',
//角色ID
roleId: '',
//用户名
username: 'admin',
//密码
password: '',
//账号类型
type: 'account',
//验证码的值
code: '',
//验证码的索引
key: '',
//预加载白色背景
image: 'data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7',
},
loginRules: {
tenantId: [{ required: false, message: 'please input tenantId', trigger: 'blur' }],
username: [{ required: true, message: 'please input username', trigger: 'blur' }],
password: [
{ required: true, message: 'please input password', trigger: 'blur' },
{ min: 1, message: 'password must be at least 6 characters long', trigger: 'blur' },
],
},
passwordType: 'password',
userBox: false,
userForm: {
deptId: '',
roleId: '',
},
userOption: {
labelWidth: 70,
submitBtn: true,
emptyBtn: false,
submitText: '登 录',
column: [
{
label: '角色',
prop: 'roleId',
type: 'select',
props: {
label: 'roleName',
value: 'id',
},
dicUrl: '/blade-system/role/select',
filterable: true,
span: 24,
display: false,
rules: [
{
required: true,
message: '请选择角色',
trigger: 'blur',
},
],
},
{
label: '部门',
prop: 'deptId',
type: 'select',
props: {
label: 'deptName',
value: 'id',
},
dicUrl: '/blade-system/dept/select',
filterable: true,
span: 24,
display: false,
rules: [
{
required: true,
message: '请选择部门',
trigger: 'blur',
},
],
},
],
},
};
},
created() {
this.getTenant();
this.refreshCode();
},
mounted() {
this.$nextTick(() => {});
},
watch: {
'loginForm.deptId'() {
const column = this.findObject(this.userOption.column, 'deptId');
if (this.loginForm.deptId.includes(',')) {
column.dicUrl = `/blade-system/dept/select?deptId=${this.loginForm.deptId}`;
column.display = true;
} else {
column.dicUrl = '';
}
},
'loginForm.roleId'() {
const column = this.findObject(this.userOption.column, 'roleId');
if (this.loginForm.roleId.includes(',')) {
column.dicUrl = `/blade-system/role/select?roleId=${this.loginForm.roleId}`;
column.display = true;
} else {
column.dicUrl = '';
}
},
},
computed: {
...mapGetters(['tagWel', 'userInfo']),
},
props: [],
methods: {
refreshCode() {
if (this.website.captchaMode) {
getCaptcha().then(res => {
const data = res.data;
this.loginForm.key = data.key;
this.loginForm.image = data.image;
});
}
},
submitLogin(form, done) {
if (!validatenull(form.deptId)) {
this.loginForm.deptId = form.deptId;
}
if (!validatenull(form.roleId)) {
this.loginForm.roleId = form.roleId;
}
this.handleLogin();
done();
},
handleLogin() {
this.$refs.loginForm.validate(valid => {
if (valid) {
const loading = this.$loading({
lock: true,
text: 'Loading...',
background: 'rgba(0, 0, 0, 0.7)',
});
this.$store
.dispatch('LoginByUsername', this.loginForm)
.then(() => {
if (this.website.switchMode) {
const deptId = this.userInfo.deptId;
const roleId = this.userInfo.roleId;
if (deptId.includes(',') || roleId.includes(',')) {
this.loginForm.deptId = deptId;
this.loginForm.roleId = roleId;
this.userBox = true;
this.$store.dispatch('LogOut').then(() => {
loading.close();
});
return false;
}
}
loading.close();
//加载工作流路由集
this.loadFlowRoutes();
this.$router.push(this.tagWel);
})
.catch(err => {
console.log(err);
loading.close();
this.refreshCode();
});
}
});
},
handleRegister() {
this.$parent.activeName = 'register';
},
loadFlowRoutes() {
this.$store.dispatch('FlowRoutes').then(() => {});
},
getTenant() {
let domain = getTopUrl();
// 临时指定域名,方便测试
//domain = "https://bladex.cn";
info(domain).then(res => {
const data = res.data;
if (data.success && data.data.tenantId) {
this.tenantMode = false;
this.loginForm.tenantId = data.data.tenantId;
this.$parent.$refs.login.style.backgroundImage = `url(${data.data.backgroundUrl})`;
}
});
},
},
};
</script>
<style></style>