mirror of
https://github.com/Grasscutters/Cultivation.git
synced 2025-12-13 07:34:36 +01:00
@@ -13,15 +13,26 @@ pub async fn get_download_links(mod_id: String) -> String {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
pub async fn list_submissions(mode: String, page: String) -> String {
|
pub async fn list_submissions(mode: String, page: String, search: String) -> String {
|
||||||
web::query(
|
if search.is_empty() {
|
||||||
format!(
|
web::query(
|
||||||
"{}/apiv9/Util/Game/Submissions?_idGameRow=8552&_nPage={}&_nPerpage=50&_sMode={}",
|
format!(
|
||||||
SITE_URL, page, mode
|
"{}/apiv9/Util/Game/Submissions?_idGameRow=8552&_nPage={}&_nPerpage=50&_sMode={}",
|
||||||
|
SITE_URL, page, mode
|
||||||
|
)
|
||||||
|
.as_str(),
|
||||||
)
|
)
|
||||||
.as_str(),
|
.await
|
||||||
)
|
} else {
|
||||||
.await
|
web::query(
|
||||||
|
format!(
|
||||||
|
"{}/apiv11/Util/Search/Results?_nPage={}&_sOrder=best_match&_idGameRow=8552&_sSearchString={}&_csvFields=name,description,article,attribs,studio,owner,credits",
|
||||||
|
SITE_URL, page, search
|
||||||
|
)
|
||||||
|
.as_str()
|
||||||
|
)
|
||||||
|
.await
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
|
|||||||
@@ -341,7 +341,13 @@ fn restart_grasscutter(window: tauri::Window) -> bool {
|
|||||||
|
|
||||||
#[cfg(unix)]
|
#[cfg(unix)]
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
fn restart_grasscutter(window: tauri::Window) {}
|
fn restart_grasscutter(window: tauri::Window) {
|
||||||
|
// Placeholder text for imports
|
||||||
|
let s = System::new();
|
||||||
|
if let Some(process) = s.process(Pid::from(1337)) {
|
||||||
|
println!("{}", process.name());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
use duct::cmd;
|
use duct::cmd;
|
||||||
use ini::Ini;
|
use ini::Ini;
|
||||||
use std::path::PathBuf;
|
|
||||||
use std::ffi::OsStr;
|
use std::ffi::OsStr;
|
||||||
|
use std::path::PathBuf;
|
||||||
|
|
||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
use {
|
use {
|
||||||
@@ -245,6 +245,10 @@ pub fn service_status(service: String) -> bool {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(unix)]
|
||||||
|
#[tauri::command]
|
||||||
|
pub fn service_status(service: String) {}
|
||||||
|
|
||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
pub fn start_service(service: String) -> bool {
|
pub fn start_service(service: String) -> bool {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import React from 'react'
|
import React from 'react'
|
||||||
import { getConfigOption } from '../../../utils/configuration'
|
import { getConfigOption } from '../../../utils/configuration'
|
||||||
import { getAllMods, getInstalledMods, getMods, ModData, PartialModData } from '../../../utils/gamebanana'
|
import { getInstalledMods, getMods, ModData, PartialModData } from '../../../utils/gamebanana'
|
||||||
import { LoadingCircle } from './LoadingCircle'
|
import { LoadingCircle } from './LoadingCircle'
|
||||||
|
|
||||||
import './ModList.css'
|
import './ModList.css'
|
||||||
@@ -64,16 +64,7 @@ export class ModList extends React.Component<IProps, IState> {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
let mods: ModData[]
|
const mods = await getMods(this.props.mode, this.props.page, this.props.search)
|
||||||
|
|
||||||
if (!(this.props.search == '')) {
|
|
||||||
// idk the api so just filter all mods to search
|
|
||||||
mods = (await getAllMods(this.props.mode)).filter((mod) =>
|
|
||||||
mod.name.toLowerCase().includes(this.props.search.toLowerCase())
|
|
||||||
)
|
|
||||||
} else {
|
|
||||||
mods = await getMods(this.props.mode, this.props.page)
|
|
||||||
}
|
|
||||||
|
|
||||||
const horny = await getConfigOption('horny_mode')
|
const horny = await getConfigOption('horny_mode')
|
||||||
|
|
||||||
|
|||||||
@@ -117,13 +117,38 @@ interface ModDownload {
|
|||||||
containsExe: boolean
|
containsExe: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getMods(mode: string, page: number) {
|
export async function getMods(mode: string, page: number, search: string) {
|
||||||
let modList: GamebananaResponse[] = []
|
let modList: GamebananaResponse[] = []
|
||||||
|
|
||||||
|
if (search.length > 0) {
|
||||||
|
let hadMods = true
|
||||||
|
let page = 1
|
||||||
|
|
||||||
|
while (hadMods) {
|
||||||
|
const resp = JSON.parse(
|
||||||
|
await invoke('list_submissions', {
|
||||||
|
mode,
|
||||||
|
page: '' + page,
|
||||||
|
search: search,
|
||||||
|
})
|
||||||
|
)
|
||||||
|
|
||||||
|
const total = resp._aMetadata._nRecordCount
|
||||||
|
|
||||||
|
if (page > total / 15) hadMods = false
|
||||||
|
|
||||||
|
modList = [...modList, ...resp._aRecords]
|
||||||
|
page++
|
||||||
|
}
|
||||||
|
|
||||||
|
return formatGamebananaData(modList)
|
||||||
|
}
|
||||||
|
|
||||||
const resp = JSON.parse(
|
const resp = JSON.parse(
|
||||||
await invoke('list_submissions', {
|
await invoke('list_submissions', {
|
||||||
mode,
|
mode,
|
||||||
page: '' + page,
|
page: '' + page,
|
||||||
|
search: '',
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -132,28 +157,6 @@ export async function getMods(mode: string, page: number) {
|
|||||||
return formatGamebananaData(modList)
|
return formatGamebananaData(modList)
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getAllMods(mode: string) {
|
|
||||||
let modList: GamebananaResponse[] = []
|
|
||||||
let hadMods = true
|
|
||||||
let page = 1
|
|
||||||
|
|
||||||
while (hadMods) {
|
|
||||||
const resp = JSON.parse(
|
|
||||||
await invoke('list_submissions', {
|
|
||||||
mode,
|
|
||||||
page: '' + page,
|
|
||||||
})
|
|
||||||
)
|
|
||||||
|
|
||||||
if (resp.length === 0) hadMods = false
|
|
||||||
|
|
||||||
modList = [...modList, ...resp]
|
|
||||||
page++
|
|
||||||
}
|
|
||||||
|
|
||||||
return formatGamebananaData(modList)
|
|
||||||
}
|
|
||||||
|
|
||||||
export async function formatGamebananaData(obj: GamebananaResponse[]) {
|
export async function formatGamebananaData(obj: GamebananaResponse[]) {
|
||||||
if (!obj) return []
|
if (!obj) return []
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user