@mc-markets/ui 1.0.85 → 1.0.87

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,142 +0,0 @@
1
- <template>
2
- <span class="m-breadcrumb__item">
3
- <span
4
- v-if="to"
5
- class="m-breadcrumb__inner"
6
- :class="{ 'is-link': to }"
7
- @click="handleClick"
8
- >
9
- <slot></slot>
10
- </span>
11
- <span v-else class="m-breadcrumb__inner">
12
- <slot></slot>
13
- </span>
14
- <i
15
- v-if="separatorIcon && !isLast"
16
- class="m-breadcrumb__separator"
17
- >
18
- <component :is="separatorIcon" />
19
- </i>
20
- <span
21
- v-else-if="!isLast"
22
- class="m-breadcrumb__separator"
23
- >
24
- {{ separator }}
25
- </span>
26
- </span>
27
- </template>
28
-
29
- <script setup>
30
- import { inject, computed, onMounted, onUnmounted, ref } from 'vue'
31
- import { useRouter } from 'vue-router'
32
-
33
- defineOptions({
34
- name: "MBreadcrumbItem",
35
- })
36
-
37
- // 定义 props
38
- const props = defineProps({
39
- to: {
40
- type: [String, Object],
41
- default: ''
42
- },
43
- replace: {
44
- type: Boolean,
45
- default: false
46
- }
47
- })
48
-
49
- // 注入父组件上下文
50
- const breadcrumbContext = inject('breadcrumbContext', {
51
- separator: '/',
52
- separatorIcon: undefined,
53
- registerItem: () => null,
54
- unregisterItem: () => {},
55
- isLastItem: () => false
56
- })
57
-
58
- // 获取分隔符配置
59
- const separator = computed(() => breadcrumbContext.separator)
60
- const separatorIcon = computed(() => breadcrumbContext.separatorIcon)
61
-
62
- // 组件 ID
63
- const itemId = ref(null)
64
-
65
- // 判断是否为最后一项
66
- const isLast = computed(() => {
67
- return itemId.value ? breadcrumbContext.isLastItem(itemId.value) : false
68
- })
69
-
70
- // 路由跳转
71
- const router = useRouter()
72
-
73
- const handleClick = () => {
74
- if (!props.to) return
75
-
76
- if (props.replace) {
77
- router.replace(props.to)
78
- } else {
79
- router.push(props.to)
80
- }
81
- }
82
-
83
- // 注册和注销组件
84
- onMounted(() => {
85
- if (breadcrumbContext.registerItem) {
86
- itemId.value = breadcrumbContext.registerItem()
87
- }
88
- })
89
-
90
- onUnmounted(() => {
91
- if (breadcrumbContext.unregisterItem && itemId.value) {
92
- breadcrumbContext.unregisterItem(itemId.value)
93
- }
94
- })
95
- </script>
96
-
97
- <style lang="scss" scoped>
98
- .m-breadcrumb__item {
99
- float: left;
100
-
101
- .m-breadcrumb__inner {
102
- color: var(--text-secondary, #606266);
103
- text-decoration: none;
104
- transition: color 0.2s cubic-bezier(0.645, 0.045, 0.355, 1);
105
-
106
- &:hover,
107
- &.is-link {
108
- color: var(--text-primary);
109
- // color: var(--bg-brand, #409eff);
110
- cursor: pointer;
111
- }
112
- }
113
-
114
- .m-breadcrumb__separator {
115
- margin: 0 9px;
116
- font-weight: 500;
117
- color: var(--text-tertiary, #c0c4cc);
118
- display: inline-flex;
119
- align-items: center;
120
- transform: translateY(10%);
121
- :deep(svg) {
122
- width: 14px;
123
- height: 14px;
124
- }
125
-
126
- [class*="icon"] {
127
- margin-right: 6px;
128
- }
129
- }
130
-
131
- &:last-child {
132
- .m-breadcrumb__inner {
133
- color: var(--text-tertiary, #909399);
134
- cursor: text;
135
- }
136
-
137
- .m-breadcrumb__separator {
138
- display: none;
139
- }
140
- }
141
- }
142
- </style>