mirror of
https://github.com/YMFE/yapi.git
synced 2025-01-18 13:04:46 +08:00
fix: 弃用Object.entries方法
This commit is contained in:
parent
250e2e5485
commit
f734b3a3ed
@ -86,12 +86,12 @@ exports.simpleJsonPathParse = function (key, json){
|
||||
try{
|
||||
let m = keys[i].match(/(.*?)\[([0-9]+)\]/)
|
||||
if(m){
|
||||
json = json[m[1]][m[2]];
|
||||
json = json[m[1]][m[2]];
|
||||
}else{
|
||||
json = json[keys[i]];
|
||||
json = json[keys[i]];
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}catch(e){
|
||||
json = null;
|
||||
break;
|
||||
@ -166,3 +166,12 @@ exports.nameLengthLimit = (type) => {
|
||||
}
|
||||
}]
|
||||
}
|
||||
|
||||
// 实现 Object.entries() 方法
|
||||
exports.entries = (obj) => {
|
||||
let res = [];
|
||||
for(let key in obj) {
|
||||
res.push([key, obj[key]]);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
@ -11,7 +11,7 @@ const RadioGroup = Radio.Group;
|
||||
const RadioButton = Radio.Button;
|
||||
import constants from '../../../../constants/variable.js';
|
||||
const confirm = Modal.confirm;
|
||||
import { nameLengthLimit } from '../../../../common';
|
||||
import { nameLengthLimit, entries } from '../../../../common';
|
||||
import '../Setting.scss';
|
||||
// layout
|
||||
const formItemLayout = {
|
||||
@ -164,7 +164,7 @@ class ProjectMessage extends Component {
|
||||
const { name, basepath, desc, project_type } = projectMsg;
|
||||
initFormValues = { name, basepath, desc, project_type };
|
||||
|
||||
const colorArr = Object.entries(constants.PROJECT_COLOR);
|
||||
const colorArr = entries(constants.PROJECT_COLOR);
|
||||
const colorSelector = (<RadioGroup onChange={this.changeProjectColor} value={projectMsg.color} className="color">
|
||||
{colorArr.map((item, index) => {
|
||||
return (<RadioButton key={index} value={item[0]} style={{ backgroundColor: item[1], color: '#fff', fontWeight: 'bold' }}>{item[0] === projectMsg.color ? <Icon type="check" /> : null}</RadioButton>);
|
||||
|
Loading…
Reference in New Issue
Block a user