feat: add download components

This commit is contained in:
camera-2018
2023-07-01 23:38:02 +08:00
parent d084dd90df
commit 08fa485f6f
4 changed files with 45 additions and 1 deletions

View File

@@ -2,6 +2,7 @@
import { h, watch } from 'vue'
// import Theme from 'vitepress/theme'
import DefaultTheme from 'vitepress/theme-without-fonts'
import Download from '../../components/Download.vue'
import './style.css'
import './rainbow.css'
@@ -16,6 +17,7 @@ export default {
},
enhanceApp(ctx) {
DefaultTheme.enhanceApp(ctx)
ctx.app.component('Download', Download)
if (typeof window === 'undefined')
return

View File

@@ -4,6 +4,10 @@
完成习题
:::
::: tip 📥
本节附件下载 <Download url="link"/>
:::
/4.人工智能/code/MAZE.zip
# Node

View File

@@ -1 +0,0 @@
这里存放示例代码和作业

39
components/Download.vue Normal file
View 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>