Skip to content

Commit

Permalink
fix: check os type
Browse files Browse the repository at this point in the history
  • Loading branch information
Xtr126 committed Feb 29, 2024
1 parent fb2f0a0 commit 7dfc9b9
Show file tree
Hide file tree
Showing 6 changed files with 73 additions and 44 deletions.
8 changes: 1 addition & 7 deletions .github/workflows/tauri.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,17 +51,11 @@ jobs:
uses: actions/cache@v4
with:
path: |
${{ env.VCPKG_ROOT }}/installed
${{ env.VCPKG_ROOT }}/downloads
${{ env.VCPKG_ROOT }}/packages
${{ env.VCPKG_ROOT }}/installed
key: ${{ runner.os }}-vcpkg-libarchive

- uses: actions/upload-artifact@v4
with:
name: vcpkg
path: ${{ env.VCPKG_ROOT }}/installed


- name: Install Vcpkg
if: matrix.platform == 'windows-latest'
run: "'${{env.VCPKG_ROOT}}/vcpkg' install libarchive:x64-windows-static-md"
Expand Down
64 changes: 40 additions & 24 deletions src-tauri/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ tauri-build = { version = "1.5", features = [] }
[dependencies]
serde_json = "1.0"
serde = { version = "1.0", features = ["derive"] }
tauri = { version = "1.5", features = ["dialog-open", "path-all", "process-exit", "shell-open", "process-command-api"] }
tauri = { version = "1.5", features = [ "os-all", "dialog-open", "path-all", "process-exit", "process-command-api"] }
compress-tools = "0.14.3"
fs_extra = "1.3.0"

Expand Down
3 changes: 3 additions & 0 deletions src-tauri/tauri.conf.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@
},
"path": {
"all": true
},
"os": {
"all": true
}
},
"bundle": {
Expand Down
16 changes: 14 additions & 2 deletions src/installer_app.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { msg } from '@lit/localize'
import { exit } from '@tauri-apps/api/process';

import androidLogo from './assets/android.svg'
import { type } from '@tauri-apps/api/os';

export class InstallerApp extends LitElement {

Expand All @@ -29,6 +30,7 @@ export class InstallerApp extends LitElement {
dataImgSize: {type: Number},
dataImgScale: {type: Number},
qemuConfigDone: {type: Boolean},
osType: {type: String},
};

constructor() {
Expand Down Expand Up @@ -199,7 +201,7 @@ export class InstallerApp extends LitElement {
<div style="margin-top: -40px; display: none;" id="c-data-img">
<label>Size: ${this.dataImgSize} GB</label>
<md-slider @change=${this.handleDataImgSize_Change} step=${this.dataImgScale} min=4 max=${this.dataImgScale * 16} value=8 ticks labeled style="width: 300px;"></md-slider>
<md-slider @change=${this.handleDataImgSize_Change} step=${this.dataImgScale} min=4 max=${this.dataImgScale * 16} value=4 ticks labeled style="width: 300px;"></md-slider>
<md-outlined-text-field @change=${this.handleDataImgScale_Change} onKeyDown="return false" label="Scale" min="1" type="number" style="width:80px" value=2></md-outlined-text-field>
</div>
Expand Down Expand Up @@ -384,7 +386,8 @@ export class InstallerApp extends LitElement {
this.dataDirSwitchEl.selected = false;
this.dataImgSwitchState();
}
this.dataDirSwitchEl.disabled = this.dataImgSwitchEl.disabled = installForQemu;
if (this.osType != 'Windows_NT')
this.dataDirSwitchEl.disabled = this.dataImgSwitchEl.disabled = installForQemu;
}

onQemuConfigDoneButtonClicked() {
Expand Down Expand Up @@ -429,6 +432,15 @@ export class InstallerApp extends LitElement {
this.dataImgSwitchEl = this.renderRoot.querySelector('#data-img-switch');
this.qemuInstallSwitchEl = this.renderRoot.querySelector('#qemu-install-switch');
this.showDialog('', '"The Android robot is reproduced or modified from work created and shared by Google and used according to terms described in the Creative Commons 3.0 Attribution License."');
type().then((osType) => {
this.osType = osType;
if (this.osType == 'Windows_NT') {
this.dataImgSwitchEl.selected = true;
this.dataDirSwitchEl.selected = false;
this.dataDirSwitchEl.disabled = true;
this.dataImgSwitchState();
}
})
}
}

Expand Down
24 changes: 14 additions & 10 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,16 +52,6 @@ async function startInstall() {
});
}


async function createGrubEntry() {
installEl.bootloaderMsg_ = await invoke("create_grub_entry", {
installDir: _installDir,
osTitle: osTitleTextFieldEl.value,
});
installEl.installDir = _installDir;
installEl.activateNextCategory();
}

async function updateProgress() {
while(true) {
await listen('new-dir-size', (event) => {
Expand All @@ -70,6 +60,8 @@ async function updateProgress() {
if (installEl.progressPercent_ == 100) {
installEl.activeCategory_ = 'data_img_progress';

if (installEl.osType == 'Windows_NT') installEl.useDataImg = true;

if (!installEl.useDataImg) {
await createGrubEntry();
} else {
Expand All @@ -86,6 +78,18 @@ async function updateProgress() {
}
}

async function createGrubEntry() {
const _installDir = installDirTextFieldEl.value;
installEl.bootloaderMsg_ = await invoke("create_grub_entry", {
installDir: _installDir,
osTitle: osTitleTextFieldEl.value,
});
installEl.installDir = _installDir;
sidePanelEl.activateNextCategory();
if (installEl.osType == 'Windows_NT')
installEl.activeCategory_ = 'bootloader-windows';
}

function toggleDarkMode() {
if (!darkModeToggleEl.selected) {
document.documentElement.setAttribute("light_mode", true);
Expand Down

0 comments on commit 7dfc9b9

Please sign in to comment.