feat:增加AList博客

This commit is contained in:
2025-12-18 10:13:00 +08:00
parent 228109ee81
commit fb404f2bcf
13 changed files with 162 additions and 45 deletions

View File

@@ -16,7 +16,7 @@
<div class="item">
<svg t="1724571760788" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="6125" width="16" height="16"><path d="M204.8 0h477.866667l273.066666 273.066667v614.4c0 75.093333-61.44 136.533333-136.533333 136.533333H204.8c-75.093333 0-136.533333-61.44-136.533333-136.533333V136.533333C68.266667 61.44 129.706667 0 204.8 0z m307.2 607.573333l68.266667 191.146667c13.653333 27.306667 54.613333 27.306667 61.44 0l102.4-273.066667c6.826667-20.48 0-34.133333-20.48-40.96s-34.133333 0-40.96 13.653334l-68.266667 191.146666-68.266667-191.146666c-13.653333-27.306667-54.613333-27.306667-68.266666 0l-68.266667 191.146666-68.266667-191.146666c-6.826667-13.653333-27.306667-27.306667-47.786666-20.48s-27.306667 27.306667-20.48 47.786666l102.4 273.066667c13.653333 27.306667 54.613333 27.306667 61.44 0l75.093333-191.146667z" fill="#1890FF" p-id="6126"></path><path d="M682.666667 0l273.066666 273.066667h-204.8c-40.96 0-68.266667-27.306667-68.266666-68.266667V0z" fill="#52C41A" p-id="6127"></path></svg>
字数: {{ wordCount }}
字数: {{ formatNumberUnit(wordCount) }}
</div>
<div>
@@ -28,7 +28,7 @@
<script lang="ts" setup>
import { computed, ref, onMounted, watch } from 'vue'
import { countWord } from '../utils'
import { countWord, formatNumberUnit } from '../utils'
import { useData } from 'vitepress'
const wordCount = ref(0)

View File

@@ -0,0 +1,37 @@
<template>
<div v-if="isNested">
<div v-for="category in props.routers.items" :key="category.text">
<h3>{{ category.text }}</h3>
<ul>
<li v-for="item in category.items" :key="item.text">
<a :href="withBase(item.link)">{{ item.text }}</a>
</li>
</ul>
</div>
</div>
<div v-else>
<ul>
<li v-for="item in props.routers.items" :key="item.text">
<a :href="withBase(item.link)">{{ item.text }}</a>
</li>
</ul>
</div>
</template>
<script setup>
import { withBase } from 'vitepress'
import { defineProps } from 'vue'
const props = defineProps({
routers: {
required: true,
type: Object
},
isNested: {
type: Boolean,
default: false
}
})
</script>

View File

@@ -2,6 +2,7 @@ import DefaultTheme from 'vitepress/theme'
import Confetti from "./components/Confetti.vue";
import ArticleMetadata from "./components/ArticleMetadata.vue"
import StatsChart from './components/StatsChart.vue'
import MenuList from './components/MenuList.vue'
import type { EnhanceAppContext } from 'vitepress'
import { onMounted, watch, nextTick } from 'vue'
import { useRoute } from 'vitepress'
@@ -32,6 +33,7 @@ export default {
enhanceApp({ app }: EnhanceAppContext) {
app.component("Confetti", Confetti);
app.component("StatsChart", StatsChart);
app.component("MenuList", MenuList);
app.component("ArticleMetadata", ArticleMetadata);
},
};

View File

@@ -72,5 +72,11 @@ export const routers = [
{ text: 'Flutter基础教程', link: '/Flutter/FlutterGuide' },
{ text: '实战技巧', link: '/Flutter/Practice' }
]
},
{
text: '🔄 其他',
items: [
{ text: 'VitePress使用和简介', link: '/Others/VitePress' },
]
}
];

View File

@@ -18,6 +18,30 @@ export const countWord = (data: string)=> {
return count
}
export const formatNumberUnit = (num: number, fixed = 1) => {
if (typeof num !== 'number') {
num = parseFloat(num);
}
if (isNaN(num)) return '0';
const absNum = Math.abs(num);
let result;
if (absNum >= 100000000) {
// 亿
result = (num / 100000000).toFixed(fixed) + '亿';
} else if (absNum >= 10000) {
// 万
result = (num / 10000).toFixed(fixed) + '万';
} else {
result = num.toFixed(0);
}
// 移除多余的 .0
return result.replace(/\.0+($|亿|万)/, '$1');
}
/**
* 判断是否为移动端
*/