Blame view

src/layouts/default/multitabs/data.ts 2.1 KB
陈文彬 authored
1
2
3
4
import { DropMenu } from '/@/components/Dropdown/index';
import { AppRouteRecordRaw } from '/@/router/types';
import type { TabItem } from '/@/store/modules/tab';
vben authored
5
6
7
8
import { useI18n } from '/@/hooks/web/useI18n';

const { t } = useI18n('layout.multipleTab');
陈文彬 authored
9
10
11
12
export enum TabContentEnum {
  TAB_TYPE,
  EXTRA_TYPE,
}
13
陈文彬 authored
14
15
16
17
18
export interface TabContentProps {
  tabItem: TabItem | AppRouteRecordRaw;
  type?: TabContentEnum;
  trigger?: Array<'click' | 'hover' | 'contextmenu'>;
}
19
陈文彬 authored
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
/**
 * @description: 右键:下拉菜单文字
 */
export enum MenuEventEnum {
  // 刷新
  REFRESH_PAGE,
  // 关闭当前
  CLOSE_CURRENT,
  // 关闭左侧
  CLOSE_LEFT,
  // 关闭右侧
  CLOSE_RIGHT,
  // 关闭其他
  CLOSE_OTHER,
  // 关闭所有
  CLOSE_ALL,
  // 放大
  SCALE,
}

export function getActions() {
  const REFRESH_PAGE: DropMenu = {
    icon: 'ant-design:reload-outlined',
    event: MenuEventEnum.REFRESH_PAGE,
vben authored
44
    text: t('redo'),
陈文彬 authored
45
46
47
48
49
    disabled: false,
  };
  const CLOSE_CURRENT: DropMenu = {
    icon: 'ant-design:close-outlined',
    event: MenuEventEnum.CLOSE_CURRENT,
vben authored
50
    text: t('close'),
陈文彬 authored
51
52
53
54
55
56
    disabled: false,
    divider: true,
  };
  const CLOSE_LEFT: DropMenu = {
    icon: 'ant-design:pic-left-outlined',
    event: MenuEventEnum.CLOSE_LEFT,
vben authored
57
    text: t('closeLeft'),
陈文彬 authored
58
59
60
61
62
63
    disabled: false,
    divider: false,
  };
  const CLOSE_RIGHT: DropMenu = {
    icon: 'ant-design:pic-right-outlined',
    event: MenuEventEnum.CLOSE_RIGHT,
vben authored
64
    text: t('closeRight'),
陈文彬 authored
65
66
67
68
69
70
    disabled: false,
    divider: true,
  };
  const CLOSE_OTHER: DropMenu = {
    icon: 'ant-design:pic-center-outlined',
    event: MenuEventEnum.CLOSE_OTHER,
vben authored
71
    text: t('closeOther'),
陈文彬 authored
72
73
74
75
76
    disabled: false,
  };
  const CLOSE_ALL: DropMenu = {
    icon: 'ant-design:line-outlined',
    event: MenuEventEnum.CLOSE_ALL,
vben authored
77
    text: t('closeAll'),
陈文彬 authored
78
79
80
81
82
83
84
85
86
87
88
89
90
    disabled: false,
  };
  return [REFRESH_PAGE, CLOSE_CURRENT, CLOSE_LEFT, CLOSE_RIGHT, CLOSE_OTHER, CLOSE_ALL];
}

export function getScaleAction(text: string, isZoom = false) {
  return {
    icon: isZoom ? 'codicon:screen-normal' : 'codicon:screen-full',
    event: MenuEventEnum.SCALE,
    text: text,
    disabled: false,
  };
}