This commit is contained in:
commit
db82325ed7
216 files changed
+33718
No files matched your search
@@ -0,0 +1,106 @@
|
||||
import { createApp } from "vue";
|
||||
import { createPinia } from "pinia";
|
||||
import { createRouter, createWebHistory } from "vue-router";
|
||||
import { useSession } from "./store";
|
||||
import App from "./App.vue";
|
||||
import Login from "./views/Login.vue";
|
||||
import Dashboard from "./views/Dashboard.vue";
|
||||
import Projects from "./views/Projects.vue";
|
||||
import Account from "./views/Account.vue";
|
||||
import Admin from "./views/Admin.vue";
|
||||
import Models from "./views/Models.vue";
|
||||
import Wallet from "./views/Wallet.vue";
|
||||
import Develop from "./views/Develop.vue";
|
||||
import AdminTasks from "./views/AdminTasks.vue";
|
||||
import Hosting from "./views/Hosting.vue";
|
||||
import Plans from "./views/Plans.vue";
|
||||
import Landing from "./views/Landing.vue";
|
||||
import AdminOverview from "./views/AdminOverview.vue";
|
||||
import Integrations from "./views/Integrations.vue";
|
||||
import Nodes from "./views/Nodes.vue";
|
||||
import AdminSites from "./views/AdminSites.vue";
|
||||
import Storage from "./views/Storage.vue";
|
||||
import Domains from "./views/Domains.vue";
|
||||
import AdminDomains from "./views/AdminDomains.vue";
|
||||
import Tickets from "./views/Tickets.vue";
|
||||
import AdminExtensions from "./views/AdminExtensions.vue";
|
||||
import PluginTools from "./views/PluginTools.vue";
|
||||
import "./style.css";
|
||||
import "./landing.css";
|
||||
const router = createRouter({
|
||||
history: createWebHistory(),
|
||||
routes: [
|
||||
{ path: "/admin/nodes", component: Nodes, meta: { admin: true } },
|
||||
{ path: "/admin/sites", component: AdminSites, meta: { admin: true } },
|
||||
{ path: "/login", component: Login, meta: { public: true } },
|
||||
{ path: "/admin/login", component: Login, meta: { public: true } },
|
||||
{ path: "/", component: Landing, meta: { public: true } },
|
||||
{ path: "/console", component: Dashboard },
|
||||
{ path: "/admin", redirect: { name: "admin-overview" } },
|
||||
{
|
||||
path: "/admin/overview",
|
||||
name: "admin-overview",
|
||||
component: AdminOverview,
|
||||
meta: { admin: true },
|
||||
},
|
||||
{
|
||||
path: "/admin/integrations",
|
||||
component: Integrations,
|
||||
meta: { admin: true },
|
||||
},
|
||||
{ path: "/projects", component: Projects },
|
||||
{ path: "/account", component: Account },
|
||||
{ path: "/wallet", component: Wallet },
|
||||
{ path: "/hosting", component: Hosting },
|
||||
{ path: "/storage", component: Storage },
|
||||
{ path: "/domains", component: Domains },
|
||||
{ path: "/tickets/:ticketId?", component: Tickets },
|
||||
{ path: "/extensions/:pluginSlug?", component: PluginTools },
|
||||
{
|
||||
path: "/admin/extensions",
|
||||
component: AdminExtensions,
|
||||
meta: { admin: true, permission: "extensions:manage" },
|
||||
},
|
||||
{
|
||||
path: "/admin/tickets/:ticketId?",
|
||||
component: Tickets,
|
||||
meta: { admin: true, permission: "tickets:manage" },
|
||||
},
|
||||
{ path: "/admin/domains", component: AdminDomains, meta: { admin: true } },
|
||||
{ path: "/admin/plans", component: Plans, meta: { admin: true } },
|
||||
{ path: "/develop", component: Develop },
|
||||
{ path: "/admin/models", component: Models, meta: { admin: true } },
|
||||
{ path: "/admin/tasks", component: AdminTasks, meta: { admin: true } },
|
||||
{
|
||||
path: "/admin/:section(users|settings|audit)",
|
||||
sensitive: true,
|
||||
component: Admin,
|
||||
meta: { admin: true },
|
||||
},
|
||||
{ path: "/admin/:pathMatch(.*)*", redirect: { name: "admin-overview" } },
|
||||
{ path: "/:pathMatch(.*)*", redirect: "/" },
|
||||
],
|
||||
});
|
||||
const app = createApp(App);
|
||||
app.use(createPinia());
|
||||
router.beforeEach(async (to) => {
|
||||
const store = useSession();
|
||||
if (to.meta.public) return true;
|
||||
const login = to.path.startsWith("/admin") ? "/admin/login" : "/login";
|
||||
if (!sessionStorage.getItem("session")) return login;
|
||||
try {
|
||||
await store.load();
|
||||
} catch {
|
||||
store.clear();
|
||||
return login;
|
||||
}
|
||||
if (to.meta.admin && !store.user?.permissions.length) return "/console";
|
||||
if (
|
||||
typeof to.meta.permission === "string" &&
|
||||
!store.user?.permissions.includes(to.meta.permission)
|
||||
)
|
||||
return { name: "admin-overview" };
|
||||
return true;
|
||||
});
|
||||
app.use(router);
|
||||
app.mount("#app");
|
||||
Reference in new issue
Block a user