Commit 04d32577 by Margaret

init

1 parent d47a26b0
Showing 58 changed files with 2364 additions and 125 deletions
module.exports = {
presets: [
'@vue/cli-plugin-babel/preset'
],
plugins: [
[
"import",
{ libraryName: "ant-design-vue", libraryDirectory: "es", style: true }
]
]
}
{
"name": "glsx-micro-manager",
"name": "glsx-micro-manager-portal",
"version": "0.1.0",
"private": true,
"scripts": {
......@@ -7,10 +7,16 @@
"build": "vue-cli-service build"
},
"dependencies": {
"ant-design-vue": "^2.0.0-beta.10",
"axios": "^0.20.0",
"core-js": "^3.6.5",
"less": "^3.12.2",
"less-loader": "^7.0.2",
"qiankun": "^2.1.0",
"qs": "^6.9.4",
"vue": "^3.0.0",
"vue-router": "^4.0.0-0",
"vuex": "^4.0.0-0"
"vue-router": "^4.0.0-alpha.6",
"vuex": "^4.0.0-alpha.1"
},
"devDependencies": {
"@vue/cli-plugin-babel": "~4.5.0",
......@@ -18,12 +24,13 @@
"@vue/cli-plugin-vuex": "~4.5.0",
"@vue/cli-service": "~4.5.0",
"@vue/compiler-sfc": "^3.0.0",
"sass": "^1.26.5",
"sass-loader": "^8.0.2"
"babel-plugin-import": "^1.13.1",
"vue-cli-plugin-vue-next": "~0.1.4"
},
"browserslist": [
"> 1%",
"last 2 versions",
"not dead"
]
],
"proxy": "https://baidu.com"
}
<template>
<div id="nav">
<router-link to="/">Home</router-link> |
<router-link to="/about">About</router-link>
<div id="app">
<keep-alive>
<div>
<dashboard v-if="hasToken"></dashboard>
<login v-else></login>
<!-- 全局loading提示 -->
<loading v-if="showLoading"></loading>
</div>
</keep-alive>
</div>
<router-view/>
</template>
<style lang="scss">
#app {
font-family: Avenir, Helvetica, Arial, sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
text-align: center;
color: #2c3e50;
<script>
import Dashboard from '@/views/Dashboard';
import Login from '@/views/Login';
import Loading from 'components/Loading/Loading';
import BaseService from 'services/Base';
import { onCreated, onMounted, computed, reactive, toRefs } from 'vue';
import { useStore } from 'vuex';
export default {
name: "App",
components: {
Dashboard,
Login,
Loading
},
setup () {
const store = useStore();
const baseService = new BaseService();
baseService.getBaseConfig().then((res) => {
const baseURL = res.axios.baseURL;
store.dispatch('app/updateBaseURL', baseURL);
}, (err) => {
});
let hasToken = computed(() => {
return !!store.getters.token;
})
let showLoading = computed(() => {
return store.getters.showLoading;
})
return {
hasToken,
showLoading
}
}
}
</script>
#nav {
padding: 30px;
<style lang="less">
.layout-container {
height: 100vh;
a {
font-weight: bold;
color: #2c3e50;
#desktop-right-sider .trigger {
font-size: 18px;
line-height: 64px;
padding: 0 24px;
cursor: pointer;
transition: color 0.3s;
}
#desktop-right-sider .trigger:hover {
color: #1890ff;
}
&.router-link-exact-active {
color: #42b983;
#desktop-right-sider .logo {
height: 32px;
background: rgba(255, 255, 255, 0.2);
margin: 16px;
}
}
}
</style>
.top-nav-right-btn {
margin-right: 35px;
cursor: pointer;
}
.common-home-bg-gradient {
background-image: linear-gradient(270deg, rgba(51, 148, 225, 0.18), transparent);
background: -webkit-gradient(linear, right top, left top, from(rgba(51, 148, 225, 0.18)), to(transparent));
}
.ellipsis {
white-space: nowrap;
text-overflow: ellipsis;
overflow: hidden;
}
.two-line-ellipsis {
text-overflow: -o-ellipsis-lastline;
overflow: hidden;
text-overflow: ellipsis;
display: -webkit-box;
-webkit-line-clamp: 2;
line-clamp: 2;
-webkit-box-orient: vertical;
}
.flex-row {
display: flex;
flex-direction: row;
}
.flex-column {
display: flex;
flex-direction: column;
}
.vh-center {
display: flex;
justify-content: center;
align-items: center;
}
.v-center {
display: flex;
align-items: center;
}
.h-center {
display: flex;
justify-content: center;
}
\ No newline at end of file
@charset "utf-8";html{background-color:#fff;color:#000;font-size:12px}
body,ul,ol,dl,dd,h1,h2,h3,h4,h5,h6,figure,form,fieldset,legend,input,textarea,button,p,blockquote,th,td,pre,xmp{margin:0;padding:0}
body,input,textarea,button,select,pre,xmp,tt,code,kbd,samp{line-height:1.5;font-family:tahoma,arial,"Hiragino Sans GB",simsun,sans-serif}
h1,h2,h3,h4,h5,h6,small,big,input,textarea,button,select{font-size:100%}
h1,h2,h3,h4,h5,h6{font-family:tahoma,arial,"Hiragino Sans GB","微软雅黑",simsun,sans-serif}
h1,h2,h3,h4,h5,h6,b,strong{font-weight:normal}
address,cite,dfn,em,i,optgroup,var{font-style:normal}
table{border-collapse:collapse;border-spacing:0;text-align:left}
caption,th{text-align:inherit}
ul,ol,menu{list-style:none}
fieldset,img{border:0}
img,object,input,textarea,button,select{vertical-align:middle}
article,aside,footer,header,section,nav,figure,figcaption,hgroup,details,menu{display:block}
audio,canvas,video{display:inline-block;*display:inline;*zoom:1}
blockquote:before,blockquote:after,q:before,q:after{content:"\0020"}
textarea{overflow:auto;resize:vertical}
input,textarea,button,select,a{outline:0 none;border: none;}
button::-moz-focus-inner,input::-moz-focus-inner{padding:0;border:0}
mark{background-color:transparent}
a,ins,s,u,del{text-decoration:none}
sup,sub{vertical-align:baseline}
html {overflow-x: hidden;height: 100%;font-size: 50px;-webkit-tap-highlight-color: transparent;}
body {font-family: "Roboto", "Helvetica Neue", Helvetica, Arial; color: #333;font-size: .28em;line-height: 1;-webkit-text-size-adjust: none;}
hr {height: .02rem;margin: .1rem 0;border: medium none;border-top: .02rem solid #cacaca;}
a {color: #333;text-decoration: none;}
\ No newline at end of file
@defaultThemeColor: #001529;
@defaultBgColor: #2b4c81;
@defaultLightBlueColor: #4679cc;
@defaultTextColor: #2196F3;
\ No newline at end of file
<template>
<a-layout-sider
class="desktop-left-sider"
width="250"
v-model:collapsed="collapsed"
:trigger="null"
collapsible
>
<Logo :collapsed="collapsed"></Logo>
<nav-info-card :collapsed="collapsed"></nav-info-card>
<Menu></Menu>
</a-layout-sider>
</template>
<script>
import Logo from './Sub/Logo';
import NavInfoCard from './Sub/NavInfoCard';
import Menu from './Sub/Menu';
import {
PieChartOutlined,
DesktopOutlined,
UserOutlined,
TeamOutlined,
FileOutlined,
} from '@ant-design/icons-vue';
import { reactive, toRefs, onMounted } from 'vue';
export default {
name: 'DesktopLeftSider',
components: {
Logo,
NavInfoCard,
Menu,
PieChartOutlined,
DesktopOutlined,
UserOutlined,
TeamOutlined,
FileOutlined,
},
props: {
collapsed: Boolean
},
setup(props, context) {
const state = reactive({
});
const onCollapse = (collapsed, type) => {
};
const onBreakpoint = (broken) => {
console.log(broken);
};
onMounted(() => {
console.log(context)
});
return {
...toRefs(state),
onCollapse,
onBreakpoint
}
}
}
</script>
<style lang="less" scoped>
@import 'styles/variables.less';
.desktop-left-sider {
background-color: @defaultThemeColor;
overflow: hidden;
.trigger {
font-size: 18px;
line-height: 64px;
padding: 0 24px;
cursor: pointer;
transition: color 0.3s;
}
.trigger:hover {
color: #1890ff;
}
}
</style>
\ No newline at end of file
<template>
<div class="home-logo-wrapper">
<img v-show="!collapsed" class="home-logo-img" src="@/assets/images/home-logo.png" alt="home-logo" >
<img v-show="collapsed" class="home-logo-img home-thumbnail-logo" src="@/assets/images/logo-thumbnail.png" alt="home-logo" >
</div>
</template>
<script>
import { ref } from 'vue';
export default {
name: 'Logo',
props: {
collapsed: Boolean
},
setup () {
}
}
</script>
<style lang="less" scoped>
@import 'styles/mixins.less';
.home-logo-wrapper {
.vh-center;
width: 100%;
height: 60px;
padding: 10px 20px;
.home-logo-img {
width: 100%;
}
.home-thumbnail-logo {
width: 80%;
}
}
</style>
\ No newline at end of file
<template>
<a-menu class="menu"
ref="menuRef"
theme="dark"
mode="inline"
v-model:selectedKeys="selectedKeys"
v-model:openKeys="openKeys"
>
<a-sub-menu v-for="item in menuList" :key="item.origin.menuNo" @titleClick="titleClick(item)">
<template v-slot:title>
<span>
<img v-if="item.origin.icon" :src="item.origin.icon" />
<UserOutlined v-else />
<span>{{item.origin.menuName}}</span>
</span>
</template>
<a-menu-item v-for="cItem in item.children" :key="cItem.origin.menuNo" @click="cItemClick(cItem.origin.path || '', cItem)">
{{cItem.origin.menuName}}
</a-menu-item>
</a-sub-menu>
</a-menu>
</template>
<script>
import {
UserOutlined,
TeamOutlined,
FileOutlined,
} from '@ant-design/icons-vue';
import { reactive, toRefs, onMounted, computed } from 'vue';
import { useStore } from 'vuex';
import MenuService from 'services/Menu';
import { menuTree as menuTreeLocalList } from 'config/menuTree';
export default {
name: 'Menu',
components: {
UserOutlined,
TeamOutlined,
FileOutlined,
},
setup(props, context) {
const store = useStore();
const state = reactive({
openKeys: [],
selectedKeys: [],
menuList: menuTreeLocalList,
curMainTitle: '',
curBreadCrumb: {
parent: {},
children: []
}
});
// 点击主菜单标题
const titleClick = (item) => {
state.curMainTitle = item.origin.menuName;
};
// 点击二级菜单标题
const cItemClick = (path, cItem) => {
const cOrigin = cItem.origin;
state.curBreadCrumb.parent['menuName'] = state.curMainTitle;
state.curBreadCrumb.children = [{
menuName: cOrigin.menuName,
path: cOrigin.path || '',
active: true
}];
history.pushState(null, path, path);
}
// 合并本地和后台返回的菜单数据
const mergeData = (server, localArr) => {
var serverMenuNo = server.origin.menuNo;
var localEle;
for (const key in localArr) {
var localMenuNo = localArr[key].origin.menuNo;
if (serverMenuNo == localMenuNo) {
localEle = localArr[key]
break;
}
}
if (!localEle) {
return server;
} else {
var children = [];
for (const key in server.children) {
var sMenuNo = server.children[key].origin.menuNo;
for (const key in localEle.children) {
var localChildrenEle = localEle.children[key].origin;
if(sMenuNo == localChildrenEle.menuNo) {
children.push({origin: localChildrenEle});
break;
}
if (key == localEle.children.length - 1) {
children.push({origin: server.children[key].origin});
}
}
}
return {origin: localEle.origin, 'children': children}
}
}
// 遍历菜单列表并合并
const getMenuTree = (serverArr, localArr) => {
var arr = []
for (const key in serverArr) {
arr.push(mergeData(serverArr[key], localArr));
}
console.log(arr);
return arr;
}
// 获取权限菜单(假数据)
// const res = {"code":200,"data":[{"children":[{"children":[],"id":20101,"origin":{"menuNo":20101,"menuName":"ODB管理","parentId":201,"type":2,"icon":null,"frontRoute":null,"orderNum":1,"checked":false},"order":1,"depth":null,"parentId":201,"label":"ODB管理"}],"id":201,"origin":{"menuNo":201,"menuName":"设备管理","parentId":0,"type":1,"icon":null,"frontRoute":null,"orderNum":1,"checked":false},"order":1,"depth":null,"parentId":0,"label":"设备管理"},{"children":[{"children":[],"id":30101,"origin":{"menuNo":30101,"menuName":"测试菜单","parentId":301,"type":2,"icon":null,"frontRoute":"bbb","orderNum":1,"checked":false},"order":1,"depth":null,"parentId":301,"label":"测试菜单"}],"id":301,"origin":{"menuNo":301,"menuName":"测试菜单","parentId":0,"type":1,"icon":null,"frontRoute":"bbb","orderNum":1,"checked":false},"order":1,"depth":null,"parentId":0,"label":"测试菜单"},{"children":[{"children":[],"id":10101,"origin":{"menuNo":10101,"menuName":"用户管理","parentId":101,"type":2,"icon":null,"frontRoute":null,"orderNum":1,"checked":false},"order":1,"depth":null,"parentId":101,"label":"用户管理"},{"children":[],"id":10102,"origin":{"menuNo":10102,"menuName":"用户组管理","parentId":101,"type":2,"icon":null,"frontRoute":null,"orderNum":2,"checked":false},"order":2,"depth":null,"parentId":101,"label":"用户组管理"},{"children":[],"id":10103,"origin":{"menuNo":10103,"menuName":"角色管理","parentId":101,"type":2,"icon":null,"frontRoute":null,"orderNum":3,"checked":false},"order":3,"depth":null,"parentId":101,"label":"角色管理"},{"children":[],"id":10104,"origin":{"menuNo":10104,"menuName":"菜单管理","parentId":101,"type":2,"icon":null,"frontRoute":null,"orderNum":4,"checked":false},"order":4,"depth":null,"parentId":101,"label":"菜单管理"},{"children":[],"id":10105,"origin":{"menuNo":10105,"menuName":"组织管理","parentId":101,"type":2,"icon":null,"frontRoute":null,"orderNum":5,"checked":false},"order":5,"depth":null,"parentId":101,"label":"组织管理"},{"children":[{"children":[],"id":1010607,"origin":{"menuNo":1010607,"menuName":"数据字典3","parentId":10106,"type":2,"icon":null,"frontRoute":"bbb","orderNum":1,"checked":false},"order":1,"depth":null,"parentId":10106,"label":"数据字典3"},{"children":[],"id":1010608,"origin":{"menuNo":1010608,"menuName":"数据字典4","parentId":10106,"type":2,"icon":null,"frontRoute":"bbb","orderNum":1,"checked":false},"order":1,"depth":null,"parentId":10106,"label":"数据字典4"},{"children":[],"id":1010609,"origin":{"menuNo":1010609,"menuName":"数据字典5","parentId":10106,"type":2,"icon":null,"frontRoute":"bbb","orderNum":1,"checked":false},"order":1,"depth":null,"parentId":10106,"label":"数据字典5"},{"children":[],"id":1010610,"origin":{"menuNo":1010610,"menuName":"数据字典6","parentId":10106,"type":2,"icon":null,"frontRoute":"bbb","orderNum":1,"checked":false},"order":1,"depth":null,"parentId":10106,"label":"数据字典6"}],"id":10106,"origin":{"menuNo":10106,"menuName":"字典管理","parentId":101,"type":2,"icon":null,"frontRoute":null,"orderNum":6,"checked":false},"order":6,"depth":null,"parentId":101,"label":"字典管理"},{"children":[],"id":10107,"origin":{"menuNo":10107,"menuName":"操作日志","parentId":101,"type":2,"icon":null,"frontRoute":null,"orderNum":7,"checked":false},"order":7,"depth":null,"parentId":101,"label":"操作日志"}],"id":101,"origin":{"menuNo":101,"menuName":"系统管理","parentId":0,"type":1,"icon":null,"frontRoute":null,"orderNum":2,"checked":false},"order":2,"depth":null,"parentId":0,"label":"系统管理"}],"message":"success"};
// const getNewTree = getMenuTree(res.data, menuTreeLocalList);
// 获取菜单树接口
const getServerTree = async () => {
const menuService = new MenuService();
menuService.getMenuTree().then( res => {
if(res.code === 200) {
const resData = res.data;
const getNewTree = getMenuTree(res.data, menuTreeLocalList),
firstParent = getNewTree[0].origin,
firstChildren = getNewTree[0].children[0].origin;
console.log(getNewTree);
state.menuList = getNewTree;
state.openKeys = [firstParent.menuNo];
state.selectedKeys = [firstChildren.menuNo];
state.curBreadCrumb.parent['menuName'] = firstParent.menuName;
state.curBreadCrumb.children.push({
menuName: firstChildren.menuName,
path: firstChildren.path || '',
active: true
});
store.dispatch('menu/setBreadCrumb', state.curBreadCrumb);
}
}, err => {
})
};
getServerTree();
onMounted(() => {
console.log(context)
});
return {
...toRefs(state),
titleClick,
cItemClick
}
}
}
</script>
<style lang="less" scoped>
@import 'styles/variables.less';
.menu {
background-color: @defaultThemeColor;
}
</style>
\ No newline at end of file
<template>
<div class="info-card" :class="{ infoActive: !isNavFilterActive }">
<DownOutlined class="arrow-icon" @click="downClicked" />
<div class="info-card-content" :style="{width: collapsed? '80px' : '100%'}">
<!-- 用户卡片头像:缩小时点击会出现用户信息 -->
<a-popover placement="right" v-if="collapsed">
<template v-slot:content>
<p>{{ username }}</p>
<p>{{ professionalTitle }}</p>
</template>
<a-avatar class="info-card-avatar" size="large" :style="{marginRight: collapsed? '0' : '15px'}">
<template v-slot:icon>
<UserOutlined />
</template>
</a-avatar>
</a-popover>
<!-- 未缩小无点击效果处理 -->
<a-avatar v-if="!collapsed" class="info-card-avatar" size="large" :style="{marginRight: collapsed? '0' : '15px'}">
<template v-slot:icon>
<UserOutlined />
</template>
</a-avatar>
<div class="flex-column info-card-user" :style="{display: collapsed? 'none' : 'block'}">
<span class="two-line-ellipsis">{{username || '用户名啦啦啦'}}</span>
<span class="two-line-ellipsis">{{professionalTitle || '管理员'}}</span>
</div>
</div>
</div>
<!-- 菜单搜索 -->
<div class="search-menu" :class="{ navActive: isNavFilterActive }">
<a-input class="search-menu-input"
v-model:value="value" placeholder="菜单搜索" />
<UpCircleOutlined class="icon-arrow" @click="upClicked" />
</div>
</template>
<script>
import {
UpCircleOutlined,
DownOutlined,
UserOutlined
} from '@ant-design/icons-vue';
import { reactive, toRefs, computed } from 'vue';
import { useStore } from 'vuex';
export default {
name: 'NavFilter',
components: {
UpCircleOutlined,
DownOutlined,
UserOutlined
},
props: {
collapsed: Boolean
},
setup (props, context) {
const store = useStore();
const state = reactive({
isNavFilterActive: false,
value: '',
username: '用户名啦啦啦',
professionalTitle: '广联赛讯管理员'
});
const upClicked = () => {
// 点击菜单搜索按钮
state.isNavFilterActive = false;
};
const downClicked = () => {
// 点击用户卡片按钮
state.isNavFilterActive = true;
};
return {
...toRefs(state),
upClicked,
downClicked
}
}
}
</script>
<style lang="less" scoped>
@import 'styles/variables.less';
@import 'styles/mixins.less';
.search-menu {
display: flex;
align-items: center;
opacity: 0;
visibility: hidden;
height: 0;
-webkit-transition: all 400ms cubic-bezier(0.34, 1.25, 0.3, 1);
transition: all 400ms cubic-bezier(0.34, 1.25, 0.3, 1);
-webkit-transform: scale(0.3);
transform: scale(0.3);
&-input {
border: 1px solid #E5E5E5;
border-radius: 4px;
border-color: rgba(0, 0, 0, 0.1);
background-color:#1a3051;
}
.icon-arrow {
margin-left: -30px;
transform: scale(1.4);
color: #fff;
}
}
.navActive {
opacity: 1;
visibility: visible;
height: 60px;
padding: 10px 20px;
-webkit-box-shadow: 0px 0px 28px 0px rgba(0, 0, 0, 0.13);
box-shadow: 0px 0px 28px 0px rgba(0, 0, 0, 0.13);
-webkit-transform: scale(1);
transform: scale(1);
}
.info-card {
position: relative;
overflow: hidden;
width: 270px;
height: 0;
background: url('../../../assets/images/info-card-cover.png') no-repeat;
opacity: 0;
visibility: hidden;
-webkit-transition: all 400ms cubic-bezier(0.34, 1.25, 0.3, 1);
transition: all 400ms cubic-bezier(0.34, 1.25, 0.3, 1);
.arrow-icon {
height: 21px;
background: rgba(0, 0, 0, 0.4);
padding: 0px 12px;
border: 1px solid rgba(0, 0, 0, 0.4);
border-radius: 0 0 20px 20px;
position: absolute;
left: 50%;
transform: translateX(-50%);
color: #fff;
-webkit-transition: all 200ms cubic-bezier(0.34, 1.25, 0.6, 1);
transition: all 200ms cubic-bezier(0.34, 1.25, 0.6, 1);
-webkit-box-shadow: 0px 0px 2px rgba(136, 106, 181, 0.3);
box-shadow: 0px 0px 2px rgba(136, 106, 181, 0.3);
&:hover {
cursor: pointer;
background: #4679cc;
border-color: #366bc3;
}
}
&-content {
width: 100%;
height: 100%;
color: #fff;
.vh-center;
}
&-avatar {
margin-right: 15px;
background-color: @defaultLightBlueColor;
}
&-user {
width: 100px;
span:last-child {
margin-top: 10px;
}
}
}
.infoActive {
opacity: 1;
height: 150px;
visibility: visible;
}
</style>
\ No newline at end of file
<template>
<a-layout-content
:style="{ margin: '24px 16px', padding: '24px', background: '#fff', minHeight: '280px' }"
>
<a-breadcrumb>
<a-breadcrumb-item class="breadcrumb-item" :class="{active: item.active, pointer: item.path}" v-for="(item, index) in breadCrumbList" :key="index" @click="routerGo(item.path || '')">
{{item.name}}
</a-breadcrumb-item>
</a-breadcrumb>
<div id="sub-system-frame"></div>
</a-layout-content>
</template>
<script>
import { useStore } from 'vuex';
import { reactive, toRefs, computed } from 'vue';
export default {
name: 'DesktopRightSider',
components: {
},
setup(props, context) {
const store = useStore();
const breadCrumbList = computed(() => {
const curBreadCrumb = store.getters.curBreadCrumb,
curParent = curBreadCrumb['parent'],
curChildren = curBreadCrumb['children'];
let breadCrumbList = [];
if(curParent) {
breadCrumbList.push({
name: curParent.menuName + ' / '
});
}
if(curChildren && curChildren.length > 0) {
curChildren.forEach((item, index, arr) => {
if(index === arr.length - 1) {
breadCrumbList.push({
name: item.menuName,
path: item.path,
active: item.active
});
} else {
breadCrumbList.push({
name: item.menuName + ' / ',
path: item.path,
active: item.active
});
}
});
}
return breadCrumbList;
})
const routerGo = (path) => {
// history.pushState(null, path, path);
}
return {
breadCrumbList,
routerGo
}
}
}
</script>
<style lang="less" scoped>
@import 'styles/variables.less';
.breadcrumb-item {
cursor: context-menu;
.pointer:hover {
color: @defaultTextColor;
}
}
.pointer {
// cursor: pointer;
}
.active {
color: @defaultTextColor;
}
</style>
\ No newline at end of file
<template>
<a-layout-header class="desktop-top-sider" style="background: #fff; padding: 0">
<!-- 菜单按钮 -->
<div class="trigger-btn">
<menu-unfold-outlined
v-if="collapsed"
class="trigger"
@click="clickCollapse"
/>
<menu-fold-outlined v-else class="trigger" @click="clickCollapse" />
</div>
<!-- <h3>主应用Vue数据:{{commonData}}</h3>
<button @click="minus">点击逐减Vue</button>
<h3>主应用React数据:{{reactNum}}</h3>
<button @click="add">点击逐加React</button> -->
<div class="right-btn">
<!-- 设置按钮 -->
<setting-button></setting-button>
<!-- 用户按钮 -->
<user-button></user-button>
</div>
</a-layout-header>
</template>
<script>
import SettingButton from './Sub/SettingButton';
import UserButton from './Sub/UserButton';
import {
MenuUnfoldOutlined,
MenuFoldOutlined,
SettingOutlined,
UserOutlined,
} from '@ant-design/icons-vue';
import actions from "@/micro/app-store";
import { useStore } from 'vuex';
import { reactive, toRefs, computed } from 'vue';
export default {
name: 'DesktopTopSider',
components: {
SettingButton,
UserButton,
MenuUnfoldOutlined,
MenuFoldOutlined,
SettingOutlined,
UserOutlined
},
setup(props, context) {
const store = useStore();
const state = reactive({
collapsed: false,
commonData: store.getters.commonData.parent,
reactNum: 0
});
const commonData = computed(() => store.getters.commonData.parent);
const clickCollapse = () => {
state.collapsed = !state.collapsed;
context.emit("collapsedStatus", state.collapsed);
};
const minus = () => {
state.commonData -= 1;
console.log(store)
store.dispatch('app/setCommonData', { parent: state.commonData });
}
const add = () => {
// 通知微应用数据发生变化
state.reactNum += 1;
actions.setGlobalState({ reactNum: state.reactNum });
console.log(actions);
}
return {
...toRefs(state),
clickCollapse,
commonData,
minus,
add
}
}
}
</script>
<style lang="less" scoped>
@import 'styles/variables.less';
@import 'styles/mixins.less';
.desktop-top-sider {
.flex-row;
.v-center;
justify-content: space-between;
.trigger-btn {
margin: 0 16px;
.trigger {
font-size: 19px;
color: @defaultThemeColor;
}
};
.right-btn {
.flex-row;
.v-center;
// .btn {
// margin-right: 35px;
// }
// .btn:last-child {
// margin-right: 30px;
// }
}
}
</style>
\ No newline at end of file
<template>
<SettingOutlined class="top-nav-right-btn setting-btn" />
</template>
<script>
import {
SettingOutlined,
} from '@ant-design/icons-vue';
import { reactive, toRefs } from 'vue';
export default {
name: 'SettingButton',
components: {
SettingOutlined
}
}
</script>
<style lang="less" scoped>
@import 'styles/common.less';
@import 'styles/variables.less';
.setting-btn {
font-size: 23px;
color: @defaultThemeColor;
}
</style>
<template>
<a-avatar class="top-nav-right-btn avatar-btn" :size="35">
<template v-slot:icon>
<UserOutlined />
</template>
</a-avatar>
</template>
<script>
import {
UserOutlined
} from '@ant-design/icons-vue';
import { reactive, toRefs } from 'vue';
export default {
name: 'UserButton',
components: {
UserOutlined
}
}
</script>
<style lang="less" scoped>
@import 'styles/common.less';
@import 'styles/variables.less';
.avatar-btn {
opacity: .8;
background-color: @defaultLightBlueColor;
}
</style>
\ No newline at end of file
<template>
<a-layout-footer class="home-footer">
Copyright ©2012-2015 粤ICP备12034057号 深圳广联赛讯有限公司 版权所有
</a-layout-footer>
</template>
<script>
export default {
name: 'HomeFooter'
}
</script>
<style lang="less" scoped>
.home-footer {
line-height: 5;
text-align: center;
color: #fff;
}
</style>
\ No newline at end of file
<template>
<a-layout-header class="header">
<Logo></Logo>
</a-layout-header>
</template>
<script>
import Logo from './Sub/Logo';
import { ref, reactive, toRefs } from 'vue';
export default {
name: "HomeHeader",
components: {
Logo
},
setup () {
const selectedKeys1 = ref(["2"]);
return {
selectedKeys1
}
}
}
</script>
<style lang="less" scoped>
@import 'styles/variables.less';
@import 'styles/mixins.less';
.header {
.common-home-bg-gradient;
box-shadow: 0 10px 60px rgba(0, 0, 0, 0.175) !important;
background-color: @defaultBgColor;
}
</style>
\ No newline at end of file
<template>
<div class="home-logo-wrapper">
<img class="home-logo-img" src="@/assets/images/home-logo.png" alt="home-logo">
<span class="home-logo-title">{{ homeTitle }}</span>
</div>
</template>
<script>
import { ref } from 'vue';
export default {
name: 'Logo',
setup () {
const homeTitle = ref('');
return { homeTitle };
}
}
</script>
<style lang="less" scoped>
.home-logo-wrapper {
float: left;
color: #fff;
font-size: 20px;
.home-logo-img {
margin-right: 10px;
}
.home-logo-title {
vertical-align: middle;
}
}
</style>
\ No newline at end of file
<template>
<div class="hello">
<h1>{{ msg }}</h1>
<p>
For a guide and recipes on how to configure / customize this project,<br>
check out the
<a href="https://cli.vuejs.org" target="_blank" rel="noopener">vue-cli documentation</a>.
</p>
<h3>Installed CLI Plugins</h3>
<ul>
<li><a href="https://github.com/vuejs/vue-cli/tree/dev/packages/%40vue/cli-plugin-babel" target="_blank" rel="noopener">babel</a></li>
<li><a href="https://github.com/vuejs/vue-cli/tree/dev/packages/%40vue/cli-plugin-router" target="_blank" rel="noopener">router</a></li>
<li><a href="https://github.com/vuejs/vue-cli/tree/dev/packages/%40vue/cli-plugin-vuex" target="_blank" rel="noopener">vuex</a></li>
</ul>
<h3>Essential Links</h3>
<ul>
<li><a href="https://vuejs.org" target="_blank" rel="noopener">Core Docs</a></li>
<li><a href="https://forum.vuejs.org" target="_blank" rel="noopener">Forum</a></li>
<li><a href="https://chat.vuejs.org" target="_blank" rel="noopener">Community Chat</a></li>
<li><a href="https://twitter.com/vuejs" target="_blank" rel="noopener">Twitter</a></li>
<li><a href="https://news.vuejs.org" target="_blank" rel="noopener">News</a></li>
</ul>
<h3>Ecosystem</h3>
<ul>
<li><a href="https://router.vuejs.org" target="_blank" rel="noopener">vue-router</a></li>
<li><a href="https://vuex.vuejs.org" target="_blank" rel="noopener">vuex</a></li>
<li><a href="https://github.com/vuejs/vue-devtools#vue-devtools" target="_blank" rel="noopener">vue-devtools</a></li>
<li><a href="https://vue-loader.vuejs.org" target="_blank" rel="noopener">vue-loader</a></li>
<li><a href="https://github.com/vuejs/awesome-vue" target="_blank" rel="noopener">awesome-vue</a></li>
</ul>
</div>
</template>
<script>
export default {
name: 'HelloWorld',
props: {
msg: String
}
}
</script>
<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped lang="scss">
h3 {
margin: 40px 0 0;
}
ul {
list-style-type: none;
padding: 0;
}
li {
display: inline-block;
margin: 0 10px;
}
a {
color: #42b983;
}
</style>
<template>
<a-layout-content class="home-content-wrapper">
<login-form></login-form>
</a-layout-content>
</template>
<script>
import LoginForm from './Sub/LoginForm';
export default {
name: 'HomeContent',
components: {
LoginForm
}
}
</script>
<style lang="less" scoped>
@import 'styles/variables.less';
@import 'styles/mixins.less';
.home-content-wrapper {
.h-center;
.common-home-bg-gradient;
background-color: @defaultBgColor;
width: 100%;
background: url(../../assets/images/svg/pattern-1.svg) no-repeat center bottom fixed;
background-size: cover;
}
</style>
\ No newline at end of file
<template>
<div class="login-form-wrapper">
<div class="login-content">
<div class="login-card-left">
<login-left-side></login-left-side>
</div>
<div class="login-card">
<div v-if="showAlert">
<a-alert v-for="(item, index) in alertArr"
:key="index"
:message="item" type="info" show-icon />
</div>
<h1 class="login-title">后台管理系统</h1>
<a-form layout="inline" :model="formInline" @submit="handleSubmit">
<a-form-item class="username-wrapper">
<a-input class="login-input username-input" size="large" :max="50" v-model:value="formInline.user" placeholder="用户名">
<template v-slot:prefix>
<UserOutlined style="color:rgba(0,0,0,.25)"/>
</template>
</a-input>
</a-form-item>
<a-form-item class="form-wrapper pwd-wrapper">
<a-input class="login-input" size="large" :max="50" v-model:value="formInline.password" type="password" placeholder="密码">
<template v-slot:prefix>
<LockOutlined style="color:rgba(0,0,0,.25)"/>
</template>
</a-input>
</a-form-item>
<a-form-item class="form-wrapper captcha-wrapper">
<a-input class="login-input" size="large" :max="6" v-model:value="formInline.captcha" placeholder="验证码"></a-input>
<div class="captcha-content" @click="updateCaptcha">
<img class="captcha-img" :src="captchaUrl" alt="验证码" />
</div>
</a-form-item>
<a-form-item class="login-button-wrapper">
<a-button
class="login-button"
type="primary"
html-type="submit"
>
登录
</a-button>
</a-form-item>
</a-form>
</div>
</div>
</div>
</template>
<script>
import { UserOutlined, LockOutlined } from '@ant-design/icons-vue';
import LoginLeftSide from './LoginLeftSide';
import { trimSpace, validate_username,
debounce } from '@/utils/tools/tools';
import LoginService from '@/services/Login';
import { reactive, toRefs, getCurrentInstance, computed } from 'vue';
import { useStore } from 'vuex';
import { useRouter } from 'vue-router';
export default {
components: {
LoginLeftSide,
UserOutlined,
LockOutlined,
},
setup(props, {attrs, emit, slots}) {
const router = useRouter();
const store = useStore();
const state = reactive({
alertMsg: '',
showAlert: false,
alertArr: [],
randomVal: '0',
formInline: {
user: '',
password: '',
captcha: '',
}
});
// 登录提交验证
const handleSubmit = async () => {
const value = state.formInline,
{ user, password, captcha } = value;
state.alertArr = [];
state.showAlert = false;
if(trimSpace(user).length <= 0) {
state.alertArr.push('请输入用户名');
state.showAlert = true;
return false;
}
if(!validate_username(user)) {
state.alertArr.push('用户名格式不正确');
state.showAlert = true;
return false;
}
if(trimSpace(password).length <= 0) {
state.alertArr.push('请输入密码');
state.showAlert = true;
return false;
}
if(trimSpace(captcha).length <= 0) {
state.alertArr.push('请输入验证码');
state.showAlert = true;
return false;
}
const loginService = new LoginService();
const params = { account: user, password, captcha};
await loginService.loginAction(params).then((res) => {
if(res.code === 200) {
const { token, user } = res.data;
localStorage.setItem('token', token);
store.dispatch('app/setUserInfo', user);
store.dispatch('app/setToken', token);
console.log('save user info', store.getters.userInfo);
} else {
const { message } = res;
state.alertArr.push(message);
state.showAlert = true;
}
}, (err) => {
})
};
const captchaUrl = computed(() => {
return `${store.getters.baseURL}/usercenter/captcha?rand=${state.randomVal}`;
})
const updateCaptcha = debounce(() => {
state.randomVal = Date.now();
}, 1000, true);
return {
...toRefs(state),
handleSubmit,
captchaUrl,
updateCaptcha
}
}
};
</script>
<style lang="less" scoped>
@import 'styles/mixins.less';
.login-form-wrapper {
margin-top: 150px;
.login-content {
display: flex;
width: 1190px;
height: 450px;
}
.login-card {
position: relative;
display: -webkit-box;
display: -ms-flexbox;
.flex-column;
-webkit-box-orient: vertical;
-webkit-box-direction: normal;
min-width: 0;
word-wrap: break-word;
background-color: #f7f9fa;
background-clip: border-box;
border-left: none;
border-radius: 4px;
width: 420px;
padding: 30px;
margin-left: 50px;
.ant-alert {
margin-bottom: 15px;
}
.login-title {
height: 55px;
font-size: 20px;
color: #2196F3;
}
.login-input {
margin-top: 30px;
}
.username-input {
margin-top: 0;
}
.captcha-wrapper {
.v-center;
justify-content: space-between;
.login-input {
width: 200px;
}
.captcha-content {
flex: 1;
margin-top: 30px;
height: 40px;
cursor: pointer;
.captcha-img {
width: 100%;
height: 100%;
}
}
}
.login-button-wrapper {
width: 100%;
display: flex;
justify-content: center;
margin-top: 45px;
.login-button {
width: 160px;
height: 40px;
box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.15), 0 1px 1px rgba(0, 0, 0, 0.075);
}
}
}
};
</style>
\ No newline at end of file
<template>
<div class="login-img-bg"></div>
</template>
<script>
export default {
name: 'LoginLeftSide'
}
</script>
<style lang="less" scoped>
.login-img-bg {
width: 680px;
height: 95%;
background: url(../../../assets/images/home-bg.png) no-repeat center center;
background-size: contain;
img {
width: 80%;
}
}
</style>
\ No newline at end of file
<template>
<div></div>
</template>
<script>
export default {
}
</script>
<style lang="less" scoped>
</style>
\ No newline at end of file
<template>
<div id="loading-box">
<div class="loading">
<a-spin></a-spin>
</div>
</div>
</template>
<script>
export default {
name: 'Loading'
}
</script>
<style lang="less" scoped>
@import 'styles/mixins.less';
#loading-box {
.vh-center;
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
.loading {
padding: 30px;
border-radius: 10px;
background: #fff;
}
}
</style>
\ No newline at end of file
import store from '@/store/index'
let BASE_URL = store.state.baseURL;
const MOCK_CONFIG_URL = 'https://oss-config.test.glsx.com.cn/mock/5be17454f31545347559d499/config';
const env = process.env.NODE_ENV;
if(!BASE_URL) {
BASE_URL = env === 'development' ? 'http://192.168.0.63:8880'
: '';
}
const API = {
getMockConfig() {
return MOCK_CONFIG_URL + '/e_sheild_config';
},
LOGIN_CAPTCHA: BASE_URL + '/usercenter/captcha', // 非接口,直接url可展示验证码
LOGIN_ACTION: BASE_URL + '/usercenter/login', // 登录接口
MENU_TREE_ACTION: BASE_URL + '/usercenter/menu/permtree', // 用户登录成功后拉取权限菜单
}
export {
API
}
\ No newline at end of file
/* 菜单本地配置
* type:1目录/2菜单/3按钮
*/
const menuTree = [
{
origin: {
parentId: 0,
menuName: "设备管理",
menuNo: 201,
type: 1,
icon: ''
},
children: [
{
origin: {
parentId: 201,
menuName: "ODB管理",
menuNo: 20101,
type: 2,
path: ''
}
}
]
},
{
origin: {
parentId: 0,
menuName: "系统管理",
menuNo: 101,
type: 1,
icon: ''
},
children: [
{
origin: {
parentId: 101,
menuName: "用户管理",
menuNo: 10101,
type: 2,
path: '/system#/user'
}
},
{
origin: {
parentId: 101,
menuName: "用户组管理",
menuNo: 10102,
type: 2,
path: ''
}
},
{
origin: {
parentId: 101,
menuName: "角色管理",
menuNo: 10103,
type: 2,
path: '/system#/role'
}
},
{
origin: {
parentId: 101,
menuName: "菜单管理",
menuNo: 10104,
type: 2,
path: '/system#/menuManage'
}
},
{
origin: {
parentId: 101,
menuName: "组织管理",
menuNo: 10105,
type: 2,
path: '/system#/orginizaManage'
}
},
{
origin: {
parentId: 101,
menuName: "字典管理",
menuNo: 10106,
type: 2,
path: '/system#/dictionaryManage'
}
},
{
origin: {
parentId: 101,
menuName: "操作日志",
menuNo: 10107,
type: 2,
path: '/system#/workLog'
}
},
]
}
]
export {
menuTree
};
\ No newline at end of file
......@@ -2,5 +2,17 @@ import { createApp } from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
import ant from '@/utils/globalAnt/ant'
createApp(App).use(store).use(router).mount('#app')
import microAppStart from "./micro/auth"
import './assets/css/resets.css'
const app = createApp(App);
app.use(store)
.use(router)
.use(ant)
.mount('#app');
microAppStart();
\ No newline at end of file
import { initGlobalState, MicroAppStateActions } from "qiankun";
import store from "@/store";
const initialState = {
reactNum: 0
// token: localStorage.token,
};
// 初始化 state
const actions = initGlobalState(initialState);
actions.onGlobalStateChange((state, prev) => {
console.log("主应用: 变更前");
console.log(prev);
console.log("主应用: 变更后");
console.log(state);
});
export default actions;
\ No newline at end of file
import store from '@/store';
import router from '@/router';
let defaultApp = null;
const apps = [
/**
* name: 微应用名称 - 具有唯一性
* entry: 微应用入口 - 通过该地址加载微应用
* container: 微应用挂载节点 - 微应用加载完成后将挂载在该节点上
* activeRule: 微应用触发的路由规则 - 触发路由规则后将加载该微应用
*/
{
name: "GLSXManagementSystemSub",
entry: "//localhost:10200",
container: "#sub-system-frame",
activeRule: "/system",
props: {
data: {
store,
router,
}
}
}
];
export default apps;
\ No newline at end of file
import qianKunStart from './index';
import store from '@/store';
import { getStorageToken } from '@/utils/storage/user';
const microAppStart = () => {
const token = getStorageToken();
/**
* @name 已登录状态获取服务端微应用注册表
*/
if (token) {
// 处理token状态共享
store.dispatch('app/setToken', token);
// getAppConfigs();
// return;
}
/**
* @name 默认加载未登录时无需服务端获取的微应用
*/
qianKunStart();
}
export default microAppStart
\ No newline at end of file
import { registerMicroApps, start, addGlobalUncaughtErrorHandler, setDefaultMountApp, initGlobalState } from 'qiankun';
import apps from './apps';
registerMicroApps(apps, {
// qiankun 生命周期钩子 - 加载前
beforeLoad: (app) => {
// 加载子应用前,加载进度条
// NProgress.start();
console.log("before load", app.name);
return Promise.resolve();
},
// qiankun 生命周期钩子 - 挂载后
afterMount: (app) => {
// 加载子应用前,进度条加载完成
// NProgress.done();
console.log("after mount", app.name);
return Promise.resolve();
},
});
/**
* 添加全局的未捕获异常处理器
*/
addGlobalUncaughtErrorHandler((event) => {
console.error(event);
// const { message: msg } = event;
// // 加载失败时提示
// if (msg && msg.includes("died in status LOADING_SOURCE_CODE")) {
// message.error("子应用加载失败,请检查应用是否可运行");
// }
});
setDefaultMountApp('/system');
// 导出 qiankun 的启动函数
export default start;
\ No newline at end of file
import { createRouter, createWebHistory } from 'vue-router'
import Home from '../views/Home.vue'
const routes = [
{
path: '/',
name: 'Home',
component: Home
name: 'Dashboard',
component: () => import('@/views/Dashboard.vue')
},
{
path: '/about',
name: 'About',
// route level code-splitting
// this generates a separate chunk (about.[hash].js) for this route
// which is lazy-loaded when the route is visited.
component: () => import(/* webpackChunkName: "about" */ '../views/About.vue')
}
path: '/login',
name: 'LoginPage',
component: () => import (
'../views/Login.vue'
)
},
{
path: "/404",
name: "notFound",
component: () => import('@/views/notFound.vue')
},
// {
// path: '/:pathMatch(.*)*',
// redirect: '/404'
// }
]
const router = createRouter({
history: createWebHistory(process.env.BASE_URL),
routes
})
// const childRoute = ['/vue','/react'];
// const isChildRoute = path => childRoute.some(item => path.startsWith(item))
// const rawAppendChild = HTMLHeadElement.prototype.appendChild;
// const rawAddEventListener = window.addEventListener;
// router.beforeEach((to, from, next) => {
// // 从子项目跳转到主项目
// if(isChildRoute(from.path) && !isChildRoute(to.path)){
// HTMLHeadElement.prototype.appendChild = rawAppendChild;
// window.addEventListener = rawAddEventListener;
// }
// next();
// });
export default router
import HTTP from '@/utils/http/http';
import { API } from '@/config/api';
export default class BaseService extends HTTP {
getBaseConfig () {
return new Promise((resolve, reject) => {
this.axiosGet({
url: API.getMockConfig(),
data: {},
success (data) {
resolve(data);
},
error (error) {
// 网络请求失败
console.log('网络请求失败');
// window.location.reload();
}
})
});
}
}
import HTTP from '@/utils/http/http';
import { API } from '@/config/api';
export default class LoginService extends HTTP {
loginAction (userInfo) {
return new Promise((resolve, reject) => {
this.axiosPost({
url: API.LOGIN_ACTION,
data: userInfo,
success (data) {
resolve(data);
},
error (error) {
console.log('登录,login接口请求失败');
}
})
});
}
}
import HTTP from '@/utils/http/http';
import { API } from '@/config/api';
export default class MenuService extends HTTP {
getMenuTree (params) {
return new Promise((resolve, reject) => {
this.axiosGet({
url: API.MENU_TREE_ACTION,
data: params,
success (data) {
resolve(data);
},
error (error) {
console.log('menu/permtree接口请求失败');
}
})
});
}
}
const getters = {
token: state => state.app.token,
userInfo: state => state.app.userInfo,
baseURL: state => state.app.baseURL,
showLoading: state => state.app.showLoading,
menu: state => state.menu.menu,
curBreadCrumb: state => state.menu.curBreadCrumb,
commonData: state => state.app.commonData
}
export default getters;
\ No newline at end of file
import { createStore } from 'vuex'
import { createStore } from 'vuex';
import getters from './getters';
// import state from './state';
// import mutations from './mutations';
const modulesFiles = require.context('./modules', true, /\.js$/)
// you do not need `import app from './modules/app'`
// it will auto require all vuex module from modules file
const modules = modulesFiles.keys().reduce((modules, modulePath) => {
// set './app.js' => 'app'
const moduleName = modulePath.replace(/^\.\/(.*)\.\w+$/, '$1')
const value = modulesFiles(modulePath)
modules[moduleName] = value.default
return modules
}, {})
console.log(modules)
export default createStore({
state: {
},
mutations: {
},
actions: {
},
modules: {
}
modules,
getters
})
export default {
namespaced: true,
state: {
baseURL: '',
size: 10, // 分页 页大小
token: '',
userInfo: {},
showLoading: false,
commonData: {
parent: 0
}
},
mutations: {
SET_BASE_URL(state, data) {
state.baseURL = data;
},
SET_COMMON_DATA(state, data){
state.commonData = data;
},
// 设置token
SET_TOKEN(state, data) {
state.token = data;
},
SET_USER_INFO(state, data) {
state.userInfo = data;
},
SHOW_LOADING(state, data) {
state.showLoading = data;
}
},
actions: {
// 更新接口地址
updateBaseURL({ commit }, data) {
console.log('in actions', data);
commit('SET_BASE_URL', data)
},
// 设置token
setToken({ commit }, data) {
commit('SET_TOKEN', data)
},
// 获取公共假数据
setCommonData({ commit }, data) {
commit('SET_COMMON_DATA', data)
},
setUserInfo({ commit }, data) {
commit('SET_USER_INFO', data)
},
// 自定义loading
showLoading({ commit }, data) {
commit('SHOW_LOADING', data)
},
}
}
\ No newline at end of file
export default {
namespaced: true,
state: {
is_collapse: false, // 折叠状态
menu: [], // 菜单数据
curBreadCrumb: {}
},
mutations: {
// 推入用户菜单
ADD_USER_MENU(state, data) {
state.menu = data;
},
// 设置折叠状态
SET_COLLAPSE_STATUS(state, data) {
state.is_collapse = data;
},
// 设置面包屑
SET_BREAD_CRUMB(state, data) {
state.curBreadCrumb = data;
},
},
actions: {
// 推入用户菜单
setUserMenu({ commit }, data) {
commit('ADD_USER_MENU', data)
},
// 设置折叠状态
setCollapseStatus({ commit }, data) {
commit('SET_COLLAPSE_STATUS', data)
},
// 设置面包屑
setBreadCrumb({ commit }, data) {
commit('SET_BREAD_CRUMB', data)
},
}
}
\ No newline at end of file
import {
Button,
Layout,
Menu,
Col,
Row,
Form,
Input,
Alert,
Avatar,
Popover,
Dropdown,
Spin,
Breadcrumb
} from "ant-design-vue";
const ant = {
install(Vue) {
Vue.component(Button.name, Button);
Vue.component(Layout.name, Layout);
Vue.component(Layout.Header.name, Layout.Header);
Vue.component(Layout.Content.name, Layout.Content);
Vue.component(Layout.Sider.name, Layout.Sider);
Vue.component(Menu.name, Menu);
Vue.component(Menu.Item.name, Menu.Item);
Vue.component(Menu.SubMenu.name, Menu.SubMenu);
Vue.component(Col.name, Col);
Vue.component(Row.name, Row);
Vue.component(Form.name, Form);
Vue.component(Input.name, Input);
Vue.component(Alert.name, Alert);
Vue.component(Avatar.name, Avatar);
Vue.component(Popover.name, Popover);
Vue.component(Dropdown.name, Dropdown);
Vue.component(Spin.name, Spin);
Vue.component(Breadcrumb.name, Breadcrumb);
},
};
export default ant;
\ No newline at end of file
import { Modal, message as Message, notification } from 'ant-design-vue';
import { InfoCircleFilled, CheckCircleFilled, CloseCircleFilled } from '@ant-design/icons-vue';
// import { ModalOptions, ModalConfirm } from 'ant-design-vue/types/modal';
/**
* @description: Create confirmation box
*/
function createConfirm(options) {
const iconType = options.iconType || 'warning';
Reflect.deleteProperty(options, 'iconType');
const opt = {
centered: true,
icon: getIcon(iconType),
...projectSetting.messageSetting,
...options,
};
return Modal.confirm(opt);
}
const baseOptions = {
okText: '确定',
centered: true,
};
function createModalOptions(options, icon) {
return {
...baseOptions,
...options,
content: renderContent(options),
icon: getIcon(icon),
};
}
function createSuccessModal(options) {
return Modal.success(createModalOptions(options, 'check'));
}
function createErrorModal(options) {
return Modal.error(createModalOptions(options, 'close'));
}
function createInfoModal(options) {
return Modal.info(createModalOptions(options, 'info'));
}
function createWarningModal(options) {
return Modal.warning(createModalOptions(options, 'info'));
}
/**
* @description: message
*/
export function useMessage() {
return {
createMessage: Message,
notification,
createConfirm: createConfirm,
createSuccessModal,
createErrorModal,
createInfoModal,
createWarningModal,
};
}
\ No newline at end of file
import store from '@/store';
import { useMessage } from '@/utils/globalAnt/antMsg';
const { createMessage } = useMessage();
const error = createMessage.error;
export function checkStatus(status, msg) {
switch (status) {
case 400:
error(`Bad Request 错误的请求`);
break;
case 401:
error('用户没有权限(令牌、用户名、密码错误)!');
break;
case 403:
error('用户得到授权,但是访问是被禁止的。!');
break;
// 404请求不存在
case 404:
error('网络请求错误,未找到该资源!');
break;
case 405:
error('网络请求错误,请求方法未允许!');
break;
case 408:
error('网络请求超时!');
break;
case 500:
error('服务器错误,请联系管理员!');
break;
case 501:
error('网络未实现!');
break;
case 502:
error('网络错误!');
break;
case 503:
error('服务不可用,服务器暂时过载或维护!');
break;
case 504:
error('网络超时!');
break;
case 505:
error('http版本不支持该请求!');
break;
case 603:
error('尚未登录或登录已过期,请重新登录');
store.dispatch('app/setToken', '');
localStorage.removeItem('token');
break;
case 505:
error('http版本不支持该请求!');
break;
case 'fail':
error('网络连接错误');
break;
case 'custom':
error(`${msg}`);
break;
default:
}
}
\ No newline at end of file
import axios from 'axios';
import store from '@/store';
import { checkStatus } from './checkStatus';
const instance = axios.create({ //创建axios实例,在这里可以设置请求的默认配置
timeout: 60000, // 设置超时时间60s
retry: 3,
retryDelay: 1000
})
// 统一设置post请求头
instance.defaults.headers.post['Content-Type'] = 'application/json';
/** 添加请求拦截器 **/
instance.interceptors.request.use(config => {
config.headers['Authorization'] = localStorage.getItem('token') || '';
store.dispatch('app/showLoading', true);
return config
}, error => {
console.log('请求错误,原因:', error)
store.dispatch('app/showLoading', false);
return Promise.reject(error)
})
/** 添加响应拦截器 **/
instance.interceptors.response.use(response => {
store.dispatch('app/showLoading', false);
const serverCode = response.data.code;
if (serverCode === 200 || response.status === 200) {
if(serverCode !== 200) {
checkStatus(serverCode);
}
if(response.status) {
return Promise.resolve(response);
}
return Promise.resolve(response.data);
} else {
checkStatus(serverCode);
return Promise.reject(response.data.message)
}
}, error => {
store.dispatch('app/showLoading', false);
const errRes = error.response;
if (errRes) {
const { data, config, status, statusText } = errRes;
checkStatus(status);
console.log(`${config.url} 接口请求出错,状态码${status}`);
return Promise.reject(error);
} else {
checkStatus('fail');
console.log('http request fail 请求失败');
return Promise.reject(new Error('请求失败'))
}
//超时处理
var config = error.config;
if (!config || !config.retry) return Promise.reject(error);
// 设置用于跟踪重试次数的变量
config.__retryCount = config.__retryCount || 0;
// 检查我们是否已将重试总数最大化
if (config.__retryCount >= config.retry) {
// 错误拒绝
return Promise.reject(error);
}
// 增加重试次数
config.__retryCount += 1;
// 创造新的承诺来处理指数退避
var backoff = new Promise(function (resolve) {
setTimeout(function () {
resolve();
}, config.retryDelay || 1);
});
// 返回承诺,其中将撤回axios以重试请求
return backoff.then(function () {
return axios(config);
});
})
export default class HTTP {
axiosPost (options) {
instance({
url: options.url,
method: 'post',
data: JSON.stringify(options.data)
}).then((res) => {
options.success(res.data);
}).catch((err) => {
options.error(err);
})
}
axiosGet (options) {
instance({
url: options.url,
method: 'get'
}).then((res) => {
options.success(res.data);
}).catch((err) => {
options.error(err);
})
}
}
\ No newline at end of file
/**
* @name 浏览器本地存储是否有用户的登陆信息
*/
const getStorageToken = () => {
return localStorage.getItem('token');
}
export {
getStorageToken
}
\ No newline at end of file
import store from '@/store/index';
// trimSpace(str).length < = 0 弹出错误校验提示
const trimSpace = (str) => {
return str.replace(/\s+/g, '');
}
// 节流
const throttle = (fn, delay) => {
var t = null,
begin = new Date().getTime();
return function () {
var _self = this,
args = arguments,
cur = new Date().getTime();
clearTimeout(t);
if(cur - begin >= delay) {
fn.apply(_self, args);
begin = cur;
} else {
t = setTimeout(function () {
fn.apply(_self, args);
}, delay);
}
}
}
// 防抖 防暴击
const debounce = (fn, delay, triggerNow) => {
var t = null;
var debounced = function(){
var _self = this,
args = arguments;
if(t){
clearTimeout(t);
}
if(triggerNow){
var exec = !t;
t = setTimeout(function(){
t = null;
}, delay);
if(exec){
// 初次进来
fn.apply(_self, args);
}
}else{
t = setTimeout(function(){
fn.apply(_self, args);
}, delay);
}
}
debounced.remove = function(){
clearTimeout(t);
t = null;
}
return debounced;
}
// 用户名校验:中文、英文、数字、英文下划线、英文括号 长度50
const validate_username = (str) => {
const reg = /^[A-Za-z0-9-\(\)\_\u4e00-\u9fa5]{3,50}$/;
if(!reg.test(str)) {
// 验证不通过
return false;
} else {
return true
}
}
// 展示loading 自定义的loading页面
const showLoading = () => {
store.dispatch('app/showLoading', true);
}
// 隐藏loading 自定义的loading页面
const hideLoading = () => {
store.dispatch('app/showLoading', false);
}
// 深拷贝
const deepClone = (origin, tar) => {
let target = tar || {},
toStr = Object.prototype.toString,
arrType = '[object Array]';
for(let key in origin) {
if(origin.hasOwnProperty(key)) {
if(typeof(origin[key]) === 'object' && origin[key] !== null) {
toStr.call(origin[key]) === arrType ? target[key] = []
: target[key] = {};
deepClone(origin[key, target[key]]);
} else {
target[key] = origin[key];
}
}
}
return target;
}
export {
trimSpace,
throttle,
debounce,
validate_username,
showLoading,
hideLoading
}
\ No newline at end of file
<template>
<div class="about">
<h1>This is an about page</h1>
</div>
<div>这是父系统的about页面</div>
</template>
<script>
export default {
name: 'About'
}
</script>
<style scoped>
</style>
\ No newline at end of file
<template>
<a-layout class="container">
<desktop-left-sider :collapsed="collapsed"></desktop-left-sider>
<a-layout id="desktop-right-sider">
<desktop-top-sider v-on:collapsedStatus="getCollapsed"></desktop-top-sider>
<desktop-right-sider></desktop-right-sider>
</a-layout>
</a-layout>
</template>
<script>
import DesktopLeftSider from 'components/DesktopLeftSider/DesktopLeftSider';
import DesktopTopSider from 'components/DesktopTopSider/DesktopTopSider';
import DesktopRightSider from 'components/DesktopRightSider/DesktopRightSider';
import { reactive, toRefs, onMounted } from 'vue';
export default {
name: "Desktop",
components: {
DesktopLeftSider,
DesktopTopSider,
DesktopRightSider
},
setup () {
const state = reactive({
collapsed: false
});
const getCollapsed = (data) => {
state.collapsed = data;
};
onMounted(() => {
});
return {
...toRefs(state),
getCollapsed
}
}
}
</script>
<style lang="less" scoped>
@import 'styles/variables.less';
.container {
height: 100vh;
#desktop-right-sider .trigger {
font-size: 18px;
line-height: 64px;
padding: 0 24px;
cursor: pointer;
transition: color 0.3s;
}
#desktop-right-sider .trigger:hover {
color: #1890ff;
}
#desktop-right-sider .logo {
height: 32px;
background: rgba(255, 255, 255, 0.2);
margin: 16px;
}
}
</style>
\ No newline at end of file
<template>
<div class="home">
<img alt="Vue logo" src="../assets/logo.png">
<HelloWorld msg="Welcome to Your Vue.js App"/>
</div>
</template>
<script>
// @ is an alias to /src
import HelloWorld from '@/components/HelloWorld.vue'
export default {
name: 'Home',
components: {
HelloWorld
}
}
</script>
<template>
<a-layout class="container">
<home-header></home-header>
<home-content></home-content>
<home-footer></home-footer>
</a-layout>
</template>
<script>
import HomeHeader from 'components/Header/HomeHeader';
import HomeContent from 'components/HomeContent/HomeContent';
import HomeFooter from 'components/Footer/HomeFooter';
import { onMounted } from 'vue';
export default {
name: "LoginPage",
components: {
HomeHeader,
HomeContent,
HomeFooter
},
setup () {
onMounted(() => {
});
}
}
</script>
<style lang="less" scoped>
@import 'styles/variables.less';
.ant-layout {
position: fixed;
height: 100%;
top: 0;
left: 0;
width: 100%;
min-width: 1190px;
background-color: @defaultBgColor;
}
</style>
\ No newline at end of file
<template>
<div>404</div>
</template>
<script>
export default {
}
</script>
<style scoped>
</style>
\ No newline at end of file
const path = require("path");
function resolve(dir) {
return path.join(__dirname, dir);
}
module.exports = {
runtimeCompiler: true,
devServer: {
// overlay: {
// warning: false,
// errors: false
// },
headers: {
'Access-Control-Allow-Origin': '*',
},
port: 8081,
// proxy: {
// "/react": {
// target: "https://baidu.com",
// changeOrigin: true,
// ws: true,
// secure: false,
// pathRewrite: {
// "^/react": ""
// }
// }
// }
},
// lintOnSave: false,
chainWebpack: config => {
config.resolve.alias
.set("@", resolve("src"))
.set("styles", resolve("src/assets/css"))
.set("images", resolve("src/assets/images"))
.set("views", resolve("src/views"))
.set("components", resolve("src/components"))
.set("config", resolve("src/config"))
.set("utils", resolve("src/utils"))
.set("services", resolve("src/services"));
},
css: {
loaderOptions: {
less: {
lessOptions: {
modifyVars: {
'primary-color': '#2196F3',
'link-color': '#1DA57A',
'border-radius-base': '2px',
},
javascriptEnabled: true,
},
},
},
}
}
\ No newline at end of file
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!