feat: init hoppscotch-embed package

This commit is contained in:
liyasthomas
2021-11-30 18:36:52 +05:30
parent 520ac8ede5
commit c3fcc6e35d
63 changed files with 12023 additions and 58 deletions

View File

@@ -0,0 +1,11 @@
## Modules
A custom user module system. Place a `.ts` file with the following template, it will be installed automatically.
```ts
import { UserModule } from '~/types'
export const install: UserModule = ({ app, router, isClient }) => {
// do something
}
```

View File

@@ -0,0 +1,25 @@
import { createI18n } from "vue-i18n"
import { UserModule } from "~/types"
// Import i18n resources
// https://vitejs.dev/guide/features.html#glob-import
//
// Don't need this? Try vitesse-lite: https://github.com/antfu/vitesse-lite
const messages = Object.fromEntries(
Object.entries(
import.meta.globEager("../../locales/*.y(a)?ml"))
.map(([key, value]) => {
const yaml = key.endsWith(".yaml")
return [key.slice(14, yaml ? -5 : -4), value.default]
}),
)
export const install: UserModule = ({ app }) => {
const i18n = createI18n({
legacy: false,
locale: "en",
messages,
})
app.use(i18n)
}

View File

@@ -0,0 +1,9 @@
import NProgress from "nprogress"
import { UserModule } from "~/types"
export const install: UserModule = ({ isClient, router }) => {
if (isClient) {
router.beforeEach(() => { NProgress.start() })
router.afterEach(() => { NProgress.done() })
}
}

View File

@@ -0,0 +1,17 @@
import { createPinia } from "pinia"
import { UserModule } from "~/types"
// Setup Pinia
// https://pinia.esm.dev/
export const install: UserModule = ({ isClient, initialState, app }) => {
const pinia = createPinia()
app.use(pinia)
// Refer to
// https://github.com/antfu/vite-ssg/blob/main/README.md#state-serialization
// for other serialization strategies.
if (isClient)
pinia.state.value = (initialState.pinia) || {}
else
initialState.pinia = pinia.state.value
}

View File

@@ -0,0 +1,12 @@
import { UserModule } from "~/types"
// https://github.com/antfu/vite-plugin-pwa#automatic-reload-when-new-content-available
export const install: UserModule = ({ isClient, router }) => {
if (!isClient)
return
router.isReady().then(async() => {
const { registerSW } = await import("virtual:pwa-register")
registerSW({ immediate: true })
})
}