修复虚拟网卡添加路由错误,和增加自动更新

This commit is contained in:
snltty
2024-07-18 10:25:58 +08:00
parent a923720124
commit 2024e1ee3d
5 changed files with 51 additions and 58 deletions

View File

@@ -18,7 +18,6 @@ namespace linker.service
protected override void OnStart(string[] _args) protected override void OnStart(string[] _args)
{ {
OpenExe(); OpenExe();
OpenExeTray();
CheckMainProcess(); CheckMainProcess();
} }
protected override void OnStop() protected override void OnStop()
@@ -29,7 +28,6 @@ namespace linker.service
} }
private Process proc; private Process proc;
private Process procTray;
private void CheckMainProcess() private void CheckMainProcess()
{ {
@@ -105,65 +103,11 @@ namespace linker.service
} }
} }
private bool OpenExeTray()
{
try
{
string filename = Process.GetCurrentProcess().MainModule.FileName;
string dir = Path.GetDirectoryName(filename);
procTray = Process.Start(new ProcessStartInfo()
{
WorkingDirectory = dir,
FileName = Path.Combine(dir, $"{mainExeName}.tray.win.exe"),
Arguments = "--task=1",
Verb = "runas",
});
return true;
}
catch (Exception)
{
try
{
procTray.Kill();
procTray.Dispose();
}
catch (Exception)
{
}
procTray = null;
}
return false;
}
private void KillExeTray()
{
try
{
procTray?.Close();
procTray?.Dispose();
foreach (var item in Process.GetProcessesByName($"{mainExeName}.tray.win"))
{
item.Kill();
}
}
catch (Exception)
{
}
finally
{
procTray = null;
}
}
public void RestartService() public void RestartService()
{ {
try try
{ {
KillExe(); KillExe();
KillExeTray();
Environment.Exit(1); Environment.Exit(1);
} }
catch (Exception) catch (Exception)

View File

@@ -0,0 +1,12 @@
错误发生在文件---------------:
C:\Users\snltty\Desktop\linker\linker.tray.win\main.aardio
错误信息---------------:
{Error}:
{Line}:#240
{File}:C:\Users\snltty\Desktop\linker\linker.tray.win\main.aardio
{Error}:
{Expected}:')'
{Match for}:'('
{Match line}:227
{Near}:'catch'

Binary file not shown.

View File

@@ -15,6 +15,15 @@ if(!atom){
/*为窗口设置原子值可以避免一个程序重复运行多个实例*/ /*为窗口设置原子值可以避免一个程序重复运行多个实例*/
win.quitMessage(); return; win.quitMessage(); return;
}; };
import fsys;
import fsys.file;
try{
fsys.delete(io._exefile+".temp");
}
catch(e){
}
mainForm.serviceName = "linker.service"; mainForm.serviceName = "linker.service";
mainForm.exeName = "linker.service.exe"; mainForm.exeName = "linker.service.exe";
@@ -79,7 +88,13 @@ mainForm.showPopmenu = function(){
} }
mainForm.reStart = function()
{
win.quitMessage();
mainForm.close();
import process.popen;
var prcs = process.popen.cmd("start "+io._exefile+" --task=1");
}
mainForm.failureService = function() mainForm.failureService = function()
{ {
import process.popen; import process.popen;
@@ -214,4 +229,26 @@ if(!_ARGV["task"])
mainForm.show(); mainForm.show();
} }
mainForm.setInterval(
function(){
import fsys;
import process.popen;
try{
if(io.exist(io._exefile+".temp"))
{
var prcs = process.popen.cmd("tasklist | findstr "+mainForm.serviceName);
var str = prcs.readAll();
if(!!string.indexOf(str,mainForm.serviceName))
{
mainForm.reStart();
}
}
}catch(e)
{
}
return true;
},1000
)
return win.loopMessage(); return win.loopMessage();

View File

@@ -121,7 +121,7 @@ export default {
//已解压 //已解压
else if(updateInfo.Status == 6){ else if(updateInfo.Status == 6){
ElMessageBox.confirm('确定关闭程序吗?如果你是以服务形式安装,关闭后应该会自动再次启动', '提示', { ElMessageBox.confirm('确定关闭程序吗?', '提示', {
confirmButtonText: '确定', confirmButtonText: '确定',
cancelButtonText: '取消', cancelButtonText: '取消',
type: 'warning' type: 'warning'