feat: add download components
This commit is contained in:
@@ -2,6 +2,7 @@
|
|||||||
import { h, watch } from 'vue'
|
import { h, watch } from 'vue'
|
||||||
// import Theme from 'vitepress/theme'
|
// import Theme from 'vitepress/theme'
|
||||||
import DefaultTheme from 'vitepress/theme-without-fonts'
|
import DefaultTheme from 'vitepress/theme-without-fonts'
|
||||||
|
import Download from '../../components/Download.vue'
|
||||||
import './style.css'
|
import './style.css'
|
||||||
import './rainbow.css'
|
import './rainbow.css'
|
||||||
|
|
||||||
@@ -16,6 +17,7 @@ export default {
|
|||||||
},
|
},
|
||||||
enhanceApp(ctx) {
|
enhanceApp(ctx) {
|
||||||
DefaultTheme.enhanceApp(ctx)
|
DefaultTheme.enhanceApp(ctx)
|
||||||
|
ctx.app.component('Download', Download)
|
||||||
if (typeof window === 'undefined')
|
if (typeof window === 'undefined')
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,10 @@
|
|||||||
完成习题
|
完成习题
|
||||||
:::
|
:::
|
||||||
|
|
||||||
|
::: tip 📥
|
||||||
|
本节附件下载 <Download url="link"/>
|
||||||
|
:::
|
||||||
|
|
||||||
/4.人工智能/code/MAZE.zip
|
/4.人工智能/code/MAZE.zip
|
||||||
|
|
||||||
# Node
|
# Node
|
||||||
|
|||||||
@@ -1 +0,0 @@
|
|||||||
这里存放示例代码和作业
|
|
||||||
39
components/Download.vue
Normal file
39
components/Download.vue
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
<template>
|
||||||
|
<div class="download">
|
||||||
|
<button @click='download()'>📎下载附件代码</button>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup>
|
||||||
|
import { defineProps } from 'vue'
|
||||||
|
const url = defineProps({
|
||||||
|
url: {
|
||||||
|
type: String,
|
||||||
|
default: ''
|
||||||
|
}
|
||||||
|
})
|
||||||
|
const download = () => {
|
||||||
|
window.open(url.url)
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
button {
|
||||||
|
background-color: #138389;
|
||||||
|
color: #fff;
|
||||||
|
border: none;
|
||||||
|
border-radius: 4px;
|
||||||
|
cursor: pointer;
|
||||||
|
padding: 5px 10px;
|
||||||
|
margin: auto 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
button:hover {
|
||||||
|
background-color: #126050;
|
||||||
|
transition: background-color 0.2s ease-in-out;
|
||||||
|
}
|
||||||
|
|
||||||
|
.download {
|
||||||
|
display: inline-block;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
Reference in New Issue
Block a user