优化:将《我的归档》时间轴内容项按升序排序

This commit is contained in:
2022-08-06 12:14:56 +08:00
parent 8ddd4ad0c8
commit 09b5fd524e
2 changed files with 24 additions and 19 deletions

View File

@@ -6,14 +6,14 @@
pending="未完待续 ······" pending="未完待续 ······"
> >
<a-timeline-item <a-timeline-item
v-for="article in articleData" v-for="article in articles"
:label="article.date" :label="formatDate(article.date)"
> >
<template #dot> <template #dot>
<IconBug :style="{color: '#F53F3F'}" v-if="article.categories.includes('Bug万象集')" /> <IconBug :style="{color: '#f53f3f'}" v-if="article.categories.includes('Bug万象集')" />
<IconBulb :style="{color: '#FF7D00'}" v-else-if="article.categories.includes('杂碎逆袭史')" /> <IconBulb :style="{color: '#ff7d00'}" v-else-if="article.categories.includes('杂碎逆袭史')" />
<IconCode v-else-if="article.categories.includes('方案春秋志')" /> <IconCode v-else-if="article.categories.includes('方案春秋志')" />
<IconBookmark :style="{color: '#00B42A'}" v-else /> <IconBookmark :style="{color: '#00b42a'}" v-else />
</template> </template>
<a :href="article.path" class="title" target="_blank">{{ article.title }}</a> <a :href="article.path" class="title" target="_blank">{{ article.title }}</a>
</a-timeline-item> </a-timeline-item>
@@ -23,20 +23,15 @@
<script lang="ts" setup> <script lang="ts" setup>
import { computed, ref } from 'vue' import { computed, ref } from 'vue'
import { useData } from 'vitepress'
import articleData from '../../../../article-data.json' import articleData from '../../../../article-data.json'
import { formatDate } from '../utils.ts' import { formatDate } from '../utils.ts'
import { IconBug, IconBulb, IconCode, IconBookmark } from '@arco-design/web-vue/es/icon' import { IconBug, IconBulb, IconCode, IconBookmark } from '@arco-design/web-vue/es/icon'
const { theme } = useData() const articles = computed(() => articleData.sort((a, b) => a.date.localeCompare(b.date)))
</script> </script>
<style scoped> <style scoped>
.timeline-wrapper { /** ---------------Arco样式--------------- */
margin-top: 24px;
margin-left: 24px;
word-break: break-all;
}
:deep(.arco-timeline-item-content) { :deep(.arco-timeline-item-content) {
color: var(--vp-c-text-1); color: var(--vp-c-text-1);
} }
@@ -44,12 +39,19 @@ const { theme } = useData()
background-color: transparent; background-color: transparent;
} }
:deep(.arco-timeline-item-label-relative > .arco-timeline-item-label) { :deep(.arco-timeline-item-label-relative > .arco-timeline-item-label) {
max-width: 120px; max-width: 145px;
} }
.arco-icon { :deep(.arco-icon) {
width: 1.3em; width: 1.3em;
height: 1.3em; height: 1.3em;
} }
/** ---------------自定义样式--------------- */
.timeline-wrapper {
margin-top: 24px;
margin-left: 35px;
word-break: break-all;
}
.title { .title {
font-weight: 400; font-weight: 400;
color: var(--vp-c-text-1); color: var(--vp-c-text-1);

View File

@@ -1,9 +1,9 @@
import DefaultTheme from 'vitepress/theme' import DefaultTheme from 'vitepress/theme'
import MyLayout from "./MyLayout.vue" import MyLayout from "./MyLayout.vue"
import ElementPlus from 'element-plus' import ElementPlus from 'element-plus'
import "element-plus/dist/index.css" import 'element-plus/dist/index.css'
import { Timeline } from '@arco-design/web-vue' import ArcoVue from '@arco-design/web-vue'
import '@arco-design/web-vue/es/timeline/style/css.js' import '@arco-design/web-vue/dist/arco.css'
import ArticleMetadata from './components/ArticleMetadata.vue' import ArticleMetadata from './components/ArticleMetadata.vue'
import Tag from './components/Tag.vue' import Tag from './components/Tag.vue'
import Archive from './components/Archive.vue' import Archive from './components/Archive.vue'
@@ -14,10 +14,13 @@ export default {
...DefaultTheme, ...DefaultTheme,
Layout: MyLayout, Layout: MyLayout,
enhanceApp({ app }) { enhanceApp({ app }) {
// 屏蔽警告信息
app.config.warnHandler = () => null
// 全局注册ElementPlus // 全局注册ElementPlus
app.use(ElementPlus) app.use(ElementPlus)
// 全局注册ArcoDesign时间轴组件 // 全局注册ArcoDesignVue
app.use(Timeline) app.use(ArcoVue)
app.component('ArticleMetadata', ArticleMetadata) app.component('ArticleMetadata', ArticleMetadata)
app.component('Tag', Tag) app.component('Tag', Tag)