diff --git a/public/i18n/en.yml b/public/i18n/en.yml index 0eaa130..543dccb 100644 --- a/public/i18n/en.yml +++ b/public/i18n/en.yml @@ -209,9 +209,12 @@ SETTINGS_ENABLE_SERVER: Enable Server SETTINGS_SET_SERVER_HOST: Set Server Host SETTINGS_SET_SERVER_PORT: Set Server Port SETTINGS_SET_SERVER_KEY: Set Auth Key +SETTINGS_SET_WEB_SERVER: Set Web Server +SETTINGS_TIPS_WEB_SERVER_NOTICE: If you don't know what is the web server's function, please read the document, or don't modify the configuration. SETTINGS_SET_ENABLE_WEB_SERVER: Enable Web Server SETTINGS_SET_WEB_SERVER_HOST: Set Web Server Host SETTINGS_SET_WEB_SERVER_PORT: Set Web Server Port +SETTINGS_SET_WEB_SERVER_PATH: Set Web Server Path SETTINGS_TIP_PLACEHOLDER_WEB_HOST: Default:127.0.0.1 SETTINGS_TIP_PLACEHOLDER_WEB_PORT: Default:37777 SETTINGS_TIP_PLACEHOLDER_HOST: Default:127.0.0.1 diff --git a/public/i18n/zh-CN.yml b/public/i18n/zh-CN.yml index f1d6306..38a3cde 100644 --- a/public/i18n/zh-CN.yml +++ b/public/i18n/zh-CN.yml @@ -211,9 +211,12 @@ SETTINGS_ENABLE_SERVER: 是否开启Server SETTINGS_SET_SERVER_HOST: 设置监听地址 SETTINGS_SET_SERVER_PORT: 设置监听端口 SETTINGS_SET_SERVER_KEY: 设置鉴权密钥 +SETTINGS_SET_WEB_SERVER: 设置Web服务 +SETTINGS_TIPS_WEB_SERVER_NOTICE: 如果你不知道Web服务的作用,请阅读文档,或者不用修改配置。 SETTINGS_SET_ENABLE_WEB_SERVER: 是否开启Web服务 SETTINGS_SET_WEB_SERVER_HOST: 设置Web服务监听地址 SETTINGS_SET_WEB_SERVER_PORT: 设置Web服务监听端口 +SETTINGS_SET_WEB_SERVER_PATH: 设置Web服务路径 SETTINGS_TIP_PLACEHOLDER_WEB_HOST: 推荐默认地址:127.0.0.1 SETTINGS_TIP_PLACEHOLDER_WEB_PORT: 推荐默认端口:37777 SETTINGS_TIP_PLACEHOLDER_HOST: 推荐默认地址:127.0.0.1 diff --git a/public/i18n/zh-TW.yml b/public/i18n/zh-TW.yml index e552e45..48d5e0d 100644 --- a/public/i18n/zh-TW.yml +++ b/public/i18n/zh-TW.yml @@ -209,9 +209,12 @@ SETTINGS_ENABLE_SERVER: 是否開啟Server SETTINGS_SET_SERVER_HOST: 設定監聽地址 SETTINGS_SET_SERVER_PORT: 設定監聽端口 SETTINGS_SET_SERVER_KEY: 設定鑒權密鑰 +SETTINGS_SET_WEB_SERVER: 設定Web服務 +SETTINGS_TIPS_WEB_SERVER_NOTICE: 如果你不知道Web服務的作用,請閱讀文檔,或者不用修改設定。 SETTINGS_SET_ENABLE_WEB_SERVER: 是否開啟Web服務 SETTINGS_SET_WEB_SERVER_HOST: 設定Web服務地 SETTINGS_SET_WEB_SERVER_PORT: 設定Web服務端口 +SETTINGS_SET_WEB_SERVER_PATH: 設定Web服務路徑 SETTINGS_TIP_PLACEHOLDER_WEB_HOST: 推薦預設地址:127.0.0.1 SETTINGS_TIP_PLACEHOLDER_WEB_PORT: 推薦預設端口:37777 SETTINGS_TIP_PLACEHOLDER_HOST: 推薦預設地址:127.0.0.1 diff --git a/src/main/events/ipcList.ts b/src/main/events/ipcList.ts index 10584ba..66f2c45 100644 --- a/src/main/events/ipcList.ts +++ b/src/main/events/ipcList.ts @@ -89,6 +89,7 @@ import SSHClient from '../utils/sshClient' import { ISftpPlistConfig } from 'piclist' import { removeFileFromS3InMain, removeFileFromDogeInMain, removeFileFromHuaweiInMain } from '~/main/utils/deleteFunc' +import webServer from '../server/webServer' const STORE_PATH = app.getPath('userData') @@ -360,6 +361,12 @@ export default { ipcMain.on('updateServer', () => { server.restart() }) + ipcMain.on('stopWebServer', () => { + webServer.stop() + }) + ipcMain.on('restartWebServer', () => { + webServer.restart() + }) ipcMain.on(OPEN_DEVTOOLS, (event: IpcMainEvent) => { event.sender.openDevTools() }) diff --git a/src/main/lifeCycle/index.ts b/src/main/lifeCycle/index.ts index b045098..48a2919 100644 --- a/src/main/lifeCycle/index.ts +++ b/src/main/lifeCycle/index.ts @@ -45,6 +45,7 @@ import path from 'path' import { CLIPBOARD_IMAGE_FOLDER } from '~/universal/utils/static' import fs from 'fs-extra' import { startFileServer } from '../fileServer' +import webServer from '../server/webServer' import axios from 'axios' const isDevelopment = process.env.NODE_ENV !== 'production' @@ -179,6 +180,7 @@ class LifeCycle { }) server.startup() startFileServer() + webServer.start() if (process.env.NODE_ENV !== 'development') { handleStartUpFiles(process.argv, process.cwd()) } diff --git a/src/main/server/webServer/index.ts b/src/main/server/webServer/index.ts index e69de29..19bd790 100644 --- a/src/main/server/webServer/index.ts +++ b/src/main/server/webServer/index.ts @@ -0,0 +1,96 @@ +import http from 'http' +import fs from 'fs-extra' +import path from 'path' +import picgo from '@core/picgo' +import logger from '../../apis/core/picgo/logger' + +const defaultPath = process.platform === 'win32' ? 'C:/Users/' : '/' + +function generateDirectoryListingHtml (files: any[], requestPath: any) { + let html = '