mirror of
https://github.com/Drop-OSS/drop-app.git
synced 2025-11-12 15:52:43 +10:00
Compare commits
46 Commits
42-feature
...
AdenMGB-sm
| Author | SHA1 | Date | |
|---|---|---|---|
| 40a490fda4 | |||
| 6d2b8c88e8 | |||
| 262c8505b7 | |||
| e798d258dc | |||
| 105b3e9bc4 | |||
| 3f18d15d39 | |||
| 97b5cd5e78 | |||
| 7e70a17a43 | |||
| 8d61a68b8a | |||
| 44a1be6991 | |||
| 4f5fccf0c1 | |||
| 5eef2bf60f | |||
| ec6294b8e7 | |||
| 17c375bcab | |||
| cb55ac2bf5 | |||
| e11db851a5 | |||
| 16365713cf | |||
| 3b830e2a44 | |||
| 75a4b73ee1 | |||
| 339d707092 | |||
| 776dc8fe7a | |||
| dbe8c8df4d | |||
| 35f49b8811 | |||
| cc5339a389 | |||
| 6104bfda72 | |||
| be688cb18f | |||
| 13cc69f10e | |||
| 574782f445 | |||
| b5a8543194 | |||
| d0e4aea5ce | |||
| 739e6166c5 | |||
| 682c6e9c0b | |||
| 46e1f16cdd | |||
| d19f9bbc31 | |||
| 2913fdf35b | |||
| f9fdf151ea | |||
| 495d93705e | |||
| c477dd4872 | |||
| f560a62c8f | |||
| 2874b9776b | |||
| afcd4e916f | |||
| 885fa42ecc | |||
| 6d295bd47f | |||
| c3ee09af85 | |||
| 0ce55e12c5 | |||
| 86bce1c68d |
23
.github/workflows/clippy.yml
vendored
Normal file
23
.github/workflows/clippy.yml
vendored
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
on: push
|
||||||
|
name: Clippy check
|
||||||
|
jobs:
|
||||||
|
clippy_check:
|
||||||
|
runs-on: ubuntu-24.04
|
||||||
|
permissions:
|
||||||
|
checks: write
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v1
|
||||||
|
- name: install dependencies (ubuntu only)
|
||||||
|
run: |
|
||||||
|
sudo apt-get update
|
||||||
|
sudo apt-get install -y libglib2.0-dev libgtk-3-dev libwebkit2gtk-4.1-dev
|
||||||
|
|
||||||
|
- uses: actions-rs/toolchain@v1
|
||||||
|
with:
|
||||||
|
toolchain: nightly
|
||||||
|
components: clippy
|
||||||
|
override: true
|
||||||
|
- uses: actions-rs/clippy-check@v1
|
||||||
|
with:
|
||||||
|
token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
args: --manifest-path ./src-tauri/Cargo.toml
|
||||||
46
.github/workflows/release.yml
vendored
46
.github/workflows/release.yml
vendored
@ -22,9 +22,9 @@ jobs:
|
|||||||
args: '--target aarch64-apple-darwin'
|
args: '--target aarch64-apple-darwin'
|
||||||
- platform: 'macos-latest' # for Intel based macs.
|
- platform: 'macos-latest' # for Intel based macs.
|
||||||
args: '--target x86_64-apple-darwin'
|
args: '--target x86_64-apple-darwin'
|
||||||
- platform: 'ubuntu-24.04' # for Tauri v1 you could replace this with ubuntu-20.04.
|
- platform: 'ubuntu-22.04' # for Tauri v1 you could replace this with ubuntu-20.04.
|
||||||
args: ''
|
args: ''
|
||||||
- platform: 'ubuntu-24.04-arm'
|
- platform: 'ubuntu-22.04-arm'
|
||||||
args: '--target aarch64-unknown-linux-gnu'
|
args: '--target aarch64-unknown-linux-gnu'
|
||||||
- platform: 'windows-latest'
|
- platform: 'windows-latest'
|
||||||
args: ''
|
args: ''
|
||||||
@ -48,12 +48,42 @@ jobs:
|
|||||||
targets: ${{ matrix.platform == 'macos-latest' && 'aarch64-apple-darwin,x86_64-apple-darwin' || '' }}
|
targets: ${{ matrix.platform == 'macos-latest' && 'aarch64-apple-darwin,x86_64-apple-darwin' || '' }}
|
||||||
|
|
||||||
- name: install dependencies (ubuntu only)
|
- name: install dependencies (ubuntu only)
|
||||||
if: matrix.platform == 'ubuntu-22.04' # This must match the platform value defined above.
|
if: matrix.platform == 'ubuntu-22.04' || matrix.platform == 'ubuntu-22.04-arm' # This must match the platform value defined above.
|
||||||
run: |
|
run: |
|
||||||
sudo apt-get update
|
sudo apt-get update
|
||||||
sudo apt-get install -y libwebkit2gtk-4.0-dev libwebkit2gtk-4.1-dev libappindicator3-dev librsvg2-dev patchelf libgtk2.0-dev libsoup3.0-dev
|
sudo apt-get install -y libwebkit2gtk-4.1-dev libappindicator3-dev librsvg2-dev patchelf xdg-utils
|
||||||
# webkitgtk 4.0 is for Tauri v1 - webkitgtk 4.1 is for Tauri v2.
|
# webkitgtk 4.0 is for Tauri v1 - webkitgtk 4.1 is for Tauri v2.
|
||||||
# You can remove the one that doesn't apply to your app to speed up the workflow a bit.
|
|
||||||
|
|
||||||
|
- name: Import Apple Developer Certificate
|
||||||
|
if: matrix.platform == 'macos-latest'
|
||||||
|
env:
|
||||||
|
APPLE_CERTIFICATE: ${{ secrets.APPLE_CERTIFICATE }}
|
||||||
|
APPLE_CERTIFICATE_PASSWORD: ${{ secrets.APPLE_CERTIFICATE_PASSWORD }}
|
||||||
|
KEYCHAIN_PASSWORD: ${{ secrets.KEYCHAIN_PASSWORD }}
|
||||||
|
run: |
|
||||||
|
echo $APPLE_CERTIFICATE | base64 --decode > certificate.p12
|
||||||
|
security create-keychain -p "$KEYCHAIN_PASSWORD" build.keychain
|
||||||
|
security default-keychain -s build.keychain
|
||||||
|
security unlock-keychain -p "$KEYCHAIN_PASSWORD" build.keychain
|
||||||
|
security set-keychain-settings -t 3600 -u build.keychain
|
||||||
|
|
||||||
|
curl https://droposs.org/drop.crt --output drop.pem
|
||||||
|
sudo security authorizationdb write com.apple.trust-settings.user allow
|
||||||
|
security add-trusted-cert -r trustRoot -k build.keychain -p codeSign -u -1 drop.pem
|
||||||
|
sudo security authorizationdb remove com.apple.trust-settings.user
|
||||||
|
|
||||||
|
security import certificate.p12 -k build.keychain -P "$APPLE_CERTIFICATE_PASSWORD" -T /usr/bin/codesign
|
||||||
|
security set-key-partition-list -S apple-tool:,apple:,codesign: -s -k "$KEYCHAIN_PASSWORD" build.keychain
|
||||||
|
security find-identity -v -p codesigning build.keychain
|
||||||
|
|
||||||
|
- name: Verify Certificate
|
||||||
|
if: matrix.platform == 'macos-latest'
|
||||||
|
run: |
|
||||||
|
CERT_INFO=$(security find-identity -v -p codesigning build.keychain | grep "Drop OSS")
|
||||||
|
CERT_ID=$(echo "$CERT_INFO" | awk -F'"' '{print $2}')
|
||||||
|
echo "CERT_ID=$CERT_ID" >> $GITHUB_ENV
|
||||||
|
echo "Certificate imported. Using identity: $CERT_ID"
|
||||||
|
|
||||||
- name: install frontend dependencies
|
- name: install frontend dependencies
|
||||||
run: yarn install # change this to npm, pnpm or bun depending on which one you use.
|
run: yarn install # change this to npm, pnpm or bun depending on which one you use.
|
||||||
@ -61,10 +91,14 @@ jobs:
|
|||||||
- uses: tauri-apps/tauri-action@v0
|
- uses: tauri-apps/tauri-action@v0
|
||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
APPLE_CERTIFICATE: ${{ secrets.APPLE_CERTIFICATE }}
|
||||||
|
APPLE_CERTIFICATE_PASSWORD: ${{ secrets.APPLE_CERTIFICATE_PASSWORD }}
|
||||||
|
APPLE_SIGNING_IDENTITY: ${{ env.CERT_ID }}
|
||||||
|
NO_STRIP: true
|
||||||
with:
|
with:
|
||||||
tagName: v__VERSION__ # the action automatically replaces \_\_VERSION\_\_ with the app version.
|
tagName: v__VERSION__ # the action automatically replaces \_\_VERSION\_\_ with the app version.
|
||||||
releaseName: 'Auto-release v__VERSION__'
|
releaseName: 'Auto-release v__VERSION__'
|
||||||
releaseBody: 'See the assets to download this version and install. This release was created automatically.'
|
releaseBody: 'See the assets to download this version and install. This release was created automatically.'
|
||||||
releaseDraft: false
|
releaseDraft: false
|
||||||
prerelease: true
|
prerelease: true
|
||||||
args: ${{ matrix.args }}
|
args: ${{ matrix.args }}
|
||||||
5
.gitignore
vendored
5
.gitignore
vendored
@ -26,4 +26,7 @@ dist-ssr
|
|||||||
.output
|
.output
|
||||||
|
|
||||||
src-tauri/flamegraph.svg
|
src-tauri/flamegraph.svg
|
||||||
src-tauri/perf*
|
src-tauri/perf*
|
||||||
|
|
||||||
|
/*.AppImage
|
||||||
|
/squashfs-root
|
||||||
9
.gitmodules
vendored
9
.gitmodules
vendored
@ -1,9 +1,6 @@
|
|||||||
[submodule "drop-base"]
|
|
||||||
path = drop-base
|
|
||||||
url = https://github.com/drop-oss/drop-base
|
|
||||||
[submodule "src-tauri/tailscale/libtailscale"]
|
[submodule "src-tauri/tailscale/libtailscale"]
|
||||||
path = src-tauri/tailscale/libtailscale
|
path = src-tauri/tailscale/libtailscale
|
||||||
url = https://github.com/tailscale/libtailscale.git
|
url = https://github.com/tailscale/libtailscale.git
|
||||||
[submodule "src-tauri/umu/umu-launcher"]
|
[submodule "libs/drop-base"]
|
||||||
path = src-tauri/umu/umu-launcher
|
path = libs/drop-base
|
||||||
url = https://github.com/Open-Wine-Components/umu-launcher.git
|
url = https://github.com/drop-oss/drop-base.git
|
||||||
|
|||||||
@ -4,7 +4,7 @@ Drop app is the companion app for [Drop](https://github.com/Drop-OSS/drop). It u
|
|||||||
|
|
||||||
## Running
|
## Running
|
||||||
Before setting up the drop app, be sure that you have a server set up.
|
Before setting up the drop app, be sure that you have a server set up.
|
||||||
The instructions for this can be found on the [Drop Wiki](https://wiki.droposs.org/guides/quickstart.html)
|
The instructions for this can be found on the [Drop Docs](https://docs.droposs.org/docs/guides/quickstart)
|
||||||
|
|
||||||
## Current features
|
## Current features
|
||||||
Currently supported are the following features:
|
Currently supported are the following features:
|
||||||
|
|||||||
55
build.mjs
Normal file
55
build.mjs
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
import fs from "fs";
|
||||||
|
import process from "process";
|
||||||
|
import childProcess from "child_process";
|
||||||
|
import createLogger from "pino";
|
||||||
|
|
||||||
|
const OUTPUT = "./.output";
|
||||||
|
const logger = createLogger({ transport: { target: "pino-pretty" } });
|
||||||
|
|
||||||
|
async function spawn(exec, opts) {
|
||||||
|
const output = childProcess.spawn(exec, { ...opts, shell: true });
|
||||||
|
output.stdout.on("data", (data) => {
|
||||||
|
process.stdout.write(data);
|
||||||
|
});
|
||||||
|
output.stderr.on("data", (data) => {
|
||||||
|
process.stderr.write(data);
|
||||||
|
});
|
||||||
|
|
||||||
|
return await new Promise((resolve, reject) => {
|
||||||
|
output.on("error", (err) => reject(err));
|
||||||
|
output.on("exit", () => resolve());
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
const expectedLibs = ["drop-base/package.json"];
|
||||||
|
|
||||||
|
for (const lib of expectedLibs) {
|
||||||
|
const path = `./libs/${lib}`;
|
||||||
|
if (!fs.existsSync(path)) throw `Missing "${expectedLibs}". Run "git submodule update --init --recursive"`;
|
||||||
|
}
|
||||||
|
|
||||||
|
const views = fs.readdirSync(".").filter((view) => {
|
||||||
|
const expectedPath = `./${view}/package.json`;
|
||||||
|
return fs.existsSync(expectedPath);
|
||||||
|
});
|
||||||
|
|
||||||
|
fs.mkdirSync(OUTPUT, { recursive: true });
|
||||||
|
|
||||||
|
for (const view of views) {
|
||||||
|
const loggerChild = logger.child({});
|
||||||
|
process.chdir(`./${view}`);
|
||||||
|
|
||||||
|
loggerChild.info(`Install deps for "${view}"`);
|
||||||
|
await spawn("yarn");
|
||||||
|
|
||||||
|
loggerChild.info(`Building "${view}"`);
|
||||||
|
await spawn("yarn build", {
|
||||||
|
env: { ...process.env, NUXT_APP_BASE_URL: `/${view}/` },
|
||||||
|
});
|
||||||
|
|
||||||
|
process.chdir("..");
|
||||||
|
|
||||||
|
fs.cpSync(`./${view}/.output/public`, `${OUTPUT}/${view}`, {
|
||||||
|
recursive: true,
|
||||||
|
});
|
||||||
|
}
|
||||||
@ -1,177 +0,0 @@
|
|||||||
<template>
|
|
||||||
<div>
|
|
||||||
<div
|
|
||||||
class="relative mb-3 transition-transform duration-300 hover:scale-105 active:scale-95"
|
|
||||||
>
|
|
||||||
<div
|
|
||||||
class="pointer-events-none absolute inset-y-0 left-0 flex items-center pl-3"
|
|
||||||
>
|
|
||||||
<MagnifyingGlassIcon class="h-5 w-5 text-zinc-400" aria-hidden="true" />
|
|
||||||
</div>
|
|
||||||
<input
|
|
||||||
type="text"
|
|
||||||
v-model="searchQuery"
|
|
||||||
class="block w-full rounded-lg border-0 bg-zinc-800/50 py-2 pl-10 pr-3 text-zinc-100 placeholder:text-zinc-500 focus:bg-zinc-800 focus:ring-2 focus:ring-inset focus:ring-blue-500 sm:text-sm sm:leading-6"
|
|
||||||
placeholder="Search library..."
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<TransitionGroup name="list" tag="ul" class="flex flex-col gap-y-1.5">
|
|
||||||
<NuxtLink
|
|
||||||
v-for="nav in filteredNavigation"
|
|
||||||
:key="nav.id"
|
|
||||||
:class="[
|
|
||||||
'transition-all duration-300 rounded-lg flex items-center py-2 px-3 hover:scale-105 active:scale-95 hover:shadow-lg hover:shadow-zinc-950/50',
|
|
||||||
nav.index === currentNavigation
|
|
||||||
? 'bg-zinc-800 text-zinc-100 shadow-md shadow-zinc-950/20'
|
|
||||||
: nav.isInstalled.value
|
|
||||||
? 'text-zinc-300 hover:bg-zinc-800/90 hover:text-zinc-200'
|
|
||||||
: 'text-zinc-500 hover:bg-zinc-800/70 hover:text-zinc-300',
|
|
||||||
]"
|
|
||||||
:href="nav.route"
|
|
||||||
>
|
|
||||||
<div class="flex items-center w-full gap-x-3">
|
|
||||||
<div
|
|
||||||
class="flex-none transition-transform duration-300 hover:-rotate-2"
|
|
||||||
>
|
|
||||||
<img
|
|
||||||
class="size-8 object-cover bg-zinc-900 rounded-lg transition-all duration-300 shadow-sm"
|
|
||||||
:src="icons[nav.id]"
|
|
||||||
alt=""
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
<div class="flex flex-col flex-1">
|
|
||||||
<p
|
|
||||||
class="truncate text-xs font-display leading-5 flex-1 font-semibold"
|
|
||||||
>
|
|
||||||
{{ nav.label }}
|
|
||||||
</p>
|
|
||||||
<p
|
|
||||||
class="text-xs font-medium"
|
|
||||||
:class="[gameStatusTextStyle[games[nav.id].status.value.type]]"
|
|
||||||
>
|
|
||||||
{{ gameStatusText[games[nav.id].status.value.type] }}
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</NuxtLink>
|
|
||||||
</TransitionGroup>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script setup lang="ts">
|
|
||||||
import { MagnifyingGlassIcon } from "@heroicons/vue/20/solid";
|
|
||||||
import { invoke } from "@tauri-apps/api/core";
|
|
||||||
import { GameStatusEnum, type Game, type GameStatus } from "~/types";
|
|
||||||
import { TransitionGroup } from "vue";
|
|
||||||
import { listen } from "@tauri-apps/api/event";
|
|
||||||
|
|
||||||
// Style information
|
|
||||||
const gameStatusTextStyle: { [key in GameStatusEnum]: string } = {
|
|
||||||
[GameStatusEnum.Installed]: "text-green-500",
|
|
||||||
[GameStatusEnum.Downloading]: "text-blue-500",
|
|
||||||
[GameStatusEnum.Running]: "text-green-500",
|
|
||||||
[GameStatusEnum.Remote]: "text-zinc-500",
|
|
||||||
[GameStatusEnum.Queued]: "text-blue-500",
|
|
||||||
[GameStatusEnum.Updating]: "text-blue-500",
|
|
||||||
[GameStatusEnum.Uninstalling]: "text-zinc-100",
|
|
||||||
[GameStatusEnum.SetupRequired]: "text-yellow-500",
|
|
||||||
};
|
|
||||||
const gameStatusText: { [key in GameStatusEnum]: string } = {
|
|
||||||
[GameStatusEnum.Remote]: "Not installed",
|
|
||||||
[GameStatusEnum.Queued]: "Queued",
|
|
||||||
[GameStatusEnum.Downloading]: "Downloading...",
|
|
||||||
[GameStatusEnum.Installed]: "Installed",
|
|
||||||
[GameStatusEnum.Updating]: "Updating...",
|
|
||||||
[GameStatusEnum.Uninstalling]: "Uninstalling...",
|
|
||||||
[GameStatusEnum.SetupRequired]: "Setup required",
|
|
||||||
[GameStatusEnum.Running]: "Running",
|
|
||||||
};
|
|
||||||
|
|
||||||
const router = useRouter();
|
|
||||||
|
|
||||||
const searchQuery = ref("");
|
|
||||||
|
|
||||||
const games: {
|
|
||||||
[key: string]: { game: Game; status: Ref<GameStatus, GameStatus> };
|
|
||||||
} = {};
|
|
||||||
const icons: { [key: string]: string } = {};
|
|
||||||
|
|
||||||
const rawGames: Ref<Game[], Game[]> = ref([]);
|
|
||||||
|
|
||||||
async function calculateGames() {
|
|
||||||
rawGames.value = await invoke("fetch_library");
|
|
||||||
for (const game of rawGames.value) {
|
|
||||||
if (games[game.id]) continue;
|
|
||||||
games[game.id] = await useGame(game.id);
|
|
||||||
}
|
|
||||||
for (const game of rawGames.value) {
|
|
||||||
if (icons[game.id]) continue;
|
|
||||||
icons[game.id] = await useObject(game.mIconObjectId);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
await calculateGames();
|
|
||||||
|
|
||||||
const navigation = computed(() =>
|
|
||||||
rawGames.value.map((game) => {
|
|
||||||
const status = games[game.id].status;
|
|
||||||
|
|
||||||
const isInstalled = computed(
|
|
||||||
() =>
|
|
||||||
status.value.type == GameStatusEnum.Installed ||
|
|
||||||
status.value.type == GameStatusEnum.SetupRequired
|
|
||||||
);
|
|
||||||
|
|
||||||
const item = {
|
|
||||||
label: game.mName,
|
|
||||||
route: `/library/${game.id}`,
|
|
||||||
prefix: `/library/${game.id}`,
|
|
||||||
isInstalled,
|
|
||||||
id: game.id,
|
|
||||||
};
|
|
||||||
return item;
|
|
||||||
})
|
|
||||||
);
|
|
||||||
const { currentNavigation, recalculateNavigation } = useCurrentNavigationIndex(
|
|
||||||
navigation.value
|
|
||||||
);
|
|
||||||
|
|
||||||
const filteredNavigation = computed(() => {
|
|
||||||
if (!searchQuery.value)
|
|
||||||
return navigation.value.map((e, i) => ({ ...e, index: i }));
|
|
||||||
const query = searchQuery.value.toLowerCase();
|
|
||||||
return navigation.value
|
|
||||||
.filter((nav) => nav.label.toLowerCase().includes(query))
|
|
||||||
.map((e, i) => ({ ...e, index: i }));
|
|
||||||
});
|
|
||||||
|
|
||||||
listen("update_library", async (event) => {
|
|
||||||
console.log("Updating library");
|
|
||||||
let oldNavigation = navigation.value[currentNavigation.value];
|
|
||||||
await calculateGames();
|
|
||||||
recalculateNavigation();
|
|
||||||
if (oldNavigation !== navigation.value[currentNavigation.value]) {
|
|
||||||
console.log("Triggered");
|
|
||||||
router.push("/library");
|
|
||||||
}
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<style scoped>
|
|
||||||
.list-move,
|
|
||||||
.list-enter-active,
|
|
||||||
.list-leave-active {
|
|
||||||
transition: all 0.3s ease;
|
|
||||||
}
|
|
||||||
|
|
||||||
.list-enter-from,
|
|
||||||
.list-leave-to {
|
|
||||||
opacity: 0;
|
|
||||||
transform: translateX(-30px);
|
|
||||||
}
|
|
||||||
|
|
||||||
.list-leave-active {
|
|
||||||
position: absolute;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
@ -1,3 +0,0 @@
|
|||||||
import type { AppState } from "~/types";
|
|
||||||
|
|
||||||
export const useAppState = () => useState<AppState>("state");
|
|
||||||
@ -1,86 +0,0 @@
|
|||||||
import { invoke } from "@tauri-apps/api/core";
|
|
||||||
import { listen } from "@tauri-apps/api/event";
|
|
||||||
import { type Game, type GameStatus as DownloadStatus, type GameStatusEnum as DownloadStatusEnum, type GameVersion, type DownloadableMetadata, DownloadableType } from "~/types";
|
|
||||||
|
|
||||||
const gameRegistry: { [key: string]: { game: Game; version?: GameVersion } } =
|
|
||||||
{};
|
|
||||||
|
|
||||||
const downloadStatusRegistry: Map<DownloadableMetadata, Ref<DownloadStatus>> = new Map();
|
|
||||||
|
|
||||||
type OptionDownloadStatus = { [key in DownloadStatusEnum]: { version_name?: string } };
|
|
||||||
export type SerializedDownloadStatus = [
|
|
||||||
{ type: DownloadStatusEnum },
|
|
||||||
OptionDownloadStatus | null
|
|
||||||
];
|
|
||||||
|
|
||||||
export const parseStatus = (status: SerializedDownloadStatus): DownloadStatus => {
|
|
||||||
console.log(status);
|
|
||||||
if (status[0]) {
|
|
||||||
return {
|
|
||||||
type: status[0].type,
|
|
||||||
};
|
|
||||||
} else if (status[1]) {
|
|
||||||
const [[gameStatus, options]] = Object.entries(status[1]);
|
|
||||||
return {
|
|
||||||
type: gameStatus as DownloadStatusEnum,
|
|
||||||
...options,
|
|
||||||
};
|
|
||||||
} else {
|
|
||||||
throw new Error("No game status");
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
export const useStatus = (meta: DownloadableMetadata) => {
|
|
||||||
return downloadStatusRegistry.get(meta)
|
|
||||||
}
|
|
||||||
|
|
||||||
export const useGame = async (gameId: string) => {
|
|
||||||
const data: {
|
|
||||||
game: Game;
|
|
||||||
status: SerializedDownloadStatus;
|
|
||||||
version?: GameVersion;
|
|
||||||
} = await invoke("fetch_game", {
|
|
||||||
gameId,
|
|
||||||
});
|
|
||||||
const meta = {
|
|
||||||
id: gameId,
|
|
||||||
version: data.version?.versionName,
|
|
||||||
downloadType: DownloadableType.Game
|
|
||||||
} satisfies DownloadableMetadata;
|
|
||||||
if (!gameRegistry[gameId]) {
|
|
||||||
|
|
||||||
gameRegistry[gameId] = { game: data.game, version: data.version };
|
|
||||||
}
|
|
||||||
if (!downloadStatusRegistry.has(meta)) {
|
|
||||||
downloadStatusRegistry.set(meta, ref(parseStatus(data.status)));
|
|
||||||
|
|
||||||
listen(`update_game/${gameId}`, (event) => {
|
|
||||||
const payload: {
|
|
||||||
status: SerializedDownloadStatus;
|
|
||||||
version?: GameVersion;
|
|
||||||
} = event.payload as any;
|
|
||||||
|
|
||||||
downloadStatusRegistry.get(meta)!.value = parseStatus(payload.status);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* I am not super happy about this.
|
|
||||||
*
|
|
||||||
* This will mean that we will still have a version assigned if we have a game installed then uninstall it.
|
|
||||||
* It is necessary because a flag to check if we should overwrite seems excessive, and this function gets called
|
|
||||||
* on transient state updates.
|
|
||||||
*/
|
|
||||||
if (payload.version) {
|
|
||||||
gameRegistry[gameId].version = payload.version;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
const game = gameRegistry[gameId];
|
|
||||||
const status = downloadStatusRegistry.get(meta)!;
|
|
||||||
return { ...game, status };
|
|
||||||
};
|
|
||||||
|
|
||||||
export type FrontendGameConfiguration = {
|
|
||||||
launchString: string;
|
|
||||||
};
|
|
||||||
Submodule drop-base deleted from 26698e5b06
1
libs/drop-base
Submodule
1
libs/drop-base
Submodule
Submodule libs/drop-base added at 04125e89be
@ -1,4 +1,5 @@
|
|||||||
<template>
|
<template>
|
||||||
|
<NuxtLoadingIndicator color="#2563eb" />
|
||||||
<NuxtLayout class="select-none w-screen h-screen">
|
<NuxtLayout class="select-none w-screen h-screen">
|
||||||
<NuxtPage />
|
<NuxtPage />
|
||||||
<ModalStack />
|
<ModalStack />
|
||||||
@ -9,8 +10,6 @@
|
|||||||
import "~/composables/downloads.js";
|
import "~/composables/downloads.js";
|
||||||
|
|
||||||
import { invoke } from "@tauri-apps/api/core";
|
import { invoke } from "@tauri-apps/api/core";
|
||||||
import { AppStatus } from "~/types";
|
|
||||||
import { listen } from "@tauri-apps/api/event";
|
|
||||||
import { useAppState } from "./composables/app-state.js";
|
import { useAppState } from "./composables/app-state.js";
|
||||||
import {
|
import {
|
||||||
initialNavigation,
|
initialNavigation,
|
||||||
@ -20,23 +19,35 @@ import {
|
|||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
|
|
||||||
const state = useAppState();
|
const state = useAppState();
|
||||||
try {
|
|
||||||
state.value = JSON.parse(await invoke("fetch_state"));
|
|
||||||
} catch (e) {
|
|
||||||
console.error("failed to parse state", e);
|
|
||||||
}
|
|
||||||
|
|
||||||
router.beforeEach(async () => {
|
async function fetchState() {
|
||||||
try {
|
try {
|
||||||
state.value = JSON.parse(await invoke("fetch_state"));
|
state.value = JSON.parse(await invoke("fetch_state"));
|
||||||
|
if (!state.value)
|
||||||
|
throw createError({
|
||||||
|
statusCode: 500,
|
||||||
|
statusMessage: `App state is: ${state.value}`,
|
||||||
|
fatal: true,
|
||||||
|
});
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error("failed to parse state", e);
|
console.error("failed to parse state", e);
|
||||||
|
throw e;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
await fetchState();
|
||||||
|
|
||||||
|
// This is inefficient but apparently we do it lol
|
||||||
|
router.beforeEach(async () => {
|
||||||
|
await fetchState();
|
||||||
});
|
});
|
||||||
|
|
||||||
setupHooks();
|
setupHooks();
|
||||||
initialNavigation(state);
|
initialNavigation(state);
|
||||||
|
|
||||||
|
// Setup playtime event listeners
|
||||||
|
const { setupEventListeners } = usePlaytime();
|
||||||
|
setupEventListeners();
|
||||||
|
|
||||||
useHead({
|
useHead({
|
||||||
title: "Drop",
|
title: "Drop",
|
||||||
});
|
});
|
||||||
|
Before Width: | Height: | Size: 6.5 MiB After Width: | Height: | Size: 6.5 MiB |
@ -46,7 +46,7 @@
|
|||||||
class="absolute right-0 z-[500] mt-2 w-32 origin-top-right rounded-md bg-zinc-900 shadow-lg ring-1 ring-zinc-100/5 focus:outline-none"
|
class="absolute right-0 z-[500] mt-2 w-32 origin-top-right rounded-md bg-zinc-900 shadow-lg ring-1 ring-zinc-100/5 focus:outline-none"
|
||||||
>
|
>
|
||||||
<div class="py-1">
|
<div class="py-1">
|
||||||
<MenuItem v-slot="{ active }">
|
<MenuItem v-if="showOptions" v-slot="{ active }">
|
||||||
<button
|
<button
|
||||||
@click="() => emit('options')"
|
@click="() => emit('options')"
|
||||||
:class="[
|
:class="[
|
||||||
@ -87,6 +87,8 @@ import {
|
|||||||
ChevronDownIcon,
|
ChevronDownIcon,
|
||||||
PlayIcon,
|
PlayIcon,
|
||||||
QueueListIcon,
|
QueueListIcon,
|
||||||
|
ServerIcon,
|
||||||
|
StopIcon,
|
||||||
WrenchIcon,
|
WrenchIcon,
|
||||||
} from "@heroicons/vue/20/solid";
|
} from "@heroicons/vue/20/solid";
|
||||||
|
|
||||||
@ -103,12 +105,18 @@ const emit = defineEmits<{
|
|||||||
(e: "uninstall"): void;
|
(e: "uninstall"): void;
|
||||||
(e: "kill"): void;
|
(e: "kill"): void;
|
||||||
(e: "options"): void;
|
(e: "options"): void;
|
||||||
|
(e: "resume"): void;
|
||||||
}>();
|
}>();
|
||||||
|
|
||||||
const showDropdown = computed(
|
const showDropdown = computed(
|
||||||
() =>
|
() =>
|
||||||
props.status.type === GameStatusEnum.Installed ||
|
props.status.type === GameStatusEnum.Installed ||
|
||||||
props.status.type === GameStatusEnum.SetupRequired
|
props.status.type === GameStatusEnum.SetupRequired ||
|
||||||
|
props.status.type === GameStatusEnum.PartiallyInstalled
|
||||||
|
);
|
||||||
|
|
||||||
|
const showOptions = computed(
|
||||||
|
() => props.status.type === GameStatusEnum.Installed
|
||||||
);
|
);
|
||||||
|
|
||||||
const styles: { [key in GameStatusEnum]: string } = {
|
const styles: { [key in GameStatusEnum]: string } = {
|
||||||
@ -118,6 +126,8 @@ const styles: { [key in GameStatusEnum]: string } = {
|
|||||||
"bg-zinc-800 text-white hover:bg-zinc-700 focus-visible:outline-zinc-700 hover:bg-zinc-700",
|
"bg-zinc-800 text-white hover:bg-zinc-700 focus-visible:outline-zinc-700 hover:bg-zinc-700",
|
||||||
[GameStatusEnum.Downloading]:
|
[GameStatusEnum.Downloading]:
|
||||||
"bg-zinc-800 text-white hover:bg-zinc-700 focus-visible:outline-zinc-700 hover:bg-zinc-700",
|
"bg-zinc-800 text-white hover:bg-zinc-700 focus-visible:outline-zinc-700 hover:bg-zinc-700",
|
||||||
|
[GameStatusEnum.Validating]:
|
||||||
|
"bg-zinc-800 text-white hover:bg-zinc-700 focus-visible:outline-zinc-700 hover:bg-zinc-700",
|
||||||
[GameStatusEnum.SetupRequired]:
|
[GameStatusEnum.SetupRequired]:
|
||||||
"bg-yellow-600 text-white hover:bg-yellow-500 focus-visible:outline-yellow-600 hover:bg-yellow-500",
|
"bg-yellow-600 text-white hover:bg-yellow-500 focus-visible:outline-yellow-600 hover:bg-yellow-500",
|
||||||
[GameStatusEnum.Installed]:
|
[GameStatusEnum.Installed]:
|
||||||
@ -128,38 +138,46 @@ const styles: { [key in GameStatusEnum]: string } = {
|
|||||||
"bg-zinc-800 text-white hover:bg-zinc-700 focus-visible:outline-zinc-700 hover:bg-zinc-700",
|
"bg-zinc-800 text-white hover:bg-zinc-700 focus-visible:outline-zinc-700 hover:bg-zinc-700",
|
||||||
[GameStatusEnum.Running]:
|
[GameStatusEnum.Running]:
|
||||||
"bg-zinc-800 text-white hover:bg-zinc-700 focus-visible:outline-zinc-700 hover:bg-zinc-700",
|
"bg-zinc-800 text-white hover:bg-zinc-700 focus-visible:outline-zinc-700 hover:bg-zinc-700",
|
||||||
|
[GameStatusEnum.PartiallyInstalled]:
|
||||||
|
"bg-blue-600 text-white hover:bg-blue-500 focus-visible:outline-blue-600 hover:bg-blue-500",
|
||||||
};
|
};
|
||||||
|
|
||||||
const buttonNames: { [key in GameStatusEnum]: string } = {
|
const buttonNames: { [key in GameStatusEnum]: string } = {
|
||||||
[GameStatusEnum.Remote]: "Install",
|
[GameStatusEnum.Remote]: "Install",
|
||||||
[GameStatusEnum.Queued]: "Queued",
|
[GameStatusEnum.Queued]: "Queued",
|
||||||
[GameStatusEnum.Downloading]: "Downloading",
|
[GameStatusEnum.Downloading]: "Downloading",
|
||||||
|
[GameStatusEnum.Validating]: "Validating",
|
||||||
[GameStatusEnum.SetupRequired]: "Setup",
|
[GameStatusEnum.SetupRequired]: "Setup",
|
||||||
[GameStatusEnum.Installed]: "Play",
|
[GameStatusEnum.Installed]: "Play",
|
||||||
[GameStatusEnum.Updating]: "Updating",
|
[GameStatusEnum.Updating]: "Updating",
|
||||||
[GameStatusEnum.Uninstalling]: "Uninstalling",
|
[GameStatusEnum.Uninstalling]: "Uninstalling",
|
||||||
[GameStatusEnum.Running]: "Stop",
|
[GameStatusEnum.Running]: "Stop",
|
||||||
|
[GameStatusEnum.PartiallyInstalled]: "Resume",
|
||||||
};
|
};
|
||||||
|
|
||||||
const buttonIcons: { [key in GameStatusEnum]: Component } = {
|
const buttonIcons: { [key in GameStatusEnum]: Component } = {
|
||||||
[GameStatusEnum.Remote]: ArrowDownTrayIcon,
|
[GameStatusEnum.Remote]: ArrowDownTrayIcon,
|
||||||
[GameStatusEnum.Queued]: QueueListIcon,
|
[GameStatusEnum.Queued]: QueueListIcon,
|
||||||
[GameStatusEnum.Downloading]: ArrowDownTrayIcon,
|
[GameStatusEnum.Downloading]: ArrowDownTrayIcon,
|
||||||
|
[GameStatusEnum.Validating]: ServerIcon,
|
||||||
[GameStatusEnum.SetupRequired]: WrenchIcon,
|
[GameStatusEnum.SetupRequired]: WrenchIcon,
|
||||||
[GameStatusEnum.Installed]: PlayIcon,
|
[GameStatusEnum.Installed]: PlayIcon,
|
||||||
[GameStatusEnum.Updating]: ArrowDownTrayIcon,
|
[GameStatusEnum.Updating]: ArrowDownTrayIcon,
|
||||||
[GameStatusEnum.Uninstalling]: TrashIcon,
|
[GameStatusEnum.Uninstalling]: TrashIcon,
|
||||||
[GameStatusEnum.Running]: PlayIcon,
|
[GameStatusEnum.Running]: StopIcon,
|
||||||
|
[GameStatusEnum.PartiallyInstalled]: ArrowDownTrayIcon,
|
||||||
};
|
};
|
||||||
|
|
||||||
const buttonActions: { [key in GameStatusEnum]: () => void } = {
|
const buttonActions: { [key in GameStatusEnum]: () => void } = {
|
||||||
[GameStatusEnum.Remote]: () => emit("install"),
|
[GameStatusEnum.Remote]: () => emit("install"),
|
||||||
[GameStatusEnum.Queued]: () => emit("queue"),
|
[GameStatusEnum.Queued]: () => emit("queue"),
|
||||||
[GameStatusEnum.Downloading]: () => emit("queue"),
|
[GameStatusEnum.Downloading]: () => emit("queue"),
|
||||||
|
[GameStatusEnum.Validating]: () => emit("queue"),
|
||||||
[GameStatusEnum.SetupRequired]: () => emit("launch"),
|
[GameStatusEnum.SetupRequired]: () => emit("launch"),
|
||||||
[GameStatusEnum.Installed]: () => emit("launch"),
|
[GameStatusEnum.Installed]: () => emit("launch"),
|
||||||
[GameStatusEnum.Updating]: () => emit("queue"),
|
[GameStatusEnum.Updating]: () => emit("queue"),
|
||||||
[GameStatusEnum.Uninstalling]: () => {},
|
[GameStatusEnum.Uninstalling]: () => {},
|
||||||
[GameStatusEnum.Running]: () => emit("kill"),
|
[GameStatusEnum.Running]: () => emit("kill"),
|
||||||
|
[GameStatusEnum.PartiallyInstalled]: () => emit("resume"),
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
@ -37,7 +37,7 @@
|
|||||||
<component class="h-5" :is="item.icon" />
|
<component class="h-5" :is="item.icon" />
|
||||||
</HeaderWidget>
|
</HeaderWidget>
|
||||||
</li>
|
</li>
|
||||||
<OfflineHeaderWidget v-if="state.status === AppStatus.Offline" />
|
<OfflineHeaderWidget v-if="state?.status === AppStatus.Offline" />
|
||||||
<HeaderUserWidget />
|
<HeaderUserWidget />
|
||||||
</ol>
|
</ol>
|
||||||
</div>
|
</div>
|
||||||
@ -1,5 +1,5 @@
|
|||||||
<template>
|
<template>
|
||||||
<Menu v-if="state.user" as="div" class="relative inline-block">
|
<Menu v-if="state?.user" as="div" class="relative inline-block">
|
||||||
<MenuButton>
|
<MenuButton>
|
||||||
<HeaderWidget>
|
<HeaderWidget>
|
||||||
<div class="inline-flex items-center text-zinc-300 hover:text-white">
|
<div class="inline-flex items-center text-zinc-300 hover:text-white">
|
||||||
@ -23,7 +23,7 @@
|
|||||||
<MenuItems
|
<MenuItems
|
||||||
class="absolute bg-zinc-900 right-0 top-10 z-50 w-56 origin-top-right focus:outline-none shadow-md"
|
class="absolute bg-zinc-900 right-0 top-10 z-50 w-56 origin-top-right focus:outline-none shadow-md"
|
||||||
>
|
>
|
||||||
<PanelWidget class="flex-col gap-y-2">
|
<div class="flex-col gap-y-2">
|
||||||
<NuxtLink
|
<NuxtLink
|
||||||
to="/id/me"
|
to="/id/me"
|
||||||
class="transition inline-flex items-center w-full py-3 px-4 hover:bg-zinc-800"
|
class="transition inline-flex items-center w-full py-3 px-4 hover:bg-zinc-800"
|
||||||
@ -37,7 +37,7 @@
|
|||||||
</NuxtLink>
|
</NuxtLink>
|
||||||
<div class="h-0.5 rounded-full w-full bg-zinc-800" />
|
<div class="h-0.5 rounded-full w-full bg-zinc-800" />
|
||||||
<div class="flex flex-col mb-1">
|
<div class="flex flex-col mb-1">
|
||||||
<MenuItem v-slot="{ active }">
|
<MenuItem v-if="state.user.admin" v-slot="{ active }">
|
||||||
<a
|
<a
|
||||||
:href="adminUrl"
|
:href="adminUrl"
|
||||||
target="_blank"
|
target="_blank"
|
||||||
@ -65,7 +65,7 @@
|
|||||||
</button>
|
</button>
|
||||||
</MenuItem>
|
</MenuItem>
|
||||||
</div>
|
</div>
|
||||||
</PanelWidget>
|
</div>
|
||||||
</MenuItems>
|
</MenuItems>
|
||||||
</transition>
|
</transition>
|
||||||
</Menu>
|
</Menu>
|
||||||
@ -87,7 +87,7 @@ router.afterEach(() => {
|
|||||||
|
|
||||||
const state = useAppState();
|
const state = useAppState();
|
||||||
const profilePictureUrl: string = await useObject(
|
const profilePictureUrl: string = await useObject(
|
||||||
state.value.user?.profilePictureObjectId ?? ""
|
state.value?.user?.profilePictureObjectId ?? ""
|
||||||
);
|
);
|
||||||
const adminUrl: string = await invoke("gen_drop_url", {
|
const adminUrl: string = await invoke("gen_drop_url", {
|
||||||
path: "/admin",
|
path: "/admin",
|
||||||
@ -13,11 +13,7 @@
|
|||||||
<div class="max-w-lg">
|
<div class="max-w-lg">
|
||||||
<slot />
|
<slot />
|
||||||
<div class="mt-10">
|
<div class="mt-10">
|
||||||
<button
|
<div>
|
||||||
@click="() => authWrapper_wrapper()"
|
|
||||||
:disabled="loading"
|
|
||||||
class="text-sm text-left font-semibold leading-7 text-blue-600"
|
|
||||||
>
|
|
||||||
<div v-if="loading" role="status">
|
<div v-if="loading" role="status">
|
||||||
<svg
|
<svg
|
||||||
aria-hidden="true"
|
aria-hidden="true"
|
||||||
@ -37,10 +33,19 @@
|
|||||||
</svg>
|
</svg>
|
||||||
<span class="sr-only">Loading...</span>
|
<span class="sr-only">Loading...</span>
|
||||||
</div>
|
</div>
|
||||||
<span v-else>
|
<span class="inline-flex gap-x-8 items-center" v-else>
|
||||||
Sign in with your browser <span aria-hidden="true">→</span>
|
<button
|
||||||
|
@click="() => authWrapper_wrapper()"
|
||||||
|
:disabled="loading"
|
||||||
|
class="px-3 py-1 inline-flex items-center gap-x-2 bg-zinc-700 rounded text-sm text-left font-semibold leading-7 text-white"
|
||||||
|
>
|
||||||
|
Sign in with your browser <ArrowTopRightOnSquareIcon class="size-4" />
|
||||||
|
</button>
|
||||||
|
<NuxtLink href="/auth/code" class="text-zinc-100 text-sm hover:text-zinc-300">
|
||||||
|
Use a code →
|
||||||
|
</NuxtLink>
|
||||||
</span>
|
</span>
|
||||||
</button>
|
</div>
|
||||||
|
|
||||||
<div class="mt-5" v-if="offerManual">
|
<div class="mt-5" v-if="offerManual">
|
||||||
<h1 class="text-zinc-100 font-semibold">Having trouble?</h1>
|
<h1 class="text-zinc-100 font-semibold">Having trouble?</h1>
|
||||||
@ -121,6 +126,7 @@
|
|||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { XCircleIcon } from "@heroicons/vue/16/solid";
|
import { XCircleIcon } from "@heroicons/vue/16/solid";
|
||||||
|
import { ArrowTopRightOnSquareIcon } from "@heroicons/vue/20/solid";
|
||||||
import { invoke } from "@tauri-apps/api/core";
|
import { invoke } from "@tauri-apps/api/core";
|
||||||
|
|
||||||
const loading = ref(false);
|
const loading = ref(false);
|
||||||
303
main/components/LibrarySearch.vue
Normal file
303
main/components/LibrarySearch.vue
Normal file
@ -0,0 +1,303 @@
|
|||||||
|
<template>
|
||||||
|
<div class="flex flex-col h-full">
|
||||||
|
<div class="mb-3 inline-flex gap-x-2">
|
||||||
|
<div
|
||||||
|
class="relative transition-transform duration-300 hover:scale-105 active:scale-95"
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
class="pointer-events-none absolute inset-y-0 left-0 flex items-center pl-3"
|
||||||
|
>
|
||||||
|
<MagnifyingGlassIcon
|
||||||
|
class="h-5 w-5 text-zinc-400"
|
||||||
|
aria-hidden="true"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<input
|
||||||
|
type="text"
|
||||||
|
v-model="searchQuery"
|
||||||
|
class="block w-full rounded-lg border-0 bg-zinc-800/50 py-2 pl-10 pr-3 text-zinc-100 placeholder:text-zinc-500 focus:bg-zinc-800 focus:ring-2 focus:ring-inset focus:ring-blue-500 sm:text-sm sm:leading-6"
|
||||||
|
placeholder="Search library..."
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<button
|
||||||
|
@click="() => calculateGames(true, true)"
|
||||||
|
class="p-1 flex items-center justify-center transition-transform duration-300 size-10 hover:scale-110 active:scale-90 rounded-lg bg-zinc-800/50 text-zinc-100"
|
||||||
|
>
|
||||||
|
<ArrowPathIcon class="size-4" />
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<TransitionGroup name="list" tag="ul" class="flex flex-col gap-y-1.5">
|
||||||
|
<Disclosure
|
||||||
|
as="div"
|
||||||
|
v-for="(nav, navIndex) in filteredNavigation"
|
||||||
|
:key="nav.id"
|
||||||
|
class="first:pt-0 last:pb-0"
|
||||||
|
v-slot="{ open }"
|
||||||
|
:default-open="nav.deft"
|
||||||
|
>
|
||||||
|
<dt>
|
||||||
|
<DisclosureButton
|
||||||
|
class="flex w-full items-center justify-between text-left text-gray-900 dark:text-white"
|
||||||
|
>
|
||||||
|
<span class="text-sm font-semibold font-display">{{
|
||||||
|
nav.name
|
||||||
|
}}</span>
|
||||||
|
<span class="ml-6 flex h-7 items-center">
|
||||||
|
<PlusSmallIcon v-if="!open" class="size-6" aria-hidden="true" />
|
||||||
|
<MinusSmallIcon v-else class="size-6" aria-hidden="true" />
|
||||||
|
</span>
|
||||||
|
</DisclosureButton>
|
||||||
|
</dt>
|
||||||
|
<DisclosurePanel as="dd" class="mt-2 flex flex-col gap-y-1.5">
|
||||||
|
<NuxtLink
|
||||||
|
v-for="item in nav.items"
|
||||||
|
:key="nav.id"
|
||||||
|
:class="[
|
||||||
|
'transition-all duration-300 rounded-lg flex items-center px-1 py-1.5 hover:scale-105 active:scale-95 hover:shadow-lg hover:shadow-zinc-950/50',
|
||||||
|
currentNavigation == item.id
|
||||||
|
? 'bg-zinc-800 text-zinc-100 shadow-md shadow-zinc-950/20'
|
||||||
|
: item.isInstalled.value
|
||||||
|
? 'text-zinc-300 hover:bg-zinc-800/90 hover:text-zinc-200'
|
||||||
|
: 'text-zinc-500 hover:bg-zinc-800/70 hover:text-zinc-300',
|
||||||
|
]"
|
||||||
|
:href="item.route"
|
||||||
|
>
|
||||||
|
<div class="flex items-center w-full gap-x-2">
|
||||||
|
<div
|
||||||
|
class="flex-none transition-transform duration-300 hover:-rotate-2"
|
||||||
|
>
|
||||||
|
<img
|
||||||
|
class="size-6 object-cover bg-zinc-900 rounded transition-all duration-300 shadow-sm"
|
||||||
|
:src="icons[item.id]"
|
||||||
|
alt=""
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<div class="inline-flex items-center gap-x-2">
|
||||||
|
<p
|
||||||
|
class="text-sm whitespace-nowrap font-display font-semibold"
|
||||||
|
>
|
||||||
|
{{ item.label }}
|
||||||
|
</p>
|
||||||
|
<p
|
||||||
|
class="truncate text-[10px] font-bold uppercase font-display"
|
||||||
|
:class="[
|
||||||
|
gameStatusTextStyle[games[item.id].status.value.type],
|
||||||
|
]"
|
||||||
|
>
|
||||||
|
{{ gameStatusText[games[item.id].status.value.type] }}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</NuxtLink>
|
||||||
|
</DisclosurePanel>
|
||||||
|
</Disclosure>
|
||||||
|
</TransitionGroup>
|
||||||
|
<div
|
||||||
|
v-if="loading"
|
||||||
|
class="h-full grow flex p-8 justify-center text-zinc-100"
|
||||||
|
>
|
||||||
|
<div role="status">
|
||||||
|
<svg
|
||||||
|
aria-hidden="true"
|
||||||
|
class="w-6 h-6 text-transparent animate-spin fill-zinc-600"
|
||||||
|
viewBox="0 0 100 101"
|
||||||
|
fill="none"
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
>
|
||||||
|
<path
|
||||||
|
d="M100 50.5908C100 78.2051 77.6142 100.591 50 100.591C22.3858 100.591 0 78.2051 0 50.5908C0 22.9766 22.3858 0.59082 50 0.59082C77.6142 0.59082 100 22.9766 100 50.5908ZM9.08144 50.5908C9.08144 73.1895 27.4013 91.5094 50 91.5094C72.5987 91.5094 90.9186 73.1895 90.9186 50.5908C90.9186 27.9921 72.5987 9.67226 50 9.67226C27.4013 9.67226 9.08144 27.9921 9.08144 50.5908Z"
|
||||||
|
fill="currentColor"
|
||||||
|
/>
|
||||||
|
<path
|
||||||
|
d="M93.9676 39.0409C96.393 38.4038 97.8624 35.9116 97.0079 33.5539C95.2932 28.8227 92.871 24.3692 89.8167 20.348C85.8452 15.1192 80.8826 10.7238 75.2124 7.41289C69.5422 4.10194 63.2754 1.94025 56.7698 1.05124C51.7666 0.367541 46.6976 0.446843 41.7345 1.27873C39.2613 1.69328 37.813 4.19778 38.4501 6.62326C39.0873 9.04874 41.5694 10.4717 44.0505 10.1071C47.8511 9.54855 51.7191 9.52689 55.5402 10.0491C60.8642 10.7766 65.9928 12.5457 70.6331 15.2552C75.2735 17.9648 79.3347 21.5619 82.5849 25.841C84.9175 28.9121 86.7997 32.2913 88.1811 35.8758C89.083 38.2158 91.5421 39.6781 93.9676 39.0409Z"
|
||||||
|
fill="currentFill"
|
||||||
|
/>
|
||||||
|
</svg>
|
||||||
|
<span class="sr-only">Loading...</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
|
import { Disclosure, DisclosureButton, DisclosurePanel } from "@headlessui/vue";
|
||||||
|
import {
|
||||||
|
ArrowPathIcon,
|
||||||
|
MagnifyingGlassIcon,
|
||||||
|
MinusSmallIcon,
|
||||||
|
PlusSmallIcon,
|
||||||
|
} from "@heroicons/vue/20/solid";
|
||||||
|
import { invoke } from "@tauri-apps/api/core";
|
||||||
|
import {
|
||||||
|
GameStatusEnum,
|
||||||
|
type Collection as Collection,
|
||||||
|
type Game,
|
||||||
|
type GameStatus,
|
||||||
|
} from "~/types";
|
||||||
|
import { TransitionGroup } from "vue";
|
||||||
|
import { listen } from "@tauri-apps/api/event";
|
||||||
|
|
||||||
|
// Style information
|
||||||
|
const gameStatusTextStyle: { [key in GameStatusEnum]: string } = {
|
||||||
|
[GameStatusEnum.Installed]: "text-green-500",
|
||||||
|
[GameStatusEnum.Downloading]: "text-zinc-400",
|
||||||
|
[GameStatusEnum.Validating]: "text-blue-300",
|
||||||
|
[GameStatusEnum.Running]: "text-green-500",
|
||||||
|
[GameStatusEnum.Remote]: "text-zinc-700",
|
||||||
|
[GameStatusEnum.Queued]: "text-zinc-400",
|
||||||
|
[GameStatusEnum.Updating]: "text-zinc-400",
|
||||||
|
[GameStatusEnum.Uninstalling]: "text-zinc-100",
|
||||||
|
[GameStatusEnum.SetupRequired]: "text-yellow-500",
|
||||||
|
[GameStatusEnum.PartiallyInstalled]: "text-gray-400",
|
||||||
|
};
|
||||||
|
const gameStatusText: { [key in GameStatusEnum]: string } = {
|
||||||
|
[GameStatusEnum.Remote]: "Not installed",
|
||||||
|
[GameStatusEnum.Queued]: "Queued",
|
||||||
|
[GameStatusEnum.Downloading]: "Downloading...",
|
||||||
|
[GameStatusEnum.Validating]: "Validating...",
|
||||||
|
[GameStatusEnum.Installed]: "Installed",
|
||||||
|
[GameStatusEnum.Updating]: "Updating...",
|
||||||
|
[GameStatusEnum.Uninstalling]: "Uninstalling...",
|
||||||
|
[GameStatusEnum.SetupRequired]: "Setup required",
|
||||||
|
[GameStatusEnum.Running]: "Running",
|
||||||
|
[GameStatusEnum.PartiallyInstalled]: "Partially installed",
|
||||||
|
};
|
||||||
|
|
||||||
|
const router = useRouter();
|
||||||
|
|
||||||
|
const searchQuery = ref("");
|
||||||
|
|
||||||
|
const loading = ref(false);
|
||||||
|
const games: {
|
||||||
|
[key: string]: { game: Game; status: Ref<GameStatus, GameStatus> };
|
||||||
|
} = {};
|
||||||
|
const icons: { [key: string]: string } = {};
|
||||||
|
|
||||||
|
const collections: Ref<Collection[]> = ref([]);
|
||||||
|
|
||||||
|
async function calculateGames(clearAll = false, forceRefresh = false) {
|
||||||
|
if (clearAll) {
|
||||||
|
collections.value = [];
|
||||||
|
loading.value = true;
|
||||||
|
}
|
||||||
|
// If we update immediately, the navigation gets re-rendered before we
|
||||||
|
// add all the necessary state, and it freaks tf out
|
||||||
|
const newGames = await invoke<Game[]>("fetch_library", {
|
||||||
|
hardRefresh: forceRefresh,
|
||||||
|
});
|
||||||
|
const otherCollections = await invoke<Collection[]>("fetch_collections", {
|
||||||
|
hardRefresh: forceRefresh,
|
||||||
|
});
|
||||||
|
const allGames = [
|
||||||
|
...newGames,
|
||||||
|
...otherCollections
|
||||||
|
.map((e) => e.entries)
|
||||||
|
.flat()
|
||||||
|
.map((e) => e.game),
|
||||||
|
].filter((v, i, a) => a.indexOf(v) === i);
|
||||||
|
|
||||||
|
for (const game of allGames) {
|
||||||
|
if (games[game.id]) continue;
|
||||||
|
games[game.id] = await useGame(game.id);
|
||||||
|
}
|
||||||
|
for (const game of allGames) {
|
||||||
|
if (icons[game.id]) continue;
|
||||||
|
icons[game.id] = await useObject(game.mIconObjectId);
|
||||||
|
}
|
||||||
|
|
||||||
|
const libraryCollection = {
|
||||||
|
id: "library",
|
||||||
|
name: "Library",
|
||||||
|
isDefault: true,
|
||||||
|
entries: newGames.map((e) => ({ gameId: e.id, game: e })),
|
||||||
|
} satisfies Collection;
|
||||||
|
|
||||||
|
loading.value = false;
|
||||||
|
collections.value = [libraryCollection, ...otherCollections];
|
||||||
|
}
|
||||||
|
|
||||||
|
// Wait up to 300 ms for the library to load, otherwise
|
||||||
|
// show the loading state while we while
|
||||||
|
await new Promise<void>((r) => {
|
||||||
|
let hasResolved = false;
|
||||||
|
const resolveFunc = () => {
|
||||||
|
if (!hasResolved) r();
|
||||||
|
hasResolved = true;
|
||||||
|
};
|
||||||
|
calculateGames(true).then(resolveFunc);
|
||||||
|
setTimeout(resolveFunc, 300);
|
||||||
|
});
|
||||||
|
|
||||||
|
const navigation = computed(() =>
|
||||||
|
collections.value.map((collection) => {
|
||||||
|
const items = collection.entries.map(({ game }) => {
|
||||||
|
const status = games[game.id].status;
|
||||||
|
|
||||||
|
const isInstalled = computed(
|
||||||
|
() => status.value.type != GameStatusEnum.Remote
|
||||||
|
);
|
||||||
|
|
||||||
|
const item = {
|
||||||
|
label: game.mName,
|
||||||
|
route: `/library/${game.id}`,
|
||||||
|
prefix: `/library/${game.id}`,
|
||||||
|
isInstalled,
|
||||||
|
id: game.id,
|
||||||
|
};
|
||||||
|
return item;
|
||||||
|
});
|
||||||
|
|
||||||
|
return {
|
||||||
|
id: collection.id,
|
||||||
|
name: collection.name,
|
||||||
|
deft: collection.isDefault,
|
||||||
|
items,
|
||||||
|
};
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
|
const route = useRoute();
|
||||||
|
const currentNavigation = computed(() => {
|
||||||
|
return route.path.slice("/library/".length);
|
||||||
|
});
|
||||||
|
|
||||||
|
const filteredNavigation = computed(() => {
|
||||||
|
if (!searchQuery.value)
|
||||||
|
return navigation.value.map((e, i) => ({ ...e, index: i }));
|
||||||
|
const query = searchQuery.value.toLowerCase();
|
||||||
|
return navigation.value
|
||||||
|
.map((c) => ({
|
||||||
|
...c,
|
||||||
|
items: c.items.filter((nav) => nav.label.toLowerCase().includes(query)),
|
||||||
|
}))
|
||||||
|
.filter((e) => e.items.length > 0);
|
||||||
|
});
|
||||||
|
|
||||||
|
listen("update_library", async (event) => {
|
||||||
|
console.log("Updating library");
|
||||||
|
let oldNavigation = currentNavigation.value;
|
||||||
|
await calculateGames();
|
||||||
|
if (oldNavigation !== currentNavigation.value) {
|
||||||
|
router.push("/library");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.list-move,
|
||||||
|
.list-enter-active,
|
||||||
|
.list-leave-active {
|
||||||
|
transition: all 0.3s ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
.list-enter-from,
|
||||||
|
.list-leave-to {
|
||||||
|
opacity: 0;
|
||||||
|
transform: translateX(-30px);
|
||||||
|
}
|
||||||
|
|
||||||
|
.list-leave-active {
|
||||||
|
position: absolute;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@ -1,6 +1,6 @@
|
|||||||
<template>
|
<template>
|
||||||
<div
|
<div
|
||||||
class="h-10 cursor-pointer flex flex-row items-center justify-between bg-zinc-950"
|
class="h-16 cursor-pointer flex flex-row items-center justify-between bg-zinc-950"
|
||||||
>
|
>
|
||||||
<div class="px-5 py-3 grow" @mousedown="() => window.startDragging()">
|
<div class="px-5 py-3 grow" @mousedown="() => window.startDragging()">
|
||||||
<Wordmark class="mt-1" />
|
<Wordmark class="mt-1" />
|
||||||
53
main/components/PlaytimeDisplay.vue
Normal file
53
main/components/PlaytimeDisplay.vue
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
<template>
|
||||||
|
<div v-if="stats" class="flex flex-col gap-1">
|
||||||
|
<!-- Main playtime display -->
|
||||||
|
<div class="flex items-center gap-2">
|
||||||
|
<ClockIcon class="w-5 h-5 text-zinc-400" />
|
||||||
|
<span class="text-base text-zinc-300 font-medium">
|
||||||
|
{{ formatPlaytime(stats.totalPlaytimeSeconds) }} played
|
||||||
|
</span>
|
||||||
|
<span v-if="isActive && showActiveIndicator" class="text-sm text-green-400 font-medium">
|
||||||
|
• Playing
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Additional details when expanded -->
|
||||||
|
<div v-if="showDetails" class="text-xs text-zinc-400 space-y-1 ml-7">
|
||||||
|
<div>{{ stats.sessionCount }} session{{ stats.sessionCount !== 1 ? 's' : '' }}</div>
|
||||||
|
<div v-if="stats.sessionCount > 0">
|
||||||
|
Avg: {{ formatPlaytime(stats.averageSessionLength) }} per session
|
||||||
|
</div>
|
||||||
|
<div v-if="stats.currentSessionDuration">
|
||||||
|
Current session: {{ formatPlaytime(stats.currentSessionDuration) }}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- No playtime data -->
|
||||||
|
<div v-else-if="showWhenEmpty" class="flex items-center gap-2 text-zinc-500">
|
||||||
|
<ClockIcon class="w-5 h-5" />
|
||||||
|
<span class="text-base">Never played</span>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
|
import { ClockIcon } from "@heroicons/vue/20/solid";
|
||||||
|
import type { GamePlaytimeStats } from "~/types";
|
||||||
|
|
||||||
|
interface Props {
|
||||||
|
stats: GamePlaytimeStats | null;
|
||||||
|
isActive?: boolean;
|
||||||
|
showDetails?: boolean;
|
||||||
|
showWhenEmpty?: boolean;
|
||||||
|
showActiveIndicator?: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
const props = withDefaults(defineProps<Props>(), {
|
||||||
|
isActive: false,
|
||||||
|
showDetails: false,
|
||||||
|
showWhenEmpty: true,
|
||||||
|
showActiveIndicator: true,
|
||||||
|
});
|
||||||
|
|
||||||
|
const { formatPlaytime } = usePlaytime();
|
||||||
|
</script>
|
||||||
76
main/components/PlaytimeStats.vue
Normal file
76
main/components/PlaytimeStats.vue
Normal file
@ -0,0 +1,76 @@
|
|||||||
|
<template>
|
||||||
|
<div class="bg-zinc-800/50 rounded-lg p-4 space-y-4">
|
||||||
|
<div class="flex items-center gap-2">
|
||||||
|
<ChartBarIcon class="w-5 h-5 text-zinc-400" />
|
||||||
|
<h3 class="text-lg font-semibold text-zinc-100">Playtime Statistics</h3>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div v-if="stats" class="grid grid-cols-1 md:grid-cols-2 gap-4">
|
||||||
|
<!-- Total Playtime -->
|
||||||
|
<div class="bg-zinc-700/50 rounded-lg p-3">
|
||||||
|
<div class="flex items-center gap-2 mb-2">
|
||||||
|
<ClockIcon class="w-4 h-4 text-blue-400" />
|
||||||
|
<span class="text-sm font-medium text-zinc-300">Total Playtime</span>
|
||||||
|
</div>
|
||||||
|
<div class="text-2xl font-bold text-zinc-100">
|
||||||
|
{{ formatDetailedPlaytime(stats.totalPlaytimeSeconds) }}
|
||||||
|
</div>
|
||||||
|
<div v-if="stats.currentSessionDuration" class="text-xs text-green-400 mt-1">
|
||||||
|
+{{ formatPlaytime(stats.currentSessionDuration) }} this session
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Sessions -->
|
||||||
|
<div class="bg-zinc-700/50 rounded-lg p-3">
|
||||||
|
<div class="flex items-center gap-2 mb-2">
|
||||||
|
<PlayIcon class="w-4 h-4 text-green-400" />
|
||||||
|
<span class="text-sm font-medium text-zinc-300">Sessions</span>
|
||||||
|
</div>
|
||||||
|
<div class="text-2xl font-bold text-zinc-100">
|
||||||
|
{{ stats.sessionCount }}
|
||||||
|
</div>
|
||||||
|
<div class="text-xs text-zinc-400 mt-1">
|
||||||
|
Avg: {{ formatPlaytime(stats.averageSessionLength) }}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- No stats available -->
|
||||||
|
<div v-else class="text-center py-8">
|
||||||
|
<ClockIcon class="w-12 h-12 text-zinc-600 mx-auto mb-3" />
|
||||||
|
<p class="text-zinc-400">No playtime data available</p>
|
||||||
|
<p class="text-sm text-zinc-500 mt-1">Statistics will appear after you start playing</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Current session indicator -->
|
||||||
|
<div v-if="isActive && stats" class="border-t border-zinc-700 pt-3">
|
||||||
|
<div class="flex items-center gap-2 text-green-400">
|
||||||
|
<div class="w-2 h-2 bg-green-400 rounded-full animate-pulse"></div>
|
||||||
|
<span class="text-sm font-medium">Currently playing</span>
|
||||||
|
<span v-if="stats.currentSessionDuration" class="text-xs text-zinc-400">
|
||||||
|
{{ formatPlaytime(stats.currentSessionDuration) }}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
|
import {
|
||||||
|
ChartBarIcon,
|
||||||
|
ClockIcon,
|
||||||
|
PlayIcon
|
||||||
|
} from "@heroicons/vue/20/solid";
|
||||||
|
import type { GamePlaytimeStats } from "~/types";
|
||||||
|
|
||||||
|
interface Props {
|
||||||
|
stats: GamePlaytimeStats | null;
|
||||||
|
isActive?: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
const props = withDefaults(defineProps<Props>(), {
|
||||||
|
isActive: false,
|
||||||
|
});
|
||||||
|
|
||||||
|
const { formatPlaytime, formatDetailedPlaytime } = usePlaytime();
|
||||||
|
</script>
|
||||||
3
main/composables/app-state.ts
Normal file
3
main/composables/app-state.ts
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
import type { AppState } from "~/types";
|
||||||
|
|
||||||
|
export const useAppState = () => useState<AppState | undefined>("state");
|
||||||
@ -32,3 +32,5 @@ listen("update_stats", (event) => {
|
|||||||
const stats = useStatsState();
|
const stats = useStatsState();
|
||||||
stats.value = event.payload as StatsState;
|
stats.value = event.payload as StatsState;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
export const useDownloadHistory = () => useState<Array<number>>('history', () => []);
|
||||||
74
main/composables/game.ts
Normal file
74
main/composables/game.ts
Normal file
@ -0,0 +1,74 @@
|
|||||||
|
import { invoke } from "@tauri-apps/api/core";
|
||||||
|
import { listen } from "@tauri-apps/api/event";
|
||||||
|
import type { Game, GameStatus, GameStatusEnum, GameVersion } from "~/types";
|
||||||
|
|
||||||
|
const gameRegistry: { [key: string]: { game: Game; version?: GameVersion } } =
|
||||||
|
{};
|
||||||
|
|
||||||
|
const gameStatusRegistry: { [key: string]: Ref<GameStatus> } = {};
|
||||||
|
|
||||||
|
type OptionGameStatus = { [key in GameStatusEnum]: { version_name?: string } };
|
||||||
|
export type SerializedGameStatus = [
|
||||||
|
{ type: GameStatusEnum },
|
||||||
|
OptionGameStatus | null
|
||||||
|
];
|
||||||
|
|
||||||
|
export const parseStatus = (status: SerializedGameStatus): GameStatus => {
|
||||||
|
if (status[0]) {
|
||||||
|
return {
|
||||||
|
type: status[0].type,
|
||||||
|
};
|
||||||
|
} else if (status[1]) {
|
||||||
|
const [[gameStatus, options]] = Object.entries(status[1]);
|
||||||
|
return {
|
||||||
|
type: gameStatus as GameStatusEnum,
|
||||||
|
...options,
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
throw new Error("No game status");
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
export const useGame = async (gameId: string) => {
|
||||||
|
if (!gameRegistry[gameId]) {
|
||||||
|
const data: {
|
||||||
|
game: Game;
|
||||||
|
status: SerializedGameStatus;
|
||||||
|
version?: GameVersion;
|
||||||
|
} = await invoke("fetch_game", {
|
||||||
|
gameId,
|
||||||
|
});
|
||||||
|
gameRegistry[gameId] = { game: data.game, version: data.version };
|
||||||
|
if (!gameStatusRegistry[gameId]) {
|
||||||
|
gameStatusRegistry[gameId] = ref(parseStatus(data.status));
|
||||||
|
|
||||||
|
listen(`update_game/${gameId}`, (event) => {
|
||||||
|
console.log(event);
|
||||||
|
const payload: {
|
||||||
|
status: SerializedGameStatus;
|
||||||
|
version?: GameVersion;
|
||||||
|
} = event.payload as any;
|
||||||
|
gameStatusRegistry[gameId].value = parseStatus(payload.status);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* I am not super happy about this.
|
||||||
|
*
|
||||||
|
* This will mean that we will still have a version assigned if we have a game installed then uninstall it.
|
||||||
|
* It is necessary because a flag to check if we should overwrite seems excessive, and this function gets called
|
||||||
|
* on transient state updates.
|
||||||
|
*/
|
||||||
|
if (payload.version) {
|
||||||
|
gameRegistry[gameId].version = payload.version;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const game = gameRegistry[gameId];
|
||||||
|
const status = gameStatusRegistry[gameId];
|
||||||
|
return { ...game, status };
|
||||||
|
};
|
||||||
|
|
||||||
|
export type FrontendGameConfiguration = {
|
||||||
|
launchString: string;
|
||||||
|
};
|
||||||
193
main/composables/playtime.ts
Normal file
193
main/composables/playtime.ts
Normal file
@ -0,0 +1,193 @@
|
|||||||
|
import { invoke } from "@tauri-apps/api/core";
|
||||||
|
import { listen } from "@tauri-apps/api/event";
|
||||||
|
import type {
|
||||||
|
GamePlaytimeStats,
|
||||||
|
PlaytimeUpdateEvent,
|
||||||
|
PlaytimeSessionStartEvent,
|
||||||
|
PlaytimeSessionEndEvent
|
||||||
|
} from "~/types";
|
||||||
|
|
||||||
|
export const usePlaytime = () => {
|
||||||
|
const playtimeStats = useState<Record<string, GamePlaytimeStats>>('playtime-stats', () => ({}));
|
||||||
|
const activeSessions = useState<Set<string>>('active-sessions', () => new Set());
|
||||||
|
|
||||||
|
// Fetch playtime stats for a specific game
|
||||||
|
const fetchGamePlaytime = async (gameId: string): Promise<GamePlaytimeStats | null> => {
|
||||||
|
try {
|
||||||
|
const stats = await invoke<GamePlaytimeStats | null>("fetch_game_playtime", { gameId });
|
||||||
|
if (stats) {
|
||||||
|
playtimeStats.value[gameId] = stats;
|
||||||
|
}
|
||||||
|
return stats;
|
||||||
|
} catch (error) {
|
||||||
|
console.error(`Failed to fetch playtime for game ${gameId}:`, error);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// Fetch all playtime stats
|
||||||
|
const fetchAllPlaytimeStats = async (): Promise<Record<string, GamePlaytimeStats>> => {
|
||||||
|
try {
|
||||||
|
const stats = await invoke<Record<string, GamePlaytimeStats>>("fetch_all_playtime_stats");
|
||||||
|
playtimeStats.value = stats;
|
||||||
|
return stats;
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Failed to fetch all playtime stats:", error);
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// Check if a session is active
|
||||||
|
const isSessionActive = async (gameId: string): Promise<boolean> => {
|
||||||
|
try {
|
||||||
|
return await invoke<boolean>("is_playtime_session_active", { gameId });
|
||||||
|
} catch (error) {
|
||||||
|
console.error(`Failed to check session status for game ${gameId}:`, error);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// Get all active sessions
|
||||||
|
const getActiveSessions = async (): Promise<string[]> => {
|
||||||
|
try {
|
||||||
|
const sessions = await invoke<string[]>("get_active_playtime_sessions");
|
||||||
|
activeSessions.value = new Set(sessions);
|
||||||
|
return sessions;
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Failed to get active sessions:", error);
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// Format playtime duration
|
||||||
|
const formatPlaytime = (seconds: number): string => {
|
||||||
|
if (seconds < 60) {
|
||||||
|
return `${seconds}s`;
|
||||||
|
} else if (seconds < 3600) {
|
||||||
|
const minutes = Math.floor(seconds / 60);
|
||||||
|
return `${minutes}m`;
|
||||||
|
} else {
|
||||||
|
const hours = Math.floor(seconds / 3600);
|
||||||
|
const minutes = Math.floor((seconds % 3600) / 60);
|
||||||
|
if (minutes === 0) {
|
||||||
|
return `${hours}h`;
|
||||||
|
}
|
||||||
|
return `${hours}h ${minutes}m`;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// Format detailed playtime
|
||||||
|
const formatDetailedPlaytime = (seconds: number): string => {
|
||||||
|
if (seconds < 60) {
|
||||||
|
return `${seconds} seconds`;
|
||||||
|
} else if (seconds < 3600) {
|
||||||
|
const minutes = Math.floor(seconds / 60);
|
||||||
|
const remainingSeconds = seconds % 60;
|
||||||
|
if (remainingSeconds === 0) {
|
||||||
|
return `${minutes} minutes`;
|
||||||
|
}
|
||||||
|
return `${minutes} minutes, ${remainingSeconds} seconds`;
|
||||||
|
} else {
|
||||||
|
const hours = Math.floor(seconds / 3600);
|
||||||
|
const minutes = Math.floor((seconds % 3600) / 60);
|
||||||
|
if (minutes === 0) {
|
||||||
|
return `${hours} hours`;
|
||||||
|
}
|
||||||
|
return `${hours} hours, ${minutes} minutes`;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// Format relative time (e.g., "2 hours ago")
|
||||||
|
const formatRelativeTime = (timestamp: string): string => {
|
||||||
|
const date = new Date(timestamp);
|
||||||
|
const now = new Date();
|
||||||
|
const diffInSeconds = Math.floor((now.getTime() - date.getTime()) / 1000);
|
||||||
|
|
||||||
|
if (diffInSeconds < 60) {
|
||||||
|
return "Just now";
|
||||||
|
} else if (diffInSeconds < 3600) {
|
||||||
|
const minutes = Math.floor(diffInSeconds / 60);
|
||||||
|
return `${minutes} minute${minutes !== 1 ? 's' : ''} ago`;
|
||||||
|
} else if (diffInSeconds < 86400) {
|
||||||
|
const hours = Math.floor(diffInSeconds / 3600);
|
||||||
|
return `${hours} hour${hours !== 1 ? 's' : ''} ago`;
|
||||||
|
} else if (diffInSeconds < 604800) {
|
||||||
|
const days = Math.floor(diffInSeconds / 86400);
|
||||||
|
return `${days} day${days !== 1 ? 's' : ''} ago`;
|
||||||
|
} else {
|
||||||
|
return date.toLocaleDateString();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// Get playtime stats for a game (from cache or fetch)
|
||||||
|
const getGamePlaytime = async (gameId: string): Promise<GamePlaytimeStats | null> => {
|
||||||
|
if (playtimeStats.value[gameId]) {
|
||||||
|
return playtimeStats.value[gameId];
|
||||||
|
}
|
||||||
|
return await fetchGamePlaytime(gameId);
|
||||||
|
};
|
||||||
|
|
||||||
|
// Setup event listeners
|
||||||
|
const setupEventListeners = () => {
|
||||||
|
// Listen for general playtime updates
|
||||||
|
listen<PlaytimeUpdateEvent>("playtime_update", (event) => {
|
||||||
|
const { gameId, stats, isActive } = event.payload;
|
||||||
|
playtimeStats.value[gameId] = stats;
|
||||||
|
|
||||||
|
if (isActive) {
|
||||||
|
activeSessions.value.add(gameId);
|
||||||
|
} else {
|
||||||
|
activeSessions.value.delete(gameId);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Listen for session start events
|
||||||
|
listen<PlaytimeSessionStartEvent>("playtime_session_start", (event) => {
|
||||||
|
const { gameId } = event.payload;
|
||||||
|
activeSessions.value.add(gameId);
|
||||||
|
});
|
||||||
|
|
||||||
|
// Listen for session end events
|
||||||
|
listen<PlaytimeSessionEndEvent>("playtime_session_end", (event) => {
|
||||||
|
const { gameId } = event.payload;
|
||||||
|
activeSessions.value.delete(gameId);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
// Setup game-specific event listeners
|
||||||
|
const setupGameEventListeners = (gameId: string) => {
|
||||||
|
listen<PlaytimeUpdateEvent>(`playtime_update/${gameId}`, (event) => {
|
||||||
|
const { stats, isActive } = event.payload;
|
||||||
|
playtimeStats.value[gameId] = stats;
|
||||||
|
|
||||||
|
if (isActive) {
|
||||||
|
activeSessions.value.add(gameId);
|
||||||
|
} else {
|
||||||
|
activeSessions.value.delete(gameId);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
listen<PlaytimeSessionStartEvent>(`playtime_session_start/${gameId}`, () => {
|
||||||
|
activeSessions.value.add(gameId);
|
||||||
|
});
|
||||||
|
|
||||||
|
listen<PlaytimeSessionEndEvent>(`playtime_session_end/${gameId}`, () => {
|
||||||
|
activeSessions.value.delete(gameId);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
return {
|
||||||
|
playtimeStats: readonly(playtimeStats),
|
||||||
|
activeSessions: readonly(activeSessions),
|
||||||
|
fetchGamePlaytime,
|
||||||
|
fetchAllPlaytimeStats,
|
||||||
|
isSessionActive,
|
||||||
|
getActiveSessions,
|
||||||
|
formatPlaytime,
|
||||||
|
formatDetailedPlaytime,
|
||||||
|
formatRelativeTime,
|
||||||
|
getGamePlaytime,
|
||||||
|
setupEventListeners,
|
||||||
|
setupGameEventListeners,
|
||||||
|
};
|
||||||
|
};
|
||||||
@ -1,9 +1,11 @@
|
|||||||
|
import { invoke } from "@tauri-apps/api/core";
|
||||||
import { listen } from "@tauri-apps/api/event";
|
import { listen } from "@tauri-apps/api/event";
|
||||||
import { data } from "autoprefixer";
|
import { data } from "autoprefixer";
|
||||||
import { AppStatus, type AppState } from "~/types";
|
import { AppStatus, type AppState } from "~/types";
|
||||||
|
|
||||||
export function setupHooks() {
|
export function setupHooks() {
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
|
const state = useAppState();
|
||||||
|
|
||||||
listen("auth/processing", (event) => {
|
listen("auth/processing", (event) => {
|
||||||
router.push("/auth/processing");
|
router.push("/auth/processing");
|
||||||
@ -15,8 +17,9 @@ export function setupHooks() {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
listen("auth/finished", (event) => {
|
listen("auth/finished", async (event) => {
|
||||||
router.push("/store");
|
router.push("/library");
|
||||||
|
state.value = JSON.parse(await invoke("fetch_state"));
|
||||||
});
|
});
|
||||||
|
|
||||||
listen("download_error", (event) => {
|
listen("download_error", (event) => {
|
||||||
@ -27,12 +30,31 @@ export function setupHooks() {
|
|||||||
description: `Drop encountered an error while downloading your game: "${(
|
description: `Drop encountered an error while downloading your game: "${(
|
||||||
event.payload as unknown as string
|
event.payload as unknown as string
|
||||||
).toString()}"`,
|
).toString()}"`,
|
||||||
buttonText: "Close"
|
buttonText: "Close",
|
||||||
},
|
},
|
||||||
(e, c) => c()
|
(e, c) => c()
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// This is for errors that (we think) aren't our fault
|
||||||
|
listen("launch_external_error", (event) => {
|
||||||
|
createModal(
|
||||||
|
ModalType.Confirmation,
|
||||||
|
{
|
||||||
|
title: "Did something go wrong?",
|
||||||
|
description:
|
||||||
|
"Drop detected that something might've gone wrong with launching your game. Do you want to open the log directory?",
|
||||||
|
buttonText: "Open",
|
||||||
|
},
|
||||||
|
async (e, c) => {
|
||||||
|
if (e == "confirm") {
|
||||||
|
await invoke("open_process_logs", { gameId: event.payload });
|
||||||
|
}
|
||||||
|
c();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
||||||
document.addEventListener("contextmenu", (event) => {
|
document.addEventListener("contextmenu", (event) => {
|
||||||
@ -43,7 +65,13 @@ export function setupHooks() {
|
|||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
export function initialNavigation(state: Ref<AppState>) {
|
export function initialNavigation(state: ReturnType<typeof useAppState>) {
|
||||||
|
if (!state.value)
|
||||||
|
throw createError({
|
||||||
|
statusCode: 500,
|
||||||
|
statusMessage: "App state not valid",
|
||||||
|
fatal: true,
|
||||||
|
});
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
|
|
||||||
switch (state.value.status) {
|
switch (state.value.status) {
|
||||||
@ -60,6 +88,6 @@ export function initialNavigation(state: Ref<AppState>) {
|
|||||||
router.push("/error/serverunavailable");
|
router.push("/error/serverunavailable");
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
router.push("/store");
|
router.push("/library");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -7,6 +7,7 @@
|
|||||||
class="mx-auto w-full max-w-7xl px-6 pt-6 sm:pt-10 lg:col-span-2 lg:col-start-1 lg:row-start-1 lg:px-8"
|
class="mx-auto w-full max-w-7xl px-6 pt-6 sm:pt-10 lg:col-span-2 lg:col-start-1 lg:row-start-1 lg:px-8"
|
||||||
>
|
>
|
||||||
<Logo class="h-10 w-auto sm:h-12" />
|
<Logo class="h-10 w-auto sm:h-12" />
|
||||||
|
|
||||||
</header>
|
</header>
|
||||||
<main
|
<main
|
||||||
class="mx-auto w-full max-w-7xl px-6 py-24 sm:py-32 lg:col-span-2 lg:col-start-1 lg:row-start-2 lg:px-8"
|
class="mx-auto w-full max-w-7xl px-6 py-24 sm:py-32 lg:col-span-2 lg:col-start-1 lg:row-start-2 lg:px-8"
|
||||||
@ -13,5 +13,9 @@ export default defineNuxtConfig({
|
|||||||
|
|
||||||
ssr: false,
|
ssr: false,
|
||||||
|
|
||||||
extends: [["./drop-base"]],
|
extends: [["../libs/drop-base"]],
|
||||||
|
|
||||||
|
app: {
|
||||||
|
baseURL: "/main",
|
||||||
|
}
|
||||||
});
|
});
|
||||||
37
main/package.json
Normal file
37
main/package.json
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
{
|
||||||
|
"name": "view",
|
||||||
|
"private": true,
|
||||||
|
"version": "0.3.3",
|
||||||
|
"type": "module",
|
||||||
|
"scripts": {
|
||||||
|
"build": "nuxt generate",
|
||||||
|
"dev": "nuxt dev",
|
||||||
|
"postinstall": "nuxt prepare",
|
||||||
|
"tauri": "tauri"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"@headlessui/vue": "^1.7.23",
|
||||||
|
"@heroicons/vue": "^2.1.5",
|
||||||
|
"@nuxtjs/tailwindcss": "^6.12.2",
|
||||||
|
"@tauri-apps/api": "^2.7.0",
|
||||||
|
"koa": "^2.16.1",
|
||||||
|
"markdown-it": "^14.1.0",
|
||||||
|
"micromark": "^4.0.1",
|
||||||
|
"nuxt": "^3.16.0",
|
||||||
|
"scss": "^0.2.4",
|
||||||
|
"vue-router": "latest",
|
||||||
|
"vuedraggable": "^4.1.0"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@tailwindcss/forms": "^0.5.9",
|
||||||
|
"@tailwindcss/typography": "^0.5.15",
|
||||||
|
"@types/markdown-it": "^14.1.2",
|
||||||
|
"autoprefixer": "^10.4.20",
|
||||||
|
"postcss": "^8.4.47",
|
||||||
|
"sass-embedded": "^1.79.4",
|
||||||
|
"tailwindcss": "^3.4.13",
|
||||||
|
"typescript": "^5.8.3",
|
||||||
|
"vue-tsc": "^2.2.10"
|
||||||
|
},
|
||||||
|
"packageManager": "yarn@1.22.22+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e"
|
||||||
|
}
|
||||||
37
main/pages/auth/code.vue
Normal file
37
main/pages/auth/code.vue
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
<template>
|
||||||
|
<div class="min-h-full w-full flex items-center justify-center">
|
||||||
|
<div class="flex flex-col items-center">
|
||||||
|
<div class="text-center">
|
||||||
|
<h1 class="text-3xl font-semibold font-display leading-6 text-zinc-100">
|
||||||
|
Device authorization
|
||||||
|
</h1>
|
||||||
|
<div class="mt-4">
|
||||||
|
<p class="text-sm text-zinc-400 max-w-md mx-auto">
|
||||||
|
Open Drop on another one of your devices, and use your account
|
||||||
|
dropdown to "Authorize client", and enter the code below.
|
||||||
|
</p>
|
||||||
|
<div
|
||||||
|
class="mt-8 flex items-center justify-center gap-x-5 text-8xl font-bold text-zinc-100"
|
||||||
|
>
|
||||||
|
<span v-for="letter in code.split('')">{{ letter }}</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="mt-10 flex items-center justify-center gap-x-6">
|
||||||
|
<NuxtLink href="/auth" class="text-sm font-semibold text-blue-600"
|
||||||
|
><span aria-hidden="true">←</span> Use a different method
|
||||||
|
</NuxtLink>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
|
import { invoke } from "@tauri-apps/api/core";
|
||||||
|
|
||||||
|
const code = await invoke<string>("auth_initiate_code");
|
||||||
|
|
||||||
|
definePageMeta({
|
||||||
|
layout: "mini",
|
||||||
|
});
|
||||||
|
</script>
|
||||||
25
main/pages/community.vue
Normal file
25
main/pages/community.vue
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
<template>
|
||||||
|
<div class="grow w-full h-full flex items-center justify-center">
|
||||||
|
<div class="flex flex-col items-center">
|
||||||
|
<WrenchScrewdriverIcon
|
||||||
|
class="h-12 w-12 text-blue-600"
|
||||||
|
aria-hidden="true"
|
||||||
|
/>
|
||||||
|
<div class="mt-3 text-center sm:mt-5">
|
||||||
|
<h1 class="text-3xl font-semibold font-display leading-6 text-zinc-100">
|
||||||
|
Under construction
|
||||||
|
</h1>
|
||||||
|
<div class="mt-4">
|
||||||
|
<p class="text-sm text-zinc-400 max-w-lg">
|
||||||
|
This page hasn't been implemented yet.
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
<script setup lang="ts">
|
||||||
|
import {
|
||||||
|
WrenchScrewdriverIcon,
|
||||||
|
} from "@heroicons/vue/20/solid";
|
||||||
|
</script>
|
||||||
@ -18,10 +18,20 @@
|
|||||||
<div class="relative z-10">
|
<div class="relative z-10">
|
||||||
<div class="px-8 pb-4">
|
<div class="px-8 pb-4">
|
||||||
<h1
|
<h1
|
||||||
class="text-5xl text-zinc-100 font-bold font-display drop-shadow-lg mb-8"
|
class="text-5xl text-zinc-100 font-bold font-display drop-shadow-lg mb-4"
|
||||||
>
|
>
|
||||||
{{ game.mName }}
|
{{ game.mName }}
|
||||||
</h1>
|
</h1>
|
||||||
|
|
||||||
|
<!-- Playtime Display -->
|
||||||
|
<div class="mb-8">
|
||||||
|
<PlaytimeDisplay
|
||||||
|
:stats="gamePlaytime"
|
||||||
|
:is-active="isPlaytimeActive"
|
||||||
|
:show-details="false"
|
||||||
|
:show-active-indicator="false"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="flex flex-row gap-x-4 items-stretch mb-8">
|
<div class="flex flex-row gap-x-4 items-stretch mb-8">
|
||||||
<!-- Do not add scale animations to this: https://stackoverflow.com/a/35683068 -->
|
<!-- Do not add scale animations to this: https://stackoverflow.com/a/35683068 -->
|
||||||
@ -32,6 +42,7 @@
|
|||||||
@uninstall="() => uninstall()"
|
@uninstall="() => uninstall()"
|
||||||
@kill="() => kill()"
|
@kill="() => kill()"
|
||||||
@options="() => (configureModalOpen = true)"
|
@options="() => (configureModalOpen = true)"
|
||||||
|
@resume="() => resumeDownload()"
|
||||||
:status="status"
|
:status="status"
|
||||||
/>
|
/>
|
||||||
<a
|
<a
|
||||||
@ -59,6 +70,12 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="space-y-6">
|
<div class="space-y-6">
|
||||||
|
<!-- Playtime Statistics -->
|
||||||
|
<PlaytimeStats
|
||||||
|
:stats="gamePlaytime"
|
||||||
|
:is-active="isPlaytimeActive"
|
||||||
|
/>
|
||||||
|
|
||||||
<div class="bg-zinc-800/50 rounded-xl p-6 backdrop-blur-sm">
|
<div class="bg-zinc-800/50 rounded-xl p-6 backdrop-blur-sm">
|
||||||
<h2 class="text-xl font-display font-semibold text-zinc-100 mb-4">
|
<h2 class="text-xl font-display font-semibold text-zinc-100 mb-4">
|
||||||
Game Images
|
Game Images
|
||||||
@ -75,7 +92,7 @@
|
|||||||
<TransitionGroup name="slide" tag="div" class="h-full">
|
<TransitionGroup name="slide" tag="div" class="h-full">
|
||||||
<img
|
<img
|
||||||
v-for="(url, index) in mediaUrls"
|
v-for="(url, index) in mediaUrls"
|
||||||
:key="url"
|
:key="index"
|
||||||
:src="url"
|
:src="url"
|
||||||
class="absolute inset-0 w-full h-full object-cover"
|
class="absolute inset-0 w-full h-full object-cover"
|
||||||
v-show="index === currentImageIndex"
|
v-show="index === currentImageIndex"
|
||||||
@ -156,8 +173,8 @@
|
|||||||
<template #default>
|
<template #default>
|
||||||
<div class="sm:flex sm:items-start">
|
<div class="sm:flex sm:items-start">
|
||||||
<div class="mt-3 text-center sm:mt-0 sm:text-left">
|
<div class="mt-3 text-center sm:mt-0 sm:text-left">
|
||||||
<h3 class="text-base font-semibold text-zinc-100"
|
<h3 class="text-base font-semibold text-zinc-100">
|
||||||
>Install {{ game.mName }}?
|
Install {{ game.mName }}?
|
||||||
</h3>
|
</h3>
|
||||||
<div class="mt-2">
|
<div class="mt-2">
|
||||||
<p class="text-sm text-zinc-400">
|
<p class="text-sm text-zinc-400">
|
||||||
@ -242,7 +259,10 @@
|
|||||||
</div>
|
</div>
|
||||||
</Listbox>
|
</Listbox>
|
||||||
</div>
|
</div>
|
||||||
<div v-else class="mt-1 rounded-md bg-red-600/10 p-4">
|
<div
|
||||||
|
v-else-if="versionOptions === null || versionOptions?.length == 0"
|
||||||
|
class="mt-1 rounded-md bg-red-600/10 p-4"
|
||||||
|
>
|
||||||
<div class="flex">
|
<div class="flex">
|
||||||
<div class="flex-shrink-0">
|
<div class="flex-shrink-0">
|
||||||
<XCircleIcon class="h-5 w-5 text-red-600" aria-hidden="true" />
|
<XCircleIcon class="h-5 w-5 text-red-600" aria-hidden="true" />
|
||||||
@ -255,6 +275,27 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div v-else class="w-full flex items-center justify-center p-4">
|
||||||
|
<div role="status">
|
||||||
|
<svg
|
||||||
|
aria-hidden="true"
|
||||||
|
class="w-7 h-7 text-transparent animate-spin fill-white"
|
||||||
|
viewBox="0 0 100 101"
|
||||||
|
fill="none"
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
>
|
||||||
|
<path
|
||||||
|
d="M100 50.5908C100 78.2051 77.6142 100.591 50 100.591C22.3858 100.591 0 78.2051 0 50.5908C0 22.9766 22.3858 0.59082 50 0.59082C77.6142 0.59082 100 22.9766 100 50.5908ZM9.08144 50.5908C9.08144 73.1895 27.4013 91.5094 50 91.5094C72.5987 91.5094 90.9186 73.1895 90.9186 50.5908C90.9186 27.9921 72.5987 9.67226 50 9.67226C27.4013 9.67226 9.08144 27.9921 9.08144 50.5908Z"
|
||||||
|
fill="currentColor"
|
||||||
|
/>
|
||||||
|
<path
|
||||||
|
d="M93.9676 39.0409C96.393 38.4038 97.8624 35.9116 97.0079 33.5539C95.2932 28.8227 92.871 24.3692 89.8167 20.348C85.8452 15.1192 80.8826 10.7238 75.2124 7.41289C69.5422 4.10194 63.2754 1.94025 56.7698 1.05124C51.7666 0.367541 46.6976 0.446843 41.7345 1.27873C39.2613 1.69328 37.813 4.19778 38.4501 6.62326C39.0873 9.04874 41.5694 10.4717 44.0505 10.1071C47.8511 9.54855 51.7191 9.52689 55.5402 10.0491C60.8642 10.7766 65.9928 12.5457 70.6331 15.2552C75.2735 17.9648 79.3347 21.5619 82.5849 25.841C84.9175 28.9121 86.7997 32.2913 88.1811 35.8758C89.083 38.2158 91.5421 39.6781 93.9676 39.0409Z"
|
||||||
|
fill="currentFill"
|
||||||
|
/>
|
||||||
|
</svg>
|
||||||
|
<span class="sr-only">Loading...</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<div v-if="installDirs">
|
<div v-if="installDirs">
|
||||||
<Listbox as="div" v-model="installDir">
|
<Listbox as="div" v-model="installDir">
|
||||||
<ListboxLabel class="block text-sm/6 font-medium text-zinc-100"
|
<ListboxLabel class="block text-sm/6 font-medium text-zinc-100"
|
||||||
@ -349,9 +390,7 @@
|
|||||||
<template #buttons>
|
<template #buttons>
|
||||||
<LoadingButton
|
<LoadingButton
|
||||||
@click="() => install()"
|
@click="() => install()"
|
||||||
:disabled="
|
:disabled="!(versionOptions && versionOptions.length > 0)"
|
||||||
!(versionOptions && versionOptions.length > 0)
|
|
||||||
"
|
|
||||||
:loading="installLoading"
|
:loading="installLoading"
|
||||||
type="submit"
|
type="submit"
|
||||||
class="ml-2 w-full sm:w-fit"
|
class="ml-2 w-full sm:w-fit"
|
||||||
@ -369,7 +408,18 @@
|
|||||||
</template>
|
</template>
|
||||||
</ModalTemplate>
|
</ModalTemplate>
|
||||||
|
|
||||||
<GameOptionsModal v-if="status.type === GameStatusEnum.Installed" v-model="configureModalOpen" :game-id="game.id" />
|
<!--
|
||||||
|
Dear future DecDuck,
|
||||||
|
This v-if is necessary for Vue rendering reasons
|
||||||
|
(it tries to access the game version for not installed games)
|
||||||
|
You have already tried to remove it
|
||||||
|
Don't.
|
||||||
|
-->
|
||||||
|
<GameOptionsModal
|
||||||
|
v-if="status.type === GameStatusEnum.Installed"
|
||||||
|
v-model="configureModalOpen"
|
||||||
|
:game-id="game.id"
|
||||||
|
/>
|
||||||
|
|
||||||
<Transition
|
<Transition
|
||||||
enter="transition ease-out duration-300"
|
enter="transition ease-out duration-300"
|
||||||
@ -419,7 +469,7 @@
|
|||||||
<img
|
<img
|
||||||
v-for="(url, index) in mediaUrls"
|
v-for="(url, index) in mediaUrls"
|
||||||
v-show="currentImageIndex === index"
|
v-show="currentImageIndex === index"
|
||||||
:key="url"
|
:key="index"
|
||||||
:src="url"
|
:src="url"
|
||||||
class="max-h-[90vh] max-w-[90vw] object-contain"
|
class="max-h-[90vh] max-w-[90vw] object-contain"
|
||||||
:alt="`${game.mName} screenshot ${index + 1}`"
|
:alt="`${game.mName} screenshot ${index + 1}`"
|
||||||
@ -440,10 +490,6 @@
|
|||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import {
|
import {
|
||||||
Dialog,
|
|
||||||
DialogTitle,
|
|
||||||
TransitionChild,
|
|
||||||
TransitionRoot,
|
|
||||||
Listbox,
|
Listbox,
|
||||||
ListboxButton,
|
ListboxButton,
|
||||||
ListboxLabel,
|
ListboxLabel,
|
||||||
@ -471,7 +517,6 @@ const router = useRouter();
|
|||||||
const id = route.params.id.toString();
|
const id = route.params.id.toString();
|
||||||
|
|
||||||
const { game: rawGame, status } = await useGame(id);
|
const { game: rawGame, status } = await useGame(id);
|
||||||
console.log("status: ", status);
|
|
||||||
const game = ref(rawGame);
|
const game = ref(rawGame);
|
||||||
|
|
||||||
const remoteUrl: string = await invoke("gen_drop_url", {
|
const remoteUrl: string = await invoke("gen_drop_url", {
|
||||||
@ -482,7 +527,10 @@ const bannerUrl = await useObject(game.value.mBannerObjectId);
|
|||||||
|
|
||||||
// Get all available images
|
// Get all available images
|
||||||
const mediaUrls = await Promise.all(
|
const mediaUrls = await Promise.all(
|
||||||
game.value.mImageCarouselObjectIds.map((id) => useObject(id))
|
game.value.mImageCarouselObjectIds.map(async (v) => {
|
||||||
|
const src = await useObject(v);
|
||||||
|
return src;
|
||||||
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
const htmlDescription = micromark(game.value.mDescription);
|
const htmlDescription = micromark(game.value.mDescription);
|
||||||
@ -496,19 +544,32 @@ const currentImageIndex = ref(0);
|
|||||||
|
|
||||||
const configureModalOpen = ref(false);
|
const configureModalOpen = ref(false);
|
||||||
|
|
||||||
|
// Playtime tracking
|
||||||
|
const {
|
||||||
|
getGamePlaytime,
|
||||||
|
setupGameEventListeners,
|
||||||
|
activeSessions
|
||||||
|
} = usePlaytime();
|
||||||
|
|
||||||
|
const gamePlaytime = ref(await getGamePlaytime(id));
|
||||||
|
const isPlaytimeActive = computed(() => activeSessions.value.has(id));
|
||||||
|
|
||||||
|
// Setup playtime event listeners for this game
|
||||||
|
setupGameEventListeners(id);
|
||||||
|
|
||||||
async function installFlow() {
|
async function installFlow() {
|
||||||
installFlowOpen.value = true;
|
installFlowOpen.value = true;
|
||||||
versionOptions.value = undefined;
|
versionOptions.value = undefined;
|
||||||
installDirs.value = undefined;
|
installDirs.value = undefined;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
versionOptions.value = await invoke("fetch_game_verion_options", {
|
versionOptions.value = await invoke("fetch_game_version_options", {
|
||||||
gameId: game.value.id,
|
gameId: game.value.id,
|
||||||
});
|
});
|
||||||
console.log(versionOptions.value);
|
|
||||||
installDirs.value = await invoke("fetch_download_dir_stats");
|
installDirs.value = await invoke("fetch_download_dir_stats");
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
installError.value = (error as string).toString();
|
installError.value = (error as string).toString();
|
||||||
|
versionOptions.value = undefined;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -533,6 +594,14 @@ async function install() {
|
|||||||
installLoading.value = false;
|
installLoading.value = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function resumeDownload() {
|
||||||
|
try {
|
||||||
|
await invoke("resume_download", { gameId: game.value.id });
|
||||||
|
} catch (e) {
|
||||||
|
console.error(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async function launch() {
|
async function launch() {
|
||||||
try {
|
try {
|
||||||
await invoke("launch_game", { id: game.value.id });
|
await invoke("launch_game", { id: game.value.id });
|
||||||
25
main/pages/news.vue
Normal file
25
main/pages/news.vue
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
<template>
|
||||||
|
<div class="grow w-full h-full flex items-center justify-center">
|
||||||
|
<div class="flex flex-col items-center">
|
||||||
|
<WrenchScrewdriverIcon
|
||||||
|
class="h-12 w-12 text-blue-600"
|
||||||
|
aria-hidden="true"
|
||||||
|
/>
|
||||||
|
<div class="mt-3 text-center sm:mt-5">
|
||||||
|
<h1 class="text-3xl font-semibold font-display leading-6 text-zinc-100">
|
||||||
|
Under construction
|
||||||
|
</h1>
|
||||||
|
<div class="mt-4">
|
||||||
|
<p class="text-sm text-zinc-400 max-w-lg">
|
||||||
|
This page hasn't been implemented yet.
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
<script setup lang="ts">
|
||||||
|
import {
|
||||||
|
WrenchScrewdriverIcon,
|
||||||
|
} from "@heroicons/vue/20/solid";
|
||||||
|
</script>
|
||||||
@ -1,32 +1,46 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="bg-zinc-950 p-4 min-h-full space-y-4">
|
<div class="bg-zinc-950 p-4 min-h-full space-y-4">
|
||||||
<div class="h-16 overflow-hidden relative rounded-xl flex flex-row border border-zinc-900">
|
<div
|
||||||
|
class="h-16 overflow-hidden relative rounded-xl flex flex-row border border-zinc-900"
|
||||||
|
>
|
||||||
<div
|
<div
|
||||||
class="bg-zinc-900 z-10 w-32 flex flex-col gap-x-2 text-blue-400 font-display items-left justify-center pl-2">
|
class="bg-zinc-900 z-10 w-32 flex flex-col gap-x-2 font-display items-left justify-center pl-2"
|
||||||
<span class="font-semibold">{{ formatKilobytes(stats.speed) }}/s</span>
|
>
|
||||||
<span v-if="stats.time > 0" class="text-sm">{{ formatTime(stats.time) }} left</span>
|
<span class="font-bold text-zinc-100">{{ formatKilobytes(stats.speed) }}B/s</span>
|
||||||
|
<span v-if="stats.time > 0" class="text-xs text-zinc-400"
|
||||||
|
>{{ formatTime(stats.time) }} left</span
|
||||||
|
>
|
||||||
</div>
|
</div>
|
||||||
<div class="absolute inset-0 h-full flex flex-row items-end justify-end">
|
<div class="absolute inset-0 h-full flex flex-row items-end justify-end space-x-[1px]">
|
||||||
<div v-for="bar in speedHistory" :style="{ height: `${(bar / speedMax) * 100}%` }"
|
<div
|
||||||
class="w-[8px] bg-blue-600/40" />
|
v-for="bar in speedHistory"
|
||||||
|
:style="{ height: `${(bar / speedMax) * 100}%` }"
|
||||||
|
class="w-[3px] bg-blue-600 rounded-t-full"
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<draggable v-model="queue.queue" @end="onEnd">
|
<draggable v-model="queue.queue" @end="onEnd">
|
||||||
<template #item="{ element }: { element: (typeof queue.value.queue)[0] }">
|
<template #item="{ element }: { element: (typeof queue.value.queue)[0] }">
|
||||||
<li v-if="downloads.has(element.meta)" :key="element.meta.id"
|
<li
|
||||||
class="mb-4 bg-zinc-900 rounded-lg flex flex-row justify-between gap-x-6 py-5 px-4">
|
v-if="games[element.meta.id]"
|
||||||
|
:key="element.meta.id"
|
||||||
|
class="mb-4 bg-zinc-900 rounded-lg flex flex-row justify-between gap-x-6 py-5 px-4"
|
||||||
|
>
|
||||||
<div class="w-full flex items-center max-w-md gap-x-4 relative">
|
<div class="w-full flex items-center max-w-md gap-x-4 relative">
|
||||||
<img class="size-24 flex-none bg-zinc-800 object-cover rounded" :src="downloads.get(element.meta)!.queueMeta.cover"
|
<img
|
||||||
alt="" />
|
class="size-24 flex-none bg-zinc-800 object-cover rounded"
|
||||||
|
:src="games[element.meta.id].cover"
|
||||||
|
alt=""
|
||||||
|
/>
|
||||||
<div class="min-w-0 flex-auto">
|
<div class="min-w-0 flex-auto">
|
||||||
<p class="text-xl font-semibold text-zinc-100">
|
<p class="text-xl font-semibold text-zinc-100">
|
||||||
<NuxtLink :href="`/library/${element.meta.id}`" class="">
|
<NuxtLink :href="`/library/${element.meta.id}`" class="">
|
||||||
<span class="absolute inset-x-0 -top-px bottom-0" />
|
<span class="absolute inset-x-0 -top-px bottom-0" />
|
||||||
{{ downloads.get(element.meta)!.queueMeta.mName }}
|
{{ games[element.meta.id].game.mName }}
|
||||||
</NuxtLink>
|
</NuxtLink>
|
||||||
</p>
|
</p>
|
||||||
<p class="mt-1 flex text-xs/5 text-gray-500">
|
<p class="mt-1 flex text-xs/5 text-gray-500">
|
||||||
{{ downloads.get(element.meta)!.queueMeta.mShortDescription }}
|
{{ games[element.meta.id].game.mShortDescription }}
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -35,28 +49,40 @@
|
|||||||
<p class="text-md text-zinc-500 uppercase font-display font-bold">
|
<p class="text-md text-zinc-500 uppercase font-display font-bold">
|
||||||
{{ element.status }}
|
{{ element.status }}
|
||||||
</p>
|
</p>
|
||||||
<div v-if="element.progress" class="mt-1 w-96 bg-zinc-800 rounded-lg overflow-hidden">
|
<div
|
||||||
<div class="h-2 bg-blue-600" :style="{ width: `${element.progress * 100}%` }" />
|
v-if="element.progress"
|
||||||
|
class="mt-1 w-96 bg-zinc-800 rounded-lg overflow-hidden"
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
class="h-2 bg-blue-600"
|
||||||
|
:style="{ width: `${element.progress * 100}%` }"
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
<span class="mt-2 inline-flex items-center gap-x-1 text-zinc-400 text-sm font-display"><span
|
<span
|
||||||
class="text-zinc-300">{{
|
class="mt-2 inline-flex items-center gap-x-1 text-zinc-400 text-sm font-display"
|
||||||
formatKilobytes(element.current / 1000)
|
><span class="text-zinc-300">{{
|
||||||
}}</span>
|
formatKilobytes(element.current / 1000)
|
||||||
|
}}B</span>
|
||||||
/
|
/
|
||||||
<span class="">{{ formatKilobytes(element.max / 1000) }}</span>
|
<span class="">{{ formatKilobytes(element.max / 1000) }}B</span
|
||||||
<ServerIcon class="size-5" />
|
><ServerIcon class="size-5"
|
||||||
</span>
|
/></span>
|
||||||
</div>
|
</div>
|
||||||
<button @click="() => cancelGame(element.meta)" class="group">
|
<button @click="() => cancelGame(element.meta)" class="group">
|
||||||
<XMarkIcon class="transition size-8 flex-none text-zinc-600 group-hover:text-zinc-300"
|
<XMarkIcon
|
||||||
aria-hidden="true" />
|
class="transition size-8 flex-none text-zinc-600 group-hover:text-zinc-300"
|
||||||
|
aria-hidden="true"
|
||||||
|
/>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</li>
|
</li>
|
||||||
<p v-else>Loading...</p>
|
<p v-else>Loading...</p>
|
||||||
</template>
|
</template>
|
||||||
</draggable>
|
</draggable>
|
||||||
<div class="text-zinc-600 uppercase font-semibold font-display w-full text-center" v-if="queue.queue.length == 0">
|
<div
|
||||||
|
class="text-zinc-600 uppercase font-semibold font-display w-full text-center"
|
||||||
|
v-if="queue.queue.length == 0"
|
||||||
|
>
|
||||||
No items in the queue
|
No items in the queue
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -65,8 +91,12 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ServerIcon, XMarkIcon } from "@heroicons/vue/20/solid";
|
import { ServerIcon, XMarkIcon } from "@heroicons/vue/20/solid";
|
||||||
import { invoke } from "@tauri-apps/api/core";
|
import { invoke } from "@tauri-apps/api/core";
|
||||||
import { useStatus } from "~/composables/game";
|
import { type DownloadableMetadata, type Game, type GameStatus } from "~/types";
|
||||||
import type { DownloadableMetadata, Game, GameStatus, QueueMetadata } from "~/types";
|
|
||||||
|
// const actionNames = {
|
||||||
|
// [GameStatusEnum.Downloading]: "downloading",
|
||||||
|
// [GameStatusEnum.Verifying]: "verifying",
|
||||||
|
// }
|
||||||
|
|
||||||
const windowWidth = ref(window.innerWidth);
|
const windowWidth = ref(window.innerWidth);
|
||||||
window.addEventListener("resize", (event) => {
|
window.addEventListener("resize", (event) => {
|
||||||
@ -75,14 +105,16 @@ window.addEventListener("resize", (event) => {
|
|||||||
|
|
||||||
const queue = useQueueState();
|
const queue = useQueueState();
|
||||||
const stats = useStatsState();
|
const stats = useStatsState();
|
||||||
const speedHistory = useState<Array<number>>(() => []);
|
const speedHistory = useDownloadHistory();
|
||||||
const speedHistoryMax = computed(() => windowWidth.value / 8);
|
const speedHistoryMax = computed(() => windowWidth.value / 4);
|
||||||
const speedMax = computed(
|
const speedMax = computed(
|
||||||
() => speedHistory.value.reduce((a, b) => (a > b ? a : b)) * 1.3
|
() => speedHistory.value.reduce((a, b) => (a > b ? a : b)) * 1.1
|
||||||
);
|
);
|
||||||
const previousGameId = ref<string | undefined>();
|
const previousGameId = useState<string | undefined>('previous_game');
|
||||||
|
|
||||||
const downloads: Ref<Map<DownloadableMetadata, { queueMeta: QueueMetadata, status: Ref<GameStatus> }>> = ref(new Map());
|
const games: Ref<{
|
||||||
|
[key: string]: { game: Game; status: Ref<GameStatus>; cover: string };
|
||||||
|
}> = ref({});
|
||||||
|
|
||||||
function resetHistoryGraph() {
|
function resetHistoryGraph() {
|
||||||
speedHistory.value = [];
|
speedHistory.value = [];
|
||||||
@ -90,14 +122,15 @@ function resetHistoryGraph() {
|
|||||||
}
|
}
|
||||||
function checkReset(v: QueueState) {
|
function checkReset(v: QueueState) {
|
||||||
const currentGame = v.queue.at(0)?.meta.id;
|
const currentGame = v.queue.at(0)?.meta.id;
|
||||||
|
// If we don't have a game
|
||||||
|
if (!currentGame) return;
|
||||||
|
|
||||||
// If we're finished
|
// If we're finished
|
||||||
if (!currentGame && previousGameId.value) {
|
if (!currentGame && previousGameId.value) {
|
||||||
previousGameId.value = undefined;
|
previousGameId.value = undefined;
|
||||||
resetHistoryGraph();
|
resetHistoryGraph();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// If we don't have a game
|
|
||||||
if (!currentGame) return;
|
|
||||||
// If we started a new download
|
// If we started a new download
|
||||||
if (currentGame && !previousGameId.value) {
|
if (currentGame && !previousGameId.value) {
|
||||||
previousGameId.value = currentGame;
|
previousGameId.value = currentGame;
|
||||||
@ -117,23 +150,23 @@ watch(queue, (v) => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
watch(stats, (v) => {
|
watch(stats, (v) => {
|
||||||
|
if(v.speed == 0) return;
|
||||||
const newLength = speedHistory.value.push(v.speed);
|
const newLength = speedHistory.value.push(v.speed);
|
||||||
if (newLength > speedHistoryMax.value) {
|
if (newLength > speedHistoryMax.value) {
|
||||||
speedHistory.value.splice(0, 1);
|
speedHistory.value.splice(0, newLength - speedHistoryMax.value);
|
||||||
}
|
}
|
||||||
checkReset(queue.value);
|
checkReset(queue.value);
|
||||||
});
|
});
|
||||||
|
|
||||||
function loadGamesForQueue(v: typeof queue.value) {
|
function loadGamesForQueue(v: typeof queue.value) {
|
||||||
for (const {
|
for (const {
|
||||||
meta,
|
meta: { id },
|
||||||
} of v.queue) {
|
} of v.queue) {
|
||||||
if (downloads.value.get(meta)) return;
|
if (games.value[id]) return;
|
||||||
(async () => {
|
(async () => {
|
||||||
const queueMeta: QueueMetadata = await invoke("get_queue_metadata", {meta});
|
const gameData = await useGame(id);
|
||||||
const status = useStatus(meta)!;
|
const cover = await useObject(gameData.game.mCoverObjectId);
|
||||||
const cover = await useObject(queueMeta.cover);
|
games.value[id] = { ...gameData, cover };
|
||||||
downloads.value.set(meta, { queueMeta: { ...queueMeta, cover }, status });
|
|
||||||
})();
|
})();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -152,7 +185,7 @@ async function cancelGame(meta: DownloadableMetadata) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function formatKilobytes(bytes: number): string {
|
function formatKilobytes(bytes: number): string {
|
||||||
const units = ["KB", "MB", "GB", "TB", "PB"];
|
const units = ["K", "M", "G", "T", "P"];
|
||||||
let value = bytes;
|
let value = bytes;
|
||||||
let unitIndex = 0;
|
let unitIndex = 0;
|
||||||
const scalar = 1000;
|
const scalar = 1000;
|
||||||
@ -68,7 +68,7 @@
|
|||||||
Open Data Directory
|
Open Data Directory
|
||||||
</button>
|
</button>
|
||||||
<button
|
<button
|
||||||
@click="() => queue_url_download()"
|
@click="() => openLogFile()"
|
||||||
type="button"
|
type="button"
|
||||||
class="inline-flex items-center gap-x-2 rounded-md bg-blue-600 px-3.5 py-2.5 text-sm font-semibold text-white shadow-sm hover:bg-blue-500 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-blue-600"
|
class="inline-flex items-center gap-x-2 rounded-md bg-blue-600 px-3.5 py-2.5 text-sm font-semibold text-white shadow-sm hover:bg-blue-500 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-blue-600"
|
||||||
>
|
>
|
||||||
@ -106,8 +106,6 @@ const systemData = await invoke<{
|
|||||||
dataDir: string;
|
dataDir: string;
|
||||||
}>("fetch_system_data");
|
}>("fetch_system_data");
|
||||||
|
|
||||||
console.log(systemData);
|
|
||||||
|
|
||||||
clientId.value = systemData.clientId;
|
clientId.value = systemData.clientId;
|
||||||
baseUrl.value = systemData.baseUrl;
|
baseUrl.value = systemData.baseUrl;
|
||||||
dataDir.value = systemData.dataDir;
|
dataDir.value = systemData.dataDir;
|
||||||
@ -115,15 +113,6 @@ dataDir.value = systemData.dataDir;
|
|||||||
const currentPlatform = await platform();
|
const currentPlatform = await platform();
|
||||||
platformInfo.value = currentPlatform;
|
platformInfo.value = currentPlatform;
|
||||||
|
|
||||||
async function queue_url_download() {
|
|
||||||
try {
|
|
||||||
await invoke("queue_url_download", { url: "https://codeload.github.com/Drop-OSS/drop-app/zip/refs/heads/develop"});
|
|
||||||
}
|
|
||||||
catch (e) {
|
|
||||||
console.error(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async function openDataDir() {
|
async function openDataDir() {
|
||||||
if (!dataDir.value) return;
|
if (!dataDir.value) return;
|
||||||
try {
|
try {
|
||||||
23
main/pages/settings/interface.vue
Normal file
23
main/pages/settings/interface.vue
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
<template>
|
||||||
|
<div class="grow w-full h-full flex items-center justify-center">
|
||||||
|
<div class="flex flex-col items-center">
|
||||||
|
<WrenchScrewdriverIcon
|
||||||
|
class="h-12 w-12 text-blue-600"
|
||||||
|
aria-hidden="true"
|
||||||
|
/>
|
||||||
|
<div class="mt-3 text-center sm:mt-5">
|
||||||
|
<h1 class="text-3xl font-semibold font-display leading-6 text-zinc-100">
|
||||||
|
Under construction
|
||||||
|
</h1>
|
||||||
|
<div class="mt-4">
|
||||||
|
<p class="text-sm text-zinc-400 max-w-lg">
|
||||||
|
This page hasn't been implemented yet.
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
<script setup lang="ts">
|
||||||
|
import { WrenchScrewdriverIcon } from "@heroicons/vue/20/solid";
|
||||||
|
</script>
|
||||||
37
main/pages/store/index.vue
Normal file
37
main/pages/store/index.vue
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
<template>
|
||||||
|
<div class="grow w-full h-full flex items-center justify-center">
|
||||||
|
<div class="flex flex-col items-center">
|
||||||
|
<BuildingStorefrontIcon
|
||||||
|
class="h-12 w-12 text-blue-600"
|
||||||
|
aria-hidden="true"
|
||||||
|
/>
|
||||||
|
<div class="mt-3 text-center sm:mt-5">
|
||||||
|
<h1 class="text-3xl font-semibold font-display leading-6 text-zinc-100">
|
||||||
|
Store not supported in client
|
||||||
|
</h1>
|
||||||
|
<div class="mt-4">
|
||||||
|
<p class="text-sm text-zinc-400 max-w-lg">
|
||||||
|
Currently, Drop requires you to view the store in your browser.
|
||||||
|
Please click the button below to open it in your default browser.
|
||||||
|
</p>
|
||||||
|
<NuxtLink
|
||||||
|
:href="storeUrl"
|
||||||
|
target="_blank"
|
||||||
|
class="mt-6 transition text-sm/6 font-semibold text-zinc-400 hover:text-zinc-100 inline-flex gap-x-2 items-center duration-200 hover:scale-105"
|
||||||
|
>
|
||||||
|
Open Store <ArrowTopRightOnSquareIcon class="size-4" />
|
||||||
|
</NuxtLink>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
<script setup lang="ts">
|
||||||
|
import {
|
||||||
|
ArrowTopRightOnSquareIcon,
|
||||||
|
BuildingStorefrontIcon,
|
||||||
|
} from "@heroicons/vue/20/solid";
|
||||||
|
import { invoke } from "@tauri-apps/api/core";
|
||||||
|
|
||||||
|
const storeUrl = await invoke<string>("gen_drop_url", { path: "/store" });
|
||||||
|
</script>
|
||||||
5
main/tsconfig.json
Normal file
5
main/tsconfig.json
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
{
|
||||||
|
// https://nuxt.com/docs/guide/concepts/typescript
|
||||||
|
"extends": "./.nuxt/tsconfig.json",
|
||||||
|
"exclude": ["src-tauri/**/*"]
|
||||||
|
}
|
||||||
@ -37,8 +37,14 @@ export type Game = {
|
|||||||
mImageCarouselObjectIds: string[];
|
mImageCarouselObjectIds: string[];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export type Collection = {
|
||||||
|
id: string;
|
||||||
|
name: string;
|
||||||
|
isDefault: boolean;
|
||||||
|
entries: Array<{ gameId: string; game: Game }>;
|
||||||
|
};
|
||||||
|
|
||||||
export type GameVersion = {
|
export type GameVersion = {
|
||||||
versionName: string;
|
|
||||||
launchCommandTemplate: string;
|
launchCommandTemplate: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -55,16 +61,19 @@ export enum GameStatusEnum {
|
|||||||
Remote = "Remote",
|
Remote = "Remote",
|
||||||
Queued = "Queued",
|
Queued = "Queued",
|
||||||
Downloading = "Downloading",
|
Downloading = "Downloading",
|
||||||
|
Validating = "Validating",
|
||||||
Installed = "Installed",
|
Installed = "Installed",
|
||||||
Updating = "Updating",
|
Updating = "Updating",
|
||||||
Uninstalling = "Uninstalling",
|
Uninstalling = "Uninstalling",
|
||||||
SetupRequired = "SetupRequired",
|
SetupRequired = "SetupRequired",
|
||||||
Running = "Running",
|
Running = "Running",
|
||||||
|
PartiallyInstalled = "PartiallyInstalled",
|
||||||
}
|
}
|
||||||
|
|
||||||
export type GameStatus = {
|
export type GameStatus = {
|
||||||
type: GameStatusEnum;
|
type: GameStatusEnum;
|
||||||
version_name?: string;
|
version_name?: string;
|
||||||
|
install_dir?: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
export enum DownloadableType {
|
export enum DownloadableType {
|
||||||
@ -76,7 +85,7 @@ export enum DownloadableType {
|
|||||||
|
|
||||||
export type DownloadableMetadata = {
|
export type DownloadableMetadata = {
|
||||||
id: string;
|
id: string;
|
||||||
version?: string;
|
version: string;
|
||||||
downloadType: DownloadableType;
|
downloadType: DownloadableType;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -86,9 +95,36 @@ export type Settings = {
|
|||||||
forceOffline: boolean;
|
forceOffline: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export type GamePlaytimeStats = {
|
||||||
|
gameId: string;
|
||||||
|
totalPlaytimeSeconds: number;
|
||||||
|
sessionCount: number;
|
||||||
|
firstPlayed: string;
|
||||||
|
lastPlayed: string;
|
||||||
|
averageSessionLength: number;
|
||||||
|
currentSessionDuration?: number;
|
||||||
|
};
|
||||||
|
|
||||||
export type QueueMetadata = {
|
export type PlaytimeSession = {
|
||||||
mName: string;
|
gameId: string;
|
||||||
cover: string;
|
startTime: string;
|
||||||
mShortDescription: string;
|
sessionId: string;
|
||||||
}
|
};
|
||||||
|
|
||||||
|
export type PlaytimeUpdateEvent = {
|
||||||
|
gameId: string;
|
||||||
|
stats: GamePlaytimeStats;
|
||||||
|
isActive: boolean;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type PlaytimeSessionStartEvent = {
|
||||||
|
gameId: string;
|
||||||
|
startTime: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type PlaytimeSessionEndEvent = {
|
||||||
|
gameId: string;
|
||||||
|
sessionDurationSeconds: number;
|
||||||
|
totalPlaytimeSeconds: number;
|
||||||
|
sessionCount: number;
|
||||||
|
};
|
||||||
8091
main/yarn.lock
Normal file
8091
main/yarn.lock
Normal file
File diff suppressed because it is too large
Load Diff
22
optimize-appimage.sh
Executable file
22
optimize-appimage.sh
Executable file
@ -0,0 +1,22 @@
|
|||||||
|
## This script is largely useless, because there's not much we can do about AppImage size
|
||||||
|
|
||||||
|
ARCH=$(uname -m)
|
||||||
|
|
||||||
|
# build tauri apps
|
||||||
|
# NO_STRIP=true yarn tauri build -- --verbose
|
||||||
|
|
||||||
|
# unpack appimage
|
||||||
|
APPIMAGE=$(ls ./src-tauri/target/release/bundle/appimage/*.AppImage)
|
||||||
|
"$APPIMAGE" --appimage-extract
|
||||||
|
|
||||||
|
# strip binary
|
||||||
|
APPIMAGE_UNPACK="./squashfs-root"
|
||||||
|
find $APPIMAGE_UNPACK -type f -exec strip -s {} \;
|
||||||
|
|
||||||
|
APPIMAGETOOL=$(echo "obsolete-appimagetool-$ARCH.AppImage")
|
||||||
|
wget -O $APPIMAGETOOL "https://github.com/AppImage/AppImageKit/releases/download/13/$APPIMAGETOOL"
|
||||||
|
chmod +x $APPIMAGETOOL
|
||||||
|
|
||||||
|
APPIMAGE_OUTPUT=$(./$APPIMAGETOOL $APPIMAGE_UNPACK | grep ".AppImage" | grep squashfs-root | awk '{ print $6 }')
|
||||||
|
|
||||||
|
mv $APPIMAGE_OUTPUT "$APPIMAGE"
|
||||||
45
package.json
45
package.json
@ -1,45 +1,22 @@
|
|||||||
{
|
{
|
||||||
"name": "drop-app",
|
"name": "drop-app",
|
||||||
"private": true,
|
"private": true,
|
||||||
"version": "0.3.0-rc-2",
|
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "nuxt build",
|
"build": "node ./build.mjs",
|
||||||
"dev": "nuxt dev",
|
|
||||||
"generate": "nuxt generate",
|
|
||||||
"preview": "nuxt preview",
|
|
||||||
"postinstall": "nuxt prepare",
|
|
||||||
"tauri": "tauri"
|
"tauri": "tauri"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@headlessui/vue": "^1.7.23",
|
"@tauri-apps/api": "^2.7.0",
|
||||||
"@heroicons/vue": "^2.1.5",
|
"@tauri-apps/plugin-deep-link": "^2.4.1",
|
||||||
"@nuxtjs/tailwindcss": "^6.12.2",
|
"@tauri-apps/plugin-dialog": "^2.3.2",
|
||||||
"@tauri-apps/api": ">=2.0.0",
|
"@tauri-apps/plugin-opener": "^2.4.0",
|
||||||
"@tauri-apps/plugin-deep-link": "~2",
|
"@tauri-apps/plugin-os": "^2.3.0",
|
||||||
"@tauri-apps/plugin-dialog": "^2.0.1",
|
"@tauri-apps/plugin-shell": "^2.3.0",
|
||||||
"@tauri-apps/plugin-os": "~2",
|
"pino": "^9.7.0",
|
||||||
"@tauri-apps/plugin-shell": "^2.2.1",
|
"pino-pretty": "^13.1.1"
|
||||||
"koa": "^2.16.1",
|
|
||||||
"markdown-it": "^14.1.0",
|
|
||||||
"micromark": "^4.0.1",
|
|
||||||
"nuxt": "^3.16.0",
|
|
||||||
"scss": "^0.2.4",
|
|
||||||
"vue": "latest",
|
|
||||||
"vue-router": "latest",
|
|
||||||
"vuedraggable": "^4.1.0"
|
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@tailwindcss/forms": "^0.5.9",
|
"@tauri-apps/cli": "^2.7.1"
|
||||||
"@tailwindcss/typography": "^0.5.15",
|
}
|
||||||
"@tauri-apps/cli": ">=2.0.0",
|
|
||||||
"@types/markdown-it": "^14.1.2",
|
|
||||||
"autoprefixer": "^10.4.20",
|
|
||||||
"postcss": "^8.4.47",
|
|
||||||
"sass-embedded": "^1.79.4",
|
|
||||||
"tailwindcss": "^3.4.13",
|
|
||||||
"typescript": "^5.8.3",
|
|
||||||
"vue-tsc": "^2.2.10"
|
|
||||||
},
|
|
||||||
"packageManager": "yarn@1.22.22+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e"
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,7 +0,0 @@
|
|||||||
<template>
|
|
||||||
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script setup lang="ts">
|
|
||||||
|
|
||||||
</script>
|
|
||||||
@ -1,4 +0,0 @@
|
|||||||
<template>
|
|
||||||
<iframe src="server://drop.local/store" class="w-full h-full" />
|
|
||||||
</template>
|
|
||||||
<script setup lang="ts"></script>
|
|
||||||
590
src-tauri/Cargo.lock
generated
590
src-tauri/Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
@ -1,9 +1,9 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "drop-app"
|
name = "drop-app"
|
||||||
version = "0.3.0-rc-2"
|
version = "0.3.3"
|
||||||
description = "The client application for the open-source, self-hosted game distribution platform Drop"
|
description = "The client application for the open-source, self-hosted game distribution platform Drop"
|
||||||
authors = ["Drop OSS"]
|
authors = ["Drop OSS"]
|
||||||
edition = "2021"
|
edition = "2024"
|
||||||
|
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
@ -25,7 +25,6 @@ tauri-build = { version = "2.0.0", features = [] }
|
|||||||
[dependencies]
|
[dependencies]
|
||||||
tauri-plugin-shell = "2.2.1"
|
tauri-plugin-shell = "2.2.1"
|
||||||
serde_json = "1"
|
serde_json = "1"
|
||||||
serde-binary = "0.5.0"
|
|
||||||
rayon = "1.10.0"
|
rayon = "1.10.0"
|
||||||
webbrowser = "1.0.2"
|
webbrowser = "1.0.2"
|
||||||
url = "2.5.2"
|
url = "2.5.2"
|
||||||
@ -66,7 +65,17 @@ whoami = "1.6.0"
|
|||||||
filetime = "0.2.25"
|
filetime = "0.2.25"
|
||||||
walkdir = "2.5.0"
|
walkdir = "2.5.0"
|
||||||
known-folders = "1.2.0"
|
known-folders = "1.2.0"
|
||||||
native_model = { version = "0.6.1", features = ["rmp_serde_1_3"] }
|
native_model = { version = "0.6.4", features = ["rmp_serde_1_3"], git = "https://github.com/Drop-OSS/native_model.git"}
|
||||||
|
tauri-plugin-opener = "2.4.0"
|
||||||
|
bitcode = "0.6.6"
|
||||||
|
reqwest-websocket = "0.5.0"
|
||||||
|
futures-lite = "2.6.0"
|
||||||
|
page_size = "0.6.0"
|
||||||
|
sysinfo = "0.36.1"
|
||||||
|
humansize = "2.1.3"
|
||||||
|
tokio-util = { version = "0.7.16", features = ["io"] }
|
||||||
|
futures-core = "0.3.31"
|
||||||
|
bytes = "1.10.1"
|
||||||
# tailscale = { path = "./tailscale" }
|
# tailscale = { path = "./tailscale" }
|
||||||
|
|
||||||
[dependencies.dynfmt]
|
[dependencies.dynfmt]
|
||||||
@ -74,8 +83,8 @@ version = "0.1.5"
|
|||||||
features = ["curly"]
|
features = ["curly"]
|
||||||
|
|
||||||
[dependencies.tauri]
|
[dependencies.tauri]
|
||||||
version = "2.1.1"
|
version = "2.7.0"
|
||||||
features = ["tray-icon"]
|
features = ["protocol-asset", "tray-icon"]
|
||||||
|
|
||||||
[dependencies.tokio]
|
[dependencies.tokio]
|
||||||
version = "1.40.0"
|
version = "1.40.0"
|
||||||
@ -98,9 +107,17 @@ version = "2"
|
|||||||
features = ["other_errors"] # You can also use "yaml_enc" or "bin_enc"
|
features = ["other_errors"] # You can also use "yaml_enc" or "bin_enc"
|
||||||
|
|
||||||
[dependencies.reqwest]
|
[dependencies.reqwest]
|
||||||
version = "0.12"
|
version = "0.12.22"
|
||||||
default-features = false
|
default-features = false
|
||||||
features = ["json", "http2", "blocking", "rustls-tls-webpki-roots"]
|
features = [
|
||||||
|
"json",
|
||||||
|
"http2",
|
||||||
|
"blocking",
|
||||||
|
"rustls-tls",
|
||||||
|
"native-tls-alpn",
|
||||||
|
"rustls-tls-native-roots",
|
||||||
|
"stream",
|
||||||
|
]
|
||||||
|
|
||||||
[dependencies.serde]
|
[dependencies.serde]
|
||||||
version = "1"
|
version = "1"
|
||||||
|
|||||||
@ -1,3 +1,3 @@
|
|||||||
fn main() {
|
fn main() {
|
||||||
tauri_build::build()
|
tauri_build::build();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -14,6 +14,7 @@
|
|||||||
"core:window:allow-close",
|
"core:window:allow-close",
|
||||||
"deep-link:default",
|
"deep-link:default",
|
||||||
"dialog:default",
|
"dialog:default",
|
||||||
"os:default"
|
"os:default",
|
||||||
|
"opener:default"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
@ -1,4 +1,4 @@
|
|||||||
use crate::database::db::{borrow_db_checked, borrow_db_mut_checked, save_db};
|
use crate::database::db::{borrow_db_checked, borrow_db_mut_checked};
|
||||||
use log::debug;
|
use log::debug;
|
||||||
use tauri::AppHandle;
|
use tauri::AppHandle;
|
||||||
use tauri_plugin_autostart::ManagerExt;
|
use tauri_plugin_autostart::ManagerExt;
|
||||||
@ -17,7 +17,6 @@ pub fn toggle_autostart_logic(app: AppHandle, enabled: bool) -> Result<(), Strin
|
|||||||
let mut db_handle = borrow_db_mut_checked();
|
let mut db_handle = borrow_db_mut_checked();
|
||||||
db_handle.settings.autostart = enabled;
|
db_handle.settings.autostart = enabled;
|
||||||
drop(db_handle);
|
drop(db_handle);
|
||||||
save_db();
|
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user