Compare commits
161 Commits
josiah/fix
...
cal/dev-13
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
35b016c0bd | ||
|
|
d22c9e24f4 | ||
|
|
167ddb1429 | ||
|
|
e31197f649 | ||
|
|
7aa47f9473 | ||
|
|
3f91b55636 | ||
|
|
e7f940daa1 | ||
|
|
75b00bec3d | ||
|
|
2376bea510 | ||
|
|
981cf159bf | ||
|
|
52720ce06a | ||
|
|
34e65ace1e | ||
|
|
f7fc208b15 | ||
|
|
5b97f1e9b8 | ||
|
|
73a353ab8c | ||
|
|
0dee21814d | ||
|
|
0657e4466f | ||
|
|
13dbb4c57e | ||
|
|
99493b9917 | ||
|
|
72a52eb7b1 | ||
|
|
b33e12c71d | ||
|
|
82d86839c7 | ||
|
|
3a20e15340 | ||
|
|
1c89b84314 | ||
|
|
6387fb21c6 | ||
|
|
c7d0839bfb | ||
|
|
175b90be5a | ||
|
|
13103b4950 | ||
|
|
8804478221 | ||
|
|
b8982a6d17 | ||
|
|
ff88724d01 | ||
|
|
7dffb352d5 | ||
|
|
1df6e29aa1 | ||
|
|
5deb4179ad | ||
|
|
358cf31c87 | ||
|
|
6db1d66591 | ||
|
|
8052fda840 | ||
|
|
15892a88d3 | ||
|
|
32793c50e1 | ||
|
|
0e0ca1971a | ||
|
|
bb9af18eed | ||
|
|
d4516d3527 | ||
|
|
87de47fe5e | ||
|
|
7d76fe1b6a | ||
|
|
ae25a15abd | ||
|
|
0f755b94ce | ||
|
|
bcf46d440b | ||
|
|
526561f2de | ||
|
|
a8caa1afc3 | ||
|
|
98e9a8473d | ||
|
|
936395484e | ||
|
|
0c3e23db96 | ||
|
|
013ba4d86d | ||
|
|
93813c448c | ||
|
|
c20b869e62 | ||
|
|
56c556821b | ||
|
|
44267619b6 | ||
|
|
90043fe84d | ||
|
|
a6a98ff63e | ||
|
|
911652133b | ||
|
|
cee1b5f522 | ||
|
|
62f5a23fcb | ||
|
|
eb595cdc3e | ||
|
|
572cd065ed | ||
|
|
76dc8a0897 | ||
|
|
4723de6269 | ||
|
|
e15fa35bad | ||
|
|
2cc6bc8ce4 | ||
|
|
5d19d31b2c | ||
|
|
c1b95ede07 | ||
|
|
058185c7fd | ||
|
|
6fb125cf0f | ||
|
|
a945e9b005 | ||
|
|
b943638afb | ||
|
|
207dc0e2bb | ||
|
|
359fbd4738 | ||
|
|
f7700acce4 | ||
|
|
87a3e2d022 | ||
|
|
5d17663040 | ||
|
|
cff3c72f94 | ||
|
|
fadf475f06 | ||
|
|
7228499737 | ||
|
|
bca467a634 | ||
|
|
cb72d2ac80 | ||
|
|
3c79607d1f | ||
|
|
36ad1f16e4 | ||
|
|
5d4f334505 | ||
|
|
1fdb5ba748 | ||
|
|
26df6f51ef | ||
|
|
6caf794ae1 | ||
|
|
2692953e31 | ||
|
|
242fd713ab | ||
|
|
7a12c4d5e2 | ||
|
|
f256ef43c0 | ||
|
|
e0cde2d6ff | ||
|
|
e4e77dc0d2 | ||
|
|
8ba6467f21 | ||
|
|
088cb54317 | ||
|
|
c47bcf665d | ||
|
|
bc90c27e27 | ||
|
|
c1be57773a | ||
|
|
315c68912c | ||
|
|
559d203996 | ||
|
|
54522518c3 | ||
|
|
bacb1561d5 | ||
|
|
b8521f926f | ||
|
|
b29672f4b4 | ||
|
|
a32fe6a41f | ||
|
|
0e35135093 | ||
|
|
31ecace083 | ||
|
|
e5b134f8f4 | ||
|
|
139a4863d1 | ||
|
|
8faea1663a | ||
|
|
ece8a07486 | ||
|
|
0030f35d0c | ||
|
|
1e24225350 | ||
|
|
e84a178586 | ||
|
|
0a83ed965e | ||
|
|
30035a9a1c | ||
|
|
512d456c66 | ||
|
|
bff26af465 | ||
|
|
f4d0f14cb6 | ||
|
|
55916b6bda | ||
|
|
a38e1dee1f | ||
|
|
ef76a81cd5 | ||
|
|
9dc5644264 | ||
|
|
8e35cf6957 | ||
|
|
ae1c3d6531 | ||
|
|
4964c8d373 | ||
|
|
497b2e977e | ||
|
|
f95d0d78f2 | ||
|
|
94a7d13af8 | ||
|
|
3a10e63756 | ||
|
|
238138d56e | ||
|
|
1846c59733 | ||
|
|
f1207f0a3a | ||
|
|
26e964174d | ||
|
|
897418ead3 | ||
|
|
eef09e1ffe | ||
|
|
fdb2b1195e | ||
|
|
4b3e036e2a | ||
|
|
3233e7fc54 | ||
|
|
dd98a1316a | ||
|
|
e5030a8fbe | ||
|
|
f549560e47 | ||
|
|
33d26238ce | ||
|
|
bcec478a64 | ||
|
|
8971d39683 | ||
|
|
1c1631f131 | ||
|
|
14b1ff79e0 | ||
|
|
479aaf503b | ||
|
|
240cccf8a1 | ||
|
|
2599dc2672 | ||
|
|
e2668f20b7 | ||
|
|
cf767c7ef2 | ||
|
|
14a7787e3d | ||
|
|
db963eb5de | ||
|
|
a1812cd954 | ||
|
|
5ed9d1749a | ||
|
|
17ca209862 | ||
|
|
03192c1dfd |
@@ -2,5 +2,8 @@
|
|||||||
[target.'cfg(windows)']
|
[target.'cfg(windows)']
|
||||||
rustflags = ["-C", "link-args=/STACK:16777220", "--cfg", "tokio_unstable"]
|
rustflags = ["-C", "link-args=/STACK:16777220", "--cfg", "tokio_unstable"]
|
||||||
|
|
||||||
|
[target.x86_64-pc-windows-msvc]
|
||||||
|
linker = "rust-lld"
|
||||||
|
|
||||||
[build]
|
[build]
|
||||||
rustflags = ["--cfg", "tokio_unstable"]
|
rustflags = ["--cfg", "tokio_unstable"]
|
||||||
|
|||||||
1
.dockerignore
Symbolic link
1
.dockerignore
Symbolic link
@@ -0,0 +1 @@
|
|||||||
|
.gitignore
|
||||||
34
.gitattributes
vendored
34
.gitattributes
vendored
@@ -1 +1,35 @@
|
|||||||
* text=auto eol=lf
|
* text=auto eol=lf
|
||||||
|
|
||||||
|
# SQLx calculates a checksum of migration scripts at build time to compare
|
||||||
|
# it with the checksum of the applied migration for the same version at
|
||||||
|
# runtime, to know if the migration script has been changed, and thus the
|
||||||
|
# DB schema went out of sync with the code.
|
||||||
|
#
|
||||||
|
# However, such checksum treats the script as a raw byte stream, taking
|
||||||
|
# into account inconsequential differences like different line endings
|
||||||
|
# in different OSes. When combined with Git's EOL conversion and mixed
|
||||||
|
# native and cross-compilation scenarios, this leads to existing
|
||||||
|
# migrations that didn't change having potentially different checksums
|
||||||
|
# according to the environment they were built in, which can break the
|
||||||
|
# migration system when deploying the Modrinth App, rendering it
|
||||||
|
# unusable.
|
||||||
|
#
|
||||||
|
# The gitattribute above ensures that all text files are checked out
|
||||||
|
# with LF line endings, but widely deployed app versions were built
|
||||||
|
# without this attribute set, which left such line endings variable to
|
||||||
|
# the platform. Thus, there is no perfect solution to this problem:
|
||||||
|
# forcing CRLF here would break Linux and macOS users, forcing LF
|
||||||
|
# breaks Windows users, and leaving it unspecified may still lead to
|
||||||
|
# line ending differences when cross-compiling from Linux to Windows
|
||||||
|
# or vice versa, or having Git configured with different line
|
||||||
|
# conversion settings. Moreover, there is no `eol=native` attribute,
|
||||||
|
# and using CI-only scripts to convert line endings would make the
|
||||||
|
# builds differ between CI and most local environments. So, let's pick
|
||||||
|
# the least bad option: let Git handle line endings using its
|
||||||
|
# configuration by leaving it unspecified, which works fine as long as
|
||||||
|
# people don't mess with Git's line ending settings, which is the vast
|
||||||
|
# majority of cases.
|
||||||
|
/packages/app-lib/migrations/20240711194701_init.sql !eol
|
||||||
|
/packages/app-lib/migrations/20240813205023_drop-active-unique.sql !eol
|
||||||
|
/packages/app-lib/migrations/20240930001852_disable-personalized-ads.sql !eol
|
||||||
|
/packages/app-lib/migrations/20241222013857_feature-flags.sql !eol
|
||||||
|
|||||||
13
.github/workflows/daedalus-docker.yml
vendored
13
.github/workflows/daedalus-docker.yml
vendored
@@ -22,23 +22,26 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v4
|
||||||
|
- name: Set up Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v2
|
||||||
- name: Fetch docker metadata
|
- name: Fetch docker metadata
|
||||||
id: docker_meta
|
id: docker_meta
|
||||||
uses: docker/metadata-action@v3
|
uses: docker/metadata-action@v5
|
||||||
with:
|
with:
|
||||||
images: ghcr.io/modrinth/daedalus
|
images: ghcr.io/modrinth/daedalus
|
||||||
- name: Login to GitHub Images
|
- name: Login to GitHub Images
|
||||||
uses: docker/login-action@v1
|
uses: docker/login-action@v3
|
||||||
with:
|
with:
|
||||||
registry: ghcr.io
|
registry: ghcr.io
|
||||||
username: ${{ github.actor }}
|
username: ${{ github.actor }}
|
||||||
password: ${{ secrets.GITHUB_TOKEN }}
|
password: ${{ secrets.GITHUB_TOKEN }}
|
||||||
- name: Build and push
|
- name: Build and push
|
||||||
id: docker_build
|
uses: docker/build-push-action@v6
|
||||||
uses: docker/build-push-action@v2
|
|
||||||
with:
|
with:
|
||||||
file: ./apps/daedalus_client/Dockerfile
|
file: ./apps/daedalus_client/Dockerfile
|
||||||
push: ${{ github.event_name != 'pull_request' }}
|
push: ${{ github.event_name != 'pull_request' }}
|
||||||
tags: ${{ steps.docker_meta.outputs.tags }}
|
tags: ${{ steps.docker_meta.outputs.tags }}
|
||||||
labels: ${{ steps.docker_meta.outputs.labels }}
|
labels: ${{ steps.docker_meta.outputs.labels }}
|
||||||
|
cache-from: type=registry,ref=ghcr.io/modrinth/daedalus:main
|
||||||
|
cache-to: type=inline
|
||||||
|
|||||||
18
.github/workflows/labrinth-docker.yml
vendored
18
.github/workflows/labrinth-docker.yml
vendored
@@ -18,30 +18,28 @@ on:
|
|||||||
jobs:
|
jobs:
|
||||||
docker:
|
docker:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
defaults:
|
|
||||||
run:
|
|
||||||
working-directory: ./apps/labrinth
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v4
|
||||||
|
- name: Set up Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v2
|
||||||
- name: Fetch docker metadata
|
- name: Fetch docker metadata
|
||||||
id: docker_meta
|
id: docker_meta
|
||||||
uses: docker/metadata-action@v3
|
uses: docker/metadata-action@v5
|
||||||
with:
|
with:
|
||||||
images: ghcr.io/modrinth/labrinth
|
images: ghcr.io/modrinth/labrinth
|
||||||
- name: Login to GitHub Images
|
- name: Login to GitHub Images
|
||||||
uses: docker/login-action@v1
|
uses: docker/login-action@v3
|
||||||
with:
|
with:
|
||||||
registry: ghcr.io
|
registry: ghcr.io
|
||||||
username: ${{ github.actor }}
|
username: ${{ github.actor }}
|
||||||
password: ${{ secrets.GITHUB_TOKEN }}
|
password: ${{ secrets.GITHUB_TOKEN }}
|
||||||
- name: Build and push
|
- name: Build and push
|
||||||
id: docker_build
|
uses: docker/build-push-action@v6
|
||||||
uses: docker/build-push-action@v2
|
|
||||||
env:
|
|
||||||
SQLX_OFFLINE: true
|
|
||||||
with:
|
with:
|
||||||
file: ./apps/labrinth/Dockerfile
|
file: ./apps/labrinth/Dockerfile
|
||||||
push: ${{ github.event_name != 'pull_request' }}
|
push: ${{ github.event_name != 'pull_request' }}
|
||||||
tags: ${{ steps.docker_meta.outputs.tags }}
|
tags: ${{ steps.docker_meta.outputs.tags }}
|
||||||
labels: ${{ steps.docker_meta.outputs.labels }}
|
labels: ${{ steps.docker_meta.outputs.labels }}
|
||||||
|
cache-from: type=registry,ref=ghcr.io/modrinth/labrinth:main
|
||||||
|
cache-to: type=inline
|
||||||
|
|||||||
152
.github/workflows/theseus-build.yml
vendored
Normal file
152
.github/workflows/theseus-build.yml
vendored
Normal file
@@ -0,0 +1,152 @@
|
|||||||
|
name: Modrinth App build
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
tags:
|
||||||
|
- 'v*'
|
||||||
|
paths:
|
||||||
|
- .github/workflows/theseus-build.yml
|
||||||
|
- 'apps/app/**'
|
||||||
|
- 'apps/app-frontend/**'
|
||||||
|
- 'packages/app-lib/**'
|
||||||
|
- 'packages/app-macros/**'
|
||||||
|
- 'packages/assets/**'
|
||||||
|
- 'packages/ui/**'
|
||||||
|
- 'packages/utils/**'
|
||||||
|
workflow_dispatch:
|
||||||
|
inputs:
|
||||||
|
sign-windows-binaries:
|
||||||
|
description: Sign Windows binaries
|
||||||
|
type: boolean
|
||||||
|
default: true
|
||||||
|
required: false
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
name: Build
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
platform: [macos-latest, windows-latest, ubuntu-22.04]
|
||||||
|
include:
|
||||||
|
- platform: macos-latest
|
||||||
|
artifact-target-name: universal-apple-darwin
|
||||||
|
- platform: windows-latest
|
||||||
|
artifact-target-name: x86_64-pc-windows-msvc
|
||||||
|
- platform: ubuntu-22.04
|
||||||
|
artifact-target-name: x86_64-unknown-linux-gnu
|
||||||
|
|
||||||
|
runs-on: ${{ matrix.platform }}
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: 📥 Check out code
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
|
|
||||||
|
- name: 🧰 Setup Rust toolchain
|
||||||
|
uses: actions-rust-lang/setup-rust-toolchain@v1
|
||||||
|
with:
|
||||||
|
rustflags: ''
|
||||||
|
target: ${{ startsWith(matrix.platform, 'macos') && 'x86_64-apple-darwin' || '' }}
|
||||||
|
|
||||||
|
- name: 🧰 Install pnpm
|
||||||
|
uses: pnpm/action-setup@v4
|
||||||
|
|
||||||
|
- name: 🧰 Setup Node.js
|
||||||
|
uses: actions/setup-node@v4
|
||||||
|
with:
|
||||||
|
node-version-file: .nvmrc
|
||||||
|
cache: pnpm
|
||||||
|
|
||||||
|
- name: 🧰 Install Linux build dependencies
|
||||||
|
if: startsWith(matrix.platform, 'ubuntu')
|
||||||
|
run: |
|
||||||
|
sudo apt-get update
|
||||||
|
sudo apt-get install -yq libwebkit2gtk-4.1-dev libayatana-appindicator3-dev librsvg2-dev
|
||||||
|
|
||||||
|
- name: 🧰 Setup Dasel
|
||||||
|
uses: jaxxstorm/action-install-gh-release@v2.1.0
|
||||||
|
with:
|
||||||
|
repo: TomWright/dasel
|
||||||
|
tag: v2.8.1
|
||||||
|
extension-matching: disable
|
||||||
|
rename-to: ${{ startsWith(matrix.platform, 'windows') && 'dasel.exe' || 'dasel' }}
|
||||||
|
chmod: 0755
|
||||||
|
|
||||||
|
- name: ⚙️ Set application version and environment
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
APP_VERSION="$(git describe --tags --always | sed -E 's/-([0-9]+)-(g[0-9a-fA-F]+)$/-canary+\1.\2/')"
|
||||||
|
echo "Setting application version to $APP_VERSION"
|
||||||
|
dasel put -f apps/app/Cargo.toml -t string -v "${APP_VERSION#v}" 'package.version'
|
||||||
|
dasel put -f packages/app-lib/Cargo.toml -t string -v "${APP_VERSION#v}" 'package.version'
|
||||||
|
dasel put -f apps/app-frontend/package.json -t string -v "${APP_VERSION#v}" 'version'
|
||||||
|
|
||||||
|
cp packages/app-lib/.env.prod packages/app-lib/.env
|
||||||
|
|
||||||
|
- name: 💨 Setup Turbo cache
|
||||||
|
uses: rharkor/caching-for-turbo@v1.8
|
||||||
|
|
||||||
|
- name: 🧰 Install dependencies
|
||||||
|
run: pnpm install
|
||||||
|
|
||||||
|
- name: ✍️ Set up Windows code signing
|
||||||
|
if: startsWith(matrix.platform, 'windows')
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
if [ '${{ startsWith(github.ref, 'refs/tags/v') || inputs.sign-windows-binaries }}' = 'true' ]; then
|
||||||
|
choco install jsign --ignore-dependencies # GitHub runners come with a global Java installation already
|
||||||
|
else
|
||||||
|
dasel delete -f apps/app/tauri-release.conf.json 'bundle.windows.signCommand'
|
||||||
|
fi
|
||||||
|
|
||||||
|
- name: 🔨 Build macOS app
|
||||||
|
run: pnpm --filter=@modrinth/app run tauri build --target universal-apple-darwin --config tauri-release.conf.json
|
||||||
|
if: startsWith(matrix.platform, 'macos')
|
||||||
|
env:
|
||||||
|
ENABLE_CODE_SIGNING: ${{ secrets.APPLE_CERTIFICATE }}
|
||||||
|
APPLE_CERTIFICATE: ${{ secrets.APPLE_CERTIFICATE }}
|
||||||
|
APPLE_CERTIFICATE_PASSWORD: ${{ secrets.APPLE_CERTIFICATE_PASSWORD }}
|
||||||
|
APPLE_SIGNING_IDENTITY: ${{ secrets.APPLE_SIGNING_IDENTITY }}
|
||||||
|
APPLE_ID: ${{ secrets.APPLE_ID }}
|
||||||
|
APPLE_TEAM_ID: ${{ secrets.APPLE_TEAM_ID }}
|
||||||
|
APPLE_PASSWORD: ${{ secrets.APPLE_PASSWORD }}
|
||||||
|
TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.TAURI_PRIVATE_KEY }}
|
||||||
|
TAURI_SIGNING_PRIVATE_KEY_PASSWORD: ${{ secrets.TAURI_KEY_PASSWORD }}
|
||||||
|
|
||||||
|
- name: 🔨 Build Linux app
|
||||||
|
run: pnpm --filter=@modrinth/app run tauri build --config tauri-release.conf.json
|
||||||
|
if: startsWith(matrix.platform, 'ubuntu')
|
||||||
|
env:
|
||||||
|
TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.TAURI_PRIVATE_KEY }}
|
||||||
|
TAURI_SIGNING_PRIVATE_KEY_PASSWORD: ${{ secrets.TAURI_KEY_PASSWORD }}
|
||||||
|
|
||||||
|
- name: 🔨 Build Windows app
|
||||||
|
run: |
|
||||||
|
[System.Convert]::FromBase64String("$env:DIGICERT_ONE_SIGNER_CLIENT_CERTIFICATE_BASE64") | Set-Content -Path signer-client-cert.p12 -AsByteStream
|
||||||
|
$env:DIGICERT_ONE_SIGNER_CREDENTIALS = "$env:DIGICERT_ONE_SIGNER_API_KEY|$PWD\signer-client-cert.p12|$env:DIGICERT_ONE_SIGNER_CLIENT_CERTIFICATE_PASSWORD"
|
||||||
|
$env:JAVA_HOME = "$env:JAVA_HOME_11_X64"
|
||||||
|
pnpm --filter=@modrinth/app run tauri build --config tauri-release.conf.json --verbose --bundles 'nsis,updater'
|
||||||
|
Remove-Item -Path signer-client-cert.p12 -ErrorAction SilentlyContinue
|
||||||
|
if: startsWith(matrix.platform, 'windows')
|
||||||
|
env:
|
||||||
|
TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.TAURI_PRIVATE_KEY }}
|
||||||
|
TAURI_SIGNING_PRIVATE_KEY_PASSWORD: ${{ secrets.TAURI_KEY_PASSWORD }}
|
||||||
|
DIGICERT_ONE_SIGNER_API_KEY: ${{ secrets.DIGICERT_ONE_SIGNER_API_KEY }}
|
||||||
|
DIGICERT_ONE_SIGNER_CLIENT_CERTIFICATE_BASE64: ${{ secrets.DIGICERT_ONE_SIGNER_CLIENT_CERTIFICATE_BASE64 }}
|
||||||
|
DIGICERT_ONE_SIGNER_CLIENT_CERTIFICATE_PASSWORD: ${{ secrets.DIGICERT_ONE_SIGNER_CLIENT_CERTIFICATE_PASSWORD }}
|
||||||
|
|
||||||
|
- name: 📤 Upload app bundles
|
||||||
|
uses: actions/upload-artifact@v4
|
||||||
|
with:
|
||||||
|
name: App bundle (${{ matrix.artifact-target-name }})
|
||||||
|
path: |
|
||||||
|
target/release/bundle/appimage/Modrinth App_*.AppImage*
|
||||||
|
target/release/bundle/deb/Modrinth App_*.deb*
|
||||||
|
target/release/bundle/rpm/Modrinth App-*.rpm*
|
||||||
|
target/universal-apple-darwin/release/bundle/macos/Modrinth App.app.tar.gz*
|
||||||
|
target/universal-apple-darwin/release/bundle/dmg/Modrinth App_*.dmg*
|
||||||
|
target/release/bundle/nsis/Modrinth App_*-setup.exe*
|
||||||
|
target/release/bundle/nsis/Modrinth App_*-setup.nsis.zip*
|
||||||
271
.github/workflows/theseus-release.yml
vendored
271
.github/workflows/theseus-release.yml
vendored
@@ -1,185 +1,118 @@
|
|||||||
name: 'Modrinth App build'
|
name: Modrinth App release
|
||||||
on:
|
on:
|
||||||
push:
|
|
||||||
branches:
|
|
||||||
- main
|
|
||||||
tags:
|
|
||||||
- 'v*'
|
|
||||||
paths:
|
|
||||||
- .github/workflows/theseus-release.yml
|
|
||||||
- 'apps/app/**'
|
|
||||||
- 'apps/app-frontend/**'
|
|
||||||
- 'packages/app-lib/**'
|
|
||||||
- 'packages/app-macros/**'
|
|
||||||
- 'packages/assets/**'
|
|
||||||
- 'packages/ui/**'
|
|
||||||
- 'packages/utils/**'
|
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
inputs:
|
inputs:
|
||||||
sign-windows-binaries:
|
version-tag:
|
||||||
description: Sign Windows binaries
|
description: Version tag to release to the wide public
|
||||||
type: boolean
|
type: string
|
||||||
default: true
|
required: true
|
||||||
required: false
|
release-notes:
|
||||||
|
description: Release notes to include in the Tauri version manifest
|
||||||
|
default: A new release of the Modrinth App is available!
|
||||||
|
type: string
|
||||||
|
required: true
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
release:
|
||||||
strategy:
|
name: Release Modrinth App
|
||||||
fail-fast: false
|
runs-on: ubuntu-latest
|
||||||
matrix:
|
|
||||||
platform: [macos-latest, windows-latest, ubuntu-22.04]
|
|
||||||
|
|
||||||
runs-on: ${{ matrix.platform }}
|
env:
|
||||||
|
LINUX_X64_BUNDLE_ARTIFACT_NAME: App bundle (x86_64-unknown-linux-gnu)
|
||||||
|
WINDOWS_X64_BUNDLE_ARTIFACT_NAME: App bundle (x86_64-pc-windows-msvc)
|
||||||
|
MACOS_UNIVERSAL_BUNDLE_ARTIFACT_NAME: App bundle (universal-apple-darwin)
|
||||||
|
LAUNCHER_FILES_BUCKET_BASE_URL: https://launcher-files.modrinth.com
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- name: 📥 Download Modrinth App artifacts
|
||||||
|
uses: dawidd6/action-download-artifact@v11
|
||||||
- name: Rust setup (mac)
|
|
||||||
if: startsWith(matrix.platform, 'macos')
|
|
||||||
uses: actions-rust-lang/setup-rust-toolchain@v1
|
|
||||||
with:
|
with:
|
||||||
rustflags: ''
|
workflow: theseus-build.yml
|
||||||
target: x86_64-apple-darwin
|
workflow_conclusion: success
|
||||||
|
event: push
|
||||||
|
branch: ${{ inputs.version-tag }}
|
||||||
|
use_unzip: true
|
||||||
|
|
||||||
- name: Rust setup
|
- name: 🛠️ Generate version manifest
|
||||||
if: "!startsWith(matrix.platform, 'macos')"
|
|
||||||
uses: actions-rust-lang/setup-rust-toolchain@v1
|
|
||||||
with:
|
|
||||||
rustflags: ''
|
|
||||||
|
|
||||||
- name: Setup rust cache
|
|
||||||
uses: actions/cache@v4
|
|
||||||
with:
|
|
||||||
path: |
|
|
||||||
target/**
|
|
||||||
!target/*/release/bundle/*/*.dmg
|
|
||||||
!target/*/release/bundle/*/*.app.tar.gz
|
|
||||||
!target/*/release/bundle/*/*.app.tar.gz.sig
|
|
||||||
!target/release/bundle/*/*.dmg
|
|
||||||
!target/release/bundle/*/*.app.tar.gz
|
|
||||||
!target/release/bundle/*/*.app.tar.gz.sig
|
|
||||||
|
|
||||||
!target/release/bundle/appimage/*.AppImage
|
|
||||||
!target/release/bundle/appimage/*.AppImage.tar.gz
|
|
||||||
!target/release/bundle/appimage/*.AppImage.tar.gz.sig
|
|
||||||
!target/release/bundle/deb/*.deb
|
|
||||||
!target/release/bundle/rpm/*.rpm
|
|
||||||
|
|
||||||
!target/release/bundle/msi/*.msi
|
|
||||||
!target/release/bundle/msi/*.msi.zip
|
|
||||||
!target/release/bundle/msi/*.msi.zip.sig
|
|
||||||
|
|
||||||
!target/release/bundle/nsis/*.exe
|
|
||||||
!target/release/bundle/nsis/*.nsis.zip
|
|
||||||
!target/release/bundle/nsis/*.nsis.zip.sig
|
|
||||||
key: ${{ runner.os }}-rust-target-${{ hashFiles('**/Cargo.lock') }}
|
|
||||||
restore-keys: |
|
|
||||||
${{ runner.os }}-rust-target-
|
|
||||||
|
|
||||||
- name: Setup Node.js
|
|
||||||
uses: actions/setup-node@v4
|
|
||||||
with:
|
|
||||||
node-version-file: .nvmrc
|
|
||||||
|
|
||||||
- name: Install pnpm via corepack
|
|
||||||
shell: bash
|
|
||||||
run: |
|
|
||||||
corepack enable
|
|
||||||
corepack prepare --activate
|
|
||||||
|
|
||||||
- name: Get pnpm store directory
|
|
||||||
id: pnpm-cache
|
|
||||||
shell: bash
|
|
||||||
run: |
|
|
||||||
echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT
|
|
||||||
|
|
||||||
- name: Setup pnpm cache
|
|
||||||
uses: actions/cache@v4
|
|
||||||
with:
|
|
||||||
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }}
|
|
||||||
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
|
|
||||||
restore-keys: |
|
|
||||||
${{ runner.os }}-pnpm-store-
|
|
||||||
|
|
||||||
- name: install dependencies (ubuntu only)
|
|
||||||
if: startsWith(matrix.platform, 'ubuntu')
|
|
||||||
run: |
|
|
||||||
sudo apt-get update
|
|
||||||
sudo apt-get install -y libwebkit2gtk-4.1-dev build-essential curl wget file libxdo-dev libssl-dev pkg-config libayatana-appindicator3-dev librsvg2-dev
|
|
||||||
|
|
||||||
- name: Install code signing client (Windows only)
|
|
||||||
if: startsWith(matrix.platform, 'windows')
|
|
||||||
run: choco install jsign --ignore-dependencies # GitHub runners come with a global Java installation already
|
|
||||||
|
|
||||||
- name: Install frontend dependencies
|
|
||||||
run: pnpm install
|
|
||||||
|
|
||||||
- name: Disable Windows code signing for non-final release builds
|
|
||||||
if: ${{ startsWith(matrix.platform, 'windows') && !startsWith(github.ref, 'refs/tags/v') && !inputs.sign-windows-binaries }}
|
|
||||||
run: |
|
|
||||||
jq 'del(.bundle.windows.signCommand)' apps/app/tauri-release.conf.json > apps/app/tauri-release.conf.json.new
|
|
||||||
Move-Item -Path apps/app/tauri-release.conf.json.new -Destination apps/app/tauri-release.conf.json -Force
|
|
||||||
|
|
||||||
- name: build app (macos)
|
|
||||||
run: pnpm --filter=@modrinth/app run tauri build --target universal-apple-darwin --config tauri-release.conf.json
|
|
||||||
if: startsWith(matrix.platform, 'macos')
|
|
||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
VERSION_TAG: ${{ inputs.version-tag }}
|
||||||
ENABLE_CODE_SIGNING: ${{ secrets.APPLE_CERTIFICATE }}
|
RELEASE_NOTES: ${{ inputs.release-notes }}
|
||||||
APPLE_CERTIFICATE: ${{ secrets.APPLE_CERTIFICATE }}
|
|
||||||
APPLE_CERTIFICATE_PASSWORD: ${{ secrets.APPLE_CERTIFICATE_PASSWORD }}
|
|
||||||
APPLE_SIGNING_IDENTITY: ${{ secrets.APPLE_SIGNING_IDENTITY }}
|
|
||||||
APPLE_ID: ${{ secrets.APPLE_ID }}
|
|
||||||
APPLE_TEAM_ID: ${{ secrets.APPLE_TEAM_ID }}
|
|
||||||
APPLE_PASSWORD: ${{ secrets.APPLE_PASSWORD }}
|
|
||||||
TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.TAURI_PRIVATE_KEY }}
|
|
||||||
TAURI_SIGNING_PRIVATE_KEY_PASSWORD: ${{ secrets.TAURI_KEY_PASSWORD }}
|
|
||||||
|
|
||||||
- name: build app (Linux)
|
|
||||||
run: pnpm --filter=@modrinth/app run tauri build --config tauri-release.conf.json
|
|
||||||
if: startsWith(matrix.platform, 'ubuntu')
|
|
||||||
env:
|
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.TAURI_PRIVATE_KEY }}
|
|
||||||
TAURI_SIGNING_PRIVATE_KEY_PASSWORD: ${{ secrets.TAURI_KEY_PASSWORD }}
|
|
||||||
|
|
||||||
- name: build app (Windows)
|
|
||||||
run: |
|
run: |
|
||||||
[System.Convert]::FromBase64String("$env:DIGICERT_ONE_SIGNER_CLIENT_CERTIFICATE_BASE64") | Set-Content -Path signer-client-cert.p12 -AsByteStream
|
# Reference: https://tauri.app/plugin/updater/#server-support
|
||||||
$env:DIGICERT_ONE_SIGNER_CREDENTIALS = "$env:DIGICERT_ONE_SIGNER_API_KEY|$PWD\signer-client-cert.p12|$env:DIGICERT_ONE_SIGNER_CLIENT_CERTIFICATE_PASSWORD"
|
jq -nc \
|
||||||
pnpm --filter=@modrinth/app run tauri build --config tauri-release.conf.json --verbose --bundles 'nsis,updater'
|
--arg versionTag "${VERSION_TAG#v}" \
|
||||||
Remove-Item -Path signer-client-cert.p12
|
--arg releaseNotes "$RELEASE_NOTES" \
|
||||||
if: startsWith(matrix.platform, 'windows')
|
--rawfile macOsAarch64UpdateArtifactSignature "${MACOS_UNIVERSAL_BUNDLE_ARTIFACT_NAME}/universal-apple-darwin/release/bundle/macos/Modrinth App.app.tar.gz.sig" \
|
||||||
|
--rawfile macOsX64UpdateArtifactSignature "${MACOS_UNIVERSAL_BUNDLE_ARTIFACT_NAME}/universal-apple-darwin/release/bundle/macos/Modrinth App.app.tar.gz.sig" \
|
||||||
|
--rawfile linuxX64UpdateArtifactSignature "${LINUX_X64_BUNDLE_ARTIFACT_NAME}/release/bundle/appimage/Modrinth App_${VERSION_TAG#v}_amd64.AppImage.tar.gz.sig" \
|
||||||
|
--rawfile windowsX64UpdateArtifactSignature "${WINDOWS_X64_BUNDLE_ARTIFACT_NAME}/release/bundle/nsis/Modrinth App_${VERSION_TAG#v}_x64-setup.nsis.zip.sig" \
|
||||||
|
'{
|
||||||
|
"version": $versionTag,
|
||||||
|
"notes": $releaseNotes,
|
||||||
|
"pub_date": now | todateiso8601,
|
||||||
|
"platforms": {
|
||||||
|
"darwin-aarch64": {
|
||||||
|
"signature": $macOsAarch64UpdateArtifactSignature,
|
||||||
|
"url": @uri "${{ env.LAUNCHER_FILES_BUCKET_BASE_URL }}/versions/\($versionTag)/macos/\("Modrinth App.app.tar.gz")",
|
||||||
|
"install_urls": [@uri "${{ env.LAUNCHER_FILES_BUCKET_BASE_URL }}/versions/\($versionTag)/macos/\("Modrinth App_" + $versionTag + "_universal.dmg")"]
|
||||||
|
},
|
||||||
|
"darwin-x86_64": {
|
||||||
|
"signature": $macOsX64UpdateArtifactSignature,
|
||||||
|
"url": @uri "${{ env.LAUNCHER_FILES_BUCKET_BASE_URL }}/versions/\($versionTag)/macos/\("Modrinth App.app.tar.gz")",
|
||||||
|
"install_urls": [@uri "${{ env.LAUNCHER_FILES_BUCKET_BASE_URL }}/versions/\($versionTag)/macos/\("Modrinth App_" + $versionTag + "_universal.dmg")"]
|
||||||
|
},
|
||||||
|
"linux-x86_64": {
|
||||||
|
"signature": $linuxX64UpdateArtifactSignature,
|
||||||
|
"url": @uri "${{ env.LAUNCHER_FILES_BUCKET_BASE_URL }}/versions/\($versionTag)/linux/\("Modrinth App_" + $versionTag + "_amd64.AppImage.tar.gz")",
|
||||||
|
"install_urls": [
|
||||||
|
@uri "${{ env.LAUNCHER_FILES_BUCKET_BASE_URL }}/versions/\($versionTag)/linux/\("Modrinth App_" + $versionTag + "_amd64.deb")",
|
||||||
|
@uri "${{ env.LAUNCHER_FILES_BUCKET_BASE_URL }}/versions/\($versionTag)/linux/\("Modrinth App_" + $versionTag + "_amd64.AppImage")",
|
||||||
|
@uri "${{ env.LAUNCHER_FILES_BUCKET_BASE_URL }}/versions/\($versionTag)/linux/\("Modrinth App-" + $versionTag + "-1.x86_64.rpm")"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"windows-x86_64": {
|
||||||
|
"signature": $windowsX64UpdateArtifactSignature,
|
||||||
|
"url": @uri "${{ env.LAUNCHER_FILES_BUCKET_BASE_URL }}/versions/\($versionTag)/windows/\("Modrinth App_" + $versionTag + "_x64-setup.nsis.zip")",
|
||||||
|
"install_urls": [@uri "${{ env.LAUNCHER_FILES_BUCKET_BASE_URL }}/versions/\($versionTag)/windows/\("Modrinth App_" + $versionTag + "_x64-setup.exe")"]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}' > updates.json
|
||||||
|
|
||||||
|
echo "Generated manifest for version ${VERSION_TAG}:"
|
||||||
|
cat updates.json
|
||||||
|
|
||||||
|
- name: 📤 Upload release artifacts
|
||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
VERSION_TAG: ${{ inputs.version-tag }}
|
||||||
TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.TAURI_PRIVATE_KEY }}
|
AWS_ACCESS_KEY_ID: ${{ secrets.LAUNCHER_FILES_BUCKET_ACCESS_KEY_ID }}
|
||||||
TAURI_SIGNING_PRIVATE_KEY_PASSWORD: ${{ secrets.TAURI_KEY_PASSWORD }}
|
AWS_SECRET_ACCESS_KEY: ${{ secrets.LAUNCHER_FILES_BUCKET_SECRET_ACCESS_KEY }}
|
||||||
DIGICERT_ONE_SIGNER_API_KEY: ${{ secrets.DIGICERT_ONE_SIGNER_API_KEY }}
|
AWS_BUCKET: ${{ secrets.LAUNCHER_FILES_BUCKET_NAME }}
|
||||||
DIGICERT_ONE_SIGNER_CLIENT_CERTIFICATE_BASE64: ${{ secrets.DIGICERT_ONE_SIGNER_CLIENT_CERTIFICATE_BASE64 }}
|
AWS_REGION: ${{ secrets.LAUNCHER_FILES_BUCKET_REGION }}
|
||||||
DIGICERT_ONE_SIGNER_CLIENT_CERTIFICATE_PASSWORD: ${{ secrets.DIGICERT_ONE_SIGNER_CLIENT_CERTIFICATE_PASSWORD }}
|
AWS_ENDPOINT_URL: ${{ secrets.LAUNCHER_FILES_BUCKET_ENDPOINT_URL }}
|
||||||
|
AWS_PAGER: ''
|
||||||
|
# Work around incompatible checksum behavior with some S3-like object storage providers,
|
||||||
|
# such as Cloudflare R2. See:
|
||||||
|
# - https://developers.cloudflare.com/r2/examples/aws/aws-cli/
|
||||||
|
# - https://developers.cloudflare.com/r2/examples/aws/aws-sdk-java/
|
||||||
|
AWS_REQUEST_CHECKSUM_CALCULATION: when_required
|
||||||
|
AWS_RESPONSE_CHECKSUM_VALIDATION: when_required
|
||||||
|
run: |
|
||||||
|
for macosBundleType in 'macos' 'dmg'; do
|
||||||
|
aws s3 cp --recursive \
|
||||||
|
"${MACOS_UNIVERSAL_BUNDLE_ARTIFACT_NAME}/universal-apple-darwin/release/bundle/${macosBundleType}" \
|
||||||
|
"s3://${AWS_BUCKET}/versions/${VERSION_TAG#v}/macos"
|
||||||
|
done
|
||||||
|
|
||||||
- name: upload ${{ matrix.platform }}
|
for linuxBundleType in 'appimage' 'deb' 'rpm'; do
|
||||||
uses: actions/upload-artifact@v4
|
aws s3 cp --recursive \
|
||||||
with:
|
"${LINUX_X64_BUNDLE_ARTIFACT_NAME}/release/bundle/${linuxBundleType}" \
|
||||||
name: ${{ matrix.platform }}
|
"s3://${AWS_BUCKET}/versions/${VERSION_TAG#v}/linux"
|
||||||
path: |
|
done
|
||||||
target/*/release/bundle/*/*.dmg
|
|
||||||
target/*/release/bundle/*/*.app.tar.gz
|
|
||||||
target/*/release/bundle/*/*.app.tar.gz.sig
|
|
||||||
target/release/bundle/*/*.dmg
|
|
||||||
target/release/bundle/*/*.app.tar.gz
|
|
||||||
target/release/bundle/*/*.app.tar.gz.sig
|
|
||||||
|
|
||||||
target/release/bundle/*/*.AppImage
|
for windowsBundleType in 'nsis'; do
|
||||||
target/release/bundle/*/*.AppImage.tar.gz
|
aws s3 cp --recursive \
|
||||||
target/release/bundle/*/*.AppImage.tar.gz.sig
|
"${WINDOWS_X64_BUNDLE_ARTIFACT_NAME}/release/bundle/${windowsBundleType}" \
|
||||||
target/release/bundle/*/*.deb
|
"s3://${AWS_BUCKET}/versions/${VERSION_TAG#v}/windows"
|
||||||
target/release/bundle/*/*.rpm
|
done
|
||||||
|
|
||||||
target/release/bundle/msi/*.msi
|
aws s3 cp updates.json "s3://${AWS_BUCKET}"
|
||||||
target/release/bundle/msi/*.msi.zip
|
|
||||||
target/release/bundle/msi/*.msi.zip.sig
|
|
||||||
|
|
||||||
target/release/bundle/nsis/*.exe
|
|
||||||
target/release/bundle/nsis/*.nsis.zip
|
|
||||||
target/release/bundle/nsis/*.nsis.zip.sig
|
|
||||||
|
|||||||
11
.github/workflows/turbo-ci.yml
vendored
11
.github/workflows/turbo-ci.yml
vendored
@@ -52,7 +52,7 @@ jobs:
|
|||||||
# cargo-binstall does not have pre-built binaries for sqlx-cli, so we fall
|
# cargo-binstall does not have pre-built binaries for sqlx-cli, so we fall
|
||||||
# back to a cached cargo install
|
# back to a cached cargo install
|
||||||
- name: 🧰 Setup cargo-sqlx
|
- name: 🧰 Setup cargo-sqlx
|
||||||
uses: AlexTMjugador/cache-cargo-install-action@feat/features-support
|
uses: taiki-e/cache-cargo-install-action@v2
|
||||||
with:
|
with:
|
||||||
tool: sqlx-cli
|
tool: sqlx-cli
|
||||||
locked: false
|
locked: false
|
||||||
@@ -74,5 +74,14 @@ jobs:
|
|||||||
cp .env.local .env
|
cp .env.local .env
|
||||||
sqlx database setup
|
sqlx database setup
|
||||||
|
|
||||||
|
- name: ⚙️ Set app environment
|
||||||
|
working-directory: packages/app-lib
|
||||||
|
run: cp .env.staging .env
|
||||||
|
|
||||||
- name: 🔍 Lint and test
|
- name: 🔍 Lint and test
|
||||||
run: pnpm run ci
|
run: pnpm run ci
|
||||||
|
|
||||||
|
- name: 🔍 Verify intl:extract has been run
|
||||||
|
run: |
|
||||||
|
pnpm intl:extract
|
||||||
|
git diff --exit-code --color */*/src/locales/en-US/index.json
|
||||||
|
|||||||
1
.idea/code.iml
generated
1
.idea/code.iml
generated
@@ -10,7 +10,6 @@
|
|||||||
<sourceFolder url="file://$MODULE_DIR$/apps/labrinth/src" isTestSource="false" />
|
<sourceFolder url="file://$MODULE_DIR$/apps/labrinth/src" isTestSource="false" />
|
||||||
<sourceFolder url="file://$MODULE_DIR$/apps/labrinth/tests" isTestSource="true" />
|
<sourceFolder url="file://$MODULE_DIR$/apps/labrinth/tests" isTestSource="true" />
|
||||||
<sourceFolder url="file://$MODULE_DIR$/packages/app-lib/src" isTestSource="false" />
|
<sourceFolder url="file://$MODULE_DIR$/packages/app-lib/src" isTestSource="false" />
|
||||||
<sourceFolder url="file://$MODULE_DIR$/packages/rust-common/src" isTestSource="false" />
|
|
||||||
<sourceFolder url="file://$MODULE_DIR$/packages/ariadne/src" isTestSource="false" />
|
<sourceFolder url="file://$MODULE_DIR$/packages/ariadne/src" isTestSource="false" />
|
||||||
<excludeFolder url="file://$MODULE_DIR$/target" />
|
<excludeFolder url="file://$MODULE_DIR$/target" />
|
||||||
</content>
|
</content>
|
||||||
|
|||||||
777
Cargo.lock
generated
777
Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
49
Cargo.toml
49
Cargo.toml
@@ -25,7 +25,7 @@ actix-ws = "0.3.0"
|
|||||||
argon2 = { version = "0.5.3", features = ["std"] }
|
argon2 = { version = "0.5.3", features = ["std"] }
|
||||||
ariadne = { path = "packages/ariadne" }
|
ariadne = { path = "packages/ariadne" }
|
||||||
async_zip = "0.0.17"
|
async_zip = "0.0.17"
|
||||||
async-compression = { version = "0.4.24", default-features = false }
|
async-compression = { version = "0.4.25", default-features = false }
|
||||||
async-recursion = "1.1.1"
|
async-recursion = "1.1.1"
|
||||||
async-stripe = { version = "0.41.0", default-features = false, features = [
|
async-stripe = { version = "0.41.0", default-features = false, features = [
|
||||||
"runtime-tokio-hyper-rustls",
|
"runtime-tokio-hyper-rustls",
|
||||||
@@ -37,6 +37,7 @@ async-tungstenite = { version = "0.29.1", default-features = false, features = [
|
|||||||
async-walkdir = "2.1.0"
|
async-walkdir = "2.1.0"
|
||||||
base64 = "0.22.1"
|
base64 = "0.22.1"
|
||||||
bitflags = "2.9.1"
|
bitflags = "2.9.1"
|
||||||
|
bytemuck = "1.23.0"
|
||||||
bytes = "1.10.1"
|
bytes = "1.10.1"
|
||||||
censor = "0.3.0"
|
censor = "0.3.0"
|
||||||
chardetng = "0.1.17"
|
chardetng = "0.1.17"
|
||||||
@@ -47,6 +48,7 @@ color-thief = "0.2.2"
|
|||||||
console-subscriber = "0.4.1"
|
console-subscriber = "0.4.1"
|
||||||
daedalus = { path = "packages/daedalus" }
|
daedalus = { path = "packages/daedalus" }
|
||||||
dashmap = "6.1.0"
|
dashmap = "6.1.0"
|
||||||
|
data-url = "0.3.1"
|
||||||
deadpool-redis = "0.21.1"
|
deadpool-redis = "0.21.1"
|
||||||
dirs = "6.0.0"
|
dirs = "6.0.0"
|
||||||
discord-rich-presence = "0.2.5"
|
discord-rich-presence = "0.2.5"
|
||||||
@@ -61,10 +63,17 @@ fs4 = { version = "0.13.1", default-features = false }
|
|||||||
futures = { version = "0.3.31", default-features = false }
|
futures = { version = "0.3.31", default-features = false }
|
||||||
futures-util = "0.3.31"
|
futures-util = "0.3.31"
|
||||||
hashlink = "0.10.0"
|
hashlink = "0.10.0"
|
||||||
|
heck = "0.5.0"
|
||||||
hex = "0.4.3"
|
hex = "0.4.3"
|
||||||
hickory-resolver = "0.25.2"
|
hickory-resolver = "0.25.2"
|
||||||
hmac = "0.12.1"
|
hmac = "0.12.1"
|
||||||
hyper-tls = "0.6.0"
|
hyper = "1.6.0"
|
||||||
|
hyper-rustls = { version = "0.27.7", default-features = false, features = [
|
||||||
|
"http1",
|
||||||
|
"native-tokio",
|
||||||
|
"ring",
|
||||||
|
"tls12",
|
||||||
|
] }
|
||||||
hyper-util = "0.1.14"
|
hyper-util = "0.1.14"
|
||||||
iana-time-zone = "0.1.63"
|
iana-time-zone = "0.1.63"
|
||||||
image = { version = "0.25.6", default-features = false, features = ["rayon"] }
|
image = { version = "0.25.6", default-features = false, features = ["rayon"] }
|
||||||
@@ -90,6 +99,8 @@ notify = { version = "8.0.0", default-features = false }
|
|||||||
notify-debouncer-mini = { version = "0.6.0", default-features = false }
|
notify-debouncer-mini = { version = "0.6.0", default-features = false }
|
||||||
p256 = "0.13.2"
|
p256 = "0.13.2"
|
||||||
paste = "1.0.15"
|
paste = "1.0.15"
|
||||||
|
phf = { version = "0.12.1", features = ["macros"] }
|
||||||
|
png = "0.17.16"
|
||||||
prometheus = "0.14.0"
|
prometheus = "0.14.0"
|
||||||
quartz_nbt = "0.2.9"
|
quartz_nbt = "0.2.9"
|
||||||
quick-xml = "0.37.5"
|
quick-xml = "0.37.5"
|
||||||
@@ -97,8 +108,9 @@ rand = "=0.8.5" # Locked on 0.8 until argon2 and p256 update to 0.9
|
|||||||
rand_chacha = "=0.3.1" # Locked on 0.3 until we can update rand to 0.9
|
rand_chacha = "=0.3.1" # Locked on 0.3 until we can update rand to 0.9
|
||||||
redis = "=0.31.0" # Locked on 0.31 until deadpool-redis updates to 0.32
|
redis = "=0.31.0" # Locked on 0.31 until deadpool-redis updates to 0.32
|
||||||
regex = "1.11.1"
|
regex = "1.11.1"
|
||||||
reqwest = { version = "0.12.19", default-features = false }
|
reqwest = { version = "0.12.20", default-features = false }
|
||||||
rust_decimal = { version = "1.37.1", features = [
|
rgb = "0.8.50"
|
||||||
|
rust_decimal = { version = "1.37.2", features = [
|
||||||
"serde-with-float",
|
"serde-with-float",
|
||||||
"serde-with-str",
|
"serde-with-str",
|
||||||
] }
|
] }
|
||||||
@@ -109,7 +121,7 @@ rust-s3 = { version = "0.35.1", default-features = false, features = [
|
|||||||
"tokio-rustls-tls",
|
"tokio-rustls-tls",
|
||||||
] }
|
] }
|
||||||
rusty-money = "0.4.1"
|
rusty-money = "0.4.1"
|
||||||
sentry = { version = "0.38.1", default-features = false, features = [
|
sentry = { version = "0.41.0", default-features = false, features = [
|
||||||
"backtrace",
|
"backtrace",
|
||||||
"contexts",
|
"contexts",
|
||||||
"debug-images",
|
"debug-images",
|
||||||
@@ -117,13 +129,13 @@ sentry = { version = "0.38.1", default-features = false, features = [
|
|||||||
"reqwest",
|
"reqwest",
|
||||||
"rustls",
|
"rustls",
|
||||||
] }
|
] }
|
||||||
sentry-actix = "0.38.1"
|
sentry-actix = "0.41.0"
|
||||||
serde = "1.0.219"
|
serde = "1.0.219"
|
||||||
serde_bytes = "0.11.17"
|
serde_bytes = "0.11.17"
|
||||||
serde_cbor = "0.11.2"
|
serde_cbor = "0.11.2"
|
||||||
serde_ini = "0.2.0"
|
serde_ini = "0.2.0"
|
||||||
serde_json = "1.0.140"
|
serde_json = "1.0.140"
|
||||||
serde_with = "3.12.0"
|
serde_with = "3.13.0"
|
||||||
serde-xml-rs = "0.8.1" # Also an XML (de)serializer, consider dropping yaserde in favor of this
|
serde-xml-rs = "0.8.1" # Also an XML (de)serializer, consider dropping yaserde in favor of this
|
||||||
sha1 = "0.10.6"
|
sha1 = "0.10.6"
|
||||||
sha1_smol = { version = "1.0.1", features = ["std"] }
|
sha1_smol = { version = "1.0.1", features = ["std"] }
|
||||||
@@ -132,18 +144,19 @@ spdx = "0.10.8"
|
|||||||
sqlx = { version = "0.8.6", default-features = false }
|
sqlx = { version = "0.8.6", default-features = false }
|
||||||
sysinfo = { version = "0.35.2", default-features = false }
|
sysinfo = { version = "0.35.2", default-features = false }
|
||||||
tar = "0.4.44"
|
tar = "0.4.44"
|
||||||
tauri = "2.5.1"
|
tauri = "2.6.1"
|
||||||
tauri-build = "2.2.0"
|
tauri-build = "2.3.0"
|
||||||
tauri-plugin-deep-link = "2.3.0"
|
tauri-plugin-deep-link = "2.4.0"
|
||||||
tauri-plugin-dialog = "2.2.2"
|
tauri-plugin-dialog = "2.3.0"
|
||||||
tauri-plugin-opener = "2.2.7"
|
tauri-plugin-http = "2.5.0"
|
||||||
tauri-plugin-os = "2.2.1"
|
tauri-plugin-opener = "2.4.0"
|
||||||
tauri-plugin-single-instance = "2.2.4"
|
tauri-plugin-os = "2.3.0"
|
||||||
tauri-plugin-updater = { version = "2.7.1", default-features = false, features = [
|
tauri-plugin-single-instance = "2.3.0"
|
||||||
|
tauri-plugin-updater = { version = "2.9.0", default-features = false, features = [
|
||||||
"rustls-tls",
|
"rustls-tls",
|
||||||
"zip",
|
"zip",
|
||||||
] }
|
] }
|
||||||
tauri-plugin-window-state = "2.2.2"
|
tauri-plugin-window-state = "2.3.0"
|
||||||
tempfile = "3.20.0"
|
tempfile = "3.20.0"
|
||||||
theseus = { path = "packages/app-lib" }
|
theseus = { path = "packages/app-lib" }
|
||||||
thiserror = "2.0.12"
|
thiserror = "2.0.12"
|
||||||
@@ -166,7 +179,7 @@ whoami = "1.6.0"
|
|||||||
winreg = "0.55.0"
|
winreg = "0.55.0"
|
||||||
woothee = "0.13.0"
|
woothee = "0.13.0"
|
||||||
yaserde = "0.12.0"
|
yaserde = "0.12.0"
|
||||||
zip = { version = "4.0.0", default-features = false, features = [
|
zip = { version = "4.2.0", default-features = false, features = [
|
||||||
"bzip2",
|
"bzip2",
|
||||||
"deflate",
|
"deflate",
|
||||||
"deflate64",
|
"deflate64",
|
||||||
@@ -213,7 +226,7 @@ wildcard_dependencies = "warn"
|
|||||||
warnings = "deny"
|
warnings = "deny"
|
||||||
|
|
||||||
[patch.crates-io]
|
[patch.crates-io]
|
||||||
wry = { git = "https://github.com/modrinth/wry", rev = "cafdaa9" }
|
wry = { git = "https://github.com/modrinth/wry", rev = "21db186" }
|
||||||
|
|
||||||
# Optimize for speed and reduce size on release builds
|
# Optimize for speed and reduce size on release builds
|
||||||
[profile.release]
|
[profile.release]
|
||||||
|
|||||||
@@ -1 +1,2 @@
|
|||||||
**/dist
|
**/dist
|
||||||
|
*.gltf
|
||||||
|
|||||||
@@ -1,22 +1,2 @@
|
|||||||
import { createConfigForNuxt } from '@nuxt/eslint-config/flat'
|
import config from '@modrinth/tooling-config/eslint/nuxt.mjs'
|
||||||
import { fixupPluginRules } from '@eslint/compat'
|
export default config
|
||||||
import turboPlugin from 'eslint-plugin-turbo'
|
|
||||||
|
|
||||||
export default createConfigForNuxt().append([
|
|
||||||
{
|
|
||||||
name: 'turbo',
|
|
||||||
plugins: {
|
|
||||||
turbo: fixupPluginRules(turboPlugin),
|
|
||||||
},
|
|
||||||
rules: {
|
|
||||||
'turbo/no-undeclared-env-vars': 'error',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'modrinth',
|
|
||||||
rules: {
|
|
||||||
'vue/html-self-closing': 'off',
|
|
||||||
'vue/multi-word-component-names': 'off',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
])
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "@modrinth/app-frontend",
|
"name": "@modrinth/app-frontend",
|
||||||
"private": true,
|
"private": true,
|
||||||
"version": "0.9.5",
|
"version": "1.0.0-local",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "vite",
|
"dev": "vite",
|
||||||
@@ -9,7 +9,7 @@
|
|||||||
"tsc:check": "vue-tsc --noEmit",
|
"tsc:check": "vue-tsc --noEmit",
|
||||||
"lint": "eslint . && prettier --check .",
|
"lint": "eslint . && prettier --check .",
|
||||||
"fix": "eslint . --fix && prettier --write .",
|
"fix": "eslint . --fix && prettier --write .",
|
||||||
"intl:extract": "formatjs extract \"{,src/components,src/composables,src/helpers,src/pages,src/store}/**/*.{vue,ts,tsx,js,jsx,mts,cts,mjs,cjs}\" --ignore '**/*.d.ts' --ignore 'node_modules' --out-file src/locales/en-US/index.json --format crowdin --preserve-whitespace",
|
"intl:extract": "formatjs extract \"src/**/*.{vue,ts,tsx,js,jsx,mts,cts,mjs,cjs}\" --ignore \"**/*.d.ts\" --ignore node_modules --out-file src/locales/en-US/index.json --format crowdin --preserve-whitespace",
|
||||||
"test": "vue-tsc --noEmit"
|
"test": "vue-tsc --noEmit"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
@@ -20,16 +20,20 @@
|
|||||||
"@sentry/vue": "^8.27.0",
|
"@sentry/vue": "^8.27.0",
|
||||||
"@tauri-apps/api": "^2.5.0",
|
"@tauri-apps/api": "^2.5.0",
|
||||||
"@tauri-apps/plugin-dialog": "^2.2.1",
|
"@tauri-apps/plugin-dialog": "^2.2.1",
|
||||||
|
"@tauri-apps/plugin-http": "^2.5.0",
|
||||||
"@tauri-apps/plugin-opener": "^2.2.6",
|
"@tauri-apps/plugin-opener": "^2.2.6",
|
||||||
"@tauri-apps/plugin-os": "^2.2.1",
|
"@tauri-apps/plugin-os": "^2.2.1",
|
||||||
"@tauri-apps/plugin-updater": "^2.7.1",
|
"@tauri-apps/plugin-updater": "^2.7.1",
|
||||||
"@tauri-apps/plugin-window-state": "^2.2.2",
|
"@tauri-apps/plugin-window-state": "^2.2.2",
|
||||||
|
"@types/three": "^0.172.0",
|
||||||
"@vintl/vintl": "^4.4.1",
|
"@vintl/vintl": "^4.4.1",
|
||||||
|
"@vueuse/core": "^11.1.0",
|
||||||
"dayjs": "^1.11.10",
|
"dayjs": "^1.11.10",
|
||||||
"floating-vue": "^5.2.2",
|
"floating-vue": "^5.2.2",
|
||||||
"ofetch": "^1.3.4",
|
"ofetch": "^1.3.4",
|
||||||
"pinia": "^2.1.7",
|
"pinia": "^2.1.7",
|
||||||
"posthog-js": "^1.158.2",
|
"posthog-js": "^1.158.2",
|
||||||
|
"three": "^0.172.0",
|
||||||
"vite-svg-loader": "^5.1.0",
|
"vite-svg-loader": "^5.1.0",
|
||||||
"vue": "^3.5.13",
|
"vue": "^3.5.13",
|
||||||
"vue-multiselect": "3.0.0",
|
"vue-multiselect": "3.0.0",
|
||||||
@@ -37,6 +41,7 @@
|
|||||||
"vue-virtual-scroller": "v2.0.0-beta.8"
|
"vue-virtual-scroller": "v2.0.0-beta.8"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
"@modrinth/tooling-config": "workspace:*",
|
||||||
"@eslint/compat": "^1.1.1",
|
"@eslint/compat": "^1.1.1",
|
||||||
"@formatjs/cli": "^6.2.12",
|
"@formatjs/cli": "^6.2.12",
|
||||||
"@nuxt/eslint-config": "^0.5.6",
|
"@nuxt/eslint-config": "^0.5.6",
|
||||||
@@ -44,13 +49,11 @@
|
|||||||
"@vitejs/plugin-vue": "^5.0.4",
|
"@vitejs/plugin-vue": "^5.0.4",
|
||||||
"autoprefixer": "^10.4.19",
|
"autoprefixer": "^10.4.19",
|
||||||
"eslint": "^9.9.1",
|
"eslint": "^9.9.1",
|
||||||
"eslint-config-custom": "workspace:*",
|
|
||||||
"eslint-plugin-turbo": "^2.5.4",
|
"eslint-plugin-turbo": "^2.5.4",
|
||||||
"postcss": "^8.4.39",
|
"postcss": "^8.4.39",
|
||||||
"prettier": "^3.2.5",
|
"prettier": "^3.2.5",
|
||||||
"sass": "^1.74.1",
|
"sass": "^1.74.1",
|
||||||
"tailwindcss": "^3.4.4",
|
"tailwindcss": "^3.4.4",
|
||||||
"tsconfig": "workspace:*",
|
|
||||||
"typescript": "^5.5.4",
|
"typescript": "^5.5.4",
|
||||||
"vite": "^5.4.6",
|
"vite": "^5.4.6",
|
||||||
"vue-tsc": "^2.1.6"
|
"vue-tsc": "^2.1.6"
|
||||||
|
|||||||
@@ -1,8 +1,7 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
import { computed, onMounted, onUnmounted, ref, watch } from 'vue'
|
|
||||||
import { RouterView, useRoute, useRouter } from 'vue-router'
|
|
||||||
import {
|
import {
|
||||||
ArrowBigUpDashIcon,
|
ArrowBigUpDashIcon,
|
||||||
|
ChangeSkinIcon,
|
||||||
CompassIcon,
|
CompassIcon,
|
||||||
DownloadIcon,
|
DownloadIcon,
|
||||||
HomeIcon,
|
HomeIcon,
|
||||||
@@ -12,6 +11,7 @@ import {
|
|||||||
LogOutIcon,
|
LogOutIcon,
|
||||||
MaximizeIcon,
|
MaximizeIcon,
|
||||||
MinimizeIcon,
|
MinimizeIcon,
|
||||||
|
NewspaperIcon,
|
||||||
PlusIcon,
|
PlusIcon,
|
||||||
RestoreIcon,
|
RestoreIcon,
|
||||||
RightArrowIcon,
|
RightArrowIcon,
|
||||||
@@ -23,53 +23,57 @@ import {
|
|||||||
Avatar,
|
Avatar,
|
||||||
Button,
|
Button,
|
||||||
ButtonStyled,
|
ButtonStyled,
|
||||||
|
NewsArticleCard,
|
||||||
Notifications,
|
Notifications,
|
||||||
OverflowMenu,
|
OverflowMenu,
|
||||||
useRelativeTime,
|
|
||||||
} from '@modrinth/ui'
|
} from '@modrinth/ui'
|
||||||
import { useLoading, useTheming } from '@/store/state'
|
import { renderString } from '@modrinth/utils'
|
||||||
import ModrinthAppLogo from '@/assets/modrinth_app.svg?component'
|
|
||||||
import AccountsCard from '@/components/ui/AccountsCard.vue'
|
|
||||||
import InstanceCreationModal from '@/components/ui/InstanceCreationModal.vue'
|
|
||||||
import { get } from '@/helpers/settings.ts'
|
|
||||||
import Breadcrumbs from '@/components/ui/Breadcrumbs.vue'
|
|
||||||
import RunningAppBar from '@/components/ui/RunningAppBar.vue'
|
|
||||||
import SplashScreen from '@/components/ui/SplashScreen.vue'
|
|
||||||
import ErrorModal from '@/components/ui/ErrorModal.vue'
|
|
||||||
import ModrinthLoadingIndicator from '@/components/LoadingIndicatorBar.vue'
|
|
||||||
import { handleError, useNotifications } from '@/store/notifications.js'
|
|
||||||
import { command_listener, warning_listener } from '@/helpers/events.js'
|
|
||||||
import { type } from '@tauri-apps/plugin-os'
|
|
||||||
import { getOS, isDev, restartApp } from '@/helpers/utils.js'
|
|
||||||
import { debugAnalytics, initAnalytics, optOutAnalytics, trackEvent } from '@/helpers/analytics'
|
|
||||||
import { getCurrentWindow } from '@tauri-apps/api/window'
|
|
||||||
import { getVersion } from '@tauri-apps/api/app'
|
import { getVersion } from '@tauri-apps/api/app'
|
||||||
import URLConfirmModal from '@/components/ui/URLConfirmModal.vue'
|
import { invoke } from '@tauri-apps/api/core'
|
||||||
import { create_profile_and_install_from_file } from './helpers/pack'
|
import { getCurrentWindow } from '@tauri-apps/api/window'
|
||||||
import { useError } from '@/store/error.js'
|
import { openUrl } from '@tauri-apps/plugin-opener'
|
||||||
import { useCheckDisableMouseover } from '@/composables/macCssFix.js'
|
import { type } from '@tauri-apps/plugin-os'
|
||||||
import ModInstallModal from '@/components/ui/install_flow/ModInstallModal.vue'
|
import { check } from '@tauri-apps/plugin-updater'
|
||||||
|
import { saveWindowState, StateFlags } from '@tauri-apps/plugin-window-state'
|
||||||
|
import { computed, onMounted, onUnmounted, provide, ref, watch } from 'vue'
|
||||||
|
import { RouterView, useRoute, useRouter } from 'vue-router'
|
||||||
|
|
||||||
|
import ModrinthAppLogo from '@/assets/modrinth_app.svg?component'
|
||||||
|
import ModrinthLoadingIndicator from '@/components/LoadingIndicatorBar.vue'
|
||||||
|
import AccountsCard from '@/components/ui/AccountsCard.vue'
|
||||||
|
import Breadcrumbs from '@/components/ui/Breadcrumbs.vue'
|
||||||
|
import ErrorModal from '@/components/ui/ErrorModal.vue'
|
||||||
|
import FriendsList from '@/components/ui/friends/FriendsList.vue'
|
||||||
import IncompatibilityWarningModal from '@/components/ui/install_flow/IncompatibilityWarningModal.vue'
|
import IncompatibilityWarningModal from '@/components/ui/install_flow/IncompatibilityWarningModal.vue'
|
||||||
import InstallConfirmModal from '@/components/ui/install_flow/InstallConfirmModal.vue'
|
import InstallConfirmModal from '@/components/ui/install_flow/InstallConfirmModal.vue'
|
||||||
import { useInstall } from '@/store/install.js'
|
import ModInstallModal from '@/components/ui/install_flow/ModInstallModal.vue'
|
||||||
import { invoke } from '@tauri-apps/api/core'
|
import InstanceCreationModal from '@/components/ui/InstanceCreationModal.vue'
|
||||||
import { get_opening_command, initialize_state } from '@/helpers/state'
|
|
||||||
import { saveWindowState, StateFlags } from '@tauri-apps/plugin-window-state'
|
|
||||||
import { renderString } from '@modrinth/utils'
|
|
||||||
import { useFetch } from '@/helpers/fetch.js'
|
|
||||||
import { check } from '@tauri-apps/plugin-updater'
|
|
||||||
import NavButton from '@/components/ui/NavButton.vue'
|
|
||||||
import { get as getCreds, login, logout } from '@/helpers/mr_auth.js'
|
|
||||||
import { get_user } from '@/helpers/cache.js'
|
|
||||||
import AppSettingsModal from '@/components/ui/modal/AppSettingsModal.vue'
|
import AppSettingsModal from '@/components/ui/modal/AppSettingsModal.vue'
|
||||||
import dayjs from 'dayjs'
|
import AuthGrantFlowWaitModal from '@/components/ui/modal/AuthGrantFlowWaitModal.vue'
|
||||||
|
import NavButton from '@/components/ui/NavButton.vue'
|
||||||
import PromotionWrapper from '@/components/ui/PromotionWrapper.vue'
|
import PromotionWrapper from '@/components/ui/PromotionWrapper.vue'
|
||||||
import { hide_ads_window, init_ads_window } from '@/helpers/ads.js'
|
|
||||||
import FriendsList from '@/components/ui/friends/FriendsList.vue'
|
|
||||||
import { openUrl } from '@tauri-apps/plugin-opener'
|
|
||||||
import QuickInstanceSwitcher from '@/components/ui/QuickInstanceSwitcher.vue'
|
import QuickInstanceSwitcher from '@/components/ui/QuickInstanceSwitcher.vue'
|
||||||
|
import RunningAppBar from '@/components/ui/RunningAppBar.vue'
|
||||||
|
import SplashScreen from '@/components/ui/SplashScreen.vue'
|
||||||
|
import URLConfirmModal from '@/components/ui/URLConfirmModal.vue'
|
||||||
|
import { useCheckDisableMouseover } from '@/composables/macCssFix.js'
|
||||||
|
import { hide_ads_window, init_ads_window } from '@/helpers/ads.js'
|
||||||
|
import { debugAnalytics, initAnalytics, optOutAnalytics, trackEvent } from '@/helpers/analytics'
|
||||||
|
import { get_user } from '@/helpers/cache.js'
|
||||||
|
import { command_listener, warning_listener } from '@/helpers/events.js'
|
||||||
|
import { useFetch } from '@/helpers/fetch.js'
|
||||||
|
import { cancelLogin, get as getCreds, login, logout } from '@/helpers/mr_auth.js'
|
||||||
|
import { get } from '@/helpers/settings.ts'
|
||||||
|
import { get_opening_command, initialize_state } from '@/helpers/state'
|
||||||
|
import { getOS, isDev, restartApp } from '@/helpers/utils.js'
|
||||||
|
import { useError } from '@/store/error.js'
|
||||||
|
import { useInstall } from '@/store/install.js'
|
||||||
|
import { handleError, useNotifications } from '@/store/notifications.js'
|
||||||
|
import { useLoading, useTheming } from '@/store/state'
|
||||||
|
|
||||||
const formatRelativeTime = useRelativeTime()
|
import { create_profile_and_install_from_file } from './helpers/pack'
|
||||||
|
import { generateSkinPreviews } from './helpers/rendering/batch-skin-renderer'
|
||||||
|
import { get_available_capes, get_available_skins } from './helpers/skins'
|
||||||
|
|
||||||
const themeStore = useTheming()
|
const themeStore = useTheming()
|
||||||
|
|
||||||
@@ -177,6 +181,7 @@ async function setupApp() {
|
|||||||
'criticalAnnouncements',
|
'criticalAnnouncements',
|
||||||
true,
|
true,
|
||||||
)
|
)
|
||||||
|
.then((response) => response.json())
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
if (res && res.header && res.body) {
|
if (res && res.header && res.body) {
|
||||||
criticalErrorMessage.value = res
|
criticalErrorMessage.value = res
|
||||||
@@ -188,15 +193,35 @@ async function setupApp() {
|
|||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
useFetch(`https://modrinth.com/blog/news.json`, 'news', true).then((res) => {
|
useFetch(`https://modrinth.com/news/feed/articles.json`, 'news', true)
|
||||||
if (res && res.articles) {
|
.then((response) => response.json())
|
||||||
news.value = res.articles
|
.then((res) => {
|
||||||
}
|
if (res && res.articles) {
|
||||||
})
|
// Format expected by NewsArticleCard component.
|
||||||
|
news.value = res.articles
|
||||||
|
.map((article) => ({
|
||||||
|
...article,
|
||||||
|
path: article.link,
|
||||||
|
thumbnail: article.thumbnail,
|
||||||
|
title: article.title,
|
||||||
|
summary: article.summary,
|
||||||
|
date: article.date,
|
||||||
|
}))
|
||||||
|
.slice(0, 4)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
get_opening_command().then(handleCommand)
|
get_opening_command().then(handleCommand)
|
||||||
checkUpdates()
|
checkUpdates()
|
||||||
fetchCredentials()
|
fetchCredentials()
|
||||||
|
|
||||||
|
try {
|
||||||
|
const skins = (await get_available_skins()) ?? []
|
||||||
|
const capes = (await get_available_capes()) ?? []
|
||||||
|
generateSkinPreviews(skins, capes)
|
||||||
|
} catch (error) {
|
||||||
|
console.warn('Failed to generate skin previews in app setup.', error)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const stateFailed = ref(false)
|
const stateFailed = ref(false)
|
||||||
@@ -241,6 +266,8 @@ const incompatibilityWarningModal = ref()
|
|||||||
|
|
||||||
const credentials = ref()
|
const credentials = ref()
|
||||||
|
|
||||||
|
const modrinthLoginFlowWaitModal = ref()
|
||||||
|
|
||||||
async function fetchCredentials() {
|
async function fetchCredentials() {
|
||||||
const creds = await getCreds().catch(handleError)
|
const creds = await getCreds().catch(handleError)
|
||||||
if (creds && creds.user_id) {
|
if (creds && creds.user_id) {
|
||||||
@@ -250,8 +277,24 @@ async function fetchCredentials() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function signIn() {
|
async function signIn() {
|
||||||
await login().catch(handleError)
|
modrinthLoginFlowWaitModal.value.show()
|
||||||
await fetchCredentials()
|
|
||||||
|
try {
|
||||||
|
await login()
|
||||||
|
await fetchCredentials()
|
||||||
|
} catch (error) {
|
||||||
|
if (
|
||||||
|
typeof error === 'object' &&
|
||||||
|
typeof error['message'] === 'string' &&
|
||||||
|
error.message.includes('Login canceled')
|
||||||
|
) {
|
||||||
|
// Not really an error due to being a result of user interaction, show nothing
|
||||||
|
} else {
|
||||||
|
handleError(error)
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
modrinthLoginFlowWaitModal.value.hide()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function logOut() {
|
async function logOut() {
|
||||||
@@ -304,6 +347,7 @@ onMounted(() => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
const accounts = ref(null)
|
const accounts = ref(null)
|
||||||
|
provide('accountsCard', accounts)
|
||||||
|
|
||||||
command_listener(handleCommand)
|
command_listener(handleCommand)
|
||||||
async function handleCommand(e) {
|
async function handleCommand(e) {
|
||||||
@@ -379,6 +423,9 @@ function handleAuxClick(e) {
|
|||||||
<Suspense>
|
<Suspense>
|
||||||
<AppSettingsModal ref="settingsModal" />
|
<AppSettingsModal ref="settingsModal" />
|
||||||
</Suspense>
|
</Suspense>
|
||||||
|
<Suspense>
|
||||||
|
<AuthGrantFlowWaitModal ref="modrinthLoginFlowWaitModal" @flow-cancel="cancelLogin" />
|
||||||
|
</Suspense>
|
||||||
<Suspense>
|
<Suspense>
|
||||||
<InstanceCreationModal ref="installationModal" />
|
<InstanceCreationModal ref="installationModal" />
|
||||||
</Suspense>
|
</Suspense>
|
||||||
@@ -399,6 +446,9 @@ function handleAuxClick(e) {
|
|||||||
>
|
>
|
||||||
<CompassIcon />
|
<CompassIcon />
|
||||||
</NavButton>
|
</NavButton>
|
||||||
|
<NavButton v-tooltip.right="'Skins (Beta)'" to="/skins">
|
||||||
|
<ChangeSkinIcon />
|
||||||
|
</NavButton>
|
||||||
<NavButton
|
<NavButton
|
||||||
v-tooltip.right="'Library'"
|
v-tooltip.right="'Library'"
|
||||||
to="/library"
|
to="/library"
|
||||||
@@ -459,13 +509,13 @@ function handleAuxClick(e) {
|
|||||||
<ModrinthAppLogo class="h-full w-auto text-contrast pointer-events-none" />
|
<ModrinthAppLogo class="h-full w-auto text-contrast pointer-events-none" />
|
||||||
<div class="flex items-center gap-1 ml-3">
|
<div class="flex items-center gap-1 ml-3">
|
||||||
<button
|
<button
|
||||||
class="cursor-pointer p-0 m-0 border-none outline-none bg-button-bg rounded-full flex items-center justify-center w-6 h-6 hover:brightness-75 transition-all"
|
class="cursor-pointer p-0 m-0 text-contrast border-none outline-none bg-button-bg rounded-full flex items-center justify-center w-6 h-6 hover:brightness-75 transition-all"
|
||||||
@click="router.back()"
|
@click="router.back()"
|
||||||
>
|
>
|
||||||
<LeftArrowIcon />
|
<LeftArrowIcon />
|
||||||
</button>
|
</button>
|
||||||
<button
|
<button
|
||||||
class="cursor-pointer p-0 m-0 border-none outline-none bg-button-bg rounded-full flex items-center justify-center w-6 h-6 hover:brightness-75 transition-all"
|
class="cursor-pointer p-0 m-0 text-contrast border-none outline-none bg-button-bg rounded-full flex items-center justify-center w-6 h-6 hover:brightness-75 transition-all"
|
||||||
@click="router.forward()"
|
@click="router.forward()"
|
||||||
>
|
>
|
||||||
<RightArrowIcon />
|
<RightArrowIcon />
|
||||||
@@ -579,34 +629,20 @@ function handleAuxClick(e) {
|
|||||||
<FriendsList :credentials="credentials" :sign-in="() => signIn()" />
|
<FriendsList :credentials="credentials" :sign-in="() => signIn()" />
|
||||||
</suspense>
|
</suspense>
|
||||||
</div>
|
</div>
|
||||||
<div v-if="news && news.length > 0" class="pt-4 flex flex-col">
|
<div v-if="news && news.length > 0" class="pt-4 flex flex-col items-center">
|
||||||
<h3 class="px-4 text-lg m-0">News</h3>
|
<h3 class="px-4 text-lg m-0 text-left w-full">News</h3>
|
||||||
<template v-for="(item, index) in news" :key="`news-${index}`">
|
<div class="px-4 pt-2 space-y-4 flex flex-col items-center w-full">
|
||||||
<a
|
<NewsArticleCard
|
||||||
:class="`flex flex-col outline-offset-[-4px] hover:bg-[--brand-gradient-border] focus:bg-[--brand-gradient-border] px-4 transition-colors ${index === 0 ? 'pt-2 pb-4' : 'py-4'}`"
|
v-for="(item, index) in news"
|
||||||
:href="item.link"
|
:key="`news-${index}`"
|
||||||
target="_blank"
|
:article="item"
|
||||||
rel="external"
|
|
||||||
>
|
|
||||||
<img
|
|
||||||
:src="item.thumbnail"
|
|
||||||
alt="News thumbnail"
|
|
||||||
aria-hidden="true"
|
|
||||||
class="w-full aspect-[3/1] object-cover rounded-2xl border-[1px] border-solid border-[--brand-gradient-border]"
|
|
||||||
/>
|
|
||||||
<h4 class="mt-2 mb-0 text-sm leading-none text-contrast font-semibold">
|
|
||||||
{{ item.title }}
|
|
||||||
</h4>
|
|
||||||
<p class="my-1 text-sm text-secondary leading-tight">{{ item.summary }}</p>
|
|
||||||
<p class="text-right text-sm text-secondary opacity-60 leading-tight m-0">
|
|
||||||
{{ formatRelativeTime(dayjs(item.date).toISOString()) }}
|
|
||||||
</p>
|
|
||||||
</a>
|
|
||||||
<hr
|
|
||||||
v-if="index !== news.length - 1"
|
|
||||||
class="h-px my-[-2px] mx-4 border-0 m-0 bg-[--brand-gradient-border]"
|
|
||||||
/>
|
/>
|
||||||
</template>
|
<ButtonStyled color="brand" size="large">
|
||||||
|
<a href="https://modrinth.com/news" target="_blank" class="my-4">
|
||||||
|
<NewspaperIcon /> View all news
|
||||||
|
</a>
|
||||||
|
</ButtonStyled>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
24
apps/app-frontend/src/assets/external/index.js
vendored
24
apps/app-frontend/src/assets/external/index.js
vendored
@@ -1,18 +1,18 @@
|
|||||||
|
export { default as ATLauncherIcon } from './atlauncher.svg'
|
||||||
export { default as BuyMeACoffeeIcon } from './bmac.svg'
|
export { default as BuyMeACoffeeIcon } from './bmac.svg'
|
||||||
export { default as DiscordIcon } from './discord.svg'
|
export { default as DiscordIcon } from './discord.svg'
|
||||||
|
export { default as GDLauncherIcon } from './gdlauncher.png'
|
||||||
|
export { default as GithubIcon } from './github.svg'
|
||||||
|
export { default as GitLabIcon } from './gitlab.svg'
|
||||||
|
export { default as GoogleIcon } from './google.svg'
|
||||||
export { default as KoFiIcon } from './kofi.svg'
|
export { default as KoFiIcon } from './kofi.svg'
|
||||||
|
export { default as MastodonIcon } from './mastodon.svg'
|
||||||
|
export { default as MicrosoftIcon } from './microsoft.svg'
|
||||||
|
export { default as MultiMCIcon } from './multimc.webp'
|
||||||
|
export { default as OpenCollectiveIcon } from './opencollective.svg'
|
||||||
export { default as PatreonIcon } from './patreon.svg'
|
export { default as PatreonIcon } from './patreon.svg'
|
||||||
export { default as PaypalIcon } from './paypal.svg'
|
export { default as PaypalIcon } from './paypal.svg'
|
||||||
export { default as OpenCollectiveIcon } from './opencollective.svg'
|
|
||||||
export { default as TwitterIcon } from './twitter.svg'
|
|
||||||
export { default as GithubIcon } from './github.svg'
|
|
||||||
export { default as MastodonIcon } from './mastodon.svg'
|
|
||||||
export { default as RedditIcon } from './reddit.svg'
|
|
||||||
export { default as GoogleIcon } from './google.svg'
|
|
||||||
export { default as MicrosoftIcon } from './microsoft.svg'
|
|
||||||
export { default as SteamIcon } from './steam.svg'
|
|
||||||
export { default as GitLabIcon } from './gitlab.svg'
|
|
||||||
export { default as ATLauncherIcon } from './atlauncher.svg'
|
|
||||||
export { default as GDLauncherIcon } from './gdlauncher.png'
|
|
||||||
export { default as MultiMCIcon } from './multimc.webp'
|
|
||||||
export { default as PrismIcon } from './prism.svg'
|
export { default as PrismIcon } from './prism.svg'
|
||||||
|
export { default as RedditIcon } from './reddit.svg'
|
||||||
|
export { default as SteamIcon } from './steam.svg'
|
||||||
|
export { default as TwitterIcon } from './twitter.svg'
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
export { default as SwapIcon } from './arrow-left-right.svg'
|
|
||||||
export { default as ToggleIcon } from './toggle.svg'
|
|
||||||
export { default as PackageIcon } from './package.svg'
|
|
||||||
export { default as VersionIcon } from './milestone.svg'
|
|
||||||
export { default as TextInputIcon } from './text-cursor-input.svg'
|
|
||||||
export { default as AddProjectImage } from './add-project.svg'
|
export { default as AddProjectImage } from './add-project.svg'
|
||||||
export { default as NewInstanceImage } from './new-instance.svg'
|
export { default as SwapIcon } from './arrow-left-right.svg'
|
||||||
export { default as MenuIcon } from './menu.svg'
|
export { default as MenuIcon } from './menu.svg'
|
||||||
export { default as ChatIcon } from './messages-square.svg'
|
export { default as ChatIcon } from './messages-square.svg'
|
||||||
|
export { default as VersionIcon } from './milestone.svg'
|
||||||
|
export { default as NewInstanceImage } from './new-instance.svg'
|
||||||
|
export { default as PackageIcon } from './package.svg'
|
||||||
|
export { default as TextInputIcon } from './text-cursor-input.svg'
|
||||||
|
export { default as ToggleIcon } from './toggle.svg'
|
||||||
|
|||||||
BIN
apps/app-frontend/src/assets/skins/herobrine.png
Normal file
BIN
apps/app-frontend/src/assets/skins/herobrine.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.1 KiB |
BIN
apps/app-frontend/src/assets/skins/steve.png
Normal file
BIN
apps/app-frontend/src/assets/skins/steve.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.3 KiB |
@@ -1,24 +1,25 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
import Instance from '@/components/ui/Instance.vue'
|
|
||||||
import { computed, ref } from 'vue'
|
|
||||||
import {
|
import {
|
||||||
ClipboardCopyIcon,
|
ClipboardCopyIcon,
|
||||||
|
EyeIcon,
|
||||||
FolderOpenIcon,
|
FolderOpenIcon,
|
||||||
PlayIcon,
|
PlayIcon,
|
||||||
PlusIcon,
|
PlusIcon,
|
||||||
TrashIcon,
|
|
||||||
StopCircleIcon,
|
|
||||||
EyeIcon,
|
|
||||||
SearchIcon,
|
SearchIcon,
|
||||||
|
StopCircleIcon,
|
||||||
|
TrashIcon,
|
||||||
XIcon,
|
XIcon,
|
||||||
} from '@modrinth/assets'
|
} from '@modrinth/assets'
|
||||||
import { Button, DropdownSelect } from '@modrinth/ui'
|
import { Button, DropdownSelect } from '@modrinth/ui'
|
||||||
import { formatCategoryHeader } from '@modrinth/utils'
|
import { formatCategoryHeader } from '@modrinth/utils'
|
||||||
import ContextMenu from '@/components/ui/ContextMenu.vue'
|
|
||||||
import dayjs from 'dayjs'
|
import dayjs from 'dayjs'
|
||||||
|
import { computed, ref } from 'vue'
|
||||||
|
|
||||||
|
import ContextMenu from '@/components/ui/ContextMenu.vue'
|
||||||
|
import Instance from '@/components/ui/Instance.vue'
|
||||||
|
import ConfirmModalWrapper from '@/components/ui/modal/ConfirmModalWrapper.vue'
|
||||||
import { duplicate, remove } from '@/helpers/profile.js'
|
import { duplicate, remove } from '@/helpers/profile.js'
|
||||||
import { handleError } from '@/store/notifications.js'
|
import { handleError } from '@/store/notifications.js'
|
||||||
import ConfirmModalWrapper from '@/components/ui/modal/ConfirmModalWrapper.vue'
|
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
instances: {
|
instances: {
|
||||||
@@ -136,7 +137,7 @@ const filteredResults = computed(() => {
|
|||||||
|
|
||||||
if (sortBy.value === 'Game version') {
|
if (sortBy.value === 'Game version') {
|
||||||
instances.sort((a, b) => {
|
instances.sort((a, b) => {
|
||||||
return a.game_version.localeCompare(b.game_version)
|
return a.game_version.localeCompare(b.game_version, undefined, { numeric: true })
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -213,6 +214,17 @@ const filteredResults = computed(() => {
|
|||||||
instanceMap.set(entry[0], entry[1])
|
instanceMap.set(entry[0], entry[1])
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
// default sorting would do 1.20.4 < 1.8.9 because 2 < 8
|
||||||
|
// localeCompare with numeric=true puts 1.8.9 < 1.20.4 because 8 < 20
|
||||||
|
if (group.value === 'Game version') {
|
||||||
|
const sortedEntries = [...instanceMap.entries()].sort((a, b) => {
|
||||||
|
return a[0].localeCompare(b[0], undefined, { numeric: true })
|
||||||
|
})
|
||||||
|
instanceMap.clear()
|
||||||
|
sortedEntries.forEach((entry) => {
|
||||||
|
instanceMap.set(entry[0], entry[1])
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
return instanceMap
|
return instanceMap
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
import { computed, onBeforeUnmount, ref, watch } from 'vue'
|
import { computed, onBeforeUnmount, ref, watch } from 'vue'
|
||||||
|
|
||||||
import { useLoading } from '@/store/state.js'
|
import { useLoading } from '@/store/state.js'
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
|
|||||||
@@ -1,31 +1,32 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
import {
|
import {
|
||||||
ClipboardCopyIcon,
|
ClipboardCopyIcon,
|
||||||
FolderOpenIcon,
|
|
||||||
PlayIcon,
|
|
||||||
PlusIcon,
|
|
||||||
TrashIcon,
|
|
||||||
DownloadIcon,
|
DownloadIcon,
|
||||||
GlobeIcon,
|
|
||||||
StopCircleIcon,
|
|
||||||
ExternalIcon,
|
ExternalIcon,
|
||||||
EyeIcon,
|
EyeIcon,
|
||||||
|
FolderOpenIcon,
|
||||||
|
GlobeIcon,
|
||||||
|
PlayIcon,
|
||||||
|
PlusIcon,
|
||||||
|
StopCircleIcon,
|
||||||
|
TrashIcon,
|
||||||
} from '@modrinth/assets'
|
} from '@modrinth/assets'
|
||||||
import ConfirmModalWrapper from '@/components/ui/modal/ConfirmModalWrapper.vue'
|
import { HeadingLink } from '@modrinth/ui'
|
||||||
import Instance from '@/components/ui/Instance.vue'
|
import { openUrl } from '@tauri-apps/plugin-opener'
|
||||||
import { computed, onMounted, onUnmounted, ref } from 'vue'
|
import { computed, onMounted, onUnmounted, ref } from 'vue'
|
||||||
import ContextMenu from '@/components/ui/ContextMenu.vue'
|
|
||||||
import ProjectCard from '@/components/ui/ProjectCard.vue'
|
|
||||||
import { get_by_profile_path } from '@/helpers/process.js'
|
|
||||||
import { handleError } from '@/store/notifications.js'
|
|
||||||
import { duplicate, kill, remove, run } from '@/helpers/profile.js'
|
|
||||||
import { useRouter } from 'vue-router'
|
import { useRouter } from 'vue-router'
|
||||||
import { showProfileInFolder } from '@/helpers/utils.js'
|
|
||||||
|
import ContextMenu from '@/components/ui/ContextMenu.vue'
|
||||||
|
import Instance from '@/components/ui/Instance.vue'
|
||||||
|
import ConfirmModalWrapper from '@/components/ui/modal/ConfirmModalWrapper.vue'
|
||||||
|
import ProjectCard from '@/components/ui/ProjectCard.vue'
|
||||||
import { trackEvent } from '@/helpers/analytics'
|
import { trackEvent } from '@/helpers/analytics'
|
||||||
|
import { get_by_profile_path } from '@/helpers/process.js'
|
||||||
|
import { duplicate, kill, remove, run } from '@/helpers/profile.js'
|
||||||
|
import { showProfileInFolder } from '@/helpers/utils.js'
|
||||||
import { handleSevereError } from '@/store/error.js'
|
import { handleSevereError } from '@/store/error.js'
|
||||||
import { install as installVersion } from '@/store/install.js'
|
import { install as installVersion } from '@/store/install.js'
|
||||||
import { openUrl } from '@tauri-apps/plugin-opener'
|
import { handleError } from '@/store/notifications.js'
|
||||||
import { HeadingLink } from '@modrinth/ui'
|
|
||||||
|
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
|
|
||||||
|
|||||||
@@ -9,13 +9,11 @@
|
|||||||
<Avatar
|
<Avatar
|
||||||
size="36px"
|
size="36px"
|
||||||
:src="
|
:src="
|
||||||
selectedAccount
|
selectedAccount ? avatarUrl : 'https://launcher-files.modrinth.com/assets/steve_head.png'
|
||||||
? `https://mc-heads.net/avatar/${selectedAccount.id}/128`
|
|
||||||
: 'https://launcher-files.modrinth.com/assets/steve_head.png'
|
|
||||||
"
|
"
|
||||||
/>
|
/>
|
||||||
<div class="flex flex-col w-full">
|
<div class="flex flex-col w-full">
|
||||||
<span>{{ selectedAccount ? selectedAccount.username : 'Select account' }}</span>
|
<span>{{ selectedAccount ? selectedAccount.profile.name : 'Select account' }}</span>
|
||||||
<span class="text-secondary text-xs">Minecraft account</span>
|
<span class="text-secondary text-xs">Minecraft account</span>
|
||||||
</div>
|
</div>
|
||||||
<DropdownIcon class="w-5 h-5 shrink-0" />
|
<DropdownIcon class="w-5 h-5 shrink-0" />
|
||||||
@@ -28,28 +26,40 @@
|
|||||||
:class="{ expanded: mode === 'expanded', isolated: mode === 'isolated' }"
|
:class="{ expanded: mode === 'expanded', isolated: mode === 'isolated' }"
|
||||||
>
|
>
|
||||||
<div v-if="selectedAccount" class="selected account">
|
<div v-if="selectedAccount" class="selected account">
|
||||||
<Avatar size="xs" :src="`https://mc-heads.net/avatar/${selectedAccount.id}/128`" />
|
<Avatar size="xs" :src="avatarUrl" />
|
||||||
<div>
|
<div>
|
||||||
<h4>{{ selectedAccount.username }}</h4>
|
<h4>{{ selectedAccount.profile.name }}</h4>
|
||||||
<p>Selected</p>
|
<p>Selected</p>
|
||||||
</div>
|
</div>
|
||||||
<Button v-tooltip="'Log out'" icon-only color="raised" @click="logout(selectedAccount.id)">
|
<Button
|
||||||
|
v-tooltip="'Log out'"
|
||||||
|
icon-only
|
||||||
|
color="raised"
|
||||||
|
@click="logout(selectedAccount.profile.id)"
|
||||||
|
>
|
||||||
<TrashIcon />
|
<TrashIcon />
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
<div v-else class="logged-out account">
|
<div v-else class="logged-out account">
|
||||||
<h4>Not signed in</h4>
|
<h4>Not signed in</h4>
|
||||||
<Button v-tooltip="'Log in'" icon-only color="primary" @click="login()">
|
<Button
|
||||||
<LogInIcon />
|
v-tooltip="'Log in'"
|
||||||
|
:disabled="loginDisabled"
|
||||||
|
icon-only
|
||||||
|
color="primary"
|
||||||
|
@click="login()"
|
||||||
|
>
|
||||||
|
<LogInIcon v-if="!loginDisabled" />
|
||||||
|
<SpinnerIcon v-else class="animate-spin" />
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
<div v-if="displayAccounts.length > 0" class="account-group">
|
<div v-if="displayAccounts.length > 0" class="account-group">
|
||||||
<div v-for="account in displayAccounts" :key="account.id" class="account-row">
|
<div v-for="account in displayAccounts" :key="account.profile.id" class="account-row">
|
||||||
<Button class="option account" @click="setAccount(account)">
|
<Button class="option account" @click="setAccount(account)">
|
||||||
<Avatar :src="`https://mc-heads.net/avatar/${account.id}/128`" class="icon" />
|
<Avatar :src="getAccountAvatarUrl(account)" class="icon" />
|
||||||
<p>{{ account.username }}</p>
|
<p>{{ account.profile.name }}</p>
|
||||||
</Button>
|
</Button>
|
||||||
<Button v-tooltip="'Log out'" icon-only @click="logout(account.id)">
|
<Button v-tooltip="'Log out'" icon-only @click="logout(account.profile.id)">
|
||||||
<TrashIcon />
|
<TrashIcon />
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
@@ -63,20 +73,23 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import { DropdownIcon, PlusIcon, TrashIcon, LogInIcon } from '@modrinth/assets'
|
import { DropdownIcon, LogInIcon, PlusIcon, SpinnerIcon, TrashIcon } from '@modrinth/assets'
|
||||||
import { Avatar, Button, Card } from '@modrinth/ui'
|
import { Avatar, Button, Card } from '@modrinth/ui'
|
||||||
import { ref, computed, onMounted, onBeforeUnmount, onUnmounted } from 'vue'
|
import { computed, onBeforeUnmount, onMounted, onUnmounted, ref } from 'vue'
|
||||||
|
|
||||||
|
import { trackEvent } from '@/helpers/analytics'
|
||||||
import {
|
import {
|
||||||
users,
|
get_default_user,
|
||||||
|
login as login_flow,
|
||||||
remove_user,
|
remove_user,
|
||||||
set_default_user,
|
set_default_user,
|
||||||
login as login_flow,
|
users,
|
||||||
get_default_user,
|
|
||||||
} from '@/helpers/auth'
|
} from '@/helpers/auth'
|
||||||
import { handleError } from '@/store/state.js'
|
|
||||||
import { trackEvent } from '@/helpers/analytics'
|
|
||||||
import { process_listener } from '@/helpers/events'
|
import { process_listener } from '@/helpers/events'
|
||||||
|
import { getPlayerHeadUrl } from '@/helpers/rendering/batch-skin-renderer.ts'
|
||||||
|
import { get_available_skins } from '@/helpers/skins'
|
||||||
import { handleSevereError } from '@/store/error.js'
|
import { handleSevereError } from '@/store/error.js'
|
||||||
|
import { handleError } from '@/store/state.js'
|
||||||
|
|
||||||
defineProps({
|
defineProps({
|
||||||
mode: {
|
mode: {
|
||||||
@@ -89,32 +102,86 @@ defineProps({
|
|||||||
const emit = defineEmits(['change'])
|
const emit = defineEmits(['change'])
|
||||||
|
|
||||||
const accounts = ref({})
|
const accounts = ref({})
|
||||||
|
const loginDisabled = ref(false)
|
||||||
const defaultUser = ref()
|
const defaultUser = ref()
|
||||||
|
const equippedSkin = ref(null)
|
||||||
|
const headUrlCache = ref(new Map())
|
||||||
|
|
||||||
async function refreshValues() {
|
async function refreshValues() {
|
||||||
defaultUser.value = await get_default_user().catch(handleError)
|
defaultUser.value = await get_default_user().catch(handleError)
|
||||||
accounts.value = await users().catch(handleError)
|
accounts.value = await users().catch(handleError)
|
||||||
|
|
||||||
|
try {
|
||||||
|
const skins = await get_available_skins()
|
||||||
|
equippedSkin.value = skins.find((skin) => skin.is_equipped)
|
||||||
|
|
||||||
|
if (equippedSkin.value) {
|
||||||
|
try {
|
||||||
|
const headUrl = await getPlayerHeadUrl(equippedSkin.value)
|
||||||
|
headUrlCache.value.set(equippedSkin.value.texture_key, headUrl)
|
||||||
|
} catch (error) {
|
||||||
|
console.warn('Failed to get head render for equipped skin:', error)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch {
|
||||||
|
equippedSkin.value = null
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function setLoginDisabled(value) {
|
||||||
|
loginDisabled.value = value
|
||||||
|
}
|
||||||
|
|
||||||
defineExpose({
|
defineExpose({
|
||||||
refreshValues,
|
refreshValues,
|
||||||
|
setLoginDisabled,
|
||||||
|
loginDisabled,
|
||||||
})
|
})
|
||||||
await refreshValues()
|
await refreshValues()
|
||||||
|
|
||||||
const displayAccounts = computed(() =>
|
const displayAccounts = computed(() =>
|
||||||
accounts.value.filter((account) => defaultUser.value !== account.id),
|
accounts.value.filter((account) => defaultUser.value !== account.profile.id),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const avatarUrl = computed(() => {
|
||||||
|
if (equippedSkin.value?.texture_key) {
|
||||||
|
const cachedUrl = headUrlCache.value.get(equippedSkin.value.texture_key)
|
||||||
|
if (cachedUrl) {
|
||||||
|
return cachedUrl
|
||||||
|
}
|
||||||
|
return `https://mc-heads.net/avatar/${equippedSkin.value.texture_key}/128`
|
||||||
|
}
|
||||||
|
if (selectedAccount.value?.profile?.id) {
|
||||||
|
return `https://mc-heads.net/avatar/${selectedAccount.value.profile.id}/128`
|
||||||
|
}
|
||||||
|
return 'https://launcher-files.modrinth.com/assets/steve_head.png'
|
||||||
|
})
|
||||||
|
|
||||||
|
function getAccountAvatarUrl(account) {
|
||||||
|
if (
|
||||||
|
account.profile.id === selectedAccount.value?.profile?.id &&
|
||||||
|
equippedSkin.value?.texture_key
|
||||||
|
) {
|
||||||
|
const cachedUrl = headUrlCache.value.get(equippedSkin.value.texture_key)
|
||||||
|
if (cachedUrl) {
|
||||||
|
return cachedUrl
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return `https://mc-heads.net/avatar/${account.profile.id}/128`
|
||||||
|
}
|
||||||
|
|
||||||
const selectedAccount = computed(() =>
|
const selectedAccount = computed(() =>
|
||||||
accounts.value.find((account) => account.id === defaultUser.value),
|
accounts.value.find((account) => account.profile.id === defaultUser.value),
|
||||||
)
|
)
|
||||||
|
|
||||||
async function setAccount(account) {
|
async function setAccount(account) {
|
||||||
defaultUser.value = account.id
|
defaultUser.value = account.profile.id
|
||||||
await set_default_user(account.id).catch(handleError)
|
await set_default_user(account.profile.id).catch(handleError)
|
||||||
emit('change')
|
emit('change')
|
||||||
}
|
}
|
||||||
|
|
||||||
async function login() {
|
async function login() {
|
||||||
|
loginDisabled.value = true
|
||||||
const loggedIn = await login_flow().catch(handleSevereError)
|
const loggedIn = await login_flow().catch(handleSevereError)
|
||||||
|
|
||||||
if (loggedIn) {
|
if (loggedIn) {
|
||||||
@@ -123,6 +190,7 @@ async function login() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
trackEvent('AccountLogIn')
|
trackEvent('AccountLogIn')
|
||||||
|
loginDisabled.value = false
|
||||||
}
|
}
|
||||||
|
|
||||||
const logout = async (id) => {
|
const logout = async (id) => {
|
||||||
|
|||||||
@@ -1,10 +1,11 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { DropdownIcon, PlusIcon, FolderOpenIcon } from '@modrinth/assets'
|
import { DropdownIcon, FolderOpenIcon, PlusIcon } from '@modrinth/assets'
|
||||||
import { ButtonStyled, OverflowMenu } from '@modrinth/ui'
|
import { ButtonStyled, OverflowMenu } from '@modrinth/ui'
|
||||||
import { open } from '@tauri-apps/plugin-dialog'
|
import { open } from '@tauri-apps/plugin-dialog'
|
||||||
|
import { useRouter } from 'vue-router'
|
||||||
|
|
||||||
import { add_project_from_path } from '@/helpers/profile.js'
|
import { add_project_from_path } from '@/helpers/profile.js'
|
||||||
import { handleError } from '@/store/notifications.js'
|
import { handleError } from '@/store/notifications.js'
|
||||||
import { useRouter } from 'vue-router'
|
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
instance: {
|
instance: {
|
||||||
|
|||||||
@@ -42,11 +42,12 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import { ChevronRightIcon, ChevronLeftIcon } from '@modrinth/assets'
|
import { ChevronLeftIcon, ChevronRightIcon } from '@modrinth/assets'
|
||||||
import { Button } from '@modrinth/ui'
|
import { Button } from '@modrinth/ui'
|
||||||
import { useBreadcrumbs } from '@/store/breadcrumbs'
|
|
||||||
import { useRoute } from 'vue-router'
|
|
||||||
import { computed } from 'vue'
|
import { computed } from 'vue'
|
||||||
|
import { useRoute } from 'vue-router'
|
||||||
|
|
||||||
|
import { useBreadcrumbs } from '@/store/breadcrumbs'
|
||||||
|
|
||||||
const route = useRoute()
|
const route = useRoute()
|
||||||
|
|
||||||
|
|||||||
@@ -1,23 +1,24 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
import {
|
import {
|
||||||
CheckIcon,
|
CheckIcon,
|
||||||
|
CopyIcon,
|
||||||
DropdownIcon,
|
DropdownIcon,
|
||||||
XIcon,
|
|
||||||
HammerIcon,
|
HammerIcon,
|
||||||
LogInIcon,
|
LogInIcon,
|
||||||
UpdatedIcon,
|
UpdatedIcon,
|
||||||
CopyIcon,
|
XIcon,
|
||||||
} from '@modrinth/assets'
|
} from '@modrinth/assets'
|
||||||
import { ChatIcon } from '@/assets/icons'
|
|
||||||
import { ButtonStyled, Collapsible } from '@modrinth/ui'
|
import { ButtonStyled, Collapsible } from '@modrinth/ui'
|
||||||
import { ref, computed } from 'vue'
|
import { computed, ref } from 'vue'
|
||||||
import { login as login_flow, set_default_user } from '@/helpers/auth.js'
|
|
||||||
import { handleError } from '@/store/notifications.js'
|
import { ChatIcon } from '@/assets/icons'
|
||||||
import { handleSevereError } from '@/store/error.js'
|
|
||||||
import { cancel_directory_change } from '@/helpers/settings.ts'
|
|
||||||
import { install } from '@/helpers/profile.js'
|
|
||||||
import { trackEvent } from '@/helpers/analytics'
|
|
||||||
import ModalWrapper from '@/components/ui/modal/ModalWrapper.vue'
|
import ModalWrapper from '@/components/ui/modal/ModalWrapper.vue'
|
||||||
|
import { trackEvent } from '@/helpers/analytics'
|
||||||
|
import { login as login_flow, set_default_user } from '@/helpers/auth.js'
|
||||||
|
import { install } from '@/helpers/profile.js'
|
||||||
|
import { cancel_directory_change } from '@/helpers/settings.ts'
|
||||||
|
import { handleSevereError } from '@/store/error.js'
|
||||||
|
import { handleError } from '@/store/notifications.js'
|
||||||
|
|
||||||
const errorModal = ref()
|
const errorModal = ref()
|
||||||
const error = ref()
|
const error = ref()
|
||||||
@@ -92,7 +93,7 @@ async function loginMinecraft() {
|
|||||||
const loggedIn = await login_flow()
|
const loggedIn = await login_flow()
|
||||||
|
|
||||||
if (loggedIn) {
|
if (loggedIn) {
|
||||||
await set_default_user(loggedIn.id).catch(handleError)
|
await set_default_user(loggedIn.profile.id).catch(handleError)
|
||||||
}
|
}
|
||||||
|
|
||||||
await trackEvent('AccountLogIn', { source: 'ErrorModal' })
|
await trackEvent('AccountLogIn', { source: 'ErrorModal' })
|
||||||
@@ -219,8 +220,8 @@ async function copyToClipboard(text) {
|
|||||||
<template v-else-if="metadata.notEnoughSpace">
|
<template v-else-if="metadata.notEnoughSpace">
|
||||||
<h3>Not enough space</h3>
|
<h3>Not enough space</h3>
|
||||||
<p>
|
<p>
|
||||||
It looks like there is not enough space on the disk containing the dirctory you
|
It looks like there is not enough space on the disk containing the directory you
|
||||||
selected Please free up some space and try again or cancel the directory change.
|
selected. Please free up some space and try again or cancel the directory change.
|
||||||
</p>
|
</p>
|
||||||
</template>
|
</template>
|
||||||
<template v-else>
|
<template v-else>
|
||||||
|
|||||||
@@ -1,12 +1,13 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
import { XIcon, PlusIcon } from '@modrinth/assets'
|
import { PlusIcon, XIcon } from '@modrinth/assets'
|
||||||
import { Button, Checkbox } from '@modrinth/ui'
|
import { Button, Checkbox } from '@modrinth/ui'
|
||||||
import { PackageIcon, VersionIcon } from '@/assets/icons'
|
|
||||||
import { ref } from 'vue'
|
|
||||||
import { export_profile_mrpack, get_pack_export_candidates } from '@/helpers/profile.js'
|
|
||||||
import { open } from '@tauri-apps/plugin-dialog'
|
import { open } from '@tauri-apps/plugin-dialog'
|
||||||
import { handleError } from '@/store/notifications.js'
|
import { ref } from 'vue'
|
||||||
|
|
||||||
|
import { PackageIcon, VersionIcon } from '@/assets/icons'
|
||||||
import ModalWrapper from '@/components/ui/modal/ModalWrapper.vue'
|
import ModalWrapper from '@/components/ui/modal/ModalWrapper.vue'
|
||||||
|
import { export_profile_mrpack, get_pack_export_candidates } from '@/helpers/profile.js'
|
||||||
|
import { handleError } from '@/store/notifications.js'
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
instance: {
|
instance: {
|
||||||
|
|||||||
@@ -1,6 +1,4 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
import { computed, onMounted, onUnmounted, ref } from 'vue'
|
|
||||||
import { useRouter } from 'vue-router'
|
|
||||||
import {
|
import {
|
||||||
DownloadIcon,
|
DownloadIcon,
|
||||||
GameIcon,
|
GameIcon,
|
||||||
@@ -11,15 +9,17 @@ import {
|
|||||||
} from '@modrinth/assets'
|
} from '@modrinth/assets'
|
||||||
import { Avatar, ButtonStyled, useRelativeTime } from '@modrinth/ui'
|
import { Avatar, ButtonStyled, useRelativeTime } from '@modrinth/ui'
|
||||||
import { convertFileSrc } from '@tauri-apps/api/core'
|
import { convertFileSrc } from '@tauri-apps/api/core'
|
||||||
import { finish_install, kill, run } from '@/helpers/profile'
|
import dayjs from 'dayjs'
|
||||||
import { get_by_profile_path } from '@/helpers/process'
|
import { computed, onMounted, onUnmounted, ref } from 'vue'
|
||||||
|
import { useRouter } from 'vue-router'
|
||||||
|
|
||||||
|
import { trackEvent } from '@/helpers/analytics'
|
||||||
import { process_listener } from '@/helpers/events'
|
import { process_listener } from '@/helpers/events'
|
||||||
import { handleError } from '@/store/state.js'
|
import { get_by_profile_path } from '@/helpers/process'
|
||||||
|
import { finish_install, kill, run } from '@/helpers/profile'
|
||||||
import { showProfileInFolder } from '@/helpers/utils.js'
|
import { showProfileInFolder } from '@/helpers/utils.js'
|
||||||
import { handleSevereError } from '@/store/error.js'
|
import { handleSevereError } from '@/store/error.js'
|
||||||
import { trackEvent } from '@/helpers/analytics'
|
import { handleError } from '@/store/state.js'
|
||||||
import dayjs from 'dayjs'
|
|
||||||
import { formatCategory } from '@modrinth/utils'
|
|
||||||
|
|
||||||
const formatRelativeTime = useRelativeTime()
|
const formatRelativeTime = useRelativeTime()
|
||||||
|
|
||||||
@@ -173,7 +173,10 @@ onUnmounted(() => unlisten())
|
|||||||
<div class="flex items-center col-span-3 gap-1 text-secondary font-semibold">
|
<div class="flex items-center col-span-3 gap-1 text-secondary font-semibold">
|
||||||
<TimerIcon />
|
<TimerIcon />
|
||||||
<span class="text-sm">
|
<span class="text-sm">
|
||||||
Played {{ formatRelativeTime(dayjs(instance.last_played).toISOString()) }}
|
<template v-if="instance.last_played">
|
||||||
|
Played {{ formatRelativeTime(dayjs(instance.last_played).toISOString()) }}
|
||||||
|
</template>
|
||||||
|
<template v-else> Never played </template>
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -237,8 +240,8 @@ onUnmounted(() => unlisten())
|
|||||||
</p>
|
</p>
|
||||||
<div class="flex items-center col-span-3 gap-1 text-secondary font-semibold mt-auto">
|
<div class="flex items-center col-span-3 gap-1 text-secondary font-semibold mt-auto">
|
||||||
<GameIcon class="shrink-0" />
|
<GameIcon class="shrink-0" />
|
||||||
<span class="text-sm">
|
<span class="text-sm capitalize">
|
||||||
{{ formatCategory(instance.loader) }} {{ instance.game_version }}
|
{{ instance.loader }} {{ instance.game_version }}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -197,7 +197,6 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import ModalWrapper from '@/components/ui/modal/ModalWrapper.vue'
|
|
||||||
import {
|
import {
|
||||||
CodeIcon,
|
CodeIcon,
|
||||||
FolderOpenIcon,
|
FolderOpenIcon,
|
||||||
@@ -209,23 +208,25 @@ import {
|
|||||||
XIcon,
|
XIcon,
|
||||||
} from '@modrinth/assets'
|
} from '@modrinth/assets'
|
||||||
import { Avatar, Button, Checkbox, Chips } from '@modrinth/ui'
|
import { Avatar, Button, Checkbox, Chips } from '@modrinth/ui'
|
||||||
import { computed, onUnmounted, ref, shallowRef } from 'vue'
|
|
||||||
import { get_loaders } from '@/helpers/tags'
|
|
||||||
import { create } from '@/helpers/profile'
|
|
||||||
import { open } from '@tauri-apps/plugin-dialog'
|
|
||||||
import { convertFileSrc } from '@tauri-apps/api/core'
|
import { convertFileSrc } from '@tauri-apps/api/core'
|
||||||
import { get_game_versions, get_loader_versions } from '@/helpers/metadata'
|
import { getCurrentWebview } from '@tauri-apps/api/webview'
|
||||||
import { handleError } from '@/store/notifications.js'
|
import { open } from '@tauri-apps/plugin-dialog'
|
||||||
|
import { computed, onUnmounted, ref, shallowRef } from 'vue'
|
||||||
import Multiselect from 'vue-multiselect'
|
import Multiselect from 'vue-multiselect'
|
||||||
|
|
||||||
|
import ModalWrapper from '@/components/ui/modal/ModalWrapper.vue'
|
||||||
|
import ProgressBar from '@/components/ui/ProgressBar.vue'
|
||||||
import { trackEvent } from '@/helpers/analytics'
|
import { trackEvent } from '@/helpers/analytics'
|
||||||
import { create_profile_and_install_from_file } from '@/helpers/pack.js'
|
|
||||||
import {
|
import {
|
||||||
get_default_launcher_path,
|
get_default_launcher_path,
|
||||||
get_importable_instances,
|
get_importable_instances,
|
||||||
import_instance,
|
import_instance,
|
||||||
} from '@/helpers/import.js'
|
} from '@/helpers/import.js'
|
||||||
import ProgressBar from '@/components/ui/ProgressBar.vue'
|
import { get_game_versions, get_loader_versions } from '@/helpers/metadata'
|
||||||
import { getCurrentWebview } from '@tauri-apps/api/webview'
|
import { create_profile_and_install_from_file } from '@/helpers/pack.js'
|
||||||
|
import { create } from '@/helpers/profile'
|
||||||
|
import { get_loaders } from '@/helpers/tags'
|
||||||
|
import { handleError } from '@/store/notifications.js'
|
||||||
|
|
||||||
const profile_name = ref('')
|
const profile_name = ref('')
|
||||||
const game_version = ref('')
|
const game_version = ref('')
|
||||||
@@ -305,12 +306,16 @@ const [
|
|||||||
get_game_versions().then(shallowRef).catch(handleError),
|
get_game_versions().then(shallowRef).catch(handleError),
|
||||||
get_loaders()
|
get_loaders()
|
||||||
.then((value) =>
|
.then((value) =>
|
||||||
value
|
ref(
|
||||||
.filter((item) => item.supported_project_types.includes('modpack'))
|
value
|
||||||
.map((item) => item.name.toLowerCase()),
|
.filter((item) => item.supported_project_types.includes('modpack'))
|
||||||
|
.map((item) => item.name.toLowerCase()),
|
||||||
|
),
|
||||||
)
|
)
|
||||||
.then(ref)
|
.catch((err) => {
|
||||||
.catch(handleError),
|
handleError(err)
|
||||||
|
return ref([])
|
||||||
|
}),
|
||||||
])
|
])
|
||||||
loaders.value.unshift('vanilla')
|
loaders.value.unshift('vanilla')
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { convertFileSrc } from '@tauri-apps/api/core'
|
|
||||||
import { formatCategory } from '@modrinth/utils'
|
|
||||||
import { GameIcon, LeftArrowIcon } from '@modrinth/assets'
|
import { GameIcon, LeftArrowIcon } from '@modrinth/assets'
|
||||||
import { Avatar, ButtonStyled } from '@modrinth/ui'
|
import { Avatar, ButtonStyled } from '@modrinth/ui'
|
||||||
|
import { formatCategory } from '@modrinth/utils'
|
||||||
|
import { convertFileSrc } from '@tauri-apps/api/core'
|
||||||
|
|
||||||
type Instance = {
|
type Instance = {
|
||||||
game_version: string
|
game_version: string
|
||||||
|
|||||||
@@ -35,13 +35,14 @@
|
|||||||
</ModalWrapper>
|
</ModalWrapper>
|
||||||
</template>
|
</template>
|
||||||
<script setup>
|
<script setup>
|
||||||
import { PlusIcon, CheckIcon, XIcon } from '@modrinth/assets'
|
import { CheckIcon, PlusIcon, XIcon } from '@modrinth/assets'
|
||||||
import { Button } from '@modrinth/ui'
|
import { Button } from '@modrinth/ui'
|
||||||
import { ref } from 'vue'
|
import { ref } from 'vue'
|
||||||
|
|
||||||
|
import ModalWrapper from '@/components/ui/modal/ModalWrapper.vue'
|
||||||
|
import { trackEvent } from '@/helpers/analytics'
|
||||||
import { find_filtered_jres } from '@/helpers/jre.js'
|
import { find_filtered_jres } from '@/helpers/jre.js'
|
||||||
import { handleError } from '@/store/notifications.js'
|
import { handleError } from '@/store/notifications.js'
|
||||||
import { trackEvent } from '@/helpers/analytics'
|
|
||||||
import ModalWrapper from '@/components/ui/modal/ModalWrapper.vue'
|
|
||||||
|
|
||||||
const chosenInstallOptions = ref([])
|
const chosenInstallOptions = ref([])
|
||||||
const detectJavaModal = ref(null)
|
const detectJavaModal = ref(null)
|
||||||
|
|||||||
@@ -53,20 +53,21 @@
|
|||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import {
|
import {
|
||||||
SearchIcon,
|
|
||||||
PlayIcon,
|
|
||||||
CheckIcon,
|
CheckIcon,
|
||||||
XIcon,
|
|
||||||
FolderSearchIcon,
|
|
||||||
DownloadIcon,
|
DownloadIcon,
|
||||||
|
FolderSearchIcon,
|
||||||
|
PlayIcon,
|
||||||
|
SearchIcon,
|
||||||
|
XIcon,
|
||||||
} from '@modrinth/assets'
|
} from '@modrinth/assets'
|
||||||
import { Button } from '@modrinth/ui'
|
import { Button } from '@modrinth/ui'
|
||||||
import { auto_install_java, find_filtered_jres, get_jre, test_jre } from '@/helpers/jre.js'
|
|
||||||
import { ref } from 'vue'
|
|
||||||
import { open } from '@tauri-apps/plugin-dialog'
|
import { open } from '@tauri-apps/plugin-dialog'
|
||||||
|
import { ref } from 'vue'
|
||||||
|
|
||||||
import JavaDetectionModal from '@/components/ui/JavaDetectionModal.vue'
|
import JavaDetectionModal from '@/components/ui/JavaDetectionModal.vue'
|
||||||
import { handleError } from '@/store/state.js'
|
|
||||||
import { trackEvent } from '@/helpers/analytics'
|
import { trackEvent } from '@/helpers/analytics'
|
||||||
|
import { auto_install_java, find_filtered_jres, get_jre, test_jre } from '@/helpers/jre.js'
|
||||||
|
import { handleError } from '@/store/state.js'
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
version: {
|
version: {
|
||||||
@@ -108,7 +109,6 @@ async function testJava() {
|
|||||||
testingJava.value = true
|
testingJava.value = true
|
||||||
testingJavaSuccess.value = await test_jre(
|
testingJavaSuccess.value = await test_jre(
|
||||||
props.modelValue ? props.modelValue.path : '',
|
props.modelValue ? props.modelValue.path : '',
|
||||||
1,
|
|
||||||
props.version,
|
props.version,
|
||||||
)
|
)
|
||||||
testingJava.value = false
|
testingJava.value = false
|
||||||
|
|||||||
@@ -1,11 +1,12 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
import { CheckIcon } from '@modrinth/assets'
|
import { CheckIcon } from '@modrinth/assets'
|
||||||
import { Button, Badge } from '@modrinth/ui'
|
import { Badge, Button } from '@modrinth/ui'
|
||||||
import { computed, ref } from 'vue'
|
import { computed, ref } from 'vue'
|
||||||
import { update_managed_modrinth_version } from '@/helpers/profile'
|
|
||||||
import { releaseColor } from '@/helpers/utils'
|
|
||||||
import { SwapIcon } from '@/assets/icons/index.js'
|
import { SwapIcon } from '@/assets/icons/index.js'
|
||||||
import ModalWrapper from '@/components/ui/modal/ModalWrapper.vue'
|
import ModalWrapper from '@/components/ui/modal/ModalWrapper.vue'
|
||||||
|
import { update_managed_modrinth_version } from '@/helpers/profile'
|
||||||
|
import { releaseColor } from '@/helpers/utils'
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
versions: {
|
versions: {
|
||||||
|
|||||||
@@ -30,7 +30,7 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { computed, onMounted, onUnmounted, ref, watch } from 'vue'
|
import { computed, onMounted, onUnmounted, ref, watch } from 'vue'
|
||||||
import type { RouteLocationRaw } from 'vue-router'
|
import type { RouteLocationRaw } from 'vue-router'
|
||||||
import { useRoute, RouterLink } from 'vue-router'
|
import { RouterLink, useRoute } from 'vue-router'
|
||||||
|
|
||||||
const route = useRoute()
|
const route = useRoute()
|
||||||
|
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
import { Avatar, TagItem } from '@modrinth/ui'
|
|
||||||
import { DownloadIcon, HeartIcon, TagIcon } from '@modrinth/assets'
|
import { DownloadIcon, HeartIcon, TagIcon } from '@modrinth/assets'
|
||||||
import { formatNumber, formatCategory } from '@modrinth/utils'
|
import { Avatar, TagItem } from '@modrinth/ui'
|
||||||
import { computed } from 'vue'
|
import { formatCategory, formatNumber } from '@modrinth/utils'
|
||||||
import dayjs from 'dayjs'
|
import dayjs from 'dayjs'
|
||||||
import relativeTime from 'dayjs/plugin/relativeTime'
|
import relativeTime from 'dayjs/plugin/relativeTime'
|
||||||
|
import { computed } from 'vue'
|
||||||
import { useRouter } from 'vue-router'
|
import { useRouter } from 'vue-router'
|
||||||
|
|
||||||
dayjs.extend(relativeTime)
|
dayjs.extend(relativeTime)
|
||||||
@@ -21,14 +21,11 @@ const props = defineProps({
|
|||||||
})
|
})
|
||||||
|
|
||||||
const featuredCategory = computed(() => {
|
const featuredCategory = computed(() => {
|
||||||
if (props.project.categories.includes('optimization')) {
|
if (props.project.display_categories.includes('optimization')) {
|
||||||
return 'optimization'
|
return 'optimization'
|
||||||
}
|
}
|
||||||
|
|
||||||
if (props.project.categories.length > 0) {
|
return props.project.display_categories[0] ?? props.project.categories[0]
|
||||||
return props.project.categories[0]
|
|
||||||
}
|
|
||||||
return undefined
|
|
||||||
})
|
})
|
||||||
|
|
||||||
const toColor = computed(() => {
|
const toColor = computed(() => {
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
import { ref, onMounted } from 'vue'
|
import { onMounted, ref } from 'vue'
|
||||||
|
|
||||||
import { init_ads_window } from '@/helpers/ads.js'
|
import { init_ads_window } from '@/helpers/ads.js'
|
||||||
|
|
||||||
const adsWrapper = ref(null)
|
const adsWrapper = ref(null)
|
||||||
@@ -32,8 +33,33 @@ function updateAdPosition() {
|
|||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div ref="adsWrapper" class="ad-parent relative flex w-full justify-center cursor-pointer bg-bg">
|
<div ref="adsWrapper" class="ad-parent relative flex w-full justify-center cursor-pointer bg-bg">
|
||||||
<div class="flex max-h-[250px] min-h-[250px] min-w-[300px] max-w-[300px] flex-col gap-4 p-6">
|
<a
|
||||||
<p class="m-0 text-2xl font-bold text-contrast">75% of ad revenue goes to creators</p>
|
href="https://modrinth.gg?from=app-placeholder"
|
||||||
</div>
|
target="_blank"
|
||||||
|
class="flex max-h-[250px] min-h-[250px] min-w-[300px] max-w-[300px] flex-col gap-4 rounded-[inherit]"
|
||||||
|
>
|
||||||
|
<img
|
||||||
|
src="https://cdn-raw.modrinth.com/modrinth-servers-placeholder-light.webp"
|
||||||
|
alt="Host your next server with Modrinth Servers"
|
||||||
|
class="hidden light-image rounded-[inherit]"
|
||||||
|
/>
|
||||||
|
<img
|
||||||
|
src="https://cdn-raw.modrinth.com/modrinth-servers-placeholder-dark.webp"
|
||||||
|
alt="Host your next server with Modrinth Servers"
|
||||||
|
class="dark-image rounded-[inherit]"
|
||||||
|
/>
|
||||||
|
</a>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
<style lang="scss" scoped>
|
||||||
|
.light,
|
||||||
|
.light-mode {
|
||||||
|
.dark-image {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.light-image {
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|||||||
@@ -1,13 +1,14 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
import { list } from '@/helpers/profile'
|
import { SpinnerIcon } from '@modrinth/assets'
|
||||||
import { handleError } from '@/store/notifications'
|
|
||||||
import dayjs from 'dayjs'
|
|
||||||
import { onUnmounted, ref } from 'vue'
|
|
||||||
import { profile_listener } from '@/helpers/events.js'
|
|
||||||
import NavButton from '@/components/ui/NavButton.vue'
|
|
||||||
import { Avatar } from '@modrinth/ui'
|
import { Avatar } from '@modrinth/ui'
|
||||||
import { convertFileSrc } from '@tauri-apps/api/core'
|
import { convertFileSrc } from '@tauri-apps/api/core'
|
||||||
import { SpinnerIcon } from '@modrinth/assets'
|
import dayjs from 'dayjs'
|
||||||
|
import { onUnmounted, ref } from 'vue'
|
||||||
|
|
||||||
|
import NavButton from '@/components/ui/NavButton.vue'
|
||||||
|
import { profile_listener } from '@/helpers/events.js'
|
||||||
|
import { list } from '@/helpers/profile'
|
||||||
|
import { handleError } from '@/store/notifications'
|
||||||
|
|
||||||
const recentInstances = ref([])
|
const recentInstances = ref([])
|
||||||
const getInstances = async () => {
|
const getInstances = async () => {
|
||||||
@@ -30,7 +31,7 @@ const getInstances = async () => {
|
|||||||
|
|
||||||
return dateB - dateA
|
return dateB - dateA
|
||||||
})
|
})
|
||||||
.slice(0, 4)
|
.slice(0, 3)
|
||||||
}
|
}
|
||||||
|
|
||||||
await getInstances()
|
await getInstances()
|
||||||
|
|||||||
@@ -96,21 +96,22 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
import {
|
import {
|
||||||
DownloadIcon,
|
DownloadIcon,
|
||||||
|
DropdownIcon,
|
||||||
StopCircleIcon,
|
StopCircleIcon,
|
||||||
TerminalSquareIcon,
|
TerminalSquareIcon,
|
||||||
DropdownIcon,
|
|
||||||
UnplugIcon,
|
UnplugIcon,
|
||||||
} from '@modrinth/assets'
|
} from '@modrinth/assets'
|
||||||
import { Button, ButtonStyled, Card } from '@modrinth/ui'
|
import { Button, ButtonStyled, Card } from '@modrinth/ui'
|
||||||
import { onBeforeUnmount, onMounted, ref } from 'vue'
|
import { onBeforeUnmount, onMounted, ref } from 'vue'
|
||||||
import { get_all as getRunningProcesses, kill as killProcess } from '@/helpers/process'
|
|
||||||
import { loading_listener, process_listener } from '@/helpers/events'
|
|
||||||
import { useRouter } from 'vue-router'
|
import { useRouter } from 'vue-router'
|
||||||
import { progress_bars_list } from '@/helpers/state.js'
|
|
||||||
import ProgressBar from '@/components/ui/ProgressBar.vue'
|
import ProgressBar from '@/components/ui/ProgressBar.vue'
|
||||||
import { handleError } from '@/store/notifications.js'
|
|
||||||
import { get_many } from '@/helpers/profile.js'
|
|
||||||
import { trackEvent } from '@/helpers/analytics'
|
import { trackEvent } from '@/helpers/analytics'
|
||||||
|
import { loading_listener, process_listener } from '@/helpers/events'
|
||||||
|
import { get_all as getRunningProcesses, kill as killProcess } from '@/helpers/process'
|
||||||
|
import { get_many } from '@/helpers/profile.js'
|
||||||
|
import { progress_bars_list } from '@/helpers/state.js'
|
||||||
|
import { handleError } from '@/store/notifications.js'
|
||||||
|
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
const card = ref(null)
|
const card = ref(null)
|
||||||
|
|||||||
@@ -117,14 +117,15 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import { TagsIcon, DownloadIcon, HeartIcon, PlusIcon, CheckIcon } from '@modrinth/assets'
|
import { CheckIcon, DownloadIcon, HeartIcon, PlusIcon, TagsIcon } from '@modrinth/assets'
|
||||||
import { ButtonStyled, Avatar } from '@modrinth/ui'
|
import { Avatar, ButtonStyled } from '@modrinth/ui'
|
||||||
import { formatNumber, formatCategory } from '@modrinth/utils'
|
import { formatCategory, formatNumber } from '@modrinth/utils'
|
||||||
import dayjs from 'dayjs'
|
import dayjs from 'dayjs'
|
||||||
import relativeTime from 'dayjs/plugin/relativeTime'
|
import relativeTime from 'dayjs/plugin/relativeTime'
|
||||||
import { ref, computed } from 'vue'
|
import { computed, ref } from 'vue'
|
||||||
import { install as installVersion } from '@/store/install.js'
|
|
||||||
import { useRouter } from 'vue-router'
|
import { useRouter } from 'vue-router'
|
||||||
|
|
||||||
|
import { install as installVersion } from '@/store/install.js'
|
||||||
dayjs.extend(relativeTime)
|
dayjs.extend(relativeTime)
|
||||||
|
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
|
|||||||
@@ -82,11 +82,12 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
|
import { MaximizeIcon, MinimizeIcon, XIcon } from '@modrinth/assets'
|
||||||
|
import { getCurrentWindow } from '@tauri-apps/api/window'
|
||||||
import { ref, watch } from 'vue'
|
import { ref, watch } from 'vue'
|
||||||
|
|
||||||
import ProgressBar from '@/components/ui/ProgressBar.vue'
|
import ProgressBar from '@/components/ui/ProgressBar.vue'
|
||||||
import { loading_listener } from '@/helpers/events.js'
|
import { loading_listener } from '@/helpers/events.js'
|
||||||
import { getCurrentWindow } from '@tauri-apps/api/window'
|
|
||||||
import { XIcon, MaximizeIcon, MinimizeIcon } from '@modrinth/assets'
|
|
||||||
import { getOS } from '@/helpers/utils.js'
|
import { getOS } from '@/helpers/utils.js'
|
||||||
import { useLoading } from '@/store/loading.js'
|
import { useLoading } from '@/store/loading.js'
|
||||||
|
|
||||||
|
|||||||
@@ -1,12 +1,13 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
import { Button } from '@modrinth/ui'
|
import { Button } from '@modrinth/ui'
|
||||||
import { ref } from 'vue'
|
import { ref } from 'vue'
|
||||||
import SearchCard from '@/components/ui/SearchCard.vue'
|
|
||||||
import { get_categories } from '@/helpers/tags.js'
|
|
||||||
import { handleError } from '@/store/notifications.js'
|
|
||||||
import { get_version, get_project } from '@/helpers/cache.js'
|
|
||||||
import { install as installVersion } from '@/store/install.js'
|
|
||||||
import ModalWrapper from '@/components/ui/modal/ModalWrapper.vue'
|
import ModalWrapper from '@/components/ui/modal/ModalWrapper.vue'
|
||||||
|
import SearchCard from '@/components/ui/SearchCard.vue'
|
||||||
|
import { get_project, get_version } from '@/helpers/cache.js'
|
||||||
|
import { get_categories } from '@/helpers/tags.js'
|
||||||
|
import { install as installVersion } from '@/store/install.js'
|
||||||
|
import { handleError } from '@/store/notifications.js'
|
||||||
|
|
||||||
const confirmModal = ref(null)
|
const confirmModal = ref(null)
|
||||||
const project = ref(null)
|
const project = ref(null)
|
||||||
|
|||||||
@@ -1,22 +1,23 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { Avatar, ButtonStyled, OverflowMenu, useRelativeTime } from '@modrinth/ui'
|
|
||||||
import {
|
import {
|
||||||
UserPlusIcon,
|
|
||||||
MoreVerticalIcon,
|
|
||||||
MailIcon,
|
MailIcon,
|
||||||
|
MoreVerticalIcon,
|
||||||
SettingsIcon,
|
SettingsIcon,
|
||||||
TrashIcon,
|
TrashIcon,
|
||||||
|
UserPlusIcon,
|
||||||
XIcon,
|
XIcon,
|
||||||
} from '@modrinth/assets'
|
} from '@modrinth/assets'
|
||||||
import { ref, onUnmounted, watch, computed } from 'vue'
|
import { Avatar, ButtonStyled, OverflowMenu, useRelativeTime } from '@modrinth/ui'
|
||||||
import { friend_listener } from '@/helpers/events'
|
|
||||||
import { friends, friend_statuses, add_friend, remove_friend } from '@/helpers/friends'
|
|
||||||
import { get_user_many } from '@/helpers/cache'
|
|
||||||
import { handleError } from '@/store/notifications.js'
|
|
||||||
import ContextMenu from '@/components/ui/ContextMenu.vue'
|
|
||||||
import type { Dayjs } from 'dayjs'
|
import type { Dayjs } from 'dayjs'
|
||||||
import dayjs from 'dayjs'
|
import dayjs from 'dayjs'
|
||||||
|
import { computed, onUnmounted, ref, watch } from 'vue'
|
||||||
|
|
||||||
|
import ContextMenu from '@/components/ui/ContextMenu.vue'
|
||||||
import ModalWrapper from '@/components/ui/modal/ModalWrapper.vue'
|
import ModalWrapper from '@/components/ui/modal/ModalWrapper.vue'
|
||||||
|
import { get_user_many } from '@/helpers/cache'
|
||||||
|
import { friend_listener } from '@/helpers/events'
|
||||||
|
import { add_friend, friend_statuses, friends, remove_friend } from '@/helpers/friends'
|
||||||
|
import { handleError } from '@/store/notifications.js'
|
||||||
|
|
||||||
const formatRelativeTime = useRelativeTime()
|
const formatRelativeTime = useRelativeTime()
|
||||||
|
|
||||||
|
|||||||
@@ -56,16 +56,17 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import ModalWrapper from '@/components/ui/modal/ModalWrapper.vue'
|
import { DownloadIcon, XIcon } from '@modrinth/assets'
|
||||||
import { XIcon, DownloadIcon } from '@modrinth/assets'
|
|
||||||
import { Button } from '@modrinth/ui'
|
import { Button } from '@modrinth/ui'
|
||||||
import { formatCategory } from '@modrinth/utils'
|
import { formatCategory } from '@modrinth/utils'
|
||||||
import { add_project_from_version as installMod } from '@/helpers/profile'
|
|
||||||
import { ref } from 'vue'
|
import { ref } from 'vue'
|
||||||
import { handleError } from '@/store/state.js'
|
|
||||||
import { trackEvent } from '@/helpers/analytics'
|
|
||||||
import Multiselect from 'vue-multiselect'
|
import Multiselect from 'vue-multiselect'
|
||||||
|
|
||||||
|
import ModalWrapper from '@/components/ui/modal/ModalWrapper.vue'
|
||||||
|
import { trackEvent } from '@/helpers/analytics'
|
||||||
|
import { add_project_from_version as installMod } from '@/helpers/profile'
|
||||||
|
import { handleError } from '@/store/state.js'
|
||||||
|
|
||||||
const instance = ref(null)
|
const instance = ref(null)
|
||||||
const project = ref(null)
|
const project = ref(null)
|
||||||
const versions = ref(null)
|
const versions = ref(null)
|
||||||
@@ -76,10 +77,10 @@ const installing = ref(false)
|
|||||||
const onInstall = ref(() => {})
|
const onInstall = ref(() => {})
|
||||||
|
|
||||||
defineExpose({
|
defineExpose({
|
||||||
show: (instanceVal, projectVal, projectVersions, callback) => {
|
show: (instanceVal, projectVal, projectVersions, selected, callback) => {
|
||||||
instance.value = instanceVal
|
instance.value = instanceVal
|
||||||
versions.value = projectVersions
|
versions.value = projectVersions
|
||||||
selectedVersion.value = projectVersions[0]
|
selectedVersion.value = selected ?? projectVersions[0]
|
||||||
|
|
||||||
project.value = projectVal
|
project.value = projectVal
|
||||||
|
|
||||||
|
|||||||
@@ -1,11 +1,12 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
import { DownloadIcon, XIcon } from '@modrinth/assets'
|
import { DownloadIcon, XIcon } from '@modrinth/assets'
|
||||||
import { Button } from '@modrinth/ui'
|
import { Button } from '@modrinth/ui'
|
||||||
import { create_profile_and_install as pack_install } from '@/helpers/pack'
|
|
||||||
import { ref } from 'vue'
|
import { ref } from 'vue'
|
||||||
import { trackEvent } from '@/helpers/analytics'
|
|
||||||
import { handleError } from '@/store/state.js'
|
|
||||||
import ModalWrapper from '@/components/ui/modal/ModalWrapper.vue'
|
import ModalWrapper from '@/components/ui/modal/ModalWrapper.vue'
|
||||||
|
import { trackEvent } from '@/helpers/analytics'
|
||||||
|
import { create_profile_and_install as pack_install } from '@/helpers/pack'
|
||||||
|
import { handleError } from '@/store/state.js'
|
||||||
|
|
||||||
const versionId = ref()
|
const versionId = ref()
|
||||||
const project = ref()
|
const project = ref()
|
||||||
|
|||||||
@@ -1,28 +1,29 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
import {
|
import {
|
||||||
|
CheckIcon,
|
||||||
DownloadIcon,
|
DownloadIcon,
|
||||||
PlusIcon,
|
PlusIcon,
|
||||||
|
RightArrowIcon,
|
||||||
UploadIcon,
|
UploadIcon,
|
||||||
XIcon,
|
XIcon,
|
||||||
RightArrowIcon,
|
|
||||||
CheckIcon,
|
|
||||||
} from '@modrinth/assets'
|
} from '@modrinth/assets'
|
||||||
import { Avatar, Button, Card } from '@modrinth/ui'
|
import { Avatar, Button, Card } from '@modrinth/ui'
|
||||||
|
import { convertFileSrc } from '@tauri-apps/api/core'
|
||||||
|
import { open } from '@tauri-apps/plugin-dialog'
|
||||||
import { computed, ref } from 'vue'
|
import { computed, ref } from 'vue'
|
||||||
|
import { useRouter } from 'vue-router'
|
||||||
|
|
||||||
|
import ModalWrapper from '@/components/ui/modal/ModalWrapper.vue'
|
||||||
|
import { trackEvent } from '@/helpers/analytics'
|
||||||
import {
|
import {
|
||||||
add_project_from_version as installMod,
|
add_project_from_version as installMod,
|
||||||
check_installed,
|
check_installed,
|
||||||
|
create,
|
||||||
get,
|
get,
|
||||||
list,
|
list,
|
||||||
create,
|
|
||||||
} from '@/helpers/profile'
|
} from '@/helpers/profile'
|
||||||
import { open } from '@tauri-apps/plugin-dialog'
|
|
||||||
import { installVersionDependencies } from '@/store/install.js'
|
import { installVersionDependencies } from '@/store/install.js'
|
||||||
import { handleError } from '@/store/notifications.js'
|
import { handleError } from '@/store/notifications.js'
|
||||||
import { useRouter } from 'vue-router'
|
|
||||||
import { convertFileSrc } from '@tauri-apps/api/core'
|
|
||||||
import { trackEvent } from '@/helpers/analytics'
|
|
||||||
import ModalWrapper from '@/components/ui/modal/ModalWrapper.vue'
|
|
||||||
|
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
|
|
||||||
|
|||||||
@@ -1,16 +1,18 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
|
import { CopyIcon, EditIcon, PlusIcon, SpinnerIcon, TrashIcon, UploadIcon } from '@modrinth/assets'
|
||||||
|
import { Avatar, ButtonStyled, Checkbox, OverflowMenu } from '@modrinth/ui'
|
||||||
import { convertFileSrc } from '@tauri-apps/api/core'
|
import { convertFileSrc } from '@tauri-apps/api/core'
|
||||||
import { SpinnerIcon, TrashIcon, UploadIcon, PlusIcon, EditIcon, CopyIcon } from '@modrinth/assets'
|
|
||||||
import { Avatar, ButtonStyled, OverflowMenu, Checkbox } from '@modrinth/ui'
|
|
||||||
import { computed, ref, type Ref, watch } from 'vue'
|
|
||||||
import { duplicate, edit, edit_icon, list, remove } from '@/helpers/profile'
|
|
||||||
import { handleError } from '@/store/notifications'
|
|
||||||
import { trackEvent } from '@/helpers/analytics'
|
|
||||||
import { open } from '@tauri-apps/plugin-dialog'
|
import { open } from '@tauri-apps/plugin-dialog'
|
||||||
import { defineMessages, useVIntl } from '@vintl/vintl'
|
import { defineMessages, useVIntl } from '@vintl/vintl'
|
||||||
|
import { computed, type Ref, ref, watch } from 'vue'
|
||||||
import { useRouter } from 'vue-router'
|
import { useRouter } from 'vue-router'
|
||||||
|
|
||||||
import ConfirmModalWrapper from '@/components/ui/modal/ConfirmModalWrapper.vue'
|
import ConfirmModalWrapper from '@/components/ui/modal/ConfirmModalWrapper.vue'
|
||||||
import type { InstanceSettingsTabProps, GameInstance } from '../../../helpers/types'
|
import { trackEvent } from '@/helpers/analytics'
|
||||||
|
import { duplicate, edit, edit_icon, list, remove } from '@/helpers/profile'
|
||||||
|
import { handleError } from '@/store/notifications'
|
||||||
|
|
||||||
|
import type { GameInstance, InstanceSettingsTabProps } from '../../../helpers/types'
|
||||||
|
|
||||||
const { formatMessage } = useVIntl()
|
const { formatMessage } = useVIntl()
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
|
|||||||
@@ -1,11 +1,13 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { Checkbox } from '@modrinth/ui'
|
import { Checkbox } from '@modrinth/ui'
|
||||||
import { computed, ref, watch } from 'vue'
|
|
||||||
import { handleError } from '@/store/notifications'
|
|
||||||
import { defineMessages, useVIntl } from '@vintl/vintl'
|
import { defineMessages, useVIntl } from '@vintl/vintl'
|
||||||
import { get } from '@/helpers/settings.ts'
|
import { computed, ref, watch } from 'vue'
|
||||||
|
|
||||||
import { edit } from '@/helpers/profile'
|
import { edit } from '@/helpers/profile'
|
||||||
import type { InstanceSettingsTabProps, AppSettings, Hooks } from '../../../helpers/types'
|
import { get } from '@/helpers/settings.ts'
|
||||||
|
import { handleError } from '@/store/notifications'
|
||||||
|
|
||||||
|
import type { AppSettings, Hooks, InstanceSettingsTabProps } from '../../../helpers/types'
|
||||||
|
|
||||||
const { formatMessage } = useVIntl()
|
const { formatMessage } = useVIntl()
|
||||||
|
|
||||||
|
|||||||
@@ -1,23 +1,16 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import {
|
import {
|
||||||
TransferIcon,
|
|
||||||
IssuesIcon,
|
|
||||||
HammerIcon,
|
|
||||||
DownloadIcon,
|
DownloadIcon,
|
||||||
WrenchIcon,
|
HammerIcon,
|
||||||
UndoIcon,
|
IssuesIcon,
|
||||||
SpinnerIcon,
|
SpinnerIcon,
|
||||||
UnplugIcon,
|
TransferIcon,
|
||||||
|
UndoIcon,
|
||||||
UnlinkIcon,
|
UnlinkIcon,
|
||||||
|
UnplugIcon,
|
||||||
|
WrenchIcon,
|
||||||
} from '@modrinth/assets'
|
} from '@modrinth/assets'
|
||||||
import { Avatar, Checkbox, Chips, ButtonStyled, TeleportDropdownMenu } from '@modrinth/ui'
|
import { Avatar, ButtonStyled, Checkbox, Chips, TeleportDropdownMenu } from '@modrinth/ui'
|
||||||
import { computed, type ComputedRef, type Ref, ref, shallowRef, watch } from 'vue'
|
|
||||||
import { edit, install, update_repair_modrinth } from '@/helpers/profile'
|
|
||||||
import { handleError } from '@/store/notifications'
|
|
||||||
import { trackEvent } from '@/helpers/analytics'
|
|
||||||
import { defineMessages, useVIntl } from '@vintl/vintl'
|
|
||||||
import { get_loader_versions } from '@/helpers/metadata'
|
|
||||||
import { get_game_versions, get_loaders } from '@/helpers/tags'
|
|
||||||
import {
|
import {
|
||||||
formatCategory,
|
formatCategory,
|
||||||
type GameVersionTag,
|
type GameVersionTag,
|
||||||
@@ -25,14 +18,23 @@ import {
|
|||||||
type Project,
|
type Project,
|
||||||
type Version,
|
type Version,
|
||||||
} from '@modrinth/utils'
|
} from '@modrinth/utils'
|
||||||
import ConfirmModalWrapper from '@/components/ui/modal/ConfirmModalWrapper.vue'
|
import { defineMessages, useVIntl } from '@vintl/vintl'
|
||||||
import { get_project, get_version_many } from '@/helpers/cache'
|
|
||||||
import ModpackVersionModal from '@/components/ui/ModpackVersionModal.vue'
|
|
||||||
import dayjs from 'dayjs'
|
import dayjs from 'dayjs'
|
||||||
|
import { computed, type ComputedRef, type Ref, ref, shallowRef, watch } from 'vue'
|
||||||
|
|
||||||
|
import ConfirmModalWrapper from '@/components/ui/modal/ConfirmModalWrapper.vue'
|
||||||
|
import ModpackVersionModal from '@/components/ui/ModpackVersionModal.vue'
|
||||||
|
import { trackEvent } from '@/helpers/analytics'
|
||||||
|
import { get_project, get_version_many } from '@/helpers/cache'
|
||||||
|
import { get_loader_versions } from '@/helpers/metadata'
|
||||||
|
import { edit, install, update_repair_modrinth } from '@/helpers/profile'
|
||||||
|
import { get_game_versions, get_loaders } from '@/helpers/tags'
|
||||||
|
import { handleError } from '@/store/notifications'
|
||||||
|
|
||||||
import type {
|
import type {
|
||||||
InstanceSettingsTabProps,
|
InstanceSettingsTabProps,
|
||||||
ManifestLoaderVersion,
|
|
||||||
Manifest,
|
Manifest,
|
||||||
|
ManifestLoaderVersion,
|
||||||
} from '../../../helpers/types'
|
} from '../../../helpers/types'
|
||||||
|
|
||||||
const { formatMessage } = useVIntl()
|
const { formatMessage } = useVIntl()
|
||||||
|
|||||||
@@ -1,14 +1,16 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { Checkbox, Slider } from '@modrinth/ui'
|
|
||||||
import { CheckCircleIcon, XCircleIcon } from '@modrinth/assets'
|
import { CheckCircleIcon, XCircleIcon } from '@modrinth/assets'
|
||||||
import { computed, readonly, ref, watch } from 'vue'
|
import { Checkbox, Slider } from '@modrinth/ui'
|
||||||
import { edit, get_optimal_jre_key } from '@/helpers/profile'
|
|
||||||
import { handleError } from '@/store/notifications'
|
|
||||||
import { defineMessages, useVIntl } from '@vintl/vintl'
|
import { defineMessages, useVIntl } from '@vintl/vintl'
|
||||||
|
import { computed, readonly, ref, watch } from 'vue'
|
||||||
|
|
||||||
import JavaSelector from '@/components/ui/JavaSelector.vue'
|
import JavaSelector from '@/components/ui/JavaSelector.vue'
|
||||||
import { get_max_memory } from '@/helpers/jre'
|
import useMemorySlider from '@/composables/useMemorySlider'
|
||||||
|
import { edit, get_optimal_jre_key } from '@/helpers/profile'
|
||||||
import { get } from '@/helpers/settings.ts'
|
import { get } from '@/helpers/settings.ts'
|
||||||
import type { InstanceSettingsTabProps, AppSettings, MemorySettings } from '../../../helpers/types'
|
import { handleError } from '@/store/notifications'
|
||||||
|
|
||||||
|
import type { AppSettings, InstanceSettingsTabProps, MemorySettings } from '../../../helpers/types'
|
||||||
|
|
||||||
const { formatMessage } = useVIntl()
|
const { formatMessage } = useVIntl()
|
||||||
|
|
||||||
@@ -34,7 +36,7 @@ const envVars = ref(
|
|||||||
|
|
||||||
const overrideMemorySettings = ref(!!props.instance.memory)
|
const overrideMemorySettings = ref(!!props.instance.memory)
|
||||||
const memory = ref(props.instance.memory ?? globalSettings.memory)
|
const memory = ref(props.instance.memory ?? globalSettings.memory)
|
||||||
const maxMemory = Math.floor((await get_max_memory().catch(handleError)) / 1024)
|
const { maxMemory, snapPoints } = await useMemorySlider()
|
||||||
|
|
||||||
const editProfileObject = computed(() => {
|
const editProfileObject = computed(() => {
|
||||||
const editProfile: {
|
const editProfile: {
|
||||||
@@ -156,6 +158,8 @@ const messages = defineMessages({
|
|||||||
:min="512"
|
:min="512"
|
||||||
:max="maxMemory"
|
:max="maxMemory"
|
||||||
:step="64"
|
:step="64"
|
||||||
|
:snap-points="snapPoints"
|
||||||
|
:snap-range="512"
|
||||||
unit="MB"
|
unit="MB"
|
||||||
/>
|
/>
|
||||||
<h2 id="project-name" class="mt-4 mb-1 text-lg font-extrabold text-contrast block">
|
<h2 id="project-name" class="mt-4 mb-1 text-lg font-extrabold text-contrast block">
|
||||||
|
|||||||
@@ -1,10 +1,12 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { Checkbox, Toggle } from '@modrinth/ui'
|
import { Checkbox, Toggle } from '@modrinth/ui'
|
||||||
import { computed, ref, type Ref, watch } from 'vue'
|
|
||||||
import { handleError } from '@/store/notifications'
|
|
||||||
import { defineMessages, useVIntl } from '@vintl/vintl'
|
import { defineMessages, useVIntl } from '@vintl/vintl'
|
||||||
import { get } from '@/helpers/settings.ts'
|
import { computed, type Ref, ref, watch } from 'vue'
|
||||||
|
|
||||||
import { edit } from '@/helpers/profile'
|
import { edit } from '@/helpers/profile'
|
||||||
|
import { get } from '@/helpers/settings.ts'
|
||||||
|
import { handleError } from '@/store/notifications'
|
||||||
|
|
||||||
import type { AppSettings, InstanceSettingsTabProps } from '../../../helpers/types'
|
import type { AppSettings, InstanceSettingsTabProps } from '../../../helpers/types'
|
||||||
|
|
||||||
const { formatMessage } = useVIntl()
|
const { formatMessage } = useVIntl()
|
||||||
|
|||||||
@@ -1,28 +1,29 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import {
|
import {
|
||||||
ReportIcon,
|
|
||||||
ModrinthIcon,
|
|
||||||
ShieldIcon,
|
|
||||||
SettingsIcon,
|
|
||||||
GaugeIcon,
|
|
||||||
PaintBrushIcon,
|
|
||||||
GameIcon,
|
|
||||||
CoffeeIcon,
|
CoffeeIcon,
|
||||||
|
GameIcon,
|
||||||
|
GaugeIcon,
|
||||||
|
ModrinthIcon,
|
||||||
|
PaintbrushIcon,
|
||||||
|
ReportIcon,
|
||||||
|
SettingsIcon,
|
||||||
|
ShieldIcon,
|
||||||
} from '@modrinth/assets'
|
} from '@modrinth/assets'
|
||||||
import { TabbedModal } from '@modrinth/ui'
|
import { TabbedModal } from '@modrinth/ui'
|
||||||
import { computed, ref, watch } from 'vue'
|
|
||||||
import { useVIntl, defineMessage } from '@vintl/vintl'
|
|
||||||
import AppearanceSettings from '@/components/ui/settings/AppearanceSettings.vue'
|
|
||||||
import JavaSettings from '@/components/ui/settings/JavaSettings.vue'
|
|
||||||
import ResourceManagementSettings from '@/components/ui/settings/ResourceManagementSettings.vue'
|
|
||||||
import PrivacySettings from '@/components/ui/settings/PrivacySettings.vue'
|
|
||||||
import DefaultInstanceSettings from '@/components/ui/settings/DefaultInstanceSettings.vue'
|
|
||||||
import { getVersion } from '@tauri-apps/api/app'
|
import { getVersion } from '@tauri-apps/api/app'
|
||||||
import { version as getOsVersion, platform as getOsPlatform } from '@tauri-apps/plugin-os'
|
import { platform as getOsPlatform, version as getOsVersion } from '@tauri-apps/plugin-os'
|
||||||
import { useTheming } from '@/store/state'
|
import { defineMessage, useVIntl } from '@vintl/vintl'
|
||||||
import FeatureFlagSettings from '@/components/ui/settings/FeatureFlagSettings.vue'
|
import { computed, ref, watch } from 'vue'
|
||||||
|
|
||||||
import ModalWrapper from '@/components/ui/modal/ModalWrapper.vue'
|
import ModalWrapper from '@/components/ui/modal/ModalWrapper.vue'
|
||||||
|
import AppearanceSettings from '@/components/ui/settings/AppearanceSettings.vue'
|
||||||
|
import DefaultInstanceSettings from '@/components/ui/settings/DefaultInstanceSettings.vue'
|
||||||
|
import FeatureFlagSettings from '@/components/ui/settings/FeatureFlagSettings.vue'
|
||||||
|
import JavaSettings from '@/components/ui/settings/JavaSettings.vue'
|
||||||
|
import PrivacySettings from '@/components/ui/settings/PrivacySettings.vue'
|
||||||
|
import ResourceManagementSettings from '@/components/ui/settings/ResourceManagementSettings.vue'
|
||||||
import { get, set } from '@/helpers/settings.ts'
|
import { get, set } from '@/helpers/settings.ts'
|
||||||
|
import { useTheming } from '@/store/state'
|
||||||
|
|
||||||
const themeStore = useTheming()
|
const themeStore = useTheming()
|
||||||
|
|
||||||
@@ -41,7 +42,7 @@ const tabs = [
|
|||||||
id: 'app.settings.tabs.appearance',
|
id: 'app.settings.tabs.appearance',
|
||||||
defaultMessage: 'Appearance',
|
defaultMessage: 'Appearance',
|
||||||
}),
|
}),
|
||||||
icon: PaintBrushIcon,
|
icon: PaintbrushIcon,
|
||||||
content: AppearanceSettings,
|
content: AppearanceSettings,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -0,0 +1,43 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import { LogInIcon, SpinnerIcon } from '@modrinth/assets'
|
||||||
|
import { ref } from 'vue'
|
||||||
|
|
||||||
|
import ModalWrapper from '@/components/ui/modal/ModalWrapper.vue'
|
||||||
|
|
||||||
|
defineProps({
|
||||||
|
onFlowCancel: {
|
||||||
|
type: Function,
|
||||||
|
default() {
|
||||||
|
return async () => {}
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
const modal = ref()
|
||||||
|
|
||||||
|
function show() {
|
||||||
|
modal.value.show()
|
||||||
|
}
|
||||||
|
|
||||||
|
function hide() {
|
||||||
|
modal.value.hide()
|
||||||
|
}
|
||||||
|
|
||||||
|
defineExpose({ show, hide })
|
||||||
|
</script>
|
||||||
|
<template>
|
||||||
|
<ModalWrapper ref="modal" @hide="onFlowCancel">
|
||||||
|
<template #title>
|
||||||
|
<span class="items-center gap-2 text-lg font-extrabold text-contrast">
|
||||||
|
<LogInIcon /> Sign in
|
||||||
|
</span>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<div class="flex justify-center gap-2">
|
||||||
|
<SpinnerIcon class="w-12 h-12 animate-spin" />
|
||||||
|
</div>
|
||||||
|
<p class="text-sm text-secondary">
|
||||||
|
Please sign in at the browser window that just opened to continue.
|
||||||
|
</p>
|
||||||
|
</ModalWrapper>
|
||||||
|
</template>
|
||||||
@@ -1,7 +1,8 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref } from 'vue'
|
|
||||||
import { ConfirmModal } from '@modrinth/ui'
|
import { ConfirmModal } from '@modrinth/ui'
|
||||||
import { show_ads_window, hide_ads_window } from '@/helpers/ads.js'
|
import { ref } from 'vue'
|
||||||
|
|
||||||
|
import { hide_ads_window, show_ads_window } from '@/helpers/ads.js'
|
||||||
import { useTheming } from '@/store/theme.ts'
|
import { useTheming } from '@/store/theme.ts'
|
||||||
|
|
||||||
const themeStore = useTheming()
|
const themeStore = useTheming()
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
import { ChevronRightIcon } from '@modrinth/assets'
|
import { ChevronRightIcon } from '@modrinth/assets'
|
||||||
import { Avatar } from '@modrinth/ui'
|
import { Avatar } from '@modrinth/ui'
|
||||||
import { convertFileSrc } from '@tauri-apps/api/core'
|
import { convertFileSrc } from '@tauri-apps/api/core'
|
||||||
|
|
||||||
import type { GameInstance } from '@/helpers/types'
|
import type { GameInstance } from '@/helpers/types'
|
||||||
|
|
||||||
defineProps<{
|
defineProps<{
|
||||||
|
|||||||
@@ -1,22 +1,24 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import {
|
import {
|
||||||
ChevronRightIcon,
|
ChevronRightIcon,
|
||||||
|
CodeIcon,
|
||||||
CoffeeIcon,
|
CoffeeIcon,
|
||||||
InfoIcon,
|
InfoIcon,
|
||||||
WrenchIcon,
|
|
||||||
MonitorIcon,
|
MonitorIcon,
|
||||||
CodeIcon,
|
WrenchIcon,
|
||||||
} from '@modrinth/assets'
|
} from '@modrinth/assets'
|
||||||
import { Avatar, TabbedModal, type TabbedModalTab } from '@modrinth/ui'
|
import { Avatar, TabbedModal, type TabbedModalTab } from '@modrinth/ui'
|
||||||
import { ref } from 'vue'
|
|
||||||
import { defineMessage, useVIntl } from '@vintl/vintl'
|
|
||||||
import ModalWrapper from '@/components/ui/modal/ModalWrapper.vue'
|
|
||||||
import GeneralSettings from '@/components/ui/instance_settings/GeneralSettings.vue'
|
|
||||||
import { convertFileSrc } from '@tauri-apps/api/core'
|
import { convertFileSrc } from '@tauri-apps/api/core'
|
||||||
|
import { defineMessage, useVIntl } from '@vintl/vintl'
|
||||||
|
import { ref } from 'vue'
|
||||||
|
|
||||||
|
import GeneralSettings from '@/components/ui/instance_settings/GeneralSettings.vue'
|
||||||
|
import HooksSettings from '@/components/ui/instance_settings/HooksSettings.vue'
|
||||||
import InstallationSettings from '@/components/ui/instance_settings/InstallationSettings.vue'
|
import InstallationSettings from '@/components/ui/instance_settings/InstallationSettings.vue'
|
||||||
import JavaSettings from '@/components/ui/instance_settings/JavaSettings.vue'
|
import JavaSettings from '@/components/ui/instance_settings/JavaSettings.vue'
|
||||||
import WindowSettings from '@/components/ui/instance_settings/WindowSettings.vue'
|
import WindowSettings from '@/components/ui/instance_settings/WindowSettings.vue'
|
||||||
import HooksSettings from '@/components/ui/instance_settings/HooksSettings.vue'
|
import ModalWrapper from '@/components/ui/modal/ModalWrapper.vue'
|
||||||
|
|
||||||
import type { InstanceSettingsTabProps } from '../../../helpers/types'
|
import type { InstanceSettingsTabProps } from '../../../helpers/types'
|
||||||
|
|
||||||
const { formatMessage } = useVIntl()
|
const { formatMessage } = useVIntl()
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref } from 'vue'
|
|
||||||
import { NewModal as Modal } from '@modrinth/ui'
|
import { NewModal as Modal } from '@modrinth/ui'
|
||||||
import { show_ads_window, hide_ads_window } from '@/helpers/ads.js'
|
import { useTemplateRef } from 'vue'
|
||||||
|
|
||||||
|
import { hide_ads_window, show_ads_window } from '@/helpers/ads.js'
|
||||||
import { useTheming } from '@/store/theme.ts'
|
import { useTheming } from '@/store/theme.ts'
|
||||||
|
|
||||||
const themeStore = useTheming()
|
const themeStore = useTheming()
|
||||||
@@ -26,16 +27,16 @@ const props = defineProps({
|
|||||||
default: true,
|
default: true,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
const modal = ref(null)
|
const modal = useTemplateRef('modal')
|
||||||
|
|
||||||
defineExpose({
|
defineExpose({
|
||||||
show: () => {
|
show: (e: MouseEvent) => {
|
||||||
hide_ads_window()
|
hide_ads_window()
|
||||||
modal.value.show()
|
modal.value?.show(e)
|
||||||
},
|
},
|
||||||
hide: () => {
|
hide: () => {
|
||||||
onModalHide()
|
onModalHide()
|
||||||
modal.value.hide()
|
modal.value?.hide()
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref } from 'vue'
|
|
||||||
import { ShareModal } from '@modrinth/ui'
|
import { ShareModal } from '@modrinth/ui'
|
||||||
import { show_ads_window, hide_ads_window } from '@/helpers/ads.js'
|
import { ref } from 'vue'
|
||||||
|
|
||||||
|
import { hide_ads_window, show_ads_window } from '@/helpers/ads.js'
|
||||||
import { useTheming } from '@/store/theme.ts'
|
import { useTheming } from '@/store/theme.ts'
|
||||||
|
|
||||||
const themeStore = useTheming()
|
const themeStore = useTheming()
|
||||||
|
|||||||
@@ -1,9 +1,10 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { TeleportDropdownMenu, ThemeSelector, Toggle } from '@modrinth/ui'
|
import { TeleportDropdownMenu, ThemeSelector, Toggle } from '@modrinth/ui'
|
||||||
import { useTheming } from '@/store/state'
|
|
||||||
import { get, set } from '@/helpers/settings.ts'
|
|
||||||
import { ref, watch } from 'vue'
|
import { ref, watch } from 'vue'
|
||||||
|
|
||||||
|
import { get, set } from '@/helpers/settings.ts'
|
||||||
import { getOS } from '@/helpers/utils'
|
import { getOS } from '@/helpers/utils'
|
||||||
|
import { useTheming } from '@/store/state'
|
||||||
import type { ColorTheme } from '@/store/theme.ts'
|
import type { ColorTheme } from '@/store/theme.ts'
|
||||||
|
|
||||||
const themeStore = useTheming()
|
const themeStore = useTheming()
|
||||||
@@ -56,9 +57,17 @@ watch(
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="mt-4 flex items-center justify-between">
|
||||||
|
<div>
|
||||||
|
<h2 class="m-0 text-lg font-extrabold text-contrast">Hide nametag</h2>
|
||||||
|
<p class="m-0 mt-1">Disables the nametag above your player on the skins page.</p>
|
||||||
|
</div>
|
||||||
|
<Toggle id="hide-nametag-skins-page" v-model="settings.hide_nametag_skins_page" />
|
||||||
|
</div>
|
||||||
|
|
||||||
<div v-if="os !== 'MacOS'" class="mt-4 flex items-center justify-between gap-4">
|
<div v-if="os !== 'MacOS'" class="mt-4 flex items-center justify-between gap-4">
|
||||||
<div>
|
<div>
|
||||||
<h2 class="m-0 text-lg font-extrabold text-contrast">Native Decorations</h2>
|
<h2 class="m-0 text-lg font-extrabold text-contrast">Native decorations</h2>
|
||||||
<p class="m-0 mt-1">Use system window frame (app restart required).</p>
|
<p class="m-0 mt-1">Use system window frame (app restart required).</p>
|
||||||
</div>
|
</div>
|
||||||
<Toggle id="native-decorations" v-model="settings.native_decorations" />
|
<Toggle id="native-decorations" v-model="settings.native_decorations" />
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { get, set } from '@/helpers/settings.ts'
|
|
||||||
import { ref, watch } from 'vue'
|
|
||||||
import { get_max_memory } from '@/helpers/jre'
|
|
||||||
import { handleError } from '@/store/notifications'
|
|
||||||
import { Slider, Toggle } from '@modrinth/ui'
|
import { Slider, Toggle } from '@modrinth/ui'
|
||||||
|
import { ref, watch } from 'vue'
|
||||||
|
|
||||||
|
import useMemorySlider from '@/composables/useMemorySlider'
|
||||||
|
import { get, set } from '@/helpers/settings.ts'
|
||||||
|
|
||||||
const fetchSettings = await get()
|
const fetchSettings = await get()
|
||||||
fetchSettings.launchArgs = fetchSettings.extra_launch_args.join(' ')
|
fetchSettings.launchArgs = fetchSettings.extra_launch_args.join(' ')
|
||||||
@@ -11,7 +11,7 @@ fetchSettings.envVars = fetchSettings.custom_env_vars.map((x) => x.join('=')).jo
|
|||||||
|
|
||||||
const settings = ref(fetchSettings)
|
const settings = ref(fetchSettings)
|
||||||
|
|
||||||
const maxMemory = ref(Math.floor((await get_max_memory().catch(handleError)) / 1024))
|
const { maxMemory, snapPoints } = await useMemorySlider()
|
||||||
|
|
||||||
watch(
|
watch(
|
||||||
settings,
|
settings,
|
||||||
@@ -107,6 +107,8 @@ watch(
|
|||||||
:min="512"
|
:min="512"
|
||||||
:max="maxMemory"
|
:max="maxMemory"
|
||||||
:step="64"
|
:step="64"
|
||||||
|
:snap-points="snapPoints"
|
||||||
|
:snap-range="512"
|
||||||
unit="MB"
|
unit="MB"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,9 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { Toggle } from '@modrinth/ui'
|
import { Toggle } from '@modrinth/ui'
|
||||||
import { useTheming } from '@/store/state'
|
|
||||||
import { ref, watch } from 'vue'
|
import { ref, watch } from 'vue'
|
||||||
|
|
||||||
import { get as getSettings, set as setSettings } from '@/helpers/settings.ts'
|
import { get as getSettings, set as setSettings } from '@/helpers/settings.ts'
|
||||||
|
import { useTheming } from '@/store/state'
|
||||||
import { DEFAULT_FEATURE_FLAGS, type FeatureFlag } from '@/store/theme.ts'
|
import { DEFAULT_FEATURE_FLAGS, type FeatureFlag } from '@/store/theme.ts'
|
||||||
|
|
||||||
const themeStore = useTheming()
|
const themeStore = useTheming()
|
||||||
|
|||||||
@@ -1,8 +1,9 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
import { ref } from 'vue'
|
import { ref } from 'vue'
|
||||||
|
|
||||||
|
import JavaSelector from '@/components/ui/JavaSelector.vue'
|
||||||
import { get_java_versions, set_java_version } from '@/helpers/jre'
|
import { get_java_versions, set_java_version } from '@/helpers/jre'
|
||||||
import { handleError } from '@/store/notifications'
|
import { handleError } from '@/store/notifications'
|
||||||
import JavaSelector from '@/components/ui/JavaSelector.vue'
|
|
||||||
|
|
||||||
const javaVersions = ref(await get_java_versions().catch(handleError))
|
const javaVersions = ref(await get_java_versions().catch(handleError))
|
||||||
async function updateJavaVersion(version) {
|
async function updateJavaVersion(version) {
|
||||||
|
|||||||
@@ -1,8 +1,9 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref, watch } from 'vue'
|
|
||||||
import { get, set } from '@/helpers/settings.ts'
|
|
||||||
import { Toggle } from '@modrinth/ui'
|
import { Toggle } from '@modrinth/ui'
|
||||||
|
import { ref, watch } from 'vue'
|
||||||
|
|
||||||
import { optInAnalytics, optOutAnalytics } from '@/helpers/analytics'
|
import { optInAnalytics, optOutAnalytics } from '@/helpers/analytics'
|
||||||
|
import { get, set } from '@/helpers/settings.ts'
|
||||||
|
|
||||||
const settings = ref(await get())
|
const settings = ref(await get())
|
||||||
|
|
||||||
|
|||||||
@@ -1,12 +1,13 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
import { Button, Slider } from '@modrinth/ui'
|
|
||||||
import { ref, watch } from 'vue'
|
|
||||||
import { get, set } from '@/helpers/settings.ts'
|
|
||||||
import { purge_cache_types } from '@/helpers/cache.js'
|
|
||||||
import { handleError } from '@/store/notifications.js'
|
|
||||||
import { BoxIcon, FolderSearchIcon, TrashIcon } from '@modrinth/assets'
|
import { BoxIcon, FolderSearchIcon, TrashIcon } from '@modrinth/assets'
|
||||||
import ConfirmModalWrapper from '@/components/ui/modal/ConfirmModalWrapper.vue'
|
import { Button, Slider } from '@modrinth/ui'
|
||||||
import { open } from '@tauri-apps/plugin-dialog'
|
import { open } from '@tauri-apps/plugin-dialog'
|
||||||
|
import { ref, watch } from 'vue'
|
||||||
|
|
||||||
|
import ConfirmModalWrapper from '@/components/ui/modal/ConfirmModalWrapper.vue'
|
||||||
|
import { purge_cache_types } from '@/helpers/cache.js'
|
||||||
|
import { get, set } from '@/helpers/settings.ts'
|
||||||
|
import { handleError } from '@/store/notifications.js'
|
||||||
|
|
||||||
const settings = ref(await get())
|
const settings = ref(await get())
|
||||||
|
|
||||||
|
|||||||
414
apps/app-frontend/src/components/ui/skin/EditSkinModal.vue
Normal file
414
apps/app-frontend/src/components/ui/skin/EditSkinModal.vue
Normal file
@@ -0,0 +1,414 @@
|
|||||||
|
<template>
|
||||||
|
<UploadSkinModal ref="uploadModal" />
|
||||||
|
<ModalWrapper ref="modal" @on-hide="resetState">
|
||||||
|
<template #title>
|
||||||
|
<span class="text-lg font-extrabold text-contrast">
|
||||||
|
{{ mode === 'edit' ? 'Editing skin' : 'Adding a skin' }}
|
||||||
|
</span>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<div class="flex flex-col md:flex-row gap-6">
|
||||||
|
<div class="max-h-[25rem] w-[16rem] min-w-[16rem] overflow-hidden relative">
|
||||||
|
<div class="absolute top-[-4rem] left-0 h-[32rem] w-[16rem] flex-shrink-0">
|
||||||
|
<SkinPreviewRenderer
|
||||||
|
:variant="variant"
|
||||||
|
:texture-src="previewSkin || ''"
|
||||||
|
:cape-src="selectedCapeTexture"
|
||||||
|
:scale="1.4"
|
||||||
|
:fov="50"
|
||||||
|
:initial-rotation="Math.PI / 8"
|
||||||
|
class="h-full w-full"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="flex flex-col gap-4 w-full min-h-[20rem]">
|
||||||
|
<section>
|
||||||
|
<h2 class="text-base font-semibold mb-2">Texture</h2>
|
||||||
|
<Button @click="openUploadSkinModal"> <UploadIcon /> Replace texture </Button>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<section>
|
||||||
|
<h2 class="text-base font-semibold mb-2">Arm style</h2>
|
||||||
|
<RadioButtons v-model="variant" :items="['CLASSIC', 'SLIM']">
|
||||||
|
<template #default="{ item }">
|
||||||
|
{{ item === 'CLASSIC' ? 'Wide' : 'Slim' }}
|
||||||
|
</template>
|
||||||
|
</RadioButtons>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<section>
|
||||||
|
<h2 class="text-base font-semibold mb-2">Cape</h2>
|
||||||
|
<div class="flex gap-2">
|
||||||
|
<CapeButton
|
||||||
|
v-if="defaultCape"
|
||||||
|
:id="defaultCape.id"
|
||||||
|
:texture="defaultCape.texture"
|
||||||
|
:name="undefined"
|
||||||
|
:selected="!selectedCape"
|
||||||
|
faded
|
||||||
|
@select="selectCape(undefined)"
|
||||||
|
>
|
||||||
|
<span>Use default cape</span>
|
||||||
|
</CapeButton>
|
||||||
|
<CapeLikeTextButton v-else :highlighted="!selectedCape" @click="selectCape(undefined)">
|
||||||
|
<span>Use default cape</span>
|
||||||
|
</CapeLikeTextButton>
|
||||||
|
|
||||||
|
<CapeButton
|
||||||
|
v-for="cape in visibleCapeList"
|
||||||
|
:id="cape.id"
|
||||||
|
:key="cape.id"
|
||||||
|
:texture="cape.texture"
|
||||||
|
:name="cape.name || 'Cape'"
|
||||||
|
:selected="selectedCape?.id === cape.id"
|
||||||
|
@select="selectCape(cape)"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<CapeLikeTextButton
|
||||||
|
v-if="(capes?.length ?? 0) > 2"
|
||||||
|
tooltip="View more capes"
|
||||||
|
@mouseup="openSelectCapeModal"
|
||||||
|
>
|
||||||
|
<template #icon><ChevronRightIcon /></template>
|
||||||
|
<span>More</span>
|
||||||
|
</CapeLikeTextButton>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="flex gap-2 mt-12">
|
||||||
|
<ButtonStyled color="brand" :disabled="disableSave || isSaving">
|
||||||
|
<button v-tooltip="saveTooltip" :disabled="disableSave || isSaving" @click="save">
|
||||||
|
<SpinnerIcon v-if="isSaving" class="animate-spin" />
|
||||||
|
<CheckIcon v-else-if="mode === 'new'" />
|
||||||
|
<SaveIcon v-else />
|
||||||
|
{{ mode === 'new' ? 'Add skin' : 'Save skin' }}
|
||||||
|
</button>
|
||||||
|
</ButtonStyled>
|
||||||
|
<Button :disabled="isSaving" @click="hide"><XIcon />Cancel</Button>
|
||||||
|
</div>
|
||||||
|
</ModalWrapper>
|
||||||
|
|
||||||
|
<SelectCapeModal
|
||||||
|
ref="selectCapeModal"
|
||||||
|
:capes="capes || []"
|
||||||
|
@select="handleCapeSelected"
|
||||||
|
@cancel="handleCapeCancel"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
|
import {
|
||||||
|
CheckIcon,
|
||||||
|
ChevronRightIcon,
|
||||||
|
SaveIcon,
|
||||||
|
SpinnerIcon,
|
||||||
|
UploadIcon,
|
||||||
|
XIcon,
|
||||||
|
} from '@modrinth/assets'
|
||||||
|
import {
|
||||||
|
Button,
|
||||||
|
ButtonStyled,
|
||||||
|
CapeButton,
|
||||||
|
CapeLikeTextButton,
|
||||||
|
RadioButtons,
|
||||||
|
SkinPreviewRenderer,
|
||||||
|
} from '@modrinth/ui'
|
||||||
|
import { computed, ref, useTemplateRef, watch } from 'vue'
|
||||||
|
|
||||||
|
import ModalWrapper from '@/components/ui/modal/ModalWrapper.vue'
|
||||||
|
import SelectCapeModal from '@/components/ui/skin/SelectCapeModal.vue'
|
||||||
|
import UploadSkinModal from '@/components/ui/skin/UploadSkinModal.vue'
|
||||||
|
import {
|
||||||
|
add_and_equip_custom_skin,
|
||||||
|
type Cape,
|
||||||
|
determineModelType,
|
||||||
|
get_normalized_skin_texture,
|
||||||
|
remove_custom_skin,
|
||||||
|
type Skin,
|
||||||
|
type SkinModel,
|
||||||
|
unequip_skin,
|
||||||
|
} from '@/helpers/skins.ts'
|
||||||
|
import { handleError } from '@/store/notifications'
|
||||||
|
|
||||||
|
const modal = useTemplateRef('modal')
|
||||||
|
const selectCapeModal = useTemplateRef('selectCapeModal')
|
||||||
|
const mode = ref<'new' | 'edit'>('new')
|
||||||
|
const currentSkin = ref<Skin | null>(null)
|
||||||
|
const shouldRestoreModal = ref(false)
|
||||||
|
const isSaving = ref(false)
|
||||||
|
|
||||||
|
const uploadedTextureUrl = ref<string | null>(null)
|
||||||
|
const previewSkin = ref<string>('')
|
||||||
|
|
||||||
|
const variant = ref<SkinModel>('CLASSIC')
|
||||||
|
const selectedCape = ref<Cape | undefined>(undefined)
|
||||||
|
const props = defineProps<{ capes?: Cape[]; defaultCape?: Cape }>()
|
||||||
|
|
||||||
|
const selectedCapeTexture = computed(() => selectedCape.value?.texture)
|
||||||
|
const visibleCapeList = ref<Cape[]>([])
|
||||||
|
|
||||||
|
const sortedCapes = computed(() => {
|
||||||
|
return [...(props.capes || [])].sort((a, b) => {
|
||||||
|
const nameA = (a.name || '').toLowerCase()
|
||||||
|
const nameB = (b.name || '').toLowerCase()
|
||||||
|
return nameA.localeCompare(nameB)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
function initVisibleCapeList() {
|
||||||
|
if (!props.capes || props.capes.length === 0) {
|
||||||
|
visibleCapeList.value = []
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if (visibleCapeList.value.length === 0) {
|
||||||
|
if (selectedCape.value) {
|
||||||
|
const otherCape = getSortedCapeExcluding(selectedCape.value.id)
|
||||||
|
visibleCapeList.value = otherCape ? [selectedCape.value, otherCape] : [selectedCape.value]
|
||||||
|
} else {
|
||||||
|
visibleCapeList.value = getSortedCapes(2)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function getSortedCapes(count: number): Cape[] {
|
||||||
|
if (!sortedCapes.value || sortedCapes.value.length === 0) return []
|
||||||
|
return sortedCapes.value.slice(0, count)
|
||||||
|
}
|
||||||
|
|
||||||
|
function getSortedCapeExcluding(excludeId: string): Cape | undefined {
|
||||||
|
if (!sortedCapes.value || sortedCapes.value.length <= 1) return undefined
|
||||||
|
return sortedCapes.value.find((cape) => cape.id !== excludeId)
|
||||||
|
}
|
||||||
|
|
||||||
|
async function loadPreviewSkin() {
|
||||||
|
if (uploadedTextureUrl.value) {
|
||||||
|
previewSkin.value = uploadedTextureUrl.value
|
||||||
|
} else if (currentSkin.value) {
|
||||||
|
try {
|
||||||
|
previewSkin.value = await get_normalized_skin_texture(currentSkin.value)
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Failed to load skin texture:', error)
|
||||||
|
previewSkin.value = '/src/assets/skins/steve.png'
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
previewSkin.value = '/src/assets/skins/steve.png'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const hasEdits = computed(() => {
|
||||||
|
if (mode.value !== 'edit') return true
|
||||||
|
if (uploadedTextureUrl.value) return true
|
||||||
|
if (!currentSkin.value) return false
|
||||||
|
if (variant.value !== currentSkin.value.variant) return true
|
||||||
|
if ((selectedCape.value?.id || null) !== (currentSkin.value.cape_id || null)) return true
|
||||||
|
return false
|
||||||
|
})
|
||||||
|
|
||||||
|
const disableSave = computed(
|
||||||
|
() =>
|
||||||
|
(mode.value === 'new' && !uploadedTextureUrl.value) ||
|
||||||
|
(mode.value === 'edit' && !hasEdits.value),
|
||||||
|
)
|
||||||
|
|
||||||
|
const saveTooltip = computed(() => {
|
||||||
|
if (isSaving.value) return 'Saving...'
|
||||||
|
if (mode.value === 'new' && !uploadedTextureUrl.value) return 'Upload a skin first!'
|
||||||
|
if (mode.value === 'edit' && !hasEdits.value) return 'Make an edit to the skin first!'
|
||||||
|
return undefined
|
||||||
|
})
|
||||||
|
|
||||||
|
function resetState() {
|
||||||
|
mode.value = 'new'
|
||||||
|
currentSkin.value = null
|
||||||
|
uploadedTextureUrl.value = null
|
||||||
|
previewSkin.value = ''
|
||||||
|
variant.value = 'CLASSIC'
|
||||||
|
selectedCape.value = undefined
|
||||||
|
visibleCapeList.value = []
|
||||||
|
shouldRestoreModal.value = false
|
||||||
|
isSaving.value = false
|
||||||
|
}
|
||||||
|
|
||||||
|
async function show(e: MouseEvent, skin?: Skin) {
|
||||||
|
mode.value = skin ? 'edit' : 'new'
|
||||||
|
currentSkin.value = skin ?? null
|
||||||
|
if (skin) {
|
||||||
|
variant.value = skin.variant
|
||||||
|
selectedCape.value = props.capes?.find((c) => c.id === skin.cape_id)
|
||||||
|
} else {
|
||||||
|
variant.value = 'CLASSIC'
|
||||||
|
selectedCape.value = undefined
|
||||||
|
}
|
||||||
|
visibleCapeList.value = []
|
||||||
|
initVisibleCapeList()
|
||||||
|
|
||||||
|
await loadPreviewSkin()
|
||||||
|
|
||||||
|
modal.value?.show(e)
|
||||||
|
}
|
||||||
|
|
||||||
|
async function showNew(e: MouseEvent, skinTextureUrl: string) {
|
||||||
|
mode.value = 'new'
|
||||||
|
currentSkin.value = null
|
||||||
|
uploadedTextureUrl.value = skinTextureUrl
|
||||||
|
variant.value = await determineModelType(skinTextureUrl)
|
||||||
|
selectedCape.value = undefined
|
||||||
|
visibleCapeList.value = []
|
||||||
|
initVisibleCapeList()
|
||||||
|
|
||||||
|
await loadPreviewSkin()
|
||||||
|
|
||||||
|
modal.value?.show(e)
|
||||||
|
}
|
||||||
|
|
||||||
|
async function restoreWithNewTexture(skinTextureUrl: string) {
|
||||||
|
uploadedTextureUrl.value = skinTextureUrl
|
||||||
|
await loadPreviewSkin()
|
||||||
|
|
||||||
|
if (shouldRestoreModal.value) {
|
||||||
|
setTimeout(() => {
|
||||||
|
modal.value?.show()
|
||||||
|
shouldRestoreModal.value = false
|
||||||
|
}, 0)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function hide() {
|
||||||
|
modal.value?.hide()
|
||||||
|
setTimeout(() => resetState(), 250)
|
||||||
|
}
|
||||||
|
|
||||||
|
function selectCape(cape: Cape | undefined) {
|
||||||
|
if (cape && selectedCape.value?.id !== cape.id) {
|
||||||
|
const isInVisibleList = visibleCapeList.value.some((c) => c.id === cape.id)
|
||||||
|
if (!isInVisibleList && visibleCapeList.value.length > 0) {
|
||||||
|
visibleCapeList.value.splice(0, 1, cape)
|
||||||
|
|
||||||
|
if (visibleCapeList.value.length > 1 && visibleCapeList.value[1].id === cape.id) {
|
||||||
|
const otherCape = getSortedCapeExcluding(cape.id)
|
||||||
|
if (otherCape) {
|
||||||
|
visibleCapeList.value.splice(1, 1, otherCape)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
selectedCape.value = cape
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleCapeSelected(cape: Cape | undefined) {
|
||||||
|
selectCape(cape)
|
||||||
|
|
||||||
|
if (shouldRestoreModal.value) {
|
||||||
|
setTimeout(() => {
|
||||||
|
modal.value?.show()
|
||||||
|
shouldRestoreModal.value = false
|
||||||
|
}, 0)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleCapeCancel() {
|
||||||
|
if (shouldRestoreModal.value) {
|
||||||
|
setTimeout(() => {
|
||||||
|
modal.value?.show()
|
||||||
|
shouldRestoreModal.value = false
|
||||||
|
}, 0)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function openSelectCapeModal(e: MouseEvent) {
|
||||||
|
if (!selectCapeModal.value) return
|
||||||
|
|
||||||
|
shouldRestoreModal.value = true
|
||||||
|
modal.value?.hide()
|
||||||
|
|
||||||
|
setTimeout(() => {
|
||||||
|
selectCapeModal.value?.show(
|
||||||
|
e,
|
||||||
|
currentSkin.value?.texture_key,
|
||||||
|
selectedCape.value,
|
||||||
|
previewSkin.value,
|
||||||
|
variant.value,
|
||||||
|
)
|
||||||
|
}, 0)
|
||||||
|
}
|
||||||
|
|
||||||
|
function openUploadSkinModal(e: MouseEvent) {
|
||||||
|
shouldRestoreModal.value = true
|
||||||
|
modal.value?.hide()
|
||||||
|
emit('open-upload-modal', e)
|
||||||
|
}
|
||||||
|
|
||||||
|
function restoreModal() {
|
||||||
|
if (shouldRestoreModal.value) {
|
||||||
|
setTimeout(() => {
|
||||||
|
const fakeEvent = new MouseEvent('click')
|
||||||
|
modal.value?.show(fakeEvent)
|
||||||
|
shouldRestoreModal.value = false
|
||||||
|
}, 500)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function save() {
|
||||||
|
isSaving.value = true
|
||||||
|
|
||||||
|
try {
|
||||||
|
let textureUrl: string
|
||||||
|
|
||||||
|
if (uploadedTextureUrl.value) {
|
||||||
|
textureUrl = uploadedTextureUrl.value
|
||||||
|
} else {
|
||||||
|
textureUrl = currentSkin.value!.texture
|
||||||
|
}
|
||||||
|
|
||||||
|
await unequip_skin()
|
||||||
|
|
||||||
|
const bytes: Uint8Array = new Uint8Array(await (await fetch(textureUrl)).arrayBuffer())
|
||||||
|
|
||||||
|
if (mode.value === 'new') {
|
||||||
|
await add_and_equip_custom_skin(bytes, variant.value, selectedCape.value)
|
||||||
|
emit('saved')
|
||||||
|
} else {
|
||||||
|
await add_and_equip_custom_skin(bytes, variant.value, selectedCape.value)
|
||||||
|
await remove_custom_skin(currentSkin.value!)
|
||||||
|
emit('saved')
|
||||||
|
}
|
||||||
|
|
||||||
|
hide()
|
||||||
|
} catch (err) {
|
||||||
|
handleError(err)
|
||||||
|
} finally {
|
||||||
|
isSaving.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
watch([uploadedTextureUrl, currentSkin], async () => {
|
||||||
|
await loadPreviewSkin()
|
||||||
|
})
|
||||||
|
|
||||||
|
watch(
|
||||||
|
() => props.capes,
|
||||||
|
() => {
|
||||||
|
initVisibleCapeList()
|
||||||
|
},
|
||||||
|
{ immediate: true },
|
||||||
|
)
|
||||||
|
|
||||||
|
const emit = defineEmits<{
|
||||||
|
(event: 'saved'): void
|
||||||
|
(event: 'deleted', skin: Skin): void
|
||||||
|
(event: 'open-upload-modal', mouseEvent: MouseEvent): void
|
||||||
|
}>()
|
||||||
|
|
||||||
|
defineExpose({
|
||||||
|
show,
|
||||||
|
showNew,
|
||||||
|
restoreWithNewTexture,
|
||||||
|
hide,
|
||||||
|
shouldRestoreModal,
|
||||||
|
restoreModal,
|
||||||
|
})
|
||||||
|
</script>
|
||||||
141
apps/app-frontend/src/components/ui/skin/SelectCapeModal.vue
Normal file
141
apps/app-frontend/src/components/ui/skin/SelectCapeModal.vue
Normal file
@@ -0,0 +1,141 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import { CheckIcon, XIcon } from '@modrinth/assets'
|
||||||
|
import {
|
||||||
|
ButtonStyled,
|
||||||
|
CapeButton,
|
||||||
|
CapeLikeTextButton,
|
||||||
|
ScrollablePanel,
|
||||||
|
SkinPreviewRenderer,
|
||||||
|
} from '@modrinth/ui'
|
||||||
|
import { computed, ref, useTemplateRef } from 'vue'
|
||||||
|
|
||||||
|
import ModalWrapper from '@/components/ui/modal/ModalWrapper.vue'
|
||||||
|
import type { Cape, SkinModel } from '@/helpers/skins.ts'
|
||||||
|
|
||||||
|
const modal = useTemplateRef('modal')
|
||||||
|
|
||||||
|
const emit = defineEmits<{
|
||||||
|
(e: 'select', cape: Cape | undefined): void
|
||||||
|
(e: 'cancel'): void
|
||||||
|
}>()
|
||||||
|
|
||||||
|
const props = defineProps<{
|
||||||
|
capes: Cape[]
|
||||||
|
}>()
|
||||||
|
|
||||||
|
const sortedCapes = computed(() => {
|
||||||
|
return [...props.capes].sort((a, b) => {
|
||||||
|
const nameA = (a.name || '').toLowerCase()
|
||||||
|
const nameB = (b.name || '').toLowerCase()
|
||||||
|
return nameA.localeCompare(nameB)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
const currentSkinId = ref<string | undefined>()
|
||||||
|
const currentSkinTexture = ref<string | undefined>()
|
||||||
|
const currentSkinVariant = ref<SkinModel>('CLASSIC')
|
||||||
|
const currentCapeTexture = computed<string | undefined>(() => currentCape.value?.texture)
|
||||||
|
const currentCape = ref<Cape | undefined>()
|
||||||
|
|
||||||
|
function show(
|
||||||
|
e: MouseEvent,
|
||||||
|
skinId?: string,
|
||||||
|
selected?: Cape,
|
||||||
|
skinTexture?: string,
|
||||||
|
variant?: SkinModel,
|
||||||
|
) {
|
||||||
|
currentSkinId.value = skinId
|
||||||
|
currentSkinTexture.value = skinTexture
|
||||||
|
currentSkinVariant.value = variant || 'CLASSIC'
|
||||||
|
currentCape.value = selected
|
||||||
|
modal.value?.show(e)
|
||||||
|
}
|
||||||
|
|
||||||
|
function select() {
|
||||||
|
emit('select', currentCape.value)
|
||||||
|
hide()
|
||||||
|
}
|
||||||
|
|
||||||
|
function hide() {
|
||||||
|
modal.value?.hide()
|
||||||
|
emit('cancel')
|
||||||
|
}
|
||||||
|
|
||||||
|
function updateSelectedCape(cape: Cape | undefined) {
|
||||||
|
currentCape.value = cape
|
||||||
|
}
|
||||||
|
|
||||||
|
function onModalHide() {
|
||||||
|
emit('cancel')
|
||||||
|
}
|
||||||
|
|
||||||
|
defineExpose({
|
||||||
|
show,
|
||||||
|
hide,
|
||||||
|
})
|
||||||
|
</script>
|
||||||
|
<template>
|
||||||
|
<ModalWrapper ref="modal" @on-hide="onModalHide">
|
||||||
|
<template #title>
|
||||||
|
<div class="flex flex-col">
|
||||||
|
<span class="text-lg font-extrabold text-heading">Change cape</span>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
<div class="flex flex-col md:flex-row gap-6">
|
||||||
|
<div class="max-h-[25rem] h-[25rem] w-[16rem] min-w-[16rem] overflow-hidden relative">
|
||||||
|
<div class="absolute top-[-4rem] left-0 h-[32rem] w-[16rem] flex-shrink-0">
|
||||||
|
<SkinPreviewRenderer
|
||||||
|
v-if="currentSkinTexture"
|
||||||
|
:cape-src="currentCapeTexture"
|
||||||
|
:texture-src="currentSkinTexture"
|
||||||
|
:variant="currentSkinVariant"
|
||||||
|
:scale="1.4"
|
||||||
|
:fov="50"
|
||||||
|
:initial-rotation="Math.PI + Math.PI / 8"
|
||||||
|
class="h-full w-full"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="flex flex-col gap-4 w-full my-auto">
|
||||||
|
<ScrollablePanel class="max-h-[20rem] max-w-[30rem] mb-5 h-full">
|
||||||
|
<div class="flex flex-wrap gap-2 justify-center content-start overflow-y-auto h-full">
|
||||||
|
<CapeLikeTextButton
|
||||||
|
tooltip="No Cape"
|
||||||
|
:highlighted="!currentCape"
|
||||||
|
@click="updateSelectedCape(undefined)"
|
||||||
|
>
|
||||||
|
<template #icon>
|
||||||
|
<XIcon />
|
||||||
|
</template>
|
||||||
|
<span>None</span>
|
||||||
|
</CapeLikeTextButton>
|
||||||
|
<CapeButton
|
||||||
|
v-for="cape in sortedCapes"
|
||||||
|
:id="cape.id"
|
||||||
|
:key="cape.id"
|
||||||
|
:name="cape.name"
|
||||||
|
:texture="cape.texture"
|
||||||
|
:selected="currentCape?.id === cape.id"
|
||||||
|
@select="updateSelectedCape(cape)"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</ScrollablePanel>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="flex gap-2 items-center">
|
||||||
|
<ButtonStyled color="brand">
|
||||||
|
<button @click="select">
|
||||||
|
<CheckIcon />
|
||||||
|
Select
|
||||||
|
</button>
|
||||||
|
</ButtonStyled>
|
||||||
|
<ButtonStyled>
|
||||||
|
<button @click="hide">
|
||||||
|
<XIcon />
|
||||||
|
Cancel
|
||||||
|
</button>
|
||||||
|
</ButtonStyled>
|
||||||
|
</div>
|
||||||
|
</ModalWrapper>
|
||||||
|
</template>
|
||||||
141
apps/app-frontend/src/components/ui/skin/UploadSkinModal.vue
Normal file
141
apps/app-frontend/src/components/ui/skin/UploadSkinModal.vue
Normal file
@@ -0,0 +1,141 @@
|
|||||||
|
<template>
|
||||||
|
<ModalWrapper ref="modal" @on-hide="hide(true)">
|
||||||
|
<template #title>
|
||||||
|
<span class="text-lg font-extrabold text-contrast"> Upload skin texture </span>
|
||||||
|
</template>
|
||||||
|
<div class="relative">
|
||||||
|
<div
|
||||||
|
class="border-2 border-dashed border-highlight-gray rounded-xl h-[173px] flex flex-col items-center justify-center p-8 cursor-pointer bg-button-bg hover:bg-button-hover transition-colors relative"
|
||||||
|
@click="triggerFileInput"
|
||||||
|
>
|
||||||
|
<p class="mx-auto mb-0 text-primary font-bold text-lg text-center flex items-center gap-2">
|
||||||
|
<UploadIcon /> Select skin texture file
|
||||||
|
</p>
|
||||||
|
<p class="mx-auto mt-0 text-secondary text-sm text-center">
|
||||||
|
Drag and drop or click here to browse
|
||||||
|
</p>
|
||||||
|
<input
|
||||||
|
ref="fileInput"
|
||||||
|
type="file"
|
||||||
|
accept="image/png"
|
||||||
|
class="hidden"
|
||||||
|
@change="handleInputFileChange"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</ModalWrapper>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
|
import { UploadIcon } from '@modrinth/assets'
|
||||||
|
import { getCurrentWebview } from '@tauri-apps/api/webview'
|
||||||
|
import { onBeforeUnmount, ref, watch } from 'vue'
|
||||||
|
|
||||||
|
import ModalWrapper from '@/components/ui/modal/ModalWrapper.vue'
|
||||||
|
import { get_dragged_skin_data } from '@/helpers/skins'
|
||||||
|
import { useNotifications } from '@/store/state'
|
||||||
|
|
||||||
|
const notifications = useNotifications()
|
||||||
|
|
||||||
|
const modal = ref()
|
||||||
|
const fileInput = ref<HTMLInputElement>()
|
||||||
|
const unlisten = ref<() => void>()
|
||||||
|
const modalVisible = ref(false)
|
||||||
|
|
||||||
|
const emit = defineEmits<{
|
||||||
|
(e: 'uploaded', data: ArrayBuffer): void
|
||||||
|
(e: 'canceled'): void
|
||||||
|
}>()
|
||||||
|
|
||||||
|
function show(e?: MouseEvent) {
|
||||||
|
modal.value?.show(e)
|
||||||
|
modalVisible.value = true
|
||||||
|
setupDragDropListener()
|
||||||
|
}
|
||||||
|
|
||||||
|
function hide(emitCanceled = false) {
|
||||||
|
modal.value?.hide()
|
||||||
|
modalVisible.value = false
|
||||||
|
cleanupDragDropListener()
|
||||||
|
resetState()
|
||||||
|
if (emitCanceled) {
|
||||||
|
emit('canceled')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function resetState() {
|
||||||
|
if (fileInput.value) fileInput.value.value = ''
|
||||||
|
}
|
||||||
|
|
||||||
|
function triggerFileInput() {
|
||||||
|
fileInput.value?.click()
|
||||||
|
}
|
||||||
|
|
||||||
|
async function handleInputFileChange(e: Event) {
|
||||||
|
const files = (e.target as HTMLInputElement).files
|
||||||
|
if (!files || files.length === 0) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
const file = files[0]
|
||||||
|
const buffer = await file.arrayBuffer()
|
||||||
|
await processData(buffer)
|
||||||
|
}
|
||||||
|
|
||||||
|
async function setupDragDropListener() {
|
||||||
|
try {
|
||||||
|
if (modalVisible.value) {
|
||||||
|
await cleanupDragDropListener()
|
||||||
|
unlisten.value = await getCurrentWebview().onDragDropEvent(async (event) => {
|
||||||
|
if (event.payload.type !== 'drop') {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!event.payload.paths || event.payload.paths.length === 0) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
const filePath = event.payload.paths[0]
|
||||||
|
|
||||||
|
try {
|
||||||
|
const data = await get_dragged_skin_data(filePath)
|
||||||
|
await processData(data.buffer)
|
||||||
|
} catch (error) {
|
||||||
|
notifications.addNotification({
|
||||||
|
title: 'Error processing file',
|
||||||
|
text: error instanceof Error ? error.message : 'Failed to read the dropped file.',
|
||||||
|
type: 'error',
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Failed to set up drag and drop listener:', error)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function cleanupDragDropListener() {
|
||||||
|
if (unlisten.value) {
|
||||||
|
unlisten.value()
|
||||||
|
unlisten.value = undefined
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function processData(buffer: ArrayBuffer) {
|
||||||
|
emit('uploaded', buffer)
|
||||||
|
hide()
|
||||||
|
}
|
||||||
|
|
||||||
|
watch(modalVisible, (isVisible) => {
|
||||||
|
if (isVisible) {
|
||||||
|
setupDragDropListener()
|
||||||
|
} else {
|
||||||
|
cleanupDragDropListener()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
onBeforeUnmount(() => {
|
||||||
|
cleanupDragDropListener()
|
||||||
|
})
|
||||||
|
|
||||||
|
defineExpose({ show, hide })
|
||||||
|
</script>
|
||||||
@@ -1,5 +1,4 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import dayjs from 'dayjs'
|
|
||||||
import {
|
import {
|
||||||
EyeIcon,
|
EyeIcon,
|
||||||
FolderOpenIcon,
|
FolderOpenIcon,
|
||||||
@@ -16,20 +15,23 @@ import {
|
|||||||
SmartClickable,
|
SmartClickable,
|
||||||
useRelativeTime,
|
useRelativeTime,
|
||||||
} from '@modrinth/ui'
|
} from '@modrinth/ui'
|
||||||
import { useVIntl } from '@vintl/vintl'
|
|
||||||
import { computed, nextTick, ref, onMounted, onUnmounted } from 'vue'
|
|
||||||
import { showProfileInFolder } from '@/helpers/utils'
|
|
||||||
import { convertFileSrc } from '@tauri-apps/api/core'
|
|
||||||
import { useRouter } from 'vue-router'
|
|
||||||
import type { GameInstance } from '@/helpers/types'
|
|
||||||
import { get_project } from '@/helpers/cache'
|
|
||||||
import { capitalizeString } from '@modrinth/utils'
|
import { capitalizeString } from '@modrinth/utils'
|
||||||
import { kill, run } from '@/helpers/profile'
|
import { convertFileSrc } from '@tauri-apps/api/core'
|
||||||
import { handleSevereError } from '@/store/error'
|
import { useVIntl } from '@vintl/vintl'
|
||||||
|
import type { Dayjs } from 'dayjs'
|
||||||
|
import dayjs from 'dayjs'
|
||||||
|
import { computed, nextTick, onMounted, onUnmounted, ref } from 'vue'
|
||||||
|
import { useRouter } from 'vue-router'
|
||||||
|
|
||||||
import { trackEvent } from '@/helpers/analytics'
|
import { trackEvent } from '@/helpers/analytics'
|
||||||
import { get_by_profile_path } from '@/helpers/process'
|
import { get_project } from '@/helpers/cache'
|
||||||
import { handleError } from '@/store/notifications'
|
|
||||||
import { process_listener } from '@/helpers/events'
|
import { process_listener } from '@/helpers/events'
|
||||||
|
import { get_by_profile_path } from '@/helpers/process'
|
||||||
|
import { kill, run } from '@/helpers/profile'
|
||||||
|
import type { GameInstance } from '@/helpers/types'
|
||||||
|
import { showProfileInFolder } from '@/helpers/utils'
|
||||||
|
import { handleSevereError } from '@/store/error'
|
||||||
|
import { handleError } from '@/store/notifications'
|
||||||
|
|
||||||
const { formatMessage } = useVIntl()
|
const { formatMessage } = useVIntl()
|
||||||
const formatRelativeTime = useRelativeTime()
|
const formatRelativeTime = useRelativeTime()
|
||||||
@@ -42,6 +44,7 @@ const emit = defineEmits<{
|
|||||||
|
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
instance: GameInstance
|
instance: GameInstance
|
||||||
|
last_played: Dayjs
|
||||||
}>()
|
}>()
|
||||||
|
|
||||||
const loadingModpack = ref(!!props.instance.linked_data)
|
const loadingModpack = ref(!!props.instance.linked_data)
|
||||||
@@ -147,12 +150,12 @@ onUnmounted(() => {
|
|||||||
: null
|
: null
|
||||||
"
|
"
|
||||||
class="w-fit shrink-0"
|
class="w-fit shrink-0"
|
||||||
:class="{ 'cursor-help smart-clickable:allow-pointer-events': instance.last_played }"
|
:class="{ 'cursor-help smart-clickable:allow-pointer-events': last_played }"
|
||||||
>
|
>
|
||||||
<template v-if="instance.last_played">
|
<template v-if="last_played">
|
||||||
{{
|
{{
|
||||||
formatMessage(commonMessages.playedLabel, {
|
formatMessage(commonMessages.playedLabel, {
|
||||||
time: formatRelativeTime(instance.last_played.toISOString()),
|
time: formatRelativeTime(last_played.toISOString?.()),
|
||||||
})
|
})
|
||||||
}}
|
}}
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@@ -1,29 +1,31 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import {
|
import { GAME_MODES, HeadingLink } from '@modrinth/ui'
|
||||||
type ServerWorld,
|
|
||||||
type ServerData,
|
|
||||||
type WorldWithProfile,
|
|
||||||
get_recent_worlds,
|
|
||||||
getWorldIdentifier,
|
|
||||||
get_profile_protocol_version,
|
|
||||||
refreshServerData,
|
|
||||||
start_join_server,
|
|
||||||
start_join_singleplayer_world,
|
|
||||||
} from '@/helpers/worlds.ts'
|
|
||||||
import { HeadingLink, GAME_MODES } from '@modrinth/ui'
|
|
||||||
import WorldItem from '@/components/ui/world/WorldItem.vue'
|
|
||||||
import InstanceItem from '@/components/ui/world/InstanceItem.vue'
|
|
||||||
import { watch, onMounted, onUnmounted, ref, computed } from 'vue'
|
|
||||||
import type { Dayjs } from 'dayjs'
|
import type { Dayjs } from 'dayjs'
|
||||||
import dayjs from 'dayjs'
|
import dayjs from 'dayjs'
|
||||||
import { useTheming } from '@/store/theme.ts'
|
import { computed, onMounted, onUnmounted, ref, watch } from 'vue'
|
||||||
import { kill, run } from '@/helpers/profile'
|
|
||||||
import { handleError } from '@/store/notifications'
|
import InstanceItem from '@/components/ui/world/InstanceItem.vue'
|
||||||
|
import WorldItem from '@/components/ui/world/WorldItem.vue'
|
||||||
import { trackEvent } from '@/helpers/analytics'
|
import { trackEvent } from '@/helpers/analytics'
|
||||||
import { process_listener, profile_listener } from '@/helpers/events'
|
import { process_listener, profile_listener } from '@/helpers/events'
|
||||||
import { get_all } from '@/helpers/process'
|
import { get_all } from '@/helpers/process'
|
||||||
|
import { kill, run } from '@/helpers/profile'
|
||||||
import type { GameInstance } from '@/helpers/types'
|
import type { GameInstance } from '@/helpers/types'
|
||||||
|
import {
|
||||||
|
get_profile_protocol_version,
|
||||||
|
get_recent_worlds,
|
||||||
|
getWorldIdentifier,
|
||||||
|
type ProtocolVersion,
|
||||||
|
refreshServerData,
|
||||||
|
type ServerData,
|
||||||
|
type ServerWorld,
|
||||||
|
start_join_server,
|
||||||
|
start_join_singleplayer_world,
|
||||||
|
type WorldWithProfile,
|
||||||
|
} from '@/helpers/worlds.ts'
|
||||||
import { handleSevereError } from '@/store/error'
|
import { handleSevereError } from '@/store/error'
|
||||||
|
import { handleError } from '@/store/notifications'
|
||||||
|
import { useTheming } from '@/store/theme.ts'
|
||||||
|
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
recentInstances: GameInstance[]
|
recentInstances: GameInstance[]
|
||||||
@@ -33,7 +35,7 @@ const theme = useTheming()
|
|||||||
|
|
||||||
const jumpBackInItems = ref<JumpBackInItem[]>([])
|
const jumpBackInItems = ref<JumpBackInItem[]>([])
|
||||||
const serverData = ref<Record<string, ServerData>>({})
|
const serverData = ref<Record<string, ServerData>>({})
|
||||||
const protocolVersions = ref<Record<string, number | null>>({})
|
const protocolVersions = ref<Record<string, ProtocolVersion | null>>({})
|
||||||
|
|
||||||
const MIN_JUMP_BACK_IN = 3
|
const MIN_JUMP_BACK_IN = 3
|
||||||
const MAX_JUMP_BACK_IN = 6
|
const MAX_JUMP_BACK_IN = 6
|
||||||
@@ -84,7 +86,7 @@ async function populateJumpBackIn() {
|
|||||||
|
|
||||||
worldItems.push({
|
worldItems.push({
|
||||||
type: 'world',
|
type: 'world',
|
||||||
last_played: dayjs(world.last_played),
|
last_played: dayjs(world.last_played ?? 0),
|
||||||
world: world,
|
world: world,
|
||||||
instance: instance,
|
instance: instance,
|
||||||
})
|
})
|
||||||
@@ -121,11 +123,8 @@ async function populateJumpBackIn() {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
// fetch each server's data
|
servers.forEach(({ instancePath, address }) =>
|
||||||
Promise.all(
|
refreshServerData(serverData.value[address], protocolVersions.value[instancePath], address),
|
||||||
servers.map(({ instancePath, address }) =>
|
|
||||||
refreshServerData(serverData.value[address], protocolVersions.value[instancePath], address),
|
|
||||||
),
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -138,20 +137,20 @@ async function populateJumpBackIn() {
|
|||||||
|
|
||||||
instanceItems.push({
|
instanceItems.push({
|
||||||
type: 'instance',
|
type: 'instance',
|
||||||
last_played: dayjs(instance.last_played),
|
last_played: dayjs(instance.last_played ?? 0),
|
||||||
instance: instance,
|
instance: instance,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
const items: JumpBackInItem[] = [...worldItems, ...instanceItems]
|
const items: JumpBackInItem[] = [...worldItems, ...instanceItems]
|
||||||
items.sort((a, b) => dayjs(b.last_played).diff(dayjs(a.last_played)))
|
items.sort((a, b) => dayjs(b.last_played ?? 0).diff(dayjs(a.last_played ?? 0)))
|
||||||
jumpBackInItems.value = items
|
jumpBackInItems.value = items
|
||||||
.filter((item, index) => index < MIN_JUMP_BACK_IN || item.last_played.isAfter(TWO_WEEKS_AGO))
|
.filter((item, index) => index < MIN_JUMP_BACK_IN || item.last_played.isAfter(TWO_WEEKS_AGO))
|
||||||
.slice(0, MAX_JUMP_BACK_IN)
|
.slice(0, MAX_JUMP_BACK_IN)
|
||||||
}
|
}
|
||||||
|
|
||||||
async function refreshServer(address: string, instancePath: string) {
|
function refreshServer(address: string, instancePath: string) {
|
||||||
await refreshServerData(serverData.value[address], protocolVersions.value[instancePath], address)
|
refreshServerData(serverData.value[address], protocolVersions.value[instancePath], address)
|
||||||
}
|
}
|
||||||
|
|
||||||
async function joinWorld(world: WorldWithProfile) {
|
async function joinWorld(world: WorldWithProfile) {
|
||||||
@@ -291,7 +290,7 @@ onUnmounted(() => {
|
|||||||
"
|
"
|
||||||
@stop="() => stopInstance(item.instance.path)"
|
@stop="() => stopInstance(item.instance.path)"
|
||||||
/>
|
/>
|
||||||
<InstanceItem v-else :instance="item.instance" />
|
<InstanceItem v-else :instance="item.instance" :last_played="item.last_played" />
|
||||||
</template>
|
</template>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,22 +1,10 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import dayjs from 'dayjs'
|
|
||||||
import type { ServerStatus, ServerWorld, SingleplayerWorld, World } from '@/helpers/worlds.ts'
|
|
||||||
import { set_world_display_status, getWorldIdentifier } from '@/helpers/worlds.ts'
|
|
||||||
import { formatNumber, getPingLevel } from '@modrinth/utils'
|
|
||||||
import {
|
import {
|
||||||
useRelativeTime,
|
|
||||||
Avatar,
|
|
||||||
ButtonStyled,
|
|
||||||
commonMessages,
|
|
||||||
OverflowMenu,
|
|
||||||
SmartClickable,
|
|
||||||
} from '@modrinth/ui'
|
|
||||||
import {
|
|
||||||
IssuesIcon,
|
|
||||||
EyeIcon,
|
|
||||||
ClipboardCopyIcon,
|
ClipboardCopyIcon,
|
||||||
EditIcon,
|
EditIcon,
|
||||||
|
EyeIcon,
|
||||||
FolderOpenIcon,
|
FolderOpenIcon,
|
||||||
|
IssuesIcon,
|
||||||
MoreVerticalIcon,
|
MoreVerticalIcon,
|
||||||
NoSignalIcon,
|
NoSignalIcon,
|
||||||
PlayIcon,
|
PlayIcon,
|
||||||
@@ -29,14 +17,33 @@ import {
|
|||||||
UserIcon,
|
UserIcon,
|
||||||
XIcon,
|
XIcon,
|
||||||
} from '@modrinth/assets'
|
} from '@modrinth/assets'
|
||||||
|
import {
|
||||||
|
Avatar,
|
||||||
|
ButtonStyled,
|
||||||
|
commonMessages,
|
||||||
|
OverflowMenu,
|
||||||
|
SmartClickable,
|
||||||
|
useRelativeTime,
|
||||||
|
} from '@modrinth/ui'
|
||||||
|
import { formatNumber, getPingLevel } from '@modrinth/utils'
|
||||||
|
import { convertFileSrc } from '@tauri-apps/api/core'
|
||||||
import type { MessageDescriptor } from '@vintl/vintl'
|
import type { MessageDescriptor } from '@vintl/vintl'
|
||||||
import { defineMessages, useVIntl } from '@vintl/vintl'
|
import { defineMessages, useVIntl } from '@vintl/vintl'
|
||||||
|
import dayjs from 'dayjs'
|
||||||
|
import { Tooltip } from 'floating-vue'
|
||||||
import type { Component } from 'vue'
|
import type { Component } from 'vue'
|
||||||
import { computed } from 'vue'
|
import { computed } from 'vue'
|
||||||
import { copyToClipboard } from '@/helpers/utils'
|
|
||||||
import { convertFileSrc } from '@tauri-apps/api/core'
|
|
||||||
import { useRouter } from 'vue-router'
|
import { useRouter } from 'vue-router'
|
||||||
import { Tooltip } from 'floating-vue'
|
|
||||||
|
import { copyToClipboard } from '@/helpers/utils'
|
||||||
|
import type {
|
||||||
|
ProtocolVersion,
|
||||||
|
ServerStatus,
|
||||||
|
ServerWorld,
|
||||||
|
SingleplayerWorld,
|
||||||
|
World,
|
||||||
|
} from '@/helpers/worlds.ts'
|
||||||
|
import { getWorldIdentifier, set_world_display_status } from '@/helpers/worlds.ts'
|
||||||
|
|
||||||
const { formatMessage } = useVIntl()
|
const { formatMessage } = useVIntl()
|
||||||
const formatRelativeTime = useRelativeTime()
|
const formatRelativeTime = useRelativeTime()
|
||||||
@@ -54,8 +61,9 @@ const props = withDefaults(
|
|||||||
playingInstance?: boolean
|
playingInstance?: boolean
|
||||||
playingWorld?: boolean
|
playingWorld?: boolean
|
||||||
startingInstance?: boolean
|
startingInstance?: boolean
|
||||||
supportsQuickPlay?: boolean
|
supportsServerQuickPlay?: boolean
|
||||||
currentProtocol?: number | null
|
supportsWorldQuickPlay?: boolean
|
||||||
|
currentProtocol?: ProtocolVersion | null
|
||||||
highlighted?: boolean
|
highlighted?: boolean
|
||||||
|
|
||||||
// Server only
|
// Server only
|
||||||
@@ -78,7 +86,8 @@ const props = withDefaults(
|
|||||||
playingInstance: false,
|
playingInstance: false,
|
||||||
playingWorld: false,
|
playingWorld: false,
|
||||||
startingInstance: false,
|
startingInstance: false,
|
||||||
supportsQuickPlay: false,
|
supportsServerQuickPlay: true,
|
||||||
|
supportsWorldQuickPlay: false,
|
||||||
currentProtocol: null,
|
currentProtocol: null,
|
||||||
|
|
||||||
refreshing: false,
|
refreshing: false,
|
||||||
@@ -102,7 +111,8 @@ const serverIncompatible = computed(
|
|||||||
!!props.serverStatus &&
|
!!props.serverStatus &&
|
||||||
!!props.serverStatus.version?.protocol &&
|
!!props.serverStatus.version?.protocol &&
|
||||||
!!props.currentProtocol &&
|
!!props.currentProtocol &&
|
||||||
props.serverStatus.version.protocol !== props.currentProtocol,
|
(props.serverStatus.version.protocol !== props.currentProtocol.version ||
|
||||||
|
props.serverStatus.version.legacy !== props.currentProtocol.legacy),
|
||||||
)
|
)
|
||||||
|
|
||||||
const locked = computed(() => props.world.type === 'singleplayer' && props.world.locked)
|
const locked = computed(() => props.world.type === 'singleplayer' && props.world.locked)
|
||||||
@@ -120,14 +130,26 @@ const messages = defineMessages({
|
|||||||
id: 'instance.worlds.a_minecraft_server',
|
id: 'instance.worlds.a_minecraft_server',
|
||||||
defaultMessage: 'A Minecraft Server',
|
defaultMessage: 'A Minecraft Server',
|
||||||
},
|
},
|
||||||
noQuickPlay: {
|
noServerQuickPlay: {
|
||||||
id: 'instance.worlds.no_quick_play',
|
id: 'instance.worlds.no_server_quick_play',
|
||||||
defaultMessage: 'You can only jump straight into worlds on Minecraft 1.20+',
|
defaultMessage: 'You can only jump straight into servers on Minecraft Alpha 1.0.5+',
|
||||||
|
},
|
||||||
|
noSingleplayerQuickPlay: {
|
||||||
|
id: 'instance.worlds.no_singleplayer_quick_play',
|
||||||
|
defaultMessage: 'You can only jump straight into singleplayer worlds on Minecraft 1.20+',
|
||||||
},
|
},
|
||||||
gameAlreadyOpen: {
|
gameAlreadyOpen: {
|
||||||
id: 'instance.worlds.game_already_open',
|
id: 'instance.worlds.game_already_open',
|
||||||
defaultMessage: 'Instance is already open',
|
defaultMessage: 'Instance is already open',
|
||||||
},
|
},
|
||||||
|
noContact: {
|
||||||
|
id: 'instance.worlds.no_contact',
|
||||||
|
defaultMessage: "Server couldn't be contacted",
|
||||||
|
},
|
||||||
|
incompatibleServer: {
|
||||||
|
id: 'instance.worlds.incompatible_server',
|
||||||
|
defaultMessage: 'Server is incompatible',
|
||||||
|
},
|
||||||
copyAddress: {
|
copyAddress: {
|
||||||
id: 'instance.worlds.copy_address',
|
id: 'instance.worlds.copy_address',
|
||||||
defaultMessage: 'Copy address',
|
defaultMessage: 'Copy address',
|
||||||
@@ -136,10 +158,6 @@ const messages = defineMessages({
|
|||||||
id: 'instance.worlds.view_instance',
|
id: 'instance.worlds.view_instance',
|
||||||
defaultMessage: 'View instance',
|
defaultMessage: 'View instance',
|
||||||
},
|
},
|
||||||
playAnyway: {
|
|
||||||
id: 'instance.worlds.play_anyway',
|
|
||||||
defaultMessage: 'Play anyway',
|
|
||||||
},
|
|
||||||
playInstance: {
|
playInstance: {
|
||||||
id: 'instance.worlds.play_instance',
|
id: 'instance.worlds.play_instance',
|
||||||
defaultMessage: 'Play instance',
|
defaultMessage: 'Play instance',
|
||||||
@@ -302,39 +320,40 @@ const messages = defineMessages({
|
|||||||
</template>
|
</template>
|
||||||
</div>
|
</div>
|
||||||
<div class="flex gap-1 justify-end smart-clickable:allow-pointer-events">
|
<div class="flex gap-1 justify-end smart-clickable:allow-pointer-events">
|
||||||
<template v-if="world.type === 'singleplayer' || serverStatus">
|
<ButtonStyled
|
||||||
<ButtonStyled
|
v-if="(playingWorld || (locked && playingInstance)) && !startingInstance"
|
||||||
v-if="(playingWorld || (locked && playingInstance)) && !startingInstance"
|
color="red"
|
||||||
color="red"
|
>
|
||||||
>
|
<button @click="emit('stop')">
|
||||||
<button @click="emit('stop')">
|
<StopCircleIcon aria-hidden="true" />
|
||||||
<StopCircleIcon aria-hidden="true" />
|
{{ formatMessage(commonMessages.stopButton) }}
|
||||||
{{ formatMessage(commonMessages.stopButton) }}
|
</button>
|
||||||
</button>
|
</ButtonStyled>
|
||||||
</ButtonStyled>
|
|
||||||
<ButtonStyled v-else>
|
|
||||||
<button
|
|
||||||
v-tooltip="
|
|
||||||
serverIncompatible
|
|
||||||
? 'Server is incompatible'
|
|
||||||
: !supportsQuickPlay
|
|
||||||
? formatMessage(messages.noQuickPlay)
|
|
||||||
: playingOtherWorld || locked
|
|
||||||
? formatMessage(messages.gameAlreadyOpen)
|
|
||||||
: null
|
|
||||||
"
|
|
||||||
:disabled="!supportsQuickPlay || playingOtherWorld || startingInstance"
|
|
||||||
@click="emit('play')"
|
|
||||||
>
|
|
||||||
<SpinnerIcon v-if="startingInstance && playingWorld" class="animate-spin" />
|
|
||||||
<PlayIcon v-else aria-hidden="true" />
|
|
||||||
{{ formatMessage(commonMessages.playButton) }}
|
|
||||||
</button>
|
|
||||||
</ButtonStyled>
|
|
||||||
</template>
|
|
||||||
<ButtonStyled v-else>
|
<ButtonStyled v-else>
|
||||||
<button class="invisible">
|
<button
|
||||||
<PlayIcon aria-hidden="true" />
|
v-tooltip="
|
||||||
|
world.type == 'server' && !supportsServerQuickPlay
|
||||||
|
? formatMessage(messages.noServerQuickPlay)
|
||||||
|
: world.type == 'singleplayer' && !supportsWorldQuickPlay
|
||||||
|
? formatMessage(messages.noSingleplayerQuickPlay)
|
||||||
|
: playingOtherWorld || locked
|
||||||
|
? formatMessage(messages.gameAlreadyOpen)
|
||||||
|
: !serverStatus
|
||||||
|
? formatMessage(messages.noContact)
|
||||||
|
: serverIncompatible
|
||||||
|
? formatMessage(messages.incompatibleServer)
|
||||||
|
: null
|
||||||
|
"
|
||||||
|
:disabled="
|
||||||
|
playingOtherWorld ||
|
||||||
|
startingInstance ||
|
||||||
|
(world.type == 'server' && !supportsServerQuickPlay) ||
|
||||||
|
(world.type == 'singleplayer' && !supportsWorldQuickPlay)
|
||||||
|
"
|
||||||
|
@click="emit('play')"
|
||||||
|
>
|
||||||
|
<SpinnerIcon v-if="startingInstance && playingWorld" class="animate-spin" />
|
||||||
|
<PlayIcon v-else aria-hidden="true" />
|
||||||
{{ formatMessage(commonMessages.playButton) }}
|
{{ formatMessage(commonMessages.playButton) }}
|
||||||
</button>
|
</button>
|
||||||
</ButtonStyled>
|
</ButtonStyled>
|
||||||
@@ -347,11 +366,6 @@ const messages = defineMessages({
|
|||||||
disabled: playingInstance,
|
disabled: playingInstance,
|
||||||
action: () => emit('play-instance'),
|
action: () => emit('play-instance'),
|
||||||
},
|
},
|
||||||
{
|
|
||||||
id: 'play-anyway',
|
|
||||||
shown: serverIncompatible && !playingInstance && supportsQuickPlay,
|
|
||||||
action: () => emit('play'),
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
id: 'open-instance',
|
id: 'open-instance',
|
||||||
shown: !!instancePath,
|
shown: !!instancePath,
|
||||||
@@ -417,10 +431,6 @@ const messages = defineMessages({
|
|||||||
<PlayIcon aria-hidden="true" />
|
<PlayIcon aria-hidden="true" />
|
||||||
{{ formatMessage(messages.playInstance) }}
|
{{ formatMessage(messages.playInstance) }}
|
||||||
</template>
|
</template>
|
||||||
<template #play-anyway>
|
|
||||||
<PlayIcon aria-hidden="true" />
|
|
||||||
{{ formatMessage(messages.playAnyway) }}
|
|
||||||
</template>
|
|
||||||
<template #open-instance>
|
<template #open-instance>
|
||||||
<EyeIcon aria-hidden="true" />
|
<EyeIcon aria-hidden="true" />
|
||||||
{{ formatMessage(messages.viewInstance) }}
|
{{ formatMessage(messages.viewInstance) }}
|
||||||
|
|||||||
@@ -1,14 +1,15 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { PlayIcon, PlusIcon, XIcon } from '@modrinth/assets'
|
import { PlayIcon, PlusIcon, XIcon } from '@modrinth/assets'
|
||||||
import { ButtonStyled, commonMessages } from '@modrinth/ui'
|
import { ButtonStyled, commonMessages } from '@modrinth/ui'
|
||||||
import { ref } from 'vue'
|
|
||||||
import ModalWrapper from '@/components/ui/modal/ModalWrapper.vue'
|
|
||||||
import type { GameInstance } from '@/helpers/types'
|
|
||||||
import InstanceModalTitlePrefix from '@/components/ui/modal/InstanceModalTitlePrefix.vue'
|
|
||||||
import { add_server_to_profile, type ServerPackStatus, type ServerWorld } from '@/helpers/worlds.ts'
|
|
||||||
import { defineMessages, useVIntl } from '@vintl/vintl'
|
import { defineMessages, useVIntl } from '@vintl/vintl'
|
||||||
import { handleError } from '@/store/notifications'
|
import { ref } from 'vue'
|
||||||
|
|
||||||
|
import InstanceModalTitlePrefix from '@/components/ui/modal/InstanceModalTitlePrefix.vue'
|
||||||
|
import ModalWrapper from '@/components/ui/modal/ModalWrapper.vue'
|
||||||
import ServerModalBody from '@/components/ui/world/modal/ServerModalBody.vue'
|
import ServerModalBody from '@/components/ui/world/modal/ServerModalBody.vue'
|
||||||
|
import type { GameInstance } from '@/helpers/types'
|
||||||
|
import { add_server_to_profile, type ServerPackStatus, type ServerWorld } from '@/helpers/worlds.ts'
|
||||||
|
import { handleError } from '@/store/notifications'
|
||||||
|
|
||||||
const { formatMessage } = useVIntl()
|
const { formatMessage } = useVIntl()
|
||||||
|
|
||||||
|
|||||||
@@ -1,20 +1,21 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { SaveIcon, XIcon } from '@modrinth/assets'
|
import { SaveIcon, XIcon } from '@modrinth/assets'
|
||||||
import { ButtonStyled, commonMessages } from '@modrinth/ui'
|
import { ButtonStyled, commonMessages } from '@modrinth/ui'
|
||||||
|
import { defineMessage, useVIntl } from '@vintl/vintl'
|
||||||
import { computed, ref } from 'vue'
|
import { computed, ref } from 'vue'
|
||||||
|
|
||||||
import ModalWrapper from '@/components/ui/modal/ModalWrapper.vue'
|
import ModalWrapper from '@/components/ui/modal/ModalWrapper.vue'
|
||||||
|
import HideFromHomeOption from '@/components/ui/world/modal/HideFromHomeOption.vue'
|
||||||
|
import ServerModalBody from '@/components/ui/world/modal/ServerModalBody.vue'
|
||||||
import type { GameInstance } from '@/helpers/types'
|
import type { GameInstance } from '@/helpers/types'
|
||||||
import {
|
import {
|
||||||
type ServerPackStatus,
|
type DisplayStatus,
|
||||||
edit_server_in_profile,
|
edit_server_in_profile,
|
||||||
|
type ServerPackStatus,
|
||||||
type ServerWorld,
|
type ServerWorld,
|
||||||
set_world_display_status,
|
set_world_display_status,
|
||||||
type DisplayStatus,
|
|
||||||
} from '@/helpers/worlds.ts'
|
} from '@/helpers/worlds.ts'
|
||||||
import { defineMessage, useVIntl } from '@vintl/vintl'
|
|
||||||
import { handleError } from '@/store/notifications'
|
import { handleError } from '@/store/notifications'
|
||||||
import ServerModalBody from '@/components/ui/world/modal/ServerModalBody.vue'
|
|
||||||
import HideFromHomeOption from '@/components/ui/world/modal/HideFromHomeOption.vue'
|
|
||||||
|
|
||||||
const { formatMessage } = useVIntl()
|
const { formatMessage } = useVIntl()
|
||||||
|
|
||||||
|
|||||||
@@ -1,14 +1,15 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ChevronRightIcon, SaveIcon, XIcon, UndoIcon } from '@modrinth/assets'
|
import { ChevronRightIcon, SaveIcon, UndoIcon, XIcon } from '@modrinth/assets'
|
||||||
import { Avatar, ButtonStyled, commonMessages } from '@modrinth/ui'
|
import { Avatar, ButtonStyled, commonMessages } from '@modrinth/ui'
|
||||||
|
import { defineMessages, useVIntl } from '@vintl/vintl'
|
||||||
import { computed, ref } from 'vue'
|
import { computed, ref } from 'vue'
|
||||||
|
|
||||||
import ModalWrapper from '@/components/ui/modal/ModalWrapper.vue'
|
import ModalWrapper from '@/components/ui/modal/ModalWrapper.vue'
|
||||||
|
import HideFromHomeOption from '@/components/ui/world/modal/HideFromHomeOption.vue'
|
||||||
import type { GameInstance } from '@/helpers/types'
|
import type { GameInstance } from '@/helpers/types'
|
||||||
import type { DisplayStatus, SingleplayerWorld } from '@/helpers/worlds.ts'
|
import type { DisplayStatus, SingleplayerWorld } from '@/helpers/worlds.ts'
|
||||||
import { set_world_display_status, rename_world, reset_world_icon } from '@/helpers/worlds.ts'
|
import { rename_world, reset_world_icon, set_world_display_status } from '@/helpers/worlds.ts'
|
||||||
import { defineMessages, useVIntl } from '@vintl/vintl'
|
|
||||||
import { handleError } from '@/store/notifications'
|
import { handleError } from '@/store/notifications'
|
||||||
import HideFromHomeOption from '@/components/ui/world/modal/HideFromHomeOption.vue'
|
|
||||||
|
|
||||||
const { formatMessage } = useVIntl()
|
const { formatMessage } = useVIntl()
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
|
import { Checkbox } from '@modrinth/ui'
|
||||||
import { defineMessage, useVIntl } from '@vintl/vintl'
|
import { defineMessage, useVIntl } from '@vintl/vintl'
|
||||||
import { computed } from 'vue'
|
import { computed } from 'vue'
|
||||||
import { Checkbox } from '@modrinth/ui'
|
|
||||||
|
|
||||||
const { formatMessage } = useVIntl()
|
const { formatMessage } = useVIntl()
|
||||||
const value = defineModel<boolean>({ required: true })
|
const value = defineModel<boolean>({ required: true })
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { TeleportDropdownMenu } from '@modrinth/ui'
|
import { TeleportDropdownMenu } from '@modrinth/ui'
|
||||||
|
import { defineMessages, type MessageDescriptor, useVIntl } from '@vintl/vintl'
|
||||||
|
|
||||||
import type { ServerPackStatus } from '@/helpers/worlds.ts'
|
import type { ServerPackStatus } from '@/helpers/worlds.ts'
|
||||||
import { type MessageDescriptor, defineMessages, useVIntl } from '@vintl/vintl'
|
|
||||||
|
|
||||||
const { formatMessage } = useVIntl()
|
const { formatMessage } = useVIntl()
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import { invoke } from '@tauri-apps/api/core'
|
import { invoke } from '@tauri-apps/api/core'
|
||||||
|
|
||||||
import cssContent from '@/assets/stylesheets/macFix.css?inline'
|
import cssContent from '@/assets/stylesheets/macFix.css?inline'
|
||||||
|
|
||||||
export async function useCheckDisableMouseover() {
|
export async function useCheckDisableMouseover() {
|
||||||
|
|||||||
22
apps/app-frontend/src/composables/useMemorySlider.js
Normal file
22
apps/app-frontend/src/composables/useMemorySlider.js
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
import { computed, ref } from 'vue'
|
||||||
|
|
||||||
|
import { get_max_memory } from '@/helpers/jre.js'
|
||||||
|
import { handleError } from '@/store/notifications.js'
|
||||||
|
|
||||||
|
export default async function () {
|
||||||
|
const maxMemory = ref(Math.floor((await get_max_memory().catch(handleError)) / 1024))
|
||||||
|
|
||||||
|
const snapPoints = computed(() => {
|
||||||
|
let points = []
|
||||||
|
let memory = 2048
|
||||||
|
|
||||||
|
while (memory <= maxMemory.value) {
|
||||||
|
points.push(memory)
|
||||||
|
memory *= 2
|
||||||
|
}
|
||||||
|
|
||||||
|
return points
|
||||||
|
})
|
||||||
|
|
||||||
|
return { maxMemory, snapPoints }
|
||||||
|
}
|
||||||
@@ -1,12 +1,13 @@
|
|||||||
import { ofetch } from 'ofetch'
|
|
||||||
import { handleError } from '@/store/state.js'
|
|
||||||
import { getVersion } from '@tauri-apps/api/app'
|
import { getVersion } from '@tauri-apps/api/app'
|
||||||
|
import { fetch } from '@tauri-apps/plugin-http'
|
||||||
|
|
||||||
|
import { handleError } from '@/store/state.js'
|
||||||
|
|
||||||
export const useFetch = async (url, item, isSilent) => {
|
export const useFetch = async (url, item, isSilent) => {
|
||||||
try {
|
try {
|
||||||
const version = await getVersion()
|
const version = await getVersion()
|
||||||
|
return await fetch(url, {
|
||||||
return await ofetch(url, {
|
method: 'GET',
|
||||||
headers: { 'User-Agent': `modrinth/theseus/${version} (support@modrinth.com)` },
|
headers: { 'User-Agent': `modrinth/theseus/${version} (support@modrinth.com)` },
|
||||||
})
|
})
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
* and deserialized into a usable JS object.
|
* and deserialized into a usable JS object.
|
||||||
*/
|
*/
|
||||||
import { invoke } from '@tauri-apps/api/core'
|
import { invoke } from '@tauri-apps/api/core'
|
||||||
|
|
||||||
import { create } from './profile'
|
import { create } from './profile'
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
@@ -36,8 +36,8 @@ export async function get_jre(path) {
|
|||||||
|
|
||||||
// Tests JRE version by running 'java -version' on it.
|
// Tests JRE version by running 'java -version' on it.
|
||||||
// Returns true if the version is valid, and matches given (after extraction)
|
// Returns true if the version is valid, and matches given (after extraction)
|
||||||
export async function test_jre(path, majorVersion, minorVersion) {
|
export async function test_jre(path, majorVersion) {
|
||||||
return await invoke('plugin:jre|jre_test_jre', { path, majorVersion, minorVersion })
|
return await invoke('plugin:jre|jre_test_jre', { path, majorVersion })
|
||||||
}
|
}
|
||||||
|
|
||||||
// Automatically installs specified java version
|
// Automatically installs specified java version
|
||||||
|
|||||||
@@ -16,3 +16,7 @@ export async function logout() {
|
|||||||
export async function get() {
|
export async function get() {
|
||||||
return await invoke('plugin:mr-auth|get')
|
return await invoke('plugin:mr-auth|get')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function cancelLogin() {
|
||||||
|
return await invoke('plugin:mr-auth|cancel_modrinth_login')
|
||||||
|
}
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
* and deserialized into a usable JS object.
|
* and deserialized into a usable JS object.
|
||||||
*/
|
*/
|
||||||
import { invoke } from '@tauri-apps/api/core'
|
import { invoke } from '@tauri-apps/api/core'
|
||||||
|
|
||||||
import { create } from './profile'
|
import { create } from './profile'
|
||||||
|
|
||||||
// Installs pack from a version ID
|
// Installs pack from a version ID
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
* and deserialized into a usable JS object.
|
* and deserialized into a usable JS object.
|
||||||
*/
|
*/
|
||||||
import { invoke } from '@tauri-apps/api/core'
|
import { invoke } from '@tauri-apps/api/core'
|
||||||
|
|
||||||
import { install_to_existing_profile } from '@/helpers/pack.js'
|
import { install_to_existing_profile } from '@/helpers/pack.js'
|
||||||
import { handleError } from '@/store/notifications.js'
|
import { handleError } from '@/store/notifications.js'
|
||||||
|
|
||||||
|
|||||||
447
apps/app-frontend/src/helpers/rendering/batch-skin-renderer.ts
Normal file
447
apps/app-frontend/src/helpers/rendering/batch-skin-renderer.ts
Normal file
@@ -0,0 +1,447 @@
|
|||||||
|
import { ClassicPlayerModel, SlimPlayerModel } from '@modrinth/assets'
|
||||||
|
import {
|
||||||
|
applyCapeTexture,
|
||||||
|
createTransparentTexture,
|
||||||
|
disposeCaches,
|
||||||
|
loadTexture,
|
||||||
|
setupSkinModel,
|
||||||
|
} from '@modrinth/utils'
|
||||||
|
import * as THREE from 'three'
|
||||||
|
import { reactive } from 'vue'
|
||||||
|
|
||||||
|
import type { Cape, Skin } from '../skins'
|
||||||
|
import { determineModelType, get_normalized_skin_texture } from '../skins'
|
||||||
|
import { headStorage } from '../storage/head-storage'
|
||||||
|
import { skinPreviewStorage } from '../storage/skin-preview-storage'
|
||||||
|
|
||||||
|
export interface RenderResult {
|
||||||
|
forwards: string
|
||||||
|
backwards: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface RawRenderResult {
|
||||||
|
forwards: Blob
|
||||||
|
backwards: Blob
|
||||||
|
}
|
||||||
|
|
||||||
|
class BatchSkinRenderer {
|
||||||
|
private renderer: THREE.WebGLRenderer | null = null
|
||||||
|
private scene: THREE.Scene | null = null
|
||||||
|
private camera: THREE.PerspectiveCamera | null = null
|
||||||
|
private currentModel: THREE.Group | null = null
|
||||||
|
private readonly width: number
|
||||||
|
private readonly height: number
|
||||||
|
|
||||||
|
constructor(width: number = 360, height: number = 504) {
|
||||||
|
this.width = width
|
||||||
|
this.height = height
|
||||||
|
}
|
||||||
|
|
||||||
|
private initializeRenderer(): void {
|
||||||
|
if (this.renderer) return
|
||||||
|
|
||||||
|
const canvas = document.createElement('canvas')
|
||||||
|
canvas.width = this.width
|
||||||
|
canvas.height = this.height
|
||||||
|
|
||||||
|
this.renderer = new THREE.WebGLRenderer({
|
||||||
|
canvas: canvas,
|
||||||
|
antialias: true,
|
||||||
|
alpha: true,
|
||||||
|
preserveDrawingBuffer: true,
|
||||||
|
})
|
||||||
|
|
||||||
|
this.renderer.outputColorSpace = THREE.SRGBColorSpace
|
||||||
|
this.renderer.toneMapping = THREE.NoToneMapping
|
||||||
|
this.renderer.toneMappingExposure = 10.0
|
||||||
|
this.renderer.setClearColor(0x000000, 0)
|
||||||
|
this.renderer.setSize(this.width, this.height)
|
||||||
|
|
||||||
|
this.scene = new THREE.Scene()
|
||||||
|
this.camera = new THREE.PerspectiveCamera(20, this.width / this.height, 0.4, 1000)
|
||||||
|
|
||||||
|
const ambientLight = new THREE.AmbientLight(0xffffff, 2)
|
||||||
|
const directionalLight = new THREE.DirectionalLight(0xffffff, 1.2)
|
||||||
|
directionalLight.castShadow = true
|
||||||
|
directionalLight.position.set(2, 4, 3)
|
||||||
|
this.scene.add(ambientLight)
|
||||||
|
this.scene.add(directionalLight)
|
||||||
|
}
|
||||||
|
|
||||||
|
public async renderSkin(
|
||||||
|
textureUrl: string,
|
||||||
|
modelUrl: string,
|
||||||
|
capeUrl?: string,
|
||||||
|
): Promise<RawRenderResult> {
|
||||||
|
this.initializeRenderer()
|
||||||
|
|
||||||
|
this.clearScene()
|
||||||
|
|
||||||
|
await this.setupModel(modelUrl, textureUrl, capeUrl)
|
||||||
|
|
||||||
|
const headPart = this.currentModel!.getObjectByName('Head')
|
||||||
|
let lookAtTarget: [number, number, number]
|
||||||
|
|
||||||
|
if (headPart) {
|
||||||
|
const headPosition = new THREE.Vector3()
|
||||||
|
headPart.getWorldPosition(headPosition)
|
||||||
|
lookAtTarget = [headPosition.x, headPosition.y - 0.3, headPosition.z]
|
||||||
|
} else {
|
||||||
|
throw new Error("Failed to find 'Head' object in model.")
|
||||||
|
}
|
||||||
|
|
||||||
|
const frontCameraPos: [number, number, number] = [-1.3, 1, 6.3]
|
||||||
|
const backCameraPos: [number, number, number] = [-1.3, 1, -2.5]
|
||||||
|
|
||||||
|
const forwards = await this.renderView(frontCameraPos, lookAtTarget)
|
||||||
|
const backwards = await this.renderView(backCameraPos, lookAtTarget)
|
||||||
|
|
||||||
|
return { forwards, backwards }
|
||||||
|
}
|
||||||
|
|
||||||
|
private async renderView(
|
||||||
|
cameraPosition: [number, number, number],
|
||||||
|
lookAtPosition: [number, number, number],
|
||||||
|
): Promise<Blob> {
|
||||||
|
if (!this.camera || !this.renderer || !this.scene) {
|
||||||
|
throw new Error('Renderer not initialized')
|
||||||
|
}
|
||||||
|
|
||||||
|
this.camera.position.set(...cameraPosition)
|
||||||
|
this.camera.lookAt(...lookAtPosition)
|
||||||
|
|
||||||
|
this.renderer.render(this.scene, this.camera)
|
||||||
|
|
||||||
|
const dataUrl = this.renderer.domElement.toDataURL('image/webp', 0.9)
|
||||||
|
const response = await fetch(dataUrl)
|
||||||
|
return await response.blob()
|
||||||
|
}
|
||||||
|
|
||||||
|
private async setupModel(modelUrl: string, textureUrl: string, capeUrl?: string): Promise<void> {
|
||||||
|
if (!this.scene) {
|
||||||
|
throw new Error('Renderer not initialized')
|
||||||
|
}
|
||||||
|
|
||||||
|
const { model } = await setupSkinModel(modelUrl, textureUrl)
|
||||||
|
|
||||||
|
if (capeUrl) {
|
||||||
|
const capeTexture = await loadTexture(capeUrl)
|
||||||
|
applyCapeTexture(model, capeTexture)
|
||||||
|
} else {
|
||||||
|
const transparentTexture = createTransparentTexture()
|
||||||
|
applyCapeTexture(model, null, transparentTexture)
|
||||||
|
}
|
||||||
|
|
||||||
|
const group = new THREE.Group()
|
||||||
|
group.add(model)
|
||||||
|
group.position.set(0, 0.3, 1.95)
|
||||||
|
group.scale.set(0.8, 0.8, 0.8)
|
||||||
|
|
||||||
|
this.scene.add(group)
|
||||||
|
this.currentModel = group
|
||||||
|
}
|
||||||
|
|
||||||
|
private clearScene(): void {
|
||||||
|
if (!this.scene) return
|
||||||
|
|
||||||
|
while (this.scene.children.length > 0) {
|
||||||
|
const child = this.scene.children[0]
|
||||||
|
this.scene.remove(child)
|
||||||
|
|
||||||
|
if (child instanceof THREE.Mesh) {
|
||||||
|
if (child.geometry) child.geometry.dispose()
|
||||||
|
if (child.material) {
|
||||||
|
if (Array.isArray(child.material)) {
|
||||||
|
child.material.forEach((material) => material.dispose())
|
||||||
|
} else {
|
||||||
|
child.material.dispose()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const ambientLight = new THREE.AmbientLight(0xffffff, 2)
|
||||||
|
const directionalLight = new THREE.DirectionalLight(0xffffff, 1.2)
|
||||||
|
directionalLight.castShadow = true
|
||||||
|
directionalLight.position.set(2, 4, 3)
|
||||||
|
this.scene.add(ambientLight)
|
||||||
|
this.scene.add(directionalLight)
|
||||||
|
|
||||||
|
this.currentModel = null
|
||||||
|
}
|
||||||
|
|
||||||
|
public dispose(): void {
|
||||||
|
if (this.renderer) {
|
||||||
|
this.renderer.dispose()
|
||||||
|
}
|
||||||
|
disposeCaches()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function getModelUrlForVariant(variant: string): string {
|
||||||
|
switch (variant) {
|
||||||
|
case 'SLIM':
|
||||||
|
return SlimPlayerModel
|
||||||
|
case 'CLASSIC':
|
||||||
|
case 'UNKNOWN':
|
||||||
|
default:
|
||||||
|
return ClassicPlayerModel
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export const skinBlobUrlMap = reactive(new Map<string, RenderResult>())
|
||||||
|
export const headBlobUrlMap = reactive(new Map<string, string>())
|
||||||
|
const DEBUG_MODE = false
|
||||||
|
|
||||||
|
let sharedRenderer: BatchSkinRenderer | null = null
|
||||||
|
function getSharedRenderer(): BatchSkinRenderer {
|
||||||
|
if (!sharedRenderer) {
|
||||||
|
sharedRenderer = new BatchSkinRenderer()
|
||||||
|
}
|
||||||
|
return sharedRenderer
|
||||||
|
}
|
||||||
|
|
||||||
|
export function disposeSharedRenderer(): void {
|
||||||
|
if (sharedRenderer) {
|
||||||
|
sharedRenderer.dispose()
|
||||||
|
sharedRenderer = null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function cleanupUnusedPreviews(skins: Skin[]): Promise<void> {
|
||||||
|
const validKeys = new Set<string>()
|
||||||
|
const validHeadKeys = new Set<string>()
|
||||||
|
|
||||||
|
for (const skin of skins) {
|
||||||
|
const key = `${skin.texture_key}+${skin.variant}+${skin.cape_id ?? 'no-cape'}`
|
||||||
|
const headKey = `${skin.texture_key}-head`
|
||||||
|
validKeys.add(key)
|
||||||
|
validHeadKeys.add(headKey)
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
await skinPreviewStorage.cleanupInvalidKeys(validKeys)
|
||||||
|
await headStorage.cleanupInvalidKeys(validHeadKeys)
|
||||||
|
} catch (error) {
|
||||||
|
console.warn('Failed to cleanup unused skin previews:', error)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function generatePlayerHeadBlob(skinUrl: string, size: number = 64): Promise<Blob> {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
const img = new Image()
|
||||||
|
img.crossOrigin = 'anonymous'
|
||||||
|
|
||||||
|
img.onload = () => {
|
||||||
|
try {
|
||||||
|
const sourceCanvas = document.createElement('canvas')
|
||||||
|
const sourceCtx = sourceCanvas.getContext('2d')
|
||||||
|
|
||||||
|
if (!sourceCtx) {
|
||||||
|
throw new Error('Could not get 2D context from source canvas')
|
||||||
|
}
|
||||||
|
|
||||||
|
sourceCanvas.width = img.width
|
||||||
|
sourceCanvas.height = img.height
|
||||||
|
|
||||||
|
sourceCtx.drawImage(img, 0, 0)
|
||||||
|
|
||||||
|
const outputCanvas = document.createElement('canvas')
|
||||||
|
const outputCtx = outputCanvas.getContext('2d')
|
||||||
|
|
||||||
|
if (!outputCtx) {
|
||||||
|
throw new Error('Could not get 2D context from output canvas')
|
||||||
|
}
|
||||||
|
|
||||||
|
outputCanvas.width = size
|
||||||
|
outputCanvas.height = size
|
||||||
|
|
||||||
|
outputCtx.imageSmoothingEnabled = false
|
||||||
|
|
||||||
|
const headImageData = sourceCtx.getImageData(8, 8, 8, 8)
|
||||||
|
|
||||||
|
const headCanvas = document.createElement('canvas')
|
||||||
|
const headCtx = headCanvas.getContext('2d')
|
||||||
|
|
||||||
|
if (!headCtx) {
|
||||||
|
throw new Error('Could not get 2D context from head canvas')
|
||||||
|
}
|
||||||
|
|
||||||
|
headCanvas.width = 8
|
||||||
|
headCanvas.height = 8
|
||||||
|
headCtx.putImageData(headImageData, 0, 0)
|
||||||
|
|
||||||
|
outputCtx.drawImage(headCanvas, 0, 0, 8, 8, 0, 0, size, size)
|
||||||
|
|
||||||
|
const hatImageData = sourceCtx.getImageData(40, 8, 8, 8)
|
||||||
|
|
||||||
|
const hatCanvas = document.createElement('canvas')
|
||||||
|
const hatCtx = hatCanvas.getContext('2d')
|
||||||
|
|
||||||
|
if (!hatCtx) {
|
||||||
|
throw new Error('Could not get 2D context from hat canvas')
|
||||||
|
}
|
||||||
|
|
||||||
|
hatCanvas.width = 8
|
||||||
|
hatCanvas.height = 8
|
||||||
|
hatCtx.putImageData(hatImageData, 0, 0)
|
||||||
|
|
||||||
|
const hatPixels = hatImageData.data
|
||||||
|
let hasHat = false
|
||||||
|
|
||||||
|
for (let i = 3; i < hatPixels.length; i += 4) {
|
||||||
|
if (hatPixels[i] > 0) {
|
||||||
|
hasHat = true
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (hasHat) {
|
||||||
|
outputCtx.drawImage(hatCanvas, 0, 0, 8, 8, 0, 0, size, size)
|
||||||
|
}
|
||||||
|
|
||||||
|
outputCanvas.toBlob(
|
||||||
|
(blob) => {
|
||||||
|
if (blob) {
|
||||||
|
resolve(blob)
|
||||||
|
} else {
|
||||||
|
reject(new Error('Failed to create blob from canvas'))
|
||||||
|
}
|
||||||
|
},
|
||||||
|
'image/webp',
|
||||||
|
0.9,
|
||||||
|
)
|
||||||
|
} catch (error) {
|
||||||
|
reject(error)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
img.onerror = () => {
|
||||||
|
reject(new Error('Failed to load skin texture image'))
|
||||||
|
}
|
||||||
|
|
||||||
|
img.src = skinUrl
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
async function generateHeadRender(skin: Skin): Promise<string> {
|
||||||
|
const headKey = `${skin.texture_key}-head`
|
||||||
|
|
||||||
|
if (headBlobUrlMap.has(headKey)) {
|
||||||
|
if (DEBUG_MODE) {
|
||||||
|
const url = headBlobUrlMap.get(headKey)!
|
||||||
|
URL.revokeObjectURL(url)
|
||||||
|
headBlobUrlMap.delete(headKey)
|
||||||
|
} else {
|
||||||
|
return headBlobUrlMap.get(headKey)!
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const skinUrl = await get_normalized_skin_texture(skin)
|
||||||
|
const headBlob = await generatePlayerHeadBlob(skinUrl, 64)
|
||||||
|
const headUrl = URL.createObjectURL(headBlob)
|
||||||
|
|
||||||
|
headBlobUrlMap.set(headKey, headUrl)
|
||||||
|
|
||||||
|
try {
|
||||||
|
await headStorage.store(headKey, headBlob)
|
||||||
|
} catch (error) {
|
||||||
|
console.warn('Failed to store head render in persistent storage:', error)
|
||||||
|
}
|
||||||
|
|
||||||
|
return headUrl
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function getPlayerHeadUrl(skin: Skin): Promise<string> {
|
||||||
|
return await generateHeadRender(skin)
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function generateSkinPreviews(skins: Skin[], capes: Cape[]): Promise<void> {
|
||||||
|
try {
|
||||||
|
const skinKeys = skins.map(
|
||||||
|
(skin) => `${skin.texture_key}+${skin.variant}+${skin.cape_id ?? 'no-cape'}`,
|
||||||
|
)
|
||||||
|
const headKeys = skins.map((skin) => `${skin.texture_key}-head`)
|
||||||
|
|
||||||
|
const [cachedSkinPreviews, cachedHeadPreviews] = await Promise.all([
|
||||||
|
skinPreviewStorage.batchRetrieve(skinKeys),
|
||||||
|
headStorage.batchRetrieve(headKeys),
|
||||||
|
])
|
||||||
|
|
||||||
|
for (let i = 0; i < skins.length; i++) {
|
||||||
|
const skinKey = skinKeys[i]
|
||||||
|
const headKey = headKeys[i]
|
||||||
|
|
||||||
|
const rawCached = cachedSkinPreviews[skinKey]
|
||||||
|
if (rawCached) {
|
||||||
|
const cached: RenderResult = {
|
||||||
|
forwards: URL.createObjectURL(rawCached.forwards),
|
||||||
|
backwards: URL.createObjectURL(rawCached.backwards),
|
||||||
|
}
|
||||||
|
skinBlobUrlMap.set(skinKey, cached)
|
||||||
|
}
|
||||||
|
|
||||||
|
const cachedHead = cachedHeadPreviews[headKey]
|
||||||
|
if (cachedHead) {
|
||||||
|
headBlobUrlMap.set(headKey, URL.createObjectURL(cachedHead))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const skin of skins) {
|
||||||
|
const key = `${skin.texture_key}+${skin.variant}+${skin.cape_id ?? 'no-cape'}`
|
||||||
|
|
||||||
|
if (skinBlobUrlMap.has(key)) {
|
||||||
|
if (DEBUG_MODE) {
|
||||||
|
const result = skinBlobUrlMap.get(key)!
|
||||||
|
URL.revokeObjectURL(result.forwards)
|
||||||
|
URL.revokeObjectURL(result.backwards)
|
||||||
|
skinBlobUrlMap.delete(key)
|
||||||
|
} else continue
|
||||||
|
}
|
||||||
|
|
||||||
|
const renderer = getSharedRenderer()
|
||||||
|
|
||||||
|
let variant = skin.variant
|
||||||
|
if (variant === 'UNKNOWN') {
|
||||||
|
try {
|
||||||
|
variant = await determineModelType(skin.texture)
|
||||||
|
} catch (error) {
|
||||||
|
console.error(`Failed to determine model type for skin ${key}:`, error)
|
||||||
|
variant = 'CLASSIC'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const modelUrl = getModelUrlForVariant(variant)
|
||||||
|
const cape: Cape | undefined = capes.find((_cape) => _cape.id === skin.cape_id)
|
||||||
|
const rawRenderResult = await renderer.renderSkin(
|
||||||
|
await get_normalized_skin_texture(skin),
|
||||||
|
modelUrl,
|
||||||
|
cape?.texture,
|
||||||
|
)
|
||||||
|
|
||||||
|
const renderResult: RenderResult = {
|
||||||
|
forwards: URL.createObjectURL(rawRenderResult.forwards),
|
||||||
|
backwards: URL.createObjectURL(rawRenderResult.backwards),
|
||||||
|
}
|
||||||
|
|
||||||
|
skinBlobUrlMap.set(key, renderResult)
|
||||||
|
|
||||||
|
try {
|
||||||
|
await skinPreviewStorage.store(key, rawRenderResult)
|
||||||
|
} catch (error) {
|
||||||
|
console.warn('Failed to store skin preview in persistent storage:', error)
|
||||||
|
}
|
||||||
|
|
||||||
|
const headKey = `${skin.texture_key}-head`
|
||||||
|
if (!headBlobUrlMap.has(headKey)) {
|
||||||
|
await generateHeadRender(skin)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
disposeSharedRenderer()
|
||||||
|
await cleanupUnusedPreviews(skins)
|
||||||
|
|
||||||
|
await skinPreviewStorage.debugCalculateStorage()
|
||||||
|
await headStorage.debugCalculateStorage()
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -4,8 +4,9 @@
|
|||||||
* and deserialized into a usable JS object.
|
* and deserialized into a usable JS object.
|
||||||
*/
|
*/
|
||||||
import { invoke } from '@tauri-apps/api/core'
|
import { invoke } from '@tauri-apps/api/core'
|
||||||
import type { ColorTheme, FeatureFlag } from '@/store/theme.ts'
|
|
||||||
import type { Hooks, MemorySettings, WindowSize } from '@/helpers/types'
|
import type { Hooks, MemorySettings, WindowSize } from '@/helpers/types'
|
||||||
|
import type { ColorTheme, FeatureFlag } from '@/store/theme.ts'
|
||||||
|
|
||||||
// Settings object
|
// Settings object
|
||||||
/*
|
/*
|
||||||
@@ -37,6 +38,7 @@ export type AppSettings = {
|
|||||||
theme: ColorTheme
|
theme: ColorTheme
|
||||||
default_page: 'home' | 'library'
|
default_page: 'home' | 'library'
|
||||||
collapsed_navigation: boolean
|
collapsed_navigation: boolean
|
||||||
|
hide_nametag_skins_page: boolean
|
||||||
advanced_rendering: boolean
|
advanced_rendering: boolean
|
||||||
native_decorations: boolean
|
native_decorations: boolean
|
||||||
toggle_sidebar: boolean
|
toggle_sidebar: boolean
|
||||||
|
|||||||
165
apps/app-frontend/src/helpers/skins.ts
Normal file
165
apps/app-frontend/src/helpers/skins.ts
Normal file
@@ -0,0 +1,165 @@
|
|||||||
|
import { arrayBufferToBase64 } from '@modrinth/utils'
|
||||||
|
import { invoke } from '@tauri-apps/api/core'
|
||||||
|
|
||||||
|
import { handleError } from '@/store/notifications'
|
||||||
|
|
||||||
|
export interface Cape {
|
||||||
|
id: string
|
||||||
|
name: string
|
||||||
|
texture: string
|
||||||
|
is_default: boolean
|
||||||
|
is_equipped: boolean
|
||||||
|
}
|
||||||
|
|
||||||
|
export type SkinModel = 'CLASSIC' | 'SLIM' | 'UNKNOWN'
|
||||||
|
export type SkinSource = 'default' | 'custom_external' | 'custom'
|
||||||
|
|
||||||
|
export interface Skin {
|
||||||
|
texture_key: string
|
||||||
|
name?: string
|
||||||
|
variant: SkinModel
|
||||||
|
cape_id?: string
|
||||||
|
texture: string
|
||||||
|
source: SkinSource
|
||||||
|
is_equipped: boolean
|
||||||
|
}
|
||||||
|
|
||||||
|
export const DEFAULT_MODEL_SORTING = ['Steve', 'Alex'] as string[]
|
||||||
|
|
||||||
|
export const DEFAULT_MODELS: Record<string, SkinModel> = {
|
||||||
|
Steve: 'CLASSIC',
|
||||||
|
Alex: 'SLIM',
|
||||||
|
Zuri: 'CLASSIC',
|
||||||
|
Sunny: 'CLASSIC',
|
||||||
|
Noor: 'SLIM',
|
||||||
|
Makena: 'SLIM',
|
||||||
|
Kai: 'CLASSIC',
|
||||||
|
Efe: 'SLIM',
|
||||||
|
Ari: 'CLASSIC',
|
||||||
|
}
|
||||||
|
|
||||||
|
export function filterSavedSkins(list: Skin[]) {
|
||||||
|
const customSkins = list.filter((s) => s.source !== 'default')
|
||||||
|
fixUnknownSkins(customSkins).catch(handleError)
|
||||||
|
return customSkins
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function determineModelType(texture: string): Promise<'SLIM' | 'CLASSIC'> {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
const canvas = document.createElement('canvas')
|
||||||
|
const context = canvas.getContext('2d')
|
||||||
|
|
||||||
|
if (!context) {
|
||||||
|
return reject(new Error('Failed to create canvas rendering context.'))
|
||||||
|
}
|
||||||
|
|
||||||
|
const image = new Image()
|
||||||
|
image.crossOrigin = 'anonymous'
|
||||||
|
image.src = texture
|
||||||
|
|
||||||
|
image.onload = () => {
|
||||||
|
canvas.width = image.width
|
||||||
|
canvas.height = image.height
|
||||||
|
|
||||||
|
context.drawImage(image, 0, 0)
|
||||||
|
|
||||||
|
const armX = 54
|
||||||
|
const armY = 20
|
||||||
|
const armWidth = 2
|
||||||
|
const armHeight = 12
|
||||||
|
const imageData = context.getImageData(armX, armY, armWidth, armHeight).data
|
||||||
|
for (let alphaIndex = 3; alphaIndex < imageData.length; alphaIndex += 4) {
|
||||||
|
if (imageData[alphaIndex] !== 0) {
|
||||||
|
resolve('CLASSIC')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
canvas.remove()
|
||||||
|
resolve('SLIM')
|
||||||
|
}
|
||||||
|
|
||||||
|
image.onerror = () => {
|
||||||
|
canvas.remove()
|
||||||
|
reject(new Error('Failed to load the image.'))
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function fixUnknownSkins(list: Skin[]) {
|
||||||
|
const unknownSkins = list.filter((s) => s.variant === 'UNKNOWN')
|
||||||
|
for (const unknownSkin of unknownSkins) {
|
||||||
|
unknownSkin.variant = await determineModelType(unknownSkin.texture)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export function filterDefaultSkins(list: Skin[]) {
|
||||||
|
return list
|
||||||
|
.filter(
|
||||||
|
(s) =>
|
||||||
|
s.source === 'default' &&
|
||||||
|
(!s.name || !(s.name in DEFAULT_MODELS) || s.variant === DEFAULT_MODELS[s.name]),
|
||||||
|
)
|
||||||
|
.sort((a, b) => {
|
||||||
|
const aIndex = a.name ? DEFAULT_MODEL_SORTING.indexOf(a.name) : -1
|
||||||
|
const bIndex = b.name ? DEFAULT_MODEL_SORTING.indexOf(b.name) : -1
|
||||||
|
return (aIndex === -1 ? Infinity : aIndex) - (bIndex === -1 ? Infinity : bIndex)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function get_available_capes(): Promise<Cape[]> {
|
||||||
|
return invoke('plugin:minecraft-skins|get_available_capes', {})
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function get_available_skins(): Promise<Skin[]> {
|
||||||
|
return invoke('plugin:minecraft-skins|get_available_skins', {})
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function add_and_equip_custom_skin(
|
||||||
|
textureBlob: Uint8Array,
|
||||||
|
variant: SkinModel,
|
||||||
|
capeOverride?: Cape,
|
||||||
|
): Promise<void> {
|
||||||
|
await invoke('plugin:minecraft-skins|add_and_equip_custom_skin', {
|
||||||
|
textureBlob,
|
||||||
|
variant,
|
||||||
|
capeOverride,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function set_default_cape(cape?: Cape): Promise<void> {
|
||||||
|
await invoke('plugin:minecraft-skins|set_default_cape', {
|
||||||
|
cape,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function equip_skin(skin: Skin): Promise<void> {
|
||||||
|
await invoke('plugin:minecraft-skins|equip_skin', {
|
||||||
|
skin,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function remove_custom_skin(skin: Skin): Promise<void> {
|
||||||
|
await invoke('plugin:minecraft-skins|remove_custom_skin', {
|
||||||
|
skin,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function get_normalized_skin_texture(skin: Skin): Promise<string> {
|
||||||
|
const data = await normalize_skin_texture(skin.texture)
|
||||||
|
const base64 = arrayBufferToBase64(data)
|
||||||
|
return `data:image/png;base64,${base64}`
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function normalize_skin_texture(texture: Uint8Array | string): Promise<Uint8Array> {
|
||||||
|
return await invoke('plugin:minecraft-skins|normalize_skin_texture', { texture })
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function unequip_skin(): Promise<void> {
|
||||||
|
await invoke('plugin:minecraft-skins|unequip_skin')
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function get_dragged_skin_data(path: string): Promise<Uint8Array> {
|
||||||
|
const data = await invoke('plugin:minecraft-skins|get_dragged_skin_data', { path })
|
||||||
|
return new Uint8Array(data)
|
||||||
|
}
|
||||||
229
apps/app-frontend/src/helpers/storage/head-storage.ts
Normal file
229
apps/app-frontend/src/helpers/storage/head-storage.ts
Normal file
@@ -0,0 +1,229 @@
|
|||||||
|
interface StoredHead {
|
||||||
|
blob: Blob
|
||||||
|
timestamp: number
|
||||||
|
}
|
||||||
|
|
||||||
|
export class HeadStorage {
|
||||||
|
private dbName = 'head-storage'
|
||||||
|
private version = 1
|
||||||
|
private db: IDBDatabase | null = null
|
||||||
|
|
||||||
|
async init(): Promise<void> {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
const request = indexedDB.open(this.dbName, this.version)
|
||||||
|
|
||||||
|
request.onerror = () => reject(request.error)
|
||||||
|
request.onsuccess = () => {
|
||||||
|
this.db = request.result
|
||||||
|
resolve()
|
||||||
|
}
|
||||||
|
|
||||||
|
request.onupgradeneeded = () => {
|
||||||
|
const db = request.result
|
||||||
|
if (!db.objectStoreNames.contains('heads')) {
|
||||||
|
db.createObjectStore('heads')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
async store(key: string, blob: Blob): Promise<void> {
|
||||||
|
if (!this.db) await this.init()
|
||||||
|
|
||||||
|
const transaction = this.db!.transaction(['heads'], 'readwrite')
|
||||||
|
const store = transaction.objectStore('heads')
|
||||||
|
|
||||||
|
const storedHead: StoredHead = {
|
||||||
|
blob,
|
||||||
|
timestamp: Date.now(),
|
||||||
|
}
|
||||||
|
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
const request = store.put(storedHead, key)
|
||||||
|
|
||||||
|
request.onsuccess = () => resolve()
|
||||||
|
request.onerror = () => reject(request.error)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
async retrieve(key: string): Promise<string | null> {
|
||||||
|
if (!this.db) await this.init()
|
||||||
|
|
||||||
|
const transaction = this.db!.transaction(['heads'], 'readonly')
|
||||||
|
const store = transaction.objectStore('heads')
|
||||||
|
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
const request = store.get(key)
|
||||||
|
|
||||||
|
request.onsuccess = () => {
|
||||||
|
const result = request.result as StoredHead | undefined
|
||||||
|
|
||||||
|
if (!result) {
|
||||||
|
resolve(null)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
const url = URL.createObjectURL(result.blob)
|
||||||
|
resolve(url)
|
||||||
|
}
|
||||||
|
request.onerror = () => reject(request.error)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
async batchRetrieve(keys: string[]): Promise<Record<string, Blob | null>> {
|
||||||
|
if (!this.db) await this.init()
|
||||||
|
|
||||||
|
const transaction = this.db!.transaction(['heads'], 'readonly')
|
||||||
|
const store = transaction.objectStore('heads')
|
||||||
|
const results: Record<string, Blob | null> = {}
|
||||||
|
|
||||||
|
return new Promise((resolve, _reject) => {
|
||||||
|
let completedRequests = 0
|
||||||
|
|
||||||
|
if (keys.length === 0) {
|
||||||
|
resolve(results)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const key of keys) {
|
||||||
|
const request = store.get(key)
|
||||||
|
|
||||||
|
request.onsuccess = () => {
|
||||||
|
const result = request.result as StoredHead | undefined
|
||||||
|
|
||||||
|
if (result) {
|
||||||
|
results[key] = result.blob
|
||||||
|
} else {
|
||||||
|
results[key] = null
|
||||||
|
}
|
||||||
|
|
||||||
|
completedRequests++
|
||||||
|
if (completedRequests === keys.length) {
|
||||||
|
resolve(results)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
request.onerror = () => {
|
||||||
|
results[key] = null
|
||||||
|
completedRequests++
|
||||||
|
if (completedRequests === keys.length) {
|
||||||
|
resolve(results)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
async cleanupInvalidKeys(validKeys: Set<string>): Promise<number> {
|
||||||
|
if (!this.db) await this.init()
|
||||||
|
|
||||||
|
const transaction = this.db!.transaction(['heads'], 'readwrite')
|
||||||
|
const store = transaction.objectStore('heads')
|
||||||
|
let deletedCount = 0
|
||||||
|
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
const request = store.openCursor()
|
||||||
|
|
||||||
|
request.onsuccess = (event) => {
|
||||||
|
const cursor = (event.target as IDBRequest<IDBCursorWithValue>).result
|
||||||
|
|
||||||
|
if (cursor) {
|
||||||
|
const key = cursor.primaryKey as string
|
||||||
|
|
||||||
|
if (!validKeys.has(key)) {
|
||||||
|
const deleteRequest = cursor.delete()
|
||||||
|
deleteRequest.onsuccess = () => {
|
||||||
|
deletedCount++
|
||||||
|
}
|
||||||
|
deleteRequest.onerror = () => {
|
||||||
|
console.warn('Failed to delete invalid head entry:', key)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
cursor.continue()
|
||||||
|
} else {
|
||||||
|
resolve(deletedCount)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
request.onerror = () => reject(request.error)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
async debugCalculateStorage(): Promise<void> {
|
||||||
|
if (!this.db) await this.init()
|
||||||
|
|
||||||
|
const transaction = this.db!.transaction(['heads'], 'readonly')
|
||||||
|
const store = transaction.objectStore('heads')
|
||||||
|
|
||||||
|
let totalSize = 0
|
||||||
|
let count = 0
|
||||||
|
const entries: Array<{ key: string; size: number }> = []
|
||||||
|
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
const request = store.openCursor()
|
||||||
|
|
||||||
|
request.onsuccess = (event) => {
|
||||||
|
const cursor = (event.target as IDBRequest<IDBCursorWithValue>).result
|
||||||
|
|
||||||
|
if (cursor) {
|
||||||
|
const key = cursor.primaryKey as string
|
||||||
|
const value = cursor.value as StoredHead
|
||||||
|
|
||||||
|
const entrySize = value.blob.size
|
||||||
|
totalSize += entrySize
|
||||||
|
count++
|
||||||
|
|
||||||
|
entries.push({
|
||||||
|
key,
|
||||||
|
size: entrySize,
|
||||||
|
})
|
||||||
|
|
||||||
|
cursor.continue()
|
||||||
|
} else {
|
||||||
|
console.group('🗄️ Head Storage Debug Info')
|
||||||
|
console.log(`Total entries: ${count}`)
|
||||||
|
console.log(`Total size: ${(totalSize / 1024 / 1024).toFixed(2)} MB`)
|
||||||
|
console.log(
|
||||||
|
`Average size per entry: ${count > 0 ? (totalSize / count / 1024).toFixed(2) : 0} KB`,
|
||||||
|
)
|
||||||
|
|
||||||
|
if (entries.length > 0) {
|
||||||
|
const sortedEntries = entries.sort((a, b) => b.size - a.size)
|
||||||
|
console.log(
|
||||||
|
'Largest entry:',
|
||||||
|
sortedEntries[0].key,
|
||||||
|
'(' + (sortedEntries[0].size / 1024).toFixed(2) + ' KB)',
|
||||||
|
)
|
||||||
|
console.log(
|
||||||
|
'Smallest entry:',
|
||||||
|
sortedEntries[sortedEntries.length - 1].key,
|
||||||
|
'(' + (sortedEntries[sortedEntries.length - 1].size / 1024).toFixed(2) + ' KB)',
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
console.groupEnd()
|
||||||
|
resolve()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
request.onerror = () => reject(request.error)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
async clearAll(): Promise<void> {
|
||||||
|
if (!this.db) await this.init()
|
||||||
|
|
||||||
|
const transaction = this.db!.transaction(['heads'], 'readwrite')
|
||||||
|
const store = transaction.objectStore('heads')
|
||||||
|
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
const request = store.clear()
|
||||||
|
|
||||||
|
request.onsuccess = () => resolve()
|
||||||
|
request.onerror = () => reject(request.error)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export const headStorage = new HeadStorage()
|
||||||
218
apps/app-frontend/src/helpers/storage/skin-preview-storage.ts
Normal file
218
apps/app-frontend/src/helpers/storage/skin-preview-storage.ts
Normal file
@@ -0,0 +1,218 @@
|
|||||||
|
import type { RawRenderResult } from '../rendering/batch-skin-renderer'
|
||||||
|
|
||||||
|
interface StoredPreview {
|
||||||
|
forwards: Blob
|
||||||
|
backwards: Blob
|
||||||
|
timestamp: number
|
||||||
|
}
|
||||||
|
|
||||||
|
export class SkinPreviewStorage {
|
||||||
|
private dbName = 'skin-previews'
|
||||||
|
private version = 1
|
||||||
|
private db: IDBDatabase | null = null
|
||||||
|
|
||||||
|
async init(): Promise<void> {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
const request = indexedDB.open(this.dbName, this.version)
|
||||||
|
|
||||||
|
request.onerror = () => reject(request.error)
|
||||||
|
request.onsuccess = () => {
|
||||||
|
this.db = request.result
|
||||||
|
resolve()
|
||||||
|
}
|
||||||
|
|
||||||
|
request.onupgradeneeded = () => {
|
||||||
|
const db = request.result
|
||||||
|
if (!db.objectStoreNames.contains('previews')) {
|
||||||
|
db.createObjectStore('previews')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
async store(key: string, result: RawRenderResult): Promise<void> {
|
||||||
|
if (!this.db) await this.init()
|
||||||
|
|
||||||
|
const transaction = this.db!.transaction(['previews'], 'readwrite')
|
||||||
|
const store = transaction.objectStore('previews')
|
||||||
|
|
||||||
|
const storedPreview: StoredPreview = {
|
||||||
|
forwards: result.forwards,
|
||||||
|
backwards: result.backwards,
|
||||||
|
timestamp: Date.now(),
|
||||||
|
}
|
||||||
|
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
const request = store.put(storedPreview, key)
|
||||||
|
|
||||||
|
request.onsuccess = () => resolve()
|
||||||
|
request.onerror = () => reject(request.error)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
async retrieve(key: string): Promise<RawRenderResult | null> {
|
||||||
|
if (!this.db) await this.init()
|
||||||
|
|
||||||
|
const transaction = this.db!.transaction(['previews'], 'readonly')
|
||||||
|
const store = transaction.objectStore('previews')
|
||||||
|
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
const request = store.get(key)
|
||||||
|
|
||||||
|
request.onsuccess = () => {
|
||||||
|
const result = request.result as StoredPreview | undefined
|
||||||
|
|
||||||
|
if (!result) {
|
||||||
|
resolve(null)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
resolve({ forwards: result.forwards, backwards: result.backwards })
|
||||||
|
}
|
||||||
|
request.onerror = () => reject(request.error)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
async batchRetrieve(keys: string[]): Promise<Record<string, RawRenderResult | null>> {
|
||||||
|
if (!this.db) await this.init()
|
||||||
|
|
||||||
|
const transaction = this.db!.transaction(['previews'], 'readonly')
|
||||||
|
const store = transaction.objectStore('previews')
|
||||||
|
const results: Record<string, RawRenderResult | null> = {}
|
||||||
|
|
||||||
|
return new Promise((resolve, _reject) => {
|
||||||
|
let completedRequests = 0
|
||||||
|
|
||||||
|
if (keys.length === 0) {
|
||||||
|
resolve(results)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const key of keys) {
|
||||||
|
const request = store.get(key)
|
||||||
|
|
||||||
|
request.onsuccess = () => {
|
||||||
|
const result = request.result as StoredPreview | undefined
|
||||||
|
|
||||||
|
if (result) {
|
||||||
|
results[key] = { forwards: result.forwards, backwards: result.backwards }
|
||||||
|
} else {
|
||||||
|
results[key] = null
|
||||||
|
}
|
||||||
|
|
||||||
|
completedRequests++
|
||||||
|
if (completedRequests === keys.length) {
|
||||||
|
resolve(results)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
request.onerror = () => {
|
||||||
|
results[key] = null
|
||||||
|
completedRequests++
|
||||||
|
if (completedRequests === keys.length) {
|
||||||
|
resolve(results)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
async cleanupInvalidKeys(validKeys: Set<string>): Promise<number> {
|
||||||
|
if (!this.db) await this.init()
|
||||||
|
|
||||||
|
const transaction = this.db!.transaction(['previews'], 'readwrite')
|
||||||
|
const store = transaction.objectStore('previews')
|
||||||
|
let deletedCount = 0
|
||||||
|
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
const request = store.openCursor()
|
||||||
|
|
||||||
|
request.onsuccess = (event) => {
|
||||||
|
const cursor = (event.target as IDBRequest<IDBCursorWithValue>).result
|
||||||
|
|
||||||
|
if (cursor) {
|
||||||
|
const key = cursor.primaryKey as string
|
||||||
|
|
||||||
|
if (!validKeys.has(key)) {
|
||||||
|
const deleteRequest = cursor.delete()
|
||||||
|
deleteRequest.onsuccess = () => {
|
||||||
|
deletedCount++
|
||||||
|
}
|
||||||
|
deleteRequest.onerror = () => {
|
||||||
|
console.warn('Failed to delete invalid entry:', key)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
cursor.continue()
|
||||||
|
} else {
|
||||||
|
resolve(deletedCount)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
request.onerror = () => reject(request.error)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
async debugCalculateStorage(): Promise<void> {
|
||||||
|
if (!this.db) await this.init()
|
||||||
|
|
||||||
|
const transaction = this.db!.transaction(['previews'], 'readonly')
|
||||||
|
const store = transaction.objectStore('previews')
|
||||||
|
|
||||||
|
let totalSize = 0
|
||||||
|
let count = 0
|
||||||
|
const entries: Array<{ key: string; size: number }> = []
|
||||||
|
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
const request = store.openCursor()
|
||||||
|
|
||||||
|
request.onsuccess = (event) => {
|
||||||
|
const cursor = (event.target as IDBRequest<IDBCursorWithValue>).result
|
||||||
|
|
||||||
|
if (cursor) {
|
||||||
|
const key = cursor.primaryKey as string
|
||||||
|
const value = cursor.value as StoredPreview
|
||||||
|
|
||||||
|
const entrySize = value.forwards.size + value.backwards.size
|
||||||
|
totalSize += entrySize
|
||||||
|
count++
|
||||||
|
|
||||||
|
entries.push({
|
||||||
|
key,
|
||||||
|
size: entrySize,
|
||||||
|
})
|
||||||
|
|
||||||
|
cursor.continue()
|
||||||
|
} else {
|
||||||
|
console.group('🗄️ Skin Preview Storage Debug Info')
|
||||||
|
console.log(`Total entries: ${count}`)
|
||||||
|
console.log(`Total size: ${(totalSize / 1024 / 1024).toFixed(2)} MB`)
|
||||||
|
console.log(
|
||||||
|
`Average size per entry: ${count > 0 ? (totalSize / count / 1024).toFixed(2) : 0} KB`,
|
||||||
|
)
|
||||||
|
|
||||||
|
if (entries.length > 0) {
|
||||||
|
const sortedEntries = entries.sort((a, b) => b.size - a.size)
|
||||||
|
console.log(
|
||||||
|
'Largest entry:',
|
||||||
|
sortedEntries[0].key,
|
||||||
|
'(' + (sortedEntries[0].size / 1024).toFixed(2) + ' KB)',
|
||||||
|
)
|
||||||
|
console.log(
|
||||||
|
'Smallest entry:',
|
||||||
|
sortedEntries[sortedEntries.length - 1].key,
|
||||||
|
'(' + (sortedEntries[sortedEntries.length - 1].size / 1024).toFixed(2) + ' KB)',
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
console.groupEnd()
|
||||||
|
resolve()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
request.onerror = () => reject(request.error)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export const skinPreviewStorage = new SkinPreviewStorage()
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
import { get_full_path, get_mod_full_path } from '@/helpers/profile'
|
|
||||||
import { invoke } from '@tauri-apps/api/core'
|
import { invoke } from '@tauri-apps/api/core'
|
||||||
|
|
||||||
|
import { get_full_path, get_mod_full_path } from '@/helpers/profile'
|
||||||
|
|
||||||
export async function isDev() {
|
export async function isDev() {
|
||||||
return await invoke('is_dev')
|
return await invoke('is_dev')
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,10 @@
|
|||||||
|
import { autoToHTML } from '@geometrically/minecraft-motd-parser'
|
||||||
|
import type { GameVersion } from '@modrinth/ui'
|
||||||
import { invoke } from '@tauri-apps/api/core'
|
import { invoke } from '@tauri-apps/api/core'
|
||||||
|
import dayjs from 'dayjs'
|
||||||
|
|
||||||
import { get_full_path } from '@/helpers/profile'
|
import { get_full_path } from '@/helpers/profile'
|
||||||
import { openPath } from '@/helpers/utils'
|
import { openPath } from '@/helpers/utils'
|
||||||
import { autoToHTML } from '@geometrically/minecraft-motd-parser'
|
|
||||||
import dayjs from 'dayjs'
|
|
||||||
import type { GameVersion } from '@modrinth/ui'
|
|
||||||
|
|
||||||
type BaseWorld = {
|
type BaseWorld = {
|
||||||
name: string
|
name: string
|
||||||
@@ -51,6 +52,7 @@ export type ServerStatus = {
|
|||||||
version?: {
|
version?: {
|
||||||
name: string
|
name: string
|
||||||
protocol: number
|
protocol: number
|
||||||
|
legacy: boolean
|
||||||
}
|
}
|
||||||
favicon?: string
|
favicon?: string
|
||||||
enforces_secure_chat: boolean
|
enforces_secure_chat: boolean
|
||||||
@@ -70,11 +72,17 @@ export interface Chat {
|
|||||||
|
|
||||||
export type ServerData = {
|
export type ServerData = {
|
||||||
refreshing: boolean
|
refreshing: boolean
|
||||||
|
lastSuccessfulRefresh?: number
|
||||||
status?: ServerStatus
|
status?: ServerStatus
|
||||||
rawMotd?: string | Chat
|
rawMotd?: string | Chat
|
||||||
renderedMotd?: string
|
renderedMotd?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export type ProtocolVersion = {
|
||||||
|
version: number
|
||||||
|
legacy: boolean
|
||||||
|
}
|
||||||
|
|
||||||
export async function get_recent_worlds(
|
export async function get_recent_worlds(
|
||||||
limit: number,
|
limit: number,
|
||||||
displayStatuses?: DisplayStatus[],
|
displayStatuses?: DisplayStatus[],
|
||||||
@@ -156,13 +164,13 @@ export async function remove_server_from_profile(path: string, index: number): P
|
|||||||
return await invoke('plugin:worlds|remove_server_from_profile', { path, index })
|
return await invoke('plugin:worlds|remove_server_from_profile', { path, index })
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function get_profile_protocol_version(path: string): Promise<number | null> {
|
export async function get_profile_protocol_version(path: string): Promise<ProtocolVersion | null> {
|
||||||
return await invoke('plugin:worlds|get_profile_protocol_version', { path })
|
return await invoke('plugin:worlds|get_profile_protocol_version', { path })
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function get_server_status(
|
export async function get_server_status(
|
||||||
address: string,
|
address: string,
|
||||||
protocolVersion: number | null = null,
|
protocolVersion: ProtocolVersion | null = null,
|
||||||
): Promise<ServerStatus> {
|
): Promise<ServerStatus> {
|
||||||
return await invoke('plugin:worlds|get_server_status', { address, protocolVersion })
|
return await invoke('plugin:worlds|get_server_status', { address, protocolVersion })
|
||||||
}
|
}
|
||||||
@@ -206,30 +214,39 @@ export function isServerWorld(world: World): world is ServerWorld {
|
|||||||
|
|
||||||
export async function refreshServerData(
|
export async function refreshServerData(
|
||||||
serverData: ServerData,
|
serverData: ServerData,
|
||||||
protocolVersion: number | null,
|
protocolVersion: ProtocolVersion | null,
|
||||||
address: string,
|
address: string,
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
|
const refreshTime = Date.now()
|
||||||
serverData.refreshing = true
|
serverData.refreshing = true
|
||||||
await get_server_status(address, protocolVersion)
|
await get_server_status(address, protocolVersion)
|
||||||
.then((status) => {
|
.then((status) => {
|
||||||
|
if (serverData.lastSuccessfulRefresh && serverData.lastSuccessfulRefresh > refreshTime) {
|
||||||
|
// Don't update if there was a more recent successful refresh
|
||||||
|
return
|
||||||
|
}
|
||||||
|
serverData.lastSuccessfulRefresh = Date.now()
|
||||||
serverData.status = status
|
serverData.status = status
|
||||||
if (status.description) {
|
if (status.description) {
|
||||||
serverData.rawMotd = status.description
|
serverData.rawMotd = status.description
|
||||||
serverData.renderedMotd = autoToHTML(status.description)
|
serverData.renderedMotd = autoToHTML(status.description)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.catch((err) => {
|
|
||||||
console.error(`Refreshing addr: ${address}`, err)
|
|
||||||
})
|
|
||||||
.finally(() => {
|
.finally(() => {
|
||||||
serverData.refreshing = false
|
serverData.refreshing = false
|
||||||
})
|
})
|
||||||
|
.catch((err) => {
|
||||||
|
console.error(`Refreshing addr ${address}`, protocolVersion, err)
|
||||||
|
if (!protocolVersion?.legacy) {
|
||||||
|
refreshServerData(serverData, { version: 74, legacy: true }, address)
|
||||||
|
}
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function refreshServers(
|
export function refreshServers(
|
||||||
worlds: World[],
|
worlds: World[],
|
||||||
serverData: Record<string, ServerData>,
|
serverData: Record<string, ServerData>,
|
||||||
protocolVersion: number | null,
|
protocolVersion: ProtocolVersion | null,
|
||||||
) {
|
) {
|
||||||
const servers = worlds.filter(isServerWorld)
|
const servers = worlds.filter(isServerWorld)
|
||||||
servers.forEach((server) => {
|
servers.forEach((server) => {
|
||||||
@@ -243,10 +260,8 @@ export async function refreshServers(
|
|||||||
})
|
})
|
||||||
|
|
||||||
// noinspection ES6MissingAwait - handled with .then by refreshServerData already
|
// noinspection ES6MissingAwait - handled with .then by refreshServerData already
|
||||||
Promise.all(
|
Object.keys(serverData).forEach((address) =>
|
||||||
Object.keys(serverData).map((address) =>
|
refreshServerData(serverData[address], protocolVersion, address),
|
||||||
refreshServerData(serverData[address], protocolVersion, address),
|
|
||||||
),
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -297,15 +312,24 @@ export async function refreshWorlds(instancePath: string): Promise<World[]> {
|
|||||||
return worlds ?? []
|
return worlds ?? []
|
||||||
}
|
}
|
||||||
|
|
||||||
const FIRST_QUICK_PLAY_VERSION = '23w14a'
|
export function hasServerQuickPlaySupport(gameVersions: GameVersion[], currentVersion: string) {
|
||||||
|
if (!gameVersions.length) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
export function hasQuickPlaySupport(gameVersions: GameVersion[], currentVersion: string) {
|
const versionIndex = gameVersions.findIndex((v) => v.version === currentVersion)
|
||||||
|
const targetIndex = gameVersions.findIndex((v) => v.version === 'a1.0.5_01')
|
||||||
|
|
||||||
|
return versionIndex === -1 || targetIndex === -1 || versionIndex <= targetIndex
|
||||||
|
}
|
||||||
|
|
||||||
|
export function hasWorldQuickPlaySupport(gameVersions: GameVersion[], currentVersion: string) {
|
||||||
if (!gameVersions.length) {
|
if (!gameVersions.length) {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
const versionIndex = gameVersions.findIndex((v) => v.version === currentVersion)
|
const versionIndex = gameVersions.findIndex((v) => v.version === currentVersion)
|
||||||
const targetIndex = gameVersions.findIndex((v) => v.version === FIRST_QUICK_PLAY_VERSION)
|
const targetIndex = gameVersions.findIndex((v) => v.version === '23w14a')
|
||||||
|
|
||||||
return versionIndex !== -1 && targetIndex !== -1 && versionIndex <= targetIndex
|
return versionIndex !== -1 && targetIndex !== -1 && versionIndex <= targetIndex
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -377,11 +377,17 @@
|
|||||||
"instance.worlds.hardcore": {
|
"instance.worlds.hardcore": {
|
||||||
"message": "Hardcore mode"
|
"message": "Hardcore mode"
|
||||||
},
|
},
|
||||||
"instance.worlds.no_quick_play": {
|
"instance.worlds.incompatible_server": {
|
||||||
"message": "You can only jump straight into worlds on Minecraft 1.20+"
|
"message": "Server is incompatible"
|
||||||
},
|
},
|
||||||
"instance.worlds.play_anyway": {
|
"instance.worlds.no_contact": {
|
||||||
"message": "Play anyway"
|
"message": "Server couldn't be contacted"
|
||||||
|
},
|
||||||
|
"instance.worlds.no_server_quick_play": {
|
||||||
|
"message": "You can only jump straight into servers on Minecraft Alpha 1.0.5+"
|
||||||
|
},
|
||||||
|
"instance.worlds.no_singleplayer_quick_play": {
|
||||||
|
"message": "You can only jump straight into singleplayer worlds on Minecraft 1.20+"
|
||||||
},
|
},
|
||||||
"instance.worlds.play_instance": {
|
"instance.worlds.play_instance": {
|
||||||
"message": "Play instance"
|
"message": "Play instance"
|
||||||
|
|||||||
@@ -1,12 +1,14 @@
|
|||||||
import { createApp } from 'vue'
|
|
||||||
import router from '@/routes'
|
|
||||||
import App from '@/App.vue'
|
|
||||||
import { createPinia } from 'pinia'
|
|
||||||
import FloatingVue from 'floating-vue'
|
|
||||||
import 'floating-vue/dist/style.css'
|
import 'floating-vue/dist/style.css'
|
||||||
import { createPlugin } from '@vintl/vintl/plugin'
|
|
||||||
import * as Sentry from '@sentry/vue'
|
import * as Sentry from '@sentry/vue'
|
||||||
import { VueScanPlugin } from '@taijased/vue-render-tracker'
|
import { VueScanPlugin } from '@taijased/vue-render-tracker'
|
||||||
|
import { createPlugin } from '@vintl/vintl/plugin'
|
||||||
|
import FloatingVue from 'floating-vue'
|
||||||
|
import { createPinia } from 'pinia'
|
||||||
|
import { createApp } from 'vue'
|
||||||
|
|
||||||
|
import App from '@/App.vue'
|
||||||
|
import router from '@/routes'
|
||||||
|
|
||||||
const VIntlPlugin = createPlugin({
|
const VIntlPlugin = createPlugin({
|
||||||
controllerOpts: {
|
controllerOpts: {
|
||||||
|
|||||||
@@ -1,32 +1,33 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { computed, nextTick, ref, shallowRef, watch } from 'vue'
|
import { ClipboardCopyIcon, ExternalIcon, GlobeIcon, SearchIcon, XIcon } from '@modrinth/assets'
|
||||||
import type { Ref } from 'vue'
|
|
||||||
import { SearchIcon, XIcon, ClipboardCopyIcon, GlobeIcon, ExternalIcon } from '@modrinth/assets'
|
|
||||||
import type { Category, GameVersion, Platform, ProjectType, SortType, Tags } from '@modrinth/ui'
|
import type { Category, GameVersion, Platform, ProjectType, SortType, Tags } from '@modrinth/ui'
|
||||||
import {
|
import {
|
||||||
SearchFilterControl,
|
|
||||||
SearchSidebarFilter,
|
|
||||||
Button,
|
Button,
|
||||||
Checkbox,
|
Checkbox,
|
||||||
DropdownSelect,
|
DropdownSelect,
|
||||||
LoadingIndicator,
|
LoadingIndicator,
|
||||||
Pagination,
|
Pagination,
|
||||||
|
SearchFilterControl,
|
||||||
|
SearchSidebarFilter,
|
||||||
useSearch,
|
useSearch,
|
||||||
} from '@modrinth/ui'
|
} from '@modrinth/ui'
|
||||||
import { handleError } from '@/store/state'
|
import { openUrl } from '@tauri-apps/plugin-opener'
|
||||||
import { useBreadcrumbs } from '@/store/breadcrumbs'
|
import { defineMessages, useVIntl } from '@vintl/vintl'
|
||||||
import { get_categories, get_game_versions, get_loaders } from '@/helpers/tags'
|
import type { Ref } from 'vue'
|
||||||
|
import { computed, nextTick, ref, shallowRef, watch } from 'vue'
|
||||||
import type { LocationQuery } from 'vue-router'
|
import type { LocationQuery } from 'vue-router'
|
||||||
import { useRoute, useRouter } from 'vue-router'
|
import { useRoute, useRouter } from 'vue-router'
|
||||||
import SearchCard from '@/components/ui/SearchCard.vue'
|
|
||||||
import { get as getInstance, get_projects as getInstanceProjects } from '@/helpers/profile.js'
|
import ContextMenu from '@/components/ui/ContextMenu.vue'
|
||||||
import { get_search_results } from '@/helpers/cache.js'
|
|
||||||
import NavTabs from '@/components/ui/NavTabs.vue'
|
|
||||||
import type Instance from '@/components/ui/Instance.vue'
|
import type Instance from '@/components/ui/Instance.vue'
|
||||||
import InstanceIndicator from '@/components/ui/InstanceIndicator.vue'
|
import InstanceIndicator from '@/components/ui/InstanceIndicator.vue'
|
||||||
import { defineMessages, useVIntl } from '@vintl/vintl'
|
import NavTabs from '@/components/ui/NavTabs.vue'
|
||||||
import ContextMenu from '@/components/ui/ContextMenu.vue'
|
import SearchCard from '@/components/ui/SearchCard.vue'
|
||||||
import { openUrl } from '@tauri-apps/plugin-opener'
|
import { get_search_results } from '@/helpers/cache.js'
|
||||||
|
import { get as getInstance, get_projects as getInstanceProjects } from '@/helpers/profile.js'
|
||||||
|
import { get_categories, get_game_versions, get_loaders } from '@/helpers/tags'
|
||||||
|
import { useBreadcrumbs } from '@/store/breadcrumbs'
|
||||||
|
import { handleError } from '@/store/state'
|
||||||
|
|
||||||
const { formatMessage } = useVIntl()
|
const { formatMessage } = useVIntl()
|
||||||
|
|
||||||
@@ -220,6 +221,7 @@ async function refreshSearch() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
results.value = rawResults.result
|
results.value = rawResults.result
|
||||||
|
currentPage.value = 1
|
||||||
|
|
||||||
const persistentParams: LocationQuery = {}
|
const persistentParams: LocationQuery = {}
|
||||||
|
|
||||||
@@ -265,6 +267,7 @@ async function onSearchChangeToTop() {
|
|||||||
|
|
||||||
function clearSearch() {
|
function clearSearch() {
|
||||||
query.value = ''
|
query.value = ''
|
||||||
|
currentPage.value = 1
|
||||||
}
|
}
|
||||||
|
|
||||||
watch(
|
watch(
|
||||||
|
|||||||
@@ -1,15 +1,17 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref, onUnmounted, computed } from 'vue'
|
import type { SearchResult } from '@modrinth/utils'
|
||||||
|
import dayjs from 'dayjs'
|
||||||
|
import { computed, onUnmounted, ref } from 'vue'
|
||||||
import { useRoute } from 'vue-router'
|
import { useRoute } from 'vue-router'
|
||||||
|
|
||||||
import RowDisplay from '@/components/RowDisplay.vue'
|
import RowDisplay from '@/components/RowDisplay.vue'
|
||||||
import { list } from '@/helpers/profile.js'
|
import RecentWorldsList from '@/components/ui/world/RecentWorldsList.vue'
|
||||||
|
import { get_search_results } from '@/helpers/cache.js'
|
||||||
import { profile_listener } from '@/helpers/events'
|
import { profile_listener } from '@/helpers/events'
|
||||||
|
import { list } from '@/helpers/profile.js'
|
||||||
|
import type { GameInstance } from '@/helpers/types'
|
||||||
import { useBreadcrumbs } from '@/store/breadcrumbs'
|
import { useBreadcrumbs } from '@/store/breadcrumbs'
|
||||||
import { handleError } from '@/store/notifications.js'
|
import { handleError } from '@/store/notifications.js'
|
||||||
import dayjs from 'dayjs'
|
|
||||||
import { get_search_results } from '@/helpers/cache.js'
|
|
||||||
import type { SearchResult } from '@modrinth/utils'
|
|
||||||
import RecentWorldsList from '@/components/ui/world/RecentWorldsList.vue'
|
|
||||||
|
|
||||||
const route = useRoute()
|
const route = useRoute()
|
||||||
const breadcrumbs = useBreadcrumbs()
|
const breadcrumbs = useBreadcrumbs()
|
||||||
@@ -82,13 +84,15 @@ async function refreshFeaturedProjects() {
|
|||||||
await fetchInstances()
|
await fetchInstances()
|
||||||
await refreshFeaturedProjects()
|
await refreshFeaturedProjects()
|
||||||
|
|
||||||
const unlistenProfile = await profile_listener(async (e) => {
|
const unlistenProfile = await profile_listener(
|
||||||
await fetchInstances()
|
async (e: { event: string; profile_path_id: string }) => {
|
||||||
|
await fetchInstances()
|
||||||
|
|
||||||
if (e.event === 'added' || e.event === 'created' || e.event === 'removed') {
|
if (e.event === 'added' || e.event === 'created' || e.event === 'removed') {
|
||||||
await refreshFeaturedProjects()
|
await refreshFeaturedProjects()
|
||||||
}
|
}
|
||||||
})
|
},
|
||||||
|
)
|
||||||
|
|
||||||
onUnmounted(() => {
|
onUnmounted(() => {
|
||||||
unlistenProfile()
|
unlistenProfile()
|
||||||
@@ -97,8 +101,8 @@ onUnmounted(() => {
|
|||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div class="p-6 flex flex-col gap-2">
|
<div class="p-6 flex flex-col gap-2">
|
||||||
<h1 v-if="recentInstances" class="m-0 text-2xl">Welcome back!</h1>
|
<h1 v-if="recentInstances?.length > 0" class="m-0 text-2xl font-extrabold">Welcome back!</h1>
|
||||||
<h1 v-else class="m-0 text-2xl">Welcome to Modrinth App!</h1>
|
<h1 v-else class="m-0 text-2xl font-extrabold">Welcome to Modrinth App!</h1>
|
||||||
<RecentWorldsList :recent-instances="recentInstances" />
|
<RecentWorldsList :recent-instances="recentInstances" />
|
||||||
<RowDisplay
|
<RowDisplay
|
||||||
v-if="hasFeaturedProjects"
|
v-if="hasFeaturedProjects"
|
||||||
|
|||||||
522
apps/app-frontend/src/pages/Skins.vue
Normal file
522
apps/app-frontend/src/pages/Skins.vue
Normal file
@@ -0,0 +1,522 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import {
|
||||||
|
EditIcon,
|
||||||
|
ExcitedRinthbot,
|
||||||
|
LogInIcon,
|
||||||
|
PlusIcon,
|
||||||
|
SpinnerIcon,
|
||||||
|
TrashIcon,
|
||||||
|
UpdatedIcon,
|
||||||
|
} from '@modrinth/assets'
|
||||||
|
import {
|
||||||
|
Button,
|
||||||
|
ButtonStyled,
|
||||||
|
ConfirmModal,
|
||||||
|
SkinButton,
|
||||||
|
SkinLikeTextButton,
|
||||||
|
SkinPreviewRenderer,
|
||||||
|
} from '@modrinth/ui'
|
||||||
|
import { arrayBufferToBase64 } from '@modrinth/utils'
|
||||||
|
import { computedAsync } from '@vueuse/core'
|
||||||
|
import type { Ref } from 'vue'
|
||||||
|
import { computed, inject, onMounted, onUnmounted, ref, useTemplateRef, watch } from 'vue'
|
||||||
|
|
||||||
|
import type AccountsCard from '@/components/ui/AccountsCard.vue'
|
||||||
|
import EditSkinModal from '@/components/ui/skin/EditSkinModal.vue'
|
||||||
|
import SelectCapeModal from '@/components/ui/skin/SelectCapeModal.vue'
|
||||||
|
import UploadSkinModal from '@/components/ui/skin/UploadSkinModal.vue'
|
||||||
|
import { trackEvent } from '@/helpers/analytics'
|
||||||
|
import { get_default_user, login as login_flow, users } from '@/helpers/auth'
|
||||||
|
import type { RenderResult } from '@/helpers/rendering/batch-skin-renderer.ts'
|
||||||
|
import { generateSkinPreviews, skinBlobUrlMap } from '@/helpers/rendering/batch-skin-renderer.ts'
|
||||||
|
import { get as getSettings } from '@/helpers/settings.ts'
|
||||||
|
import type { Cape, Skin } from '@/helpers/skins.ts'
|
||||||
|
import {
|
||||||
|
equip_skin,
|
||||||
|
filterDefaultSkins,
|
||||||
|
filterSavedSkins,
|
||||||
|
get_available_capes,
|
||||||
|
get_available_skins,
|
||||||
|
get_normalized_skin_texture,
|
||||||
|
normalize_skin_texture,
|
||||||
|
remove_custom_skin,
|
||||||
|
set_default_cape,
|
||||||
|
} from '@/helpers/skins.ts'
|
||||||
|
import { handleSevereError } from '@/store/error'
|
||||||
|
import { handleError, useNotifications } from '@/store/notifications'
|
||||||
|
const editSkinModal = useTemplateRef('editSkinModal')
|
||||||
|
const selectCapeModal = useTemplateRef('selectCapeModal')
|
||||||
|
const uploadSkinModal = useTemplateRef('uploadSkinModal')
|
||||||
|
|
||||||
|
const notifications = useNotifications()
|
||||||
|
|
||||||
|
const settings = ref(await getSettings())
|
||||||
|
const skins = ref<Skin[]>([])
|
||||||
|
const capes = ref<Cape[]>([])
|
||||||
|
|
||||||
|
const accountsCard = inject('accountsCard') as Ref<typeof AccountsCard>
|
||||||
|
const currentUser = ref(undefined)
|
||||||
|
const currentUserId = ref<string | undefined>(undefined)
|
||||||
|
|
||||||
|
const username = computed(() => currentUser.value?.profile?.name ?? undefined)
|
||||||
|
const selectedSkin = ref<Skin | null>(null)
|
||||||
|
const defaultCape = ref<Cape>()
|
||||||
|
|
||||||
|
const originalSelectedSkin = ref<Skin | null>(null)
|
||||||
|
const originalDefaultCape = ref<Cape>()
|
||||||
|
|
||||||
|
const savedSkins = computed(() => filterSavedSkins(skins.value))
|
||||||
|
const defaultSkins = computed(() => filterDefaultSkins(skins.value))
|
||||||
|
|
||||||
|
const currentCape = computed(() => {
|
||||||
|
if (selectedSkin.value?.cape_id) {
|
||||||
|
const overrideCape = capes.value.find((c) => c.id === selectedSkin.value?.cape_id)
|
||||||
|
if (overrideCape) {
|
||||||
|
return overrideCape
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return defaultCape.value
|
||||||
|
})
|
||||||
|
|
||||||
|
const skinTexture = computedAsync(async () => {
|
||||||
|
if (selectedSkin.value?.texture) {
|
||||||
|
return await get_normalized_skin_texture(selectedSkin.value)
|
||||||
|
} else {
|
||||||
|
return ''
|
||||||
|
}
|
||||||
|
})
|
||||||
|
const capeTexture = computed(() => currentCape.value?.texture)
|
||||||
|
const skinVariant = computed(() => selectedSkin.value?.variant)
|
||||||
|
const skinNametag = computed(() =>
|
||||||
|
settings.value.hide_nametag_skins_page ? undefined : username.value,
|
||||||
|
)
|
||||||
|
|
||||||
|
let userCheckInterval: number | null = null
|
||||||
|
|
||||||
|
const deleteSkinModal = ref()
|
||||||
|
const skinToDelete = ref<Skin | null>(null)
|
||||||
|
|
||||||
|
function confirmDeleteSkin(skin: Skin) {
|
||||||
|
skinToDelete.value = skin
|
||||||
|
deleteSkinModal.value?.show()
|
||||||
|
}
|
||||||
|
|
||||||
|
async function deleteSkin() {
|
||||||
|
if (!skinToDelete.value) return
|
||||||
|
await remove_custom_skin(skinToDelete.value).catch(handleError)
|
||||||
|
await loadSkins()
|
||||||
|
skinToDelete.value = null
|
||||||
|
}
|
||||||
|
|
||||||
|
async function loadCapes() {
|
||||||
|
try {
|
||||||
|
capes.value = (await get_available_capes()) ?? []
|
||||||
|
defaultCape.value = capes.value.find((c) => c.is_equipped)
|
||||||
|
originalDefaultCape.value = defaultCape.value
|
||||||
|
} catch (error) {
|
||||||
|
if (currentUser.value) {
|
||||||
|
handleError(error)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function loadSkins() {
|
||||||
|
try {
|
||||||
|
skins.value = (await get_available_skins()) ?? []
|
||||||
|
generateSkinPreviews(skins.value, capes.value)
|
||||||
|
selectedSkin.value = skins.value.find((s) => s.is_equipped) ?? null
|
||||||
|
originalSelectedSkin.value = selectedSkin.value
|
||||||
|
} catch (error) {
|
||||||
|
if (currentUser.value) {
|
||||||
|
handleError(error)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function changeSkin(newSkin: Skin) {
|
||||||
|
const previousSkin = selectedSkin.value
|
||||||
|
const previousSkinsList = [...skins.value]
|
||||||
|
|
||||||
|
skins.value = skins.value.map((skin) => {
|
||||||
|
return {
|
||||||
|
...skin,
|
||||||
|
is_equipped: skin.texture_key === newSkin.texture_key,
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
selectedSkin.value = skins.value.find((s) => s.texture_key === newSkin.texture_key) || null
|
||||||
|
|
||||||
|
try {
|
||||||
|
await equip_skin(newSkin)
|
||||||
|
if (accountsCard.value) {
|
||||||
|
await accountsCard.value.refreshValues()
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
selectedSkin.value = previousSkin
|
||||||
|
skins.value = previousSkinsList
|
||||||
|
|
||||||
|
if ((error as { message?: string })?.message?.includes('429 Too Many Requests')) {
|
||||||
|
notifications.addNotification({
|
||||||
|
type: 'error',
|
||||||
|
title: 'Slow down!',
|
||||||
|
text: "You're changing your skin too frequently. Mojang's servers have temporarily blocked further requests. Please wait a moment before trying again.",
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
handleError(error)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function handleCapeSelected(cape: Cape | undefined) {
|
||||||
|
const previousDefaultCape = defaultCape.value
|
||||||
|
const previousCapesList = [...capes.value]
|
||||||
|
|
||||||
|
capes.value = capes.value.map((c) => ({
|
||||||
|
...c,
|
||||||
|
is_equipped: cape ? c.id === cape.id : false,
|
||||||
|
}))
|
||||||
|
|
||||||
|
defaultCape.value = cape ? capes.value.find((c) => c.id === cape.id) : undefined
|
||||||
|
|
||||||
|
try {
|
||||||
|
await set_default_cape(cape)
|
||||||
|
} catch (error) {
|
||||||
|
defaultCape.value = previousDefaultCape
|
||||||
|
capes.value = previousCapesList
|
||||||
|
|
||||||
|
if ((error as { message?: string })?.message?.includes('429 Too Many Requests')) {
|
||||||
|
notifications.addNotification({
|
||||||
|
type: 'error',
|
||||||
|
title: 'Slow down!',
|
||||||
|
text: "You're changing your cape too frequently. Mojang's servers have temporarily blocked further requests. Please wait a moment before trying again.",
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
handleError(error)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function onSkinSaved() {
|
||||||
|
await Promise.all([loadCapes(), loadSkins()])
|
||||||
|
}
|
||||||
|
|
||||||
|
async function loadCurrentUser() {
|
||||||
|
try {
|
||||||
|
const defaultId = await get_default_user()
|
||||||
|
currentUserId.value = defaultId
|
||||||
|
|
||||||
|
const allAccounts = await users()
|
||||||
|
currentUser.value = allAccounts.find((acc) => acc.profile.id === defaultId)
|
||||||
|
} catch (e) {
|
||||||
|
handleError(e)
|
||||||
|
currentUser.value = undefined
|
||||||
|
currentUserId.value = undefined
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function getBakedSkinTextures(skin: Skin): RenderResult | undefined {
|
||||||
|
const key = `${skin.texture_key}+${skin.variant}+${skin.cape_id ?? 'no-cape'}`
|
||||||
|
return skinBlobUrlMap.get(key)
|
||||||
|
}
|
||||||
|
|
||||||
|
async function login() {
|
||||||
|
accountsCard.value.setLoginDisabled(true)
|
||||||
|
const loggedIn = await login_flow().catch(handleSevereError)
|
||||||
|
|
||||||
|
if (loggedIn && accountsCard) {
|
||||||
|
await accountsCard.value.refreshValues()
|
||||||
|
}
|
||||||
|
|
||||||
|
trackEvent('AccountLogIn')
|
||||||
|
accountsCard.value.setLoginDisabled(false)
|
||||||
|
}
|
||||||
|
|
||||||
|
function openUploadSkinModal(e: MouseEvent) {
|
||||||
|
uploadSkinModal.value?.show(e)
|
||||||
|
}
|
||||||
|
|
||||||
|
function onSkinFileUploaded(buffer: ArrayBuffer) {
|
||||||
|
const fakeEvent = new MouseEvent('click')
|
||||||
|
normalize_skin_texture(`data:image/png;base64,` + arrayBufferToBase64(buffer)).then(
|
||||||
|
(skinTextureNormalized: Uint8Array) => {
|
||||||
|
const skinTexUrl = `data:image/png;base64,` + arrayBufferToBase64(skinTextureNormalized)
|
||||||
|
if (editSkinModal.value && editSkinModal.value.shouldRestoreModal) {
|
||||||
|
editSkinModal.value.restoreWithNewTexture(skinTexUrl)
|
||||||
|
} else {
|
||||||
|
editSkinModal.value?.showNew(fakeEvent, skinTexUrl)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
function onUploadCanceled() {
|
||||||
|
editSkinModal.value?.restoreModal()
|
||||||
|
}
|
||||||
|
|
||||||
|
watch(
|
||||||
|
() => selectedSkin.value?.cape_id,
|
||||||
|
() => {},
|
||||||
|
)
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
userCheckInterval = window.setInterval(checkUserChanges, 250)
|
||||||
|
})
|
||||||
|
|
||||||
|
onUnmounted(() => {
|
||||||
|
if (userCheckInterval !== null) {
|
||||||
|
window.clearInterval(userCheckInterval)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
async function checkUserChanges() {
|
||||||
|
try {
|
||||||
|
const defaultId = await get_default_user()
|
||||||
|
if (defaultId !== currentUserId.value) {
|
||||||
|
await loadCurrentUser()
|
||||||
|
await loadCapes()
|
||||||
|
await loadSkins()
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
if (currentUser.value) {
|
||||||
|
handleError(error)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
await Promise.all([loadCapes(), loadSkins(), loadCurrentUser()])
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<EditSkinModal
|
||||||
|
ref="editSkinModal"
|
||||||
|
:capes="capes"
|
||||||
|
:default-cape="defaultCape"
|
||||||
|
@saved="onSkinSaved"
|
||||||
|
@deleted="() => loadSkins()"
|
||||||
|
@open-upload-modal="openUploadSkinModal"
|
||||||
|
/>
|
||||||
|
<SelectCapeModal ref="selectCapeModal" :capes="capes" @select="handleCapeSelected" />
|
||||||
|
<UploadSkinModal
|
||||||
|
ref="uploadSkinModal"
|
||||||
|
@uploaded="onSkinFileUploaded"
|
||||||
|
@canceled="onUploadCanceled"
|
||||||
|
/>
|
||||||
|
<ConfirmModal
|
||||||
|
ref="deleteSkinModal"
|
||||||
|
title="Are you sure you want to delete this skin?"
|
||||||
|
description="This will permanently delete the selected skin. This action cannot be undone."
|
||||||
|
proceed-label="Delete"
|
||||||
|
@proceed="deleteSkin"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<div v-if="currentUser" class="p-4 skin-layout">
|
||||||
|
<div class="preview-panel">
|
||||||
|
<h1 class="m-0 text-2xl font-bold flex items-center gap-2">
|
||||||
|
Skins
|
||||||
|
<span class="text-sm font-bold px-2 bg-brand-highlight text-brand rounded-full">Beta</span>
|
||||||
|
</h1>
|
||||||
|
<div class="preview-container">
|
||||||
|
<SkinPreviewRenderer
|
||||||
|
:cape-src="capeTexture"
|
||||||
|
:texture-src="skinTexture || ''"
|
||||||
|
:variant="skinVariant"
|
||||||
|
:nametag="skinNametag"
|
||||||
|
:initial-rotation="Math.PI / 8"
|
||||||
|
>
|
||||||
|
<template #subtitle>
|
||||||
|
<ButtonStyled :disabled="!!selectedSkin?.cape_id">
|
||||||
|
<button
|
||||||
|
v-tooltip="
|
||||||
|
selectedSkin?.cape_id
|
||||||
|
? 'The equipped skin is overriding the default cape.'
|
||||||
|
: undefined
|
||||||
|
"
|
||||||
|
:disabled="!!selectedSkin?.cape_id"
|
||||||
|
@click="
|
||||||
|
(e: MouseEvent) =>
|
||||||
|
selectCapeModal?.show(
|
||||||
|
e,
|
||||||
|
selectedSkin?.texture_key,
|
||||||
|
currentCape,
|
||||||
|
skinTexture,
|
||||||
|
skinVariant,
|
||||||
|
)
|
||||||
|
"
|
||||||
|
>
|
||||||
|
<UpdatedIcon />
|
||||||
|
Change cape
|
||||||
|
</button>
|
||||||
|
</ButtonStyled>
|
||||||
|
</template>
|
||||||
|
</SkinPreviewRenderer>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="skins-container">
|
||||||
|
<section class="flex flex-col gap-2 mt-1">
|
||||||
|
<h2 class="text-lg font-bold m-0 text-primary">Saved skins</h2>
|
||||||
|
<div class="skin-card-grid">
|
||||||
|
<SkinLikeTextButton class="skin-card" @click="openUploadSkinModal">
|
||||||
|
<template #icon>
|
||||||
|
<PlusIcon class="size-8" />
|
||||||
|
</template>
|
||||||
|
<span>Add a skin</span>
|
||||||
|
</SkinLikeTextButton>
|
||||||
|
|
||||||
|
<SkinButton
|
||||||
|
v-for="skin in savedSkins"
|
||||||
|
:key="`saved-skin-${skin.texture_key}`"
|
||||||
|
class="skin-card"
|
||||||
|
:forward-image-src="getBakedSkinTextures(skin)?.forwards"
|
||||||
|
:backward-image-src="getBakedSkinTextures(skin)?.backwards"
|
||||||
|
:selected="selectedSkin === skin"
|
||||||
|
@select="changeSkin(skin)"
|
||||||
|
>
|
||||||
|
<template #overlay-buttons>
|
||||||
|
<Button
|
||||||
|
color="green"
|
||||||
|
aria-label="Edit skin"
|
||||||
|
class="pointer-events-auto"
|
||||||
|
@click.stop="(e) => editSkinModal?.show(e, skin)"
|
||||||
|
>
|
||||||
|
<EditIcon /> Edit
|
||||||
|
</Button>
|
||||||
|
<Button
|
||||||
|
v-show="!skin.is_equipped"
|
||||||
|
v-tooltip="'Delete skin'"
|
||||||
|
aria-label="Delete skin"
|
||||||
|
color="red"
|
||||||
|
class="!rounded-[100%] pointer-events-auto"
|
||||||
|
icon-only
|
||||||
|
@click.stop="() => confirmDeleteSkin(skin)"
|
||||||
|
>
|
||||||
|
<TrashIcon />
|
||||||
|
</Button>
|
||||||
|
</template>
|
||||||
|
</SkinButton>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<section class="flex flex-col gap-2 mt-6">
|
||||||
|
<h2 class="text-lg font-bold m-0 text-primary">Default skins</h2>
|
||||||
|
<div class="skin-card-grid">
|
||||||
|
<SkinButton
|
||||||
|
v-for="skin in defaultSkins"
|
||||||
|
:key="`default-skin-${skin.texture_key}`"
|
||||||
|
class="skin-card"
|
||||||
|
:forward-image-src="getBakedSkinTextures(skin)?.forwards"
|
||||||
|
:backward-image-src="getBakedSkinTextures(skin)?.backwards"
|
||||||
|
:selected="selectedSkin === skin"
|
||||||
|
:tooltip="skin.name"
|
||||||
|
@select="changeSkin(skin)"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div v-else class="flex items-center justify-center min-h-[50vh] pt-[25%]">
|
||||||
|
<div
|
||||||
|
class="bg-bg-raised rounded-lg p-7 flex flex-col gap-5 shadow-md relative max-w-xl w-full mx-auto"
|
||||||
|
>
|
||||||
|
<img
|
||||||
|
:src="ExcitedRinthbot"
|
||||||
|
alt="Excited Modrinth Bot"
|
||||||
|
class="absolute -top-28 right-8 md:right-20 h-28 w-auto"
|
||||||
|
/>
|
||||||
|
<div
|
||||||
|
class="absolute top-0 left-0 w-full h-[1px] opacity-40 bg-gradient-to-r from-transparent via-green-500 to-transparent"
|
||||||
|
style="
|
||||||
|
background: linear-gradient(
|
||||||
|
to right,
|
||||||
|
transparent 2rem,
|
||||||
|
var(--color-green) calc(100% - 13rem),
|
||||||
|
var(--color-green) calc(100% - 5rem),
|
||||||
|
transparent calc(100% - 2rem)
|
||||||
|
);
|
||||||
|
"
|
||||||
|
></div>
|
||||||
|
|
||||||
|
<div class="flex flex-col gap-5">
|
||||||
|
<h1 class="text-3xl font-extrabold m-0">Please sign-in</h1>
|
||||||
|
<p class="text-lg m-0">
|
||||||
|
Please sign into your Minecraft account to use the skin management features of the
|
||||||
|
Modrinth app.
|
||||||
|
</p>
|
||||||
|
<ButtonStyled v-show="accountsCard" color="brand" :disabled="accountsCard.loginDisabled">
|
||||||
|
<button :disabled="accountsCard.loginDisabled" @click="login">
|
||||||
|
<LogInIcon v-if="!accountsCard.loginDisabled" />
|
||||||
|
<SpinnerIcon v-else class="animate-spin" />
|
||||||
|
Sign In
|
||||||
|
</button>
|
||||||
|
</ButtonStyled>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<style lang="scss" scoped>
|
||||||
|
$skin-card-width: 155px;
|
||||||
|
$skin-card-gap: 4px;
|
||||||
|
|
||||||
|
.skin-layout {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: minmax(0, 1fr) minmax(0, 2.5fr);
|
||||||
|
gap: 2.5rem;
|
||||||
|
|
||||||
|
@media (max-width: 700px) {
|
||||||
|
grid-template-columns: 1fr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.preview-panel {
|
||||||
|
top: 1.5rem;
|
||||||
|
position: sticky;
|
||||||
|
align-self: start;
|
||||||
|
padding: 0.5rem;
|
||||||
|
padding-top: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.preview-container {
|
||||||
|
height: 80vh;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
margin-left: calc((2.5rem / 2));
|
||||||
|
|
||||||
|
@media (max-width: 700px) {
|
||||||
|
height: 50vh;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.skins-container {
|
||||||
|
padding-top: 0.5rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.skin-card-grid {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: repeat(3, 1fr);
|
||||||
|
gap: $skin-card-gap;
|
||||||
|
width: 100%;
|
||||||
|
|
||||||
|
@media (min-width: 1300px) {
|
||||||
|
grid-template-columns: repeat(4, 1fr);
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (min-width: 1750px) {
|
||||||
|
grid-template-columns: repeat(5, 1fr);
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (min-width: 2050px) {
|
||||||
|
grid-template-columns: repeat(6, 1fr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.skin-card {
|
||||||
|
aspect-ratio: 0.95;
|
||||||
|
border-radius: 10px;
|
||||||
|
box-sizing: border-box;
|
||||||
|
width: 100%;
|
||||||
|
min-width: 0;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
import Index from './Index.vue'
|
|
||||||
import Browse from './Browse.vue'
|
import Browse from './Browse.vue'
|
||||||
|
import Index from './Index.vue'
|
||||||
|
import Skins from './Skins.vue'
|
||||||
import Worlds from './Worlds.vue'
|
import Worlds from './Worlds.vue'
|
||||||
|
|
||||||
export { Index, Browse, Worlds }
|
export { Browse, Index, Skins, Worlds }
|
||||||
|
|||||||
@@ -157,13 +157,6 @@
|
|||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<script setup>
|
<script setup>
|
||||||
import {
|
|
||||||
Avatar,
|
|
||||||
ButtonStyled,
|
|
||||||
ContentPageHeader,
|
|
||||||
LoadingIndicator,
|
|
||||||
OverflowMenu,
|
|
||||||
} from '@modrinth/ui'
|
|
||||||
import {
|
import {
|
||||||
CheckCircleIcon,
|
CheckCircleIcon,
|
||||||
ClipboardCopyIcon,
|
ClipboardCopyIcon,
|
||||||
@@ -187,24 +180,32 @@ import {
|
|||||||
UserPlusIcon,
|
UserPlusIcon,
|
||||||
XIcon,
|
XIcon,
|
||||||
} from '@modrinth/assets'
|
} from '@modrinth/assets'
|
||||||
import { finish_install, get, get_full_path, kill, run } from '@/helpers/profile'
|
import {
|
||||||
import { get_by_profile_path } from '@/helpers/process'
|
Avatar,
|
||||||
import { process_listener, profile_listener } from '@/helpers/events'
|
ButtonStyled,
|
||||||
import { useRoute, useRouter } from 'vue-router'
|
ContentPageHeader,
|
||||||
import { computed, onUnmounted, ref, watch } from 'vue'
|
LoadingIndicator,
|
||||||
import { handleError, useBreadcrumbs, useLoading } from '@/store/state'
|
OverflowMenu,
|
||||||
import { showProfileInFolder } from '@/helpers/utils.js'
|
} from '@modrinth/ui'
|
||||||
import ContextMenu from '@/components/ui/ContextMenu.vue'
|
|
||||||
import NavTabs from '@/components/ui/NavTabs.vue'
|
|
||||||
import { trackEvent } from '@/helpers/analytics'
|
|
||||||
import { convertFileSrc } from '@tauri-apps/api/core'
|
import { convertFileSrc } from '@tauri-apps/api/core'
|
||||||
import { handleSevereError } from '@/store/error.js'
|
|
||||||
import { get_project, get_version_many } from '@/helpers/cache.js'
|
|
||||||
import dayjs from 'dayjs'
|
import dayjs from 'dayjs'
|
||||||
import duration from 'dayjs/plugin/duration'
|
import duration from 'dayjs/plugin/duration'
|
||||||
import relativeTime from 'dayjs/plugin/relativeTime'
|
import relativeTime from 'dayjs/plugin/relativeTime'
|
||||||
|
import { computed, onUnmounted, ref, watch } from 'vue'
|
||||||
|
import { useRoute, useRouter } from 'vue-router'
|
||||||
|
|
||||||
|
import ContextMenu from '@/components/ui/ContextMenu.vue'
|
||||||
import ExportModal from '@/components/ui/ExportModal.vue'
|
import ExportModal from '@/components/ui/ExportModal.vue'
|
||||||
import InstanceSettingsModal from '@/components/ui/modal/InstanceSettingsModal.vue'
|
import InstanceSettingsModal from '@/components/ui/modal/InstanceSettingsModal.vue'
|
||||||
|
import NavTabs from '@/components/ui/NavTabs.vue'
|
||||||
|
import { trackEvent } from '@/helpers/analytics'
|
||||||
|
import { get_project, get_version_many } from '@/helpers/cache.js'
|
||||||
|
import { process_listener, profile_listener } from '@/helpers/events'
|
||||||
|
import { get_by_profile_path } from '@/helpers/process'
|
||||||
|
import { finish_install, get, get_full_path, kill, run } from '@/helpers/profile'
|
||||||
|
import { showProfileInFolder } from '@/helpers/utils.js'
|
||||||
|
import { handleSevereError } from '@/store/error.js'
|
||||||
|
import { handleError, useBreadcrumbs, useLoading } from '@/store/state'
|
||||||
|
|
||||||
dayjs.extend(duration)
|
dayjs.extend(duration)
|
||||||
dayjs.extend(relativeTime)
|
dayjs.extend(relativeTime)
|
||||||
|
|||||||
@@ -88,26 +88,28 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
|
import 'vue-virtual-scroller/dist/vue-virtual-scroller.css'
|
||||||
|
|
||||||
import { CheckIcon, ClipboardCopyIcon, ShareIcon, TrashIcon } from '@modrinth/assets'
|
import { CheckIcon, ClipboardCopyIcon, ShareIcon, TrashIcon } from '@modrinth/assets'
|
||||||
import { Button, Card, Checkbox, DropdownSelect } from '@modrinth/ui'
|
import { Button, Card, Checkbox, DropdownSelect } from '@modrinth/ui'
|
||||||
import {
|
|
||||||
delete_logs_by_filename,
|
|
||||||
get_logs,
|
|
||||||
get_output_by_filename,
|
|
||||||
get_latest_log_cursor,
|
|
||||||
} from '@/helpers/logs.js'
|
|
||||||
import { computed, nextTick, onBeforeUnmount, onMounted, onUnmounted, ref, watch } from 'vue'
|
|
||||||
import dayjs from 'dayjs'
|
import dayjs from 'dayjs'
|
||||||
import isToday from 'dayjs/plugin/isToday'
|
import isToday from 'dayjs/plugin/isToday'
|
||||||
import isYesterday from 'dayjs/plugin/isYesterday'
|
import isYesterday from 'dayjs/plugin/isYesterday'
|
||||||
import { get_by_profile_path } from '@/helpers/process.js'
|
|
||||||
import { useRoute } from 'vue-router'
|
|
||||||
import { process_listener } from '@/helpers/events.js'
|
|
||||||
import { handleError } from '@/store/notifications.js'
|
|
||||||
import { ofetch } from 'ofetch'
|
import { ofetch } from 'ofetch'
|
||||||
|
import { computed, nextTick, onBeforeUnmount, onMounted, onUnmounted, ref, watch } from 'vue'
|
||||||
|
import { useRoute } from 'vue-router'
|
||||||
import { RecycleScroller } from 'vue-virtual-scroller'
|
import { RecycleScroller } from 'vue-virtual-scroller'
|
||||||
import 'vue-virtual-scroller/dist/vue-virtual-scroller.css'
|
|
||||||
import ShareModalWrapper from '@/components/ui/modal/ShareModalWrapper.vue'
|
import ShareModalWrapper from '@/components/ui/modal/ShareModalWrapper.vue'
|
||||||
|
import { process_listener } from '@/helpers/events.js'
|
||||||
|
import {
|
||||||
|
delete_logs_by_filename,
|
||||||
|
get_latest_log_cursor,
|
||||||
|
get_logs,
|
||||||
|
get_output_by_filename,
|
||||||
|
} from '@/helpers/logs.js'
|
||||||
|
import { get_by_profile_path } from '@/helpers/process.js'
|
||||||
|
import { handleError } from '@/store/notifications.js'
|
||||||
|
|
||||||
dayjs.extend(isToday)
|
dayjs.extend(isToday)
|
||||||
dayjs.extend(isYesterday)
|
dayjs.extend(isYesterday)
|
||||||
@@ -483,7 +485,7 @@ onUnmounted(() => {
|
|||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
gap: 1rem;
|
gap: 1rem;
|
||||||
height: calc(100vh - 11rem);
|
height: 100vh;
|
||||||
}
|
}
|
||||||
|
|
||||||
.button-row {
|
.button-row {
|
||||||
|
|||||||
@@ -276,11 +276,29 @@ import {
|
|||||||
RadialHeader,
|
RadialHeader,
|
||||||
Toggle,
|
Toggle,
|
||||||
} from '@modrinth/ui'
|
} from '@modrinth/ui'
|
||||||
|
import type { ContentItem } from '@modrinth/ui/src/components/content/ContentListItem.vue'
|
||||||
import type { Organization, Project, TeamMember, Version } from '@modrinth/utils'
|
import type { Organization, Project, TeamMember, Version } from '@modrinth/utils'
|
||||||
import { formatProjectType } from '@modrinth/utils'
|
import { formatProjectType } from '@modrinth/utils'
|
||||||
|
import { getCurrentWebview } from '@tauri-apps/api/webview'
|
||||||
|
import { defineMessages, useVIntl } from '@vintl/vintl'
|
||||||
|
import dayjs from 'dayjs'
|
||||||
import type { ComputedRef } from 'vue'
|
import type { ComputedRef } from 'vue'
|
||||||
import { computed, onUnmounted, ref, watch } from 'vue'
|
import { computed, onUnmounted, ref, watch } from 'vue'
|
||||||
import { defineMessages, useVIntl } from '@vintl/vintl'
|
|
||||||
|
import { TextInputIcon } from '@/assets/icons'
|
||||||
|
import AddContentButton from '@/components/ui/AddContentButton.vue'
|
||||||
|
import type ContextMenu from '@/components/ui/ContextMenu.vue'
|
||||||
|
import ExportModal from '@/components/ui/ExportModal.vue'
|
||||||
|
import ShareModalWrapper from '@/components/ui/modal/ShareModalWrapper.vue'
|
||||||
|
import ModpackVersionModal from '@/components/ui/ModpackVersionModal.vue'
|
||||||
|
import { trackEvent } from '@/helpers/analytics'
|
||||||
|
import {
|
||||||
|
get_organization_many,
|
||||||
|
get_project_many,
|
||||||
|
get_team_many,
|
||||||
|
get_version_many,
|
||||||
|
} from '@/helpers/cache.js'
|
||||||
|
import { profile_listener } from '@/helpers/events.js'
|
||||||
import {
|
import {
|
||||||
add_project_from_path,
|
add_project_from_path,
|
||||||
get_projects,
|
get_projects,
|
||||||
@@ -289,26 +307,9 @@ import {
|
|||||||
update_all,
|
update_all,
|
||||||
update_project,
|
update_project,
|
||||||
} from '@/helpers/profile.js'
|
} from '@/helpers/profile.js'
|
||||||
import { handleError } from '@/store/notifications.js'
|
|
||||||
import { trackEvent } from '@/helpers/analytics'
|
|
||||||
import { highlightModInProfile } from '@/helpers/utils.js'
|
|
||||||
import { TextInputIcon } from '@/assets/icons'
|
|
||||||
import ExportModal from '@/components/ui/ExportModal.vue'
|
|
||||||
import ModpackVersionModal from '@/components/ui/ModpackVersionModal.vue'
|
|
||||||
import AddContentButton from '@/components/ui/AddContentButton.vue'
|
|
||||||
import {
|
|
||||||
get_organization_many,
|
|
||||||
get_project_many,
|
|
||||||
get_team_many,
|
|
||||||
get_version_many,
|
|
||||||
} from '@/helpers/cache.js'
|
|
||||||
import { profile_listener } from '@/helpers/events.js'
|
|
||||||
import ShareModalWrapper from '@/components/ui/modal/ShareModalWrapper.vue'
|
|
||||||
import { getCurrentWebview } from '@tauri-apps/api/webview'
|
|
||||||
import dayjs from 'dayjs'
|
|
||||||
import type { CacheBehaviour, ContentFile, GameInstance } from '@/helpers/types'
|
import type { CacheBehaviour, ContentFile, GameInstance } from '@/helpers/types'
|
||||||
import type ContextMenu from '@/components/ui/ContextMenu.vue'
|
import { highlightModInProfile } from '@/helpers/utils.js'
|
||||||
import type { ContentItem } from '@modrinth/ui/src/components/content/ContentListItem.vue'
|
import { handleError } from '@/store/notifications.js'
|
||||||
|
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
instance: GameInstance
|
instance: GameInstance
|
||||||
|
|||||||
@@ -1,9 +1,10 @@
|
|||||||
<template>{{ instance.name }} overview</template>
|
<template>{{ instance.name }} overview</template>
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import type { GameInstance } from '@/helpers/types'
|
|
||||||
import type ContextMenu from '@/components/ui/ContextMenu.vue'
|
|
||||||
import type { Version } from '@modrinth/utils'
|
import type { Version } from '@modrinth/utils'
|
||||||
|
|
||||||
|
import type ContextMenu from '@/components/ui/ContextMenu.vue'
|
||||||
|
import type { GameInstance } from '@/helpers/types'
|
||||||
|
|
||||||
defineProps<{
|
defineProps<{
|
||||||
instance: GameInstance
|
instance: GameInstance
|
||||||
options: InstanceType<typeof ContextMenu>
|
options: InstanceType<typeof ContextMenu>
|
||||||
|
|||||||
@@ -67,7 +67,8 @@
|
|||||||
:key="`world-${world.type}-${world.type == 'singleplayer' ? world.path : `${world.address}-${world.index}`}`"
|
:key="`world-${world.type}-${world.type == 'singleplayer' ? world.path : `${world.address}-${world.index}`}`"
|
||||||
:world="world"
|
:world="world"
|
||||||
:highlighted="highlightedWorld === getWorldIdentifier(world)"
|
:highlighted="highlightedWorld === getWorldIdentifier(world)"
|
||||||
:supports-quick-play="supportsQuickPlay"
|
:supports-server-quick-play="supportsServerQuickPlay"
|
||||||
|
:supports-world-quick-play="supportsWorldQuickPlay"
|
||||||
:current-protocol="protocolVersion"
|
:current-protocol="protocolVersion"
|
||||||
:playing-instance="playing"
|
:playing-instance="playing"
|
||||||
:playing-world="worldsMatch(world, worldPlaying)"
|
:playing-world="worldsMatch(world, worldPlaying)"
|
||||||
@@ -120,52 +121,54 @@
|
|||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref, computed, onUnmounted, watch } from 'vue'
|
import { PlusIcon, SearchIcon, SpinnerIcon, UpdatedIcon, XIcon } from '@modrinth/assets'
|
||||||
import { useRoute } from 'vue-router'
|
|
||||||
import type { GameInstance } from '@/helpers/types'
|
|
||||||
import {
|
import {
|
||||||
Button,
|
Button,
|
||||||
ButtonStyled,
|
ButtonStyled,
|
||||||
RadialHeader,
|
|
||||||
FilterBar,
|
FilterBar,
|
||||||
type FilterBarOption,
|
type FilterBarOption,
|
||||||
type GameVersion,
|
|
||||||
GAME_MODES,
|
GAME_MODES,
|
||||||
|
type GameVersion,
|
||||||
|
RadialHeader,
|
||||||
} from '@modrinth/ui'
|
} from '@modrinth/ui'
|
||||||
import { PlusIcon, SpinnerIcon, UpdatedIcon, SearchIcon, XIcon } from '@modrinth/assets'
|
import type { Version } from '@modrinth/utils'
|
||||||
import {
|
import { defineMessages } from '@vintl/vintl'
|
||||||
type SingleplayerWorld,
|
import { computed, onUnmounted, ref, watch } from 'vue'
|
||||||
type World,
|
import { useRoute } from 'vue-router'
|
||||||
type ServerWorld,
|
|
||||||
type ServerData,
|
import type ContextMenu from '@/components/ui/ContextMenu.vue'
|
||||||
type ProfileEvent,
|
import ConfirmModalWrapper from '@/components/ui/modal/ConfirmModalWrapper.vue'
|
||||||
get_profile_protocol_version,
|
|
||||||
remove_server_from_profile,
|
|
||||||
delete_world,
|
|
||||||
start_join_server,
|
|
||||||
start_join_singleplayer_world,
|
|
||||||
getWorldIdentifier,
|
|
||||||
refreshServerData,
|
|
||||||
refreshWorld,
|
|
||||||
sortWorlds,
|
|
||||||
refreshServers,
|
|
||||||
hasQuickPlaySupport,
|
|
||||||
refreshWorlds,
|
|
||||||
handleDefaultProfileUpdateEvent,
|
|
||||||
showWorldInFolder,
|
|
||||||
} from '@/helpers/worlds.ts'
|
|
||||||
import AddServerModal from '@/components/ui/world/modal/AddServerModal.vue'
|
import AddServerModal from '@/components/ui/world/modal/AddServerModal.vue'
|
||||||
import EditServerModal from '@/components/ui/world/modal/EditServerModal.vue'
|
import EditServerModal from '@/components/ui/world/modal/EditServerModal.vue'
|
||||||
import EditWorldModal from '@/components/ui/world/modal/EditSingleplayerWorldModal.vue'
|
import EditWorldModal from '@/components/ui/world/modal/EditSingleplayerWorldModal.vue'
|
||||||
import WorldItem from '@/components/ui/world/WorldItem.vue'
|
import WorldItem from '@/components/ui/world/WorldItem.vue'
|
||||||
|
|
||||||
import ConfirmModalWrapper from '@/components/ui/modal/ConfirmModalWrapper.vue'
|
|
||||||
import { handleError } from '@/store/notifications'
|
|
||||||
import type ContextMenu from '@/components/ui/ContextMenu.vue'
|
|
||||||
import type { Version } from '@modrinth/utils'
|
|
||||||
import { profile_listener } from '@/helpers/events'
|
import { profile_listener } from '@/helpers/events'
|
||||||
import { get_game_versions } from '@/helpers/tags'
|
import { get_game_versions } from '@/helpers/tags'
|
||||||
import { defineMessages } from '@vintl/vintl'
|
import type { GameInstance } from '@/helpers/types'
|
||||||
|
import {
|
||||||
|
delete_world,
|
||||||
|
get_profile_protocol_version,
|
||||||
|
getWorldIdentifier,
|
||||||
|
handleDefaultProfileUpdateEvent,
|
||||||
|
hasServerQuickPlaySupport,
|
||||||
|
hasWorldQuickPlaySupport,
|
||||||
|
type ProfileEvent,
|
||||||
|
type ProtocolVersion,
|
||||||
|
refreshServerData,
|
||||||
|
refreshServers,
|
||||||
|
refreshWorld,
|
||||||
|
refreshWorlds,
|
||||||
|
remove_server_from_profile,
|
||||||
|
type ServerData,
|
||||||
|
type ServerWorld,
|
||||||
|
showWorldInFolder,
|
||||||
|
type SingleplayerWorld,
|
||||||
|
sortWorlds,
|
||||||
|
start_join_server,
|
||||||
|
start_join_singleplayer_world,
|
||||||
|
type World,
|
||||||
|
} from '@/helpers/worlds.ts'
|
||||||
|
import { handleError } from '@/store/notifications'
|
||||||
|
|
||||||
const route = useRoute()
|
const route = useRoute()
|
||||||
|
|
||||||
@@ -210,7 +213,9 @@ const worldPlaying = ref<World>()
|
|||||||
const worlds = ref<World[]>([])
|
const worlds = ref<World[]>([])
|
||||||
const serverData = ref<Record<string, ServerData>>({})
|
const serverData = ref<Record<string, ServerData>>({})
|
||||||
|
|
||||||
const protocolVersion = ref<number | null>(await get_profile_protocol_version(instance.value.path))
|
const protocolVersion = ref<ProtocolVersion | null>(
|
||||||
|
await get_profile_protocol_version(instance.value.path),
|
||||||
|
)
|
||||||
|
|
||||||
const unlistenProfile = await profile_listener(async (e: ProfileEvent) => {
|
const unlistenProfile = await profile_listener(async (e: ProfileEvent) => {
|
||||||
if (e.profile_path_id !== instance.value.path) return
|
if (e.profile_path_id !== instance.value.path) return
|
||||||
@@ -246,7 +251,7 @@ async function refreshAllWorlds() {
|
|||||||
worlds.value = await refreshWorlds(instance.value.path).finally(
|
worlds.value = await refreshWorlds(instance.value.path).finally(
|
||||||
() => (refreshingAll.value = false),
|
() => (refreshingAll.value = false),
|
||||||
)
|
)
|
||||||
await refreshServers(worlds.value, serverData.value, protocolVersion.value)
|
refreshServers(worlds.value, serverData.value, protocolVersion.value)
|
||||||
|
|
||||||
const hasNoWorlds = worlds.value.length === 0
|
const hasNoWorlds = worlds.value.length === 0
|
||||||
|
|
||||||
@@ -352,8 +357,11 @@ function worldsMatch(world: World, other: World | undefined) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const gameVersions = ref<GameVersion[]>(await get_game_versions().catch(() => []))
|
const gameVersions = ref<GameVersion[]>(await get_game_versions().catch(() => []))
|
||||||
const supportsQuickPlay = computed(() =>
|
const supportsServerQuickPlay = computed(() =>
|
||||||
hasQuickPlaySupport(gameVersions.value, instance.value.game_version),
|
hasServerQuickPlaySupport(gameVersions.value, instance.value.game_version),
|
||||||
|
)
|
||||||
|
const supportsWorldQuickPlay = computed(() =>
|
||||||
|
hasWorldQuickPlaySupport(gameVersions.value, instance.value.game_version),
|
||||||
)
|
)
|
||||||
|
|
||||||
const filterOptions = computed(() => {
|
const filterOptions = computed(() => {
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user