feat: ✨ 新增登录
This commit is contained in:
@@ -51,7 +51,7 @@ export function useCollapseToggle(threshold: number = COLLAPSE_THRESHOLD) {
|
||||
|
||||
// 使用示例与特性说明
|
||||
// <script setup lang="ts">
|
||||
// import { useCollapseToggle } from '@/composables/useCollapseToggle';
|
||||
// import { useCollapseToggle } from '@/hooks/useCollapseToggle';
|
||||
// import { COLLAPSE_THRESHOLD } from '@/config/index'; (可传,不传入全局配置走)
|
||||
// const { changeCollapseIcon } = useCollapseToggle(designStore, COLLAPSE_THRESHOLD);
|
||||
// </script>
|
||||
|
||||
@@ -76,8 +76,9 @@ export function useSafeArea(options: SafeAreaOptions): { isInSafeArea: Ref<boole
|
||||
|
||||
// 使用示例
|
||||
// 外部组件中
|
||||
// const isListening = ref(false); // 响应式开关
|
||||
// import { useSafeArea } from '@/hooks/useSafeArea';
|
||||
|
||||
// const isListening = ref(false); // 响应式开关
|
||||
// const { isInSafeArea } = useSafeArea({
|
||||
// direction: 'left',
|
||||
// size: 50,
|
||||
|
||||
@@ -30,7 +30,7 @@ export function useScreenStore() {
|
||||
|
||||
// 使用步骤
|
||||
/** 适配移动端开始 */
|
||||
// import { useScreenStore } from "@/hooks/screen/index.ts";
|
||||
// import { useScreenStore } from "@/hooks/useScreen";
|
||||
// 获取当前为[移动端、IPad、PC端]仓库,可以使用 watchEffect(() => {}) 进行监听。
|
||||
// const { isMobile } = useScreenStore();
|
||||
/** 适配移动端结束 */
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
import { ref } from 'vue';
|
||||
|
||||
type TimeGreeting = '凌晨' | '清晨' | '早上' | '中午' | '下午' | '傍晚' | '晚上';
|
||||
|
||||
// 时间分段配置(按顺序排列,find会返回第一个匹配项)
|
||||
const timeRanges: Array<[start: number, end: number, label: TimeGreeting]> = [
|
||||
[0, 5, '凌晨'],
|
||||
[5, 7, '清晨'],
|
||||
[7, 12, '早上'],
|
||||
[12, 14, '中午'],
|
||||
[14, 18, '下午'],
|
||||
[18, 21, '傍晚'],
|
||||
[21, 24, '晚上'],
|
||||
];
|
||||
|
||||
/**
|
||||
* 获取当前时段问候语(Vue组合式函数)
|
||||
* @returns 响应式的时段问候语
|
||||
*/
|
||||
export function useTimeGreeting() {
|
||||
// 直接计算初始值(合并初始化逻辑)
|
||||
const currentHour = new Date().getHours();
|
||||
const greeting = timeRanges.find(([s, e]) => currentHour >= s && currentHour < e)?.[2] || '晚上';
|
||||
|
||||
// 使用ref保持响应式(即使不更新,组件仍可正确绑定)
|
||||
return ref<TimeGreeting>(greeting);
|
||||
}
|
||||
|
||||
// 示例用法(在Vue组件中)
|
||||
// <script setup lang="ts">
|
||||
// import { useTimeGreeting } from '@/hooks/useTimeGreeting';
|
||||
// const timeGreeting = useTimeGreeting();
|
||||
// </script>
|
||||
// <template>
|
||||
// <div>{{ timeGreeting }}好,欢迎~</div>
|
||||
// </template>
|
||||
Reference in New Issue
Block a user