Skip to content
This repository has been archived by the owner on Jun 6, 2023. It is now read-only.

Commit

Permalink
refactor: 重构部分类名
Browse files Browse the repository at this point in the history
  • Loading branch information
asforest committed Dec 18, 2021
1 parent 64cb646 commit 44b9ef5
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 21 deletions.
6 changes: 3 additions & 3 deletions src/main/Update.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Updater } from "./Updater"
import { UpdaterApplication } from "./UpdaterApplication"
import { FileObject } from "./utils/FileObject"
import { CommonMode } from "./workmode/CommonMode"
import { ExistMode } from "./workmode/ExistMode"
Expand Down Expand Up @@ -31,11 +31,11 @@ export interface DownloadTask

export class Update
{
updater: Updater
updater: UpdaterApplication
workdir: FileObject
config: any

constructor(updater: Updater)
constructor(updater: UpdaterApplication)
{
this.updater = updater
this.workdir = updater.workdir
Expand Down
12 changes: 5 additions & 7 deletions src/main/Updater.ts → src/main/UpdaterApplication.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { ConfigFileNotFoundException } from "./exceptions/ConfigFileNotFoundExce
import { Update } from "./Update";
import { FileObject } from "./utils/FileObject";
import { LogSys } from "./logging/LogSys";
import { UpdaterWindow } from "./UpdaterWindow";
import { Window } from "./windows/Window";
import { app, dialog } from "electron";
import { FileNotExistException } from "./exceptions/FileNotExistException";
import path = require('path')
Expand All @@ -14,20 +14,20 @@ const packagejson = require('../../package.json')
import bytesConvert from './utils/ByteConvert'
import StackShorten from "./utils/StackShorten";

export class Updater
export class UpdaterApplication
{
workdir = null as unknown as FileObject
progdir = null as unknown as FileObject
config = null as any
uwin = null as unknown as UpdaterWindow
uwin = null as unknown as Window
updateObj = null as unknown as Update
exitcode = 0

async main(): Promise<void>
{
try {
this.singleInstance()
this.uwin = new UpdaterWindow(this)
this.uwin = new Window(this)

this.progdir = new FileObject(app.isPackaged && '_LW_EXEDIR' in process.env ? process.env['_LW_EXEDIR']!! : process.cwd())
this.progdir = app.isPackaged ? this.progdir : this.progdir.append('debug-directory')
Expand Down Expand Up @@ -116,10 +116,8 @@ export class Updater
} catch (error) {
let stack = StackShorten(error.stack)
dialog.showErrorBox('发生错误 '+packagejson.version, stack)
app.exit(1)
LogSys.error(stack)
} finally {

app.exit(1)
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/main/main.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
require('source-map-support').install();
const { Updater } = require("./Updater");
const { UpdaterApplication } = require("./UpdaterApplication");

new Updater().main()
new UpdaterApplication().main()
17 changes: 17 additions & 0 deletions src/main/windows/ErrorDialog.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { app, BrowserWindow } from "electron";

export class Window
{
win = null as unknown as BrowserWindow

static async Show(title: string, content: string)
{
let window = await new Promise((a, b) => {
let create = () => a(new BrowserWindow())
app.isReady()? create() : app.on('ready', () => create())
})


return window
}
}
18 changes: 9 additions & 9 deletions src/main/UpdaterWindow.ts → src/main/windows/Window.ts
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
import { app, BrowserWindow, ipcMain, IpcMainEvent, IpcMainInvokeEvent } from "electron";
import { FileObject } from "./utils/FileObject";
import { LogSys } from "./logging/LogSys";
import { Updater } from "./Updater";
import { FileObject } from "../utils/FileObject";
import { LogSys } from "../logging/LogSys";
import { UpdaterApplication } from "../UpdaterApplication";
import child_process = require('child_process')
import iconv = require('iconv-lite');
import path = require('path')
import strReplace from './utils/StringReplace'
import StackShorten from "./utils/StackShorten";
const packagejson = require('../../package.json')
import strReplace from '../utils/StringReplace'
import StackShorten from "../utils/StackShorten";
const packagejson = require('../../../package.json')

export class UpdaterWindow
export class Window
{
updater: Updater
updater: UpdaterApplication
win = null as unknown as BrowserWindow

onAllClosed = () => { app.quit() }

private processes: child_process.ChildProcess[] = []

constructor(updater: Updater)
constructor(updater: UpdaterApplication)
{
this.updater = updater
}
Expand Down

0 comments on commit 44b9ef5

Please sign in to comment.