mirror of
https://github.com/CorentinTh/it-tools.git
synced 2025-04-30 03:19:12 -04:00
feat: added components
This commit is contained in:
parent
6e0c369398
commit
5fa81533d9
30 changed files with 2405 additions and 1853 deletions
|
@ -11,7 +11,7 @@ const copyToClipboard = (text: string) => {
|
|||
}
|
||||
|
||||
@Component
|
||||
export class Copyable extends Vue {
|
||||
export class CopyableMixin extends Vue {
|
||||
copy(text: string, toastText = 'Copied to clipboard !') {
|
||||
copyToClipboard(text)
|
||||
console.log(toastText)
|
|
@ -1,33 +1,36 @@
|
|||
import {Component, Vue} from 'nuxt-property-decorator'
|
||||
import {RouteConfig} from '@nuxt/types/config/router'
|
||||
import {ToolConfig} from '~/types/ToolConfig'
|
||||
import {ToolRouteConfig} from '~/types/ToolConfig'
|
||||
import {capitalise} from '~/utils/string'
|
||||
|
||||
export type ToolRouteConfig = RouteConfig & {config: ToolConfig}
|
||||
|
||||
@Component
|
||||
export class ToolRoutes extends Vue {
|
||||
export class ToolRoutesMixin extends Vue {
|
||||
toolRoutesFlat : ToolRouteConfig[] = []
|
||||
toolRoutesSections : {[key: string]: ToolRouteConfig[]} = {}
|
||||
|
||||
async mounted() {
|
||||
async created() {
|
||||
const routes = this.$router.options.routes?.filter(r => r.meta?.isTool) || []
|
||||
const flat: ToolRouteConfig[] = []
|
||||
const sections: { [key: string]: ToolRouteConfig[] } = {}
|
||||
|
||||
for (const route of routes) {
|
||||
if ('component' in route) {
|
||||
// @ts-ignore
|
||||
const component = await route.component()
|
||||
const routeConfig = {...route, config: component.options.methods.config()} as ToolRouteConfig
|
||||
this.toolRoutesFlat.push(routeConfig)
|
||||
flat.push(routeConfig)
|
||||
|
||||
const sectionKey = capitalise(route.meta.section).replace(/_/g, ' ')
|
||||
|
||||
if (!(sectionKey in this.toolRoutesSections)) {
|
||||
this.toolRoutesSections[sectionKey] = []
|
||||
if (!(sectionKey in sections)) {
|
||||
sections[sectionKey] = []
|
||||
}
|
||||
|
||||
this.toolRoutesSections[sectionKey].push(routeConfig)
|
||||
sections[sectionKey].push(routeConfig)
|
||||
}
|
||||
}
|
||||
|
||||
this.toolRoutesSections = sections
|
||||
this.toolRoutesFlat = flat
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue