Skip to content

Commit

Permalink
fix: bugs & lint: code
Browse files Browse the repository at this point in the history
  • Loading branch information
Tigercrl committed Jan 12, 2025
1 parent 8c49897 commit 2e80863
Show file tree
Hide file tree
Showing 64 changed files with 1,972 additions and 2,009 deletions.
4 changes: 2 additions & 2 deletions apps/app/.prettier.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import config from '@repo/configs/prettier/base'
import config from "@repo/configs/prettier/base";

export default config;
export default config;
4 changes: 2 additions & 2 deletions apps/app/eslint.config.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import vueConfig from '@repo/configs/eslint/vue.js'
import vueConfig from "@repo/configs/eslint/vue.js";

export default vueConfig
export default vueConfig;
2 changes: 1 addition & 1 deletion apps/app/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 2 additions & 4 deletions apps/app/src-tauri/capabilities/default.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@
"$schema": "../gen/schemas/desktop-schema.json",
"identifier": "default",
"description": "Capability for the main window",
"windows": [
"main"
],
"windows": ["main"],
"permissions": [
"core:default",
"opener:default",
Expand All @@ -14,4 +12,4 @@
"core:window:allow-unmaximize",
"core:window:allow-minimize"
]
}
}
16 changes: 8 additions & 8 deletions apps/app/src/App.vue
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
<script setup lang="ts">
import Layout from "@repo/commons/src/Layout.vue";
import {layout} from "./router.ts";
import {useLocale} from "@repo/commons/src/utils/uses";
import {useI18n} from "vue-i18n";
import { layout } from "./router.ts";
import { useLocale } from "@repo/commons/src/utils/uses";
import { useI18n } from "vue-i18n";
import WindowButton from "./components/WindowButton.vue";
useLocale().injectComposer(useI18n())
useLocale().injectComposer(useI18n());
</script>

<template>
<div class="app__container">
<WindowButton/>
<WindowButton />
<Layout v-if="layout == 'default'">
<router-view v-slot="{ Component, route }">
<transition name="blur" mode="out-in">
<component :is="Component" :key="route.path"/>
<component :is="Component" :key="route.path" />
</transition>
</router-view>
</Layout>
<router-view v-else-if="layout == 'none'" v-slot="{ Component, route }">
<transition name="blur" mode="out-in">
<component :is="Component" :key="route.path"/>
<component :is="Component" :key="route.path" />
</transition>
</router-view>
</div>
Expand All @@ -39,4 +39,4 @@ useLocale().injectComposer(useI18n())
margin-top: 8px;
height: calc(100% - 8px);
}
</style>
</style>
29 changes: 18 additions & 11 deletions apps/app/src/components/WindowButton.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<script lang="ts" setup>
import {ref} from 'vue';
import {getCurrentWindow} from "@tauri-apps/api/window";
import {exit} from "@tauri-apps/plugin-process";
import { ref } from "vue";
import { getCurrentWindow } from "@tauri-apps/api/window";
import { exit } from "@tauri-apps/plugin-process";
const maximizeBtnIcon = ref();
Expand All @@ -15,12 +15,13 @@ async function minimizeApp() {
async function maximizeApp() {
if (await getCurrentWindow().isMaximized()) {
maximizeBtnIcon.value.className = 'fas fa-up-right-and-down-left-from-center';
document.body.classList.remove('maximized');
maximizeBtnIcon.value.className =
"fas fa-up-right-and-down-left-from-center";
document.body.classList.remove("maximized");
await getCurrentWindow().unmaximize();
} else {
maximizeBtnIcon.value.className = 'fas fa-down-left-and-up-right-to-center';
document.body.classList.add('maximized');
maximizeBtnIcon.value.className = "fas fa-down-left-and-up-right-to-center";
document.body.classList.add("maximized");
await getCurrentWindow().maximize();
}
}
Expand All @@ -29,9 +30,15 @@ async function maximizeApp() {
<template>
<div class="window-button__container">
<button @click="exitApp"><i class="fas fa-xmark"></i></button>
<button @click="minimizeApp" id="window-minimize-button"><i class="fas fa-minus"></i></button>
<button @click="maximizeApp" id="window-maximize-button"><i
class="fas fa-up-right-and-down-left-from-center" ref="maximizeBtnIcon"></i></button>
<button @click="minimizeApp" id="window-minimize-button">
<i class="fas fa-minus"></i>
</button>
<button @click="maximizeApp" id="window-maximize-button">
<i
class="fas fa-up-right-and-down-left-from-center"
ref="maximizeBtnIcon"
></i>
</button>
</div>
</template>

Expand Down Expand Up @@ -67,4 +74,4 @@ async function maximizeApp() {
.window-button__container button:hover {
border: 1px solid var(--el-menu-border-color);
}
</style>
</style>
68 changes: 34 additions & 34 deletions apps/app/src/main.ts
Original file line number Diff line number Diff line change
@@ -1,42 +1,42 @@
import {createApp} from "vue";
import { createApp } from "vue";
import App from "./App.vue";
import ElementPlus from "element-plus";
import {createPinia} from "pinia";
import {agreedEula, loadApp} from "@repo/commons/src/utils/loader";
import {setRouter} from "@repo/commons/src/utils/globals";
import { createPinia } from "pinia";
import { agreedEula, loadApp } from "@repo/commons/src/utils/loader";
import { setRouter } from "@repo/commons/src/utils/globals";
import router from "./router";
import {createI18n} from "vue-i18n";
import {useLocale} from "@repo/commons/src/utils/uses";
import { type } from '@tauri-apps/plugin-os';
import { createI18n } from "vue-i18n";
import { useLocale } from "@repo/commons/src/utils/uses";
import { type } from "@tauri-apps/plugin-os";

const app = createApp(App)
app.use(router)
app.use(ElementPlus)
const app = createApp(App);
app.use(router);
app.use(ElementPlus);
app.use(createPinia());

(async () => {
const messages: any = {};
const localeStore = useLocale()
for (const locale of localeStore.locales) {
messages[locale] = (await import(`./assets/i18n/${locale}.json`)).default;
}
const i18n = createI18n(await useLocale().getConfig(messages))
const messages: any = {};
const localeStore = useLocale();
for (const locale of localeStore.locales) {
messages[locale] = (await import(`./assets/i18n/${locale}.json`)).default;
}
const i18n = createI18n(await useLocale().getConfig(messages));

return {
i18n
}
})().then(async ({i18n}) => {
app.use(i18n)
setRouter(router)
app.mount("#app");
const os = type()
if (os == 'macos') {
document.body.classList.add('tauri-macos')
} else if(os == 'windows' || os == 'linux') {
document.body.classList.add('tauri-desktop')
} else {
document.body.classList.add('tauri-mobile')
}
if (!agreedEula.value) await router.push('/welcome/welcome')
await loadApp()
})
return {
i18n,
};
})().then(async ({ i18n }) => {
app.use(i18n);
setRouter(router);
app.mount("#app");
const os = type();
if (os == "macos") {
document.body.classList.add("tauri-macos");
} else if (os == "windows" || os == "linux") {
document.body.classList.add("tauri-desktop");
} else {
document.body.classList.add("tauri-mobile");
}
if (!agreedEula.value) await router.push("/welcome/welcome");
await loadApp();
});
120 changes: 60 additions & 60 deletions apps/app/src/router.ts
Original file line number Diff line number Diff line change
@@ -1,70 +1,70 @@
import {createRouter, createWebHistory} from "vue-router";
import {ref} from "vue";
import {agreedEula} from "@repo/commons/src/utils/loader.ts";
import Home from "@repo/commons/src/pages/Home.vue"
import Welcome from "@repo/commons/src/pages/welcome/Welcome.vue"
import Eula from "@repo/commons/src/pages/welcome/Eula.vue"
import Done from "@repo/commons/src/pages/welcome/Done.vue"
import Connect from "@repo/commons/src/pages/Connect.vue"
import Debug from "@repo/commons/src/pages/Debug.vue"
import Instances from "@repo/commons/src/pages/Instances.vue"
import News from "@repo/commons/src/pages/News.vue"
import { createRouter, createWebHistory } from "vue-router";
import { ref } from "vue";
import { agreedEula } from "@repo/commons/src/utils/loader.ts";
import Home from "@repo/commons/src/pages/Home.vue";
import Welcome from "@repo/commons/src/pages/welcome/Welcome.vue";
import Eula from "@repo/commons/src/pages/welcome/Eula.vue";
import Done from "@repo/commons/src/pages/welcome/Done.vue";
import Connect from "@repo/commons/src/pages/Connect.vue";
import Debug from "@repo/commons/src/pages/Debug.vue";
import Instances from "@repo/commons/src/pages/Instances.vue";
import News from "@repo/commons/src/pages/News.vue";

export type LayoutType = 'none' | 'default'
export type LayoutType = "none" | "default";

export const layout = ref<LayoutType>('default')
export const layout = ref<LayoutType>("default");

const router = createRouter({
history: createWebHistory(import.meta.env.BASE_URL),
routes: [
{
path: "/",
component: Home
},
{
path: "/welcome/welcome",
component: Welcome,
meta: {
layout: 'none'
}
},
{
path: "/welcome/eula",
component: Eula,
meta: {
layout: 'none'
}
},
{
path: "/welcome/done",
component: Done,
meta: {
layout: 'none'
}
},
{
path: "/connect",
component: Connect
},
{
path: "/debug",
component: Debug
},
{
path: "/instances",
component: Instances
},
{
path: "/news",
component: News
},
],
history: createWebHistory(import.meta.env.BASE_URL),
routes: [
{
path: "/",
component: Home,
},
{
path: "/welcome/welcome",
component: Welcome,
meta: {
layout: "none",
},
},
{
path: "/welcome/eula",
component: Eula,
meta: {
layout: "none",
},
},
{
path: "/welcome/done",
component: Done,
meta: {
layout: "none",
},
},
{
path: "/connect",
component: Connect,
},
{
path: "/debug",
component: Debug,
},
{
path: "/instances",
component: Instances,
},
{
path: "/news",
component: News,
},
],
});

router.beforeEach(async (to, _from, next) => {
layout.value = <LayoutType | undefined>to.meta.layout ?? 'default'
layout.value = <LayoutType | undefined>to.meta.layout ?? "default";

next()
})
next();
});

export default router;
4 changes: 2 additions & 2 deletions apps/app/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
// https://nuxt.com/docs/guide/concepts/typescript
"extends": ["@repo/configs/ts/vue.json"]
// https://nuxt.com/docs/guide/concepts/typescript
"extends": ["@repo/configs/ts/vue.json"]
}
4 changes: 2 additions & 2 deletions apps/web/.prettier.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import config from '@repo/configs/prettier/base'
import config from "@repo/configs/prettier/base";

export default config;
export default config;
2 changes: 1 addition & 1 deletion apps/web/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,4 @@ pnpm i
pnpm dev # start a dev server
pnpm run docs # generate docs
pnpm build # build for production
```
```
12 changes: 6 additions & 6 deletions apps/web/app.config.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
const config = {
appVersion: async () => {
return (await import('./package.json')).default.version;
},
updater: 'https://example.com/update.json',
resourcepackFormat: 1,
appVersion: async () => {
return (await import("./package.json")).default.version;
},
updater: "https://example.com/update.json",
resourcepackFormat: 1,
};

(async () => {
console.log('MCSL Future Web version: ' + (await config.appVersion()));
console.log("MCSL Future Web version: " + (await config.appVersion()));
})();

export default defineAppConfig(config);
Loading

0 comments on commit 2e80863

Please sign in to comment.