Compare commits

...

12 Commits

Author SHA1 Message Date
ba9bfcbdcc 版本号 2025-03-28 16:23:51 +08:00
c85ee3f425 补充app联合查询 2025-03-28 16:22:29 +08:00
c872318147 update .gitignore 2025-03-18 09:53:24 +08:00
ag
93f5bd0c58 gitignore 2025-03-18 09:38:44 +08:00
ag
d991b2a3e0 性别字段兼容 2025-03-17 16:16:55 +08:00
ag
919709e560 图标库相关修改 2025-02-20 10:46:46 +08:00
ag
8159f97701 cellsysMember.js 新增创建时间和修改时间格式化属性 2025-02-14 11:15:37 +08:00
ag
6ed69a4e8e 当前版本 2025-01-13 14:20:50 +08:00
ag
ae6ec1b4eb 当前版本 2025-01-13 14:11:16 +08:00
ag
fee4985d75 token的获取方式改变 2024-12-27 09:41:41 +08:00
ag
6040224f29 1.15.6 2024-12-26 16:34:50 +08:00
ag
e375b43f22 axios的封装调整 2024-12-26 16:18:03 +08:00
15 changed files with 385 additions and 52 deletions

12
.idea/CellsysBase.iml generated
View File

@ -1,12 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="WEB_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$">
<excludeFolder url="file://$MODULE_DIR$/.tmp" />
<excludeFolder url="file://$MODULE_DIR$/temp" />
<excludeFolder url="file://$MODULE_DIR$/tmp" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

8
.idea/modules.xml generated
View File

@ -1,8 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/CellsysBase.iml" filepath="$PROJECT_DIR$/.idea/CellsysBase.iml" />
</modules>
</component>
</project>

8
.idea/workspace.xml generated
View File

@ -1,8 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="PropertiesComponent">{
&quot;keyToString&quot;: {
&quot;settings.editor.selected.configurable&quot;: &quot;preferences.editor&quot;
}
}</component>
</project>

View File

@ -147,7 +147,7 @@ class CellsysGroup {
_membersParam.push({
_realname: memberObj.realName,
_mobile: memberObj.mobile,
_gender: memberObj.gender,
_gender: String(memberObj.gender),
_email: memberObj.email,
_member_type_name: memberObj.typeName
? memberObj.typeName
@ -210,5 +210,4 @@ class CellsysGroup {
}
}
export default CellsysGroup
export default CellsysGroup;

View File

@ -1,5 +1,5 @@
import Canvg from 'canvg'
import { CellsysType } from './cellsysUtil.js'
import {CellsysType, EditTask, EditType} from './cellsysUtil.js'
class CellsysIcon {
@ -142,6 +142,82 @@ const personStand = {
'data': 'M505.394 231.226c49.548 0 92.49-46.245 92.49-102.4s-42.942-105.703-92.49-105.703-92.49 46.245-92.49 102.4 39.638 105.703 92.49 105.703zm75.974 66.064H429.419c-16.516 0-33.032 6.607-46.245 19.82-13.213 13.213-19.82 33.032-19.82 52.851v214.71c0 39.639 26.427 69.368 59.459 72.67l6.606 3.304v336.93h151.949V657.341h6.606c33.032-3.303 56.155-33.032 59.458-72.671v-214.71c0-39.638-29.729-72.67-66.064-72.67z'
}
/**
* 创建图标
* @param {*} icon
*/
export function saveIcon(icon) {
let editTask = new EditTask(EditType.saveIcon);
editTask.addParam("_name", icon.name);
editTask.addParam("_fill_color", icon.fillColor);
editTask.addParam("_fill_opacity", icon.fillOpacity);
editTask.addParam("_type", icon.type);
editTask.addParam("_tags", icon.tags);
editTask.addParam("_data", icon.data);
editTask.addParam("_rotate", icon.rotate);
return editTask.execute();
}
/**
* 导入图标
* @param {*} cellsysObject
*/
export function importIcons(cellsysObject) {
let editTask = new EditTask(EditType.importIcons),
paramList = []
if (cellsysObject.length > 0) {
cellsysObject.forEach(icon => {
paramList.push({
'_name': icon.name,
'_fill_color': icon.fillColor,
'_fill_opacity': icon.fillOpacity,
'_type': icon.type,
'_tags': icon.tags,
'_data': icon.data,
'_rotate': icon.rotate
})
})
editTask.addParam('_icons', paramList)
}
return editTask.execute()
}
/**
* 更新图标
* @param {*} cellsysObject
*/
export function updateIcon(cellsysObject) {
let editTask = new EditTask(EditType.updateIcon);
editTask.addParam("_icon_id", cellsysObject.id);
editTask.addParam("_id", cellsysObject.id);
editTask.addParam("_name", cellsysObject.name);
editTask.addParam("_fill_color", cellsysObject.fillColor);
editTask.addParam("_fill_opacity", cellsysObject.fillOpacity);
editTask.addParam("_type", cellsysObject.type);
editTask.addParam("_tags", cellsysObject.tags);
editTask.addParam("_data", cellsysObject.data);
return editTask.execute();
}
/**
* 删除图标
* @param {*} cellsysObject
*/
export function deleteIcon(cellsysObject) {
let editTask = new EditTask(EditType.deleteIcon);
editTask.addParam("_id", cellsysObject.id);
return editTask.execute();
}
/**
* 排序图标
* @param {*} data
*/
export function sortIcons(data) {
let editTask = new EditTask(EditType.sortIcon)
editTask.addParam('_icons', data)
return editTask.execute()
}
export default CellsysIcon
export {

View File

@ -1,4 +1,4 @@
import { CellsysType } from './cellsysUtil.js';
import {CellsysType, EditTask, EditType, Query, QueryTask, QueryType} from './cellsysUtil.js';
class CellsysIconType {
constructor(params) {
@ -16,4 +16,47 @@ class CellsysIconType {
}
/**
* 新增图标类型
* @param {*} cellsysObject
*/
export function saveIconType(cellsysObject) {
let editTask = new EditTask(EditType.saveIconType)
editTask.addParam("_name", cellsysObject.name)
editTask.addParam("_sort", cellsysObject.sort)
return editTask.execute()
}
/**
* 更新图标类型
* @param {*} cellsysObject
*/
export function updateIconType(cellsysObject) {
let editTask = new EditTask(EditType.updateIconType)
editTask.addParam("_id", cellsysObject.id)
editTask.addParam("_name", cellsysObject.name)
editTask.addParam("_sort", cellsysObject.sort)
return editTask.execute()
}
/**
* 删除图标类型
* @param {*} cellsysObject
*/
export function deleteIconType(cellsysObject) {
let editTask = new EditTask(EditType.deleteIconType)
editTask.addParam("_id", cellsysObject.id)
return editTask.execute()
}
/**
* 排序图标
* @param {*} data
*/
export function sortIconTypes(data) {
let editTask = new EditTask(EditType.sortIconType)
editTask.addParam('_icon_types', data)
return editTask.execute()
}
export default CellsysIconType

View File

@ -51,7 +51,12 @@ class CellsysMember {
return formatterDate(this.dateTime, 'YYYY-MM-DD HH:mm');
}
}
get createTimeFormat() {
return formatterDate(this.createTime);
}
get updateTimeFormat() {
return formatterDate(this.updateTime);
}
setLeader(value) {
if (value && value === 1) {
this.isLeader = 1;

View File

@ -241,7 +241,7 @@ class CellsysOrg {
editTask.addParam('_username', params.userName);
editTask.addParam('_realname', params.realName);
editTask.addParam('_email', params.email);
editTask.addParam('_gender', params.gender);
editTask.addParam('_gender', String(params.gender));
editTask.addParam('_birthday', params.birthday);
editTask.addParam('_avatar', params.avatar);
editTask.addParam('_is_username', 0);
@ -296,9 +296,9 @@ class CellsysOrg {
/**
* 查询组织内的所有App
*/
queryApps(pageInfo, order, filters) {
queryApps(pageInfo, order, filters,getUnion) {
let query = new Query();
query.addFilter('org_id', Operator.Equals, this.id);
// query.addFilter('org_id', Operator.Equals, this.id);
if (pageInfo) {
query.setCurrPage(pageInfo.currPage);
query.setPageSize(pageInfo.pageSize);
@ -313,7 +313,14 @@ class CellsysOrg {
query.addFilter(item['name'], item['operator'], item['value']);
});
}
let queryTask = new QueryTask(QueryType.App, pageInfo ? true : false);
let queryType=QueryType.App
if (this.unionStatus === 1 && getUnion === true) {
//联合状态为父级组织,并且需要获取联合信息
queryType = QueryType.UnionApp;
} else {
query.setOrder({ org_id: 'asc', id: 'desc' });
}
let queryTask = new QueryTask(queryType, pageInfo ? true : false);
return new Promise((resolve, reject) => {
queryTask
.execute(query)
@ -346,9 +353,9 @@ class CellsysOrg {
* @param order
* @returns {Promise<unknown>}
*/
queryAppListByPublish(pageInfo, filters, order) {
queryAppListByPublish(pageInfo, filters, order,getUnion) {
let query = new Query();
query.addFilter('org_id', Operator.Equals, this.id);
// query.addFilter('org_id', Operator.Equals, this.id);
query.addFilter('is_publish', Operator.Equals, 1);
if (pageInfo) {
query.setCurrPage(pageInfo.currPage);
@ -364,7 +371,14 @@ class CellsysOrg {
query.addFilter(item['name'], item['operator'], item['value']);
});
}
let queryTask = new QueryTask(QueryType.App, pageInfo ? true : false);
let queryType=QueryType.App
if (this.unionStatus === 1 && getUnion === true) {
//联合状态为父级组织,并且需要获取联合信息
queryType = QueryType.UnionApp;
} else {
query.setOrder({ org_id: 'asc', id: 'desc' });
}
let queryTask = new QueryTask(queryType, pageInfo ? true : false);
return new Promise((resolve, reject) => {
queryTask
.execute(query)
@ -805,7 +819,7 @@ class CellsysOrg {
* @param feedback 审核意见
* @returns {function(): Promise<unknown>}
*/
auditJoinOrgMember(params) {
auditJoinOrgMember(params = {}) {
let { userId, audit, feedback, memberTypeId, groudIds } = params;
let editTask = new EditTask(EditType.OrgMember_Update);
let status = audit ? 2 : 3;

View File

@ -1,6 +1,6 @@
import { Query, QueryTask, QueryType } from './cellsysUtil.js';
import './utils/paho-mqtt.js';
import { getToken } from '@/utils/auth';
import cellsysSystem from './cellsysSystem';
let clientManager = {
//全局clinet管理
@ -37,7 +37,7 @@ const TopicType = {
const createMqttClient = (cellsysPush, cellsysTopic) => {
// let clientId = 'cellsys' + (new Date().getTime()) + Math.floor(Math.random() * 100)
let clientId = getToken() + cellsysTopic.topicType + new Date().getTime();
let clientId = cellsysSystem.token + cellsysTopic.topicType + new Date().getTime();
let { ip, port, aliasPath, isSSL, username, password } = cellsysPush;
let client;

View File

@ -13,7 +13,8 @@ import CellsysMemberType from './cellsysMemberType';
class CellsysSystem {
constructor(params) {}
static token = null;
static token = null; //当前token
static adminToken = null; //管理员token
static hostname = null;
//在边缘工作站上查询设备列表
@ -26,6 +27,7 @@ class CellsysSystem {
queryTask
.execute(query)
.then((orgList) => {
debugger;
resolve(orgList);
})
.catch((err) => {

View File

@ -54,6 +54,8 @@ const QueryType = {
UnionMemberTypeUser: '/rpc/view_org_union_member_type_user',
// 门户中App的列表
App: '/rpc/view_org_app_basic', //查询应用基础列表2含原始应用idview_app_basic不含
//查询组织联合的u应用列表
UnionApp: '/rpc/view_org_union_app',
// 应用模板
AppModel: '/rpc/view_app_model',
AppModelType: '/rpc/view_app_model_type',
@ -143,6 +145,7 @@ const QueryType = {
StatsEventCount: '/rpc/view_stats_event_type_count',
Icon: '/rpc/view_icon',
IconType: '/rpc/view_icon_type',
QRCodeList: '/rpc/view_qr_code', //查询二维码列表
BannerType: '/rpc/view_banner_type',
BannerList: '/rpc/view_banner',
@ -377,6 +380,16 @@ const EditType = {
EdgeNameUpdate: '/rpc/UpdateEdgeName',
//更改用户聊天记录已读状态
ChatPrivateRead: '/rpc/cellsysChatPrivateRead',
//图标
importIcons: '/rpc/cellsysIconsInsert',
saveIcon: '/rpc/cellsysIconInsert',
updateIcon: '/rpc/cellsysIconUpdate',
deleteIcon: '/rpc/cellsysIconDelete',
sortIcon: '/rpc/cellsysIconSortUpdate',
saveIconType: '/rpc/cellsysIconTypeInsert',
updateIconType: '/rpc/cellsysIconTypeUpdate',
deleteIconType: '/rpc/cellsysIconTypeDelete',
sortIconType: '/rpc/cellsysIconTypeSortUpdate',
};
// 提交类接口

169
package-lock.json generated
View File

@ -1,15 +1,17 @@
{
"name": "@airkoon/cellsys",
"version": "1.15.1",
"version": "1.15.3",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "@airkoon/cellsys",
"version": "1.15.1",
"version": "1.15.3",
"license": "ISC",
"dependencies": {
"canvg": "~3.0.7"
"axios": "~1.4.0",
"canvg": "~3.0.7",
"dayjs": "~1.10.6"
}
},
"node_modules/@babel/runtime": {
@ -33,6 +35,21 @@
"resolved": "https://registry.npmmirror.com/@types/raf/-/raf-3.4.3.tgz",
"integrity": "sha512-c4YAvMedbPZ5tEyxzQdMoOhhJ4RD3rngZIdwC2/qDN3d7JpEhB6fiBRKVY1lg5B7Wk+uPBjn5f39j1/2MY1oOw=="
},
"node_modules/asynckit": {
"version": "0.4.0",
"resolved": "https://registry.npmmirror.com/asynckit/-/asynckit-0.4.0.tgz",
"integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q=="
},
"node_modules/axios": {
"version": "1.4.0",
"resolved": "https://registry.npmmirror.com/axios/-/axios-1.4.0.tgz",
"integrity": "sha512-S4XCWMEmzvo64T9GfvQDOXgYRDJ/wsSZc7Jvdgx5u1sd0JwsuPLqb3SYmusag+edF6ziyMensPVqLTSc1PiSEA==",
"dependencies": {
"follow-redirects": "^1.15.0",
"form-data": "^4.0.0",
"proxy-from-env": "^1.1.0"
}
},
"node_modules/canvg": {
"version": "3.0.10",
"resolved": "https://registry.npmmirror.com/canvg/-/canvg-3.0.10.tgz",
@ -51,6 +68,17 @@
"node": ">=10.0.0"
}
},
"node_modules/combined-stream": {
"version": "1.0.8",
"resolved": "https://registry.npmmirror.com/combined-stream/-/combined-stream-1.0.8.tgz",
"integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==",
"dependencies": {
"delayed-stream": "~1.0.0"
},
"engines": {
"node": ">= 0.8"
}
},
"node_modules/core-js": {
"version": "3.38.0",
"resolved": "https://registry.npmmirror.com/core-js/-/core-js-3.38.0.tgz",
@ -61,11 +89,80 @@
"url": "https://opencollective.com/core-js"
}
},
"node_modules/dayjs": {
"version": "1.10.8",
"resolved": "https://registry.npmmirror.com/dayjs/-/dayjs-1.10.8.tgz",
"integrity": "sha512-wbNwDfBHHur9UOzNUjeKUOJ0fCb0a52Wx0xInmQ7Y8FstyajiV1NmK1e00cxsr9YrE9r7yAChE0VvpuY5Rnlow=="
},
"node_modules/delayed-stream": {
"version": "1.0.0",
"resolved": "https://registry.npmmirror.com/delayed-stream/-/delayed-stream-1.0.0.tgz",
"integrity": "sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==",
"engines": {
"node": ">=0.4.0"
}
},
"node_modules/follow-redirects": {
"version": "1.15.9",
"resolved": "https://registry.npmmirror.com/follow-redirects/-/follow-redirects-1.15.9.tgz",
"integrity": "sha512-gew4GsXizNgdoRyqmyfMHyAmXsZDk6mHkSxZFCzW9gwlbtOW44CDtYavM+y+72qD/Vq2l550kMF52DT8fOLJqQ==",
"funding": [
{
"type": "individual",
"url": "https://github.com/sponsors/RubenVerborgh"
}
],
"engines": {
"node": ">=4.0"
},
"peerDependenciesMeta": {
"debug": {
"optional": true
}
}
},
"node_modules/form-data": {
"version": "4.0.1",
"resolved": "https://registry.npmmirror.com/form-data/-/form-data-4.0.1.tgz",
"integrity": "sha512-tzN8e4TX8+kkxGPK8D5u0FNmjPUjw3lwC9lSLxxoB/+GtsJG91CO8bSWy73APlgAZzZbXEYZJuxjkHH2w+Ezhw==",
"dependencies": {
"asynckit": "^0.4.0",
"combined-stream": "^1.0.8",
"mime-types": "^2.1.12"
},
"engines": {
"node": ">= 6"
}
},
"node_modules/mime-db": {
"version": "1.52.0",
"resolved": "https://registry.npmmirror.com/mime-db/-/mime-db-1.52.0.tgz",
"integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==",
"engines": {
"node": ">= 0.6"
}
},
"node_modules/mime-types": {
"version": "2.1.35",
"resolved": "https://registry.npmmirror.com/mime-types/-/mime-types-2.1.35.tgz",
"integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==",
"dependencies": {
"mime-db": "1.52.0"
},
"engines": {
"node": ">= 0.6"
}
},
"node_modules/performance-now": {
"version": "2.1.0",
"resolved": "https://registry.npmmirror.com/performance-now/-/performance-now-2.1.0.tgz",
"integrity": "sha512-7EAHlyLHI56VEIdK57uwHdHKIaAGbnXPiw0yWbarQZOKaKpvUIgW0jWRVLiatnM+XXlSwsanIBH/hzGMJulMow=="
},
"node_modules/proxy-from-env": {
"version": "1.1.0",
"resolved": "https://registry.npmmirror.com/proxy-from-env/-/proxy-from-env-1.1.0.tgz",
"integrity": "sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg=="
},
"node_modules/raf": {
"version": "3.4.1",
"resolved": "https://registry.npmmirror.com/raf/-/raf-3.4.1.tgz",
@ -125,6 +222,21 @@
"resolved": "https://registry.npmmirror.com/@types/raf/-/raf-3.4.3.tgz",
"integrity": "sha512-c4YAvMedbPZ5tEyxzQdMoOhhJ4RD3rngZIdwC2/qDN3d7JpEhB6fiBRKVY1lg5B7Wk+uPBjn5f39j1/2MY1oOw=="
},
"asynckit": {
"version": "0.4.0",
"resolved": "https://registry.npmmirror.com/asynckit/-/asynckit-0.4.0.tgz",
"integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q=="
},
"axios": {
"version": "1.4.0",
"resolved": "https://registry.npmmirror.com/axios/-/axios-1.4.0.tgz",
"integrity": "sha512-S4XCWMEmzvo64T9GfvQDOXgYRDJ/wsSZc7Jvdgx5u1sd0JwsuPLqb3SYmusag+edF6ziyMensPVqLTSc1PiSEA==",
"requires": {
"follow-redirects": "^1.15.0",
"form-data": "^4.0.0",
"proxy-from-env": "^1.1.0"
}
},
"canvg": {
"version": "3.0.10",
"resolved": "https://registry.npmmirror.com/canvg/-/canvg-3.0.10.tgz",
@ -140,16 +252,67 @@
"svg-pathdata": "^6.0.3"
}
},
"combined-stream": {
"version": "1.0.8",
"resolved": "https://registry.npmmirror.com/combined-stream/-/combined-stream-1.0.8.tgz",
"integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==",
"requires": {
"delayed-stream": "~1.0.0"
}
},
"core-js": {
"version": "3.38.0",
"resolved": "https://registry.npmmirror.com/core-js/-/core-js-3.38.0.tgz",
"integrity": "sha512-XPpwqEodRljce9KswjZShh95qJ1URisBeKCjUdq27YdenkslVe7OO0ZJhlYXAChW7OhXaRLl8AAba7IBfoIHug=="
},
"dayjs": {
"version": "1.10.8",
"resolved": "https://registry.npmmirror.com/dayjs/-/dayjs-1.10.8.tgz",
"integrity": "sha512-wbNwDfBHHur9UOzNUjeKUOJ0fCb0a52Wx0xInmQ7Y8FstyajiV1NmK1e00cxsr9YrE9r7yAChE0VvpuY5Rnlow=="
},
"delayed-stream": {
"version": "1.0.0",
"resolved": "https://registry.npmmirror.com/delayed-stream/-/delayed-stream-1.0.0.tgz",
"integrity": "sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ=="
},
"follow-redirects": {
"version": "1.15.9",
"resolved": "https://registry.npmmirror.com/follow-redirects/-/follow-redirects-1.15.9.tgz",
"integrity": "sha512-gew4GsXizNgdoRyqmyfMHyAmXsZDk6mHkSxZFCzW9gwlbtOW44CDtYavM+y+72qD/Vq2l550kMF52DT8fOLJqQ=="
},
"form-data": {
"version": "4.0.1",
"resolved": "https://registry.npmmirror.com/form-data/-/form-data-4.0.1.tgz",
"integrity": "sha512-tzN8e4TX8+kkxGPK8D5u0FNmjPUjw3lwC9lSLxxoB/+GtsJG91CO8bSWy73APlgAZzZbXEYZJuxjkHH2w+Ezhw==",
"requires": {
"asynckit": "^0.4.0",
"combined-stream": "^1.0.8",
"mime-types": "^2.1.12"
}
},
"mime-db": {
"version": "1.52.0",
"resolved": "https://registry.npmmirror.com/mime-db/-/mime-db-1.52.0.tgz",
"integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg=="
},
"mime-types": {
"version": "2.1.35",
"resolved": "https://registry.npmmirror.com/mime-types/-/mime-types-2.1.35.tgz",
"integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==",
"requires": {
"mime-db": "1.52.0"
}
},
"performance-now": {
"version": "2.1.0",
"resolved": "https://registry.npmmirror.com/performance-now/-/performance-now-2.1.0.tgz",
"integrity": "sha512-7EAHlyLHI56VEIdK57uwHdHKIaAGbnXPiw0yWbarQZOKaKpvUIgW0jWRVLiatnM+XXlSwsanIBH/hzGMJulMow=="
},
"proxy-from-env": {
"version": "1.1.0",
"resolved": "https://registry.npmmirror.com/proxy-from-env/-/proxy-from-env-1.1.0.tgz",
"integrity": "sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg=="
},
"raf": {
"version": "3.4.1",
"resolved": "https://registry.npmmirror.com/raf/-/raf-3.4.1.tgz",

View File

@ -1,13 +1,15 @@
{
"name": "@airkoon/cellsys",
"version": "1.15.3",
"description": "边缘服务器相关",
"version": "1.16.4",
"description": "边缘服务器和cloud的公共库",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "gui",
"license": "ISC",
"dependencies": {
"canvg": "~3.0.7"
"canvg": "~3.0.7",
"axios": "~1.4.0",
"dayjs": "~1.10.6"
}
}

View File

@ -1,4 +1,6 @@
import axios from 'axios';
import { AdminQueryType } from '../cellsysUtil';
import cellsysSystem from '../cellsysSystem';
const service = axios.create({
baseURL: '/api', //api 的 base_url根据开发生产环境配置文件配置
@ -10,6 +12,48 @@ const service = axios.create({
responseType: 'json',
});
service.interceptors.request.use(
(config) => {
let url = config.url;
let token = cellsysSystem.token;
if (AdminQueryType.indexOf(url) !== -1) {
//这里应该再加一层用户身份判断才是正确的写法
token = cellsysSystem.adminToken;
}
if (token && !config.headers['Authorization']) {
config.headers['Authorization'] = 'Bearer ' + token;
}
return config;
},
(error) => {
console.error(error);
return Promise.reject(error);
},
);
//这里需要注意的是由于历史原因axios的response的成功回调格式是在本文件中封装而失败回调的格式是在引用CellsysBase的项目中按需进行封装。
service.interceptors.response.use(
(response) => {
let data;
if (response.data === undefined || response.data == null) {
switch (response.status) {
case 201:
data = { code: 201 };
break;
default:
data = { code: 200 };
break;
}
} else {
data = response.data;
}
return data;
},
(err) => {
return Promise.reject(err);
},
);
const post = (url, data, config) => {
return service.post(url, data, config);
};