web-component-gallery 1.3.12 → 2.0.2
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/dist/923.umd.js +1 -0
- package/dist/index.umd.js +1 -12252
- package/dist/js.umd.js +1 -0
- package/dist/style.css +17 -0
- package/dist/style.umd.js +1 -0
- package/{method → extensions}/AMap.js +1 -5
- package/{plugins/method → extensions}/Dialog.js +2 -2
- package/{lib/lazy_use.js → extensions/index.js} +16 -2
- package/lib/{amap/components/AmapSearch/index.jsx → amap-comp/AmapSearch.jsx} +3 -5
- package/lib/amap-comp/index.js +18 -0
- package/{plugins/lib/amap/components/AmapSearch/index.less → lib/amap-comp/style/AmapSearch.less} +5 -3
- package/lib/amap-comp/style/index.js +1 -0
- package/lib/amap-comp/style/index.less +1 -0
- package/lib/{amap/AmapDraw.jsx → amap-draw/index.jsx} +2 -4
- package/lib/amap-draw/style/index.js +1 -0
- package/lib/{amap/AmapDraw.less → amap-draw/style/index.less} +6 -3
- package/lib/browse/index.jsx +0 -2
- package/lib/browse/style/index.js +1 -0
- package/lib/button/Button.js +1 -3
- package/lib/button/style/index.js +1 -0
- package/{plugins/lib/dateTime → lib/date-time}/index.vue +3 -13
- package/lib/date-time/style/index.js +1 -0
- package/lib/date-time/style/index.less +7 -0
- package/lib/{descriptions → descriptions-list}/index.jsx +1 -3
- package/lib/descriptions-list/style/index.js +1 -0
- package/{plugins/lib/tree → lib/directory}/Directory.js +4 -21
- package/lib/directory/index.js +8 -0
- package/lib/directory/style/index.js +1 -0
- package/lib/{tree/style/Directory.less → directory/style/index.less} +3 -4
- package/{plugins/lib/form/components → lib/form-comp}/ACascaderMultiple.vue +1 -106
- package/lib/form-comp/ARadio.vue +70 -0
- package/lib/{form/components → form-comp}/ARangePicker.vue +9 -20
- package/lib/{form/components → form-comp}/ASelectCustom.vue +1 -8
- package/lib/form-comp/ATagsInput.vue +88 -0
- package/lib/form-comp/ATimePicker.vue +127 -0
- package/lib/{form/components → form-comp}/AUpload.vue +2 -17
- package/lib/form-comp/index.js +37 -0
- package/lib/form-comp/style/ACascaderMultiple.less +117 -0
- package/lib/form-comp/style/ARadio.less +0 -0
- package/lib/form-comp/style/ARangePicker.less +11 -0
- package/lib/form-comp/style/ASelectCustom.less +4 -0
- package/lib/form-comp/style/ATagsInput.less +24 -0
- package/lib/form-comp/style/ATimePicker.less +8 -0
- package/lib/form-comp/style/AUpload.less +15 -0
- package/lib/form-comp/style/index.js +1 -0
- package/lib/form-comp/style/index.less +7 -0
- package/lib/index.js +60 -45
- package/lib/modal/index.jsx +4 -6
- package/lib/modal/style/index.js +1 -0
- package/lib/modal/{index.less → style/index.less} +6 -7
- package/{plugins/lib/form → lib/model}/Model.js +1 -3
- package/lib/model/index.js +7 -0
- package/lib/model/style/index.js +1 -0
- package/lib/{form/style/Model.less → model/style/index.less} +10 -10
- package/{plugins/lib/form → lib/model}/utils/render.js +1 -1
- package/lib/{form → model}/utils/resetFields.js +1 -1
- package/lib/no-data/directive.js +65 -0
- package/lib/no-data/index.js +21 -0
- package/lib/no-data/index.vue +35 -0
- package/lib/no-data/style/index.js +1 -0
- package/lib/no-data/style/index.less +15 -0
- package/lib/search/index.js +7 -0
- package/{plugins/lib/form/Search.vue → lib/search/index.vue} +3 -6
- package/lib/search/style/index.js +1 -0
- package/{plugins/lib/form/style/Search.less → lib/search/style/index.less} +7 -8
- package/lib/style/mixins.less +1 -1
- package/lib/{svgIcon → svg-icon}/index.vue +1 -17
- package/lib/svg-icon/style/index.js +1 -0
- package/lib/svg-icon/style/index.less +15 -0
- package/lib/table/index.vue +4 -8
- package/lib/table/style/index.js +1 -0
- package/lib/table/style/index.less +12 -13
- package/lib/tree/index.js +2 -11
- package/{plugins/lib/tree/Tree.vue → lib/tree/index.vue} +2 -5
- package/lib/tree/style/index.js +1 -0
- package/{plugins/lib/tree/style/Tree.less → lib/tree/style/index.less} +4 -4
- package/lib/weather/index.vue +1 -9
- package/lib/weather/style/index.js +1 -0
- package/lib/weather/style/index.less +7 -0
- package/package.json +16 -34
- package/utils/Axios.js +91 -82
- package/utils/Postcss.js +12 -8
- package/README.md +0 -24
- package/dist/amap.umd.js +0 -12252
- package/dist/avatar.umd.js +0 -5337
- package/dist/button.umd.js +0 -5845
- package/dist/dateTime.umd.js +0 -1287
- package/dist/form.umd.js +0 -9981
- package/dist/multiTab.umd.js +0 -5556
- package/dist/svgIcon.umd.js +0 -1167
- package/dist/table.umd.js +0 -6306
- package/dist/tree.umd.js +0 -5393
- package/dist/weather.umd.js +0 -1167
- package/lib/amap/components/AmapSearch/index.less +0 -16
- package/lib/amap/index.js +0 -13
- package/lib/avatar/index.js +0 -7
- package/lib/avatar/index.vue +0 -47
- package/lib/basic/404.vue +0 -24
- package/lib/dateTime/index.vue +0 -43
- package/lib/form/Model.js +0 -153
- package/lib/form/Search.vue +0 -159
- package/lib/form/components/ACascaderMultiple.vue +0 -766
- package/lib/form/components/ARadio.vue +0 -74
- package/lib/form/components/ATagsInput.vue +0 -93
- package/lib/form/components/ATimePicker.vue +0 -73
- package/lib/form/index.js +0 -55
- package/lib/form/style/Search.less +0 -34
- package/lib/form/utils/render.js +0 -85
- package/lib/iframe/events.js +0 -2
- package/lib/iframe/index.jsx +0 -234
- package/lib/iframe/index.less +0 -19
- package/lib/multiTab/APIEnums.js +0 -17
- package/lib/multiTab/MultiTab.jsx +0 -237
- package/lib/multiTab/RouteAPI.js +0 -71
- package/lib/multiTab/RouteContent.jsx +0 -90
- package/lib/multiTab/RouteKeepAlive.js +0 -183
- package/lib/multiTab/events.js +0 -2
- package/lib/multiTab/index.js +0 -15
- package/lib/multiTab/index.less +0 -73
- package/lib/style/index.less +0 -2
- package/lib/tree/Directory.js +0 -428
- package/lib/tree/Tree.vue +0 -181
- package/lib/tree/style/Tree.less +0 -52
- package/method/Dialog.js +0 -134
- package/method/index.js +0 -12
- package/plugins/lib/amap/AmapDraw.jsx +0 -349
- package/plugins/lib/amap/AmapDraw.less +0 -45
- package/plugins/lib/amap/components/AmapSearch/index.jsx +0 -73
- package/plugins/lib/amap/index.js +0 -13
- package/plugins/lib/avatar/index.js +0 -7
- package/plugins/lib/avatar/index.vue +0 -47
- package/plugins/lib/basic/404.vue +0 -24
- package/plugins/lib/browse/index.jsx +0 -76
- package/plugins/lib/browse/index.less +0 -4
- package/plugins/lib/button/Button.js +0 -89
- package/plugins/lib/button/index.js +0 -7
- package/plugins/lib/dateTime/index.js +0 -7
- package/plugins/lib/descriptions/index.jsx +0 -108
- package/plugins/lib/descriptions/index.less +0 -15
- package/plugins/lib/form/components/ARadio.vue +0 -74
- package/plugins/lib/form/components/ARangePicker.vue +0 -129
- package/plugins/lib/form/components/ASelectCustom.vue +0 -226
- package/plugins/lib/form/components/ATagsInput.vue +0 -93
- package/plugins/lib/form/components/ATimePicker.vue +0 -73
- package/plugins/lib/form/components/AUpload.vue +0 -183
- package/plugins/lib/form/components/RenderComp.vue +0 -69
- package/plugins/lib/form/index.js +0 -55
- package/plugins/lib/form/style/Model.less +0 -53
- package/plugins/lib/form/utils/resetFields.js +0 -16
- package/plugins/lib/iframe/events.js +0 -2
- package/plugins/lib/iframe/index.jsx +0 -234
- package/plugins/lib/iframe/index.less +0 -19
- package/plugins/lib/index.js +0 -72
- package/plugins/lib/lazy_use.js +0 -40
- package/plugins/lib/modal/index.jsx +0 -53
- package/plugins/lib/modal/index.less +0 -50
- package/plugins/lib/multiTab/APIEnums.js +0 -17
- package/plugins/lib/multiTab/MultiTab.jsx +0 -237
- package/plugins/lib/multiTab/RouteAPI.js +0 -71
- package/plugins/lib/multiTab/RouteContent.jsx +0 -90
- package/plugins/lib/multiTab/RouteKeepAlive.js +0 -183
- package/plugins/lib/multiTab/events.js +0 -2
- package/plugins/lib/multiTab/index.js +0 -15
- package/plugins/lib/multiTab/index.less +0 -73
- package/plugins/lib/style/index.less +0 -2
- package/plugins/lib/style/mixins.less +0 -79
- package/plugins/lib/svgIcon/index.js +0 -7
- package/plugins/lib/svgIcon/index.vue +0 -77
- package/plugins/lib/table/index.js +0 -7
- package/plugins/lib/table/index.vue +0 -217
- package/plugins/lib/table/style/index.less +0 -50
- package/plugins/lib/tree/index.js +0 -17
- package/plugins/lib/tree/style/Directory.less +0 -119
- package/plugins/lib/weather/index.js +0 -7
- package/plugins/lib/weather/index.vue +0 -58
- package/plugins/method/AMap.js +0 -368
- package/plugins/method/PageLoading.jsx +0 -106
- package/plugins/method/Theme.js +0 -88
- package/plugins/method/index.js +0 -12
- package/plugins/store/auth.js +0 -31
- package/plugins/store/cache.js +0 -56
- package/plugins/store/chat.js +0 -74
- package/plugins/store/project.js +0 -46
- package/plugins/utils/Axios.js +0 -105
- package/plugins/utils/Base64.js +0 -314
- package/plugins/utils/Filter.js +0 -249
- package/plugins/utils/PostMessage.js +0 -16
- package/plugins/utils/Postcss.js +0 -9
- package/plugins/utils/Rem.js +0 -24
- package/plugins/utils/Request.js +0 -38
- package/plugins/utils/Storage.js +0 -73
- package/plugins/utils/Tree.js +0 -169
- package/plugins/utils/Utils.js +0 -51
- package/plugins/utils/Validate.js +0 -33
- package/plugins/utils/Websocket.js +0 -186
- package/utils/PostMessage.js +0 -16
- package/utils/Request.js +0 -38
- /package/{method → extensions}/PageLoading.jsx +0 -0
- /package/{method → extensions}/Theme.js +0 -0
- /package/{plugins/font → font}/DS-DIGI-1.ttf +0 -0
- /package/{plugins/font → font}/DS-DIGIB-2.ttf +0 -0
- /package/{plugins/font → font}/DS-DIGII-3.ttf +0 -0
- /package/{plugins/font → font}/DS-DIGIT-4.ttf +0 -0
- /package/{plugins/font → font}/Orbitron-Black.ttf +0 -0
- /package/{plugins/font → font}/Orbitron-Bold.ttf +0 -0
- /package/{plugins/font → font}/Orbitron-Medium.ttf +0 -0
- /package/{plugins/font → font}/Orbitron-Regular.ttf +0 -0
- /package/{plugins/font → font}/PANGMENZHENGDAOBIAOTITI-1.TTF +0 -0
- /package/{plugins/font → font}/PingFang SC.ttf +0 -0
- /package/{plugins/font → font}/YouSheBiaoTiHei.ttf +0 -0
- /package/{plugins/font → font}/font.css +0 -0
- /package/{plugins/font → font}//345/255/227/351/255/20235/345/217/267-/347/273/217/345/205/270/351/233/205/351/273/221.ttf" +0 -0
- /package/lib/browse/{index.less → style/index.less} +0 -0
- /package/{dist/css/index.css → lib/button/style/index.less} +0 -0
- /package/lib/{dateTime → date-time}/index.js +0 -0
- /package/lib/{descriptions → descriptions-list/style}/index.less +0 -0
- /package/lib/{form/components → form-comp}/RenderComp.vue +0 -0
- /package/lib/{svgIcon → svg-icon}/index.js +0 -0
|
@@ -1,237 +0,0 @@
|
|
|
1
|
-
import AppEvent from './events'
|
|
2
|
-
import { TAB_BINDING } from './APIEnums'
|
|
3
|
-
import { Menu, Dropdown, Button, Icon, Tabs } from 'ant-design-vue'
|
|
4
|
-
import './index.less'
|
|
5
|
-
|
|
6
|
-
const eventKey = {
|
|
7
|
-
'closeThat': TAB_BINDING.TAB_CLOSE,
|
|
8
|
-
'closeRight': TAB_BINDING.TAB_CLOSE_RIGHT,
|
|
9
|
-
'closeLeft': TAB_BINDING.TAB_CLOSE_LEFT,
|
|
10
|
-
'closeAll': TAB_BINDING.TAB_CLOSE_ALL
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
const i18nRender = (context) => context
|
|
14
|
-
|
|
15
|
-
const renderTabMenu = (h, path) => {
|
|
16
|
-
const props = {
|
|
17
|
-
on: {
|
|
18
|
-
click: ({ key, item, domEvent }) => {
|
|
19
|
-
console.log('key', path)
|
|
20
|
-
console.log(key, item, domEvent)
|
|
21
|
-
AppEvent.$emit(eventKey[key], path)
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
return (
|
|
26
|
-
<Menu {...props}>
|
|
27
|
-
<Menu.Item key="closeThat">关闭当前标签</Menu.Item>
|
|
28
|
-
<Menu.Item key="closeRight">关闭右侧</Menu.Item>
|
|
29
|
-
<Menu.Item key="closeLeft">关闭左侧</Menu.Item>
|
|
30
|
-
<Menu.Item key="closeAll">关闭全部</Menu.Item>
|
|
31
|
-
</Menu>
|
|
32
|
-
)
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
const renderTabDropDown = (h, title, keyPath, handles) => {
|
|
36
|
-
const handleReload = () => {
|
|
37
|
-
handles['reload'](keyPath)
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
const menus = renderTabMenu(h, keyPath)
|
|
41
|
-
return (
|
|
42
|
-
<Dropdown overlay={menus} trigger={['contextmenu']}>
|
|
43
|
-
<span>
|
|
44
|
-
<span class='ant-pro-multi-tab-title'>{ title }</span>
|
|
45
|
-
{/* <Icon title='reload page' class='ant-pro-multi-tab-icon' type={'reload'} onClick={handleReload} /> */}
|
|
46
|
-
</span>
|
|
47
|
-
</Dropdown>
|
|
48
|
-
)
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
const MultiTab = {
|
|
52
|
-
name: 'MultiTab',
|
|
53
|
-
props: {
|
|
54
|
-
contentWidth: {
|
|
55
|
-
type: Boolean,
|
|
56
|
-
default: false
|
|
57
|
-
}
|
|
58
|
-
},
|
|
59
|
-
data () {
|
|
60
|
-
return {
|
|
61
|
-
activeKey: '',
|
|
62
|
-
pages: [],
|
|
63
|
-
fullPathList: []
|
|
64
|
-
}
|
|
65
|
-
},
|
|
66
|
-
render (h) {
|
|
67
|
-
const { $data: { pages }, contentWidth } = this
|
|
68
|
-
const handles = {
|
|
69
|
-
cls: (keyPath) => {
|
|
70
|
-
// console.log('close', keyPath)
|
|
71
|
-
// this.closeThat(keyPath)
|
|
72
|
-
this.$tab.close(keyPath, false)
|
|
73
|
-
},
|
|
74
|
-
reload: (keyPath) => {
|
|
75
|
-
this.$tab.refresh(keyPath)
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
const tabPanels = pages.map(page => {
|
|
79
|
-
const title = page.meta.customTitle || page.meta.title
|
|
80
|
-
return (
|
|
81
|
-
<Tabs.TabPane
|
|
82
|
-
style={{ height: 0 }}
|
|
83
|
-
key={page.fullPath}
|
|
84
|
-
tab={renderTabDropDown(h, i18nRender(title), page.fullPath, handles)}
|
|
85
|
-
closable={pages.length > 1}
|
|
86
|
-
></Tabs.TabPane>
|
|
87
|
-
)
|
|
88
|
-
})
|
|
89
|
-
|
|
90
|
-
const edit = (targetKey, action) => {
|
|
91
|
-
console.log('editTab:', targetKey, 'action:', action)
|
|
92
|
-
this[action](targetKey)
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
const handleMenuClick = ({key}) => {
|
|
96
|
-
this[key](this.activeKey)
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
const controlMenu = (<Dropdown slot="tabBarExtraContent" style={{ marginRight: '8px' }}>
|
|
100
|
-
<Menu slot="overlay" onClick={handleMenuClick}>
|
|
101
|
-
{/* <Menu.Item key="closeAll">全部关闭</Menu.Item> */}
|
|
102
|
-
<Menu.Item key="closeThat">关闭当前</Menu.Item>
|
|
103
|
-
<Menu.Item key="closeAll">关闭其他</Menu.Item>
|
|
104
|
-
</Menu>
|
|
105
|
-
<Button icon={'align-left'} type={'link'}><Icon type="down" /></Button>
|
|
106
|
-
</Dropdown>)
|
|
107
|
-
|
|
108
|
-
return (
|
|
109
|
-
<div class={['ant-pro-multi-tab', contentWidth ? 'wide' : null]}>
|
|
110
|
-
<div class={'ant-pro-multi-tab-wrapper'}>
|
|
111
|
-
<Tabs
|
|
112
|
-
hideAdd
|
|
113
|
-
type={'editable-card'}
|
|
114
|
-
vModel={this.activeKey}
|
|
115
|
-
onEdit={edit}
|
|
116
|
-
>
|
|
117
|
-
{tabPanels}
|
|
118
|
-
{controlMenu}
|
|
119
|
-
</Tabs>
|
|
120
|
-
</div>
|
|
121
|
-
</div>
|
|
122
|
-
)
|
|
123
|
-
},
|
|
124
|
-
created () {
|
|
125
|
-
const { pages, fullPathList } = this
|
|
126
|
-
AppEvent.$on(TAB_BINDING.TAB_CLOSE, val => {
|
|
127
|
-
this.closeThat(val)
|
|
128
|
-
console.log('hook:tab:ck', val)
|
|
129
|
-
}).$on(TAB_BINDING.TAB_CLOSE_RIGHT, val => {
|
|
130
|
-
this.closeRight(val)
|
|
131
|
-
console.log('hook:tab:closeRight', val)
|
|
132
|
-
}).$on(TAB_BINDING.TAB_CLOSE_LEFT, val => {
|
|
133
|
-
this.closeLeft(val)
|
|
134
|
-
console.log('hook:tab:closeLeft', val)
|
|
135
|
-
}).$on(TAB_BINDING.TAB_CLOSE_ALL, val => {
|
|
136
|
-
this.closeAll(val)
|
|
137
|
-
console.log('hook:tab:closeAll', val)
|
|
138
|
-
}).$on('hook:tab:rename', val => {
|
|
139
|
-
// console.log('hook:tab:rename', val)
|
|
140
|
-
})
|
|
141
|
-
|
|
142
|
-
pages.push(this.$route)
|
|
143
|
-
fullPathList.push(this.$route.fullPath)
|
|
144
|
-
|
|
145
|
-
this.activeLastTab()
|
|
146
|
-
|
|
147
|
-
this.$watch('$route', newVal => {
|
|
148
|
-
const { fullPath, params } = newVal
|
|
149
|
-
if (this.activeKey !== fullPath) {
|
|
150
|
-
this.activeKey = fullPath
|
|
151
|
-
}
|
|
152
|
-
if (this.fullPathList.indexOf(fullPath) < 0) {
|
|
153
|
-
this.fullPathList.push(fullPath)
|
|
154
|
-
/** 向外抛出打开方法 */
|
|
155
|
-
this.$tab.open(newVal)
|
|
156
|
-
if (params && params._tabName) {
|
|
157
|
-
const newPage = Object.assign({}, newVal, {
|
|
158
|
-
meta: {
|
|
159
|
-
customTitle: params._tabName
|
|
160
|
-
}
|
|
161
|
-
})
|
|
162
|
-
this.pages.push(newPage)
|
|
163
|
-
} else {
|
|
164
|
-
this.pages.push(newVal)
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
})
|
|
168
|
-
this.$watch('activeKey', pathKey => {
|
|
169
|
-
this.$router.push({ path: pathKey })
|
|
170
|
-
/** 激活路由时记录信息 */
|
|
171
|
-
this.$tab.activeTab(this.$route)
|
|
172
|
-
})
|
|
173
|
-
},
|
|
174
|
-
mounted () {
|
|
175
|
-
/** 延迟执行,记录第一次路由 */
|
|
176
|
-
// let timer=setTimeout(()=>{
|
|
177
|
-
// this.$tab.open(this.$route)
|
|
178
|
-
// clearTimeout(timer)
|
|
179
|
-
// }, 60)
|
|
180
|
-
},
|
|
181
|
-
methods: {
|
|
182
|
-
activeLastTab () {
|
|
183
|
-
this.activeKey = this.fullPathList[this.fullPathList.length - 1]
|
|
184
|
-
},
|
|
185
|
-
remove (targetKey) {
|
|
186
|
-
this.closeThat(targetKey)
|
|
187
|
-
},
|
|
188
|
-
closeThat (targetKey) {
|
|
189
|
-
if (this.fullPathList.length > 1) {
|
|
190
|
-
this.pages = this.pages.filter(page => page.fullPath !== targetKey)
|
|
191
|
-
this.fullPathList = this.fullPathList.filter(path => path !== targetKey)
|
|
192
|
-
this.activeLastTab()
|
|
193
|
-
/** 向外抛出关闭方法 */
|
|
194
|
-
let cache = true
|
|
195
|
-
try {
|
|
196
|
-
const majorPath = targetKey.split('?')[0]
|
|
197
|
-
cache = this.fullPathList.some( path =>
|
|
198
|
-
path.includes('?') &&
|
|
199
|
-
path.split('?')[0] === majorPath
|
|
200
|
-
)
|
|
201
|
-
this.$tab.close(majorPath, cache)
|
|
202
|
-
} catch{ this.$tab.close(targetKey, cache) }
|
|
203
|
-
console.log( cache, '是否缓存' )
|
|
204
|
-
}
|
|
205
|
-
},
|
|
206
|
-
closeLeft(e) {
|
|
207
|
-
const currentIndex = this.fullPathList.indexOf(e)
|
|
208
|
-
if (currentIndex > 0) {
|
|
209
|
-
this.fullPathList.forEach((item, index) => {
|
|
210
|
-
if (index < currentIndex) {
|
|
211
|
-
this.remove(item)
|
|
212
|
-
}
|
|
213
|
-
})
|
|
214
|
-
}
|
|
215
|
-
},
|
|
216
|
-
closeRight(e) {
|
|
217
|
-
const currentIndex = this.fullPathList.indexOf(e)
|
|
218
|
-
if (currentIndex < this.fullPathList.length - 1) {
|
|
219
|
-
this.fullPathList.forEach((item, index) => {
|
|
220
|
-
if (index > currentIndex) {
|
|
221
|
-
this.remove(item)
|
|
222
|
-
}
|
|
223
|
-
})
|
|
224
|
-
}
|
|
225
|
-
},
|
|
226
|
-
closeAll(e) {
|
|
227
|
-
const currentIndex = this.fullPathList.indexOf(e)
|
|
228
|
-
this.fullPathList.forEach((item, index) => {
|
|
229
|
-
if (index !== currentIndex) {
|
|
230
|
-
this.remove(item)
|
|
231
|
-
}
|
|
232
|
-
})
|
|
233
|
-
},
|
|
234
|
-
}
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
export default MultiTab
|
package/lib/multiTab/RouteAPI.js
DELETED
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
import { ROUTE_BINDING } from './APIEnums'
|
|
2
|
-
import AppEvent from './events'
|
|
3
|
-
|
|
4
|
-
const RouteAPI = {
|
|
5
|
-
/**
|
|
6
|
-
* Open a new tab(route)
|
|
7
|
-
* 打开一个新标签(路由)
|
|
8
|
-
*
|
|
9
|
-
* @param config: {
|
|
10
|
-
* routeName,
|
|
11
|
-
* title,
|
|
12
|
-
* path
|
|
13
|
-
* }
|
|
14
|
-
*/
|
|
15
|
-
open (config) {
|
|
16
|
-
AppEvent.$emit(ROUTE_BINDING.R_OPEN, config)
|
|
17
|
-
},
|
|
18
|
-
/**
|
|
19
|
-
* Close a tab
|
|
20
|
-
* 关闭一个打开的标签
|
|
21
|
-
* 如果标签没打开或找不到标签则不做任何事情
|
|
22
|
-
*
|
|
23
|
-
* @param config
|
|
24
|
-
* @param cache: bool true 则关闭后会缓存页面,false 反之
|
|
25
|
-
* { config, isCache: cache }
|
|
26
|
-
*/
|
|
27
|
-
close (config, cache) {
|
|
28
|
-
AppEvent.$emit(ROUTE_BINDING.R_CLOSE, { config, isCache: cache })
|
|
29
|
-
},
|
|
30
|
-
/**
|
|
31
|
-
* Active a opened tab
|
|
32
|
-
* 激活一个已经打开的 tab
|
|
33
|
-
* @param config
|
|
34
|
-
*/
|
|
35
|
-
activeTab (config) {
|
|
36
|
-
AppEvent.$emit(ROUTE_BINDING.R_ACTIVE, config)
|
|
37
|
-
},
|
|
38
|
-
/**
|
|
39
|
-
* Replace current page to new Route
|
|
40
|
-
* 替换当前 tab 页面为一个新的页面
|
|
41
|
-
* 注意:这个替换会更新路由地址,但是 tab 的位置不会发生变化
|
|
42
|
-
* 被替换的路由还会被缓存住,下次打开还是缓存时的状态
|
|
43
|
-
*
|
|
44
|
-
* @param {*} config
|
|
45
|
-
*/
|
|
46
|
-
replace (config) {
|
|
47
|
-
AppEvent.$emit('hook:replace', config)
|
|
48
|
-
},
|
|
49
|
-
/**
|
|
50
|
-
* Refresh current tab (clear page cache)
|
|
51
|
-
*/
|
|
52
|
-
refresh (keyPath) {
|
|
53
|
-
AppEvent.$emit(ROUTE_BINDING.R_REFRESH, keyPath)
|
|
54
|
-
},
|
|
55
|
-
closeAll () {
|
|
56
|
-
AppEvent.$emit('hook:closeAll')
|
|
57
|
-
},
|
|
58
|
-
closeOthers () {
|
|
59
|
-
AppEvent.$emit('hook:closeOthers')
|
|
60
|
-
},
|
|
61
|
-
/**
|
|
62
|
-
* Get all cached page
|
|
63
|
-
*
|
|
64
|
-
* @param callback
|
|
65
|
-
*/
|
|
66
|
-
caches (callback) {
|
|
67
|
-
AppEvent.$emit(ROUTE_BINDING.R_GET_CACHES, callback)
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
export default RouteAPI
|
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
/* eslint-disable */
|
|
2
|
-
import { ROUTE_BINDING, TAB_BINDING } from './APIEnums'
|
|
3
|
-
import AppEvent from './events'
|
|
4
|
-
import RouteAPI from './RouteAPI'
|
|
5
|
-
import MultiTab from './MultiTab.jsx'
|
|
6
|
-
import RouteKeepAlive from './RouteKeepAlive'
|
|
7
|
-
|
|
8
|
-
const addAndGet = val => {
|
|
9
|
-
return val >= Number.MAX_SAFE_INTEGER ? 0 : ++val
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
const RouteContent = {
|
|
13
|
-
name: 'RouteContent',
|
|
14
|
-
data () {
|
|
15
|
-
return {
|
|
16
|
-
includes: [],
|
|
17
|
-
excludes: [],
|
|
18
|
-
/*
|
|
19
|
-
* Cache: { fullPath : String, snapshot : Number }
|
|
20
|
-
* cached: Map
|
|
21
|
-
*/
|
|
22
|
-
cached: {}
|
|
23
|
-
}
|
|
24
|
-
},
|
|
25
|
-
render () {
|
|
26
|
-
const {
|
|
27
|
-
$route: { meta, fullPath },
|
|
28
|
-
includes,
|
|
29
|
-
excludes,
|
|
30
|
-
cached
|
|
31
|
-
} = this
|
|
32
|
-
|
|
33
|
-
const handleRef = (ref) => {
|
|
34
|
-
this.keepRef = ref
|
|
35
|
-
}
|
|
36
|
-
console.log('meta', this.$route);
|
|
37
|
-
if (meta.keepAlive) {
|
|
38
|
-
if (includes.findIndex(item => item === fullPath) === -1) {
|
|
39
|
-
includes.push(fullPath)
|
|
40
|
-
cached[fullPath] = {
|
|
41
|
-
fullPath,
|
|
42
|
-
snapshot: 0
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
const genKey = cached[fullPath].fullPath + cached[fullPath].snapshot
|
|
47
|
-
const props = {
|
|
48
|
-
on: {
|
|
49
|
-
ref: handleRef
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
return (
|
|
53
|
-
<route-keep-alive {...props} include={includes} exclude={excludes}>
|
|
54
|
-
<router-view key={genKey} />
|
|
55
|
-
</route-keep-alive>
|
|
56
|
-
)
|
|
57
|
-
},
|
|
58
|
-
created () {
|
|
59
|
-
AppEvent.$on(ROUTE_BINDING.R_OPEN, ({ routeName, title, ...rest }) => {
|
|
60
|
-
this.$router.push({ name: routeName, params: { '_tabName': title, ...rest } })
|
|
61
|
-
}).$on(ROUTE_BINDING.R_REFRESH, keyPath => {
|
|
62
|
-
const { $route: { fullPath } } = this
|
|
63
|
-
let key = keyPath || fullPath
|
|
64
|
-
const cache = this.cached[key]
|
|
65
|
-
this.keepRef.clearCache(key)
|
|
66
|
-
cache.snapshot = addAndGet(cache.snapshot)
|
|
67
|
-
// how with
|
|
68
|
-
this.$forceUpdate()
|
|
69
|
-
}).$on(ROUTE_BINDING.R_GET_CACHES, (callback) => {
|
|
70
|
-
callback(this.keepRef.allCache())
|
|
71
|
-
}).$on(ROUTE_BINDING.R_CLOSE, val => {
|
|
72
|
-
const { config: keyPath, isCache } = val
|
|
73
|
-
AppEvent.$emit(TAB_BINDING.TAB_CLOSE, keyPath)
|
|
74
|
-
// this.keepRef.clearCache(keyPath)
|
|
75
|
-
})
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
RouteContent.install = function (Vue) {
|
|
80
|
-
if (Vue.prototype.$tab) {
|
|
81
|
-
return
|
|
82
|
-
}
|
|
83
|
-
Vue.prototype.$tab = RouteAPI
|
|
84
|
-
Vue.prototype.$tabBus = AppEvent
|
|
85
|
-
Vue.component(RouteContent.name, RouteContent)
|
|
86
|
-
Vue.component(RouteKeepAlive.name, RouteKeepAlive)
|
|
87
|
-
Vue.component(MultiTab.name, MultiTab)
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
export default RouteContent
|
|
@@ -1,183 +0,0 @@
|
|
|
1
|
-
const _toString = Object.prototype.toString
|
|
2
|
-
|
|
3
|
-
const isRegExp = (v) => {
|
|
4
|
-
return _toString.call(v) === '[object RegExp]'
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
const isDef = (v) => {
|
|
8
|
-
return v !== undefined && v !== null
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
const isAsyncPlaceholder = (node) => {
|
|
12
|
-
return node.isComment && node.asyncFactory
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
const remove = (arr, item) => {
|
|
16
|
-
if (arr.length) {
|
|
17
|
-
const index = arr.indexOf(item)
|
|
18
|
-
if (index > -1) {
|
|
19
|
-
return arr.splice(index, 1)
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export const getFirstComponentChild = (children) => {
|
|
25
|
-
if (Array.isArray(children)) {
|
|
26
|
-
for (let i = 0; i < children.length; i++) {
|
|
27
|
-
const c = children[i]
|
|
28
|
-
if (isDef(c) && (isDef(c.componentOptions) || isAsyncPlaceholder(c))) {
|
|
29
|
-
return c
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
export const getComponentName = (opts) => {
|
|
36
|
-
return opts && (opts.Ctor.options.name || opts.tag)
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
export const getComponentKey = (opts) => {
|
|
40
|
-
return opts && (opts.Ctor.cid + (opts.tag ? `::${opts.tag}` : ''))
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
export const getCurrentRouteKey = ($route) => {
|
|
44
|
-
return $route.fullPath
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
const matches = (pattern, name) => {
|
|
48
|
-
if (Array.isArray(pattern)) {
|
|
49
|
-
return pattern.indexOf(name) > -1
|
|
50
|
-
} else if (typeof pattern === 'string') {
|
|
51
|
-
return pattern.split(',').indexOf(name) > -1
|
|
52
|
-
} else if (isRegExp(pattern)) {
|
|
53
|
-
return pattern.test(name)
|
|
54
|
-
}
|
|
55
|
-
/* istanbul ignore next */
|
|
56
|
-
return false
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
const pruneCache = (keepAliveInstance, cacheKey) => {
|
|
60
|
-
const { cache, keys, _vnode } = keepAliveInstance
|
|
61
|
-
for (const key in cache) {
|
|
62
|
-
const cachedNode = cache[key]
|
|
63
|
-
if (cachedNode) {
|
|
64
|
-
if (cacheKey === key) {
|
|
65
|
-
pruneCacheEntry(cache, key, keys, _vnode)
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
const pruneCacheEntry = (
|
|
72
|
-
cache,
|
|
73
|
-
key,
|
|
74
|
-
keys,
|
|
75
|
-
current
|
|
76
|
-
) => {
|
|
77
|
-
const cached = cache[key]
|
|
78
|
-
if (cached && (!current || cached.tag !== current.tag)) {
|
|
79
|
-
cached.componentInstance.$destroy()
|
|
80
|
-
}
|
|
81
|
-
cache[key] = null
|
|
82
|
-
remove(keys, key)
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
/* const findCached = (cached, vnode) => {
|
|
86
|
-
|
|
87
|
-
} */
|
|
88
|
-
|
|
89
|
-
const RouteKeepAlive = {
|
|
90
|
-
name: 'RouteKeepAlive',
|
|
91
|
-
abstract: true,
|
|
92
|
-
props: {
|
|
93
|
-
include: {
|
|
94
|
-
type: [String, Array],
|
|
95
|
-
default: ''
|
|
96
|
-
},
|
|
97
|
-
exclude: {
|
|
98
|
-
type: [String, Array],
|
|
99
|
-
default: ''
|
|
100
|
-
},
|
|
101
|
-
max: {
|
|
102
|
-
type: [String, Number],
|
|
103
|
-
default: null
|
|
104
|
-
}
|
|
105
|
-
},
|
|
106
|
-
|
|
107
|
-
created () {
|
|
108
|
-
this.cache = Object.create(null)
|
|
109
|
-
this.keys = []
|
|
110
|
-
},
|
|
111
|
-
|
|
112
|
-
destroyed () {
|
|
113
|
-
for (const key in this.cache) {
|
|
114
|
-
pruneCacheEntry(this.cache, key, this.keys)
|
|
115
|
-
}
|
|
116
|
-
},
|
|
117
|
-
|
|
118
|
-
mounted () {
|
|
119
|
-
this.$watch('include', val => {
|
|
120
|
-
pruneCache(this, val)
|
|
121
|
-
})
|
|
122
|
-
this.$watch('exclude', val => {
|
|
123
|
-
pruneCache(this, val)
|
|
124
|
-
})
|
|
125
|
-
},
|
|
126
|
-
|
|
127
|
-
methods: {
|
|
128
|
-
allCache () {
|
|
129
|
-
return this.cache
|
|
130
|
-
},
|
|
131
|
-
clearCache (key) {
|
|
132
|
-
pruneCache(this, key)
|
|
133
|
-
this.$router.replace(this.$router.currentRoute)
|
|
134
|
-
}
|
|
135
|
-
},
|
|
136
|
-
|
|
137
|
-
render () {
|
|
138
|
-
this.$emit('ref', this)
|
|
139
|
-
const slot = this.$slots.default
|
|
140
|
-
const vnode = getFirstComponentChild(slot)
|
|
141
|
-
// const vnode = cloneVNode(defVNode, true)
|
|
142
|
-
const componentOptions = vnode && vnode.componentOptions
|
|
143
|
-
|
|
144
|
-
const key = getCurrentRouteKey(this.$route)
|
|
145
|
-
if (componentOptions) {
|
|
146
|
-
// check pattern
|
|
147
|
-
const { include, exclude } = this
|
|
148
|
-
if (
|
|
149
|
-
// not included
|
|
150
|
-
(include && (!key || !matches(include, key))) ||
|
|
151
|
-
// excluded
|
|
152
|
-
(exclude && key && matches(exclude, key))
|
|
153
|
-
) {
|
|
154
|
-
return vnode
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
const { cache, keys } = this
|
|
158
|
-
if (cache[key]) {
|
|
159
|
-
vnode.componentInstance = cache[key].componentInstance
|
|
160
|
-
// make current key freshest
|
|
161
|
-
remove(keys, key)
|
|
162
|
-
keys.push(key)
|
|
163
|
-
} else {
|
|
164
|
-
// vnode = cloneVNode(vnode, true)
|
|
165
|
-
|
|
166
|
-
cache[key] = vnode
|
|
167
|
-
keys.push(key)
|
|
168
|
-
// prune oldest entry
|
|
169
|
-
if (this.max && keys.length > parseInt(this.max)) {
|
|
170
|
-
pruneCacheEntry(cache, keys[0], keys, this._vnode)
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
vnode.data.keepAlive = true
|
|
174
|
-
}
|
|
175
|
-
return vnode || (slot && slot[0])
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
RouteKeepAlive.install = function (Vue) {
|
|
180
|
-
Vue.component(RouteKeepAlive.name, RouteKeepAlive)
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
export default RouteKeepAlive
|
package/lib/multiTab/events.js
DELETED
package/lib/multiTab/index.js
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import AppEvent from './events'
|
|
2
|
-
import RouteAPI from './RouteAPI'
|
|
3
|
-
import MultiTab from './MultiTab.jsx'
|
|
4
|
-
import * as APIEnums from './APIEnums'
|
|
5
|
-
import RouteKeepAlive from './RouteKeepAlive'
|
|
6
|
-
import RouteContent from './RouteContent.jsx'
|
|
7
|
-
|
|
8
|
-
export {
|
|
9
|
-
AppEvent,
|
|
10
|
-
RouteAPI,
|
|
11
|
-
MultiTab,
|
|
12
|
-
RouteKeepAlive,
|
|
13
|
-
APIEnums
|
|
14
|
-
}
|
|
15
|
-
export default RouteContent
|
package/lib/multiTab/index.less
DELETED
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
@import "~ant-design-vue/es/style/themes/default";
|
|
2
|
-
|
|
3
|
-
@multi-tab-prefix-cls: ~"ant-pro-multi-tab";
|
|
4
|
-
@multi-tab-wrapper-prefix-cls: ~"ant-pro-multi-tab-wrapper";
|
|
5
|
-
|
|
6
|
-
.@{multi-tab-prefix-cls} {
|
|
7
|
-
.ant-tabs-bar {
|
|
8
|
-
margin: 0;
|
|
9
|
-
border-bottom: none;
|
|
10
|
-
padding-left: @padding-md + 4px;
|
|
11
|
-
box-sizing: border-box;
|
|
12
|
-
background: @layout-header-background;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
.ant-tabs-extra-content .ant-btn {
|
|
16
|
-
border: none;
|
|
17
|
-
background: transparent;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
.ant-tabs.ant-tabs-card .ant-tabs-card-bar {
|
|
21
|
-
.ant-tabs-tab {
|
|
22
|
-
height: 26px;
|
|
23
|
-
line-height: 26px;
|
|
24
|
-
color: @input-placeholder-color;
|
|
25
|
-
border-radius: @border-radius-sm;
|
|
26
|
-
padding: 0 @padding-xs;
|
|
27
|
-
border: none;
|
|
28
|
-
background: transparent;
|
|
29
|
-
|
|
30
|
-
.ant-tabs-close-x {
|
|
31
|
-
margin-left: 14px;
|
|
32
|
-
color: @input-placeholder-color;
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
.ant-tabs-tab-active {
|
|
36
|
-
color: @primary-color;
|
|
37
|
-
background-color: @item-active-bg;
|
|
38
|
-
|
|
39
|
-
.ant-tabs-close-x {
|
|
40
|
-
color: @primary-color;
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
.ant-tabs-nav-container {
|
|
44
|
-
display: flex;
|
|
45
|
-
align-items: center;
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
.ant-tabs-nav .ant-tabs-tab .anticon {
|
|
50
|
-
margin-right: 4px;
|
|
51
|
-
&:last-child {
|
|
52
|
-
margin-right: 0;
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
.ant-pro-multi-tab-title {
|
|
57
|
-
user-select: none;
|
|
58
|
-
font-weight: 300;
|
|
59
|
-
font-size: @font-size-base;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
.ant-pro-multi-tab-icon {
|
|
63
|
-
height: @font-size-base;
|
|
64
|
-
overflow: hidden;
|
|
65
|
-
color: @text-color-secondary;
|
|
66
|
-
font-size: @font-size-sm;
|
|
67
|
-
vertical-align: middle;
|
|
68
|
-
transition: all 0.3s;
|
|
69
|
-
&:hover {
|
|
70
|
-
color: @heading-color;
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
}
|
package/lib/style/index.less
DELETED