From 8169d3ad49eae35826b55060062f56b24b32d465 Mon Sep 17 00:00:00 2001 From: Zach Baird <30800863+ZachBaird@users.noreply.github.com> Date: Wed, 5 Apr 2023 10:18:04 -0400 Subject: [PATCH] Starts adding search pages to launcher. (#49) * launcher base gui initial * Bootstraps router, Omorphia, and prettier. * Adds pages. Adds Vuex. SideBar nav contains user section and pages section. * Adds Instance markup. Instances added to Home page. * Adds News to home page. * Adds settings to nav. Other touches. * Polishing initial base GUI. * Moves some styling to assets. Changes px values to rem. * Removes pointless border-radius CSS. * Implements Omorphia vars. * Adds trending mods section. * Updates home page. * Swaps Vuex implementation for Pinia. * Fixes invalid CSS on instance list item hover. * Adds @ path resolve for imports. * First pass on search page. * Fix some styling of row display * Cleaning up styles and markup. * Fixes overall layout issues. * Cleans up more styling. Modifies AppBar coloring. * Allows pagination arrows to conditionally appear in RowDisplay. * Adds paging behavior in RowDisplay. * Updates nav and settings button styling. * Brings in Knossos style for trending mods. Polishes News CSS. * Updates Omorphia. Starts addressing PR comments. * Addresses some more PR comments. * Changes side navigation styling. Active route class implemented. * Combines trending and popular row. * Makes images more realistic. Adds CTA to instances. * Converts all instances to card style. Converts more styles to rem. * Moves Navigation and UserSection into App.vue * Adds Modrinth favicon. * Cleans up branch after merge. * Removes unused styling. * Adds transition to news card. * Adds ofetch. Separates stores. More logic moved to instance store. Browse hits API. * Modifies Browse instance styling. Moves Browse results out of Instance.vue. * First pass on filtering. * Points search at prod API. * Updates Omorphia package. Adds index sorting. * Fills out search functionality. * Renames state files. Moves SearchPanel into Browse. Fixes checkbox styling. * Changes how facets are composed. Dynamically sets loaders and categories. * Moves search state to searchStore. Cleans up some code. * Ups h2 font-size. Wraps search panel in Card. * Cleans up branch after merge. Fixes some Browse styling. * Search store produces query string. API call made in Browse. * Changes filter-panel styling. * Uses client and server icons directly. Removes dead code from search store. * Clear button disabled on initial state. Accesses store directly, removes some dead code. Fixes search panel styling. * Generates proj tags in Browse. Removes getter in search store. * Removes unnecessary code. * Reworks facet management. Fixes some styling. * Relabels Tauri calls in tags.js. Attempts to call helper in Browse. * fixed win10 stack overflow * cargo fmt * Makes computed value. Gets tags from Tauri. Overrides Omorphia style. Fixes dropdown width. --------- Co-authored-by: Jai A Co-authored-by: CodexAdrian <83074853+CodexAdrian@users.noreply.github.com> Co-authored-by: Wyatt Verchere --- theseus/src/state/tags.rs | 52 +-- theseus_gui/.gitignore | 3 +- theseus_gui/.prettierignore | 1 + theseus_gui/dist/.gitignore | 4 + theseus_gui/package.json | 5 +- theseus_gui/src/App.vue | 14 +- theseus_gui/src/components/RowDisplay.vue | 4 +- theseus_gui/src/helpers/tags.js | 6 +- theseus_gui/src/pages/Browse.vue | 535 +++++++++++++++++++++- theseus_gui/src/pages/Index.vue | 14 +- theseus_gui/src/pages/instance/Index.vue | 14 +- theseus_gui/src/store/instances.js | 115 +++++ theseus_gui/src/store/news.js | 35 ++ theseus_gui/src/store/search.js | 116 +++++ theseus_gui/src/store/state.js | 160 +------ theseus_gui/src/store/theme.js | 10 + theseus_gui/yarn.lock | 108 ++--- 17 files changed, 915 insertions(+), 281 deletions(-) create mode 100644 theseus_gui/dist/.gitignore create mode 100644 theseus_gui/src/store/instances.js create mode 100644 theseus_gui/src/store/news.js create mode 100644 theseus_gui/src/store/search.js create mode 100644 theseus_gui/src/store/theme.js 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 }}