Skip to content

Commit

Permalink
perf(naive): naive示例支持查看源码
Browse files Browse the repository at this point in the history
  • Loading branch information
greper committed Nov 20, 2023
1 parent 5ccd27d commit a07f0e1
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 0 deletions.
54 changes: 54 additions & 0 deletions src/layout/components/source-link/index.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<template>
<div v-if="showSourceLink" class="fs-source-link-group">
<div class="fs-source-link" @click="goSource('https://gitee.com')">本页源码(Gitee)</div>
<div class="fs-source-link" @click="goSource('https://github.com')">本页源码(Github)</div>
</div>
</template>

<script lang="ts">
import { defineComponent, ref, watch } from 'vue';
import { useRoute, useRouter } from 'vue-router';
export default defineComponent({
name: 'FsSourceLink',
setup() {
const router = useRouter();
const showSourceLink = ref(false);
watch(
() => {
return router.currentRoute.value.fullPath;
},
(value) => {
showSourceLink.value = value !== '/index';
},
{ immediate: true }
);
const middle = '/fast-crud/fs-admin-naive-ui/blob/main/src/views';
function goSource(prefix: any) {
const path = router.currentRoute.value.fullPath;
window.open(prefix + middle + path + '/index.vue');
}
return {
goSource,
showSourceLink,
};
},
});
</script>

<style lang="less">
.fs-source-link-group {
position: fixed;
right: 3px;
bottom: 20px;
.fs-source-link {
text-align: left;
cursor: pointer;
font-size: 12px;
border-radius: 5px 0 0 5px;
padding: 5px;
background: #666;
color: #fff;
margin-bottom: 5px;
}
}
</style>
2 changes: 2 additions & 0 deletions src/layout/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
<!-- <NLayoutFooter v-if="getShowFooter">-->
<!-- <PageFooter />-->
<!-- </NLayoutFooter>-->
<fs-source-link />
</n-layout-content>
<n-back-top :right="100" />
</n-layout>
Expand All @@ -79,6 +80,7 @@
import { useDesignSetting } from '@/hooks/setting/useDesignSetting';
import { useRoute } from 'vue-router';
import { useProjectSettingStore } from '@/store/modules/projectSetting';
import FsSourceLink from '@/layout/components/source-link/index.vue';
const { getDarkTheme } = useDesignSetting();
const {
Expand Down

0 comments on commit a07f0e1

Please sign in to comment.