diff --git a/theseus/src/state/tags.rs b/theseus/src/state/tags.rs index 5643b387d..c76a577cb 100644 --- a/theseus/src/state/tags.rs +++ b/theseus/src/state/tags.rs @@ -134,13 +134,12 @@ impl Tags { // Fetches the tags from the Modrinth API and stores them in the database #[tracing::instrument(skip(self))] pub async fn fetch_update(&mut self) -> crate::Result<()> { - let categories = self.fetch_tag::("category"); - let loaders = self.fetch_tag::("loader"); - let game_versions = self.fetch_tag::("game_version"); - let licenses = self.fetch_tag::("license"); - let donation_platforms = - self.fetch_tag::("donation_platform"); - let report_types = self.fetch_tag::("report_type"); + let categories = self.fetch_tag("category"); + let loaders = self.fetch_tag("loader"); + let game_versions = self.fetch_tag("game_version"); + let licenses = self.fetch_tag("license"); + let donation_platforms = self.fetch_tag("donation_platform"); + let report_types = self.fetch_tag("report_type"); let ( categories, @@ -149,59 +148,60 @@ impl Tags { licenses, donation_platforms, report_types, - ) = futures::join!( + ) = tokio::try_join!( categories, loaders, game_versions, licenses, donation_platforms, report_types - ); + )?; // Store the tags in the database self.0.categories.insert( "categories", - bincode::encode_to_vec(categories?, *BINCODE_CONFIG)?, + bincode::encode_to_vec(categories.json().await?, *BINCODE_CONFIG)?, )?; self.0.loaders.insert( "loaders", - bincode::encode_to_vec(loaders?, *BINCODE_CONFIG)?, + bincode::encode_to_vec(loaders.json().await?, *BINCODE_CONFIG)?, )?; self.0.game_versions.insert( "game_versions", - bincode::encode_to_vec(game_versions?, *BINCODE_CONFIG)?, + bincode::encode_to_vec( + game_versions.json().await?, + *BINCODE_CONFIG, + )?, )?; self.0.licenses.insert( "licenses", - bincode::encode_to_vec(licenses?, *BINCODE_CONFIG)?, + bincode::encode_to_vec(licenses.json().await?, *BINCODE_CONFIG)?, )?; self.0.donation_platforms.insert( "donation_platforms", - bincode::encode_to_vec(donation_platforms?, *BINCODE_CONFIG)?, + bincode::encode_to_vec( + donation_platforms.json().await?, + *BINCODE_CONFIG, + )?, )?; self.0.report_types.insert( "report_types", - bincode::encode_to_vec(report_types?, *BINCODE_CONFIG)?, + bincode::encode_to_vec( + report_types.json().await?, + *BINCODE_CONFIG, + )?, )?; Ok(()) } #[tracing::instrument(skip(self))] - pub async fn fetch_tag( + pub async fn fetch_tag( &self, tag_type: &str, - ) -> Result, reqwest::Error> - where - T: serde::de::DeserializeOwned, - { + ) -> Result { let url = &format!("{MODRINTH_API_URL}tag/{}", tag_type); - let content = REQWEST_CLIENT - .get(url) - .send() - .await? - .json::>() - .await?; + let content = REQWEST_CLIENT.get(url).send().await?; Ok(content) } } diff --git a/theseus_gui/.gitignore b/theseus_gui/.gitignore index ad4f821fb..d6cbf02e7 100644 --- a/theseus_gui/.gitignore +++ b/theseus_gui/.gitignore @@ -10,7 +10,6 @@ pnpm-debug.log* lerna-debug.log* node_modules -dist dist-ssr *.local @@ -24,3 +23,5 @@ dist-ssr *.njsproj *.sln *.sw? + +generated.js diff --git a/theseus_gui/.prettierignore b/theseus_gui/.prettierignore index ee923b2ab..76ac1f1b4 100644 --- a/theseus_gui/.prettierignore +++ b/theseus_gui/.prettierignore @@ -7,6 +7,7 @@ node_modules .env dist *.md +package.json generated/ !.gitkeep diff --git a/theseus_gui/dist/.gitignore b/theseus_gui/dist/.gitignore new file mode 100644 index 000000000..0db63c670 --- /dev/null +++ b/theseus_gui/dist/.gitignore @@ -0,0 +1,4 @@ +# Ignore everything in this directory +* +# except the gitignore +!.gitignore \ No newline at end of file diff --git a/theseus_gui/package.json b/theseus_gui/package.json index 9cfa2dd98..22e509afe 100644 --- a/theseus_gui/package.json +++ b/theseus_gui/package.json @@ -14,11 +14,12 @@ }, "dependencies": { "@tauri-apps/api": "^1.2.0", - "axios": "^1.3.4", + "ofetch": "^1.0.1", "omorphia": "^0.4.2", "pinia": "^2.0.33", "vite-svg-loader": "^4.0.0", "vue": "^3.2.45", + "vue-multiselect": "^3.0.0-alpha.2", "vue-router": "4" }, "devDependencies": { @@ -33,4 +34,4 @@ "vite": "^4.0.0", "vite-plugin-eslint": "^1.8.1" } -} +} \ No newline at end of file diff --git a/theseus_gui/src/App.vue b/theseus_gui/src/App.vue index 1c6be0253..ffeabfe88 100644 --- a/theseus_gui/src/App.vue +++ b/theseus_gui/src/App.vue @@ -11,19 +11,17 @@ import { SettingsIcon, Avatar, } from 'omorphia' -import { useTheming, useInstances } from '@/store/state' +import { useTheming } from '@/store/state' import { toggleTheme } from '@/helpers/theme' const route = useRoute() const router = useRouter() -const theme = useTheming() -const instances = useInstances() -instances.fetchInstances() +const themeStore = useTheming() -toggleTheme(theme.darkTheme) +toggleTheme(themeStore.darkTheme) -watch(theme, (newState) => { +watch(themeStore, (newState) => { toggleTheme(newState.darkTheme) }) @@ -59,7 +57,9 @@ watch(theme, (newState) => {
- + + +
diff --git a/theseus_gui/src/components/RowDisplay.vue b/theseus_gui/src/components/RowDisplay.vue index 21ac08229..746473b52 100644 --- a/theseus_gui/src/components/RowDisplay.vue +++ b/theseus_gui/src/components/RowDisplay.vue @@ -63,8 +63,8 @@ const handleRightPage = () => {

{{ props.label }}

diff --git a/theseus_gui/src/helpers/tags.js b/theseus_gui/src/helpers/tags.js index 6bdd36e82..207e2467a 100644 --- a/theseus_gui/src/helpers/tags.js +++ b/theseus_gui/src/helpers/tags.js @@ -12,17 +12,17 @@ export async function get_tag_bundle() { // Gets cached category tags export async function get_categories() { - return await invoke('tags_get_categories') + return await invoke('tags_get_category_tags') } // Gets cached loaders tags export async function get_loaders() { - return await invoke('tags_get_loaders') + return await invoke('tags_get_loader_tags') } // Gets cached game_versions tags export async function get_game_versions() { - return await invoke('tags_get_game_versions') + return await invoke('tags_get_game_version_tags') } // Gets cached licenses tags diff --git a/theseus_gui/src/pages/Browse.vue b/theseus_gui/src/pages/Browse.vue index cbfea27df..1fcd8a1bc 100644 --- a/theseus_gui/src/pages/Browse.vue +++ b/theseus_gui/src/pages/Browse.vue @@ -1,7 +1,536 @@ - + + + + diff --git a/theseus_gui/src/pages/Index.vue b/theseus_gui/src/pages/Index.vue index 3f211af2d..288be5fa8 100644 --- a/theseus_gui/src/pages/Index.vue +++ b/theseus_gui/src/pages/Index.vue @@ -2,21 +2,21 @@ import { useInstances, useNews } from '@/store/state' import RowDisplay from '@/components/RowDisplay.vue' -const instances = useInstances() -const news = useNews() -instances.fetchInstances() -news.fetchNews() +const instanceStore = useInstances() +const newsStore = useNews() +instanceStore.fetchInstances() +newsStore.fetchNews() // Remove once state is populated with real data -const recentInstances = instances.instances.slice(0, 4) -const popularInstances = instances.instances.filter((i) => i.downloads > 50 || i.trending) +const recentInstances = instanceStore.instances.slice(0, 4) +const popularInstances = instanceStore.instances.filter((i) => i.downloads > 50 || i.trending) diff --git a/theseus_gui/src/pages/instance/Index.vue b/theseus_gui/src/pages/instance/Index.vue index 4ee4a10c1..7039602c2 100644 --- a/theseus_gui/src/pages/instance/Index.vue +++ b/theseus_gui/src/pages/instance/Index.vue @@ -2,10 +2,10 @@
- +
-

{{ getInstance(instances).name }}

- Fabric {{ getInstance(instances).version }} +

{{ getInstance(instanceStore).name }}

+ Fabric {{ getInstance(instanceStore).version }}