mirror of
https://github.com/snltty/linker.git
synced 2025-10-21 16:19:27 +08:00
修复虚拟网卡添加路由错误,和增加自动更新
This commit is contained in:
@@ -18,7 +18,6 @@ namespace linker.service
|
||||
protected override void OnStart(string[] _args)
|
||||
{
|
||||
OpenExe();
|
||||
OpenExeTray();
|
||||
CheckMainProcess();
|
||||
}
|
||||
protected override void OnStop()
|
||||
@@ -29,7 +28,6 @@ namespace linker.service
|
||||
}
|
||||
|
||||
private Process proc;
|
||||
private Process procTray;
|
||||
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()
|
||||
{
|
||||
try
|
||||
{
|
||||
KillExe();
|
||||
KillExeTray();
|
||||
|
||||
Environment.Exit(1);
|
||||
}
|
||||
catch (Exception)
|
||||
|
12
linker.tray.win/build_error_log.txt
Normal file
12
linker.tray.win/build_error_log.txt
Normal 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'
|
BIN
linker.tray.win/dist/linker.tray.win.exe
vendored
BIN
linker.tray.win/dist/linker.tray.win.exe
vendored
Binary file not shown.
@@ -15,6 +15,15 @@ if(!atom){
|
||||
/*为窗口设置原子值可以避免一个程序重复运行多个实例*/
|
||||
win.quitMessage(); return;
|
||||
};
|
||||
import fsys;
|
||||
import fsys.file;
|
||||
try{
|
||||
fsys.delete(io._exefile+".temp");
|
||||
}
|
||||
catch(e){
|
||||
|
||||
}
|
||||
|
||||
|
||||
mainForm.serviceName = "linker.service";
|
||||
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()
|
||||
{
|
||||
import process.popen;
|
||||
@@ -214,4 +229,26 @@ if(!_ARGV["task"])
|
||||
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();
|
@@ -121,7 +121,7 @@ export default {
|
||||
//已解压
|
||||
else if(updateInfo.Status == 6){
|
||||
|
||||
ElMessageBox.confirm('确定关闭程序吗?如果你是以服务形式安装,关闭后应该会自动再次启动', '提示', {
|
||||
ElMessageBox.confirm('确定关闭程序吗?', '提示', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
|
Reference in New Issue
Block a user