'layout框架'

main
fwb 1 month ago
parent f7ef90558a
commit 1f52d0c047
  1. 57
      src/layout/index.vue
  2. 11
      src/main.ts
  3. 6
      src/router/routes.ts
  4. 19
      src/styles/index.scss
  5. 253
      src/styles/reset.scss
  6. 21
      src/styles/variable.scss
  7. 27
      src/views/404/index.vue
  8. 18
      src/views/home/index.vue
  9. 2
      src/views/login/index.vue

@ -0,0 +1,57 @@
<template>
<div class="layout_container">
<!--左侧菜单-->
<div class="layout_slider">
q
</div>
<!--顶部导航-->
<div class="layout_tabbar">
d
</div>
<!--内容展示区域-->
<div class="layout_main">
<div>
<p style="height: 1000px"></p>
</div>
</div>
</div>
</template>
<script setup lang="ts">
</script>
<style scoped lang="scss">
.layout_container{
height: 100vh;
width: 100%;
background: lightskyblue;
.layout_slider{
width: $base-menu-width;
height: 100vh;
background: $base-menu-background;
}
.layout_tabbar{
position: absolute;
width: calc(100% - $base-menu-width);
height: $base-tabbar-height;
background: grey;
top: 0px;
left:260px;
}
.layout_main{
position: absolute;
width: calc(100% - $base-menu-width);
height: calc(100vh - $base-tabbar-height);
background: white;
top: $base-tabbar-height;
left:260px;
padding: 20px;
overflow: auto;
}
}
</style>

@ -8,10 +8,15 @@ import zhCn from 'element-plus/es/locale/lang/zh-cn'
//引入路由
import router from '@/router'
//引入仓库
import pinia from '@/store'
import App from '@/App.vue'
//svg插件需要配置代码
import 'virtual:svg-icons-register'
//引入模板的全局的样式
import '@/styles/index.scss'
//获取应用实例对象
const app = createApp(App)
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
@ -34,9 +39,7 @@ app.use(ElementPlus, {
// },
// })
//svg插件需要配置代码
import 'virtual:svg-icons-register'
import '@/styles/index.scss'
app.use(router)
app.use(pinia)
// 将应用挂载到挂载点上

@ -2,13 +2,13 @@
export const constantRoute = [
{
name: 'login',
path: '/',
path: '/login',
component: () => import('@/views/login/index.vue'),
},
{
name: 'home',
path: '/home',
component: () => import('@/views/home/index.vue'),
path: '/',
component: () => import('@/layout/index.vue'),
},
{
name: '404',

@ -1,3 +1,18 @@
//引入清除默认样式
@import "reset";
//设置scss全局变量
@import './reset.scss';
//滚动条外观设置
::-webkit-scrollbar {
width: 10px;
}
::-webkit-scrollbar-track {
//background: $base-menu-background;
background: white;
}
::-webkit-scrollbar-thumb{
width: 10px;
background-color: whitesmoke;
border-radius: 10px;
}

@ -1,161 +1,186 @@
* {
*,
*:after,
*:before {
box-sizing: border-box;
background-repeat: no-repeat;
-webkit-tap-highlight-color: rgba(0,0,0,0);
}
body {
margin: 0;
line-height: 1;
outline: none;
}
html,
body,
div,
span,
applet,
object,
iframe,
h1,
h2,
h3,
h4,
h5,
h6,
p,
blockquote,
pre,
a,
abbr,
acronym,
address,
big,
cite,
code,
del,
dfn,
em,
img,
ins,
kbd,
q,
s,
samp,
small,
strike,
strong,
sub,
sup,
tt,
var,
b,
u,
i,
center,
dl,
dt,
dd,
ol,
ul,
li,
fieldset,
form,
label,
legend,
table,
caption,
tbody,
tfoot,
thead,
tr,
th,
td,
article,
aside,
canvas,
details,
embed,
figure,
figcaption,
footer,
header,
hgroup,
menu,
nav,
output,
ruby,
section,
main,
figcaption,
figure,
menu,
details {
display: block;
}
summary,
time,
mark,
audio,
canvas,
video {
display: inline-block;
}
img {
display: block;
border: 0;
}
font: inherit;
font-size: 100%;
h1,
h2,
h3,
h4,
h5,
h6 {
margin: 0;
padding: 0;
font-weight: normal;
vertical-align: baseline;
border: 0;
}
p {
margin: 0;
padding: 0;
article,
aside,
details,
figcaption,
figure,
footer,
header,
hgroup,
menu,
nav,
section {
display: block;
}
address,
cite,
dfn,
em,
var {
font-style: normal;
body {
line-height: 1;
}
ul,
ol {
margin: 0;
padding: 0;
list-style-type: none;
ol,
ul {
list-style: none;
}
a {
background-color: transparent;
font-size: inherit;
color: inherit;
text-decoration: none;
blockquote,
q {
quotes: none;
&:active,
&:hover {
outline: 0;
&:before,
&:after {
content: '';
content: none;
}
}
:focus {
outline: 0;
}
sub,
sup {
font-size: 75%;
line-height: 0;
button,
input,
select,
textarea {
margin: 0;
font-size: inherit;
}
position: relative;
button,
html [type="button"],
[type="reset"],
[type="submit"] {
padding: 0;
border: 0;
color: inherit;
background-color: transparent;
-webkit-appearance: button;
cursor: pointer;
vertical-align: baseline;
}
button::-moz-focus-inner,
input::-moz-focus-inner {
border: 0;
padding: 0;
sup {
top: -.5em;
}
input {
padding: 0;
line-height: normal;
&::-webkit-input-placeholder {
font-weight: 300;
}
&::-ms-input-placeholder {
font-weight: 300;
}
sub {
bottom: -.25em;
}
&::-moz-placeholder {
font-weight: 300;
}
table {
border-spacing: 0;
border-collapse: collapse;
}
[type="number"] {
-moz-appearance: textfield;
input,
textarea,
button {
font-family: inhert;
font-size: inherit;
&::-webkit-inner-spin-button,
&::-webkit-outer-spin-button {
margin: 0;
height: auto;
-webkit-appearance: none;
}
color: inherit;
}
[type="search"] {
-webkit-appearance: textfield;
select {
text-indent: .01px;
text-overflow: '';
&::-webkit-search-cancel-button,
&::-webkit-search-decoration {
-webkit-appearance: none;
}
}
border: 0;
border-radius: 0;
textarea {
overflow: auto;
resize: none;
-webkit-appearance: none;
-moz-appearance: none;
}
select {
-webkit-appearance: none;
background-color: #fff;
select::-ms-expand {
display: none;
}
table {
border-collapse: collapse;
border-spacing: 0;
code,
pre {
font-family: monospace, monospace;
font-size: 1em;
}

@ -1,4 +1,17 @@
//引入清除默认样式
@import "reset";
//给项目scss提供全局变量
$h1-color:green;
//项目提供scss全局变量
//定义项目主题颜色
//左侧的菜单的宽度
$base-menu-width:260px;
//左侧菜单的背景颜色
$base-menu-background:darkslateblue;
$base-menu-min-width:50px;
// 顶部导航的高度
$base-tabbar-height:50px;
//左侧菜单logo高度设置
$base-menu-logo-height:50px;
//左侧菜单logo右侧文字大小
$base-logo-title-fontSize:20px;

@ -1,7 +1,24 @@
<template>
<div>
<h1>404</h1>
</div>
<el-result title="404" sub-title="抱歉 请求地址错误">
<template #icon>
<el-image class="image_error"
src="src/assets/images/error_images/404.png"
/>
</template>
<template #extra>
<el-button @click="backHandle" style="background: lightskyblue;width: 80px">返回操作</el-button>
</template>
</el-result>
</template>
<script setup lang="ts"></script>
<style scoped></style>
<script setup lang="ts">
import {useRouter} from "vue-router";
const router = useRouter();
const backHandle = ()=>{
router.push('/login');
}
</script>
<style scoped>
.image_error{
margin-left: 31%;
}
</style>

@ -1,7 +1,17 @@
<template>
<div>
<h1>2级路由</h1>
<div class="common-layout">
<el-container>
<el-aside width="20%" style="background: skyblue">Aside</el-aside>
<el-container>
<el-header style="background: blanchedalmond">Header</el-header>
<el-main style="background: hotpink">Main</el-main>
</el-container>
</el-container>
</div>
</template>
<script setup lang="ts"></script>
<style scoped></style>
<script setup lang="ts">
</script>
<style scoped>
</style>

@ -78,7 +78,7 @@ const loginHandle = async () => {
// 2
setTimeout(() => {
//
$router.push('/home')
$router.push('/')
//
loading.value = false
}, 1000) // 2000 = 2

Loading…
Cancel
Save