t20-common-lib 0.2.1 → 0.2.3

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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "t20-common-lib",
3
- "version": "0.2.1",
3
+ "version": "0.2.3",
4
4
  "description": "T20",
5
5
  "private": false,
6
6
  "main": "dist/index.js",
@@ -0,0 +1,8 @@
1
+ import MainPage from './src/main';
2
+
3
+ /* istanbul ignore next */
4
+ MainPage.install = function(Vue) {
5
+ Vue.component(MainPage.name, MainPage);
6
+ };
7
+
8
+ export default MainPage;
@@ -0,0 +1,34 @@
1
+ <template>
2
+ <div class="flex-column">
3
+ <div v-if="$slots.header" class="header">
4
+ <slot name="header"></slot>
5
+ </div>
6
+ <div v-if="$slots.card || $slots.tab" style="position: relative;">
7
+ <slot name="card"></slot>
8
+ <div class="tab" v-if="$slots.tab">
9
+ <slot name="tab"></slot>
10
+ </div>
11
+ </div>
12
+ <div class="bg-white flex-1 overflow">
13
+ <slot></slot>
14
+ </div>
15
+ </div>
16
+ </template>
17
+
18
+ <script>
19
+ export default {
20
+ name: 'MainPage'
21
+ }
22
+ </script>
23
+
24
+ <style lang="scss" scoped>
25
+ .tab {
26
+ position: absolute;
27
+ bottom: -34px;
28
+ }
29
+
30
+ .header {
31
+ height: 32px;
32
+ line-height: 32px;
33
+ }
34
+ </style>
@@ -0,0 +1,8 @@
1
+ import TabPane from './src/main';
2
+
3
+ /* istanbul ignore next */
4
+ TabPane.install = function(Vue) {
5
+ Vue.component(TabPane.name, TabPane);
6
+ };
7
+
8
+ export default TabPane;
@@ -0,0 +1,128 @@
1
+ <template>
2
+ <div v-if="data.length === 0" class="n20-secondary-tab m-b-s">
3
+ <div class="el-tabs__item is-active" style="padding: 0;">{{ init }}</div>
4
+ </div>
5
+ <div v-else-if="data.length === 1" class="n20-secondary-tab m-b-s">
6
+ <div class="el-tabs__item is-active" style="padding: 0;">
7
+ <span v-if="data[0].icon" :class="data[0].icon"></span>
8
+ <sup v-if="data[0].badge" class="el-tabs__item-badge"></sup>
9
+ {{ data[0].name }}
10
+ </div>
11
+ </div>
12
+ <el-tabs v-else :value="init" :class="classes" :tabPosition="tabPosition" :before-leave="beforeFn" @tab-click="clickFn">
13
+ <el-tab-pane
14
+ v-for="item of data"
15
+ :key="item.name"
16
+ :tab-info="item"
17
+ :name="item.name"
18
+ :icon="item.icon"
19
+ :disabled="item.disabled"
20
+ >
21
+ <template slot="label">
22
+ <span v-if="item.icon" :class="item.icon"></span>
23
+ <sup v-if="item.badge" class="el-tabs__item-badge"></sup>
24
+ <span v-if="item.content" v-title="`${item.content}`"> {{ item.name }}</span>
25
+ <span v-else>{{ item.name }}</span>
26
+ <i
27
+ v-if="item.tips"
28
+ v-title="item.tips"
29
+ class="n20-icon-xinxitishi"
30
+ style="color: var(--color-text-secondary); align-self: flex-start;"
31
+ ></i>
32
+ </template>
33
+ </el-tab-pane>
34
+ </el-tabs>
35
+ </template>
36
+
37
+ <script>
38
+
39
+ export default {
40
+ name: 'TabPane',
41
+ props: {
42
+ data: {
43
+ type: Array,
44
+ default: () => []
45
+ },
46
+ init: {
47
+ type: String,
48
+ default: ''
49
+ },
50
+ stop: {
51
+ type: Boolean,
52
+ default: false
53
+ },
54
+ tabPosition: {
55
+ type: String,
56
+ default: 'top'
57
+ }
58
+ },
59
+ computed: {
60
+ classes(){
61
+ return {
62
+ 'n20-secondary-tab': true,
63
+ 'm-b-s': this.tabPosition == 'top',
64
+ 'left-css': this.tabPosition == 'left'
65
+ }
66
+ }
67
+ },
68
+ methods: {
69
+ getTooltip(name, tips) {
70
+ return `<el-tooltip content="${tips}">${name}</el-tooltip>`
71
+ },
72
+ clickFn(C) {
73
+ let item = C.$attrs['tab-info']
74
+ if (this.$listeners['update:init']) {
75
+ !item.disabled && this.$emit('update:init', item.name)
76
+ }
77
+ if (this.$listeners['click']) {
78
+ this.$emit('click', item)
79
+ }
80
+ },
81
+ beforeFn(name) {
82
+ return !this.stop
83
+ }
84
+ }
85
+ }
86
+ </script>
87
+
88
+ <style>
89
+ .tooltip {
90
+ position: absolute;
91
+ top: 100%;
92
+ left: 0;
93
+ z-index: 9999;
94
+ background-color: black;
95
+ color: white;
96
+ padding: 5px;
97
+ font-size: 12px;
98
+ opacity: 0;
99
+ transition: opacity 0.3s;
100
+ }
101
+
102
+ .tooltip::after {
103
+ content: '';
104
+ position: absolute;
105
+ top: -5px;
106
+ left: 50%;
107
+ transform: translateX(-50%);
108
+ border: 5px solid transparent;
109
+ border-bottom-color: black;
110
+ }
111
+
112
+ .tooltip.show {
113
+ opacity: 1;
114
+ }
115
+ .left-css .el-tabs__item.is-active:after{
116
+ width: 2px;
117
+ height: 20px!important;
118
+ margin-top: -22px!important;
119
+ margin-left: -10px;
120
+ }
121
+ .left-css .el-tabs__item.is-left {
122
+ text-align: left!important;
123
+ }
124
+ .left-css .el-tabs__header.is-left{
125
+ margin-right: 0!important;
126
+ margin-left: 10px!important;
127
+ }
128
+ </style>
package/src/index.js CHANGED
@@ -3,10 +3,12 @@ import fitlers from './filters/index'
3
3
  import repairEl from './utils/repairElementUI'
4
4
  // 导入组件
5
5
  import MyButton from '../packages/mybutton/index.js'
6
+ import MainPage from '../packages/main-page/index.js'
6
7
 
7
8
  // 存储组件列表
8
9
  const components = [
9
- MyButton
10
+ MyButton,
11
+ MainPage
10
12
  ]
11
13
 
12
14
  // 定义 install 方法,接收 Vue 作为参数
@@ -36,5 +38,6 @@ export default {
36
38
  export {
37
39
  // 以下是具体的组件列表
38
40
  MyButton,
41
+ MainPage,
39
42
  repairEl
40
43
  }