diff --git a/easytier-gui/locales/en.yml b/easytier-gui/locales/en.yml index 16b4b39..6c80c27 100644 --- a/easytier-gui/locales/en.yml +++ b/easytier-gui/locales/en.yml @@ -32,7 +32,7 @@ settings: Settings exchange_language: 切换中文 exit: Exit -chips_placeholder: "e.g: {0}, press Enter to add" +chips_placeholder: 'e.g: {0}, press Enter to add' off_text: Press to disable on_text: Press to enable show_config: Show Config diff --git a/easytier-gui/package.json b/easytier-gui/package.json index 53eea70..b1f5239 100644 --- a/easytier-gui/package.json +++ b/easytier-gui/package.json @@ -33,6 +33,7 @@ "eslint-plugin-format": "^0.1.1", "naive-ui": "^2.38.2", "postcss": "^8.4.38", + "prettier": "^3.2.5", "tailwindcss": "^3.4.3", "typescript": "^5.4.5", "unplugin-auto-import": "^0.17.5", @@ -45,7 +46,6 @@ "vite": "^5.2.11", "vite-plugin-vue-devtools": "^7.1.3", "vite-plugin-vue-layouts": "^0.11.0", - "prettier": "^3.2.5", "vue-i18n": "^9.13.1", "vue-tsc": "^2.0.16" } diff --git a/easytier-gui/src/App.vue b/easytier-gui/src/App.vue index 6d11557..7c2aa3f 100644 --- a/easytier-gui/src/App.vue +++ b/easytier-gui/src/App.vue @@ -1,3 +1,3 @@ \ No newline at end of file + diff --git a/easytier-gui/src/components/Config.vue b/easytier-gui/src/components/Config.vue index d35e88a..947a1a8 100644 --- a/easytier-gui/src/components/Config.vue +++ b/easytier-gui/src/components/Config.vue @@ -1,39 +1,37 @@ diff --git a/easytier-gui/src/composables/network.ts b/easytier-gui/src/composables/network.ts index a59f8e0..90455eb 100644 --- a/easytier-gui/src/composables/network.ts +++ b/easytier-gui/src/composables/network.ts @@ -1,22 +1,22 @@ -import { NetworkConfig } from "~/types/network"; -import { invoke } from "@tauri-apps/api/tauri"; +import { invoke } from '@tauri-apps/api/tauri' +import type { NetworkConfig } from '~/types/network' export async function parseNetworkConfig(cfg: NetworkConfig): Promise { - const ret: string = await invoke("parse_network_config", { cfg: JSON.stringify(cfg) }); - return ret; + const ret: string = await invoke('parse_network_config', { cfg: JSON.stringify(cfg) }) + return ret } export async function runNetworkInstance(cfg: NetworkConfig) { - const ret: string = await invoke("run_network_instance", { cfg: JSON.stringify(cfg) }); - return ret; + const ret: string = await invoke('run_network_instance', { cfg: JSON.stringify(cfg) }) + return ret } export async function retainNetworkInstance(instanceIds: Array) { - const ret: string = await invoke("retain_network_instance", { instanceIds: JSON.stringify(instanceIds) }); - return ret; + const ret: string = await invoke('retain_network_instance', { instanceIds: JSON.stringify(instanceIds) }) + return ret } export async function collectNetworkInfos() { - const ret: string = await invoke("collect_network_infos", {}); - return JSON.parse(ret); + const ret: string = await invoke('collect_network_infos', {}) + return JSON.parse(ret) } diff --git a/easytier-gui/src/layouts/default.vue b/easytier-gui/src/layouts/default.vue index 6d11557..7c2aa3f 100644 --- a/easytier-gui/src/layouts/default.vue +++ b/easytier-gui/src/layouts/default.vue @@ -1,3 +1,3 @@ \ No newline at end of file + diff --git a/easytier-gui/src/main.ts b/easytier-gui/src/main.ts index 4660127..04c23e2 100644 --- a/easytier-gui/src/main.ts +++ b/easytier-gui/src/main.ts @@ -1,37 +1,37 @@ -import { setupLayouts } from "virtual:generated-layouts"; -import { createRouter, createWebHistory } from "vue-router/auto"; +import { setupLayouts } from 'virtual:generated-layouts' +import { createRouter, createWebHistory } from 'vue-router/auto' -import PrimeVue from 'primevue/config'; -import ToastService from 'primevue/toastservice'; -import App from "~/App.vue"; +import PrimeVue from 'primevue/config' +import ToastService from 'primevue/toastservice' +import App from '~/App.vue' -import "~/styles.css"; -import "primevue/resources/themes/aura-light-green/theme.css"; -import "primeicons/primeicons.css"; -import "primeflex/primeflex.css"; -import { i18n, loadLanguageAsync } from "~/modules/i18n"; +import '~/styles.css' +import 'primevue/resources/themes/aura-light-green/theme.css' +import 'primeicons/primeicons.css' +import 'primeflex/primeflex.css' +import { i18n, loadLanguageAsync } from '~/modules/i18n' if (import.meta.env.PROD) { - document.addEventListener("keydown", (event) => { + document.addEventListener('keydown', (event) => { if ( - event.key === "F5" || - (event.ctrlKey && event.key === "r") || - (event.metaKey && event.key === "r") + event.key === 'F5' + || (event.ctrlKey && event.key === 'r') + || (event.metaKey && event.key === 'r') ) - event.preventDefault(); - }); + event.preventDefault() + }) - document.addEventListener("contextmenu", (event) => { - event.preventDefault(); - }); + document.addEventListener('contextmenu', (event) => { + event.preventDefault() + }) } const app = createApp(App) const router = createRouter({ history: createWebHistory(), - extendRoutes: (routes) => setupLayouts(routes), -}); + extendRoutes: routes => setupLayouts(routes), +}) app.use(router) app.use(createPinia()) @@ -40,5 +40,4 @@ loadLanguageAsync(localStorage.getItem('lang') || 'en') app.use(PrimeVue) app.use(ToastService) -app.mount("#app") - +app.mount('#app') diff --git a/easytier-gui/src/modules/i18n.ts b/easytier-gui/src/modules/i18n.ts index 8112d7c..4a28dea 100644 --- a/easytier-gui/src/modules/i18n.ts +++ b/easytier-gui/src/modules/i18n.ts @@ -21,7 +21,7 @@ const loadedLanguages: string[] = [] function setI18nLanguage(lang: Locale) { i18n.global.locale.value = lang as any - localStorage.setItem("locale", lang); + localStorage.setItem('locale', lang) return lang } @@ -35,15 +35,16 @@ export async function loadLanguageAsync(lang: string): Promise { return setI18nLanguage(lang) // If the language hasn't been loaded yet - let messages; + let messages try { messages = await localesMap[lang]() - } catch { - messages = await localesMap['en']() + } + catch { + messages = await localesMap.en() } i18n.global.setLocaleMessage(lang, messages.default) loadedLanguages.push(lang) return setI18nLanguage(lang) -} \ No newline at end of file +} diff --git a/easytier-gui/src/pages/index.vue b/easytier-gui/src/pages/index.vue index 3be5077..cc943e6 100644 --- a/easytier-gui/src/pages/index.vue +++ b/easytier-gui/src/pages/index.vue @@ -1,19 +1,19 @@ +
- - + - {{ messageBarContent }} + {{ messageBarContent }} +
- - - - \ No newline at end of file diff --git a/easytier-gui/src/stores/network.ts b/easytier-gui/src/stores/network.ts index e676e86..2dc2885 100644 --- a/easytier-gui/src/stores/network.ts +++ b/easytier-gui/src/stores/network.ts @@ -1,8 +1,9 @@ -import { DEFAULT_NETWORK_CONFIG, NetworkConfig, NetworkInstance } from '~/types/network'; +import type { NetworkConfig, NetworkInstance } from '~/types/network' +import { DEFAULT_NETWORK_CONFIG } from '~/types/network' export const useNetworkStore = defineStore('networkStore', { state: () => { - const networkList = [DEFAULT_NETWORK_CONFIG()]; + const networkList = [DEFAULT_NETWORK_CONFIG()] return { // for initially empty lists networkList: networkList as NetworkConfig[], @@ -18,80 +19,80 @@ export const useNetworkStore = defineStore('networkStore', { getters: { lastNetwork(): NetworkConfig { - return this.networkList[this.networkList.length - 1]; + return this.networkList[this.networkList.length - 1] }, curNetworkId(): string { - return this.curNetwork.instance_id; + return this.curNetwork.instance_id }, networkInstances(): Array { - return Object.values(this.instances); + return Object.values(this.instances) }, networkInstanceIds(): Array { - return Object.keys(this.instances); - } + return Object.keys(this.instances) + }, }, actions: { addNewNetwork() { - this.networkList.push(DEFAULT_NETWORK_CONFIG()); + this.networkList.push(DEFAULT_NETWORK_CONFIG()) }, delCurNetwork() { - const curNetworkIdx = this.networkList.indexOf(this.curNetwork); - this.networkList.splice(curNetworkIdx, 1); - const nextCurNetworkIdx = Math.min(curNetworkIdx, this.networkList.length - 1); - this.curNetwork = this.networkList[nextCurNetworkIdx]; + const curNetworkIdx = this.networkList.indexOf(this.curNetwork) + this.networkList.splice(curNetworkIdx, 1) + const nextCurNetworkIdx = Math.min(curNetworkIdx, this.networkList.length - 1) + this.curNetwork = this.networkList[nextCurNetworkIdx] }, removeNetworkInstance(instanceId: string) { - delete this.instances[instanceId]; + delete this.instances[instanceId] }, addNetworkInstance(instanceId: string) { this.instances[instanceId] = { instance_id: instanceId, running: false, - error_msg: "", + error_msg: '', detail: {}, - }; + } }, updateWithNetworkInfos(networkInfos: Record) { - this.networkInfos = networkInfos; + this.networkInfos = networkInfos for (const [instanceId, info] of Object.entries(networkInfos)) { - if (this.instances[instanceId] === undefined) { - this.addNetworkInstance(instanceId); - } - this.instances[instanceId].running = info["running"]; - this.instances[instanceId].error_msg = info["error_msg"]; - this.instances[instanceId].detail = info; + if (this.instances[instanceId] === undefined) + this.addNetworkInstance(instanceId) + + this.instances[instanceId].running = info.running + this.instances[instanceId].error_msg = info.error_msg + this.instances[instanceId].detail = info } }, loadFromLocalStorage() { - const networkList = JSON.parse(localStorage.getItem("networkList") || '[]'); - let result = []; + const networkList = JSON.parse(localStorage.getItem('networkList') || '[]') + const result = [] for (const cfg of networkList) { result.push({ ...DEFAULT_NETWORK_CONFIG, ...cfg, - }); + }) } - if (result.length === 0) { - result.push(DEFAULT_NETWORK_CONFIG); - } - this.networkList = result; - this.curNetwork = this.networkList[0]; + if (result.length === 0) + result.push(DEFAULT_NETWORK_CONFIG) + + this.networkList = result + this.curNetwork = this.networkList[0] }, saveToLocalStorage() { - localStorage.setItem("networkList", JSON.stringify(this.networkList)); - } - } + localStorage.setItem('networkList', JSON.stringify(this.networkList)) + }, + }, }) if (import.meta.hot) - import.meta.hot.accept(acceptHMRUpdate(useNetworkStore as any, import.meta.hot)) \ No newline at end of file + import.meta.hot.accept(acceptHMRUpdate(useNetworkStore as any, import.meta.hot)) diff --git a/easytier-gui/src/styles.css b/easytier-gui/src/styles.css index 99fb8a4..25de580 100644 --- a/easytier-gui/src/styles.css +++ b/easytier-gui/src/styles.css @@ -1,12 +1,12 @@ @layer tailwind-base, primevue, tailwind-utilities; @layer tailwind-base { - @tailwind base; + @tailwind base; } @layer tailwind-utilities { - @tailwind components; - @tailwind utilities; + @tailwind components; + @tailwind utilities; } :root { @@ -26,8 +26,8 @@ } .card { - background: var(--surface-card); - padding: 2rem; - border-radius: 10px; - margin-bottom: 1rem; -} \ No newline at end of file + background: var(--surface-card); + padding: 2rem; + border-radius: 10px; + margin-bottom: 1rem; +} diff --git a/easytier-gui/src/types/network.ts b/easytier-gui/src/types/network.ts index 286bb48..4785c97 100644 --- a/easytier-gui/src/types/network.ts +++ b/easytier-gui/src/types/network.ts @@ -1,72 +1,72 @@ -import { v4 as uuidv4 } from 'uuid'; +import { v4 as uuidv4 } from 'uuid' export enum NetworkingMethod { - PublicServer = "PublicServer", - Manual = "Manual", - Standalone = "Standalone", + PublicServer = 'PublicServer', + Manual = 'Manual', + Standalone = 'Standalone', } export interface NetworkConfig { - instance_id: string, + instance_id: string virtual_ipv4: string network_name: string network_secret: string - networking_method: NetworkingMethod, + networking_method: NetworkingMethod - public_server_url: string, - peer_urls: Array, + public_server_url: string + peer_urls: Array - proxy_cidrs: Array, + proxy_cidrs: Array - enable_vpn_portal: boolean, - vpn_portal_listne_port: number, - vpn_portal_client_network_addr: string, - vpn_portal_client_network_len: number, + enable_vpn_portal: boolean + vpn_portal_listne_port: number + vpn_portal_client_network_addr: string + vpn_portal_client_network_len: number - advanced_settings: boolean, + advanced_settings: boolean - listener_urls: Array, - rpc_port: number, + listener_urls: Array + rpc_port: number } -export const DEFAULT_NETWORK_CONFIG = (): NetworkConfig => { +export function DEFAULT_NETWORK_CONFIG(): NetworkConfig { return { instance_id: uuidv4(), - virtual_ipv4: "", - network_name: "default", - network_secret: "", + virtual_ipv4: '', + network_name: 'default', + network_secret: '', networking_method: NetworkingMethod.PublicServer, - public_server_url: "tcp://easytier.public.kkrainbow.top:11010", + public_server_url: 'tcp://easytier.public.kkrainbow.top:11010', peer_urls: [], proxy_cidrs: [], enable_vpn_portal: false, vpn_portal_listne_port: 22022, - vpn_portal_client_network_addr: "", + vpn_portal_client_network_addr: '', vpn_portal_client_network_len: 24, advanced_settings: false, listener_urls: [ - "tcp://0.0.0.0:11010", - "udp://0.0.0.0:11010", - "wg://0.0.0.0:11011", + 'tcp://0.0.0.0:11010', + 'udp://0.0.0.0:11010', + 'wg://0.0.0.0:11011', ], rpc_port: 15888, } } export interface NetworkInstance { - instance_id: string, + instance_id: string - running: boolean, - error_msg: string, + running: boolean + error_msg: string - detail: any, -} \ No newline at end of file + detail: any +} diff --git a/easytier-gui/tailwind.config.js b/easytier-gui/tailwind.config.js index a28ce71..146cfe5 100644 --- a/easytier-gui/tailwind.config.js +++ b/easytier-gui/tailwind.config.js @@ -1,12 +1,11 @@ /** @type {import('tailwindcss').Config} */ export default { content: [ - "./index.html", - "./src/**/*.{vue,js,ts,jsx,tsx}", + './index.html', + './src/**/*.{vue,js,ts,jsx,tsx}', ], theme: { extend: {}, }, plugins: [], } - diff --git a/easytier-gui/tsconfig.json b/easytier-gui/tsconfig.json index cdb4de3..a9ed295 100644 --- a/easytier-gui/tsconfig.json +++ b/easytier-gui/tsconfig.json @@ -9,8 +9,6 @@ "baseUrl": ".", "module": "ESNext", "moduleResolution": "bundler", - "allowImportingTsExtensions": true, - "noEmit": true, "paths": { "~/*": [ "src/*" @@ -23,10 +21,12 @@ "unplugin-vue-macros/macros-global", "unplugin-vue-router/client" ], + "allowImportingTsExtensions": true, "allowJs": true, "strict": true, "strictNullChecks": true, "noUnusedLocals": true, + "noEmit": true, "esModuleInterop": true, "forceConsistentCasingInFileNames": true, "isolatedModules": true, @@ -42,4 +42,4 @@ "dist", "node_modules" ] -} \ No newline at end of file +} diff --git a/easytier-gui/vite.config.ts b/easytier-gui/vite.config.ts index 44723b7..717ea43 100644 --- a/easytier-gui/vite.config.ts +++ b/easytier-gui/vite.config.ts @@ -9,13 +9,13 @@ import VueI18n from '@intlify/unplugin-vue-i18n/vite' import VueDevTools from 'vite-plugin-vue-devtools' import VueRouter from 'unplugin-vue-router/vite' import { VueRouterAutoImports } from 'unplugin-vue-router' -import { PrimeVueResolver } from 'unplugin-vue-components/resolvers'; +import { PrimeVueResolver } from 'unplugin-vue-components/resolvers' // https://vitejs.dev/config/ export default defineConfig(async () => ({ resolve: { alias: { - "~/": `${path.resolve(__dirname, "src")}/`, + '~/': `${path.resolve(__dirname, 'src')}/`, }, }, plugins: [ @@ -64,8 +64,8 @@ export default defineConfig(async () => ({ include: [/\.vue$/, /\.vue\?vue/, /\.md$/], dts: 'src/components.d.ts', resolvers: [ - PrimeVueResolver() - ] + PrimeVueResolver(), + ], }), // https://github.com/intlify/bundle-tools/tree/main/packages/unplugin-vue-i18n @@ -90,7 +90,7 @@ export default defineConfig(async () => ({ strictPort: true, watch: { // 3. tell vite to ignore watching `src-tauri` - ignored: ["**/src-tauri/**"], + ignored: ['**/src-tauri/**'], }, }, -})); +}))