feat: 破坏性更新 cjs to es

This commit is contained in:
手瓜一十雪
2024-05-22 19:58:45 +08:00
parent f65b2be06f
commit 442342d106
17 changed files with 75 additions and 13 deletions

View File

@@ -5,6 +5,13 @@ import { resolve } from 'node:path';
import { ALLRouter } from './src/router';
import { WebUiConfig } from './src/helper/config';
const app = express();
import { dirname } from "node:path"
import { fileURLToPath } from "node:url"
const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);
/**
* 初始化并启动WebUI服务。
* 该函数配置了Express服务器以支持JSON解析和静态文件服务并监听6099端口。

View File

@@ -2,6 +2,12 @@ import { RequestHandler } from "express";
import { resolve } from "path";
import { readdir, stat } from "fs/promises";
import { existsSync } from "fs";
import { dirname } from "node:path"
import { fileURLToPath } from "node:url"
const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);
export const GetLogFileListHandler: RequestHandler = async (req, res) => {
try {
let LogsPath = resolve(__dirname, "./logs/");

View File

@@ -3,6 +3,13 @@ import { WebUiDataRuntime } from "../helper/Data";
import { existsSync, readFileSync, writeFileSync } from "node:fs";
import { resolve } from "node:path";
import { OB11Config } from "@/webui/ui/components/WebUiApiOB11Config";
import { dirname } from "node:path"
import { fileURLToPath } from "node:url"
const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);
const isEmpty = (data: any) =>
data === undefined || data === null || data === "";
export const OB11GetConfigHandler: RequestHandler = async (req, res) => {

View File

@@ -1,6 +1,12 @@
import { existsSync, readFileSync, writeFileSync } from "node:fs";
import { resolve } from "node:path";
const net = require('net');
import * as net from "node:net";
import { dirname } from "node:path"
import { fileURLToPath } from "node:url"
const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);
// 限制尝试端口的次数,避免死循环
const MAX_PORT_TRY = 100;