t20-common-lib 0.2.0 → 0.2.1

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,13 +1,14 @@
1
1
  {
2
2
  "name": "t20-common-lib",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "T20",
5
5
  "private": false,
6
6
  "main": "dist/index.js",
7
7
  "module": "src/index.js",
8
8
  "style": "dist/styles/index.css",
9
9
  "files": [
10
- "src"
10
+ "src",
11
+ "packages"
11
12
  ],
12
13
  "scripts": {
13
14
  "serve": "vue-cli-service serve",
@@ -0,0 +1,8 @@
1
+ import MyButton from './src/main';
2
+
3
+ /* istanbul ignore next */
4
+ MyButton.install = function(Vue) {
5
+ Vue.component(MyButton.name, MyButton);
6
+ };
7
+
8
+ export default MyButton;
@@ -0,0 +1,62 @@
1
+ <template>
2
+ <el-button
3
+ :size="size"
4
+ :type="type"
5
+ :icon="icon"
6
+ :loading="loading"
7
+ :disabled="disabled || !hasPermission"
8
+ :round="round"
9
+ :circle="circle"
10
+ @click="handleClick"
11
+ v-bind="$attrs"
12
+ v-on="$listeners"
13
+ >
14
+ <slot></slot>
15
+ </el-button>
16
+ </template>
17
+
18
+ <script>
19
+ export default {
20
+ name: 'MyButton',
21
+ props: {
22
+ size: {
23
+ type: String,
24
+ default: 'medium',
25
+ validator: val => ['mini', 'small', 'medium', 'large'].includes(val)
26
+ },
27
+ type: {
28
+ type: String,
29
+ default: 'default',
30
+ validator: val => ['primary', 'success', 'warning', 'danger', 'info', 'text', 'default'].includes(val)
31
+ },
32
+ icon: String,
33
+ loading: Boolean,
34
+ disabled: Boolean,
35
+ round: Boolean,
36
+ circle: Boolean,
37
+ permission: String
38
+ },
39
+ computed: {
40
+ hasPermission() {
41
+ if (!this.permission) return true
42
+ // 实际项目中替换为真实的权限判断逻辑
43
+ return true
44
+ }
45
+ },
46
+ methods: {
47
+ handleClick(e) {
48
+ this.$emit('click', e)
49
+ }
50
+ }
51
+ }
52
+ </script>
53
+
54
+ <style scoped lang="scss">
55
+ ::v-deep .el-button {
56
+ margin-right: 8px;
57
+
58
+ &:last-child {
59
+ margin-right: 0;
60
+ }
61
+ }
62
+ </style>