mirror of
https://github.com/m-xlsea/ruoyi-plus-soybean.git
synced 2025-09-24 07:49:47 +08:00
feat(projects): 添加多页签风格:按钮和浏览器两种风格
This commit is contained in:
@ -1,3 +1,3 @@
|
||||
import { setupAppContext, useReloadInject } from './app';
|
||||
export { setupAppContext, useReloadInject } from './app';
|
||||
|
||||
export { setupAppContext, useReloadInject };
|
||||
export { useHoverIndexProvide, useHoverIndexInject } from './part';
|
||||
|
@ -0,0 +1,5 @@
|
||||
import useHoverIndexContext from './useHoverIndexContext';
|
||||
|
||||
const { useHoverIndexProvide, useHoverIndexInject } = useHoverIndexContext();
|
||||
|
||||
export { useHoverIndexProvide, useHoverIndexInject };
|
||||
|
39
src/context/part/useHoverIndexContext.ts
Normal file
39
src/context/part/useHoverIndexContext.ts
Normal file
@ -0,0 +1,39 @@
|
||||
import { ref } from 'vue';
|
||||
import type { Ref } from 'vue';
|
||||
import { useContext } from '@/hooks';
|
||||
|
||||
interface HoverIndexContext {
|
||||
/** 被悬浮元素索引 */
|
||||
index: Ref<number>;
|
||||
/** 设置索引 */
|
||||
setHoverIndex(index: number): void;
|
||||
/** 重置索引 */
|
||||
resetHoverIndex(): void;
|
||||
}
|
||||
const { useProvide, useInject: useHoverIndexInject } = useContext<HoverIndexContext>();
|
||||
|
||||
/** 获取被悬浮元素的索引上下文 */
|
||||
export default function useHoverIndexContext() {
|
||||
const index = ref(-1);
|
||||
function setHoverIndex(hIndex: number) {
|
||||
index.value = hIndex;
|
||||
}
|
||||
function resetHoverIndex() {
|
||||
index.value = -1;
|
||||
}
|
||||
|
||||
const context: HoverIndexContext = {
|
||||
index,
|
||||
setHoverIndex,
|
||||
resetHoverIndex
|
||||
};
|
||||
function useHoverIndexProvide() {
|
||||
useProvide(context);
|
||||
}
|
||||
|
||||
return {
|
||||
context,
|
||||
useHoverIndexProvide,
|
||||
useHoverIndexInject
|
||||
};
|
||||
}
|
Reference in New Issue
Block a user