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

@@ -33,7 +33,8 @@ export default withMermaid({
'/Web-Front/': [routers[0]],
'/Web-Backend/': [routers[1]],
'/DevOps/': [routers[2]],
'/Flutter/': [routers[3]]
'/Flutter/': [routers[3]],
'/Others/': [routers[4]]
},
// socialLinks: [

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');
}
/**
* 判断是否为移动端
*/

View File

@@ -3,15 +3,8 @@ layout: doc
title: DevOps
---
# DevOps
<script setup>
import { routers } from '../.vitepress/theme/router'
import { withBase } from 'vitepress'
</script>
<ul>
<li v-for="item in routers[2].items" :key="item.text">
<a :href="withBase(item.link)">{{ item.text }}</a>
</li>
</ul>
<MenuList :routers=routers[2] />

View File

@@ -3,15 +3,8 @@ layout: doc
title: Flutter
---
# Flutter
<script setup>
import { routers } from '../.vitepress/theme/router'
import { withBase } from 'vitepress'
</script>
<ul>
<li v-for="item in routers[3].items" :key="item.text">
<a :href="withBase(item.link)">{{ item.text }}</a>
</li>
</ul>
<MenuList :routers=routers[3] />

5
docs/Others/VitePress.md Normal file
View File

@@ -0,0 +1,5 @@
---
title: VitePress简介和使用
date: 2025-12-18
---

10
docs/Others/index.md Normal file
View File

@@ -0,0 +1,10 @@
---
layout: doc
title: 其他
---
<script setup>
import { routers } from '../.vitepress/theme/router'
</script>
<MenuList :routers=routers[4] />

View File

@@ -2,3 +2,73 @@
title: AList简介和使用
date: 2025-12-17
---
# 一、简介
&emsp;&emsp;[AList](https://alistgo.com/zh/)是一个支持多种存储,支持网页浏览和 WebDAV 的文件列表程序,由 gin 和 Solidjs 驱动。
# 二、安装
## 2.1 Docker安装
```yml
services:
alist:
image: xhofe/alist:v3.41.0
container_name: alist
restart: unless-stopped
volumes:
- ./data:/opt/alist/data
- /srv:/srv
ports:
- "5244:5244"
environment:
- PUID=0
- PGID=0
```
&emsp;&emsp;这里的srv为宿主机的系统服务数据目录添加该映射可以让Alist能够访问宿主机/srv目录下的本地文件。
# 三、挂载
## 3.1 挂载本地存储
&emsp;&emsp;打开控制台,选择存储->添加->本地存储,设置挂载路径(自定义,如`/local`),选择根文件夹路径为`/srv`,点击添加。
&emsp;&emsp;这样就可以将`/local`路径映射到宿主机的`/srv`目录了。
&emsp;&emsp;可以在宿主机的`/srv`目录中添加文件查看AList的主页是否可以正确显示。
# 四、API
&emsp;&emsp;在线调试地址:[Alist-Public](https://alist-public.apifox.cn/)
## 4.1 登录
```JavaScript
const username = ''
const password = ''
// 1. 登录获取token
const login = await axios.post(`${AListUrl}/api/auth/login`, {
username,
password
})
const token = login.data.data.token
```
## 4.2 上传文件
```JavaScript
const data = new FormData()
data.append('file', options.file)
const filePath = `${AListPath}/${options.file.name}`
await axios({
method: 'put',
url: `${AListUrl}/api/fs/form`,
headers: {
Authorization: token,
'File-Path': filePath
},
data
})
```
## 4.3 下载文件
&emsp;&emsp;在AList的文件路径中加上前缀`/p/`。例如文件路径为`/local/Test/test.mp4`,则下载路径为`/p/local/Test/test.mp4`
::: tip
以上为相对路径使用时加上相应的ip和端口号。
:::

View File

@@ -4,20 +4,8 @@ title: Web后端
description: Web后端开发技术文档包含数据库、框架、中间件等
---
# Web 后端开发
后端开发技术栈的学习笔记和总结。
<script setup>
import { routers } from '../.vitepress/theme/router'
import { withBase } from 'vitepress'
</script>
<div v-for="category in routers[1].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>
<MenuList :routers=routers[1] :isNested=true />

View File

@@ -4,20 +4,8 @@ title: Web前端
description: Web前端开发技术文档
---
# Web 前端开发
前端开发技术栈的学习笔记和总结。
<script setup>
import { routers } from '../.vitepress/theme/router'
import { withBase } from 'vitepress'
</script>
<div v-for="category in routers[0].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>
<MenuList :routers=routers[0] :isNested=true />