Initial release of Web Tools 0.0.5

This commit is contained in:
mid
2026-08-07 21:51:15 +08:00
commit fa14e9e5b9
71 changed files with 6365 additions and 0 deletions
+34
View File
@@ -0,0 +1,34 @@
import { createRouter, createWebHistory, type RouteRecordRaw } from 'vue-router'
import { toolById, toolComponents, tools } from '@/tools/registry'
const toolRoutes: RouteRecordRaw[] = tools.map((tool) => ({
path: `/tools/${tool.id}`,
name: tool.id,
component: toolComponents[tool.id],
meta: {
title: tool.title,
categoryId: tool.category,
toolId: tool.id,
},
}))
export const router = createRouter({
history: createWebHistory(),
routes: [
{ path: '/', redirect: '/tools/ascii-hex' },
...toolRoutes,
{
path: '/setting',
name: 'setting',
component: () => import('@/views/SettingView.vue'),
meta: { title: '工具管理' },
},
{ path: '/:pathMatch(.*)*', redirect: '/tools/ascii-hex' },
],
scrollBehavior: () => ({ top: 0 }),
})
router.beforeEach((to) => {
if (to.meta.toolId && !toolById.has(String(to.meta.toolId))) return '/tools/ascii-hex'
return true
})