diff --git a/src/api/Category/index.js b/src/api/Category/index.js deleted file mode 100644 index 1612800..0000000 --- a/src/api/Category/index.js +++ /dev/null @@ -1,38 +0,0 @@ -// * @Author: h7ml -// * @Date: 2021-08-16 12:07:36 -// * @LastEditors: h7ml -// * @LastEditTime: 2021-08-16 12:07:36 -// * @Description: Category api -// * @FilePath: src\api\Category\index.js -// * @DocumentLink: http://prod.iotn2n.com/swagger/#/category -import request from '@/utils/request/request' -import { - create_object, - del_object, - get_object, - update_object, -} from '@/api/Parse' - -export async function queryCategory(params) { - return request({ - url: `/classes/Category`, - method: 'get', - params: params, - }) -} - -export async function getCategory(ObjectId) { - return get_object('Category', ObjectId) -} - -export async function delCategory(ObjectId) { - return del_object('Category', ObjectId) -} - -export async function putCategory(ObjectId, params) { - return update_object('Category', ObjectId, params) -} - -export async function postCategory(params) { - return create_object('Category', params) -} diff --git a/src/api/Exproto/index.js b/src/api/Exproto/index.js deleted file mode 100644 index 6574b18..0000000 --- a/src/api/Exproto/index.js +++ /dev/null @@ -1,41 +0,0 @@ -/* - * @Author: h7ml - * @Date: 2021-03-18 10:18:03 - * @LastEditTime: 2021-03-18 10:19:01 - * @LastEditors: h7ml - * @FilePath: \dgiot-dashboard\src\api\Exproto\index.js - * @Description:拓展编程api整合 - */ -import request from '@/utils/request/request' - -export async function getExproto(params) { - return request({ - url: 'exproto', - method: 'get', - params: params, - }) -} - -export async function delExproto(params) { - return request({ - url: 'exproto', - method: 'DELETE', - params: params, - }) -} - -export async function putExproto(data) { - return request({ - url: 'exproto', - method: 'put', - data: data, - }) -} - -export async function postExproto(params) { - return request({ - url: 'release_exproto', - method: 'post', - params: params, - }) -} diff --git a/src/api/Group/index.js b/src/api/Group/index.js deleted file mode 100644 index e228df8..0000000 --- a/src/api/Group/index.js +++ /dev/null @@ -1,50 +0,0 @@ -import { - create_object, - del_object, - get_object, - query_object, - update_object, -} from '@/api/Parse' -import request from '@/utils/request/request' - -// 获取虚拟设备分组 -/** - * <<"nodeType">> => 0 是设备,<<"nodeType">> => 1 是网关,<<"nodeType">> => 2 是虚拟分组 - */ -export async function queryGroup(params) { - params = { - where: { - nodeType: 2, - }, - } - return query_object('Product', params) -} - -export async function getGroup(ObjectId) { - return get_object('Product', ObjectId) -} - -export async function delGroup(ObjectId) { - return del_object('Product', ObjectId) -} - -export async function putGroup(ObjectId, params) { - return update_object('Product', ObjectId, params) -} - -export async function postGroup(params) { - return create_object('Product', params) -} - -// 新建虚拟设备分组 -export function addGroup(name) { - return request({ - url: 'group', - method: 'post', - data: { - devType: 'dgiot_hub', - name: name, - topo: 'group_topo', - }, - }) -} diff --git a/src/api/Logs/index.js b/src/api/Logs/index.js deleted file mode 100644 index 7ef264e..0000000 --- a/src/api/Logs/index.js +++ /dev/null @@ -1,93 +0,0 @@ -// * @Author: h7ml -// * @Date: 2021-08-24 10:02:54 -// * @LastEditors: -// * @LastEditTime: 2021-8-26 17:51:56 -// * @Description: -// * @FilePath: src\api\LogLevel\index.js -// * @DocumentLink: http://prod.iotn2n.com/swagger/#/LogLevel -import { - create_object, - del_object, - query_object, - update_object, -} from '@/api/Parse' -import request from '@/utils/request/request' - -/** - * @description: 获取类树 - * @docsLink: http://localhost:5080/dgiot_swagger/#/Data/post_tree - * @param params - * @returns {Promise<*>} - */ -export async function post_tree(params) { - return request({ - url: 'tree', - method: 'post', - data: params, - }) -} - -/** - * @document http://prod.iotn2n.com/swagger/#/System/get_log_level - * @param params - * @return {Promise<*>} - */ -export async function getLogLevel(params) { - return request({ - url: 'log/level', - method: 'get', - params, - }) -} - -/** - * @document http://prod.iotn2n.com/swagger/#/System/put_log_level - * @param params - * @return {Promise<*>} - */ -export async function putLogLevel(params) { - return request({ - url: 'log/level', - method: 'put', - data: params, - }) -} - -/** - * @document http://114.117.171.233/swagger/#/System/get_traces - * @return {Promise<*>} - */ -export async function getTraces() { - return request({ - url: 'tree', - method: 'get', - }) -} - -/** - * @document http://114.117.171.233/swagger/#/System/post_traces - * @return {Promise<*>} - */ -export async function actionTraces(params) { - return request({ - url: 'tree', - method: 'post', - data: params, - }) -} - -export async function queryLog(params) { - return query_object('Log', params) -} - -export async function postIndustry(params) { - return create_object('LogLevel', params) -} - -export async function delIndustry(ObjectId) { - return del_object('LogLevel', ObjectId) -} - -export async function updateIndustry(ObjectId, params) { - return update_object('LogLevel', ObjectId, params) -} diff --git a/src/api/MasterData/index.js b/src/api/MasterData/index.js deleted file mode 100644 index 697e359..0000000 --- a/src/api/MasterData/index.js +++ /dev/null @@ -1,43 +0,0 @@ -// - -import request from '@/utils/request/request' -import { - create_object, - del_object, - get_object, - update_object, - query_object, -} from '@/api/Parse' - -export async function queryMasterData(params) { - return request({ - url: `/classes/MasterData`, - method: 'get', - params: params, - }) - // return query_object('MasterData', params) -} - -export async function getMasterData(ObjectId) { - return get_object('MasterData', ObjectId) -} - -export async function delMasterData(ObjectId) { - return del_object('MasterData', ObjectId) -} - -export async function putMasterData(ObjectId, params) { - return update_object('MasterData', ObjectId, params) -} - -export async function postMasterData(params) { - return create_object('MasterData', params) -} diff --git a/src/api/MetaData/index.js b/src/api/MetaData/index.js deleted file mode 100644 index 1079021..0000000 --- a/src/api/MetaData/index.js +++ /dev/null @@ -1,50 +0,0 @@ -// - -import request from '@/utils/request/request' -import { - create_object, - del_object, - get_object, - update_object, - query_object, -} from '@/api/Parse' - -export async function queryMaterial(params) { - return request({ - url: `/material`, - method: 'get', - params: params, - }) -} -export async function queryMetaData(params) { - return request({ - url: `/classes/MetaData`, - method: 'get', - params: params, - }) - // return query_object('MetaData', params) -} - -export async function getMetaData(ObjectId) { - return get_object('MetaData', ObjectId) -} - -export async function delMetaData(ObjectId) { - return del_object('MetaData', ObjectId) -} - -export async function putMetaData(ObjectId, params) { - return update_object('MetaData', ObjectId, params) -} - -export async function postMetaData(params) { - return create_object('MetaData', params) -} diff --git a/src/api/Modeling/index.js b/src/api/Modeling/index.js deleted file mode 100644 index 79075d1..0000000 --- a/src/api/Modeling/index.js +++ /dev/null @@ -1,57 +0,0 @@ -// - -import request from '@/utils/request/request' -import { - create_object, - del_object, - get_object, - update_object, - query_object, -} from '@/api/Parse' - -export async function queryRoleTree() { - return request({ - url: `/roletree`, - method: 'get', - // params: params, - }) - // return query_object('MetaData', params) -} -//iotapi/classes/Dict -export async function queryDictTemp(params) { - return request({ - url: `/classes/Dict`, - method: 'get', - params: params, - }) - // return query_object('MetaData', params) -} - -// export async function getMetaData(ObjectId) { -// return get_object('MetaData', ObjectId) -// } - -// export async function delMetaData(ObjectId) { -// return del_object('MetaData', ObjectId) -// } - -// export async function putMetaData(ObjectId, params) { -// return update_object('MetaData', ObjectId, params) -// } - -export async function postRole(params) { - return request({ - url: `/role`, - method: 'post', - data: params, - }) - // return create_object('role', params) -} diff --git a/src/api/Opc/index.js b/src/api/Opc/index.js deleted file mode 100644 index 379af9d..0000000 --- a/src/api/Opc/index.js +++ /dev/null @@ -1,26 +0,0 @@ -// * @Author: dext7r -// * @Date: 2021-12-16 21:35:04 -// * @LastEditors: dext7r -// * @LastEditTime: 2021-12-16 21:35:04 -// * @Description: -// * @FilePath: src\api\Opc\index.js -// * @DocumentLink: http://prod.iotn2n.com/dgiot_swagger/#/OPC -import request from '@/utils/request/request' - -/** - * @docs-api http://prod.iotn2n.com/dgiot_swagger/#/OPC/post_head - * @param data - * @return {Promise<*>} - * @description 获取表头 - */ -export async function postHead(data) { - return request({ - url: 'head', - method: 'post', - headers: { - accept: 'application/json', - 'Content-Type': 'application/json', - }, - data: data, - }) -} diff --git a/src/api/Platform/index.js b/src/api/Platform/index.js deleted file mode 100644 index 0676a2d..0000000 --- a/src/api/Platform/index.js +++ /dev/null @@ -1,127 +0,0 @@ -/* - * @Author: h7ml - * @Date: 2021-03-01 10:03:27 - * @LastEditTime: 2021-03-01 10:22:52 - * @LastEditors: Please set LastEditors - * @Description: In User Settings Edit - * @FilePath: \dgiot-dashboard\src\api\Platform\index.js - */ -import request from '@/utils/request/request' - -export async function Project_count(params) { - return request({ - url: '/classes/Project', - method: 'get', - headers: { - accept: 'application/json', - 'Content-Type': 'application/json', - }, - params: params, - }) -} - -export async function product_count(params) { - return request({ - url: '/classes/Product', - method: 'get', - headers: { - accept: 'application/json', - 'Content-Type': 'application/json', - }, - params: params, - }) -} - -export async function app_count(params) { - return request({ - url: '/classes/App', - method: 'get', - headers: { - accept: 'application/json', - 'Content-Type': 'application/json', - }, - params: params, - }) -} - -export async function dev_count(params) { - return request({ - url: '/classes/Device', - method: 'get', - headers: { - accept: 'application/json', - 'Content-Type': 'application/json', - }, - params: params, - }) -} - -export async function dev_active_count(params) { - return request({ - url: '/classes/Device', - method: 'get', - headers: { - accept: 'application/json', - 'Content-Type': 'application/json', - }, - params: params, - }) -} - -export async function dev_online_count(params) { - return request({ - url: '/classes/Device', - method: 'get', - headers: { - accept: 'application/json', - 'Content-Type': 'application/json', - }, - params: params, - }) -} - -/** - * 新建报告模板 - * @param {*} data - * @returns - */ -export async function cereteReport(data) { - return request({ - url: '/reportTemp', - method: 'post', - headers: { - accept: 'application/json', - 'Content-Type': 'multipart/form-data', - }, - data: data, - }) -} - -/** - * 上传报告模板文件 - * @param {*} data - * @returns - */ -export async function postReportFile(formData) { - return request({ - url: '/reportTemp', - method: 'post', - headers: { - 'Content-Type': 'multipart/form-data', - }, - data: formData, - }) -} - -/** - * 修好报告模板文件 - * @param {*} data - * @returns - */ -export async function putReportFile(data) { - return request({ - url: '/reportTemp', - method: 'put', - data: data, - }) -} diff --git a/src/components/Device/deviceState.vue b/src/components/Device/deviceState.vue deleted file mode 100644 index 4f78059..0000000 --- a/src/components/Device/deviceState.vue +++ /dev/null @@ -1,95 +0,0 @@ - - - diff --git a/src/components/Device/info.vue b/src/components/Device/info.vue deleted file mode 100644 index a5a43e3..0000000 --- a/src/components/Device/info.vue +++ /dev/null @@ -1,188 +0,0 @@ - - - diff --git a/src/dgiot/components/DgiotChart/index.vue b/src/dgiot/components/DgiotChart/index.vue deleted file mode 100644 index 2867597..0000000 --- a/src/dgiot/components/DgiotChart/index.vue +++ /dev/null @@ -1,315 +0,0 @@ - - - - diff --git a/src/dgiot/components/DgiotClientsBasic/index.vue b/src/dgiot/components/DgiotClientsBasic/index.vue deleted file mode 100644 index 06ff471..0000000 --- a/src/dgiot/components/DgiotClientsBasic/index.vue +++ /dev/null @@ -1,316 +0,0 @@ - - - - - diff --git a/src/dgiot/components/DgiotClientsSubscriptions/index.vue b/src/dgiot/components/DgiotClientsSubscriptions/index.vue deleted file mode 100644 index fb35781..0000000 --- a/src/dgiot/components/DgiotClientsSubscriptions/index.vue +++ /dev/null @@ -1,229 +0,0 @@ - - - - - diff --git a/src/dgiot/components/DgiotDialog/index.vue b/src/dgiot/components/DgiotDialog/index.vue deleted file mode 100644 index d9269f2..0000000 --- a/src/dgiot/components/DgiotDialog/index.vue +++ /dev/null @@ -1,120 +0,0 @@ - - - - diff --git a/src/dgiot/components/DgiotEmqSelect/index.vue b/src/dgiot/components/DgiotEmqSelect/index.vue deleted file mode 100644 index 6237f84..0000000 --- a/src/dgiot/components/DgiotEmqSelect/index.vue +++ /dev/null @@ -1,125 +0,0 @@ - - - diff --git a/src/dgiot/components/DgiotErrorLog/index.vue b/src/dgiot/components/DgiotErrorLog/index.vue deleted file mode 100644 index 5dfb466..0000000 --- a/src/dgiot/components/DgiotErrorLog/index.vue +++ /dev/null @@ -1,169 +0,0 @@ - - - - - diff --git a/src/dgiot/components/DgiotHeader/index.vue b/src/dgiot/components/DgiotHeader/index.vue index 65c7a10..c750e00 100644 --- a/src/dgiot/components/DgiotHeader/index.vue +++ b/src/dgiot/components/DgiotHeader/index.vue @@ -29,14 +29,6 @@ v-show="isDeptShow" :title="$translateTitle(`home.department switch`)" /> - -
- - -
- {{ title }} -
- {{ $translateTitle('alert.For details, please refer to') }} - - - - - - - - - - {{ $translateTitle('alert.Documentation') }} - - -
- -
-
-
- - - - - diff --git a/src/dgiot/components/DgiotLanguage/index.vue b/src/dgiot/components/DgiotLanguage/index.vue deleted file mode 100644 index d1c4799..0000000 --- a/src/dgiot/components/DgiotLanguage/index.vue +++ /dev/null @@ -1,53 +0,0 @@ - - - - - diff --git a/src/dgiot/components/DgiotNav/index.vue b/src/dgiot/components/DgiotNav/index.vue index c633c4f..d7164c3 100644 --- a/src/dgiot/components/DgiotNav/index.vue +++ b/src/dgiot/components/DgiotNav/index.vue @@ -37,7 +37,7 @@ - + diff --git a/src/dgiot/components/DgiotPlayer/index.vue b/src/dgiot/components/DgiotPlayer/index.vue deleted file mode 100644 index f83a1b6..0000000 --- a/src/dgiot/components/DgiotPlayer/index.vue +++ /dev/null @@ -1,165 +0,0 @@ - - - - - diff --git a/src/dgiot/components/DgiotPuzzle/index.vue b/src/dgiot/components/DgiotPuzzle/index.vue deleted file mode 100644 index 0d6fc57..0000000 --- a/src/dgiot/components/DgiotPuzzle/index.vue +++ /dev/null @@ -1,870 +0,0 @@ - - - diff --git a/src/dgiot/components/DgiotPuzzle/reset.png b/src/dgiot/components/DgiotPuzzle/reset.png deleted file mode 100644 index d655240..0000000 Binary files a/src/dgiot/components/DgiotPuzzle/reset.png and /dev/null differ diff --git a/src/dgiot/components/DgiotQqMap/components/DgiotQqMapSelectPoint.vue b/src/dgiot/components/DgiotQqMap/components/DgiotQqMapSelectPoint.vue deleted file mode 100644 index aaa0155..0000000 --- a/src/dgiot/components/DgiotQqMap/components/DgiotQqMapSelectPoint.vue +++ /dev/null @@ -1,266 +0,0 @@ - - - - - diff --git a/src/dgiot/components/DgiotQqMap/index.vue b/src/dgiot/components/DgiotQqMap/index.vue deleted file mode 100644 index 9e8241e..0000000 --- a/src/dgiot/components/DgiotQqMap/index.vue +++ /dev/null @@ -1,72 +0,0 @@ - - - diff --git a/src/dgiot/components/DgiotQrcode/index.vue b/src/dgiot/components/DgiotQrcode/index.vue deleted file mode 100644 index 741680f..0000000 --- a/src/dgiot/components/DgiotQrcode/index.vue +++ /dev/null @@ -1,146 +0,0 @@ - - - - diff --git a/src/dgiot/components/DgiotRequire/index.vue b/src/dgiot/components/DgiotRequire/index.vue deleted file mode 100644 index e326b62..0000000 --- a/src/dgiot/components/DgiotRequire/index.vue +++ /dev/null @@ -1,63 +0,0 @@ - - - diff --git a/src/dgiot/components/DgiotSlider/index.vue b/src/dgiot/components/DgiotSlider/index.vue deleted file mode 100644 index 4717a94..0000000 --- a/src/dgiot/components/DgiotSlider/index.vue +++ /dev/null @@ -1,172 +0,0 @@ - - - diff --git a/src/dgiot/components/DgiotSourceCode/index.vue b/src/dgiot/components/DgiotSourceCode/index.vue deleted file mode 100644 index 75ddfe2..0000000 --- a/src/dgiot/components/DgiotSourceCode/index.vue +++ /dev/null @@ -1,61 +0,0 @@ - - - - - diff --git a/src/dgiot/components/DgiotTable/index.vue b/src/dgiot/components/DgiotTable/index.vue deleted file mode 100644 index 20e2804..0000000 --- a/src/dgiot/components/DgiotTable/index.vue +++ /dev/null @@ -1,114 +0,0 @@ - - diff --git a/src/utils/file/excel.js b/src/utils/file/excel.js deleted file mode 100644 index e874a64..0000000 --- a/src/utils/file/excel.js +++ /dev/null @@ -1,220 +0,0 @@ -// import { saveAs } from 'file-saver' -// import XLSX from 'xlsx' - -function generateArray(table) { - let out = [] - let rows = table.querySelectorAll('tr') - let ranges = [] - for (let R = 0; R < rows.length; ++R) { - let outRow = [] - let row = rows[R] - let columns = row.querySelectorAll('td') - for (let C = 0; C < columns.length; ++C) { - let cell = columns[C] - let colspan = cell.getAttribute('colspan') - let rowspan = cell.getAttribute('rowspan') - let cellValue = cell.innerText - if (cellValue !== '' && cellValue === +cellValue) cellValue = +cellValue - - ranges.forEach(function (range) { - if ( - R >= range.s.r && - R <= range.e.r && - outRow.length >= range.s.c && - outRow.length <= range.e.c - ) { - for (let i = 0; i <= range.e.c - range.s.c; ++i) outRow.push(null) - } - }) - - if (rowspan || colspan) { - rowspan = rowspan || 1 - colspan = colspan || 1 - ranges.push({ - s: { - r: R, - c: outRow.length, - }, - e: { - r: R + rowspan - 1, - c: outRow.length + colspan - 1, - }, - }) - } - - outRow.push(cellValue !== '' ? cellValue : null) - - if (colspan) for (let k = 0; k < colspan - 1; ++k) outRow.push(null) - } - out.push(outRow) - } - return [out, ranges] -} - -function datenum(v, date1904) { - if (date1904) v += 1462 - let epoch = Date.parse(v) - return (epoch - new Date(Date.UTC(1899, 11, 30))) / (24 * 60 * 60 * 1000) -} - -function sheet_from_array_of_arrays(data) { - let ws = {} - let range = { - s: { - c: 10000000, - r: 10000000, - }, - e: { - c: 0, - r: 0, - }, - } - for (let R = 0; R !== data.length; ++R) { - for (let C = 0; C !== data[R].length; ++C) { - if (range.s.r > R) range.s.r = R - if (range.s.c > C) range.s.c = C - if (range.e.r < R) range.e.r = R - if (range.e.c < C) range.e.c = C - let cell = { - v: data[R][C], - } - if (cell.v == null) continue - let cell_ref = XLSX.utils.encode_cell({ - c: C, - r: R, - }) - - if (typeof cell.v === 'number') { - cell.t = 'n' - } else if (typeof cell.v === 'boolean') { - cell.t = 'b' - } else if (cell.v instanceof Date) { - cell.t = 'n' - cell.z = XLSX.SSF._table[14] - cell.v = datenum(cell.v) - } else { - cell.t = 's' - } - - ws[cell_ref] = cell - } - } - if (range.s.c < 10000000) ws['!ref'] = XLSX.utils.encode_range(range) - return ws -} - -function Workbook() { - if (!(this instanceof Workbook)) return new Workbook() - this.SheetNames = [] - this.Sheets = {} -} - -function s2ab(s) { - let buf = new ArrayBuffer(s.length) - let view = new Uint8Array(buf) - for (let i = 0; i !== s.length; ++i) view[i] = s.charCodeAt(i) & 0xff - return buf -} - -export function export_table_to_excel(id) { - let theTable = document.getElementById(id) - let oo = generateArray(theTable) - let ranges = oo[1] - - let data = oo[0] - let ws_name = 'SheetJS' - - let wb = new Workbook(), - ws = sheet_from_array_of_arrays(data) - - ws['!merges'] = ranges - - wb.SheetNames.push(ws_name) - wb.Sheets[ws_name] = ws - - let wbout = XLSX.write(wb, { - bookType: 'xlsx', - bookSST: false, - type: 'binary', - }) - - saveAs( - new Blob([s2ab(wbout)], { - type: 'application/octet-stream', - }), - 'test.xlsx' - ) -} - -export function export_json_to_excel({ - multiHeader = [], - header, - data, - filename, - merges = [], - autoWidth = true, - bookType = 'xlsx', -} = {}) { - filename = filename || 'excel-list' - data = [...data] - data.unshift(header) - - for (let i = multiHeader.length - 1; i > -1; i--) { - data.unshift(multiHeader[i]) - } - - let ws_name = 'SheetJS' - let wb = new Workbook(), - ws = sheet_from_array_of_arrays(data) - - if (merges.length > 0) { - if (!ws['!merges']) ws['!merges'] = [] - merges.forEach((item) => { - ws['!merges'].push(XLSX.utils.decode_range(item)) - }) - } - - if (autoWidth) { - const colWidth = data.map((row) => - row.map((val) => { - if (val == null) { - return { - wch: 10, - } - } else if (val.toString().charCodeAt(0) > 255) { - return { - wch: val.toString().length * 2, - } - } else { - return { - wch: val.toString().length, - } - } - }) - ) - let result = colWidth[0] - for (let i = 1; i < colWidth.length; i++) { - for (let j = 0; j < colWidth[i].length; j++) { - if (result[j]['wch'] < colWidth[i][j]['wch']) { - result[j]['wch'] = colWidth[i][j]['wch'] - } - } - } - ws['!cols'] = result - } - - wb.SheetNames.push(ws_name) - wb.Sheets[ws_name] = ws - - let wbout = XLSX.write(wb, { - bookType: bookType, - bookSST: false, - type: 'binary', - }) - saveAs( - new Blob([s2ab(wbout)], { - type: 'application/octet-stream', - }), - `${filename}.${bookType}` - ) -} diff --git a/src/utils/file/export2zip.js b/src/utils/file/export2zip.js deleted file mode 100644 index 4b36f60..0000000 --- a/src/utils/file/export2zip.js +++ /dev/null @@ -1,31 +0,0 @@ -/* - * @Author: h7ml - * @Date: 2021-03-11 12:41:30 - * @LastEditTime: 2021-03-11 17:55:38 - * @LastEditors: h7ml - * @FilePath: \dgiot-dashboard\src\utils\export2zip.js - * @Description: - */ -// require('script-loader!file-saver') -// import JSZip from 'jszip' -function export_txt_to_zip(jsonData, jsonName, zipName) { - const zip = new JSZip() - const txt_name = jsonName || 'file' - const zip_name = zipName || 'file' - zip.file(`${txt_name}.json`, jsonData) - zip - .generateAsync({ - type: 'blob', - }) - .then( - (blob) => { - saveAs(blob, `${zip_name}.zip`) - }, - (err) => { - dgiotlog.log(err) - alert('导出失败') - } - ) -} - -export { export_txt_to_zip } diff --git a/src/utils/file/file.js b/src/utils/file/file.js deleted file mode 100644 index f89484e..0000000 --- a/src/utils/file/file.js +++ /dev/null @@ -1,17 +0,0 @@ -// import requirefile from '@/utils/file/requirefile' -// const FileModule = requirefile(require.context('./File', true, /.js$/)) -// dgiotlog.log(FileModule, 'FileModule') -// module.exports = { -// ...FileModule, -// } - -const modulesFiles = require.context('../file', true, /.js$/) -const modules = modulesFiles.keys().reduce((modules, modulePath) => { - const moduleName = modulePath.replace(/^.\/(.*)\.js/, '$1') - const value = modulesFiles(modulePath) - modules[moduleName] = value.default - return modules -}, {}) -module.exports = { - ...modules, -} diff --git a/src/utils/file/gif.js b/src/utils/file/gif.js deleted file mode 100644 index 191e3eb..0000000 --- a/src/utils/file/gif.js +++ /dev/null @@ -1,364 +0,0 @@ -// Generic functions -/* eslint-disable */ -var bitsToNum = function (ba) { - return ba.reduce(function (s, n) { - return s * 2 + n - }, 0) -} - -var byteToBitArr = function (bite) { - var a = [] - for (var i = 7; i >= 0; i--) { - a.push(!!(bite & (1 << i))) - } - return a -} - -// Stream -/** - * @constructor - */ // Make compiler happy. -var Stream = function (data) { - this.data = data - this.len = this.data.length - this.pos = 0 - - this.readByte = function () { - if (this.pos >= this.data.length) { - throw new Error('Attempted to read past end of stream.') - } - return data.charCodeAt(this.pos++) & 0xff - } - - this.readBytes = function (n) { - var bytes = [] - for (var i = 0; i < n; i++) { - bytes.push(this.readByte()) - } - return bytes - } - - this.read = function (n) { - var s = '' - for (var i = 0; i < n; i++) { - s += String.fromCharCode(this.readByte()) - } - return s - } - - this.readUnsigned = function () { - // Little-endian. - var a = this.readBytes(2) - return (a[1] << 8) + a[0] - } -} - -var lzwDecode = function (minCodeSize, data) { - // TODO: Now that the GIF parser is a bit different, maybe this should get an array of bytes instead of a String? - var pos = 0 // Maybe this streaming thing should be merged with the Stream? - - var readCode = function (size) { - var code = 0 - for (var i = 0; i < size; i++) { - if (data.charCodeAt(pos >> 3) & (1 << (pos & 7))) { - code |= 1 << i - } - pos++ - } - return code - } - - var output = [] - - var clearCode = 1 << minCodeSize - var eoiCode = clearCode + 1 - - var codeSize = minCodeSize + 1 - - var dict = [] - - var clear = function () { - dict = [] - codeSize = minCodeSize + 1 - for (var i = 0; i < clearCode; i++) { - dict[i] = [i] - } - dict[clearCode] = [] - dict[eoiCode] = null - } - - var code - var last - - while (true) { - last = code - code = readCode(codeSize) - - if (code === clearCode) { - clear() - continue - } - if (code === eoiCode) break - - if (code < dict.length) { - if (last !== clearCode) { - dict.push(dict[last].concat(dict[code][0])) - } - } else { - if (code !== dict.length) throw new Error('Invalid LZW code.') - dict.push(dict[last].concat(dict[last][0])) - } - output.push.apply(output, dict[code]) - - if (dict.length === 1 << codeSize && codeSize < 12) { - // If we're at the last code and codeSize is 12, the next code will be a clearCode, and it'll be 12 bits long. - codeSize++ - } - } - - // I don't know if this is technically an error, but some GIFs do it. - //if (Math.ceil(pos / 8) !== data.length) throw new Error('Extraneous LZW bytes.'); - return output -} - -// The actual parsing; returns an object with properties. -var parseGIF = function (st, handler) { - handler || (handler = {}) - - // LZW (GIF-specific) - var parseCT = function (entries) { - // Each entry is 3 bytes, for RGB. - var ct = [] - for (var i = 0; i < entries; i++) { - ct.push(st.readBytes(3)) - } - return ct - } - - var readSubBlocks = function () { - var size, data - data = '' - do { - size = st.readByte() - data += st.read(size) - } while (size !== 0) - return data - } - - var parseHeader = function () { - var hdr = {} - hdr.sig = st.read(3) - hdr.ver = st.read(3) - if (hdr.sig !== 'GIF') throw new Error('Not a GIF file.') // XXX: This should probably be handled more nicely. - - hdr.width = st.readUnsigned() - hdr.height = st.readUnsigned() - - var bits = byteToBitArr(st.readByte()) - hdr.gctFlag = bits.shift() - hdr.colorRes = bitsToNum(bits.splice(0, 3)) - hdr.sorted = bits.shift() - hdr.gctSize = bitsToNum(bits.splice(0, 3)) - - hdr.bgColor = st.readByte() - hdr.pixelAspectRatio = st.readByte() // if not 0, aspectRatio = (pixelAspectRatio + 15) / 64 - - if (hdr.gctFlag) { - hdr.gct = parseCT(1 << (hdr.gctSize + 1)) - } - handler.hdr && handler.hdr(hdr) - } - - var parseExt = function (block) { - var parseGCExt = function (block) { - var blockSize = st.readByte() // Always 4 - - var bits = byteToBitArr(st.readByte()) - block.reserved = bits.splice(0, 3) // Reserved; should be 000. - block.disposalMethod = bitsToNum(bits.splice(0, 3)) - block.userInput = bits.shift() - block.transparencyGiven = bits.shift() - - block.delayTime = st.readUnsigned() - - block.transparencyIndex = st.readByte() - - block.terminator = st.readByte() - - handler.gce && handler.gce(block) - } - - var parseComExt = function (block) { - block.comment = readSubBlocks() - handler.com && handler.com(block) - } - - var parsePTExt = function (block) { - // No one *ever* uses this. If you use it, deal with parsing it yourself. - var blockSize = st.readByte() // Always 12 - block.ptHeader = st.readBytes(12) - block.ptData = readSubBlocks() - handler.pte && handler.pte(block) - } - - var parseAppExt = function (block) { - var parseNetscapeExt = function (block) { - var blockSize = st.readByte() // Always 3 - block.unknown = st.readByte() // ??? Always 1? What is this? - block.iterations = st.readUnsigned() - block.terminator = st.readByte() - handler.app && handler.app.NETSCAPE && handler.app.NETSCAPE(block) - } - - var parseUnknownAppExt = function (block) { - block.appData = readSubBlocks() - // FIXME: This won't work if a handler wants to match on any identifier. - handler.app && - handler.app[block.identifier] && - handler.app[block.identifier](block) - } - - var blockSize = st.readByte() // Always 11 - block.identifier = st.read(8) - block.authCode = st.read(3) - switch (block.identifier) { - case 'NETSCAPE': - parseNetscapeExt(block) - break - default: - parseUnknownAppExt(block) - break - } - } - - var parseUnknownExt = function (block) { - block.data = readSubBlocks() - handler.unknown && handler.unknown(block) - } - - block.label = st.readByte() - switch (block.label) { - case 0xf9: - block.extType = 'gce' - parseGCExt(block) - break - case 0xfe: - block.extType = 'com' - parseComExt(block) - break - case 0x01: - block.extType = 'pte' - parsePTExt(block) - break - case 0xff: - block.extType = 'app' - parseAppExt(block) - break - default: - block.extType = 'unknown' - parseUnknownExt(block) - break - } - } - - var parseImg = function (img) { - var deinterlace = function (pixels, width) { - // Of course this defeats the purpose of interlacing. And it's *probably* - // the least efficient way it's ever been implemented. But nevertheless... - - var newPixels = new Array(pixels.length) - var rows = pixels.length / width - var cpRow = function (toRow, fromRow) { - var fromPixels = pixels.slice(fromRow * width, (fromRow + 1) * width) - newPixels.splice.apply( - newPixels, - [toRow * width, width].concat(fromPixels) - ) - } - - // See appendix E. - var offsets = [0, 4, 2, 1] - var steps = [8, 8, 4, 2] - - var fromRow = 0 - for (var pass = 0; pass < 4; pass++) { - for (var toRow = offsets[pass]; toRow < rows; toRow += steps[pass]) { - cpRow(toRow, fromRow) - fromRow++ - } - } - - return newPixels - } - - img.leftPos = st.readUnsigned() - img.topPos = st.readUnsigned() - img.width = st.readUnsigned() - img.height = st.readUnsigned() - - var bits = byteToBitArr(st.readByte()) - img.lctFlag = bits.shift() - img.interlaced = bits.shift() - img.sorted = bits.shift() - img.reserved = bits.splice(0, 2) - img.lctSize = bitsToNum(bits.splice(0, 3)) - - if (img.lctFlag) { - img.lct = parseCT(1 << (img.lctSize + 1)) - } - - img.lzwMinCodeSize = st.readByte() - - var lzwData = readSubBlocks() - - img.pixels = lzwDecode(img.lzwMinCodeSize, lzwData) - - if (img.interlaced) { - // Move - img.pixels = deinterlace(img.pixels, img.width) - } - - handler.img && handler.img(img) - } - - var parseBlock = function () { - var block = {} - block.sentinel = st.readByte() - - switch ( - String.fromCharCode(block.sentinel) // For ease of matching - ) { - case '!': - block.type = 'ext' - parseExt(block) - break - case ',': - block.type = 'img' - parseImg(block) - break - case ';': - block.type = 'eof' - handler.eof && handler.eof(block) - break - default: - throw new Error('Unknown block: 0x' + block.sentinel.toString(16)) // TODO: Pad this with a 0. - } - - if (block.type !== 'eof') setTimeout(parseBlock, 0) - } - - var parse = function () { - parseHeader() - setTimeout(parseBlock, 0) - } - - parse() -} - -// BEGIN_NON_BOOKMARKLET_CODE -if (typeof exports !== 'undefined') { - exports.Stream = Stream - exports.parseGIF = parseGIF -} -// export { parseGIF } -// END_NON_BOOKMARKLET_CODE diff --git a/src/utils/file/requirefile.js b/src/utils/file/requirefile.js deleted file mode 100644 index 5c403a4..0000000 --- a/src/utils/file/requirefile.js +++ /dev/null @@ -1,17 +0,0 @@ -/** - * @description require context module - */ -function requirefile(modulesFiles, path, flag, type) { - let modules = {} - if (modulesFiles) { - modules = modulesFiles.keys().reduce((modules, modulePath) => { - const moduleName = modulePath.replace(/^.\/(.*)\.js/, '$1') - const value = modulesFiles(modulePath) - modules[moduleName] = value.default - return modules - }, {}) - } - return modules -} - -export default requirefile diff --git a/src/utils/file/rgif.js b/src/utils/file/rgif.js deleted file mode 100644 index 673e2d9..0000000 --- a/src/utils/file/rgif.js +++ /dev/null @@ -1,124 +0,0 @@ -import { parseGIF, Stream } from '@/utils/file/gif' -var playGIF = (function () { - var stream - var hdr - - var loadError = null - - var transparency = null - var delay = null - var disposalMethod = null - var lastDisposalMethod = null - var frame = null - - var frames = [] - var reset = function () { - transparency = null - delay = null - lastDisposalMethod = disposalMethod - disposalMethod = null - frame = null - frames = [] - } - var clear = function () { - transparency = null - delay = null - lastDisposalMethod = disposalMethod - disposalMethod = null - frame = null - } - - //gif header info base info - var doHdr = function (_hdr) { - hdr = _hdr - - tmpCanvas.width = hdr.width - tmpCanvas.height = hdr.height - } - - var doGCE = function (gce) { - pushFrame() - clear() - transparency = gce.transparencyGiven ? gce.transparencyIndex : null - delay = gce.delayTime - disposalMethod = gce.disposalMethod - } - - var pushFrame = function () { - if (!frame) return - frames.push({ - data: frame.getImageData(0, 0, hdr.width, hdr.height), - delay: delay, - }) - } - //图片数据 - var doImg = function (img) { - //console.log(img); - if (!frame) frame = tmpCanvas.getContext('2d') - var ct = img.lctFlag ? img.lct : hdr.gct // TODO: What if neither exists? - - var cData = frame.getImageData( - img.leftPos, - img.topPos, - img.width, - img.height - ) - - img.pixels.forEach(function (pixel, i) { - // cData.data === [R,G,B,A,...] - if (transparency !== pixel) { - // This includes null, if no transparency was defined. - cData.data[i * 4 + 0] = ct[pixel][0] - cData.data[i * 4 + 1] = ct[pixel][1] - cData.data[i * 4 + 2] = ct[pixel][2] - cData.data[i * 4 + 3] = 255 // Opaque. - } else { - if (lastDisposalMethod === 2 || lastDisposalMethod === 3) { - cData.data[i * 4 + 3] = 0 // Transparent. - // XXX: This is very very wrong. - } else { - } - } - }) - frame.putImageData(cData, img.leftPos, img.topPos) - } - - var doNothing = function () {} - - var withProgress = function (fn, draw) { - return function (block) { - fn(block) - } - } - - var handler = { - hdr: withProgress(doHdr), - gce: withProgress(doGCE), - com: withProgress(doNothing), // I guess that's all for now. - app: { - NETSCAPE: withProgress(doNothing), - }, - img: withProgress(doImg), - eof: function (block) {}, - } - - var tmpCanvas = document.createElement('canvas') - - var doParse = function (stream, callback) { - try { - handler.eof = function () { - pushFrame() - callback(hdr, frames, tmpCanvas) - } - reset() - parseGIF(stream, handler) - } catch (err) { - throw new Error('parse error.' + err) - } - } - return { - doParse: doParse, - } -})() - -export default playGIF diff --git a/src/utils/monaco/provider.js b/src/utils/monaco/provider.js deleted file mode 100644 index 7fe2211..0000000 --- a/src/utils/monaco/provider.js +++ /dev/null @@ -1,121 +0,0 @@ -import i18n from '@/i18n' - -export function translateTitle(title) { - let pageTitle = '' - if (i18n.te(`dgiotI18n.${title}`)) { - pageTitle = i18n.t(`dgiotI18n.${title}`) - } else { - pageTitle = title.substr(title.lastIndexOf('.') + 1) - } - return pageTitle -} - -export const ruleEngineProvider = [ - { - name: 'clientid', - documentation: translateTitle('rule.clientid_doc'), - type: 'Field', - default: 'c_emqx', - valueType: 'string', - }, - { - name: 'username', - documentation: translateTitle('rule.username_doc'), - type: 'Field', - default: 'u_emqx', - valueType: 'string', - }, - { - name: 'event', - documentation: translateTitle('rule.event_doc'), - type: 'Field', - default: 'disconnect', - valueType: 'string', - }, - { - name: 'id', - documentation: translateTitle('rule.id_doc'), - type: 'Field', - default: '--', - valueType: 'string', - }, - { - name: 'payload', - documentation: translateTitle('rule.payload_doc'), - type: 'Field', - default: '{"msg": "hello"}', - valueType: 'string', - }, - { - name: 'peername', - documentation: translateTitle('rule.peername_doc'), - type: 'Field', - default: '127.0.0.1:63412', - valueType: 'string', - }, - { - name: 'qos', - documentation: translateTitle('rule.qos_doc'), - type: 'Field', - default: 1, - valueType: 'integer', - }, - { - name: 'timestamp', - documentation: translateTitle('rule.timestamp_doc'), - type: 'Field', - default: 1576549961086, - valueType: 'integer', - }, - { - name: 'topic', - documentation: translateTitle('rule.topic_doc'), - type: 'Field', - default: 't/a', - valueType: 'string', - }, - { - name: 'node', - documentation: translateTitle('rule.node_doc'), - type: 'Field', - default: 'emqx@127.0.0.1', - valueType: 'string', - }, - { - name: '"$events/message_delivered"', - documentation: translateTitle('rule.message_delivered'), - type: 'Method', - }, - { - name: '"$events/message_acked"', - documentation: translateTitle('rule.message_acked'), - type: 'Method', - }, - { - name: '"$events/message_dropped"', - documentation: translateTitle('rule.message_dropped'), - type: 'Method', - }, - { - name: '"$events/client_connected"', - documentation: translateTitle('rule.client_connected'), - type: 'Method', - }, - { - name: '"$events/client_disconnected"', - documentation: translateTitle('rule.client_disconnected'), - type: 'Method', - }, - { - name: '"$events/session_subscribed"', - documentation: translateTitle('rule.session_subscribed'), - type: 'Method', - }, - { - name: '"$events/session_unsubscribed"', - documentation: translateTitle('rule.session_unsubscribed'), - type: 'Method', - }, -] - -export default [] diff --git a/src/utils/swagger/genSwagger.js b/src/utils/swagger/genSwagger.js deleted file mode 100644 index c0fc81b..0000000 --- a/src/utils/swagger/genSwagger.js +++ /dev/null @@ -1,176 +0,0 @@ -const fs = require('fs') -const path = require('path') -const http = require('http') -const network = require('../../config/net.config') -const baseURL = network.proxy[0].target - -function mkdirsSync(dirname) { - if (fs.existsSync(dirname)) { - return true - } else { - if (mkdirsSync(path.dirname(dirname))) { - fs.mkdirSync(dirname) - return true - } - } -} - -function getPath(pathUrl) { - return path.resolve(__dirname, pathUrl) -} - -function generateTemplate(arr) { - return `import { ${arr.join(', ')} } from '@/utils/Request/request'\n` -} - -function generateFunc(name, summary, type = 'post') { - const arr = name.slice(1).split('/') - const fun = arr[arr.length - 1] - return ` -// ${summary || ''} -export function ${fun}(data, cb, errHandle) { - return ${type}('${name}', data, cb, errHandle) -}\n` -} - -function httpgetJson(url) { - return new Promise((resolve, reject) => { - http - .get(url, (res) => { - const { statusCode } = res - const contentType = res.headers['content-type'] - - let error - if (statusCode !== 200) { - error = new Error('请求失败。\n' + `状态码: ${statusCode}`) - } else if (!/^application\/json/.test(contentType)) { - error = new Error( - '无效的 content-type.\n' + - `期望 application/json 但获取的是 ${contentType}` - ) - } - if (error) { - dgiotlog.warn(error.message) - // 消耗响应数据以释放内存 - res.resume() - return - } - - res.setEncoding('utf8') - let rawData = '' - res.on('data', (chunk) => { - rawData += chunk - }) - res.on('end', () => { - try { - const parsedData = JSON.parse(rawData) - resolve(parsedData) - } catch (e) { - reject(`错误: ${e.message}`) - } - }) - }) - .on('error', (e) => { - reject(`错误: ${e.message}`) - }) - }) -} - -const srcFolder = '/src' -const url = `${baseURL}/swagger.json` -// const argv = process.argv -// dgiotlog.log(argv) - -async function main() { - dgiotlog.log('获取远程json文件中...') - const { paths } = await httpgetJson(url) - dgiotlog.log('获取成功正在生成api文件') - const obj = {} - for (const name in paths) { - const path = paths[name] - - let folder = '' - if (path.post) { - const tag = path.post.tags[0] - if (!tag) continue - const urlArray = name.slice(1).split('/') - if (name.slice(1).split('/').length === 4) { - folder = urlArray[1] - } else { - if (name.slice(1).split('/')[0] !== tag) { - continue - } - } - if (obj[path.post.tags[0]]) { - obj[path.post.tags[0]].push({ - summary: path.post.summary, - tag, - name, - type: 'post', - folder, - }) - } else { - obj[path.post.tags[0]] = [ - { - summary: path.post.summary, - tag, - name, - type: 'post', - folder, - }, - ] - } - } else if (path.get) { - const tag = path.get.tags[0] - if (!tag) continue - const urlArray = name.slice(1).split('/') - if (name.slice(1).split('/').length === 4) { - folder = urlArray[1] - } else { - if (name.slice(1).split('/')[0] !== tag) { - continue - } - } - if (obj[path.get.tags[0]]) { - obj[path.get.tags[0]].push({ - summary: path.get.summary, - tag, - name, - type: 'get', - folder, - }) - } else { - obj[path.get.tags[0]] = [ - { - summary: path.get.summary, - tag, - name, - type: 'get', - folder, - }, - ] - } - } - } - for (const tagName in obj) { - let jsString = '' - const requestTypes = [] - let folder = '' - for (const item of obj[tagName]) { - const requestType = requestTypes.filter((o) => o === item.type) - if (requestType.length === 0) requestTypes.push(item.type) - jsString += generateFunc(item.name, item.summary, item.type) - folder = item.folder - } - jsString = generateTemplate(requestTypes) + jsString - mkdirsSync(getPath(`..${srcFolder}/apis/${folder}`)) - dgiotlog.log(jsString) - fs.writeFileSync( - getPath(`..${srcFolder}/apis/${folder}/${tagName}.js`), - jsString - ) - } - dgiotlog.log('生成完毕') -} - -main() diff --git a/src/utils/swagger/index.js b/src/utils/swagger/index.js deleted file mode 100644 index 0051f64..0000000 --- a/src/utils/swagger/index.js +++ /dev/null @@ -1,30 +0,0 @@ -/** - * 自动构建执行,其他情况禁止执行 - * @type {module:fs} - */ -const fs = require('fs') -const path = require('path') -const { proxy } = require('../../config/net.config') -const http = require('http') -const swaggerFile = path.join(__dirname, '../../../swagger.json') -http - .get(`${proxy[0].target}/swagger.json`, (resp) => { - let data = '' - resp.on('data', (chunk) => { - data += chunk - }) - - resp.on('end', () => { - fs.writeFile(swaggerFile, data, function (err) { - if (err) { - return dgiotlog.log('Failed to crawl' + err) - } - dgiotlog.log( - 'File created swagger successfully, address:' + swaggerFile - ) - }) - }) - }) - .on('error', (err) => { - dgiotlog.log('Error: ' + err.message) - }) diff --git a/src/utils/webscroket/index.js b/src/utils/webscroket/index.js deleted file mode 100644 index 7bd4940..0000000 --- a/src/utils/webscroket/index.js +++ /dev/null @@ -1,344 +0,0 @@ -var TOPIC_EMPTY = 'topic为空!' -var MSG_EMPTY = '消息内容为空!' -var DISCONNECT_MSG = '当前尚未连接' -var userName = 'konva' -let localHost = [ - 'tcloudbaseapp.com', - 'gitee.io', - 'github.io', - 'netlify.app', - 'surge.sh', - 'h7ml.icu', -] - -if (process.env.NODE_ENV == 'development') { - localHost.push('localhost', '127.0.0.1') -} -var clientssession = getToken(tokenTableName, storage) -var info = { - topic: 'web/' + clientssession, - qos: 2, -} -import { storage, tokenTableName } from '@/config' -import { globalUrl } from '@/utils/utilwen' -import { getToken } from '@/utils/vue' - -const { hostname } = window.location - -function getsession(session) { - clientssession = session - info = { - topic: 'web/' + clientssession, - qos: 2, - } -} - -function formatDate(date, fmt) { - if (/(y+)/.test(fmt)) { - fmt = fmt.replace( - RegExp.$1, - (date.getFullYear() + '').substr(4 - RegExp.$1.length) - ) - } - var o = { - 'M+': date.getMonth() + 1, - 'd+': date.getDate(), - 'h+': date.getHours(), - 'm+': date.getMinutes(), - 's+': date.getSeconds(), - } - for (const k in o) { - if (new RegExp(`(${k})`).test(fmt)) { - var str = o[k] + '' - fmt = fmt.replace( - RegExp.$1, - RegExp.$1.length === 1 ? str : padLeftZero(str) - ) - } - } - return fmt -} - -function padLeftZero(str) { - return ('00' + str).substr(str.length) -} - -var sendInfo = { - topic: '/test', - text: 'Hello world!', - qos: 0, - retained: true, -} -// if (process.env.NODE_ENV == 'development') { -// localHost.push('localhost', '127.0.0.1') -// } -let _scokethost = - globalUrl(hostname, localHost).split('//')[1] || location.hostname -// var result = localHost.some((i) => { -// return hostname.indexOf(i) > -1 -// }) -// if (result) { -// dgiotlog.log(process.env.VUE_APP_URL) -// _scokethost = process.env.VUE_APP_URL.split('//')[1] -// } else { -// _scokethost = '' -// } -dgiotlog.info(`%_scokethost is : ${_scokethost}`, 'color: green;') -// eslint-disable-next-line no-unused-vars -var Websocket = { - modName: 'websocket', - client: null, - connState: false, - cInfo: { - host: _scokethost, - port: window.location.protocol === 'https:' ? 8084 : 8083, - clientId: 'C_' + new Date().getTime(), - userName: userName, - isSSL: window.location.protocol === 'https:' ? true : false, - password: 'test123', - keepAlive: null, - keepAliveInterval: 10, - cleanSession: false, - }, - sendInfo: '{}', - hooks: [], - tablelist: [], - subInfo: info, - originrecivedata: [], - send: function () { - var _this = this - var sendInfo = JSON.parse(_this.sendInfo) - dgiotlog.log(sendInfo) - _this.sendMessage(sendInfo) - }, - log: function (Msg) { - try { - Msg = JSON.parse(Msg) - // eslint-disable-next-line no-empty - } catch (e) {} - // eslint-disable-next-line no-undef - }, - newClient: function () { - var _this = this - // eslint-disable-next-line no-undef - _this.client = new Paho.MQTT.Client( - _this.cInfo.host, - Number(_this.cInfo.port), - _this.cInfo.clientId - ) - }, - sslPort: function () { - var _this = this - _this.cInfo.useSSL ? (_this.cInfo.port = 8084) : (_this.cInfo.port = 8083) - }, - recive: function (msg) { - dgiotlog.log(msg) - }, - - add_hook: function (Re, Callback) { - var _this = this - if (_this.hooks.length > 0) { - for (var i = 0; i < _this.hooks.length; i++) { - if (_this.hooks[i].re.toString() == Re.toString()) { - _this.hooks[i].re = Re - _this.hooks[i].callback = Callback - return - } - } - } - _this.hooks.push({ - re: Re, - callback: Callback, - }) - }, - - dispatch: function (message) { - dgiotlog.log('message', message) - var _this = this - var topic = message.destinationName - const hooks = _this.hooks - hooks.map((item) => { - if (item.re.test(topic)) { - item.callback(message.payloadString) - } - }) - }, - - connect: function () { - var _this = this - // eslint-disable-next-line no-undef - if (_this.client && _this.client.isConnected()) { - return - } else { - _this.newClient() - } - _this.client.onConnectionLost = function (responseObject) { - if (responseObject.errorCode !== 0) { - dgiotlog.log('onConnectionLost: ' + responseObject.errorMessage) - setTimeout(function () { - _this.connect() - }, 1000) - } else { - window.clearTimeout() - } - // return - } - _this.client.onMessageArrived = function (message) { - try { - message.msgString = message.payloadString - } catch (e) { - message.msgString = - 'Binary message(' + message.payloadBytes.length + ')' - } - _this.dispatch(message) - } - - var options = { - onFailure: function (err) { - _this.connState = false - dgiotlog.log('连接失败 ' + err.errorMessage) - setTimeout(function () { - _this.connect() - }, 5000) - }, - onSuccess: function () { - _this.connState = true - _this.subscribe(_this.subInfo, function (res) { - if (res.result) { - dgiotlog.log(_this.subInfo) - dgiotlog.log('订阅成功') - } - }) - }, - } - var userName = _this.cInfo.userName - var password = _this.cInfo.password - var keepAlive = _this.cInfo.keepAlive - var cleanSession = _this.cInfo.cleanSession - var useSSL = window.location.protocol === 'https:' ? true : false - if (userName) { - options.userName = userName - } - if (password) { - options.password = password - } - if (keepAlive) { - options.keepAliveInterval = Number(keepAlive) - } - options.cleanSession = cleanSession - window.location.protocol === 'https:' ? (options.useSSL = useSSL) : '' - _this.client.connect(options) - }, - - disconnect: function () { - var _this = this - if (_this.client && this.client.isConnected()) { - _this.client.disconnect() - _this.client = null - } - dgiotlog.log('已经断开连接!') - _this.connState = false - setTimeout(function () { - _this.connect() - }, 5000) - }, - subscribe: function (subInfo, callback) { - var _this = this - if (!_this.client || !_this.client.isConnected()) { - dgiotlog.log(DISCONNECT_MSG) - _this.connect() - return - } - if (!subInfo.topic) { - dgiotlog.log(TOPIC_EMPTY) - return - } - _this.client.subscribe(subInfo.topic, { - qos: Number(subInfo.qos), - onSuccess: function (msg) { - subInfo.msg = msg - dgiotlog.log(subInfo.msg) - subInfo.result = true - callback && callback(subInfo) - }, - onFailure: function (err) { - if (err.errorCode[0] === 128) { - dgiotlog.log('The topic cannot SUBSCRIBE for ACL Deny') - } - subInfo.msg = err - dgiotlog.log(err) - subInfo.result = false - callback && callback(subInfo) - }, - }) - }, - unsubscribe: function (subInfo, callback) { - var _this = this - if (!_this.client || !_this.client.isConnected()) { - _this.tablelist.push({ - date: formatDate(new Date(), 'yyyy-MM-dd hh:mm'), - content: DISCONNECT_MSG, - }) - dgiotlog.log(DISCONNECT_MSG) - _this.connect() - return - } - if (!subInfo.topic) { - _this.tablelist.push({ - date: formatDate(new Date(), 'yyyy-MM-dd hh:mm'), - content: TOPIC_EMPTY, - }) - dgiotlog.log(TOPIC_EMPTY) - return - } - _this.client.unsubscribe(subInfo.topic, { - onSuccess: function (msg) { - subInfo.msg = msg - dgiotlog.log(subInfo) - subInfo.result = true - callback && callback(subInfo) - }, - onFailure: function (err) { - subInfo.msg = err - dgiotlog.log(err) - subInfo.result = true - callback && callback(subInfo) - }, - }) - }, - sendMessage: function (sendInfo) { - var _this = this - var text = sendInfo.text - if (!_this.client || !_this.client.isConnected()) { - dgiotlog.log(DISCONNECT_MSG) - _this.connect() - return - } - if (!sendInfo.topic) { - dgiotlog.log(TOPIC_EMPTY) - return - } - if (!text) { - dgiotlog.log(MSG_EMPTY) - return - } - // eslint-disable-next-line no-undef - var message = new Paho.MQTT.Message(text) - message.destinationName = sendInfo.topic - message.qos = Number(sendInfo.qos) - message.retained = sendInfo.retained - _this.client.send(message) - dgiotlog.log(sendInfo) - }, -} -export { - // eslint-disable-next-line no-undef - Websocket, - sendInfo, - TOPIC_EMPTY, - MSG_EMPTY, - DISCONNECT_MSG, - getsession, - _scokethost, -} -window.Websocket = Websocket diff --git a/src/views/MultiTenant/user/register/index.vue b/src/views/MultiTenant/user/register/index.vue deleted file mode 100644 index 719e253..0000000 --- a/src/views/MultiTenant/user/register/index.vue +++ /dev/null @@ -1,354 +0,0 @@ - - - - - diff --git a/src/views/MultiTenant/user/register/register.vue b/src/views/MultiTenant/user/register/register.vue deleted file mode 100644 index 74f9b31..0000000 --- a/src/views/MultiTenant/user/register/register.vue +++ /dev/null @@ -1,448 +0,0 @@ - - - - - -