@haluo/util 2.0.0 → 2.0.2-0.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/README.md +12 -1
- package/dist/index.d.ts +39 -0
- package/dist/index.js +74 -33
- package/dist/modules/cookie/index.d.ts +27 -0
- package/dist/modules/cookie/index.js +55 -54
- package/dist/modules/date/index.d.ts +52 -0
- package/dist/modules/date/index.js +192 -192
- package/dist/modules/dom/index.d.ts +28 -0
- package/dist/modules/dom/index.js +62 -62
- package/dist/modules/filter/index.d.ts +24 -0
- package/dist/modules/filter/index.js +48 -44
- package/dist/modules/format/index.d.ts +15 -0
- package/dist/modules/format/index.js +22 -21
- package/dist/modules/match/index.d.ts +12 -0
- package/dist/modules/match/index.js +31 -31
- package/dist/modules/monitor/index.d.ts +3 -0
- package/dist/modules/monitor/index.js +17 -17
- package/dist/modules/monitor/lib/jsError.d.ts +1 -0
- package/dist/modules/monitor/lib/jsError.js +53 -53
- package/dist/modules/monitor/lib/timing.d.ts +1 -0
- package/dist/modules/monitor/lib/timing.js +69 -69
- package/dist/modules/monitor/lib/xhr.d.ts +1 -0
- package/dist/modules/monitor/lib/xhr.js +48 -48
- package/dist/modules/monitor/utils/onload.d.ts +1 -0
- package/dist/modules/monitor/utils/onload.js +11 -11
- package/dist/modules/monitor/utils/tracker.d.ts +7 -0
- package/dist/modules/monitor/utils/tracker.js +63 -63
- package/dist/modules/number/index.d.ts +47 -0
- package/dist/modules/number/index.js +118 -102
- package/dist/modules/open-app/index.d.ts +84 -0
- package/dist/modules/open-app/index.js +239 -0
- package/dist/modules/sentry/index.d.ts +15 -0
- package/dist/modules/sentry/index.js +81 -81
- package/dist/modules/tools/index.d.ts +166 -0
- package/dist/modules/tools/index.js +393 -393
- package/dist/modules/upload/ALIOSS_EXAMPLE.d.ts +12 -0
- package/dist/modules/upload/ALIOSS_EXAMPLE.js +320 -0
- package/dist/modules/upload/aliOss.d.ts +324 -0
- package/dist/modules/upload/aliOss.js +838 -0
- package/dist/modules/upload/index.d.ts +51 -0
- package/dist/modules/upload/index.js +55 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/dist/types/index.d.ts +3 -0
- package/dist/types/index.js +2 -0
- package/dist/types/modules/cookie/index.d.ts +27 -0
- package/dist/types/modules/date/index.d.ts +52 -0
- package/dist/types/modules/dom/index.d.ts +28 -0
- package/dist/types/modules/filter/index.d.ts +24 -0
- package/dist/types/modules/format/index.d.ts +15 -0
- package/dist/types/modules/match/index.d.ts +12 -0
- package/dist/types/modules/monitor/index.d.ts +3 -0
- package/dist/types/modules/monitor/lib/jsError.d.ts +1 -0
- package/dist/types/modules/monitor/lib/timing.d.ts +1 -0
- package/dist/types/modules/monitor/lib/xhr.d.ts +1 -0
- package/dist/types/modules/monitor/utils/onload.d.ts +1 -0
- package/dist/types/modules/monitor/utils/tracker.d.ts +7 -0
- package/dist/types/modules/number/index.d.ts +41 -0
- package/dist/types/modules/sentry/index.d.ts +15 -0
- package/dist/types/modules/tools/index.d.ts +166 -0
- package/dist/types/types/index.d.ts +3 -0
- package/package.json +18 -13
- package/.babelrc +0 -21
- package/.eslintrc.js +0 -216
- package/__tests__/unit/date/date.spec.js +0 -14
- package/__tests__/unit/jest.conf.js +0 -25
- package/__tests__/unit/specs/date.test.js +0 -11
- package/global.d.ts +0 -0
- package/publish.sh +0 -11
- package/specification/CSS.md +0 -25
- package/specification/JS.md +0 -9
- package/specification/VUE.md +0 -1
- package/src/consts/httpCode.js +0 -10
- package/src/index.ts +0 -51
- package/src/modules/cookie/index.ts +0 -69
- package/src/modules/date/index.ts +0 -196
- package/src/modules/dom/index.ts +0 -78
- package/src/modules/filter/index.ts +0 -43
- package/src/modules/format/index.ts +0 -19
- package/src/modules/match/index.ts +0 -31
- package/src/modules/monitor/index.ts +0 -13
- package/src/modules/monitor/lib/jsError.ts +0 -57
- package/src/modules/monitor/lib/timing.ts +0 -75
- package/src/modules/monitor/lib/xhr.ts +0 -40
- package/src/modules/monitor/utils/onload.ts +0 -8
- package/src/modules/monitor/utils/tracker.ts +0 -47
- package/src/modules/number/index.ts +0 -108
- package/src/modules/sentry/index.ts +0 -82
- package/src/modules/tools/index.ts +0 -427
- package/tsconfig.json +0 -34
package/package.json
CHANGED
|
@@ -1,18 +1,23 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@haluo/util",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.20.1",
|
|
4
4
|
"main": "./dist/index.js",
|
|
5
|
-
"author": "<wanghui@
|
|
6
|
-
"description": "
|
|
5
|
+
"author": "<wanghui@mddmoto.com>",
|
|
6
|
+
"description": "摩托范工具库",
|
|
7
7
|
"scripts": {
|
|
8
|
-
"build": "
|
|
8
|
+
"build": "tsc",
|
|
9
|
+
"build:webpack": "webpack --config ./build/webpack.pro.config.js",
|
|
9
10
|
"tsc": "tsc",
|
|
10
|
-
"
|
|
11
|
-
"
|
|
12
|
-
"
|
|
11
|
+
"lib": "tsc",
|
|
12
|
+
"pub": "npm publish",
|
|
13
|
+
"pub:next": "npm publish --tag next",
|
|
13
14
|
"precommit": "lint-staged"
|
|
14
15
|
},
|
|
15
|
-
"
|
|
16
|
+
"files": [
|
|
17
|
+
"dist",
|
|
18
|
+
"package.json"
|
|
19
|
+
],
|
|
20
|
+
"types": "dist/index.d.ts",
|
|
16
21
|
"lint-staged": {
|
|
17
22
|
"src/**/*.{js,vue}": [
|
|
18
23
|
"eslint --fix",
|
|
@@ -26,10 +31,9 @@
|
|
|
26
31
|
"@haluo/util"
|
|
27
32
|
],
|
|
28
33
|
"dependencies": {
|
|
29
|
-
"@types/
|
|
34
|
+
"@types/ali-oss": "^6.16.13",
|
|
30
35
|
"axios": "^0.19.2",
|
|
31
36
|
"clipboard-copy": "^4.0.1",
|
|
32
|
-
"jest": "^27.0.6",
|
|
33
37
|
"raven-js": "^3.27.2",
|
|
34
38
|
"ua-parser-js": "^1.0.2",
|
|
35
39
|
"uuid": "^8.3.2"
|
|
@@ -43,11 +47,12 @@
|
|
|
43
47
|
"@babel/preset-env": "^7.14.7",
|
|
44
48
|
"@babel/preset-typescript": "^7.14.5",
|
|
45
49
|
"@types/node": "^14.0.13",
|
|
50
|
+
"@types/qs": "^6.14.0",
|
|
46
51
|
"@types/webpack-env": "^1.15.2",
|
|
47
52
|
"@typescript-eslint/eslint-plugin": "^5.33.0",
|
|
53
|
+
"ali-oss": "^6.17.1",
|
|
48
54
|
"autoprefixer-loader": "^2.1.0",
|
|
49
55
|
"babel-eslint": "^8.2.3",
|
|
50
|
-
"babel-jest": "^26.0.1",
|
|
51
56
|
"babel-loader": "^8.0.6",
|
|
52
57
|
"babel-preset-env": "^1.7.0",
|
|
53
58
|
"eslint": "^4.19.1",
|
|
@@ -61,10 +66,10 @@
|
|
|
61
66
|
"eslint-plugin-standard": "^3.1.0",
|
|
62
67
|
"eslint-plugin-vue": "^4.5.0",
|
|
63
68
|
"html-webpack-plugin": "^3.2.0",
|
|
64
|
-
"jest": "^27.0.6",
|
|
65
69
|
"lodash": "^4.17.21",
|
|
70
|
+
"lrz": "^4.9.41",
|
|
66
71
|
"normalize.css": "^8.0.1",
|
|
67
|
-
"
|
|
72
|
+
"qs": "^6.14.0",
|
|
68
73
|
"typescript": "^4.9.5",
|
|
69
74
|
"webpack": "^4.32.2",
|
|
70
75
|
"webpack-cli": "^3.3.2",
|
package/.babelrc
DELETED
package/.eslintrc.js
DELETED
|
@@ -1,216 +0,0 @@
|
|
|
1
|
-
const DOMGlobals = [] // ['window']
|
|
2
|
-
|
|
3
|
-
module.exports = {
|
|
4
|
-
root: true,
|
|
5
|
-
parserOptions: {
|
|
6
|
-
parser: '@typescript-eslint/parser',
|
|
7
|
-
sourceType: 'module'
|
|
8
|
-
},
|
|
9
|
-
env: {
|
|
10
|
-
browser: true,
|
|
11
|
-
node: true,
|
|
12
|
-
es6: true,
|
|
13
|
-
jest: true
|
|
14
|
-
},
|
|
15
|
-
extends: ['plugin:vue/recommended', 'eslint:recommended', "plugin:@typescript-eslint/recommended"],
|
|
16
|
-
globals: {
|
|
17
|
-
document: true,
|
|
18
|
-
navigator: true,
|
|
19
|
-
window: true,
|
|
20
|
-
wx: true,
|
|
21
|
-
Toast: true,
|
|
22
|
-
AppCall: true,
|
|
23
|
-
QRCode: true
|
|
24
|
-
},
|
|
25
|
-
// 0 关闭 1警告 2报错
|
|
26
|
-
// add your custom rules here
|
|
27
|
-
// it is base on https://github.com/vuejs/eslint-config-vue
|
|
28
|
-
rules: {
|
|
29
|
-
'vue/max-attributes-per-line': [2, {
|
|
30
|
-
'singleline': 10,
|
|
31
|
-
'multiline': {
|
|
32
|
-
'max': 1,
|
|
33
|
-
'allowFirstLine': false
|
|
34
|
-
}
|
|
35
|
-
}],
|
|
36
|
-
'vue/name-property-casing': [2, 'PascalCase'],
|
|
37
|
-
'vue/no-parsing-error': [2, { 'x-invalid-end-tag': false }],
|
|
38
|
-
'vue/require-prop-types': 0,
|
|
39
|
-
'vue/html-self-closing': 0,
|
|
40
|
-
'accessor-pairs': 2,
|
|
41
|
-
'arrow-spacing': [2, {
|
|
42
|
-
'before': true,
|
|
43
|
-
'after': true
|
|
44
|
-
}],
|
|
45
|
-
'block-spacing': [2, 'always'],
|
|
46
|
-
'brace-style': [2, '1tbs', {
|
|
47
|
-
'allowSingleLine': true
|
|
48
|
-
}],
|
|
49
|
-
'camelcase': [0, {
|
|
50
|
-
'properties': 'always'
|
|
51
|
-
}],
|
|
52
|
-
'comma-dangle': 0, // [2, 'never'],
|
|
53
|
-
'comma-spacing': [2, {
|
|
54
|
-
'before': false,
|
|
55
|
-
'after': true
|
|
56
|
-
}],
|
|
57
|
-
'comma-style': [2, 'last'],
|
|
58
|
-
'constructor-super': 2,
|
|
59
|
-
'curly': [2, 'multi-line'],
|
|
60
|
-
'dot-location': [2, 'property'],
|
|
61
|
-
'eol-last': 2,
|
|
62
|
-
'eqeqeq': [2, 'allow-null'],
|
|
63
|
-
'generator-star-spacing': [2, {
|
|
64
|
-
'before': true,
|
|
65
|
-
'after': true
|
|
66
|
-
}],
|
|
67
|
-
'handle-callback-err': [2, '^(err|error)$'],
|
|
68
|
-
'indent': 0, // [2, 2, { 'SwitchCase': 1 }],
|
|
69
|
-
'jsx-quotes': [2, 'prefer-single'],
|
|
70
|
-
'key-spacing': [2, {
|
|
71
|
-
'beforeColon': false,
|
|
72
|
-
'afterColon': true
|
|
73
|
-
}],
|
|
74
|
-
'keyword-spacing': [2, {
|
|
75
|
-
'before': true,
|
|
76
|
-
'after': true
|
|
77
|
-
}],
|
|
78
|
-
'max-depth': [1, { 'max': 4 }],
|
|
79
|
-
'max-len': [1, { 'code': 150, 'tabWidth': 2, 'ignoreUrls': true, 'ignoreRegExpLiterals': true }],
|
|
80
|
-
'max-lines': [1, { 'max': 1000, 'skipBlankLines': true, 'skipComments': true }],
|
|
81
|
-
// 'max-lines-per-function': [1, { 'max': 20, 'skipComments': true }],
|
|
82
|
-
'max-params': [1, 3],
|
|
83
|
-
'new-cap': [2, {
|
|
84
|
-
'newIsCap': true,
|
|
85
|
-
'capIsNew': false
|
|
86
|
-
}],
|
|
87
|
-
'new-parens': 2,
|
|
88
|
-
'no-array-constructor': 2,
|
|
89
|
-
'no-caller': 2,
|
|
90
|
-
'no-console': 0,
|
|
91
|
-
'no-class-assign': 2,
|
|
92
|
-
'no-cond-assign': 2,
|
|
93
|
-
'no-const-assign': 2,
|
|
94
|
-
'no-control-regex': 0,
|
|
95
|
-
'no-delete-var': 2,
|
|
96
|
-
'no-dupe-args': 2,
|
|
97
|
-
'no-dupe-class-members': 2,
|
|
98
|
-
'no-dupe-keys': 2,
|
|
99
|
-
'no-duplicate-case': 2,
|
|
100
|
-
'no-empty-character-class': 2,
|
|
101
|
-
'no-empty-pattern': 2,
|
|
102
|
-
'no-eval': 2,
|
|
103
|
-
'no-ex-assign': 2,
|
|
104
|
-
'no-extend-native': 2,
|
|
105
|
-
'no-extra-bind': 2,
|
|
106
|
-
'no-extra-boolean-cast': 2,
|
|
107
|
-
'no-extra-parens': [2, 'functions'],
|
|
108
|
-
'no-fallthrough': 2,
|
|
109
|
-
'no-floating-decimal': 2,
|
|
110
|
-
'no-func-assign': 2,
|
|
111
|
-
'no-implied-eval': 2,
|
|
112
|
-
'no-inner-declarations': [2, 'functions'],
|
|
113
|
-
'no-invalid-regexp': 2,
|
|
114
|
-
'no-irregular-whitespace': 2,
|
|
115
|
-
'no-iterator': 2,
|
|
116
|
-
'no-label-var': 2,
|
|
117
|
-
'no-labels': [2, {
|
|
118
|
-
'allowLoop': false,
|
|
119
|
-
'allowSwitch': false
|
|
120
|
-
}],
|
|
121
|
-
'no-lone-blocks': 2,
|
|
122
|
-
'no-magic-numbers': [1, { 'ignore': [-1, 0, 1, 10, 12, 24, 30, 60, 100, 200, 1000, 2000, 3000, 3600, 5000], "ignoreArrayIndexes": true }],
|
|
123
|
-
'no-mixed-spaces-and-tabs': 2,
|
|
124
|
-
'no-multi-spaces': 2,
|
|
125
|
-
'no-multi-str': 2,
|
|
126
|
-
'no-multiple-empty-lines': [2, {
|
|
127
|
-
'max': 1
|
|
128
|
-
}],
|
|
129
|
-
'no-native-reassign': 2,
|
|
130
|
-
'no-negated-in-lhs': 2,
|
|
131
|
-
'no-new-object': 2,
|
|
132
|
-
'no-new-require': 2,
|
|
133
|
-
'no-new-symbol': 2,
|
|
134
|
-
'no-new-wrappers': 2,
|
|
135
|
-
'no-obj-calls': 2,
|
|
136
|
-
'no-octal': 2,
|
|
137
|
-
'no-octal-escape': 2,
|
|
138
|
-
'no-path-concat': 2,
|
|
139
|
-
'no-proto': 2,
|
|
140
|
-
'no-redeclare': 2,
|
|
141
|
-
'no-regex-spaces': 2,
|
|
142
|
-
'no-return-assign': 0,
|
|
143
|
-
'no-restricted-globals': [1, ...DOMGlobals],
|
|
144
|
-
'no-self-assign': 2,
|
|
145
|
-
'no-self-compare': 2,
|
|
146
|
-
'no-sequences': 0,
|
|
147
|
-
'no-shadow-restricted-names': 2,
|
|
148
|
-
'no-spaced-func': 2,
|
|
149
|
-
'no-sparse-arrays': 2,
|
|
150
|
-
'no-this-before-super': 2,
|
|
151
|
-
'no-throw-literal': 2,
|
|
152
|
-
'no-trailing-spaces': 2,
|
|
153
|
-
'no-undef': 2,
|
|
154
|
-
'no-undef-init': 2,
|
|
155
|
-
'no-unexpected-multiline': 2,
|
|
156
|
-
'no-unmodified-loop-condition': 2,
|
|
157
|
-
'no-unneeded-ternary': [2, {
|
|
158
|
-
'defaultAssignment': false
|
|
159
|
-
}],
|
|
160
|
-
'no-unreachable': 2,
|
|
161
|
-
'no-unsafe-finally': 2,
|
|
162
|
-
'no-unused-vars': [2, {
|
|
163
|
-
'vars': 'all',
|
|
164
|
-
'args': 'none'
|
|
165
|
-
}],
|
|
166
|
-
'no-useless-call': 2,
|
|
167
|
-
'no-useless-computed-key': 2,
|
|
168
|
-
'no-useless-constructor': 2,
|
|
169
|
-
'no-useless-escape': 0,
|
|
170
|
-
'no-whitespace-before-property': 2,
|
|
171
|
-
'no-with': 2,
|
|
172
|
-
'one-var': [2, {
|
|
173
|
-
'initialized': 'never'
|
|
174
|
-
}],
|
|
175
|
-
'operator-linebreak': [2, 'after', {
|
|
176
|
-
'overrides': {
|
|
177
|
-
'?': 'before',
|
|
178
|
-
':': 'before'
|
|
179
|
-
}
|
|
180
|
-
}],
|
|
181
|
-
'padded-blocks': [2, 'never'],
|
|
182
|
-
'quotes': [2, 'single', {
|
|
183
|
-
'avoidEscape': true,
|
|
184
|
-
'allowTemplateLiterals': true
|
|
185
|
-
}],
|
|
186
|
-
'semi': 0,
|
|
187
|
-
'semi-spacing': [2, {
|
|
188
|
-
'before': false,
|
|
189
|
-
'after': true
|
|
190
|
-
}],
|
|
191
|
-
'space-before-blocks': [2, 'always'],
|
|
192
|
-
'space-before-function-paren': 0,
|
|
193
|
-
'space-before-function-paren': 0,
|
|
194
|
-
'space-in-parens': [2, 'never'],
|
|
195
|
-
'space-infix-ops': 2,
|
|
196
|
-
'space-unary-ops': [2, {
|
|
197
|
-
'words': true,
|
|
198
|
-
'nonwords': false
|
|
199
|
-
}],
|
|
200
|
-
'spaced-comment': [2, 'always', {
|
|
201
|
-
'markers': ['global', 'globals', 'eslint', 'eslint-disable', '*package', '!', ',']
|
|
202
|
-
}],
|
|
203
|
-
'template-curly-spacing': [2, 'never'],
|
|
204
|
-
'use-isnan': 2,
|
|
205
|
-
'valid-typeof': 2,
|
|
206
|
-
'wrap-iife': [2, 'any'],
|
|
207
|
-
'yield-star-spacing': [2, 'both'],
|
|
208
|
-
'yoda': [2, 'never'],
|
|
209
|
-
'prefer-const': 2,
|
|
210
|
-
'no-debugger': process.env.NODE_ENV === 'production' ? 2 : 0,
|
|
211
|
-
'object-curly-spacing': [2, 'always', {
|
|
212
|
-
objectsInObjects: false
|
|
213
|
-
}],
|
|
214
|
-
'array-bracket-spacing': [2, 'never']
|
|
215
|
-
}
|
|
216
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { format, formatPassTimeForDetail } from '../../../src/modules/date/index.ts'
|
|
2
|
-
describe('date', () => {
|
|
3
|
-
it('formatTime()默认格式,返回时间格式是否正常', () => {
|
|
4
|
-
expect(format(1586934316925)).toBe('2020-04-15 15:05:16')
|
|
5
|
-
})
|
|
6
|
-
|
|
7
|
-
it('formatTime()传参数,返回时间格式是否正常', () => {
|
|
8
|
-
expect(format(1586934316925, 'YYYY.MM.DD')).toBe('2020.04.15')
|
|
9
|
-
})
|
|
10
|
-
|
|
11
|
-
it('formatPassTimeForDetail()传参数,返回时间格式是否正常', () => {
|
|
12
|
-
expect(formatPassTimeForDetail(Date.now() - 60 * 60 * 1000)).toBe('1小时前')
|
|
13
|
-
})
|
|
14
|
-
})
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
const path = require('path');
|
|
2
|
-
|
|
3
|
-
module.exports = {
|
|
4
|
-
preset: 'ts-jest',
|
|
5
|
-
verbose: true,
|
|
6
|
-
rootDir: path.resolve(__dirname, '../../'),
|
|
7
|
-
moduleFileExtensions: [
|
|
8
|
-
'js',
|
|
9
|
-
'json',
|
|
10
|
-
'ts'
|
|
11
|
-
],
|
|
12
|
-
transform: {
|
|
13
|
-
'^.+\\.ts$': 'ts-jest',
|
|
14
|
-
'^.+\\.js$': 'babel-jest',
|
|
15
|
-
},
|
|
16
|
-
testMatch: [
|
|
17
|
-
'**/__tests__/**/*.(spec|test).[jt]s?(x)',
|
|
18
|
-
],
|
|
19
|
-
transformIgnorePatterns: ['/node_modules/'],
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
// 语句覆盖率(statement coverage)
|
|
23
|
-
// 分支覆盖率(branch coverage)
|
|
24
|
-
// 函数覆盖率(function coverage)
|
|
25
|
-
// 行覆盖率(line coverage)
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
const date = require('../../../src/modules/date/index');
|
|
2
|
-
|
|
3
|
-
console.log(date);
|
|
4
|
-
describe('date 模块', () => {
|
|
5
|
-
test('formatTime()默认格式,返回时间格式是否正常', () => {
|
|
6
|
-
expect(date.format(1586934316925)).toBe('2020-04-15 15:05:16');
|
|
7
|
-
})
|
|
8
|
-
test('format()传参数,返回时间格式是否正常', () => {
|
|
9
|
-
expect(date.format(1586934316925, 'YYYY.MM.DD')).toBe('2020.04.15');
|
|
10
|
-
})
|
|
11
|
-
});
|
package/global.d.ts
DELETED
|
File without changes
|
package/publish.sh
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env bash
|
|
2
|
-
# npm config get registry # 检查仓库镜像库
|
|
3
|
-
# npm config set registry=http://registry.npmjs.org
|
|
4
|
-
# echo '请进行登录相关操作:'
|
|
5
|
-
# npm login # 登陆
|
|
6
|
-
tsc
|
|
7
|
-
echo "-------publishing-------"
|
|
8
|
-
npm publish # 发布
|
|
9
|
-
# npm config set registry=https://registry.npm.taobao.org # 设置为淘宝镜像
|
|
10
|
-
echo "发布完成"
|
|
11
|
-
exit
|
package/specification/CSS.md
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
### CSS
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
#### [BEM](http://getbem.com/)
|
|
5
|
-
**BlockElementModifier其实是块(block)、元素(element)、修饰符(modifier)**
|
|
6
|
-
> * block 代表了更高级别的抽象或组件
|
|
7
|
-
> * block__element 代表 block 的后代,用于形成一个完整的 block 的整体
|
|
8
|
-
> * block--modifier代表 block 的不同状态或不同版本
|
|
9
|
-
|
|
10
|
-
```css
|
|
11
|
-
/* demo */
|
|
12
|
-
person{} /* 人 */
|
|
13
|
-
person__hand{} /* 人的手 */
|
|
14
|
-
person--female{} /* 女人 */
|
|
15
|
-
person--female__hand{} /* 女人的手 */
|
|
16
|
-
person__hand--left{} /* 人的左手 */
|
|
17
|
-
```
|
|
18
|
-
|
|
19
|
-
#### Z-Index
|
|
20
|
-
```
|
|
21
|
-
页面元素:1-99
|
|
22
|
-
fixed:100-199
|
|
23
|
-
弹框:200-299
|
|
24
|
-
Toast:300-399
|
|
25
|
-
```
|
package/specification/JS.md
DELETED
package/specification/VUE.md
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
### [VUE](https://cn.vuejs.org/v2/style-guide/)
|
package/src/consts/httpCode.js
DELETED
package/src/index.ts
DELETED
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @Author: wanghui
|
|
3
|
-
* createBy: @2020.05.21
|
|
4
|
-
*/
|
|
5
|
-
'use strict'
|
|
6
|
-
|
|
7
|
-
const modules: any = {
|
|
8
|
-
cookie: require('./modules/cookie'),
|
|
9
|
-
date: require('./modules/date'),
|
|
10
|
-
dom: require('./modules/dom'),
|
|
11
|
-
filter: require('./modules/filter'),
|
|
12
|
-
format: require('./modules/format'),
|
|
13
|
-
match: require('./modules/match'),
|
|
14
|
-
number: require('./modules/number'),
|
|
15
|
-
tools: require('./modules/tools'),
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
class Utils {
|
|
19
|
-
[key: string]: Object
|
|
20
|
-
|
|
21
|
-
constructor() {
|
|
22
|
-
Object.assign(this, modules)
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* 挂载各组件
|
|
27
|
-
* 示例:this.$cookie、this.$date、this.$match、this.$number、this.$tools
|
|
28
|
-
* @param {Object} Vue 需要挂载的目标对象
|
|
29
|
-
*/
|
|
30
|
-
install(app: any) {
|
|
31
|
-
Object.keys(modules).forEach((key) => {
|
|
32
|
-
const globalProperties = app.config.globalProperties
|
|
33
|
-
globalProperties['$' + key] = modules[key]
|
|
34
|
-
})
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
// loadModules() {
|
|
38
|
-
// const modules = require['context']('./modules/', true, /.js$/)
|
|
39
|
-
// modules.keys().forEach((modulesKey: string) => {
|
|
40
|
-
// const attr: string = modulesKey.replace('./', '').replace('.js', '').replace('/index', '')
|
|
41
|
-
// const haveDefault = ['sentry']
|
|
42
|
-
// if (haveDefault.includes(attr)) {
|
|
43
|
-
// this[attr] = modules(modulesKey).default
|
|
44
|
-
// } else {
|
|
45
|
-
// this[attr] = modules(modulesKey)
|
|
46
|
-
// }
|
|
47
|
-
// })
|
|
48
|
-
// }
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
module.exports = new Utils()
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @file Cookie
|
|
3
|
-
* @Author: wanghui
|
|
4
|
-
* @createBy: @2021.01.21
|
|
5
|
-
*/
|
|
6
|
-
'use strict'
|
|
7
|
-
interface ICookie {
|
|
8
|
-
name: string,
|
|
9
|
-
value: string,
|
|
10
|
-
exdays: number,
|
|
11
|
-
path?: string,
|
|
12
|
-
domain?: string,
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
class CookieClass {
|
|
16
|
-
/**
|
|
17
|
-
* 获取cookie
|
|
18
|
-
* @param {String} name
|
|
19
|
-
* @return {String}
|
|
20
|
-
*/
|
|
21
|
-
getCookie(name: string) {
|
|
22
|
-
const _name = name + '='
|
|
23
|
-
const ca = document.cookie.split(';')
|
|
24
|
-
for (let i = 0; i < ca.length; i++) {
|
|
25
|
-
let c = ca[i]
|
|
26
|
-
while (c.charAt(0) === ' ') c = c.substring(1)
|
|
27
|
-
if (c.includes(_name)) return c.substring(_name.length, c.length)
|
|
28
|
-
}
|
|
29
|
-
return ''
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* 设置cookie
|
|
34
|
-
* @param {Object} ICookie
|
|
35
|
-
*/
|
|
36
|
-
setCookie({
|
|
37
|
-
name = '',
|
|
38
|
-
value = '',
|
|
39
|
-
exdays = -1,
|
|
40
|
-
path = '/',
|
|
41
|
-
domain = '.jddmoto.com',
|
|
42
|
-
}: ICookie) {
|
|
43
|
-
var d = new Date();
|
|
44
|
-
d.setTime(d.getTime() + (exdays * 24 * 60 * 60 * 1000))
|
|
45
|
-
var expires = `expires=${d.toUTCString()}`
|
|
46
|
-
document.cookie = `${name}=${value};${expires};path=${path};domain=${domain};`
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
* 清除Cookie
|
|
51
|
-
* @param {String} name
|
|
52
|
-
*/
|
|
53
|
-
clearCookie({
|
|
54
|
-
name = '',
|
|
55
|
-
path = '/',
|
|
56
|
-
domain = '.jddmoto.com',
|
|
57
|
-
}: ICookie) {
|
|
58
|
-
this.setCookie({
|
|
59
|
-
name,
|
|
60
|
-
value: '',
|
|
61
|
-
exdays: -1,
|
|
62
|
-
path,
|
|
63
|
-
domain
|
|
64
|
-
})
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
module.exports = new CookieClass()
|
|
69
|
-
|