pref: reduce code

This commit is contained in:
ChenZhaoYu
2023-02-10 09:19:37 +08:00
parent e8cb651db3
commit ac6e860a67
21 changed files with 147 additions and 1126 deletions

View File

@@ -0,0 +1,10 @@
<template>
<div class="fixed bottom-0 left-0 right-0 p-4 text-sm text-center text-neutral-500">
<span class="text-center">
Made By ChenZhaoYu -
<a href="https://github.com/Chanzhaoyu/chatgpt-bot" target="_blank" class="text-blue-500">
Github
</a>
</span>
</div>
</template>

21
src/components/Icon.vue Normal file
View File

@@ -0,0 +1,21 @@
<script setup lang='ts'>
import { computed, useAttrs } from 'vue'
import { Icon } from '@iconify/vue'
interface Props {
icon?: string
}
defineProps<Props>()
const attrs = useAttrs()
const bindAttrs = computed<{ class: string; style: string }>(() => ({
class: (attrs.class as string) || '',
style: (attrs.style as string) || '',
}))
</script>
<template>
<Icon :icon="icon" v-bind="bindAttrs" />
</template>

View File

@@ -1,6 +1,6 @@
<script setup lang="ts">
import { defineComponent, h } from 'vue'
import { NMessageProvider, useMessage } from 'naive-ui'
import { NConfigProvider, NMessageProvider, useMessage } from 'naive-ui'
function registerNaiveTools() {
window.$message = useMessage()
@@ -18,8 +18,10 @@ const NaiveProviderContent = defineComponent({
</script>
<template>
<NMessageProvider>
<slot />
<NaiveProviderContent />
</NMessageProvider>
<NConfigProvider class="h-full">
<NMessageProvider>
<slot />
<NaiveProviderContent />
</NMessageProvider>
</NConfigProvider>
</template>

View File

@@ -1,36 +0,0 @@
<script setup lang='ts'>
import { computed, useAttrs } from 'vue'
import { Icon } from '@iconify/vue'
interface Props {
icon?: string
localIcon?: string
}
const props = defineProps<Props>()
const attrs = useAttrs()
const bindAttrs = computed<{ class: string; style: string }>(() => ({
class: (attrs.class as string) || '',
style: (attrs.style as string) || '',
}))
const symbolId = computed(() => {
const icon = props.localIcon || 'no-icon'
return `#icon-local-${icon}`
})
const renderLocalIcon = computed(() => props.localIcon || !props.icon)
</script>
<template>
<template v-if="renderLocalIcon">
<svg aria-hidden="true" width="1em" height="1em" v-bind="bindAttrs">
<use :xlink:href="symbolId" fill="currentColor" />
</svg>
</template>
<template v-else>
<Icon v-if="icon" :icon="icon" v-bind="bindAttrs" />
</template>
</template>

View File

@@ -1,4 +1,5 @@
import NaiveProvider from './NaiveProvider.vue'
import SvgIcon from './SvgIcon.vue'
import Icon from './Icon.vue'
import GithubSite from './GithubSite.vue'
export { NaiveProvider, SvgIcon }
export { NaiveProvider, Icon, GithubSite }