Skip to content

Commit

Permalink
feat: 新增版本日志
Browse files Browse the repository at this point in the history
  • Loading branch information
ikenxuan committed Aug 13, 2024
1 parent 7c64edc commit fb82218
Show file tree
Hide file tree
Showing 6 changed files with 64 additions and 2 deletions.
3 changes: 2 additions & 1 deletion docs/.vitepress/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,8 @@ export default defineConfig({
{ text: '联系人相关', link: '/api/contact' },
{ text: '消息相关', link: '/api/message' }
]
}
},
{ text: '更新日志', link: '/other/changelog' },
],
socialLinks: [
{ icon: 'github', link: 'https://github.com/KarinJS/Karin' },
Expand Down
50 changes: 50 additions & 0 deletions docs/.vitepress/theme/components/ChangeLog.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<template>
<div v-if="loading">正在请求更新日志...</div>
<div v-else-if="error">获取更新日志失败,错误: {{ error }}</div>
<div v-else v-html="compiledMarkdown"></div>
</template>

<script>
import axios from 'axios';
import {marked} from 'marked';
export default {
props: {
src: {
type: String,
required: true
}
},
data() {
return {
markdownContent: '',
compiledMarkdown: '',
loading: true,
error: null
};
},
mounted() {
this.fetchMarkdown();
},
methods: {
fetchMarkdown() {
axios.get(this.src, {
timeout: 10000
})
.then(response => {
this.markdownContent = response.data;
this.compileMarkdown();
})
.catch(error => {
this.error = error;
})
.finally(() => {
this.loading = false;
});
},
compileMarkdown() {
this.compiledMarkdown = marked(this.markdownContent);
}
}
};
</script>
4 changes: 3 additions & 1 deletion docs/.vitepress/theme/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,12 @@ import {
} from '@nolebase/vitepress-plugin-highlight-targeted-heading/client'
// 快速复制当前页的url
import Share from './components/Share.vue'
// 卡片
// 组件
import Ncard from './components/Ncard.vue'
import HomeUnderline from './components/HomeUnderline.vue'
import HomeFooter from './components/HomeFooter.vue'
import Confetti from './components/Confetti.vue'
import ChangeLogs from './components/ChangeLog.vue'
// 页面属性
import {
NolebasePagePropertiesPlugin,
Expand All @@ -67,6 +68,7 @@ export default {
app.component('NCard', Ncard)
app.component('HomeFooter', HomeFooter)
app.component('Confetti', Confetti)
app.component('ChangeLogs', ChangeLogs)
app.use(TwoslashFloatingVue as unknown as Plugin)
app.use(NolebaseGitChangelogPlugin as Plugin)
app.provide(InjectionKey, {
Expand Down
1 change: 1 addition & 0 deletions docs/other/changelog.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<ChangeLogs src="https://raw.githubusercontent.com/KarinJS/Karin/dev/CHANGELOG.md" />
6 changes: 6 additions & 0 deletions docs/start/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ Karin 的渲染器是独立的一个项目,需要单独安装噢
Karin 社区拥有众多开发者,开发了许多特色插件,你可以在插件市场找到你想要的插件~
</NCard>

### 更新日志
<br>
<NCard title="⬆️ 是新内容!" link="../../Karin/other/changelog">
在这里,你可以查看到 Karin 所有版本的更新日志。
</NCard>

---
::: tip 温馨提示
如果文档中发现错误,或提交文档修改,或丰富本站文档,可点击页面底部的编辑按钮
Expand Down
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,12 @@
"@shikijs/vitepress-twoslash": "^1.12.1",
"@vitejs/plugin-vue": "^5.1.2",
"@vueuse/core": "^10.11.1",
"axios": "^1.7.3",
"canvas-confetti": "^1.9.3",
"markdown-it-footnote": "^4.0.0",
"markdown-it-mathjax3": "^4.3.2",
"markdown-it-task-lists": "^2.1.1",
"marked": "^14.0.0",
"medium-zoom": "^1.1.0",
"sass-embedded": "^1.77.8",
"vite": "^5.4.0",
Expand Down

0 comments on commit fb82218

Please sign in to comment.