This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const fieldsToChildren = (data) => { | |
return data.map(item => { | |
if (!item.key) { | |
item.key = index | |
index += 1 | |
} | |
if (item.fields) { | |
item.children = item.fields | |
delete item.fields | |
for (let i = 0; i < item.children.length; i++) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 支持检索嵌套表格 | |
* @param key | |
*/ | |
getNestedRowByKey(key, data = this.state.data) { | |
if (data.some(item => item.key === key)) { | |
return data.filter(item => item.key === key)[0] | |
} | |
for (let i = 0; i < data.length; i++) { | |
const item = data[i] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 公用 ajax 请求 | |
*/ | |
request: function (options) { | |
var defaultOptions = { | |
beforeSend: function (xhr) { | |
xhr.setRequestHeader('accept', 'application/json'); | |
xhr.setRequestHeader('Accept-Language', 'en'); | |
}, | |
type: 'post', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
import { Input, Icon } from 'antd'; | |
import styles from './index.less'; | |
const map = { | |
UserName: { | |
component: Input, | |
props: { | |
size: 'large', | |
prefix: <Icon type="user" className={styles.prefixIcon} />, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
import { Input, Icon } from 'antd'; | |
import styles from './index.less'; | |
const map = { | |
UserName: { | |
component: Input, | |
props: { | |
size: 'large', | |
prefix: <Icon type="user" className={styles.prefixIcon} />, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 一个典型的闭包 + IIFE(Immediately-invoked function expression) F结合的例子 | |
*/ | |
const generateId = (() => { | |
let i = 0; | |
return (prefix = '') => { | |
i += 1; | |
return `${prefix}${i}`; | |
}; | |
})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
This script attempts to identify all CSS classes mentioned in HTML but not defined in the stylesheets. | |
In order to use it, just run it in the DevTools console (or add it to DevTools Snippets and run it from there). | |
Note that this script requires browser to support `fetch` and some ES6 features (fat arrow, Promises, Array.from, Set). You can transpile it to ES5 here: https://babeljs.io/repl/ . | |
Known limitations: | |
- it won't be able to take into account some external stylesheets (if CORS isn't set up) | |
- it will produce false negatives for classes that are mentioned in the comments. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import test from 'ava'; | |
import { expect } from 'chai'; | |
import chai from 'chai'; | |
import { forEach } from 'lodash'; | |
test('额度', t => { | |
try { | |
const exp = /^([1-9](\d{0,9})?(\.\d{1,2})?|0(\.\d{1,2}))$/; | |
const goodCases = [ | |
'1', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
docker_desc="Dockerfile" # Dockerfile filename | |
image_name="yourimage" # Name and optionally tag of your image | |
file_extension=".tar" # File extension of saved file | |
gz_extension=".gz" # File extension of saved file after compression | |
# Dockerfile exist or not | |
if [ ! -e "$docker_desc" ]; then | |
echo "Dockerfile not found" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
xcode-select --install |
NewerOlder