uptime-kuma/src/main.js

160 lines
4.2 KiB
JavaScript
Raw Normal View History

2021-07-27 10:47:13 -07:00
import "bootstrap";
import { createApp, h } from "vue";
2021-08-24 01:44:58 -07:00
import { createI18n } from "vue-i18n"
2021-07-27 10:47:13 -07:00
import { createRouter, createWebHistory } from "vue-router";
import Toast from "vue-toastification";
import "vue-toastification/dist/index.css";
import App from "./App.vue";
import "./assets/app.scss";
import { FontAwesomeIcon } from "./icon.js";
import EmptyLayout from "./layouts/EmptyLayout.vue";
import Layout from "./layouts/Layout.vue";
import socket from "./mixins/socket";
import theme from "./mixins/theme";
2021-08-10 00:02:46 -07:00
import mobile from "./mixins/mobile";
2021-08-17 01:41:12 -07:00
import datetime from "./mixins/datetime";
2021-06-25 06:55:49 -07:00
import Dashboard from "./pages/Dashboard.vue";
import DashboardHome from "./pages/DashboardHome.vue";
import Details from "./pages/Details.vue";
import EditMonitor from "./pages/EditMonitor.vue";
2021-07-27 10:47:13 -07:00
import Settings from "./pages/Settings.vue";
2021-07-10 22:47:57 -07:00
import Setup from "./pages/Setup.vue";
2021-08-19 03:12:52 -07:00
import List from "./pages/List.vue";
import { appName } from "./util.ts";
2021-06-25 06:55:49 -07:00
2021-08-24 01:44:58 -07:00
import en from "./languages/en";
import zhHK from "./languages/zh-HK";
2021-08-25 17:43:26 -07:00
import deDE from "./languages/de-DE";
2021-09-02 02:10:54 -07:00
import nlNL from "./languages/nl-NL";
import esEs from "./languages/es-ES";
2021-09-05 14:37:26 -07:00
import frFR from "./languages/fr-FR";
2021-09-07 23:41:19 -07:00
import itIT from "./languages/it-IT";
import ja from "./languages/ja";
2021-09-01 02:51:22 -07:00
import daDK from "./languages/da-DK";
2021-09-02 17:06:26 -07:00
import sr from "./languages/sr";
2021-09-02 17:20:01 -07:00
import srLatn from "./languages/sr-latn";
import svSE from "./languages/sv-SE";
2021-09-01 08:29:01 -07:00
import koKR from "./languages/ko-KR";
2021-09-01 11:37:01 -07:00
import ruRU from "./languages/ru-RU";
2021-09-02 03:33:09 -07:00
import zhCN from "./languages/zh-CN";
2021-09-04 13:38:53 -07:00
import pl from "./languages/pl"
import etEE from "./languages/et-EE"
2021-08-24 01:44:58 -07:00
2021-06-25 06:55:49 -07:00
const routes = [
{
2021-07-27 10:47:13 -07:00
path: "/",
2021-06-25 06:55:49 -07:00
component: Layout,
children: [
{
name: "root",
2021-07-27 10:47:13 -07:00
path: "",
2021-06-25 06:55:49 -07:00
component: Dashboard,
children: [
{
name: "DashboardHome",
2021-07-27 10:47:13 -07:00
path: "/dashboard",
2021-06-25 06:55:49 -07:00
component: DashboardHome,
children: [
{
2021-07-27 10:47:13 -07:00
path: "/dashboard/:id",
2021-06-27 01:10:55 -07:00
component: EmptyLayout,
children: [
{
2021-07-27 10:47:13 -07:00
path: "",
2021-06-27 01:10:55 -07:00
component: Details,
},
{
2021-07-27 10:47:13 -07:00
path: "/edit/:id",
2021-06-27 01:10:55 -07:00
component: EditMonitor,
},
2021-07-27 10:47:13 -07:00
],
2021-06-25 06:55:49 -07:00
},
{
2021-07-27 10:47:13 -07:00
path: "/add",
2021-06-25 06:55:49 -07:00
component: EditMonitor,
},
2021-08-19 03:12:52 -07:00
{
path: "/list",
component: List,
},
2021-07-27 10:47:13 -07:00
],
2021-06-25 06:55:49 -07:00
},
{
2021-07-27 10:47:13 -07:00
path: "/settings",
2021-06-25 06:55:49 -07:00
component: Settings,
},
],
},
2021-07-10 22:47:57 -07:00
2021-06-25 06:55:49 -07:00
],
2021-07-10 22:47:57 -07:00
},
{
2021-07-27 10:47:13 -07:00
path: "/setup",
2021-07-10 22:47:57 -07:00
component: Setup,
},
2021-06-25 06:55:49 -07:00
]
const router = createRouter({
2021-07-27 10:47:13 -07:00
linkActiveClass: "active",
2021-06-25 06:55:49 -07:00
history: createWebHistory(),
routes,
})
2021-08-24 01:44:58 -07:00
const languageList = {
en,
"zh-HK": zhHK,
2021-08-25 17:43:26 -07:00
"de-DE": deDE,
2021-09-02 02:10:54 -07:00
"nl-NL": nlNL,
"es-ES": esEs,
2021-09-05 14:41:57 -07:00
"fr-FR": frFR,
2021-09-07 23:41:19 -07:00
"it-IT": itIT,
"ja": ja,
2021-09-01 02:51:22 -07:00
"da-DK": daDK,
2021-09-02 17:06:26 -07:00
"sr": sr,
2021-09-02 17:20:01 -07:00
"sr-latn": srLatn,
"sv-SE": svSE,
2021-09-01 08:29:01 -07:00
"ko-KR": koKR,
2021-09-01 11:37:01 -07:00
"ru-RU": ruRU,
2021-09-02 03:33:09 -07:00
"zh-CN": zhCN,
2021-09-04 13:38:53 -07:00
"pl": pl,
"et-EE": etEE,
2021-08-24 01:44:58 -07:00
};
const i18n = createI18n({
locale: localStorage.locale || "en",
fallbackLocale: "en",
silentFallbackWarn: true,
silentTranslationWarn: true,
messages: languageList
});
2021-06-25 06:55:49 -07:00
const app = createApp({
mixins: [
socket,
2021-08-10 00:02:46 -07:00
theme,
2021-08-17 01:41:12 -07:00
mobile,
datetime
2021-06-25 06:55:49 -07:00
],
data() {
return {
appName: appName
}
},
2021-07-27 10:47:13 -07:00
render: () => h(App),
2021-06-25 06:55:49 -07:00
})
2021-08-24 01:44:58 -07:00
app.use(router);
app.use(i18n);
2021-06-25 06:55:49 -07:00
const options = {
2021-07-27 10:47:13 -07:00
position: "bottom-right",
2021-06-25 06:55:49 -07:00
};
app.use(Toast, options);
2021-07-27 10:47:13 -07:00
app.component("FontAwesomeIcon", FontAwesomeIcon)
2021-07-27 01:52:44 -07:00
2021-07-27 10:47:13 -07:00
app.mount("#app")