Skip to content

Commit

Permalink
feat:#1 页面路由与跳转
Browse files Browse the repository at this point in the history
  • Loading branch information
terwer committed Oct 9, 2022
1 parent acc3673 commit 16a4228
Show file tree
Hide file tree
Showing 6 changed files with 69 additions and 17 deletions.
10 changes: 7 additions & 3 deletions app.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
<template>
<NuxtLayout>
<NuxtPage/>
</NuxtLayout>
<Transition name="page" mode="out-in">
<NuxtLayout>
<div :key="$route.fullPath">
<NuxtPage/>
</div>
</NuxtLayout>
</Transition>
</template>

<script lang="ts" setup>
Expand Down
32 changes: 32 additions & 0 deletions assets/scss/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,36 @@ html.dark {
a {
font-weight: 400;
color: var(--el-color-primary);
}

/*
页面动画
https://github.com/nuxt/framework/issues/3141#issuecomment-1212899838
*/
.page-enter-active {
transition: all 0.1s ease-out;
}

.page-leave-active {
transition: all 0.3s cubic-bezier(1, 0.5, 0.8, 1);
}

.page-enter-from,
.page-leave-to {
transform: translateY(20px);
opacity: 0;
}

.layout-enter-active {
transition: all 0.1s ease-out;
}

.layout-leave-active {
transition: all 0.3s cubic-bezier(1, 0.5, 0.8, 1);
}

.layout-enter-from,
.layout-leave-to {
transform: translateY(-20px);
opacity: 0;
}
5 changes: 4 additions & 1 deletion components/default/Footer.vue
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
<template>
<footer>
footer
footer .
<NuxtLink href="/setting">Setting</NuxtLink>
</footer>
</template>

<script lang="ts">
export default {
name: "Footer"
}
</script>

<style scoped>
Expand Down
20 changes: 18 additions & 2 deletions components/default/Header.vue
Original file line number Diff line number Diff line change
@@ -1,15 +1,31 @@
<template>
<header>
<el-page-header :icon="ArrowLeft" title="返回" @click="onBack" v-if="$route.fullPath!='/'">
<template #content>
<div class="flex items-center">
<span class="text-large font-600 mr-3"> {{ $route.fullPath }} </span>
</div>
</template>
</el-page-header>

<Navbar/>
</header>
</template>

<script lang="ts">
<script lang="ts" setup>
import Navbar from "~/components/default/Navbar.vue";
import {ElPageHeader} from "element-plus";
import {ArrowLeft} from '@element-plus/icons-vue'
const router = useRouter();
const onBack = () => {
router.go(-1)
}
</script>

<script lang="ts">
export default {
name: "Header",
components: {Navbar}
}
</script>

Expand Down
2 changes: 1 addition & 1 deletion layouts/default.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<template>
<div>
<Header/>
<slot/>
<slot />
<Footer/>
</div>
</template>
Expand Down
17 changes: 7 additions & 10 deletions pages/ChangeTheme.vue → pages/setting.vue
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,8 @@
</template>

<script lang="ts" setup>
import {ElForm, ElFormItem, ElButton, ElSelect, ElOption} from "element-plus";
import {ref} from 'vue'
import {ElSpace, ElDivider} from 'element-plus'
import {ElButton, ElDivider, ElForm, ElFormItem, ElOption, ElSelect, ElSpace} from "element-plus";
import {h, ref} from 'vue'
const value = ref('default')
const options = [
Expand All @@ -63,9 +62,10 @@ const langOptions = [
},
]
definePageMeta({
layout: false,
});
// 使用这一行可以不使用通用布局
// definePageMeta({
// layout: false,
// });
const route = useRoute()
Expand All @@ -78,12 +78,9 @@ const spacer = h(ElDivider, {direction: 'vertical'})

<script lang="ts">
export default {
name: "ChangeTheme"
name: "seting"
}
</script>

<style scoped>
.setting {
padding: 10px;
}
</style>

0 comments on commit 16a4228

Please sign in to comment.