Skip to content

Commit

Permalink
移动游戏信息的位置 添加加载动画 使游戏信息加载延迟时不会发生错误
Browse files Browse the repository at this point in the history
  • Loading branch information
RERASER committed Sep 23, 2024
1 parent eee64b3 commit d93ad9b
Show file tree
Hide file tree
Showing 14 changed files with 271 additions and 251 deletions.
5 changes: 2 additions & 3 deletions assets/launcher-ui/src/env.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,7 @@ interface Window {
minimize: () => void;
mounted: () => void;
shellExecute: (file: string, args?: string) => void;
detectGameInstall: (gameIndex: number) => Promise<string[]>;
detectGameInstall1: (gameIndex: number) => Promise<GameMeta>;
detectGameInstall: (gameIndex: number) => Promise<GameMeta>;
readFile: (path: string) => Promise<string | undefined>;
writeFile: (path: string, content: string) => Promise<void>;
uuid: () => Promise<string>;
Expand All @@ -66,7 +65,7 @@ interface Window {
__cb: ((message: string, color: string, timeout: number) => void) | undefined;
},
ctx: {
gameInfos: Ref<GameMeta[]>;
// gameInfos: Ref<GameMeta[]>;
},
},
chrome: any;
Expand Down
57 changes: 11 additions & 46 deletions assets/launcher-ui/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { launcher } from './modules/launcher';
import { iidx } from './modules/iidx';
import { sdvx } from './modules/sdvx';
import { parseJsonText } from 'typescript';
import { gitadora } from './modules/gitadora';

window.laochan = {
close() {
Expand All @@ -25,10 +26,7 @@ window.laochan = {
window.saucer.call('shellExecute', [file, args]);
},
async detectGameInstall(game: number) {
return await window.saucer.call<string[]>('detectGameInstall', [game]);
},
async detectGameInstall1(game: number) {
return JSON.parse(await window.saucer.call<string>('detectGameInstall1', [game]));
return JSON.parse(await window.saucer.call<string>('detectGameInstall', [game]));
},
async readFile(path: string) {
const result = await window.saucer.call<string>('readFile', [path]);
Expand Down Expand Up @@ -74,40 +72,7 @@ window.laochan = {
},
num: () => {},
ctx: {
gameInfos: ref<GameMeta[]>([{
game_type: 0,
game_name: '',
installed: false,
install_path: '',
resource_path: '',
game_module_path: '',
settings_module_path: '',
updater_module_path: '',
game_module_version: '',
game_module_target_version: ''
},{
game_type: 0,
game_name: '',
installed: false,
install_path: '',
resource_path: '',
game_module_path: '',
settings_module_path: '',
updater_module_path: '',
game_module_version: '',
game_module_target_version: ''
},{
game_type: 0,
game_name: '',
installed: false,
install_path: '',
resource_path: '',
game_module_path: '',
settings_module_path: '',
updater_module_path: '',
game_module_version: '',
game_module_target_version: ''
}]),
gameInfos: ref<GameMeta[]>(new Array<GameMeta>(3)),
},
alert: {
__cb: undefined,
Expand All @@ -122,15 +87,15 @@ window.laochan = {
};

(async () => {
for (let i = 0; i < 3; i++) {
// window.laochan.ctx.gameInfos.value[i] = await window.laochan.detectGameInstall(i);
window.laochan.ctx.gameInfos.value[i] = await window.laochan.detectGameInstall1(i);
}
launcher.loadConfig();
iidx.loadConfig();
sdvx.loadConfig();

await launcher.loadConfig();
await iidx.loadConfig();
await sdvx.loadConfig();
await iidx.UpdateMeta();
await sdvx.UpdateMeta();
await gitadora.UpdateMeta();
})();

const app = createApp(App)
app.use(router)
app.mount('#app')
app.mount('#app')
19 changes: 13 additions & 6 deletions assets/launcher-ui/src/modules/gitadora.ts
Original file line number Diff line number Diff line change
@@ -1,28 +1,35 @@
import { ref, type Ref } from "vue";
import { launcher, VersionState } from "./launcher";
import type { RefSymbol } from "@vue/reactivity";
import { faL } from "@fortawesome/free-solid-svg-icons";

export interface GITADORAConfig {
}

export class GITADORA {
private _config: Ref<GITADORAConfig | undefined> = ref(undefined);
private _dirty: boolean = false;
public GameMeta: Ref<GameMeta | undefined> = ref(undefined);
public GameVersionState: Ref<VersionState> = ref(VersionState.Unknown);

get config() {
return this._config;
}

installed() {
return !!window.laochan.ctx.gameInfos.value[2].installed;
return this.GameMeta.value?.installed ?? false;
}

async UpdateMeta() {
this.GameMeta.value = await window.laochan.detectGameInstall(2);
this.GameVersionState.value = this.checkVersion();
}

get installPath() {
if (!this.installed()) {
return;
}

const [installPath] = window.laochan.ctx.gameInfos.value[2].install_path;
return installPath;
return this.GameMeta.value!.install_path;
}

get configPath() {
Expand All @@ -38,8 +45,8 @@ export class GITADORA {
if (!this.installed()) {
return VersionState.Unknown;
}
const installVersion = window.laochan.ctx.gameInfos.value[2].game_module_version;
const targetVersion = window.laochan.ctx.gameInfos.value[2].game_module_target_version;
const installVersion = this.GameMeta.value!.game_module_version;
const targetVersion = this.GameMeta.value!.game_module_target_version;
const installVersionNum = Number.parseInt(installVersion.split(":")[4]);
const targetVersionNum = Number.parseInt(targetVersion.split(":")[4]);
if (installVersionNum > targetVersionNum) {
Expand Down
17 changes: 11 additions & 6 deletions assets/launcher-ui/src/modules/iidx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,22 +35,27 @@ export interface IIDXConfig {
export class IIDX {
private _config: Ref<IIDXConfig | undefined> = ref(undefined);
private _dirty: boolean = false;
public GameMeta: Ref<GameMeta | undefined> = ref(undefined);
public GameVersionState: Ref<VersionState> = ref(VersionState.Unknown);

get config() {
return this._config;
}

installed() {
return !!window.laochan.ctx.gameInfos.value[0].installed;
return this.GameMeta.value?.installed??false;
}

async UpdateMeta() {
this.GameMeta.value = await window.laochan.detectGameInstall(0);
this.GameVersionState.value = this.checkVersion();
}

get installPath() {
if (!this.installed()) {
return;
}

const installPath = window.laochan.ctx.gameInfos.value[0].install_path;
return installPath;
return this.GameMeta.value!.install_path;
}

get configPath() {
Expand All @@ -66,8 +71,8 @@ export class IIDX {
if (!this.installed()) {
return VersionState.Unknown;
}
const installVersion = window.laochan.ctx.gameInfos.value[0].game_module_version;
const targetVersion = window.laochan.ctx.gameInfos.value[0].game_module_target_version;
const installVersion = this.GameMeta.value!.game_module_version;
const targetVersion = this.GameMeta.value!.game_module_target_version;
const installVersionNum = Number.parseInt(installVersion.split(":")[4]);
const targetVersionNum = Number.parseInt(targetVersion.split(":")[4]);
if (installVersionNum > targetVersionNum) {
Expand Down
17 changes: 11 additions & 6 deletions assets/launcher-ui/src/modules/sdvx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,27 @@ export interface SDVXConfig {
export class SDVX {
private _config: Ref<SDVXConfig | undefined> = ref(undefined);
private _dirty: boolean = false;
public GameMeta: Ref<GameMeta | undefined> = ref(undefined);
public GameVersionState: Ref<VersionState> = ref(VersionState.Unknown);

get config() {
return this._config;
}

installed() {
return !!window.laochan.ctx.gameInfos.value[1].installed;
return this.GameMeta.value?.installed??false;
}

async UpdateMeta() {
this.GameMeta.value = await window.laochan.detectGameInstall(1);
this.GameVersionState.value = this.checkVersion();
}

get installPath() {
if (!this.installed()) {
return;
}

const [installPath] = window.laochan.ctx.gameInfos.value[1].install_path;
return installPath;
return this.GameMeta.value!.install_path;
}

get configPath() {
Expand All @@ -38,8 +43,8 @@ export class SDVX {
if (!this.installed()) {
return VersionState.Unknown;
}
const installVersion = window.laochan.ctx.gameInfos.value[1].game_module_version;
const targetVersion = window.laochan.ctx.gameInfos.value[1].game_module_target_version;
const installVersion = this.GameMeta.value!.game_module_version;
const targetVersion = this.GameMeta.value!.game_module_target_version;
const installVersionNum = Number.parseInt(installVersion.split(":")[4]);
const targetVersionNum = Number.parseInt(targetVersion.split(":")[4]);
if (installVersionNum > targetVersionNum) {
Expand Down
Loading

0 comments on commit d93ad9b

Please sign in to comment.