iov-pro-components 0.0.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.
Files changed (133) hide show
  1. package/.eslintignore +5 -0
  2. package/.eslintrc.js +192 -0
  3. package/.gitignore +3 -0
  4. package/README.md +4 -0
  5. package/babel.config.js +5 -0
  6. package/docs/.vuepress/config.js +169 -0
  7. package/docs/.vuepress/styles/index.styl +62 -0
  8. package/docs/.vuepress/styles/palette.styl +20 -0
  9. package/docs/.vuepress/theme/enhanceApp.js +100 -0
  10. package/docs/.vuepress/theme/index.js +3 -0
  11. package/docs/README.md +13 -0
  12. package/docs/components/description.md +519 -0
  13. package/docs/components/dialog-select.md +91 -0
  14. package/docs/components/display.md +36 -0
  15. package/docs/components/enums.md +33 -0
  16. package/docs/components/icon.md +406 -0
  17. package/docs/components/link-group.md +39 -0
  18. package/docs/components/page-detail.md +48 -0
  19. package/docs/components/page-module.md +51 -0
  20. package/docs/components/pro-form.md +958 -0
  21. package/docs/components/pro-table.md +683 -0
  22. package/docs/components/request.md +44 -0
  23. package/docs/components/search-table.md +963 -0
  24. package/docs/components/space.md +35 -0
  25. package/docs/components/sub-title.md +24 -0
  26. package/docs/components/submit-module.md +24 -0
  27. package/docs/template/add.md +124 -0
  28. package/docs/template/confirm.md +28 -0
  29. package/docs/template/detail.md +240 -0
  30. package/docs/template/dialog.md +339 -0
  31. package/docs/template/list.md +464 -0
  32. package/docs/template/tabs-mini.md +32 -0
  33. package/docs/template/tabs.md +32 -0
  34. package/jsconfig.json +19 -0
  35. package/lib/iov-pro-components.css +1 -0
  36. package/lib/iov-pro-components.min.js +7 -0
  37. package/lib/postcss.config.js +8 -0
  38. package/package.json +75 -0
  39. package/patches/vue-server-renderer+2.7.16.patch +13 -0
  40. package/rollup.config.mjs +79 -0
  41. package/src/App.vue +103 -0
  42. package/src/main.js +33 -0
  43. package/src/packages/column-tooltip/index.js +7 -0
  44. package/src/packages/column-tooltip/src/main.vue +127 -0
  45. package/src/packages/description/index.js +7 -0
  46. package/src/packages/description/src/main.vue +375 -0
  47. package/src/packages/description/src/text.vue +103 -0
  48. package/src/packages/dialog-select/index.js +7 -0
  49. package/src/packages/dialog-select/src/main.vue +308 -0
  50. package/src/packages/display/index.js +7 -0
  51. package/src/packages/display/src/main.vue +44 -0
  52. package/src/packages/enums/index.js +7 -0
  53. package/src/packages/enums/src/main.vue +23 -0
  54. package/src/packages/export/index.js +7 -0
  55. package/src/packages/export/src/main.vue +316 -0
  56. package/src/packages/fixed-button-group/index.js +7 -0
  57. package/src/packages/fixed-button-group/src/main.vue +104 -0
  58. package/src/packages/form/index.js +7 -0
  59. package/src/packages/form/src/collapse.vue +149 -0
  60. package/src/packages/form/src/main.vue +1190 -0
  61. package/src/packages/form-collapse/index.js +7 -0
  62. package/src/packages/index.js +86 -0
  63. package/src/packages/link-group/index.js +7 -0
  64. package/src/packages/link-group/src/main.vue +52 -0
  65. package/src/packages/page-detail/index.js +7 -0
  66. package/src/packages/page-detail/src/main.vue +123 -0
  67. package/src/packages/page-module/index.js +7 -0
  68. package/src/packages/page-module/src/main.vue +56 -0
  69. package/src/packages/preview/index.js +7 -0
  70. package/src/packages/preview/src/eval-image-viewer.js +50 -0
  71. package/src/packages/preview/src/image-viewer.vue +366 -0
  72. package/src/packages/preview/src/main.vue +97 -0
  73. package/src/packages/request/index.js +7 -0
  74. package/src/packages/request/src/main.vue +125 -0
  75. package/src/packages/search-table/index.js +7 -0
  76. package/src/packages/search-table/src/inner-tabs.vue +237 -0
  77. package/src/packages/search-table/src/main.vue +472 -0
  78. package/src/packages/search-table/src/outer-tabs.vue +45 -0
  79. package/src/packages/search-table-inner-tabs/index.js +7 -0
  80. package/src/packages/search-table-outer-tabs/index.js +7 -0
  81. package/src/packages/space/index.js +7 -0
  82. package/src/packages/space/src/main.vue +74 -0
  83. package/src/packages/sub-title/index.js +7 -0
  84. package/src/packages/sub-title/src/main.vue +70 -0
  85. package/src/packages/submit-module/index.js +7 -0
  86. package/src/packages/submit-module/src/main.vue +67 -0
  87. package/src/packages/table/index.js +7 -0
  88. package/src/packages/table/src/filter.vue +89 -0
  89. package/src/packages/table/src/main.vue +668 -0
  90. package/src/packages/table/src/search.vue +90 -0
  91. package/src/packages/table/src/sort.vue +118 -0
  92. package/src/packages/theme/index.scss +15 -0
  93. package/src/packages/theme/src/column-tooltip.scss +23 -0
  94. package/src/packages/theme/src/common/color.scss +134 -0
  95. package/src/packages/theme/src/description.scss +56 -0
  96. package/src/packages/theme/src/dialog-select.scss +32 -0
  97. package/src/packages/theme/src/fixed-button-group.scss +25 -0
  98. package/src/packages/theme/src/form.scss +11 -0
  99. package/src/packages/theme/src/link-group.scss +43 -0
  100. package/src/packages/theme/src/page-detail.scss +61 -0
  101. package/src/packages/theme/src/page-module.scss +46 -0
  102. package/src/packages/theme/src/preview.scss +67 -0
  103. package/src/packages/theme/src/search-table.scss +185 -0
  104. package/src/packages/theme/src/space.scss +12 -0
  105. package/src/packages/theme/src/sub-title.scss +47 -0
  106. package/src/packages/theme/src/submit-module.scss +13 -0
  107. package/src/packages/theme/src/table.scss +129 -0
  108. package/src/packages/theme/src/toolbar.scss +109 -0
  109. package/src/packages/toolbar/index.js +7 -0
  110. package/src/packages/toolbar/src/main.vue +126 -0
  111. package/src/packages/toolbar/src/setting.vue +217 -0
  112. package/src/packages/toolbar/src/style.vue +68 -0
  113. package/src/packages/toolbar/src/zoom.vue +65 -0
  114. package/src/router.js +83 -0
  115. package/src/utils/config-center.js +218 -0
  116. package/src/utils/function-eval.js +84 -0
  117. package/src/utils/index.js +104 -0
  118. package/src/views/column-tooltip.vue +37 -0
  119. package/src/views/components/OtherSelect.vue +18 -0
  120. package/src/views/description.vue +60 -0
  121. package/src/views/detail.vue +146 -0
  122. package/src/views/directive/number.js +82 -0
  123. package/src/views/enums.vue +22 -0
  124. package/src/views/export.vue +9 -0
  125. package/src/views/form-collapse.vue +185 -0
  126. package/src/views/form.vue +402 -0
  127. package/src/views/link-group.vue +16 -0
  128. package/src/views/preview.vue +33 -0
  129. package/src/views/request.vue +56 -0
  130. package/src/views/search-table.vue +297 -0
  131. package/src/views/table.vue +145 -0
  132. package/src/views/toolbar.vue +30 -0
  133. package/vue.config.js +22 -0
package/.eslintignore ADDED
@@ -0,0 +1,5 @@
1
+ dist
2
+ docs
3
+ lib
4
+ public
5
+ script
package/.eslintrc.js ADDED
@@ -0,0 +1,192 @@
1
+ module.exports = {
2
+ root: true,
3
+ parserOptions: {
4
+ parser: 'babel-eslint',
5
+ sourceType: 'module'
6
+ },
7
+ env: {
8
+ browser: true,
9
+ node: true,
10
+ es6: true,
11
+ },
12
+ extends: ['plugin:vue/recommended', 'eslint:recommended'],
13
+
14
+ // add your custom rules here
15
+ //it is base on https://github.com/vuejs/eslint-config-vue
16
+ rules: {
17
+ "vue/singleline-html-element-content-newline": "off",
18
+ "vue/multiline-html-element-content-newline":"off",
19
+ "vue/name-property-casing": ["error", "PascalCase"],
20
+ "vue/no-v-html": "off",
21
+ 'accessor-pairs': 2,
22
+ 'arrow-spacing': [2, {
23
+ 'before': true,
24
+ 'after': true
25
+ }],
26
+ 'block-spacing': [2, 'always'],
27
+ 'brace-style': [2, '1tbs', {
28
+ 'allowSingleLine': true
29
+ }],
30
+ 'camelcase': [0, {
31
+ 'properties': 'always'
32
+ }],
33
+ 'comma-dangle': [2, 'never'],
34
+ 'comma-spacing': [2, {
35
+ 'before': false,
36
+ 'after': true
37
+ }],
38
+ 'comma-style': [2, 'last'],
39
+ 'constructor-super': 2,
40
+ 'curly': [2, 'multi-line'],
41
+ 'dot-location': [2, 'property'],
42
+ 'eol-last': 2,
43
+ 'eqeqeq': ["error", "always", {"null": "ignore"}],
44
+ 'generator-star-spacing': [2, {
45
+ 'before': true,
46
+ 'after': true
47
+ }],
48
+ 'handle-callback-err': [2, '^(err|error)$'],
49
+ 'indent': [2, 2, {
50
+ 'SwitchCase': 1
51
+ }],
52
+ 'jsx-quotes': [2, 'prefer-single'],
53
+ 'key-spacing': [2, {
54
+ 'beforeColon': false,
55
+ 'afterColon': true
56
+ }],
57
+ 'keyword-spacing': [2, {
58
+ 'before': true,
59
+ 'after': true
60
+ }],
61
+ 'new-cap': [2, {
62
+ 'newIsCap': true,
63
+ 'capIsNew': false
64
+ }],
65
+ 'new-parens': 2,
66
+ 'no-array-constructor': 2,
67
+ 'no-caller': 2,
68
+ 'no-console': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
69
+ 'no-class-assign': 2,
70
+ 'no-cond-assign': 2,
71
+ 'no-const-assign': 2,
72
+ 'no-control-regex': 0,
73
+ 'no-delete-var': 2,
74
+ 'no-dupe-args': 2,
75
+ 'no-dupe-class-members': 2,
76
+ 'no-dupe-keys': 2,
77
+ 'no-duplicate-case': 2,
78
+ 'no-empty-character-class': 2,
79
+ 'no-empty-pattern': 2,
80
+ 'no-eval': 2,
81
+ 'no-ex-assign': 2,
82
+ 'no-extend-native': 2,
83
+ 'no-extra-bind': 2,
84
+ 'no-extra-boolean-cast': 2,
85
+ 'no-extra-parens': [2, 'functions'],
86
+ 'no-fallthrough': 2,
87
+ 'no-floating-decimal': 2,
88
+ 'no-func-assign': 2,
89
+ 'no-implied-eval': 2,
90
+ 'no-inner-declarations': [2, 'functions'],
91
+ 'no-invalid-regexp': 2,
92
+ 'no-irregular-whitespace': 2,
93
+ 'no-iterator': 2,
94
+ 'no-label-var': 2,
95
+ 'no-labels': [2, {
96
+ 'allowLoop': false,
97
+ 'allowSwitch': false
98
+ }],
99
+ 'no-lone-blocks': 2,
100
+ 'no-mixed-spaces-and-tabs': 2,
101
+ 'no-multi-spaces': 2,
102
+ 'no-multi-str': 2,
103
+ 'no-multiple-empty-lines': [2, {
104
+ 'max': 1
105
+ }],
106
+ 'no-native-reassign': 2,
107
+ 'no-negated-in-lhs': 2,
108
+ 'no-new-object': 2,
109
+ 'no-new-require': 2,
110
+ 'no-new-symbol': 2,
111
+ 'no-new-wrappers': 2,
112
+ 'no-obj-calls': 2,
113
+ 'no-octal': 2,
114
+ 'no-octal-escape': 2,
115
+ 'no-path-concat': 2,
116
+ 'no-proto': 2,
117
+ 'no-redeclare': 2,
118
+ 'no-regex-spaces': 2,
119
+ 'no-return-assign': [2, 'except-parens'],
120
+ 'no-self-assign': 2,
121
+ 'no-self-compare': 2,
122
+ 'no-sequences': 2,
123
+ 'no-shadow-restricted-names': 2,
124
+ 'no-spaced-func': 2,
125
+ 'no-sparse-arrays': 2,
126
+ 'no-this-before-super': 2,
127
+ 'no-throw-literal': 2,
128
+ 'no-trailing-spaces': 2,
129
+ 'no-undef': 2,
130
+ 'no-undef-init': 2,
131
+ 'no-unexpected-multiline': 2,
132
+ 'no-unmodified-loop-condition': 2,
133
+ 'no-unneeded-ternary': [2, {
134
+ 'defaultAssignment': false
135
+ }],
136
+ 'no-unreachable': 2,
137
+ 'no-unsafe-finally': 2,
138
+ 'no-unused-vars': [2, {
139
+ 'vars': 'all',
140
+ 'args': 'none'
141
+ }],
142
+ 'no-useless-call': 2,
143
+ 'no-useless-computed-key': 2,
144
+ 'no-useless-constructor': 2,
145
+ 'no-useless-escape': 0,
146
+ 'no-whitespace-before-property': 2,
147
+ 'no-with': 2,
148
+ 'one-var': [2, {
149
+ 'initialized': 'never'
150
+ }],
151
+ 'operator-linebreak': [2, 'after', {
152
+ 'overrides': {
153
+ '?': 'before',
154
+ ':': 'before'
155
+ }
156
+ }],
157
+ 'padded-blocks': [2, 'never'],
158
+ 'quotes': [2, 'single', {
159
+ 'avoidEscape': true,
160
+ 'allowTemplateLiterals': true
161
+ }],
162
+ 'semi': [2, 'never'],
163
+ 'semi-spacing': [2, {
164
+ 'before': false,
165
+ 'after': true
166
+ }],
167
+ 'space-before-blocks': [2, 'always'],
168
+ 'space-before-function-paren': [2, 'never'],
169
+ 'space-in-parens': [2, 'never'],
170
+ 'space-infix-ops': 2,
171
+ 'space-unary-ops': [2, {
172
+ 'words': true,
173
+ 'nonwords': false
174
+ }],
175
+ 'spaced-comment': [2, 'always', {
176
+ 'markers': ['global', 'globals', 'eslint', 'eslint-disable', '*package', '!', ',']
177
+ }],
178
+ 'template-curly-spacing': [2, 'never'],
179
+ 'use-isnan': 2,
180
+ 'valid-typeof': 2,
181
+ 'wrap-iife': [2, 'any'],
182
+ 'yield-star-spacing': [2, 'both'],
183
+ 'yoda': [2, 'never'],
184
+ 'prefer-const': 2,
185
+ 'no-debugger': process.env.NODE_ENV === 'production' ? 2 : 0,
186
+ 'object-curly-spacing': [2, 'always', {
187
+ objectsInObjects: false
188
+ }],
189
+ 'array-bracket-spacing': [2, 'never'],
190
+ "max-len": [0, 180, 4],//字符串最大长度
191
+ }
192
+ }
package/.gitignore ADDED
@@ -0,0 +1,3 @@
1
+ node_modules
2
+ package-lock.json
3
+ dist/*
package/README.md ADDED
@@ -0,0 +1,4 @@
1
+ # Iov Pro Components
2
+
3
+ 基于`Iov Design`的`Pro`级组件库
4
+
@@ -0,0 +1,5 @@
1
+ module.exports = {
2
+ presets: [
3
+ '@vue/cli-plugin-babel/preset'
4
+ ]
5
+ }
@@ -0,0 +1,169 @@
1
+ const path = require('path')
2
+
3
+ module.exports = {
4
+ base: '/iov-pro-components/',
5
+ title: 'IOV Pro Components',
6
+ dest: path.resolve(__dirname, '../../dist'),
7
+ description: '基于IOV Design的前端组件库',
8
+ configureWebpack: {
9
+ resolve: {
10
+ alias: {
11
+ '@': path.join(__dirname, '../../src')
12
+ }
13
+ }
14
+ },
15
+ chainWebpack: (config) => {
16
+ config.resolve.alias
17
+ .set('core-js/library/fn', 'core-js/features')
18
+ },
19
+ plugins: ['demo-container'],
20
+ themeConfig: {
21
+ // 顶部导航
22
+ nav: [
23
+ { text: '首页', link: '/' },
24
+ { text: '组件', link: '/components/icon' },
25
+ { text: '模板', link: '/template/list' },
26
+ { text: 'GitLab', link: 'http://172.23.105.167/cusc-fe/iov-pro-components.git' }
27
+ ],
28
+ // 侧边栏配置
29
+ sidebar: {
30
+ '/components/': [
31
+ {
32
+ title: '基础',
33
+ redirect: '/components/icon',
34
+ collapsable: false,
35
+ sidebarDepth: 0,
36
+ children: [
37
+ {
38
+ title: '图标 Icon',
39
+ path: '/components/icon'
40
+ }
41
+ ]
42
+ },
43
+ {
44
+ title: '列表',
45
+ redirect: '/components/pro-form',
46
+ collapsable: false,
47
+ sidebarDepth: 0,
48
+ children: [
49
+ {
50
+ title: '表单 ProForm',
51
+ path: '/components/pro-form'
52
+ },
53
+ {
54
+ title: '表格 ProTable',
55
+ path: '/components/pro-table'
56
+ },
57
+ {
58
+ title: '搜索表单 SearchTable',
59
+ path: '/components/search-table'
60
+ },
61
+ {
62
+ title: '表格按钮组 LinkGroup',
63
+ path: '/components/link-group'
64
+ }
65
+ ]
66
+ },
67
+ {
68
+ title: '详情',
69
+ redirect: '/components/page-detail',
70
+ collapsable: false,
71
+ sidebarDepth: 0,
72
+ children: [
73
+ {
74
+ title: '页面详情 PageDetail',
75
+ path: '/components/page-detail'
76
+ },
77
+ {
78
+ title: '页面模块 PageModule',
79
+ path: '/components/page-module'
80
+ },
81
+ {
82
+ title: '小标题 SubTitle',
83
+ path: '/components/sub-title'
84
+ },
85
+ {
86
+ title: '提交按钮模块 SubmitModule',
87
+ path: '/components/submit-module'
88
+ },
89
+ {
90
+ title: '描述 Description',
91
+ path: '/components/description'
92
+ },
93
+ {
94
+ title: '弹窗搜索 DialogSelect',
95
+ path: '/components/dialog-select'
96
+ }
97
+ ]
98
+ },
99
+ {
100
+ title: '工具',
101
+ redirect: '/components/request',
102
+ collapsable: false,
103
+ sidebarDepth: 0,
104
+ children: [
105
+ {
106
+ title: '接口请求 Request',
107
+ path: '/components/request'
108
+ },
109
+ {
110
+ title: '间隔 Space',
111
+ path: '/components/space'
112
+ },
113
+ {
114
+ title: '显示 Display',
115
+ path: '/components/display'
116
+ },
117
+ {
118
+ title: '枚举 Enums',
119
+ path: '/components/enums'
120
+ }
121
+ ]
122
+ }
123
+ ],
124
+ '/template/': [
125
+ {
126
+ title: '模板',
127
+ redirect: '/template/list',
128
+ collapsable: false,
129
+ sidebarDepth: 0,
130
+ children: [
131
+ {
132
+ title: '列表页',
133
+ path: '/template/list'
134
+ },
135
+ {
136
+ title: '新增页',
137
+ path: '/template/add'
138
+ },
139
+ {
140
+ title: '详情页',
141
+ path: '/template/detail'
142
+ },
143
+ {
144
+ title: '弹窗',
145
+ path: '/template/dialog'
146
+ },
147
+ {
148
+ title: '确认框',
149
+ path: '/template/confirm'
150
+ },
151
+ {
152
+ title: '标签页',
153
+ path: '/template/tabs'
154
+ },
155
+ {
156
+ title: 'mini标签页',
157
+ path: '/template/tabs-mini'
158
+ }
159
+ ]
160
+ }
161
+ ]
162
+ }
163
+ },
164
+ locales: {
165
+ '/': {
166
+ lang: 'zh-CN'
167
+ }
168
+ }
169
+ }
@@ -0,0 +1,62 @@
1
+ table {
2
+ margin: 0;
3
+ }
4
+ [class*=" iov-icon-"], [class^=iov-icon-] {
5
+ line-height: 1.5;
6
+ }
7
+ a.sidebar-link {
8
+ line-height: 28px !important;
9
+ }
10
+ h1 {
11
+ font-size: 28px;
12
+ font-weight: 400;
13
+ margin-bottom: 0 !important;
14
+ }
15
+ h2 {
16
+ border-bottom: 0;
17
+ font-size: 22px;
18
+ font-weight: 400;
19
+ padding-top: 4.1rem;
20
+ }
21
+ p {
22
+ font-size: 14px;
23
+ }
24
+ th, td {
25
+ border-top: 0;
26
+ border: 0;
27
+ }
28
+ .caret-bottom.icon {
29
+ height: 44px;
30
+ &:before {
31
+ top: 50%;
32
+ transform: translateY(-50%);
33
+ }
34
+ }
35
+ div.search-box {
36
+ margin-right: 3rem;
37
+ }
38
+ .copy-action, .demo-block-control {
39
+ background-color: #ffffff !important;
40
+ border-top: none !important;
41
+ color: #494b53 !important;
42
+ }
43
+ .demo-block-control .caret-bottom:before {
44
+ border-top-color: #494b53 !important;
45
+ opacity: 0.8;
46
+ }
47
+ .demo-block .meta {
48
+ border-top: 1px solid #ebebeb;
49
+ }
50
+ .demo-block-control:hover {
51
+ background-color: #f9fafc !important;
52
+ }
53
+ .demo-block-control:hover .copy-action, .demo-block-control:hover {
54
+ color: #2A68FF !important;
55
+ }
56
+ .demo-block-control:hover .caret-bottom:before {
57
+ border-top-color: #2A68FF !important;
58
+ }
59
+ .theme-container.grey-background-demo-content .demo-content {
60
+ background-color: #FAFAFA;
61
+ padding: 0 !important;
62
+ }
@@ -0,0 +1,20 @@
1
+ // 颜色
2
+ $accentColor = #2A68FF
3
+ $textColor = #2c3e50
4
+ $borderColor = #eaecef
5
+ $codeBgColor = #282c34
6
+ $arrowBgColor = #ccc
7
+ $badgeTipColor = #42b983
8
+ $badgeWarningColor = darken(#ffe564, 35%)
9
+ $badgeErrorColor = #DA5961
10
+
11
+ // 布局
12
+ $navbarHeight = 4.6rem
13
+ $sidebarWidth = 20rem
14
+ $contentWidth = 960px
15
+ $homePageWidth = 960px
16
+
17
+ // 响应式变化点
18
+ $MQNarrow = 959px
19
+ $MQMobile = 719px
20
+ $MQMobileNarrow = 419px
@@ -0,0 +1,100 @@
1
+ import ElementUI from 'iov-design'
2
+ import IovProComponents from '../../../src/packages'
3
+
4
+ import 'iov-design/lib/theme-chalk/index.css'
5
+
6
+ function checkNumber(el, binding, vnode) {
7
+ const decimals = !isNaN(binding.value) ? binding.value : 2 // 默认小数位数为 2
8
+
9
+ // 构建正则表达式,支持 0 和空值,不允许以 '.' 开头,也不允许多个零开头
10
+ const regex = new RegExp(`^(?!\\.)[0-9]*(\\.\\d{0,${decimals}})?$|^$`)
11
+
12
+ // 获取 el-input 内部的 input 元素
13
+ const input = el.tagName === 'INPUT' ? el : el.querySelector('input')
14
+ if (input) {
15
+ let previousValue = '' // 记录上次合法的值
16
+
17
+ input.addEventListener('input', (event) => {
18
+ let currentValue = input.value
19
+
20
+ // 使用 slice 去除多余的零
21
+ if (/^0[0-9]/.test(currentValue)) {
22
+ currentValue = currentValue.slice(0, 1) // 保留一个零,移除其他零
23
+ }
24
+
25
+ // 防止以小数点开头,例如 ".123" -> "0.123"
26
+ if (/^\./.test(currentValue)) {
27
+ currentValue = '0' + currentValue // 补全为 "0.123"
28
+ }
29
+
30
+ if (+decimals === 0 && /^\d+\.$/.test(currentValue)) {
31
+ currentValue = currentValue.slice(0, -1)
32
+ }
33
+
34
+ // 如果当前值合法,保存为上次合法值
35
+ if (regex.test(currentValue)) {
36
+ previousValue = currentValue
37
+ input.value = previousValue
38
+ } else {
39
+ // 如果不合法,恢复到上次合法值
40
+ const cursorPosition = input.selectionStart - 1 // 获取光标位置
41
+ input.value = previousValue // 恢复到合法值
42
+
43
+ // 修复光标位置
44
+ input.setSelectionRange(cursorPosition, cursorPosition)
45
+
46
+ // 手动触发 input 事件以更新 v-model
47
+ const event = new Event('input', { bubbles: true })
48
+ input.dispatchEvent(event)
49
+ }
50
+ })
51
+ input.addEventListener('blur', () => {
52
+ // 当前输入的值
53
+ const currentValue = input.value
54
+ // 如果当前输入的值以.结尾
55
+ if (/\.$/.test(currentValue)) {
56
+ previousValue = currentValue.slice(0, currentValue.length - 1)
57
+ input.value = previousValue
58
+ // 手动触发 input 事件以更新 v-model
59
+ const event = new Event('input', { bubbles: true })
60
+ input.dispatchEvent(event)
61
+ }
62
+ })
63
+ }
64
+ }
65
+
66
+ export default ({
67
+ Vue, // VuePress 正在使用的 Vue 构造函数
68
+ options, // 附加到根实例的一些选项
69
+ router, // 当前应用的路由实例
70
+ siteData // 站点元数据
71
+ }) => {
72
+ // 注册全局组件
73
+ Vue.use(ElementUI)
74
+ Vue.use(IovProComponents, {
75
+ preview: {
76
+ request: (params) => {
77
+ return new Promise((resolve) => {
78
+ setTimeout(() => {
79
+ resolve('https://prod-common-public.obs-helf.cucloud.cn/mall/goods/893f1000000000114669556')
80
+ }, 1000)
81
+ })
82
+ },
83
+ cacheTime: 60000
84
+ }
85
+ })
86
+
87
+ // 注册自定义指令
88
+ Vue.directive('number', {
89
+ bind(el, binding, vnode) {
90
+ checkNumber(el, binding, vnode)
91
+ },
92
+ unbind(el) {
93
+ const input = el.tagName === 'INPUT' ? el : el.querySelector('input')
94
+ if (input) {
95
+ input.removeEventListener('input', () => {})
96
+ input.removeEventListener('blur', () => {})
97
+ }
98
+ }
99
+ })
100
+ }
@@ -0,0 +1,3 @@
1
+ module.exports = {
2
+ extend: '@vuepress/theme-default'
3
+ }
package/docs/README.md ADDED
@@ -0,0 +1,13 @@
1
+ ---
2
+ home: true
3
+ heroText: IOV Pro Components
4
+ tagline: 基于IOV Design的高级组件库
5
+ actionText: 快速上手 →
6
+ actionLink: /components/pro-form
7
+ features:
8
+ - title: 简洁至上
9
+ details: 以 Schema配置 为中心的项目结构,以最少的代码帮助你日常开发。
10
+ - title: Vue2驱动
11
+ details: 享受 Vue + webpack 的开发体验。
12
+ footer: Copyright©2018 联通智网科技版权所有 京ICP备16005440号-1
13
+ ---