2024-01-12 21:07:34 +08:00

174 lines
4.9 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/**
*
* @author Ray <https://github.com/XiaoDaiGua-Ray>
*
* @date 2023-11-03
*
* @workspace ray-template
*
* @remark 今天也是元气满满撸代码的一天
*/
import { NFlex, NCard, NButton, NInput } from 'naive-ui'
import {
useAppNavigation,
useMaximize,
useSpinning,
useWatermark,
useTheme,
} from '@/hooks'
import { getVariableToRefs } from '@/global-variable'
import { useSettingGetters } from '@/store'
export default defineComponent({
name: 'TemplateHooks',
setup() {
const currentMenuOption = ref('')
const maximizeRef = getVariableToRefs('layoutContentMaximize')
const watermark = ref(useSettingGetters().getWatermarkConfig.value.content)
const { navigationTo } = useAppNavigation()
const { maximize, isLayoutContentMaximized } = useMaximize()
const { reload, openSpin, closeSpin } = useSpinning()
const {
showWatermark,
hiddenWatermark,
setWatermarkContent,
toggleWatermark,
} = useWatermark()
const { changeDarkTheme, changeLightTheme, toggleTheme, getAppTheme } =
useTheme()
return {
navigationTo,
reload,
currentMenuOption,
maximize,
maximizeRef,
openSpin,
closeSpin,
showWatermark,
hiddenWatermark,
setWatermarkContent,
watermark,
toggleWatermark,
changeDarkTheme,
changeLightTheme,
toggleTheme,
getAppTheme,
isLayoutContentMaximized,
}
},
render() {
const {
navigationTo,
reload,
maximize,
openSpin,
closeSpin,
showWatermark,
hiddenWatermark,
setWatermarkContent,
toggleWatermark,
changeDarkTheme,
changeLightTheme,
toggleTheme,
getAppTheme,
isLayoutContentMaximized,
} = this
return (
<NFlex vertical>
<NCard title="接口说明">
<h3>
hooks/template hook
</h3>
</NCard>
<NCard title="useTheme 主题">
<NFlex vertical>
<h3>getAppTheme : {getAppTheme().themeLabel}</h3>
<NFlex>
<NButton onClick={() => changeDarkTheme()}></NButton>
<NButton onClick={() => changeLightTheme()}></NButton>
<NButton onClick={() => toggleTheme()}></NButton>
</NFlex>
</NFlex>
</NCard>
<NCard title="useWatermark 水印">
<NFlex vertical>
<NInput
v-model:value={this.watermark}
onInput={(val) => {
setWatermarkContent(val)
}}
/>
<NFlex>
<NButton onClick={() => showWatermark()}></NButton>
<NButton onClick={() => hiddenWatermark()}></NButton>
<NButton onClick={() => toggleWatermark()}></NButton>
</NFlex>
</NFlex>
</NCard>
<NCard title="useSpinning">
<h3>
使
vue 800ms
</h3>
<br />
<NFlex>
<NButton
onClick={() => {
reload()
}}
>
</NButton>
<NButton
onClick={() => {
openSpin()
setTimeout(() => {
closeSpin()
}, 800)
}}
>
</NButton>
</NFlex>
</NCard>
<NCard title="useMaximize 内容区域最大化">
<h3>
isLayoutContentMaximized :
{isLayoutContentMaximized ? '最大化' : '正常尺寸'}
</h3>
<NButton
onClick={() => {
maximize(!this.maximizeRef, {
scrollToOptions: {
left: 0,
top: 0,
},
})
}}
>
</NButton>
</NCard>
<NCard title="useAppNavigation 导航方法">
<h3>
navigationTo
/multi/multi-menu-one
</h3>
<br />
<NButton onClick={() => navigationTo('/multi/multi-menu-one')}>
</NButton>
</NCard>
</NFlex>
)
},
})