mirror of
https://github.com/IT4Change/boilerplate-frontend.git
synced 2025-12-13 07:35:53 +00:00
clean structure
This commit is contained in:
parent
02b3276519
commit
2851a5144f
@ -70,7 +70,10 @@
|
|||||||
"import/no-dynamic-require": "error",
|
"import/no-dynamic-require": "error",
|
||||||
"import/no-internal-modules": "off",
|
"import/no-internal-modules": "off",
|
||||||
"import/no-relative-packages": "error",
|
"import/no-relative-packages": "error",
|
||||||
"import/no-relative-parent-imports": "error",
|
"import/no-relative-parent-imports": [
|
||||||
|
"error",
|
||||||
|
{ "ignore": ["#[src,root,components,pages,plugins,context,types]/*"] }
|
||||||
|
],
|
||||||
"import/no-self-import": "error",
|
"import/no-self-import": "error",
|
||||||
"import/no-unresolved": "error",
|
"import/no-unresolved": "error",
|
||||||
"import/no-useless-path-segments": "error",
|
"import/no-useless-path-segments": "error",
|
||||||
|
|||||||
@ -1,10 +1,8 @@
|
|||||||
import { setup } from '@storybook/vue3'
|
import { setup } from '@storybook/vue3'
|
||||||
import { createPinia } from 'pinia'
|
import { createPinia } from 'pinia'
|
||||||
|
|
||||||
// eslint-disable-next-line import/no-relative-parent-imports
|
import i18n from '#plugins/i18n'
|
||||||
import i18n from '../renderer/i18n'
|
import CreateVuetify from '#plugins/vuetify'
|
||||||
// eslint-disable-next-line import/no-relative-parent-imports
|
|
||||||
import CreateVuetify from '../renderer/vuetify'
|
|
||||||
|
|
||||||
import { withVuetifyTheme } from './withVuetifyTheme.decorator'
|
import { withVuetifyTheme } from './withVuetifyTheme.decorator'
|
||||||
|
|
||||||
|
|||||||
@ -82,7 +82,6 @@ The following endpoints are provided given the right command is executed or all
|
|||||||
|
|
||||||
- [ ] figma
|
- [ ] figma
|
||||||
- [ ] chromatic
|
- [ ] chromatic
|
||||||
- [ ] github actions
|
|
||||||
- [ ] feature zähler -> pinia tore
|
- [ ] feature zähler -> pinia tore
|
||||||
|
|
||||||
## Known Problems
|
## Known Problems
|
||||||
|
|||||||
13
package.json
13
package.json
@ -24,7 +24,9 @@
|
|||||||
"docker",
|
"docker",
|
||||||
"remark-cli"
|
"remark-cli"
|
||||||
],
|
],
|
||||||
"author": "Ulf Gebhardt",
|
"author": {
|
||||||
|
"name": "Ulf Gebhardt"
|
||||||
|
},
|
||||||
"license": "Apache-2.0",
|
"license": "Apache-2.0",
|
||||||
"bugs": {
|
"bugs": {
|
||||||
"url": "https://github.com/IT4Change/boilerplate-frontend/issues"
|
"url": "https://github.com/IT4Change/boilerplate-frontend/issues"
|
||||||
@ -122,5 +124,14 @@
|
|||||||
"stylelint-config-standard-scss": "^11.1.0",
|
"stylelint-config-standard-scss": "^11.1.0",
|
||||||
"vitest": "^0.34.6",
|
"vitest": "^0.34.6",
|
||||||
"vuepress": "^2.0.0-rc.0"
|
"vuepress": "^2.0.0-rc.0"
|
||||||
|
},
|
||||||
|
"imports": {
|
||||||
|
"#root/*": "./*",
|
||||||
|
"#src/*": "./src/*",
|
||||||
|
"#components/*": "./src/components/*",
|
||||||
|
"#pages/*": "./src/pages/*",
|
||||||
|
"#plugins/*": "./renderer/plugins/*",
|
||||||
|
"#context/*": "./renderer/context/*",
|
||||||
|
"#types/*": "./types/*"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,8 +1,6 @@
|
|||||||
import { createApp } from './app'
|
import { createApp } from './app'
|
||||||
|
|
||||||
import type { PageContextClient } from './types'
|
import type { PageContextClient } from '#types/PageContext'
|
||||||
|
|
||||||
export { render }
|
|
||||||
|
|
||||||
// This render() hook only supports SSR, see https://vike.dev/render-modes for how to modify render() to support SPA
|
// This render() hook only supports SSR, see https://vike.dev/render-modes for how to modify render() to support SPA
|
||||||
async function render(pageContext: PageContextClient) {
|
async function render(pageContext: PageContextClient) {
|
||||||
@ -15,3 +13,5 @@ async function render(pageContext: PageContextClient) {
|
|||||||
/* To enable Client-side Routing:
|
/* To enable Client-side Routing:
|
||||||
export const clientRouting = true
|
export const clientRouting = true
|
||||||
// !! WARNING !! Before doing so, read https://vike.dev/clientRouting */
|
// !! WARNING !! Before doing so, read https://vike.dev/clientRouting */
|
||||||
|
|
||||||
|
export { render }
|
||||||
|
|||||||
@ -1,13 +1,13 @@
|
|||||||
import { renderToString as renderToString_ } from '@vue/server-renderer'
|
import { renderToString as renderToString_ } from '@vue/server-renderer'
|
||||||
import { escapeInject, dangerouslySkipEscape } from 'vike/server'
|
import { escapeInject, dangerouslySkipEscape } from 'vike/server'
|
||||||
|
|
||||||
import { createApp } from './app'
|
import logoUrl from '#components/logo.svg'
|
||||||
import logoUrl from './logo.svg'
|
|
||||||
|
|
||||||
import type { PageContextServer } from './types'
|
import { createApp } from './app'
|
||||||
|
|
||||||
|
import type { PageContextServer } from '#types/PageContext'
|
||||||
import type { App } from 'vue'
|
import type { App } from 'vue'
|
||||||
|
|
||||||
export { render }
|
|
||||||
// See https://vike.dev/data-fetching
|
// See https://vike.dev/data-fetching
|
||||||
export const passToClient = ['pageProps', 'urlPathname']
|
export const passToClient = ['pageProps', 'urlPathname']
|
||||||
|
|
||||||
@ -56,3 +56,5 @@ async function renderToString(app: App) {
|
|||||||
if (err) throw err
|
if (err) throw err
|
||||||
return appHtml
|
return appHtml
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export { render }
|
||||||
|
|||||||
@ -1,16 +1,16 @@
|
|||||||
import { createPinia } from 'pinia'
|
|
||||||
import { createSSRApp, defineComponent, h } from 'vue'
|
import { createSSRApp, defineComponent, h } from 'vue'
|
||||||
|
|
||||||
import i18n from './i18n'
|
import PageShell from '#components//PageShell.vue'
|
||||||
import PageShell from './PageShell.vue'
|
import { setPageContext } from '#context/usePageContext'
|
||||||
import { setPageContext } from './usePageContext'
|
import i18n from '#plugins/i18n'
|
||||||
import CreateVuetify from './vuetify'
|
import pinia from '#plugins/pinia'
|
||||||
|
import CreateVuetify from '#plugins/vuetify'
|
||||||
|
import { Page } from '#types/Page'
|
||||||
|
import { PageProps } from '#types/PageProps'
|
||||||
|
|
||||||
import type { Component, PageContext, PageProps } from './types'
|
import type { PageContext } from '#types/PageContext'
|
||||||
|
|
||||||
export { createApp }
|
function createApp(Page: Page, pageProps: PageProps | undefined, pageContext: PageContext) {
|
||||||
|
|
||||||
function createApp(Page: Component, pageProps: PageProps | undefined, pageContext: PageContext) {
|
|
||||||
const PageWithLayout = defineComponent({
|
const PageWithLayout = defineComponent({
|
||||||
render() {
|
render() {
|
||||||
return h(
|
return h(
|
||||||
@ -25,7 +25,6 @@ function createApp(Page: Component, pageProps: PageProps | undefined, pageContex
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
const pinia = createPinia()
|
|
||||||
const app = createSSRApp(PageWithLayout)
|
const app = createSSRApp(PageWithLayout)
|
||||||
app.use(pinia)
|
app.use(pinia)
|
||||||
app.use(i18n)
|
app.use(i18n)
|
||||||
@ -36,3 +35,5 @@ function createApp(Page: Component, pageProps: PageProps | undefined, pageContex
|
|||||||
|
|
||||||
return app
|
return app
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export { createApp }
|
||||||
|
|||||||
@ -3,13 +3,10 @@
|
|||||||
|
|
||||||
import { inject } from 'vue'
|
import { inject } from 'vue'
|
||||||
|
|
||||||
import { PageContext } from './types'
|
import { PageContext } from '#types/PageContext'
|
||||||
|
|
||||||
import type { App, InjectionKey } from 'vue'
|
import type { App, InjectionKey } from 'vue'
|
||||||
|
|
||||||
export { usePageContext }
|
|
||||||
export { setPageContext }
|
|
||||||
|
|
||||||
const key: InjectionKey<PageContext> = Symbol(undefined)
|
const key: InjectionKey<PageContext> = Symbol(undefined)
|
||||||
|
|
||||||
function usePageContext() {
|
function usePageContext() {
|
||||||
@ -21,3 +18,6 @@ function usePageContext() {
|
|||||||
function setPageContext(app: App, pageContext: PageContext) {
|
function setPageContext(app: App, pageContext: PageContext) {
|
||||||
app.provide(key, pageContext)
|
app.provide(key, pageContext)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export { usePageContext }
|
||||||
|
export { setPageContext }
|
||||||
@ -1,10 +1,8 @@
|
|||||||
import { createI18n } from 'vue-i18n'
|
import { createI18n } from 'vue-i18n'
|
||||||
|
|
||||||
// eslint-disable-next-line import/no-relative-parent-imports
|
import de from '#src/locales/de.json'
|
||||||
import de from '../src/locales/de.json'
|
|
||||||
// import { de as $vuetify } from 'vuetify/locale'
|
// import { de as $vuetify } from 'vuetify/locale'
|
||||||
// eslint-disable-next-line import/no-relative-parent-imports
|
import en from '#src/locales/en.json'
|
||||||
import en from '../src/locales/en.json'
|
|
||||||
// import { en as $vuetify } from 'vuetify/locale'
|
// import { en as $vuetify } from 'vuetify/locale'
|
||||||
|
|
||||||
export default createI18n({
|
export default createI18n({
|
||||||
3
renderer/plugins/pinia.ts
Normal file
3
renderer/plugins/pinia.ts
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
import { createPinia } from 'pinia'
|
||||||
|
|
||||||
|
export default createPinia()
|
||||||
@ -1,9 +1,7 @@
|
|||||||
import { config } from '@vue/test-utils'
|
import { config } from '@vue/test-utils'
|
||||||
|
|
||||||
// eslint-disable-next-line import/no-relative-parent-imports
|
import i18n from '#plugins/i18n'
|
||||||
import i18n from '../renderer/i18n'
|
import vuetify from '#plugins/vuetify'
|
||||||
// eslint-disable-next-line import/no-relative-parent-imports
|
|
||||||
import vuetify from '../renderer/vuetify'
|
|
||||||
|
|
||||||
config.global.plugins.push(vuetify(i18n))
|
config.global.plugins.push(vuetify(i18n))
|
||||||
|
|
||||||
@ -4,7 +4,7 @@
|
|||||||
</a>
|
</a>
|
||||||
</template>
|
</template>
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { usePageContext } from './usePageContext'
|
import { usePageContext } from '#context/usePageContext'
|
||||||
|
|
||||||
const pageContext = usePageContext()
|
const pageContext = usePageContext()
|
||||||
</script>
|
</script>
|
||||||
|
Before Width: | Height: | Size: 5.7 KiB After Width: | Height: | Size: 5.7 KiB |
@ -8,5 +8,5 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import ClickCounter from './ClickCounter.vue'
|
import ClickCounter from '#components/ClickCounter.vue'
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@ -9,7 +9,16 @@
|
|||||||
"types": ["vite/client"],
|
"types": ["vite/client"],
|
||||||
"skipLibCheck": true,
|
"skipLibCheck": true,
|
||||||
"esModuleInterop": true,
|
"esModuleInterop": true,
|
||||||
"resolveJsonModule": true
|
"resolveJsonModule": true,
|
||||||
|
"paths": {
|
||||||
|
"#root/*": ["./*"],
|
||||||
|
"#src/*": ["./src/*"],
|
||||||
|
"#components/*": ["./src/components/*"],
|
||||||
|
"#pages/*": ["./src/pages/*"],
|
||||||
|
"#plugins/*": ["./renderer/plugins/*"],
|
||||||
|
"#context/*": ["./renderer/context/*"],
|
||||||
|
"#types/*": ["./types/*"]
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"ts-node": {
|
"ts-node": {
|
||||||
"transpileOnly": true,
|
"transpileOnly": true,
|
||||||
|
|||||||
5
types/Page.ts
Normal file
5
types/Page.ts
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
import type { ComponentPublicInstance } from 'vue'
|
||||||
|
|
||||||
|
type Page = ComponentPublicInstance // https://stackoverflow.com/questions/63985658/how-to-type-vue-instance-out-of-definecomponent-in-vue-3/63986086#63986086
|
||||||
|
|
||||||
|
export type { Page }
|
||||||
@ -1,25 +1,19 @@
|
|||||||
import type { ComponentPublicInstance } from 'vue'
|
import { Page } from '#types/Page'
|
||||||
|
import { PageProps } from '#types/PageProps'
|
||||||
|
|
||||||
export type {
|
export type {
|
||||||
PageContextServer,
|
PageContextServer,
|
||||||
/*
|
/*
|
||||||
// When using Client Routing https://vike.dev/clientRouting
|
// When using Client Routing https://vike.dev/clientRouting
|
||||||
PageContextClient,
|
PageContextClient,
|
||||||
PageContext,
|
PageContext,
|
||||||
/ */
|
/ */
|
||||||
// When using Server Routing
|
// When using Server Routing
|
||||||
PageContextClientWithServerRouting as PageContextClient,
|
PageContextClientWithServerRouting as PageContextClient,
|
||||||
PageContextWithServerRouting as PageContext,
|
PageContextWithServerRouting as PageContext,
|
||||||
//* /
|
//* /
|
||||||
} from 'vike/types'
|
} from 'vike/types'
|
||||||
|
|
||||||
type PageProps = object
|
|
||||||
type Component = ComponentPublicInstance // https://stackoverflow.com/questions/63985658/how-to-type-vue-instance-out-of-definecomponent-in-vue-3/63986086#63986086
|
|
||||||
type Page = Component
|
|
||||||
|
|
||||||
export type { PageProps }
|
|
||||||
export type { Component }
|
|
||||||
|
|
||||||
// https://vike.dev/pageContext#typescript
|
// https://vike.dev/pageContext#typescript
|
||||||
declare global {
|
declare global {
|
||||||
// eslint-disable-next-line @typescript-eslint/no-namespace
|
// eslint-disable-next-line @typescript-eslint/no-namespace
|
||||||
3
types/PageProps.ts
Normal file
3
types/PageProps.ts
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
type PageProps = object
|
||||||
|
|
||||||
|
export type { PageProps }
|
||||||
0
src/vue.d.ts → types/vue.d.ts
vendored
0
src/vue.d.ts → types/vue.d.ts
vendored
@ -1,3 +1,5 @@
|
|||||||
|
import path from 'path'
|
||||||
|
|
||||||
import vueI18n from '@intlify/unplugin-vue-i18n/vite'
|
import vueI18n from '@intlify/unplugin-vue-i18n/vite'
|
||||||
import vue from '@vitejs/plugin-vue'
|
import vue from '@vitejs/plugin-vue'
|
||||||
import vike from 'vike/plugin'
|
import vike from 'vike/plugin'
|
||||||
@ -18,6 +20,17 @@ const config: UserConfig = {
|
|||||||
outDir: './build',
|
outDir: './build',
|
||||||
},
|
},
|
||||||
ssr: { noExternal: ['vuetify'] },
|
ssr: { noExternal: ['vuetify'] },
|
||||||
|
resolve: {
|
||||||
|
alias: {
|
||||||
|
'#root': __dirname,
|
||||||
|
'#src': path.join(__dirname, '/src'),
|
||||||
|
'#components': path.join(__dirname, '/src/components'),
|
||||||
|
'#pages': path.join(__dirname, '/src/pages'),
|
||||||
|
'#plugins': path.join(__dirname, '/renderer/plugins'),
|
||||||
|
'#context': path.join(__dirname, '/renderer/context'),
|
||||||
|
'#types': path.join(__dirname, '/types'),
|
||||||
|
},
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
export default config
|
export default config
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user