Skip to content

Commit

Permalink
Fix #7 and fix #8
Browse files Browse the repository at this point in the history
  • Loading branch information
shedaniel committed May 24, 2023
1 parent 15c7983 commit c8040b8
Show file tree
Hide file tree
Showing 15 changed files with 54 additions and 16 deletions.
18 changes: 8 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ This subfolder contains the frontend Vue website. The frontend runs independentl

#### frontend/src-tauri

This subfolder contains the experimental tauri application for a local Linkie experience. (Currently only Windows, with plans for other platforms)
This subfolder contains the experimental tauri application for a local Linkie experience.

The application fires a JRE process of the backend and connects to it, the frontend is the Vue website.

Expand Down Expand Up @@ -55,21 +55,19 @@ npm run build
First, we need to build a custom JRE to bundle along: (Use Java 17)

```bash
# Unix-Like
java/bin/jlink --add-modules java.base,java.xml,jdk.unsupported,java.net.http,jdk.crypto.ec --output jdk-17-minjre --strip-debug --no-man-pages --no-header-files --compress=2
```

```powershell
# Windows
java\bin\jlink.exe --add-modules java.base,java.xml,jdk.unsupported,java.net.http,jdk.crypto.ec --output jdk-17-minjre --strip-debug --no-man-pages --no-header-files --compress=2
cd backend
./gradlew customJre
```

Place the generated `jdk-17-minjre` at `/backend/build/libs`, and also compile the `backend`. (Instructions above)
The custom jre is in `build/libs/`.
Now, also compile the `backend`. (Instructions above)

Build the tauri project: (Requires Rust)

```bash
npm install
npm run tauri build
```

Compiled file is at `/frontend/src-tauri/target/release/bundle`.
Compiled file is at `/frontend/src-tauri/target/release/`.<br>
Bundled installer/app is at `/frontend/src-tauri/target/release/bundle`.
27 changes: 27 additions & 0 deletions backend/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,30 @@ build.finalizedBy shadowJar
compileKotlin {
kotlinOptions.jvmTarget = "1.8"
}

def launcher = javaToolchains.launcherFor {
languageVersion.set(JavaLanguageVersion.of(17))
vendor.set(JvmVendorSpec.matching("adoptium"))
}

tasks.register("customJre", Exec) {
doFirst {
file("build/libs/jdk-17-minjre").deleteDir()
}
def tmp = File.createTempDir("jdk-17-minjre")
tmp.deleteOnExit()
workingDir = tmp
def exe = new File(launcher.get().executablePath.asFile.parentFile, "jlink.exe")
def obj = new File(launcher.get().executablePath.asFile.parentFile, "jlink")
def cmd = [(exe.exists() ? exe : obj).absolutePath, "--add-modules", "java.base,java.xml,jdk.unsupported,java.net.http,jdk.crypto.ec,jdk.zipfs",
"--output", "jdk-17-minjre", "--strip-debug", "--no-man-pages", "--no-header-files", "--compress=2"]
commandLine(cmd)
println(String.join(" ", cmd))
doLast {
copy {
from(tmp)
into("build/libs")
}
tmp.deleteDir()
}
}
Binary file removed frontend/src-tauri/icons/Square107x107Logo.png
Binary file not shown.
Binary file removed frontend/src-tauri/icons/Square142x142Logo.png
Binary file not shown.
Binary file removed frontend/src-tauri/icons/Square150x150Logo.png
Binary file not shown.
Binary file removed frontend/src-tauri/icons/Square284x284Logo.png
Binary file not shown.
Binary file removed frontend/src-tauri/icons/Square30x30Logo.png
Binary file not shown.
Binary file removed frontend/src-tauri/icons/Square310x310Logo.png
Binary file not shown.
Binary file removed frontend/src-tauri/icons/Square44x44Logo.png
Binary file not shown.
Binary file removed frontend/src-tauri/icons/Square71x71Logo.png
Binary file not shown.
Binary file removed frontend/src-tauri/icons/Square89x89Logo.png
Binary file not shown.
Binary file removed frontend/src-tauri/icons/StoreLogo.png
Binary file not shown.
2 changes: 2 additions & 0 deletions frontend/src-tauri/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,8 @@ pub fn start_backend<R: Runtime>(app: &AppHandle<R>, process: &mut ChildProcess)
return Err(("Could not find backend jar ".to_owned() + backend_jar.to_str().unwrap()).into());
}
let working_dir: PathBuf = app.path_resolver().app_cache_dir().unwrap();
send_console(&app, "Working dir at ".to_owned() + working_dir.to_str().unwrap());
fs::create_dir_all(working_dir.clone()).expected(&app, "Failed to create working dir");
fs::copy(backend_jar, working_dir.join("linkie-web-backend.jar"))
.expected(&app, "Failed to copy backend jar");
// java_path can start with \\?\, which is not supported by Command::new
Expand Down
14 changes: 10 additions & 4 deletions frontend/src-tauri/tauri.conf.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"bundle": {
"active": true,
"category": "DeveloperTool",
"copyright": "",
"copyright": "Copyright Linkie & shedaniel© 2020 - 2023. All right reserved.",
"deb": {
"depends": []
},
Expand All @@ -29,10 +29,11 @@
"icons/128x128.png",
"icons/128x128@2x.png",
"icons/icon.icns",
"icons/icon.ico"
"icons/icon.ico",
"icons/icon.png"
],
"identifier": "me.shedaniel.linkie.linkie-tauri",
"longDescription": "",
"longDescription": "View mod dependencies; Search up mappings; All in one place!",
"macOS": {
"entitlements": null,
"exceptionDomain": "",
Expand All @@ -45,7 +46,12 @@
"../../backend/build/libs/jdk-17-minjre/*"
],
"shortDescription": "",
"targets": "all",
"targets": [
"appimage",
"msi",
"dmg",
"app"
],
"windows": {
"certificateThumbprint": null,
"digestAlgorithm": "sha256",
Expand Down
9 changes: 7 additions & 2 deletions frontend/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import enGB from "./locales/en_GB.json"
import zhCN from "./locales/zh_CN.json"
// @ts-ignore
import zhTW from "./locales/zh_TW.json"
import {isTauri} from "./app/tauri/tauri";
// @ts-ignore

Prism.manual = true;
Expand All @@ -29,15 +30,19 @@ NProgress.configure({
const app = createApp(App)

HTTP.interceptors.request.use(config => {
NProgress.start()
if (!isTauri()) {
NProgress.start()
}
return config
}, error => {
console.log(error)
return Promise.reject(error)
})

HTTP.interceptors.response.use(response => {
NProgress.done()
if (!isTauri()) {
NProgress.done()
}
return response
}, error => {
if (!axios.isCancel(error)) {
Expand Down

0 comments on commit c8040b8

Please sign in to comment.