@xilonglab/vue-main 1.1.6 → 1.1.7
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.
package/package.json
CHANGED
|
@@ -89,7 +89,7 @@ async function upload(option) {
|
|
|
89
89
|
<el-upload class="xl-image-input" action="" v-loading="loading" :headers="headers" :http-request="upload"
|
|
90
90
|
:before-upload="beforeUpload" :on-success="onSuccess" :show-file-list="false" :disabled="disabled"
|
|
91
91
|
:accept="props.accept">
|
|
92
|
-
<img v-if="value" class="image" :src="
|
|
92
|
+
<img v-if="value" class="image" :src="`/storage/${value}`"
|
|
93
93
|
:style="`max-width: ${width}px;max-height:${height}px`" />
|
|
94
94
|
<el-icon v-else class="icon" :style="`width: ${width}px;height:${height}px`">
|
|
95
95
|
<Plus />
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
<script setup>
|
|
2
|
+
defineOptions({ name: "XlTabsNav" })
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
import { useRouter } from 'vue-router'
|
|
6
|
+
import { inject } from 'vue'
|
|
7
|
+
import ContextMenu from '@imengyu/vue3-context-menu'
|
|
8
|
+
|
|
9
|
+
const router = useRouter()
|
|
10
|
+
const store = inject('store')
|
|
11
|
+
|
|
12
|
+
const switchTab = (tab) => {
|
|
13
|
+
router.push(tab.fullPath)
|
|
14
|
+
store.setActiveTab(tab.fullPath, tab.query)
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const closeTab = (path) => {
|
|
18
|
+
store.closeTab(path, router)
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const closeOtherTabs = (currentPath) => {
|
|
22
|
+
store.closeOtherTabs(currentPath, router)
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const closeLeftTabs = (currentPath) => {
|
|
26
|
+
store.closeLeftTabs(currentPath, router)
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const closeRightTabs = (currentPath) => {
|
|
30
|
+
store.closeRightTabs(currentPath, router)
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const showContextMenu = (event, tab) => {
|
|
34
|
+
event.preventDefault()
|
|
35
|
+
|
|
36
|
+
const currentIndex = store.state.tabs.findIndex(t => t.fullPath === tab.fullPath)
|
|
37
|
+
const hasLeftTabs = currentIndex > 0
|
|
38
|
+
const hasRightTabs = currentIndex >= 0 && currentIndex < store.state.tabs.length - 1
|
|
39
|
+
|
|
40
|
+
const menuItems = []
|
|
41
|
+
|
|
42
|
+
if (hasLeftTabs) {
|
|
43
|
+
menuItems.push({
|
|
44
|
+
label: '关闭左侧标签页',
|
|
45
|
+
onClick: () => closeLeftTabs(tab.fullPath)
|
|
46
|
+
})
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
if (hasRightTabs) {
|
|
50
|
+
menuItems.push({
|
|
51
|
+
label: '关闭右侧标签页',
|
|
52
|
+
onClick: () => closeRightTabs(tab.fullPath)
|
|
53
|
+
})
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
if (store.state.tabs.length > 1) {
|
|
57
|
+
menuItems.push({
|
|
58
|
+
label: '关闭其它标签页',
|
|
59
|
+
onClick: () => closeOtherTabs(tab.fullPath)
|
|
60
|
+
})
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
if (menuItems.length > 0) {
|
|
64
|
+
ContextMenu.showContextMenu({
|
|
65
|
+
x: event.x,
|
|
66
|
+
y: event.y,
|
|
67
|
+
items: menuItems
|
|
68
|
+
})
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
</script>
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
<template>
|
|
75
|
+
<div class="xl-tabs-nav">
|
|
76
|
+
<div
|
|
77
|
+
v-for="tab in store.state.tabs"
|
|
78
|
+
:key="tab.path"
|
|
79
|
+
class="tab-item"
|
|
80
|
+
:class="{ active: tab.fullPath === store.state.activeTab }"
|
|
81
|
+
@click="switchTab(tab)"
|
|
82
|
+
@contextmenu="showContextMenu($event, tab)"
|
|
83
|
+
>
|
|
84
|
+
<span>{{ tab.title }}</span>
|
|
85
|
+
<span class="close-icon" @click.stop="closeTab(tab.fullPath)">×</span>
|
|
86
|
+
</div>
|
|
87
|
+
</div>
|
|
88
|
+
</template>
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
<style lang="less">
|
|
92
|
+
.xl-tabs-nav {
|
|
93
|
+
display: flex;
|
|
94
|
+
padding: 4px 4px 0;
|
|
95
|
+
|
|
96
|
+
.tab-item {
|
|
97
|
+
height:20px;
|
|
98
|
+
|
|
99
|
+
padding: 5px 10px;
|
|
100
|
+
background: #fff;
|
|
101
|
+
color:rgb(100,100,100);
|
|
102
|
+
margin-right: 3px;
|
|
103
|
+
// border: 1px solid #d9d9d9;
|
|
104
|
+
/* border-bottom: none; */
|
|
105
|
+
border-radius: 4px;
|
|
106
|
+
cursor: pointer;
|
|
107
|
+
display: flex;
|
|
108
|
+
align-items: center;
|
|
109
|
+
font-size: 14px;
|
|
110
|
+
color:rgb(100,100,100);
|
|
111
|
+
/* gap: 8px; */
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
.tab-item.active {
|
|
115
|
+
background: rgb(66, 185, 131);
|
|
116
|
+
color:#fff;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
.close-icon {
|
|
120
|
+
font-size: 14px;
|
|
121
|
+
width: 16px;
|
|
122
|
+
height: 16px;
|
|
123
|
+
line-height: 16px;
|
|
124
|
+
text-align: center;
|
|
125
|
+
border-radius: 50%;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
.close-icon:hover {
|
|
129
|
+
background: #ccc;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
.tabs-content {
|
|
133
|
+
flex: 1;
|
|
134
|
+
display: flex;
|
|
135
|
+
flex-flow: column;
|
|
136
|
+
overflow: auto;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
</style>
|