Files
EasyTier/easytier-web/frontend/src/main.ts
T
KKRainbow e31bde1836 feat(web): add standalone WASM config generator (#2480)
Add a small Vite workspace that builds and publishes independently
of the dashboard. Reuse frontend-lib for the form and expose the
existing NetworkConfig conversions through wasm-bindgen.

Initialize the Aura theme in the standalone entry, detect the browser
language, and provide a persistent selector in the form header. Present
Generate Config and Copy Config as the page actions.

Keep the shared network secret field fluid so both form columns align.
Bundle the generator under dist/config-generator in the dashboard
artifact while preserving its standalone build output.

Build the optimized WASM module with the project and remove the
API-backed generator route from the dashboard.
2026-08-07 16:25:33 +08:00

97 lines
2.8 KiB
TypeScript

import { createApp } from 'vue'
import 'easytier-frontend-lib/style.css'
import './style.css'
import App from './App.vue'
import EasytierFrontendLib from 'easytier-frontend-lib'
import PrimeVue from 'primevue/config'
import Aura from '@primeuix/themes/aura';
import ConfirmationService from 'primevue/confirmationservice';
import { I18nUtils } from 'easytier-frontend-lib'
import { createRouter, createWebHashHistory } from 'vue-router'
import MainPage from './components/MainPage.vue'
import Login from './components/Login.vue'
import DeviceList from './components/DeviceList.vue'
import DeviceManagement from './components/DeviceManagement.vue'
import Dashboard from './components/Dashboard.vue'
import DialogService from 'primevue/dialogservice';
import ToastService from 'primevue/toastservice';
const routes = [
{
path: '/auth', children: [
{
name: 'login',
path: '',
component: Login,
alias: 'login',
props: { isRegistering: false }
},
{
name: 'register',
path: 'register',
component: Login,
props: { isRegistering: true }
}
]
},
{
path: '/h/:apiHost', component: MainPage, children: [
{
path: '',
alias: 'dashboard',
name: 'dashboard',
component: Dashboard,
},
{
path: 'deviceList',
name: 'deviceList',
component: DeviceList,
children: [
{
path: 'device/:deviceId/:instanceId?',
name: 'deviceManagement',
component: DeviceManagement,
}
]
},
]
},
{
path: '/:pathMatch(.*)*', name: 'notFound', redirect: () => {
let apiHost = localStorage.getItem('apiHost');
if (apiHost) {
return { name: 'dashboard', params: { apiHost: apiHost } }
} else {
return { name: 'login' }
}
}
}
]
const router = createRouter({
history: createWebHashHistory(),
routes,
})
const app = createApp(App)
// Use i18n
app.use(I18nUtils.i18n)
app.use(PrimeVue,
{
theme: {
preset: Aura,
options: {
prefix: 'p',
darkModeSelector: 'system',
cssLayer: {
name: 'primevue',
order: 'tailwind-base, primevue, tailwind-utilities'
}
}
}
}
).use(ToastService as any).use(DialogService as any).use(router).use(ConfirmationService as any).use(EasytierFrontendLib).mount('#app')