mirror of
https://github.com/shadps4-emu/shadPS4-launcher.git
synced 2026-01-31 00:55:20 +01:00
feat: add game mock
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -22,3 +22,5 @@ dist-ssr
|
||||
*.njsproj
|
||||
*.sln
|
||||
*.sw?
|
||||
|
||||
.env
|
||||
1
mock/.gitignore
vendored
Normal file
1
mock/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
games.json
|
||||
@@ -4,7 +4,7 @@
|
||||
"version": "0.1.0",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "tauri dev",
|
||||
"dev": "tauri dev --config ./src-tauri/tauri.dev.conf.json",
|
||||
"build": "tauri build",
|
||||
"vite:dev": "vite",
|
||||
"vite:build": "tsc && vite build",
|
||||
|
||||
@@ -34,14 +34,22 @@
|
||||
]
|
||||
},
|
||||
{
|
||||
"identifier": "shell:allow-execute",
|
||||
"allow": [
|
||||
{
|
||||
"name": "shadps4-emu",
|
||||
"cmd": "$APPDATA/shadps4-emu.exe",
|
||||
"args": true
|
||||
}
|
||||
]
|
||||
"identifier": "shell:allow-execute",
|
||||
"allow": [
|
||||
{
|
||||
"name": "shadps4-emu",
|
||||
"cmd": "$APPDATA/shadps4-emu.exe",
|
||||
"args": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"identifier": "fs:read-files",
|
||||
"allow": [
|
||||
{
|
||||
"path": "$RESOURCE/mock/**/*"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
8
src-tauri/tauri.dev.conf.json
Normal file
8
src-tauri/tauri.dev.conf.json
Normal file
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"$schema": "https://schema.tauri.app/config/2",
|
||||
"bundle": {
|
||||
"resources": {
|
||||
"../mock/**/*": "resources/mock/"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
import { convertFileSrc } from "@tauri-apps/api/core";
|
||||
import { basename, join } from "@tauri-apps/api/path";
|
||||
import { exists, readDir } from "@tauri-apps/plugin-fs";
|
||||
import { basename, join, resourceDir } from "@tauri-apps/api/path";
|
||||
import { exists, readDir, readTextFile } from "@tauri-apps/plugin-fs";
|
||||
import { atom } from "jotai";
|
||||
import { pathPreferences } from "./paths";
|
||||
|
||||
@@ -12,6 +12,14 @@ export interface GameEntry {
|
||||
}
|
||||
|
||||
export const gameLibrary = atom(async (get) => {
|
||||
if (import.meta.env.VITE_USE_MOCK) {
|
||||
const data = await readTextFile(
|
||||
await join(await resourceDir(), "mock/games.json"),
|
||||
);
|
||||
|
||||
return JSON.parse(data) as GameEntry[];
|
||||
}
|
||||
|
||||
const knownPaths: string[] = [];
|
||||
|
||||
async function isGame(path: string) {
|
||||
|
||||
8
src/vite-env.d.ts
vendored
8
src/vite-env.d.ts
vendored
@@ -1 +1,9 @@
|
||||
/// <reference types="vite/client" />
|
||||
|
||||
interface ImportMetaEnv {
|
||||
readonly VITE_USE_MOCK: boolean;
|
||||
}
|
||||
|
||||
interface ImportMeta {
|
||||
readonly env: ImportMetaEnv;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user