@eim-materials/eim-pc-admin-lite
Version:
该模板适用于从 0 到 1 开始搭建项目,内置基础的页面,路由和菜单展示。
147 lines (143 loc) • 3.25 kB
JavaScript
import Server from './server';
/* eslint class-methods-use-this: 0 */
class API extends Server {
/**
* 获取用户信息
*
*/
async getInfo(params) {
try {
const result = await this.axios('get', '/user/info', params);
if (result && result.code === 0) {
return result;
}
const err = {
tip: '获取用户信息失败',
response: result,
data: params,
url: '/user/info',
};
throw err;
} catch (err) {
throw err;
}
}
async logout() {
try {
const result = await this.axios('post', '/login/logout');
if (result && result.code === 0) {
return result;
}
const err = {
tip: '登出失败',
response: result,
data: {},
url: '/login/logout',
};
throw err;
} catch (err) {
throw err;
}
}
// 文件上传
async upload(formData) {
try {
const result = await this.axios('post', '/cloudfs/api/fs/upload', formData);
if (result.state === 'SUCCESS') {
return result;
}
const err = {
tip: '文件上传失败',
response: result,
data: {
formData,
},
url: '/cloudfs/api/fs/upload',
};
throw err;
} catch (err) {
throw err;
}
}
// 获取角色列表
async getAdminRolePage(params) {
try {
const result = await this.axios('get', '/appsframework/admin/role/page', params);
if (result.state === 0) {
return result;
}
const err = {
tip: '获取角色列表失败',
response: result,
data: {
params,
},
url: '/appsframework/admin/role/page',
};
throw err;
} catch (err) {
throw err;
}
}
// 获取角色详情接口
async getAdminRoleInfo(params) {
try {
const result = await this.axios('get', '/appsframework/admin/role/info', params);
if (result.state === 0) {
return result;
}
const err = {
tip: '获取角色详情失败',
response: result,
data: {
params,
},
url: '/appsframework/admin/role/info',
};
throw err;
} catch (err) {
throw err;
}
}
// 保存角色接口
async getAdminRoleSave(params) {
try {
const result = await this.axios('post', '/appsframework/admin/role/save', params);
if (result.state === 0) {
return result;
}
const err = {
tip: '保存角色失败',
response: result,
data: {
params,
},
url: '/appsframework/admin/role/save',
};
throw err;
} catch (err) {
throw err;
}
}
// 删除角色接口
async delAdminRole(params) {
try {
const result = await this.axios('get', '/appsframework/admin/role/del', params);
if (result.state === 0) {
return result;
}
const err = {
tip: '删除角色失败',
response: result,
data: {
params,
},
url: '/appsframework/admin/role/del',
};
throw err;
} catch (err) {
throw err;
}
}
}
export default new API();