Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d72b450149 | ||
|
|
786168abdb | ||
|
|
108be1e211 | ||
|
|
c75bb79786 | ||
|
|
2c00f8ba6d | ||
|
|
9071f056b4 | ||
|
|
3df765394b | ||
|
|
eaa484d17d | ||
|
|
ce03c11956 | ||
|
|
b1a1bc5f81 |
No files matched your search
Vendored
+2
-1
@@ -11,5 +11,6 @@
|
|||||||
"files.associations": {
|
"files.associations": {
|
||||||
"*.css": "postcss"
|
"*.css": "postcss"
|
||||||
},
|
},
|
||||||
"editor.formatOnSave": false
|
"editor.formatOnSave": false,
|
||||||
|
"typescript.tsdk": "node_modules/typescript/lib"
|
||||||
}
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
MIT License
|
MIT License
|
||||||
|
|
||||||
Copyright (c) 2020-2021 Anthony Fu
|
Copyright (c) 2020-PRESENT Anthony Fu
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
|||||||
@@ -56,6 +56,8 @@ Mocking up web app with <b>Vitesse</b><sup><em>(speed)</em></sup><br>
|
|||||||
|
|
||||||
- 🦔 Critical CSS via [critters](https://github.com/GoogleChromeLabs/critters)
|
- 🦔 Critical CSS via [critters](https://github.com/GoogleChromeLabs/critters)
|
||||||
|
|
||||||
|
- 🔤 [Webfont self-hosting](https://github.com/feat-agency/vite-plugin-webfont-dl)
|
||||||
|
|
||||||
- 🦾 TypeScript, of course
|
- 🦾 TypeScript, of course
|
||||||
|
|
||||||
- ⚙️ Unit Testing with [Vitest](https://github.com/vitest-dev/vitest), E2E Testing with [Cypress](https://cypress.io/) on [GitHub Actions](https://github.com/features/actions)
|
- ⚙️ Unit Testing with [Vitest](https://github.com/vitest-dev/vitest), E2E Testing with [Cypress](https://cypress.io/) on [GitHub Actions](https://github.com/features/actions)
|
||||||
@@ -95,6 +97,7 @@ Mocking up web app with <b>Vitesse</b><sup><em>(speed)</em></sup><br>
|
|||||||
- [`vite-ssg-sitemap`](https://github.com/jbaubree/vite-ssg-sitemap) - Sitemap generator
|
- [`vite-ssg-sitemap`](https://github.com/jbaubree/vite-ssg-sitemap) - Sitemap generator
|
||||||
- [`@vueuse/head`](https://github.com/vueuse/head) - manipulate document head reactively
|
- [`@vueuse/head`](https://github.com/vueuse/head) - manipulate document head reactively
|
||||||
- [`vite-plugin-vue-inspector`](https://github.com/webfansplz/vite-plugin-vue-inspector) - jump to local IDE source code while click the element of browser automatically
|
- [`vite-plugin-vue-inspector`](https://github.com/webfansplz/vite-plugin-vue-inspector) - jump to local IDE source code while click the element of browser automatically
|
||||||
|
- [`vite-plugin-webfont-dl`](https://github.com/feat-agency/vite-plugin-webfont-dl) - Zero-config webfont (Google Fonts) downloader and injector to improve website's performance.
|
||||||
|
|
||||||
### Coding Style
|
### Coding Style
|
||||||
|
|
||||||
@@ -214,7 +217,3 @@ docker run --rm -it -p 8080:80 vitesse:latest
|
|||||||
I have created several Vite apps recently. Setting the configs up is kinda the bottleneck for me to make the ideas simply come true within a very short time.
|
I have created several Vite apps recently. Setting the configs up is kinda the bottleneck for me to make the ideas simply come true within a very short time.
|
||||||
|
|
||||||
So I made this starter template for myself to create apps more easily, along with some good practices that I have learned from making those apps. It's strongly opinionated, but feel free to tweak it or even maintain your own forks. [(see community maintained variation forks)](#variations)
|
So I made this starter template for myself to create apps more easily, along with some good practices that I have learned from making those apps. It's strongly opinionated, but feel free to tweak it or even maintain your own forks. [(see community maintained variation forks)](#variations)
|
||||||
|
|
||||||
## 📄 License
|
|
||||||
|
|
||||||
MIT License © 2020-PRESENT [Anthony Fu](https://github.com/antfu)
|
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
import { defineConfig } from 'cypress'
|
import { defineConfig } from 'cypress'
|
||||||
|
import vitePreprocessor from 'cypress-vite'
|
||||||
|
|
||||||
export default defineConfig({
|
export default defineConfig({
|
||||||
e2e: {
|
e2e: {
|
||||||
@@ -6,5 +7,8 @@ export default defineConfig({
|
|||||||
chromeWebSecurity: false,
|
chromeWebSecurity: false,
|
||||||
specPattern: 'cypress/e2e/**/*.spec.*',
|
specPattern: 'cypress/e2e/**/*.spec.*',
|
||||||
supportFile: false,
|
supportFile: false,
|
||||||
|
setupNodeEvents(on) {
|
||||||
|
on('file:preprocessor', vitePreprocessor())
|
||||||
|
},
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
+48
-35
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"private": true,
|
"private": true,
|
||||||
"packageManager": "pnpm@7.17.1",
|
"packageManager": "pnpm@8.1.1",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "vite-ssg build",
|
"build": "vite-ssg build",
|
||||||
"dev": "vite --port 3333 --open",
|
"dev": "vite --port 3333 --open",
|
||||||
@@ -12,55 +12,68 @@
|
|||||||
"test:e2e": "cypress open",
|
"test:e2e": "cypress open",
|
||||||
"test:unit": "vitest",
|
"test:unit": "vitest",
|
||||||
"typecheck": "vue-tsc --noEmit",
|
"typecheck": "vue-tsc --noEmit",
|
||||||
"up": "taze major -I"
|
"up": "taze major -I",
|
||||||
|
"postinstall": "npx simple-git-hooks",
|
||||||
|
"sizecheck": "npx vite-bundle-visualizer"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@unocss/reset": "^0.48.4",
|
"@unocss/reset": "^0.50.6",
|
||||||
"@vueuse/core": "^9.11.0",
|
"@vueuse/core": "^9.13.0",
|
||||||
"@vueuse/head": "^1.0.22",
|
"@vueuse/head": "^1.1.23",
|
||||||
"nprogress": "^0.2.0",
|
"nprogress": "^0.2.0",
|
||||||
"pinia": "^2.0.29",
|
"pinia": "^2.0.33",
|
||||||
"vue": "^3.2.45",
|
"vue": "^3.2.47",
|
||||||
"vue-demi": "^0.13.11",
|
"vue-demi": "^0.13.11",
|
||||||
"vue-i18n": "^9.2.2",
|
"vue-i18n": "^9.2.2",
|
||||||
"vue-router": "^4.1.6"
|
"vue-router": "^4.1.6"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@antfu/eslint-config": "^0.34.1",
|
"@antfu/eslint-config": "^0.38.4",
|
||||||
"@iconify-json/carbon": "^1.1.13",
|
"@iconify-json/carbon": "^1.1.16",
|
||||||
"@intlify/unplugin-vue-i18n": "^0.8.1",
|
"@intlify/unplugin-vue-i18n": "^0.10.0",
|
||||||
"@types/markdown-it-link-attributes": "^3.0.1",
|
"@types/markdown-it-link-attributes": "^3.0.1",
|
||||||
"@types/nprogress": "^0.2.0",
|
"@types/nprogress": "^0.2.0",
|
||||||
"@vitejs/plugin-vue": "^4.0.0",
|
"@vitejs/plugin-vue": "^4.1.0",
|
||||||
"@vue-macros/volar": "^0.5.15",
|
"@vue-macros/volar": "^0.9.5",
|
||||||
"@vue/test-utils": "^2.2.7",
|
"@vue/test-utils": "^2.3.2",
|
||||||
"critters": "^0.0.16",
|
"critters": "^0.0.16",
|
||||||
"cross-env": "^7.0.3",
|
"cross-env": "^7.0.3",
|
||||||
"cypress": "^12.3.0",
|
"cypress": "^12.9.0",
|
||||||
"eslint": "^8.32.0",
|
"cypress-vite": "^1.3.1",
|
||||||
"eslint-plugin-cypress": "^2.12.1",
|
"eslint": "^8.37.0",
|
||||||
|
"eslint-plugin-cypress": "^2.13.2",
|
||||||
"https-localhost": "^4.7.1",
|
"https-localhost": "^4.7.1",
|
||||||
|
"lint-staged": "^13.2.0",
|
||||||
"markdown-it-link-attributes": "^4.0.1",
|
"markdown-it-link-attributes": "^4.0.1",
|
||||||
"markdown-it-shiki": "^0.7.2",
|
"markdown-it-shiki": "^0.8.0",
|
||||||
"pnpm": "^7.25.1",
|
"pnpm": "^8.1.1",
|
||||||
"shiki": "^0.12.1",
|
"shiki": "^0.14.1",
|
||||||
"taze": "^0.8.5",
|
"simple-git-hooks": "^2.8.1",
|
||||||
"typescript": "^4.9.4",
|
"taze": "^0.9.1",
|
||||||
"unocss": "^0.48.4",
|
"typescript": "^4.9.3",
|
||||||
"unplugin-auto-import": "^0.12.1",
|
"unocss": "^0.50.6",
|
||||||
"unplugin-vue-components": "^0.22.12",
|
"unplugin-auto-import": "^0.15.2",
|
||||||
"unplugin-vue-macros": "^1.4.2",
|
"unplugin-vue-components": "^0.24.1",
|
||||||
"vite": "^4.0.4",
|
"unplugin-vue-macros": "^2.0.0",
|
||||||
"vite-plugin-inspect": "^0.7.14",
|
"vite": "^4.2.1",
|
||||||
"vite-plugin-pages": "^0.28.0",
|
"vite-bundle-visualizer": "^0.6.0",
|
||||||
"vite-plugin-pwa": "^0.14.1",
|
"vite-plugin-inspect": "^0.7.19",
|
||||||
"vite-plugin-vue-component-preview": "^0.3.4",
|
"vite-plugin-pages": "^0.29.0",
|
||||||
"vite-plugin-vue-inspector": "^3.2.1",
|
"vite-plugin-pwa": "^0.14.7",
|
||||||
"vite-plugin-vue-layouts": "^0.7.0",
|
"vite-plugin-vue-component-preview": "^1.1.5",
|
||||||
"vite-plugin-vue-markdown": "^0.22.2",
|
"vite-plugin-vue-inspector": "^3.4.0",
|
||||||
|
"vite-plugin-vue-layouts": "^0.8.0",
|
||||||
|
"vite-plugin-vue-markdown": "^0.22.4",
|
||||||
|
"vite-plugin-webfont-dl": "^3.7.0",
|
||||||
"vite-ssg": "^0.22.1",
|
"vite-ssg": "^0.22.1",
|
||||||
"vite-ssg-sitemap": "^0.4.3",
|
"vite-ssg-sitemap": "^0.4.3",
|
||||||
"vitest": "^0.27.2",
|
"vitest": "^0.29.8",
|
||||||
"vue-tsc": "^1.0.24"
|
"vue-tsc": "^1.3.8"
|
||||||
|
},
|
||||||
|
"simple-git-hooks": {
|
||||||
|
"pre-commit": "pnpm lint-staged"
|
||||||
|
},
|
||||||
|
"lint-staged": {
|
||||||
|
"*": "eslint --fix"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Generated
+3215
-2556
File diff suppressed because it is too large.
Load diff
Vendored
+17
-3
@@ -1,4 +1,7 @@
|
|||||||
// Generated by 'unplugin-auto-import'
|
/* eslint-disable */
|
||||||
|
/* prettier-ignore */
|
||||||
|
// @ts-nocheck
|
||||||
|
// Generated by unplugin-auto-import
|
||||||
export {}
|
export {}
|
||||||
declare global {
|
declare global {
|
||||||
const $$: typeof import('vue/macros')['$$']
|
const $$: typeof import('vue/macros')['$$']
|
||||||
@@ -83,7 +86,6 @@ declare global {
|
|||||||
const refThrottled: typeof import('@vueuse/core')['refThrottled']
|
const refThrottled: typeof import('@vueuse/core')['refThrottled']
|
||||||
const refWithControl: typeof import('@vueuse/core')['refWithControl']
|
const refWithControl: typeof import('@vueuse/core')['refWithControl']
|
||||||
const resolveComponent: typeof import('vue')['resolveComponent']
|
const resolveComponent: typeof import('vue')['resolveComponent']
|
||||||
const resolveDirective: typeof import('vue')['resolveDirective']
|
|
||||||
const resolveRef: typeof import('@vueuse/core')['resolveRef']
|
const resolveRef: typeof import('@vueuse/core')['resolveRef']
|
||||||
const resolveUnref: typeof import('@vueuse/core')['resolveUnref']
|
const resolveUnref: typeof import('@vueuse/core')['resolveUnref']
|
||||||
const shallowReactive: typeof import('vue')['shallowReactive']
|
const shallowReactive: typeof import('vue')['shallowReactive']
|
||||||
@@ -113,10 +115,12 @@ declare global {
|
|||||||
const useArrayFilter: typeof import('@vueuse/core')['useArrayFilter']
|
const useArrayFilter: typeof import('@vueuse/core')['useArrayFilter']
|
||||||
const useArrayFind: typeof import('@vueuse/core')['useArrayFind']
|
const useArrayFind: typeof import('@vueuse/core')['useArrayFind']
|
||||||
const useArrayFindIndex: typeof import('@vueuse/core')['useArrayFindIndex']
|
const useArrayFindIndex: typeof import('@vueuse/core')['useArrayFindIndex']
|
||||||
|
const useArrayFindLast: typeof import('@vueuse/core')['useArrayFindLast']
|
||||||
const useArrayJoin: typeof import('@vueuse/core')['useArrayJoin']
|
const useArrayJoin: typeof import('@vueuse/core')['useArrayJoin']
|
||||||
const useArrayMap: typeof import('@vueuse/core')['useArrayMap']
|
const useArrayMap: typeof import('@vueuse/core')['useArrayMap']
|
||||||
const useArrayReduce: typeof import('@vueuse/core')['useArrayReduce']
|
const useArrayReduce: typeof import('@vueuse/core')['useArrayReduce']
|
||||||
const useArraySome: typeof import('@vueuse/core')['useArraySome']
|
const useArraySome: typeof import('@vueuse/core')['useArraySome']
|
||||||
|
const useArrayUnique: typeof import('@vueuse/core')['useArrayUnique']
|
||||||
const useAsyncQueue: typeof import('@vueuse/core')['useAsyncQueue']
|
const useAsyncQueue: typeof import('@vueuse/core')['useAsyncQueue']
|
||||||
const useAsyncState: typeof import('@vueuse/core')['useAsyncState']
|
const useAsyncState: typeof import('@vueuse/core')['useAsyncState']
|
||||||
const useAttrs: typeof import('vue')['useAttrs']
|
const useAttrs: typeof import('vue')['useAttrs']
|
||||||
@@ -202,12 +206,14 @@ declare global {
|
|||||||
const useParallax: typeof import('@vueuse/core')['useParallax']
|
const useParallax: typeof import('@vueuse/core')['useParallax']
|
||||||
const usePermission: typeof import('@vueuse/core')['usePermission']
|
const usePermission: typeof import('@vueuse/core')['usePermission']
|
||||||
const usePointer: typeof import('@vueuse/core')['usePointer']
|
const usePointer: typeof import('@vueuse/core')['usePointer']
|
||||||
|
const usePointerLock: typeof import('@vueuse/core')['usePointerLock']
|
||||||
const usePointerSwipe: typeof import('@vueuse/core')['usePointerSwipe']
|
const usePointerSwipe: typeof import('@vueuse/core')['usePointerSwipe']
|
||||||
const usePreferredColorScheme: typeof import('@vueuse/core')['usePreferredColorScheme']
|
const usePreferredColorScheme: typeof import('@vueuse/core')['usePreferredColorScheme']
|
||||||
const usePreferredContrast: typeof import('@vueuse/core')['usePreferredContrast']
|
const usePreferredContrast: typeof import('@vueuse/core')['usePreferredContrast']
|
||||||
const usePreferredDark: typeof import('@vueuse/core')['usePreferredDark']
|
const usePreferredDark: typeof import('@vueuse/core')['usePreferredDark']
|
||||||
const usePreferredLanguages: typeof import('@vueuse/core')['usePreferredLanguages']
|
const usePreferredLanguages: typeof import('@vueuse/core')['usePreferredLanguages']
|
||||||
const usePreferredReducedMotion: typeof import('@vueuse/core')['usePreferredReducedMotion']
|
const usePreferredReducedMotion: typeof import('@vueuse/core')['usePreferredReducedMotion']
|
||||||
|
const usePrevious: typeof import('@vueuse/core')['usePrevious']
|
||||||
const useRafFn: typeof import('@vueuse/core')['useRafFn']
|
const useRafFn: typeof import('@vueuse/core')['useRafFn']
|
||||||
const useRefHistory: typeof import('@vueuse/core')['useRefHistory']
|
const useRefHistory: typeof import('@vueuse/core')['useRefHistory']
|
||||||
const useResizeObserver: typeof import('@vueuse/core')['useResizeObserver']
|
const useResizeObserver: typeof import('@vueuse/core')['useResizeObserver']
|
||||||
@@ -277,6 +283,11 @@ declare global {
|
|||||||
const watchWithFilter: typeof import('@vueuse/core')['watchWithFilter']
|
const watchWithFilter: typeof import('@vueuse/core')['watchWithFilter']
|
||||||
const whenever: typeof import('@vueuse/core')['whenever']
|
const whenever: typeof import('@vueuse/core')['whenever']
|
||||||
}
|
}
|
||||||
|
// for type re-export
|
||||||
|
declare global {
|
||||||
|
// @ts-ignore
|
||||||
|
export type { Component, ComponentPublicInstance, ComputedRef, InjectionKey, PropType, Ref, VNode } from 'vue'
|
||||||
|
}
|
||||||
// for vue template auto import
|
// for vue template auto import
|
||||||
import { UnwrapRef } from 'vue'
|
import { UnwrapRef } from 'vue'
|
||||||
declare module 'vue' {
|
declare module 'vue' {
|
||||||
@@ -363,7 +374,6 @@ declare module 'vue' {
|
|||||||
readonly refThrottled: UnwrapRef<typeof import('@vueuse/core')['refThrottled']>
|
readonly refThrottled: UnwrapRef<typeof import('@vueuse/core')['refThrottled']>
|
||||||
readonly refWithControl: UnwrapRef<typeof import('@vueuse/core')['refWithControl']>
|
readonly refWithControl: UnwrapRef<typeof import('@vueuse/core')['refWithControl']>
|
||||||
readonly resolveComponent: UnwrapRef<typeof import('vue')['resolveComponent']>
|
readonly resolveComponent: UnwrapRef<typeof import('vue')['resolveComponent']>
|
||||||
readonly resolveDirective: UnwrapRef<typeof import('vue')['resolveDirective']>
|
|
||||||
readonly resolveRef: UnwrapRef<typeof import('@vueuse/core')['resolveRef']>
|
readonly resolveRef: UnwrapRef<typeof import('@vueuse/core')['resolveRef']>
|
||||||
readonly resolveUnref: UnwrapRef<typeof import('@vueuse/core')['resolveUnref']>
|
readonly resolveUnref: UnwrapRef<typeof import('@vueuse/core')['resolveUnref']>
|
||||||
readonly shallowReactive: UnwrapRef<typeof import('vue')['shallowReactive']>
|
readonly shallowReactive: UnwrapRef<typeof import('vue')['shallowReactive']>
|
||||||
@@ -393,10 +403,12 @@ declare module 'vue' {
|
|||||||
readonly useArrayFilter: UnwrapRef<typeof import('@vueuse/core')['useArrayFilter']>
|
readonly useArrayFilter: UnwrapRef<typeof import('@vueuse/core')['useArrayFilter']>
|
||||||
readonly useArrayFind: UnwrapRef<typeof import('@vueuse/core')['useArrayFind']>
|
readonly useArrayFind: UnwrapRef<typeof import('@vueuse/core')['useArrayFind']>
|
||||||
readonly useArrayFindIndex: UnwrapRef<typeof import('@vueuse/core')['useArrayFindIndex']>
|
readonly useArrayFindIndex: UnwrapRef<typeof import('@vueuse/core')['useArrayFindIndex']>
|
||||||
|
readonly useArrayFindLast: UnwrapRef<typeof import('@vueuse/core')['useArrayFindLast']>
|
||||||
readonly useArrayJoin: UnwrapRef<typeof import('@vueuse/core')['useArrayJoin']>
|
readonly useArrayJoin: UnwrapRef<typeof import('@vueuse/core')['useArrayJoin']>
|
||||||
readonly useArrayMap: UnwrapRef<typeof import('@vueuse/core')['useArrayMap']>
|
readonly useArrayMap: UnwrapRef<typeof import('@vueuse/core')['useArrayMap']>
|
||||||
readonly useArrayReduce: UnwrapRef<typeof import('@vueuse/core')['useArrayReduce']>
|
readonly useArrayReduce: UnwrapRef<typeof import('@vueuse/core')['useArrayReduce']>
|
||||||
readonly useArraySome: UnwrapRef<typeof import('@vueuse/core')['useArraySome']>
|
readonly useArraySome: UnwrapRef<typeof import('@vueuse/core')['useArraySome']>
|
||||||
|
readonly useArrayUnique: UnwrapRef<typeof import('@vueuse/core')['useArrayUnique']>
|
||||||
readonly useAsyncQueue: UnwrapRef<typeof import('@vueuse/core')['useAsyncQueue']>
|
readonly useAsyncQueue: UnwrapRef<typeof import('@vueuse/core')['useAsyncQueue']>
|
||||||
readonly useAsyncState: UnwrapRef<typeof import('@vueuse/core')['useAsyncState']>
|
readonly useAsyncState: UnwrapRef<typeof import('@vueuse/core')['useAsyncState']>
|
||||||
readonly useAttrs: UnwrapRef<typeof import('vue')['useAttrs']>
|
readonly useAttrs: UnwrapRef<typeof import('vue')['useAttrs']>
|
||||||
@@ -482,12 +494,14 @@ declare module 'vue' {
|
|||||||
readonly useParallax: UnwrapRef<typeof import('@vueuse/core')['useParallax']>
|
readonly useParallax: UnwrapRef<typeof import('@vueuse/core')['useParallax']>
|
||||||
readonly usePermission: UnwrapRef<typeof import('@vueuse/core')['usePermission']>
|
readonly usePermission: UnwrapRef<typeof import('@vueuse/core')['usePermission']>
|
||||||
readonly usePointer: UnwrapRef<typeof import('@vueuse/core')['usePointer']>
|
readonly usePointer: UnwrapRef<typeof import('@vueuse/core')['usePointer']>
|
||||||
|
readonly usePointerLock: UnwrapRef<typeof import('@vueuse/core')['usePointerLock']>
|
||||||
readonly usePointerSwipe: UnwrapRef<typeof import('@vueuse/core')['usePointerSwipe']>
|
readonly usePointerSwipe: UnwrapRef<typeof import('@vueuse/core')['usePointerSwipe']>
|
||||||
readonly usePreferredColorScheme: UnwrapRef<typeof import('@vueuse/core')['usePreferredColorScheme']>
|
readonly usePreferredColorScheme: UnwrapRef<typeof import('@vueuse/core')['usePreferredColorScheme']>
|
||||||
readonly usePreferredContrast: UnwrapRef<typeof import('@vueuse/core')['usePreferredContrast']>
|
readonly usePreferredContrast: UnwrapRef<typeof import('@vueuse/core')['usePreferredContrast']>
|
||||||
readonly usePreferredDark: UnwrapRef<typeof import('@vueuse/core')['usePreferredDark']>
|
readonly usePreferredDark: UnwrapRef<typeof import('@vueuse/core')['usePreferredDark']>
|
||||||
readonly usePreferredLanguages: UnwrapRef<typeof import('@vueuse/core')['usePreferredLanguages']>
|
readonly usePreferredLanguages: UnwrapRef<typeof import('@vueuse/core')['usePreferredLanguages']>
|
||||||
readonly usePreferredReducedMotion: UnwrapRef<typeof import('@vueuse/core')['usePreferredReducedMotion']>
|
readonly usePreferredReducedMotion: UnwrapRef<typeof import('@vueuse/core')['usePreferredReducedMotion']>
|
||||||
|
readonly usePrevious: UnwrapRef<typeof import('@vueuse/core')['usePrevious']>
|
||||||
readonly useRafFn: UnwrapRef<typeof import('@vueuse/core')['useRafFn']>
|
readonly useRafFn: UnwrapRef<typeof import('@vueuse/core')['useRafFn']>
|
||||||
readonly useRefHistory: UnwrapRef<typeof import('@vueuse/core')['useRefHistory']>
|
readonly useRefHistory: UnwrapRef<typeof import('@vueuse/core')['useRefHistory']>
|
||||||
readonly useResizeObserver: UnwrapRef<typeof import('@vueuse/core')['useResizeObserver']>
|
readonly useResizeObserver: UnwrapRef<typeof import('@vueuse/core')['useResizeObserver']>
|
||||||
|
|||||||
Vendored
+4
-2
@@ -1,5 +1,7 @@
|
|||||||
// generated by unplugin-vue-components
|
/* eslint-disable */
|
||||||
// We suggest you to commit this file into source control
|
/* prettier-ignore */
|
||||||
|
// @ts-nocheck
|
||||||
|
// Generated by unplugin-vue-components
|
||||||
// Read more: https://github.com/vuejs/core/pull/3399
|
// Read more: https://github.com/vuejs/core/pull/3399
|
||||||
import '@vue/runtime-core'
|
import '@vue/runtime-core'
|
||||||
|
|
||||||
|
|||||||
@@ -1,17 +1,21 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
const { t, availableLocales, locale } = useI18n()
|
import { availableLocales, loadLanguageAsync } from '~/modules/i18n'
|
||||||
|
|
||||||
const toggleLocales = () => {
|
const { t, locale } = useI18n()
|
||||||
|
|
||||||
|
async function toggleLocales() {
|
||||||
// change to some real logic
|
// change to some real logic
|
||||||
const locales = availableLocales
|
const locales = availableLocales
|
||||||
locale.value = locales[(locales.indexOf(locale.value) + 1) % locales.length]
|
const newLocale = locales[(locales.indexOf(locale.value) + 1) % locales.length]
|
||||||
|
await loadLanguageAsync(newLocale)
|
||||||
|
locale.value = newLocale
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<nav text-xl mt-6>
|
<nav text-xl mt-6>
|
||||||
<RouterLink class="icon-btn mx-2" to="/" :title="t('button.home')">
|
<RouterLink class="icon-btn mx-2" to="/">
|
||||||
<div i-carbon-campsite />
|
<div i-carbon-campsite :title="t('button.home')" />
|
||||||
</RouterLink>
|
</RouterLink>
|
||||||
|
|
||||||
<button class="icon-btn mx-2 !outline-none" :title="t('button.toggle_dark')" @click="toggleDark()">
|
<button class="icon-btn mx-2 !outline-none" :title="t('button.toggle_dark')" @click="toggleDark()">
|
||||||
@@ -22,8 +26,8 @@ const toggleLocales = () => {
|
|||||||
<div i-carbon-language />
|
<div i-carbon-language />
|
||||||
</a>
|
</a>
|
||||||
|
|
||||||
<RouterLink class="icon-btn mx-2" to="/about" :title="t('button.about')">
|
<RouterLink class="icon-btn mx-2" to="/about">
|
||||||
<div i-carbon-dicom-overlay />
|
<div i-carbon-dicom-overlay :title="t('button.about')" />
|
||||||
</RouterLink>
|
</RouterLink>
|
||||||
|
|
||||||
<a class="icon-btn mx-2" rel="noreferrer" href="https://github.com/antfu/vitesse" target="_blank" title="GitHub">
|
<a class="icon-btn mx-2" rel="noreferrer" href="https://github.com/antfu/vitesse" target="_blank" title="GitHub">
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
const { modelValue } = defineModel<{
|
const { modelValue } = defineModels<{
|
||||||
modelValue: string
|
modelValue: string
|
||||||
}>()
|
}>()
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
+2
-2
@@ -1,6 +1,6 @@
|
|||||||
import { ViteSSG } from 'vite-ssg'
|
import { ViteSSG } from 'vite-ssg'
|
||||||
import { setupLayouts } from 'virtual:generated-layouts'
|
import { setupLayouts } from 'virtual:generated-layouts'
|
||||||
import Previewer from 'virtual:vue-component-preview'
|
// import Previewer from 'virtual:vue-component-preview'
|
||||||
import App from './App.vue'
|
import App from './App.vue'
|
||||||
import type { UserModule } from './types'
|
import type { UserModule } from './types'
|
||||||
import generatedRoutes from '~pages'
|
import generatedRoutes from '~pages'
|
||||||
@@ -19,6 +19,6 @@ export const createApp = ViteSSG(
|
|||||||
// install all modules under `modules/`
|
// install all modules under `modules/`
|
||||||
Object.values(import.meta.glob<{ install: UserModule }>('./modules/*.ts', { eager: true }))
|
Object.values(import.meta.glob<{ install: UserModule }>('./modules/*.ts', { eager: true }))
|
||||||
.forEach(i => i.install?.(ctx))
|
.forEach(i => i.install?.(ctx))
|
||||||
ctx.app.use(Previewer)
|
// ctx.app.use(Previewer)
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
+39
-14
@@ -1,3 +1,4 @@
|
|||||||
|
import type { Locale } from 'vue-i18n'
|
||||||
import { createI18n } from 'vue-i18n'
|
import { createI18n } from 'vue-i18n'
|
||||||
import { type UserModule } from '~/types'
|
import { type UserModule } from '~/types'
|
||||||
|
|
||||||
@@ -5,21 +6,45 @@ import { type UserModule } from '~/types'
|
|||||||
// https://vitejs.dev/guide/features.html#glob-import
|
// https://vitejs.dev/guide/features.html#glob-import
|
||||||
//
|
//
|
||||||
// Don't need this? Try vitesse-lite: https://github.com/antfu/vitesse-lite
|
// Don't need this? Try vitesse-lite: https://github.com/antfu/vitesse-lite
|
||||||
const messages = Object.fromEntries(
|
const i18n = createI18n({
|
||||||
Object.entries(
|
legacy: false,
|
||||||
import.meta.glob<{ default: any }>('../../locales/*.y(a)?ml', { eager: true }))
|
locale: '',
|
||||||
.map(([key, value]) => {
|
messages: {},
|
||||||
const yaml = key.endsWith('.yaml')
|
})
|
||||||
return [key.slice(14, yaml ? -5 : -4), value.default]
|
|
||||||
}),
|
const localesMap = Object.fromEntries(
|
||||||
)
|
Object.entries(import.meta.glob('../../locales/*.yml'))
|
||||||
|
.map(([path, loadLocale]) => [path.match(/([\w-]*)\.yml$/)?.[1], loadLocale]),
|
||||||
|
) as Record<Locale, () => Promise<{ default: Record<string, string> }>>
|
||||||
|
|
||||||
|
export const availableLocales = Object.keys(localesMap)
|
||||||
|
|
||||||
|
const loadedLanguages: string[] = []
|
||||||
|
|
||||||
|
function setI18nLanguage(lang: Locale) {
|
||||||
|
i18n.global.locale.value = lang as any
|
||||||
|
if (typeof document !== 'undefined')
|
||||||
|
document.querySelector('html')?.setAttribute('lang', lang)
|
||||||
|
return lang
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function loadLanguageAsync(lang: string): Promise<Locale> {
|
||||||
|
// If the same language
|
||||||
|
if (i18n.global.locale.value === lang)
|
||||||
|
return setI18nLanguage(lang)
|
||||||
|
|
||||||
|
// If the language was already loaded
|
||||||
|
if (loadedLanguages.includes(lang))
|
||||||
|
return setI18nLanguage(lang)
|
||||||
|
|
||||||
|
// If the language hasn't been loaded yet
|
||||||
|
const messages = await localesMap[lang]()
|
||||||
|
i18n.global.setLocaleMessage(lang, messages.default)
|
||||||
|
loadedLanguages.push(lang)
|
||||||
|
return setI18nLanguage(lang)
|
||||||
|
}
|
||||||
|
|
||||||
export const install: UserModule = ({ app }) => {
|
export const install: UserModule = ({ app }) => {
|
||||||
const i18n = createI18n({
|
|
||||||
legacy: false,
|
|
||||||
locale: 'en',
|
|
||||||
messages,
|
|
||||||
})
|
|
||||||
|
|
||||||
app.use(i18n)
|
app.use(i18n)
|
||||||
|
loadLanguageAsync('en')
|
||||||
}
|
}
|
||||||
+3
-3
@@ -3,12 +3,12 @@ defineOptions({
|
|||||||
name: 'IndexPage',
|
name: 'IndexPage',
|
||||||
})
|
})
|
||||||
const user = useUserStore()
|
const user = useUserStore()
|
||||||
const name = $ref(user.savedName)
|
const name = ref(user.savedName)
|
||||||
|
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
const go = () => {
|
function go() {
|
||||||
if (name)
|
if (name)
|
||||||
router.push(`/hi/${encodeURIComponent(name)}`)
|
router.push(`/hi/${encodeURIComponent(name.value)}`)
|
||||||
}
|
}
|
||||||
|
|
||||||
const { t } = useI18n()
|
const { t } = useI18n()
|
||||||
|
|||||||
@@ -1,3 +1,3 @@
|
|||||||
// Vitest Snapshot v1
|
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
|
||||||
|
|
||||||
exports[`TheCounter.vue > should render 1`] = `"<div>10 <button class=\\"inc\\"> + </button><button class=\\"dec\\"> - </button></div>"`;
|
exports[`TheCounter.vue > should render 1`] = `"<div>10 <button class=\\"inc\\"> + </button><button class=\\"dec\\"> - </button></div>"`;
|
||||||
+1
-1
@@ -30,7 +30,7 @@
|
|||||||
},
|
},
|
||||||
"vueCompilerOptions": {
|
"vueCompilerOptions": {
|
||||||
"plugins": [
|
"plugins": [
|
||||||
"@vue-macros/volar/define-model",
|
"@vue-macros/volar/define-models",
|
||||||
"@vue-macros/volar/define-slots"
|
"@vue-macros/volar/define-slots"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|||||||
+10
-3
@@ -1,6 +1,6 @@
|
|||||||
import path from 'path'
|
import path from 'node:path'
|
||||||
import { defineConfig } from 'vite'
|
import { defineConfig } from 'vite'
|
||||||
import Preview from 'vite-plugin-vue-component-preview'
|
// import Preview from 'vite-plugin-vue-component-preview'
|
||||||
import Vue from '@vitejs/plugin-vue'
|
import Vue from '@vitejs/plugin-vue'
|
||||||
import Pages from 'vite-plugin-pages'
|
import Pages from 'vite-plugin-pages'
|
||||||
import generateSitemap from 'vite-ssg-sitemap'
|
import generateSitemap from 'vite-ssg-sitemap'
|
||||||
@@ -16,6 +16,7 @@ import LinkAttributes from 'markdown-it-link-attributes'
|
|||||||
import Unocss from 'unocss/vite'
|
import Unocss from 'unocss/vite'
|
||||||
import Shiki from 'markdown-it-shiki'
|
import Shiki from 'markdown-it-shiki'
|
||||||
import VueMacros from 'unplugin-vue-macros/vite'
|
import VueMacros from 'unplugin-vue-macros/vite'
|
||||||
|
import WebfontDownload from 'vite-plugin-webfont-dl'
|
||||||
|
|
||||||
export default defineConfig({
|
export default defineConfig({
|
||||||
resolve: {
|
resolve: {
|
||||||
@@ -25,7 +26,7 @@ export default defineConfig({
|
|||||||
},
|
},
|
||||||
|
|
||||||
plugins: [
|
plugins: [
|
||||||
Preview(),
|
// Preview(),
|
||||||
|
|
||||||
VueMacros({
|
VueMacros({
|
||||||
plugins: {
|
plugins: {
|
||||||
@@ -143,6 +144,9 @@ export default defineConfig({
|
|||||||
Inspector({
|
Inspector({
|
||||||
toggleButtonVisibility: 'never',
|
toggleButtonVisibility: 'never',
|
||||||
}),
|
}),
|
||||||
|
|
||||||
|
// https://github.com/feat-agency/vite-plugin-webfont-dl
|
||||||
|
WebfontDownload(),
|
||||||
],
|
],
|
||||||
|
|
||||||
// https://github.com/vitest-dev/vitest
|
// https://github.com/vitest-dev/vitest
|
||||||
@@ -158,6 +162,9 @@ export default defineConfig({
|
|||||||
ssgOptions: {
|
ssgOptions: {
|
||||||
script: 'async',
|
script: 'async',
|
||||||
formatting: 'minify',
|
formatting: 'minify',
|
||||||
|
crittersOptions: {
|
||||||
|
reduceInlineStyles: false,
|
||||||
|
},
|
||||||
onFinished() { generateSitemap() },
|
onFinished() { generateSitemap() },
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user