Skip to content

Commit

Permalink
refactor: 使用setup语法糖
Browse files Browse the repository at this point in the history
Signed-off-by: crrashh1542 <[email protected]>
  • Loading branch information
crrashh1542 committed Feb 20, 2024
1 parent 9b7bdc9 commit a04dbde
Show file tree
Hide file tree
Showing 10 changed files with 71 additions and 120 deletions.
66 changes: 28 additions & 38 deletions src/components/Appbar.vue
Original file line number Diff line number Diff line change
@@ -1,52 +1,41 @@
<script>
const linkList =
[{
'name': '主页',
'link': 'https://www.crrashh.com/',
'type': 'link'
}, {
'name': '分类',
'link': '/category',
'type': 'route'
}, {
'name': '关于',
'link': '/about',
'type': 'route'
}]
export default {
name: 'MainAppbar',
data() {
return {
title: 'Windows Up-to-Date',
link: linkList
}
},
methods: {
dialogOpen(){
let dialogEl = document.getElementById('setting')
dialogEl.hidden = false
}
}
<script setup>
defineOptions({ name: 'WidgetAppbar' })
const linkList = [{
'name': '主页',
'link': 'https://www.crrashh.com/',
'type': 'link'
}, {
'name': '分类',
'link': '/category',
'type': 'route'
}, {
'name': '关于',
'link': '/about',
'type': 'route'
}]
function dialogOpen() {
let dialogEl = document.getElementById('setting')
dialogEl.hidden = false
}
</script>

<template>
<div class="appbar">

<!-- 左侧标题 -->
<router-link to="/" class="title">{{ title }}</router-link>
<router-link to="/" class="title">Windows Up-to-Date</router-link>

<!-- 左右分隔 -->
<div class="grow"></div>

<!-- 右侧链接 -->
<div class="external">
<span v-for="i in link" :key="i.name">
<span v-for="i in linkList" :key="i.name">

<!-- 如果类型是外部链接 → <a> -->
<a v-if="i.type == 'link'" :href="i.link"
class="link item" target="_blank">{{ i.name }}</a>
<a v-if="i.type == 'link'" :href="i.link" class="link item" target="_blank">{{ i.name }}</a>

<!-- 如果类型是项目内路由 → <router-link> -->
<router-link class="item" v-if="i.type == 'route'" :to="i.link">
Expand All @@ -56,7 +45,7 @@ export default {
<span><!-- 保留节目,选项必须在! -->
<a href="#" class="item stable" @click="dialogOpen">选项</a>
</span>

</div>
</div>
</template>
Expand Down Expand Up @@ -96,7 +85,7 @@ export default {
display: none;
}
.external > span > a.item {
.external>span>a.item {
// 链接
margin: 0 15px;
font-size: 17px;
Expand Down Expand Up @@ -136,4 +125,5 @@ export default {
.appbar {
--appbar-link-display: none;
}
}</style>
}
</style>
10 changes: 4 additions & 6 deletions src/components/Card.vue
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
<script>
import { provideFluentDesignSystem, fluentCard } from "@fluentui/web-components"
provideFluentDesignSystem().register(fluentCard())
<script setup>
defineOptions({ name: 'WidgetCard' })
export default {
name: 'WidgetCard'
}
import { provideFluentDesignSystem, fluentCard } from '@fluentui/web-components'
provideFluentDesignSystem().register(fluentCard())
</script>

<template>
Expand Down
6 changes: 2 additions & 4 deletions src/components/Catalog.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
<script>
export default {
name: 'WidgetCatalog'
}
<script setup>
defineOptions({ name: 'WidgetCatalog' })
</script>

<template>
Expand Down
6 changes: 2 additions & 4 deletions src/components/Footer.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
<script>
export default {
name: 'MainFooter'
}
<script setup>
defineOptions({ name: 'MainFooter' })
</script>

<template>
Expand Down
6 changes: 2 additions & 4 deletions src/components/LoadAnim.vue
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
<script>
<script setup>
import { fluentProgressRing, provideFluentDesignSystem } from '@fluentui/web-components'
provideFluentDesignSystem().register(fluentProgressRing())
export default {
name: 'MainLoadAnim'
}
defineOptions({ name: 'MainLoadAnim' })
</script>

<template>
Expand Down
49 changes: 22 additions & 27 deletions src/components/Navbar.vue
Original file line number Diff line number Diff line change
@@ -1,35 +1,27 @@
<script>
const navSections = [
{
"path": "/",
"icon": "icon-home",
"text": "主页"
},
{
"path": "/category",
"icon": "icon-tag",
"text": "分类"
},
{
"path": "/about",
"icon": "icon-about",
"text": "关于"
}
]
<script setup>
defineOptions({ name: 'WidgetNavBar' })
export default {
name: 'WidgetNavBar',
data() {
return { navSections }
}
}
const navSections = [{
"path": "/",
"icon": "icon-home",
"text": "主页"
},
{
"path": "/category",
"icon": "icon-tag",
"text": "分类"
},
{
"path": "/about",
"icon": "icon-about",
"text": "关于"
}]
</script>

<template>
<div class="navbar flex flex-row fixed bottom-0 left-0 w-full">

<router-link v-for="s in navSections" :to="s.path"
:key="s.value" class="inline text-center basis-1/3 py-2">
<router-link v-for="s in navSections" :to="s.path" :key="s.value" class="inline text-center basis-1/3 py-2">

<span class="icon block text-xl pt-1 pb-0.5" :class="s.icon"></span>
<span class="block text-sm py-0.5">{{ s.text }}</span>
Expand All @@ -47,9 +39,12 @@ export default {
background-color: @wu-color-bar;
backdrop-filter: blur(3px);
border-top: 1px solid @wu-color-split-line;
.path-active { // router 活跃状态(处于当前页时)的配置 class
.path-active {
// router 活跃状态(处于当前页时)的配置 class
color: @wu-color-theme;
}
.icon::before {
height: 40px;
}
Expand Down
6 changes: 2 additions & 4 deletions src/components/TopNav.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
<script>
export default {
name: 'WidgetTopNav'
}
<script setup>
defineOptions({ name: 'WidgetTopNav' })
</script>

<template>
Expand Down
20 changes: 5 additions & 15 deletions src/views/MainAbout.vue
Original file line number Diff line number Diff line change
@@ -1,27 +1,17 @@
<script>
import buildInfo from '../scripts/parseRepoInfo'
<script setup>
// 引入组件
import Banner from '../components/Banner.vue'
import Card from '../components/Card.vue'
// 设定数据
document.title = '关于项目 / Windows Up-to-Date'
import buildInfo from '../scripts/parseRepoInfo'
const sources = [
['https://msbuilds.rg-adguard.net', 'MSFT BUFFET DATABASE'],
['https://changewindows.org', 'ChangeWindows'],
['https://bbs.pcbeta.com/viewthread-1941423-1-1.html', '远景论坛 - 2262x(2263x).2715/2700更新包和修复包下载 & 内部版本进度 & .NET CU'],
['https://community.wvbtech.com', 'wvbCommunity']
]
export default {
name: 'MainAbout',
components: { Banner, Card },
data() {
return {
buildInfo, sources
}
},
setup() {
document.title = '关于项目 / Windows Up-to-Date'
}
}
</script>

<template>
Expand Down
8 changes: 2 additions & 6 deletions src/views/MainCategory.vue
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
<script>
<script setup>
// 引入组件
import Card from '../components/Card.vue'
export default {
name: 'MainCategory',
components: { Card }
}
</script>

<template>
<!-- PlaceHolder 2024-02-01 by crrashh1542 -->
<!-- PlaceHolder 2024-02-19 by crrashh1542 -->
</template>

<style lang="less" scoped>
Expand Down
14 changes: 2 additions & 12 deletions src/views/NotFound.vue
Original file line number Diff line number Diff line change
@@ -1,18 +1,8 @@
<script>
<script setup>
import { provideFluentDesignSystem, fluentButton } from "@fluentui/web-components"
provideFluentDesignSystem().register(fluentButton())
export default {
name: 'OtherNotFound',
setup() {
document.title = '内容不见啦! / Windows Up-to-Date'
},
methods: {
routerToHome() {
this.$router.push('/')
}
}
}
document.title = '内容不见啦! / Windows Up-to-Date'
</script>

<template>
Expand Down

0 comments on commit a04dbde

Please sign in to comment.