Skip to content

Instantly share code, notes, and snippets.

@xgqfrms-GitHub
Created July 6, 2017 09:49
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save xgqfrms-GitHub/94607b60e14b998eab87ca8ab86588e4 to your computer and use it in GitHub Desktop.
Save xgqfrms-GitHub/94607b60e14b998eab87ca8ab86588e4 to your computer and use it in GitHub Desktop.
角色权限认证管理
@xgqfrms-GitHub
Copy link
Author

xgqfrms-GitHub commented Jul 6, 2017

rsa-ca-error

https://github.com/xgqfrms/RAIO/issues/6

https://github.com/pmg1989/dva-admin

npm start

C:\Users\xray.anyproxy_certs

rootCA.key

-----BEGIN RSA PRIVATE KEY-----

-----END RSA PRIVATE KEY-----

@xgqfrms-GitHub
Copy link
Author

xgqfrms-GitHub commented Jul 6, 2017

Mock

fake.js

        'roleId|1': [1, 2, 3],
        'roleName|1': function() {
            return ["管理员", "教师", "学生"][this.roleId - 1]
        },



// [array][index]


const arr = ["管理员", "教师", "学生"];

arr[0];
arr[1];
arr[2];

/*

["管理员", "教师", "学生"]
// (3) ["管理员", "教师", "学生"]
["管理员", "教师", "学生"][0];
//"管理员"
["管理员", "教师", "学生"][1];
//"教师"
["管理员", "教师", "学生"][2];
//"学生"

*/

@xgqfrms-GitHub
Copy link
Author

xgqfrms-GitHub commented Jul 6, 2017

fake.js

https://gist.github.com/xyzdata/f2b41a63feb21081e9f51d464d7434d7#gistcomment-2141118

// 使用 Mock
import Mock from 'mockjs';

let data = Mock.mock({
    // 属性 list 的值是一个数组,其中含有 1 到 10 个元素
    'users|1-100': [{
        // 属性 id 是一个自增数,起始值为 1,每次增 1
        'id|+1': 101
    }]
});


// 输出结果
console.log(
    JSON.stringify(data, null, 4)
);

// JSON.stringify(value[, replacer[, space]]);

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify

@xgqfrms-GitHub
Copy link
Author

xgqfrms-GitHub commented Jul 6, 2017

boolean & 0

["管理员", "教师", "学生"][true+0]
// "教师"

["管理员", "教师", "学生"][false+0]
// "管理员"


        'bm': '@boolean',
        'isMale|1': function() {
            return ["Man", "Woman"][this.bm + 0]
        },

@xgqfrms-GitHub
Copy link
Author

// 连字符转驼峰
String.prototype.hyphenToHump = function() {
    return this.replace(/-(\w)/g, function() {
        return arguments[1].toUpperCase()
    });
};

// 驼峰转连字符
String.prototype.humpToHyphen = function() {
    return this.replace(/([A-Z])/g, '-$1').toLowerCase();
};

@xgqfrms-GitHub
Copy link
Author

xgqfrms-GitHub commented Jul 6, 2017

shit & bug

H:\xgqfrms\Roles\src\utils\index.js

OK ???

import menu from './menu'
import Cookie from './cookie'
export config from './config'
export request from './request-mock'
export { color }
from './theme'

bad

import menu from './menu';
import Cookie from './cookie';
import config from './config';
import request from './request-mock';
import {color} from './theme';

export

export { name1, name2, , nameN };
export { variable1 as name1, variable2 as name2, , nameN };
export let name1, name2, , nameN; // also var
export let name1 = , name2 = , , nameN; // also var, const

export default expression;
export default function () {  } // also class, function*
export default function name1() {  } // also class, function*
export { name1 as default,  };

export * from ;
export { name1, name2, , nameN } from ;
export { import1 as name1, import2 as name2, , nameN } from ;

https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Statements/export

@xgqfrms-GitHub
Copy link
Author

https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Statements/import

import defaultMember from "module-name"; 
import * as name from "module-name"; 
import { member } from "module-name"; 
import { member as alias } from "module-name"; 
import { member1 , member2 } from "module-name"; 
import { member1 , member2 as alias2 , [...] } from "module-name"; 
import defaultMember, { member [ , [...] ] } from "module-name"; 
import defaultMember, * as name from "module-name"; 
import "module-name";

@xgqfrms-GitHub
Copy link
Author

xgqfrms-GitHub commented Jul 6, 2017

Admin\ModalForm.js

\src\routes

H:\xgqfrms\Roles\src\routes\account\Admin\ModalForm.js

@xgqfrms-GitHub
Copy link
Author

xgqfrms-GitHub commented Jul 6, 2017

    {
        title: '性别',
        dataIndex: 'isMale',
        key: 'isMale',
        render: (text) => <span>{text
            ? '男'
            : '女'}</span>
    },

H:\xgqfrms\Roles\src\routes\account\Admin\List.js

\src\routes\

@xgqfrms-GitHub
Copy link
Author

xgqfrms-GitHub commented Jul 6, 2017

@xyzdata
Copy link

xyzdata commented Jul 7, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment