Compare commits
No commits in common. "9978ba9c3d951cc8081e7bf42806b5681b2786f5" and "5bc0e6637e7f08de59c711778062533a1e6620cb" have entirely different histories.
9978ba9c3d
...
5bc0e6637e
@ -1,27 +0,0 @@
|
|||||||
import fs from 'fs';
|
|
||||||
import path from 'path';
|
|
||||||
import { fileURLToPath } from 'url';
|
|
||||||
import BaseController from '../core/BaseController.js';
|
|
||||||
|
|
||||||
class IndexController extends BaseController {
|
|
||||||
constructor() {
|
|
||||||
super();
|
|
||||||
}
|
|
||||||
index() {
|
|
||||||
const {ctx} = this;
|
|
||||||
console.log("访问首页");
|
|
||||||
const indexPath = path.join(path.dirname(fileURLToPath(import.meta.url)), '../views/index.html');
|
|
||||||
fs.readFile(indexPath, (err, data) => {
|
|
||||||
if (err) {
|
|
||||||
console.log('读取首页文件错误:', err.message);
|
|
||||||
ctx.response.writeHead(500, { 'Content-Type': 'text/plain' });
|
|
||||||
ctx.response.end('500 Internal Server Error');
|
|
||||||
} else {
|
|
||||||
ctx.response.writeHead(200, { 'Content-Type': 'text/html' });
|
|
||||||
ctx.response.end(data);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export default new IndexController();
|
|
||||||
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "printserver",
|
"name": "printserver",
|
||||||
"version": "1.0.10",
|
"version": "1.0.9",
|
||||||
"main": "electron/main.cjs",
|
"main": "electron/main.cjs",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "node index.js",
|
"start": "node index.js",
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
import service from '../core/BaseService.js';
|
import service from '../core/BaseService.js';
|
||||||
import configUtil from '../utils/config.js';
|
import configUtil from '../utils/config.js';
|
||||||
import { startService, uninstallService } from '../utils/windowsService.js';
|
import { ensureServiceInstalled, uninstallService } from '../utils/windowsService.js';
|
||||||
|
|
||||||
function isServiceRunnerProcess() {
|
function isServiceRunnerProcess() {
|
||||||
return process.argv.includes('--service-runner');
|
return process.argv.includes('--service-runner');
|
||||||
@ -121,7 +121,7 @@ class SettingService extends service {
|
|||||||
const previousIsService = !!config.isService;
|
const previousIsService = !!config.isService;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await startService();
|
await ensureServiceInstalled();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
config.isService = previousIsService;
|
config.isService = previousIsService;
|
||||||
configUtil.write(config);
|
configUtil.write(config);
|
||||||
|
|||||||
@ -110,22 +110,6 @@ function isAccessDeniedErrorMessage(message) {
|
|||||||
return /AccessDenied|拒绝访问|\b0x5\b|\berror\s*5\b/i.test(String(message));
|
return /AccessDenied|拒绝访问|\b0x5\b|\berror\s*5\b/i.test(String(message));
|
||||||
}
|
}
|
||||||
|
|
||||||
function isServiceAlreadyExistsErrorMessage(message) {
|
|
||||||
if (!message) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return /already exists|已存在|Service with id\s*'?.+?'?\s*already exists/i.test(String(message));
|
|
||||||
}
|
|
||||||
|
|
||||||
function isServiceAlreadyRunningErrorMessage(message) {
|
|
||||||
if (!message) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return /already started|already running|已启动|正在运行/i.test(String(message));
|
|
||||||
}
|
|
||||||
|
|
||||||
async function runWrapperCommandElevated(command, metadata) {
|
async function runWrapperCommandElevated(command, metadata) {
|
||||||
const escapedWrapperPath = metadata.wrapperPath.replace(/'/g, "''");
|
const escapedWrapperPath = metadata.wrapperPath.replace(/'/g, "''");
|
||||||
const escapedCommand = String(command).replace(/'/g, "''");
|
const escapedCommand = String(command).replace(/'/g, "''");
|
||||||
@ -216,35 +200,13 @@ export async function getServiceStatus(options = {}) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export async function ensureServiceInstalled(options = {}) {
|
export async function ensureServiceInstalled(options = {}) {
|
||||||
let status = null;
|
const status = await getServiceStatus(options);
|
||||||
try {
|
if (status.installed) {
|
||||||
status = await getServiceStatus(options);
|
|
||||||
} catch (error) {
|
|
||||||
status = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (status && status.installed) {
|
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
|
||||||
await runWrapperCommand('install', options);
|
await runWrapperCommand('install', options);
|
||||||
} catch (error) {
|
return getServiceStatus(options);
|
||||||
if (!isServiceAlreadyExistsErrorMessage(error.message)) {
|
|
||||||
throw error;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
return await getServiceStatus(options);
|
|
||||||
} catch (error) {
|
|
||||||
// 某些机器上 status 读取异常,但 install 已提示“已存在”。此时按已安装处理。
|
|
||||||
return {
|
|
||||||
installed: true,
|
|
||||||
running: false,
|
|
||||||
rawStatus: 'Existing'
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function startService(options = {}) {
|
export async function startService(options = {}) {
|
||||||
@ -253,14 +215,7 @@ export async function startService(options = {}) {
|
|||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
|
||||||
await runWrapperCommand('start', options);
|
await runWrapperCommand('start', options);
|
||||||
} catch (error) {
|
|
||||||
if (!isServiceAlreadyRunningErrorMessage(error.message)) {
|
|
||||||
throw error;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return getServiceStatus(options);
|
return getServiceStatus(options);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -269,40 +269,6 @@
|
|||||||
border-bottom: 1px dashed #e5ebf3;
|
border-bottom: 1px dashed #e5ebf3;
|
||||||
}
|
}
|
||||||
|
|
||||||
.printer-item {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: space-between;
|
|
||||||
gap: 12px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.printer-name {
|
|
||||||
overflow: hidden;
|
|
||||||
text-overflow: ellipsis;
|
|
||||||
white-space: nowrap;
|
|
||||||
}
|
|
||||||
|
|
||||||
.printer-state {
|
|
||||||
font-size: 12px;
|
|
||||||
font-weight: 600;
|
|
||||||
border-radius: 999px;
|
|
||||||
padding: 2px 8px;
|
|
||||||
border: 1px solid transparent;
|
|
||||||
white-space: nowrap;
|
|
||||||
}
|
|
||||||
|
|
||||||
.printer-state.online {
|
|
||||||
color: #107c10;
|
|
||||||
background: #e9f6ea;
|
|
||||||
border-color: #c8e6ca;
|
|
||||||
}
|
|
||||||
|
|
||||||
.printer-state.offline {
|
|
||||||
color: #c42b1c;
|
|
||||||
background: #fdeeee;
|
|
||||||
border-color: #f5c7c2;
|
|
||||||
}
|
|
||||||
|
|
||||||
.item:last-child {
|
.item:last-child {
|
||||||
border-bottom: none;
|
border-bottom: none;
|
||||||
}
|
}
|
||||||
@ -552,10 +518,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="list">
|
<div class="list">
|
||||||
<div class="item" v-if="printers.length === 0">无打印机</div>
|
<div class="item" v-if="printers.length === 0">无打印机</div>
|
||||||
<div class="item printer-item" v-for="p in printers" :key="p.name">
|
<div class="item" v-for="p in printers" :key="p.name">{{ p.name }}</div>
|
||||||
<span class="printer-name">{{ p.name }}</span>
|
|
||||||
<span class="printer-state" :class="isPrinterOffline(p) ? 'offline' : 'online'">{{ isPrinterOffline(p) ? '离线' : '在线' }}</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -852,15 +815,6 @@
|
|||||||
const s = this.statusList.find(x => x.name === name);
|
const s = this.statusList.find(x => x.name === name);
|
||||||
return s ? s.status : '未知';
|
return s ? s.status : '未知';
|
||||||
},
|
},
|
||||||
isPrinterOffline(printer) {
|
|
||||||
const raw = printer && printer.workOffline;
|
|
||||||
if (typeof raw === 'boolean') {
|
|
||||||
return raw;
|
|
||||||
}
|
|
||||||
|
|
||||||
const normalized = String(raw || '').trim().toLowerCase();
|
|
||||||
return normalized === 'true' || normalized === '1' || normalized === 'yes';
|
|
||||||
},
|
|
||||||
loadPrinters() {
|
loadPrinters() {
|
||||||
wsSendWithCallback('printer.getWindowsPrinters', {}, (data) => {
|
wsSendWithCallback('printer.getWindowsPrinters', {}, (data) => {
|
||||||
if (data.success) {
|
if (data.success) {
|
||||||
|
|||||||
@ -168,35 +168,6 @@
|
|||||||
.item {
|
.item {
|
||||||
margin-bottom: 6px;
|
margin-bottom: 6px;
|
||||||
}
|
}
|
||||||
.printer-item {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: space-between;
|
|
||||||
gap: 10px;
|
|
||||||
}
|
|
||||||
.printer-name {
|
|
||||||
overflow: hidden;
|
|
||||||
text-overflow: ellipsis;
|
|
||||||
white-space: nowrap;
|
|
||||||
}
|
|
||||||
.printer-state {
|
|
||||||
font-size: 12px;
|
|
||||||
font-weight: bold;
|
|
||||||
border-radius: 999px;
|
|
||||||
padding: 2px 8px;
|
|
||||||
border: 1px solid transparent;
|
|
||||||
white-space: nowrap;
|
|
||||||
}
|
|
||||||
.printer-state.online {
|
|
||||||
color: #2e7d32;
|
|
||||||
background: #e8f5e9;
|
|
||||||
border-color: #c8e6c9;
|
|
||||||
}
|
|
||||||
.printer-state.offline {
|
|
||||||
color: #c62828;
|
|
||||||
background: #ffebee;
|
|
||||||
border-color: #ffcdd2;
|
|
||||||
}
|
|
||||||
button {
|
button {
|
||||||
padding: 7px 18px;
|
padding: 7px 18px;
|
||||||
background: #4CAF50;
|
background: #4CAF50;
|
||||||
@ -254,10 +225,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="list">
|
<div class="list">
|
||||||
<div class="item" v-if="printers.length === 0">无打印机</div>
|
<div class="item" v-if="printers.length === 0">无打印机</div>
|
||||||
<div class="item printer-item" v-for="p in printers" :key="p.name">
|
<div class="item" v-for="p in printers" :key="p.name">{{ p.name }}</div>
|
||||||
<span class="printer-name">{{ p.name }}</span>
|
|
||||||
<span class="printer-state" :class="isPrinterOffline(p) ? 'offline' : 'online'">{{ isPrinterOffline(p) ? '离线' : '在线' }}</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="list-box">
|
<div class="list-box">
|
||||||
@ -366,15 +334,6 @@ new Vue({
|
|||||||
const s = this.statusList.find(x => x.name === name);
|
const s = this.statusList.find(x => x.name === name);
|
||||||
return s ? s.status : '未知';
|
return s ? s.status : '未知';
|
||||||
},
|
},
|
||||||
isPrinterOffline(printer) {
|
|
||||||
const raw = printer && printer.workOffline;
|
|
||||||
if (typeof raw === 'boolean') {
|
|
||||||
return raw;
|
|
||||||
}
|
|
||||||
|
|
||||||
const normalized = String(raw || '').trim().toLowerCase();
|
|
||||||
return normalized === 'true' || normalized === '1' || normalized === 'yes';
|
|
||||||
},
|
|
||||||
loadPrinters() {
|
loadPrinters() {
|
||||||
wsSendWithCallback('printer.getWindowsPrinters', {}, (data) => {
|
wsSendWithCallback('printer.getWindowsPrinters', {}, (data) => {
|
||||||
if (data.success) {
|
if (data.success) {
|
||||||
|
|||||||
8
降低被杀软误报.todo
Normal file
8
降低被杀软误报.todo
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
降低被杀软误报 TODO(暂缓)
|
||||||
|
|
||||||
|
状态:暂不纳入当前计划(2026-03-29)
|
||||||
|
|
||||||
|
说明:
|
||||||
|
- 本文件已清理为留档说明,不作为当前迭代执行清单。
|
||||||
|
- 已完成的 P0 改造保留在代码中(签名流程、NSIS 分发收敛、Bypass 收敛)。
|
||||||
|
- 后续若恢复计划,建议从“替换正式 CA 代码签名证书”开始。
|
||||||
Loading…
x
Reference in New Issue
Block a user