更新任务
This commit is contained in:
1 parent
120a57ad57
commit
6118a80ac4
279 files changed
+9682
-2362
No files matched your search
@@ -0,0 +1,55 @@
|
||||
<template>
|
||||
<t-button
|
||||
v-if="isPosts && !frontmatter.isNoBackBtn"
|
||||
theme="default"
|
||||
variant="dashed"
|
||||
style="margin-bottom: 10px"
|
||||
@click="goBack"
|
||||
>
|
||||
<template #icon>
|
||||
<RollbackIcon/>
|
||||
</template>
|
||||
{{ '返回上一页' }}
|
||||
</t-button>
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
import { ref, computed, onMounted, onUnmounted } from 'vue'
|
||||
import { useRoute, useData } from 'vitepress'
|
||||
import { RollbackIcon } from 'tdesign-icons-vue-next'
|
||||
|
||||
const route = useRoute()
|
||||
const isPosts = computed(() => route.path.startsWith('/posts'))
|
||||
const { frontmatter } = useData()
|
||||
|
||||
function goBack () {
|
||||
if (window.history.length <= 1) {
|
||||
location.href = '/'
|
||||
} else {
|
||||
window.history.go(hashChangeCount.value)
|
||||
hashChangeCount.value = -1
|
||||
}
|
||||
}
|
||||
|
||||
const hashChangeCount = ref(-1)
|
||||
onMounted(() => {
|
||||
window.onhashchange = () => {
|
||||
hashChangeCount.value--
|
||||
}
|
||||
})
|
||||
|
||||
onUnmounted(() => {
|
||||
window.onhashchange = null
|
||||
})
|
||||
</script>
|
||||
<style scoped>
|
||||
.img-container {
|
||||
height: 105px;
|
||||
width: 100px;
|
||||
}
|
||||
|
||||
img {
|
||||
height: 100px;
|
||||
border-radius: 5px;
|
||||
margin-top: 5px;
|
||||
}
|
||||
</style>
|
||||
Reference in new issue
Block a user