1
0
mirror of https://gitee.com/sui-feng-cb/AzurLaneAutoScript1 synced 2026-03-14 10:46:02 +08:00

Opt: AP preserve until reset

This commit is contained in:
sui-feng-cb
2025-09-03 13:59:51 +08:00
parent c3856ae101
commit 6b0383a169
137 changed files with 9982 additions and 13706 deletions

View File

@@ -1,59 +0,0 @@
import {ALAS_CONFIG_YAML} from '@common/constant/config';
import {getAlasABSPath, checkIsFirst} from '@common/utils';
import {ThemeObj} from '@common/constant/theme';
import {Dirent} from 'fs';
const path = require('path');
const yaml = require('yaml');
const fs = require('fs');
let alasConfig: AlasConfig | null = null;
export async function getAlasConfig() {
if (alasConfig === null) {
const alasPath = getAlasABSPath();
const file = fs.readFileSync(path.join(alasPath, `./config/${ALAS_CONFIG_YAML}`), 'utf8');
const config = yaml.parse(file) as DefAlasConfig;
const WebuiPort = config.Deploy.Webui.WebuiPort.toString();
const Theme = config.Deploy.Webui.Theme;
alasConfig = {
webuiUrl: `http://127.0.0.1:${WebuiPort}`,
theme: ThemeObj[Theme] || 'light',
language: config.Deploy.Webui.Language || 'en-US',
repository: config.Deploy.Git.Repository as any,
alasPath,
};
}
return alasConfig;
}
export function checkIsNeedInstall() {
return checkIsFirst();
}
interface fileInfoItem {
name: string;
path: string;
lastModifyTime: Date;
}
export function getAlasConfigDirFiles() {
const alasPath = getAlasABSPath();
const configPath = path.join(alasPath, `./config`);
const files: Dirent[] = fs.readdirSync(configPath, {withFileTypes: true});
const filesInfoList: fileInfoItem[] = files.map((file: Dirent) => {
const name = file.name;
const filePath = path.join(configPath, name);
return {
name,
path: filePath,
lastModifyTime: getFileUpdateDate(filePath),
};
});
return {
configPath,
files: filesInfoList,
};
}
export function getFileUpdateDate(path: string) {
const stat = fs.statSync(path);
return stat.mtime;
}

View File

@@ -1,13 +0,0 @@
import {ipcRenderer} from 'electron';
import IpcRenderer = Electron.IpcRenderer;
export function ipcRendererSend(channel: string, ...args: any[]): void {
ipcRenderer.send(channel, ...args);
}
export function ipcRendererOn(
channel: string,
listener: (event: Electron.IpcRendererEvent, ...args: any[]) => void,
): IpcRenderer {
return ipcRenderer.on(channel, listener);
}

View File

@@ -1,10 +1,17 @@
/**
* @module preload
*/
import {contextBridge} from 'electron';
export {sha256sum} from './nodeCrypto';
export {versions} from './versions';
export {ipcRendererSend, ipcRendererOn} from './electronApi';
export {getAlasConfig, checkIsNeedInstall, getAlasConfigDirFiles} from './alasConfig';
export {copyFilesToDir} from '@common/utils/copyFilesToDir';
export {modifyConfigYaml} from './modifyConfigYaml';
const apiKey = 'electron';
/**
* @see https://github.com/electron/electron/issues/21437#issuecomment-573522360
*/
const api: ElectronApi = {
versions: process.versions,
};
/**
* The "Main World" is the JavaScript context that your main renderer code runs in.
* By default, the page you load in your renderer executes code in this world.
*
* @see https://www.electronjs.org/docs/api/context-bridge
*/
contextBridge.exposeInMainWorld(apiKey, api);

View File

@@ -1,8 +0,0 @@
import {join, normalize} from 'path';
import {modifyYaml} from '@common/utils';
import {ALAS_CONFIG_YAML} from '@common/constant/config';
export function modifyConfigYaml(path: string, keyObj: {[k in string]: any}) {
const configYamlPath = join(normalize(path) + `./config/${ALAS_CONFIG_YAML}`);
return modifyYaml(configYamlPath, keyObj);
}

View File

@@ -1,5 +0,0 @@
import {type BinaryLike, createHash} from 'node:crypto';
export function sha256sum(data: BinaryLike) {
return createHash('sha256').update(data).digest('hex');
}

View File

@@ -1 +0,0 @@
export {versions} from 'node:process';