Skip to content

Commit

Permalink
Merge pull request #99 from HoraceHuang-ui/horace_dev
Browse files Browse the repository at this point in the history
Horace dev
  • Loading branch information
HoraceHuang-ui authored May 8, 2024
2 parents 73ef0d0 + e2cfd42 commit 9ec8986
Show file tree
Hide file tree
Showing 25 changed files with 799 additions and 102 deletions.
7 changes: 7 additions & 0 deletions electron-builder.json5
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,12 @@
"src/assets/hi3banner.webp",
"src/assets/gpIcons/Xbox/*",
"src/assets/gpIcons/PS/*",
{
"from": "node_modules/regedit/vbs",
"to": "regedit/vbs",
"filter": [
"**/*",
],
},
],
}
104 changes: 98 additions & 6 deletions electron/main/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,13 @@ import { DynamicTextAssets, EnkaClient, TextAssets } from 'enka-network-api'
import { promises as fs } from 'fs'
import { Octokit } from '@octokit/core'
import path from 'path'
import { useStore } from '../../src/store'
import { createPinia } from 'pinia'
import piniaPluginPersistedstate from 'pinia-plugin-persistedstate'
import regedit, { promisified as reg } from 'regedit'
import { SrRegInfo } from '../../src/types/starrail/srRegInfo'
import { GsRegInfo } from '../../src/types/genshin/gsRegInfo'
import { Hi3RegInfo } from '../../src/types/honkai3/hi3RegInfo'

const pinia = createPinia()
pinia.use(piniaPluginPersistedstate)
regedit.setExternalVBSLocation('resources/regedit/vbs')

const store = useStore(pinia)
const enka = new EnkaClient({
requestTimeout: 10000,
})
Expand Down Expand Up @@ -316,6 +315,99 @@ async function createWindow() {
return result
})

ipcMain.on('reg:gsSet', (_event, acc: string) => {
// await reg.deleteKey(['HKCU\\Software\\miHoYo\\原神'])
// await reg.createKey(['HKCU\\Software\\miHoYo\\原神'])
const account = JSON.parse(acc)

reg.putValue({
'HKCU\\Software\\miHoYo\\原神': {
// GENERAL_DATA_h2389025596: {
// value: account.generalData,
// type: 'REG_BINARY',
// },
MIHOYOSDK_ADL_PROD_CN_h3123967166: {
value: account.mihoyoSdk,
type: 'REG_BINARY',
},
},
})
})

ipcMain.on('reg:srSet', (_event, acc: string) => {
// await reg.deleteKey(['HKCU\\Software\\miHoYo\\崩坏:星穹铁道'])
// await reg.createKey(['HKCU\\Software\\miHoYo\\崩坏:星穹铁道'])
const account = JSON.parse(acc)

reg.putValue({
'HKCU\\Software\\miHoYo\\崩坏:星穹铁道': {
MIHOYOSDK_ADL_PROD_CN_h3123967166: {
value: account.mihoyoSdk,
type: 'REG_BINARY',
},
// App_LastUserID_h2841727341: {
// value: account.lastUserId,
// type: 'REG_DWORD',
// },
},
})
})

ipcMain.handle('reg:gsGet', async (): Promise<GsRegInfo> => {
const result = (await reg.list(['HKCU\\Software\\miHoYo\\原神']))[
'HKCU\\Software\\miHoYo\\原神'
]
return result.exists && result.values
? {
name: '',
// generalData: result.values.GENERAL_DATA_h2389025596.value as number[],
mihoyoSdk: result.values.MIHOYOSDK_ADL_PROD_CN_h3123967166
.value as number[],
}
: undefined
})

ipcMain.on('reg:hi3Set', (_event, acc: string) => {
const account = JSON.parse(acc)

reg.putValue({
'HKCU\\Software\\miHoYo\\崩坏3': {
MIHOYOSDK_ADL_PROD_CN_h3123967166: {
value: account.mihoyoSdk,
type: 'REG_BINARY',
},
},
})
})

ipcMain.handle('reg:hi3Get', async (): Promise<Hi3RegInfo> => {
const result = (await reg.list(['HKCU\\Software\\miHoYo\\崩坏3']))[
'HKCU\\Software\\miHoYo\\崩坏3'
]
return result.exists && result.values
? {
name: '',
mihoyoSdk: result.values.MIHOYOSDK_ADL_PROD_CN_h3123967166
.value as number[],
}
: undefined
})

ipcMain.handle('reg:srGet', async (): Promise<SrRegInfo> => {
const result = (await reg.list(['HKCU\\Software\\miHoYo\\崩坏:星穹铁道']))[
'HKCU\\Software\\miHoYo\\崩坏:星穹铁道'
]
console.log(result)
return result.exists && result.values
? {
name: '',
// lastUserId: result.values.App_LastUserID_h2841727341.value as number,
mihoyoSdk: result.values.MIHOYOSDK_ADL_PROD_CN_h3123967166
.value as number[],
}
: undefined
})

// --------- Window configs ------------
// win.setWindowButtonVisibility(true)
// nativeTheme.themeSource = 'light'
Expand Down
20 changes: 20 additions & 0 deletions electron/preload/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,26 @@ contextBridge.exposeInMainWorld('github', {
return await ipcRenderer.invoke('github:getLatestRelease')
},
})
contextBridge.exposeInMainWorld('reg', {
gsGet: async () => {
return await ipcRenderer.invoke('reg:gsGet')
},
srGet: async () => {
return await ipcRenderer.invoke('reg:srGet')
},
hi3Get: async () => {
return await ipcRenderer.invoke('reg:hi3Get')
},
gsSet: (account: string) => {
ipcRenderer.send('reg:gsSet', account)
},
srSet: (account: string) => {
ipcRenderer.send('reg:srSet', account)
},
hi3Set: (account: string) => {
ipcRenderer.send('reg:hi3Set', account)
},
})

function domReady(
condition: DocumentReadyState[] = ['complete', 'interactive'],
Expand Down
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "miXeD",
"version": "2.6.0",
"version": "2.6.1",
"main": "dist-electron/main/index.js",
"description": "All-in-one miHoYo game launcher",
"author": "HoraceHYY <[email protected]>",
Expand All @@ -25,6 +25,7 @@
},
"devDependencies": {
"@electron-forge/cli": "^7.3.0",
"@types/winreg": "^1.2.36",
"@vitejs/plugin-vue": "^5.0.4",
"@vue/eslint-config-typescript": "^10.0.0",
"autoprefixer": "^10.4.18",
Expand Down Expand Up @@ -55,6 +56,7 @@
"enka-network-api": "^4.3.0",
"marked": "^12.0.1",
"path": "^0.12.7",
"regedit": "^5.1.3",
"sass": "^1.72.0",
"vue-i18n": "^9.10.1"
}
Expand Down
19 changes: 10 additions & 9 deletions src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -171,15 +171,16 @@ onMounted(async () => {
{
title: translate('updDialog_title'),
showCancel: true,
vnode: h(UpdateDialogContent, {
appVer: appVer,
updInfo: updInfo.value,
skipCurrent: skipCurrent.value,
'onUpdate:skipCurrent': (value: boolean) => {
skipCurrent.value = value
},
gameStyle: store.settings.appearance.dialogStyle,
}),
vnode: () =>
h(UpdateDialogContent, {
appVer: appVer,
updInfo: updInfo.value,
skipCurrent: skipCurrent.value,
'onUpdate:skipCurrent': (value: boolean) => {
skipCurrent.value = value
},
gameStyle: store.settings.appearance.dialogStyle,
}),
},
)
}
Expand Down
9 changes: 7 additions & 2 deletions src/components/MyDropdown.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script setup lang="ts">
import { computed, PropType, ref } from 'vue'
import { computed, defineModel, PropType, ref } from 'vue'
const props = defineProps({
items: {
Expand Down Expand Up @@ -31,6 +31,10 @@ const props = defineProps({
},
})
const showDropdown = defineModel({
default: false,
})
const emit = defineEmits(['command'])
const wrapperStyles: Record<string, any> = {
Expand Down Expand Up @@ -80,6 +84,7 @@ const transform = computed(() => {
})
const hideMenu = () => {
showDropdown.value = false
showMenu.value = false
clearTimeout(timer)
timer = undefined
Expand Down Expand Up @@ -130,7 +135,7 @@ const sendCommand = (idx: number) => {
<div
class="dropdown-wrapper"
:style="{ ...wrapperStyles[placement], width: width }"
v-if="showMenu"
v-if="showMenu || showDropdown"
ref="dropdownRef"
>
<div
Expand Down
21 changes: 8 additions & 13 deletions src/components/UpdateDialogContent.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import { marked } from 'marked'
import { translate } from '../i18n'
import MyCheckbox from './MyCheckbox.vue'
import { computed, PropType, ref } from 'vue'
import { computed, PropType } from 'vue'
import ScrollWrapper from './ScrollWrapper.vue'
const props = defineProps({
Expand All @@ -14,22 +14,17 @@ const props = defineProps({
type: Object,
required: true,
},
showSkipCurrent: {
type: Boolean,
default: true,
},
skipCurrent: {
type: Boolean,
default: false,
},
gameStyle: {
type: String as PropType<'gs' | 'sr' | 'hi3'>,
default: 'gs',
},
skipCurrent: {
type: Boolean,
required: true,
},
})
defineEmits(['update:skipCurrent'])
const skip = ref(props.skipCurrent)
defineEmits(['update:skipCurrent'])
const updDialogContent = marked(props.updInfo.body)
Expand Down Expand Up @@ -83,8 +78,8 @@ const colorClass = computed(() => {
{{ translate('updDialog_footerText') }}
</div>
<MyCheckbox
v-if="showSkipCurrent"
v-model="skip"
:model-value="skipCurrent"
@update:model-value="(nv: boolean) => $emit('update:skipCurrent', nv)"
:text="translate('updDialog_skipCurrent')"
:on-color="onColor"
:off-color="offColor"
Expand Down
10 changes: 9 additions & 1 deletion src/i18n/en_US.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,17 @@
"general_gameImportTitle": "Select {game} executable",
"general_openOfficialLauncher": "Open official launcher",
"general_clearGamePath": "Clear game path",
"general_clearProfileInfo": "Clear profile info",
"general_clearProfileInfo": "Clear player info",
"general_clearAccounts": "Clear accounts",
"general_loadingFailed": "Error Loading Page",
"general_back": "Back",
"general_refresh": "Refresh",
"general_account": "Account",
"general_doNotModify": "Do Not Modify",
"general_addAccountTitle": "Add Account",
"general_addAccountMsg": "After clicking Confirm, the current logged-in account information in game will be read from system registry, and you can quickly launch from this account later. Please distinguish carefully if there are duplicate names.",
"general_addAccountWarning": "Available for Mainland CN server only!!!",
"general_addAccountPlaceholder": "Please name the current account",
"POST_TYPE_INFO": "Info",
"POST_TYPE_ANNOUNCE": "Announce",
"POST_TYPE_ACTIVITY": "Activity",
Expand Down Expand Up @@ -109,6 +116,7 @@
"gamepad_init": "Gamepad Mode",
"gamepad_selectGame": "Select Game",
"gamepad_officialLauncher": "Official Launcher",
"gamepad_selectAccount": "Select Account",
"gamepad_selectSettingItem": "Settings Item",
"gamepad_selectSettingCard": "Category",
"gamepad_playerInfo": "Player Info",
Expand Down
10 changes: 9 additions & 1 deletion src/i18n/fr_FR.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,17 @@
"general_gameImportTitle": "Sélectionnez l'exécutable {game}",
"general_openOfficialLauncher": "Ouvrir le lanceur officiel",
"general_clearGamePath": "Effacer le chemin de jeu",
"general_clearProfileInfo": "Effacer les informations du profil",
"general_clearProfileInfo": "Effacer les info sur le joueur",
"general_clearAccounts": "Effacer les comptes",
"general_loadingFailed": "Erreur lors du chargement de la page",
"general_back": "Retour",
"general_refresh": "Rafraîchir",
"general_account": "Compte",
"general_doNotModify": "Pas de Modifications",
"general_addAccountTitle": "Ajouter un Compte",
"general_addAccountMsg": "Après avoir cliqué sur Confirmer, les informations du compte actuellement connecté au jeu seront lues à partir du registre système et vous pourrez rapidement lancer à partir de ce compte plus tard. Veuillez distinguer soigneusement s'il existe des noms en double.",
"general_addAccountWarning": "Disponible uniquement pour le serveur de Chine continentale!!!",
"general_addAccountPlaceholder": "Veuillez nommer le compte courant",
"POST_TYPE_INFO": "Infos",
"POST_TYPE_ANNOUNCE": "Annonce",
"POST_TYPE_ACTIVITY": "Activité",
Expand Down Expand Up @@ -111,6 +118,7 @@
"gamepad_character": "Personnage",
"gamepad_selectGame": "Sélectionnez un jeu",
"gamepad_officialLauncher": "Lanceur Officiel",
"gamepad_selectAccount": "Sélectionnez un compte",
"gamepad_selectSettingItem": "élément",
"gamepad_selectSettingCard": "catégorie",
"gamepad_autoEnterGamepad": "Saisie automatique lorsque connecté",
Expand Down
10 changes: 9 additions & 1 deletion src/i18n/ja_JP.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,17 @@
"general_gameImportTitle": "{game} の実行可能ファイルを選択",
"general_openOfficialLauncher": "公式ランチャーを開く",
"general_clearGamePath": "ゲームのパスを消去",
"general_clearProfileInfo": "プロフィール情報を消去",
"general_clearProfileInfo": "プレイヤー情報をクリアする",
"general_clearAccounts": "アカウントをクリアする",
"general_loadingFailed": "今、ページ読み込みエラー",
"general_back": "戻る",
"general_refresh": "リフレッシュ",
"general_account": "アカウント",
"general_doNotModify": "変更しないでください",
"general_addAccountTitle": "アカウントを追加する",
"general_addAccountMsg": "[確認] をクリックすると、ゲーム内で現在ログインしているアカウント情報がシステム レジストリから読み取られ、後でこのアカウントからすぐに起動できるようになります。 名前が重複している場合は、慎重に区別してください。",
"general_addAccountWarning": "中国本土サーバーのみで利用可能!!!",
"general_addAccountPlaceholder": "アカウントの命名",
"POST_TYPE_INFO": "情報",
"POST_TYPE_ANNOUNCE": "お知らせ",
"POST_TYPE_ACTIVITY": "イベント",
Expand Down Expand Up @@ -109,6 +116,7 @@
"gamepad_init": "ゲームパッドモード",
"gamepad_selectGame": "ゲームを選択",
"gamepad_officialLauncher": "公式ランチャー",
"gamepad_selectAccount": "アカウントの選択",
"gamepad_selectSettingItem": "項目",
"gamepad_selectSettingCard": "カテゴリ",
"gamepad_playerInfo": "プレーヤー情報",
Expand Down
Loading

0 comments on commit 9ec8986

Please sign in to comment.