Commit 8826207c authored by 刘阳's avatar 刘阳

init

parent 4ec1d349
...@@ -11,6 +11,6 @@ module.exports = { ...@@ -11,6 +11,6 @@ module.exports = {
...agentList ...agentList
}, },
publicPath: '/customTmplate-vue3', publicPath: '/customTmplate-vue3',
outputDir: 'customTmplate-vue3' outputDir: 'customTmplate-vue3',
} }
\ No newline at end of file
<template> <template>
<div id="app"> <div :class="mode">
<g-header /> <basic-menu />
<div id="nav"> <div class="content">
<router-link to="/">Home</router-link> | <geek-header v-if="mode === 'vertical'" />
<router-view />
</div> </div>
<router-view/>
</div> </div>
</template> </template>
<script lang="ts"> <script lang="ts">
import BasicMenu from "./components/menuNav/src/BasicMenu.vue";
import { Header } from '@/components' import { GeekHeader } from "@/components";
import { menuData } from "@/constant";
export default { export default {
components: { components: { BasicMenu, GeekHeader },
GHeader: Header data() {
const { mode } = menuData;
return {
mode: mode,
editableTabsValue: "2",
editableTabs: [
{
title: "Tab 1",
name: "1",
content: "Tab 1 content"
} }
} ]
};
},
watch: {
// $route: {
// handler: function( val:any, oldVal:any) {
// console.log(val);
// },
// // 深度观察监听
// deep: true
// }
}
};
</script> </script>
<style lang='scss'> <style lang="scss" scoped>
#app { .vertical {
font-family: Avenir, Helvetica, Arial, sans-serif; display: flex;
-webkit-font-smoothing: antialiased; flex-direction: row;
-moz-osx-font-smoothing: grayscale;
text-align: center;
color: #2c3e50;
} }
.horizontal {
#nav { display: flex;
padding: 30px; flex-direction: column;
} }
.content {
#nav a { display: flex;
font-weight: bold; flex: 1;
color: #2c3e50; flex-direction: column;
} }
#nav a.router-link-exact-active { .el-header {
color: #42b983; color: #333;
line-height: 60px;
} }
</style> </style>
<template>
<el-header class="gk-header" style="text-align: right; font-size: 14px">
<el-dropdown>
<i class="el-icon-setting" style="margin-right: 15px"></i>
<template #dropdown>
<el-dropdown-menu>
<el-dropdown-item @click="handleClick(item)" v-for="(item, index) in rightMenu" :key="index">{{
item.value
}}</el-dropdown-item>
</el-dropdown-menu>
</template>
</el-dropdown>
<span>王小虎</span>
</el-header>
</template>
<script>
import { menuData } from "@/constant";
export default {
data() {
const { rightMenu } = menuData
return {
rightMenu
};
},
methods: {
handleClick(item){
console.log('ss',item)
}
},
};
</script>
<style lang="scss" scoped>
.gk-header {
height: 64px;
width: 100%;
border: solid 1px #f5f5f5;
}
</style>
<template>
<div class="gk-header">
</div>
</template>
<style lang="scss" scoped>
.gk-header {
height: 64px;
width: 100%;
background-color: blue;
}
</style>
/* eslint-disable import/prefer-default-export */ /* eslint-disable import/prefer-default-export */
import Header from './header/index.vue'; import GeekHeader from './geekHeader/index.vue';
export { export {
Header, GeekHeader,
}; };
import BasicMenu from './src/BasicMenu.vue'
export { BasicMenu }
\ No newline at end of file
<template>
<div :class="mode=== 'horizontal'? 'horizontal-content':''">
<div :class="mode=== 'horizontal'?'horizontal':''">
<div class="header" @click="controllCollapse">
<img :src="headerImg" width="56" alt="" srcset="" />
</div>
<el-menu
:collapse="isCollapse"
:mode="mode"
:router="router"
:class="mode"
>
<div v-for="(item, index) in routers" :key="index">
<el-submenu
v-if="item.children && item.children.length > 0"
:index="item.path ? item.path : index + ''"
>
<template #title>
<i :class="item.icon"></i>
<span v-if="!isCollapse">{{ item.title }}</span>
</template>
<el-menu-item
v-for="(child, childIndex) in item.children"
:key="childIndex"
:index="child.path ? `${item.path}/${child.path}` : `${index}-${childIndex}`"
>
<i v-if="child.icon" :class="child.icon"></i>
{{ child.title }}</el-menu-item
>
</el-submenu>
<el-menu-item v-else :index="item.path ? item.path : index + ''">
<i :class="item.icon"></i>
<template #title>{{ item.title }}</template>
</el-menu-item>
</div>
</el-menu>
</div>
<el-header v-if="mode==='horizontal'" class="gk-header" style="text-align: right; font-size: 14px">
<el-dropdown>
<i class="el-icon-setting" style="margin-right: 15px"></i>
<template #dropdown>
<el-dropdown-menu >
<el-dropdown-item @click="handleClick(item)" v-for="(item,index) in rightMenu" :key="index">{{item.value}}</el-dropdown-item>
</el-dropdown-menu>
</template>
</el-dropdown>
<span>王小虎</span>
</el-header>
</div>
</template>
<script>
import { menuData } from "@/constant";
export default {
data() {
const { isCollapse, router, routers, mode, headerImg ,rightMenu} = menuData;
return {
isCollapse,
router,
routers,
mode,
headerImg,
rightMenu
};
},
methods: {
controllCollapse() {
if(this.mode === 'horizontal') return
this.isCollapse = !this.isCollapse;
},
handleClick(item){
console.log('sss',item)
}
}
};
</script>
<style scoped>
::v-deep .vertical:not(.el-menu--collapse) {
min-height: 800px;
width: 200px;
}
.horizontal {
display: flex;
flex-direction: row;
align-items: center;
padding: 0px 10px;
justify-content: space-between;
}
::v-deep .el-menu--collapse {
min-height: 800px;
}
::v-deep .el-submenu__icon-arrow {
top: 53%;
right: 5px;
}
.horizontal-content {
display: flex;
flex-direction: row;
justify-content: space-between;
}
.header {
line-height: 60px;
display: flex;
justify-content: center;
padding: 10px 0px;
}
.el-header {
color: #333;
line-height: 60px;
}
</style>
export default {
const menuData = {
isCollapse: false,
router: true,
// horizontal vertical
mode: 'vertical',
headerImg:'https://i.gtimg.cn/club/item/face/img/2/15922_100.gif',
routers: [
{
title: "导航一",
icon: "el-icon-location",
path: "home",
children: [
{
title: "导航三",
icon: "el-icon-document",
path: "next"
},
{
title: "导航二",
icon: "el-icon-menu",
children: [],
path: ""
}
]
},
{
title: "导航二",
icon: "el-icon-menu",
path: "",
children: [
{
title: "导航二2",
icon: "el-icon-setting"
},
{
title: "导航二",
icon: "el-icon-menu",
children: []
}
]
},
{
title: "导航三",
icon: "el-icon-document",
children: [],
path: ""
},
{
title: "导航四",
icon: "el-icon-setting",
children: [
{
title: "导航二",
icon: "el-icon-menu",
children: [],
path: ""
}
],
path: ""
}
],
rightMenu:[
{
key:'',
value: '查看s'
},
{
key:'',
value: '新增'
},
{
key:'',
value: '删除'
}
]
}
export {
menuData
} }
\ No newline at end of file
...@@ -3,8 +3,18 @@ import Home from '../views/Home.vue'; ...@@ -3,8 +3,18 @@ import Home from '../views/Home.vue';
const routes: Array<RouteRecordRaw> = [ const routes: Array<RouteRecordRaw> = [
{ {
path: '/', path: '/home',
name: 'Home', name: 'home',
component: Home,
children: [ {
path: 'next',
name:'next',
component: Home,
}]
},
{
path: '/next',
name: 'next',
component: Home, component: Home,
} }
]; ];
......
<template> <template>
<div class="home"> <el-container style="height: 500px;margin:10px; border: 1px solid #eee">
<img alt="Vue logo" src="@/assets/images/logo.png"> <el-container>
<p>{{ state.name }}</p> <el-main >
<el-button type="primary" @click="update"> ss </el-button> <div>
<div style="margin-bottom: 20px;">
<el-button size="small" @click="addTab(editableTabsValue)">
add tab
</el-button>
</div> </div>
<el-tabs v-model="editableTabsValue" type="card" closable @tab-remove="removeTab">
<el-tab-pane
v-for="(item, index) in editableTabs"
:key="item.name + index"
:label="item.title"
:name="item.name"
>
{{ item.content }}
</el-tab-pane>
</el-tabs>
</div>
</el-main>
</el-container>
</el-container>
</template> </template>
<script lang="ts"> <script>
import { computed, reactive, toRefs } from 'vue'
import { useStore } from 'vuex';
export default { export default {
name: 'Home', components: { },
components: { data() {
const item = {
date: "2016-05-02",
name: "王小虎",
address: "上海市普陀区金沙江路 1518 弄"
};
return {
tableData: Array(20).fill(item),
editableTabsValue: "2",
editableTabs: [
{
title: "Tab 1",
name: "1",
content: "Tab 1 content"
}
],
tabIndex: 2,
isCollapse: false,
windowHeight: document.documentElement.clientHeight
};
}, },
setup() { methods: {
const store = useStore() controllCollapse() {
const info = reactive({ this.isCollapse = !this.isCollapse;
nnn: '1232', },
a: 242 addTab(targetName) {
}) let newTabName = ++this.tabIndex + "";
this.editableTabs.push({
const update = () => { title: "New Tab",
store.commit('hello/changeName', new Date().getTime()) name: newTabName,
content: "New Tab content"
});
this.editableTabsValue = newTabName;
},
removeTab(targetName) {
let tabs = this.editableTabs;
let activeName = this.editableTabsValue;
if (activeName === targetName) {
tabs.forEach((tab, index) => {
if (tab.name === targetName) {
let nextTab = tabs[index + 1] || tabs[index - 1];
if (nextTab) {
activeName = nextTab.name;
}
}
});
} }
const state = computed(() => store.state.hello) this.editableTabsValue = activeName;
this.editableTabs = tabs.filter(tab => tab.name !== targetName);
return {
...toRefs(info),
state,
update,
} }
} }
} };
</script> </script>
<style lang="scss" scoped>
</style>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment