Skip to content
代码片段 群组 项目
提交 57eb8f01 编辑于 作者: Timotej Ecimovic's avatar Timotej Ecimovic
浏览文件

ES6 is now gone from the server and we can execute this directly from electron.

上级 1d953837
No related branches found
No related tags found
无相关合并请求
......@@ -25,7 +25,7 @@
"zcl-format": "zcl/script/format",
"headlessServer": "quasar dev -m electron -- --httpPort 8081 --noUI --xmlRoot=./zcl/zcl-studio.properties",
"browser": "quasar dev",
"zap": "quasar build && quasar dev -m electron",
"zap": "electron src-electron/main-process/electron-main.js",
"build-spa": "quasar build",
"doc": "jsdoc src-electron src-shared -r -d ./generated-html/",
"apidoc": "jsdoc2md src-shared/**/*.js src-electron/**/*.js > docs/api.md",
......
......@@ -41,4 +41,4 @@ require('electron').app.on('ready', () => {
})
// Require `main` process to boot app
require('./electron-main')
require('./electron-main.js')
......@@ -19,12 +19,12 @@ const { session, BrowserWindow, dialog } = require('electron')
const path = require('path')
const { iconsDirectory, mainDatabase } = require('../util/env.js')
const { getWindowDirtyFlagWithCallback } = require('../db/query-session.js')
const { initMenu } = require('./menu.js')
const menu = require('./menu.js')
const { initTray } = require('./tray.js')
function initializeElectronUi(port) {
let w = windowCreate(port)
initMenu(port)
menu.initMenu(port)
initTray(port)
}
......
......@@ -39,7 +39,7 @@ const {
validateAttribute,
} = require('../validation/validation.js')
const { httpCode } = require('../server/http-server.js')
const httpServer = require('../server/http-server.js')
const RestApi = require('../../src-shared/rest-api.js')
......@@ -56,10 +56,10 @@ function registerSessionApi(db, app) {
side: side,
flag: flag,
})
.status(httpCode.ok)
.status(httpServer.httpCode.ok)
.send()
)
.catch((err) => response.status(httpCode.badRequest).send())
.catch((err) => response.status(httpServer.httpCode.badRequest).send())
})
app.post('/post/attribute/update', (request, response) => {
......@@ -122,7 +122,7 @@ function registerSessionApi(db, app) {
validationIssues: validationData,
replyId: RestApi.replyId.singleAttributeState,
})
return response.status(httpCode.ok).send()
return response.status(httpServer.httpCode.ok).send()
}
)
})
......@@ -170,7 +170,7 @@ function registerSessionApi(db, app) {
clusterRef: clusterRef,
replyId: RestApi.replyId.singleCommandState,
})
return response.status(httpCode.ok).send()
return response.status(httpServer.httpCode.ok).send()
})
})
......@@ -218,7 +218,7 @@ function registerSessionApi(db, app) {
listType: listType,
replyId: 'singleReportableAttributeState',
})
return response.status(httpCode.ok).send()
return response.status(httpServer.httpCode.ok).send()
})
})
......@@ -228,7 +228,7 @@ function registerSessionApi(db, app) {
logInfo(`[${sessionId}]: Saving: ${key} => ${value}`)
updateKeyValue(db, sessionId, key, value)
.then(() => {
response.status(httpCode.ok)
response.status(httpServer.httpCode.ok)
})
.catch((err) => {
throw err
......@@ -258,11 +258,11 @@ function registerSessionApi(db, app) {
replyId: RestApi.replyId.zclEndpointResponse,
validationIssues: validationData,
})
return response.status(httpCode.ok).send()
return response.status(httpServer.httpCode.ok).send()
})
})
.catch((err) => {
return response.status(httpCode.badRequest).send()
return response.status(httpServer.httpCode.badRequest).send()
})
break
case RestApi.action.delete:
......@@ -273,7 +273,7 @@ function registerSessionApi(db, app) {
id: context.id,
replyId: RestApi.replyId.zclEndpointResponse,
})
return response.status(httpCode.ok).send()
return response.status(httpServer.httpCode.ok).send()
})
break
case RestApi.action.update:
......@@ -305,7 +305,7 @@ function registerSessionApi(db, app) {
replyId: RestApi.replyId.zclEndpointResponse,
validationIssues: validationData,
})
return response.status(httpCode.ok).send()
return response.status(httpServer.httpCode.ok).send()
})
})
break
......@@ -328,10 +328,10 @@ function registerSessionApi(db, app) {
deviceTypeRef: context.deviceTypeRef,
replyId: RestApi.replyId.zclEndpointTypeResponse,
})
return response.status(httpCode.ok).send()
return response.status(httpServer.httpCode.ok).send()
})
.catch((err) => {
return response.status(httpCode.badRequest).send()
return response.status(httpServer.httpCode.badRequest).send()
})
break
case RestApi.action.delete:
......@@ -342,7 +342,7 @@ function registerSessionApi(db, app) {
id: context.id,
replyId: RestApi.replyId.zclEndpointTypeResponse,
})
return response.status(httpCode.ok).send()
return response.status(httpServer.httpCode.ok).send()
})
break
default:
......@@ -374,7 +374,7 @@ function registerSessionApi(db, app) {
updatedValue: updatedValue,
replyId: RestApi.replyId.zclEndpointTypeResponse,
})
return response.status(httpCode.ok).send()
return response.status(httpServer.httpCode.ok).send()
}
)
})
......
......@@ -91,9 +91,7 @@ function initHttpServer(db, port) {
registerGenerationApi(db, app)
registerAdminApi(db, app)
var staticDir = path.join(__dirname, __indexDirOffset)
app.use(express.static(staticDir))
app.use(express.static(env.httpStaticContent))
httpServer = app.listen(port, () => {
env.logInfo(`HTTP server created on port: ` + httpServerPort())
......
......@@ -32,15 +32,16 @@ var pino_logger = pino({
var explicit_logger_set = false
var dbInstance
var httpStaticContent = path.join(__dirname, '../../dist/spa')
function setDevelopmentEnv() {
global.__statics = path.join('src', 'statics').replace(/\\/g, '\\\\')
global.__indexDirOffset = path.join('../../dist/spa')
httpStaticContent = path.join(__dirname, '../../dist/spa')
}
function setProductionEnv() {
global.__statics = path.join(__dirname, 'statics').replace(/\\/g, '\\\\')
global.__indexDirOffset = path.join('.').replace(/\\/g, '\\\\')
httpStaticContent = path.join('.').replace(/\\/g, '\\\\')
}
function setMainDatabase(db) {
......@@ -132,3 +133,4 @@ exports.logInfo = logInfo
exports.logError = logError
exports.logWarning = logWarning
exports.logSql = logSql
exports.httpStaticContent = httpStaticContent
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册