ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
[toc] ### 1. 优化底部容量提示,将容量提示放到sider中 ``` <template> <Layout class="layout"> <Header class="bg-white px-0 layout-header"> <Menu @on-select="handleSelect" mode="horizontal" theme="light" :active-name="topActive" class="d-flex align-items-center"> <div class="layout-logo">企业网盘</div> <MenuItem :name="index" v-for="(item,index) in topMenus" :key="index"> <Icon :type="item.icon" /> {{item.title}} </MenuItem> <div class="ml-auto mr-3"> <Dropdown style="margin-left: 20px" placement="bottom-end"> <a href="javascript:void(0)"> <Avatar src="https://i.loli.net/2017/08/21/599a521472424.jpg" /> 管理员 <Icon type="ios-arrow-down"></Icon> </a> <DropdownMenu slot="list"> <DropdownItem>个人资料</DropdownItem> <DropdownItem>修改密码</DropdownItem> <DropdownItem>安全退出</DropdownItem> </DropdownMenu> </Dropdown> </div> </Menu> </Header> <Layout> <Sider hide-trigger class="sider"> <Menu @on-select="handleSiderSelect" class="sider-menu" theme="light" active-name="1" width="200px"> <MenuGroup title="全部文件"> <MenuItem name="1"> <Icon type="md-document" /> 图片 </MenuItem> <MenuItem name="2"> <Icon type="md-chatbubbles" /> 视频 </MenuItem> <MenuItem name="3"> <Icon type="md-chatbubbles" /> 音乐 </MenuItem> <MenuItem name="4"> <Icon type="md-chatbubbles" /> 其他 </MenuItem> </MenuGroup> <MenuGroup title="其他操作"> <MenuItem name="5"> <Icon type="md-heart" /> 我的分享 </MenuItem> <MenuItem name="6"> <Icon type="md-leaf" /> 回收站 </MenuItem> </MenuGroup> </Menu> <div class="footer-left px-3"> <Progress :percent="90" :stroke-color="['#108ee9', '#87d068']" hide-info /> <div class="d-flex mt-2 justify-content-between"> <small>总共: 100GB</small> <small class="text-warning">已用: 90GB</small> </div> </div> </Sider> <Content class="bg-white">主内容</Content> </Layout> </Layout> </template> <script> export default { data() { return { topActive: 0, topMenus: [{ icon: "ios-paper", title: "网盘" }, { icon: "ios-people", title: "分享" }, { icon: "ios-construct", title: "更多" } ] } }, methods: { handleSelect(e) { console.log(e) this.topActive = e; }, handleSiderSelect(e) { console.log(e) } } } </script> <style scoped="scoped"> .footer-left /deep/ .ivu-progress-inner { background: #fff !important; border: 1px solid #eee !important; } .layout { height: 100%; } .footer-left { width: 200px; background-color: #ebf0f1; height: 55px; position: absolute; bottom:0; left : 0; } .layout-logo { width: 200px; text-align: center; font-size: 25px; } .layout-header { height: 60px; line-height: 60px; } .sider{ position: relative; } .sider, .sider-menu { background-color: #ebf0f1; } </style> ``` ### 2. 解决content区域滚动条滚动问题 ``` <template> <Layout class="layout"> <Header class="bg-white px-0 layout-header"> <Menu @on-select="handleSelect" mode="horizontal" theme="light" :active-name="topActive" class="d-flex align-items-center"> <div class="layout-logo">企业网盘</div> <MenuItem :name="index" v-for="(item,index) in topMenus" :key="index"> <Icon :type="item.icon" /> {{item.title}} </MenuItem> <div class="ml-auto mr-3"> <Dropdown style="margin-left: 20px" placement="bottom-end"> <a href="javascript:void(0)"> <Avatar src="https://i.loli.net/2017/08/21/599a521472424.jpg" /> 管理员 <Icon type="ios-arrow-down"></Icon> </a> <DropdownMenu slot="list"> <DropdownItem>个人资料</DropdownItem> <DropdownItem>修改密码</DropdownItem> <DropdownItem>安全退出</DropdownItem> </DropdownMenu> </Dropdown> </div> </Menu> </Header> <Layout> <Sider hide-trigger class="sider"> <Menu @on-select="handleSiderSelect" class="sider-menu" theme="light" active-name="1" width="200px"> <MenuGroup title="全部文件"> <MenuItem name="1"> <Icon type="md-document" /> 图片 </MenuItem> <MenuItem name="2"> <Icon type="md-chatbubbles" /> 视频 </MenuItem> <MenuItem name="3"> <Icon type="md-chatbubbles" /> 音乐 </MenuItem> <MenuItem name="4"> <Icon type="md-chatbubbles" /> 其他 </MenuItem> </MenuGroup> <MenuGroup title="其他操作"> <MenuItem name="5"> <Icon type="md-heart" /> 我的分享 </MenuItem> <MenuItem name="6"> <Icon type="md-leaf" /> 回收站 </MenuItem> </MenuGroup> </Menu> <div class="footer-left px-3"> <Progress :percent="90" :stroke-color="['#108ee9', '#87d068']" hide-info /> <div class="d-flex mt-2 justify-content-between"> <small>总共: 100GB</small> <small class="text-warning">已用: 90GB</small> </div> </div> </Sider> <Content class="bg-white layout-content"> <div class="content-box"> <router-view></router-view> </div> </Content> </Layout> </Layout> </template> <script> export default { data() { return { topActive: 0, topMenus: [{ icon: "ios-paper", title: "网盘" }, { icon: "ios-people", title: "分享" }, { icon: "ios-construct", title: "更多" } ] } }, methods: { handleSelect(e) { console.log(e) this.topActive = e; }, handleSiderSelect(e) { console.log(e) } } } </script> <style scoped="scoped"> .footer-left /deep/ .ivu-progress-inner { background: #fff !important; border: 1px solid #eee !important; } .layout { height: 100%; } .footer-left { width: 200px; background-color: #ebf0f1; height: 55px; position: absolute; bottom:0; left : 0; } .layout-logo { width: 200px; text-align: center; font-size: 25px; } .layout-header { height: 60px; line-height: 60px; } .sider{ position: relative; } .sider, .sider-menu { background-color: #ebf0f1; } .layout-content{ position: relative; } .content-box{ position: absolute; overflow-y: auto; bottom: 0; top: 0; right: 0; left: 0; } </style> ``` ### 3. 在pages目录内创建template文件夹 ### 4. 在template文件夹内创建index.vue ### 5. 配置index.vue组件的路由 ``` import Vue from "vue"; import VueRouter from "vue-router"; Vue.use(VueRouter); const routes = [ { path: "/login", name: "login", component: () => import( "../views/login.vue") }, { path: "/", redirect : "/index", name: "layout", component: () => import("../views/layout.vue"), children : [ { path : "/index", name : "index", component: () => import("../views/index.vue") } ] } ]; const router = new VueRouter({ mode: "history", base: process.env.BASE_URL, routes }); export default router; ``` ### 6.实现网盘主布局的顶部操作条 ``` <template> <div> <div class="index-top border-bottom d-flex px-3 py-2"> <Button type="primary" icon="ios-search" class="mr-2">上传</Button> <Button icon="ios-search" class="mr-2">新建文件夹</Button> <Button icon="ios-search" class="mr-2">下载</Button> <Button icon="ios-search" class="mr-2">分享</Button> <Button icon="ios-search" class="mr-2">重命名</Button> <Button icon="ios-search" class="mr-2">删除</Button> <Input class="ml-auto top-search" search enter-button placeholder="请输入关键词" /> </div> </div> </template> <script> </script> <style scoped="scoped"> .index-top{ position: absolute; top : 0; left: 0; right: 0; } .top-search{ width: 200px; } </style> ```