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
|
*.njsproj
|
||||||
*.sln
|
*.sln
|
||||||
*.sw?
|
*.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",
|
"version": "0.1.0",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "tauri dev",
|
"dev": "tauri dev --config ./src-tauri/tauri.dev.conf.json",
|
||||||
"build": "tauri build",
|
"build": "tauri build",
|
||||||
"vite:dev": "vite",
|
"vite:dev": "vite",
|
||||||
"vite:build": "tsc && vite build",
|
"vite:build": "tsc && vite build",
|
||||||
|
|||||||
@@ -34,14 +34,22 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"identifier": "shell:allow-execute",
|
"identifier": "shell:allow-execute",
|
||||||
"allow": [
|
"allow": [
|
||||||
{
|
{
|
||||||
"name": "shadps4-emu",
|
"name": "shadps4-emu",
|
||||||
"cmd": "$APPDATA/shadps4-emu.exe",
|
"cmd": "$APPDATA/shadps4-emu.exe",
|
||||||
"args": true
|
"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 { convertFileSrc } from "@tauri-apps/api/core";
|
||||||
import { basename, join } from "@tauri-apps/api/path";
|
import { basename, join, resourceDir } from "@tauri-apps/api/path";
|
||||||
import { exists, readDir } from "@tauri-apps/plugin-fs";
|
import { exists, readDir, readTextFile } from "@tauri-apps/plugin-fs";
|
||||||
import { atom } from "jotai";
|
import { atom } from "jotai";
|
||||||
import { pathPreferences } from "./paths";
|
import { pathPreferences } from "./paths";
|
||||||
|
|
||||||
@@ -12,6 +12,14 @@ export interface GameEntry {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const gameLibrary = atom(async (get) => {
|
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[] = [];
|
const knownPaths: string[] = [];
|
||||||
|
|
||||||
async function isGame(path: 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" />
|
/// <reference types="vite/client" />
|
||||||
|
|
||||||
|
interface ImportMetaEnv {
|
||||||
|
readonly VITE_USE_MOCK: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface ImportMeta {
|
||||||
|
readonly env: ImportMetaEnv;
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user