For front-end pages and function points , Authority management done .
Role definition :
const ROLE = {
MANAGER: 1,
USER: 2,
}Product definition :
const PRODUCT_TYPE = {
TESTA: 0,
TESTB: 1
}Function point definition :( Specific to the buttons on the page , Display and hide some functions )
const FUNCTION_POINT = {
SEARCH: " Inquire about ",
MODIFY: " modify ",
}Permission definition :( Page path / The function node corresponds to the permission )
const AUTH = {
"/user": `ROLE${ROLE.MANAGER}`,
"/testA": `ROLE${ROLE.USER} && PRODUCT_TYPE${PRODUCT_TYPE.TESTA}`,
"/testB": `ROLE${ROLE.USER} && PRODUCT_TYPE${PRODUCT_TYPE.TESTB}`,
[FUNCTION_POINT.SEARCH]: `ROLE${ROLE.MANAGER}`,
}Rights management :
let AuthManager = {
role: null,
productType: null,
// Initialize user roles
initial(role, productType) {
this.role = role;
this.productType = productType;
},
check(prop) {
if (!AUTH[prop]) return true;
let string = "return " + AUTH[prop];
string = string.replaceAll("ROLE", `${this.role}===`);
string = string.replaceAll("PRODUCT_TYPE", `${this.productType}===`);
let result;
try {
// eslint-disable-next-line no-new-func
result = new Function(string)();
} catch {
result = true;
}
return result;
},
getDefaultPage() {
let result;
switch (this.role) {
case ROLE.MANAGER: result = "/"; break;
case ROLE.USER:
if (this.productType === PRODUCT_TYPE.TESTA) result = "/testA";
if (this.productType === PRODUCT_TYPE.TESTB) result = "/testB";
break;
default:
break;
}
return result;
}
}
export default AuthManager;







![[OSG] OSG development (03) -- build the osgqt Library of MSVC version](/img/54/602cc5e92d8bfafbef346d6fbb96e3.png)
![[telnet] telnet installation and configuration](/img/e1/34801a499c75a2588524ed2ec5af8e.jpg)