This commit is contained in:
3
.npmrc
3
.npmrc
@ -1,2 +1,3 @@
|
|||||||
use-node-version=20.16.0
|
|
||||||
# registry=https://npm-cf-proxy.oo1.dev
|
# registry=https://npm-cf-proxy.oo1.dev
|
||||||
|
use-node-version=20.16.0
|
||||||
|
shamefully-hoist=true
|
||||||
|
1
components.d.ts
vendored
1
components.d.ts
vendored
@ -13,6 +13,7 @@ declare module 'vue' {
|
|||||||
IconEcosystem: typeof import('./src/components/icons/IconEcosystem.vue')['default']
|
IconEcosystem: typeof import('./src/components/icons/IconEcosystem.vue')['default']
|
||||||
IconSupport: typeof import('./src/components/icons/IconSupport.vue')['default']
|
IconSupport: typeof import('./src/components/icons/IconSupport.vue')['default']
|
||||||
IconTooling: typeof import('./src/components/icons/IconTooling.vue')['default']
|
IconTooling: typeof import('./src/components/icons/IconTooling.vue')['default']
|
||||||
|
ReusableTemplate: typeof import('./src/components/ReusableTemplate.vue')['default']
|
||||||
RouterLink: typeof import('vue-router')['RouterLink']
|
RouterLink: typeof import('vue-router')['RouterLink']
|
||||||
RouterView: typeof import('vue-router')['RouterView']
|
RouterView: typeof import('vue-router')['RouterView']
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
"@unhead/vue": "^1.10.0",
|
"@unhead/vue": "^1.10.0",
|
||||||
"@vant/use": "^1.6.0",
|
"@vant/use": "^1.6.0",
|
||||||
"@yanhao98/vue-router-helper": "^0.0.4",
|
"@yanhao98/vue-router-helper": "^0.0.4",
|
||||||
"alova": "^3.0.10",
|
"alova": "^3.0.11",
|
||||||
"axios": "^1.7.4",
|
"axios": "^1.7.4",
|
||||||
"dayjs": "^1.11.13",
|
"dayjs": "^1.11.13",
|
||||||
"jsencrypt": "^3.3.2",
|
"jsencrypt": "^3.3.2",
|
||||||
@ -45,6 +45,7 @@
|
|||||||
"@types/jsdom": "^21.1.7",
|
"@types/jsdom": "^21.1.7",
|
||||||
"@types/node": "^22.5.0",
|
"@types/node": "^22.5.0",
|
||||||
"@types/nprogress": "^0.2.3",
|
"@types/nprogress": "^0.2.3",
|
||||||
|
"@unocss/preset-attributify": "^0.62.2",
|
||||||
"@unocss/preset-rem-to-px": "^0.62.2",
|
"@unocss/preset-rem-to-px": "^0.62.2",
|
||||||
"@unocss/reset": "^0.62.2",
|
"@unocss/reset": "^0.62.2",
|
||||||
"@vant/auto-import-resolver": "^1.2.1",
|
"@vant/auto-import-resolver": "^1.2.1",
|
||||||
|
19
pnpm-lock.yaml
generated
19
pnpm-lock.yaml
generated
@ -15,7 +15,7 @@ importers:
|
|||||||
dependencies:
|
dependencies:
|
||||||
'@alova/adapter-axios':
|
'@alova/adapter-axios':
|
||||||
specifier: ^2.0.5
|
specifier: ^2.0.5
|
||||||
version: 2.0.5(alova@3.0.10)(axios@1.7.4)
|
version: 2.0.5(alova@3.0.11)(axios@1.7.4)
|
||||||
'@unhead/vue':
|
'@unhead/vue':
|
||||||
specifier: ^1.10.0
|
specifier: ^1.10.0
|
||||||
version: 1.10.0(vue@3.4.38(typescript@5.5.4))
|
version: 1.10.0(vue@3.4.38(typescript@5.5.4))
|
||||||
@ -26,8 +26,8 @@ importers:
|
|||||||
specifier: ^0.0.4
|
specifier: ^0.0.4
|
||||||
version: 0.0.4(nprogress@0.2.0)(vue-router@4.4.3(patch_hash=srtmpgmwmi3z5x3wdppdguh7mi)(vue@3.4.38(typescript@5.5.4)))
|
version: 0.0.4(nprogress@0.2.0)(vue-router@4.4.3(patch_hash=srtmpgmwmi3z5x3wdppdguh7mi)(vue@3.4.38(typescript@5.5.4)))
|
||||||
alova:
|
alova:
|
||||||
specifier: ^3.0.10
|
specifier: ^3.0.11
|
||||||
version: 3.0.10
|
version: 3.0.11
|
||||||
axios:
|
axios:
|
||||||
specifier: ^1.7.4
|
specifier: ^1.7.4
|
||||||
version: 1.7.4
|
version: 1.7.4
|
||||||
@ -98,6 +98,9 @@ importers:
|
|||||||
'@types/nprogress':
|
'@types/nprogress':
|
||||||
specifier: ^0.2.3
|
specifier: ^0.2.3
|
||||||
version: 0.2.3
|
version: 0.2.3
|
||||||
|
'@unocss/preset-attributify':
|
||||||
|
specifier: ^0.62.2
|
||||||
|
version: 0.62.2
|
||||||
'@unocss/preset-rem-to-px':
|
'@unocss/preset-rem-to-px':
|
||||||
specifier: ^0.62.2
|
specifier: ^0.62.2
|
||||||
version: 0.62.2
|
version: 0.62.2
|
||||||
@ -1244,8 +1247,8 @@ packages:
|
|||||||
ajv@6.12.6:
|
ajv@6.12.6:
|
||||||
resolution: {integrity: sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g==, tarball: https://registry.npmjs.org/ajv/-/ajv-6.12.6.tgz}
|
resolution: {integrity: sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g==, tarball: https://registry.npmjs.org/ajv/-/ajv-6.12.6.tgz}
|
||||||
|
|
||||||
alova@3.0.10:
|
alova@3.0.11:
|
||||||
resolution: {integrity: sha512-nYt3Xv+huzsekOsIkJNtR7R1Rkhz2gpuNAHjkbRtDWtV6RGyV6sA3T+Uy4MKvkJ4YBID6hGQoOuZeteUCNG5Ug==, tarball: https://registry.npmjs.org/alova/-/alova-3.0.10.tgz}
|
resolution: {integrity: sha512-AOsjol0wTYUzxLOo3m2IvfL7KyQjFFzlCwAXV6fqeOolTWSbDMVcQ9jAWLgPFtLeYenia3jzwPxHbNyQIQK+UA==, tarball: https://registry.npmjs.org/alova/-/alova-3.0.11.tgz}
|
||||||
engines: {node: '>= 18.0.0'}
|
engines: {node: '>= 18.0.0'}
|
||||||
|
|
||||||
ansi-escapes@7.0.0:
|
ansi-escapes@7.0.0:
|
||||||
@ -3072,10 +3075,10 @@ packages:
|
|||||||
|
|
||||||
snapshots:
|
snapshots:
|
||||||
|
|
||||||
'@alova/adapter-axios@2.0.5(alova@3.0.10)(axios@1.7.4)':
|
'@alova/adapter-axios@2.0.5(alova@3.0.11)(axios@1.7.4)':
|
||||||
dependencies:
|
dependencies:
|
||||||
'@alova/shared': 1.0.4
|
'@alova/shared': 1.0.4
|
||||||
alova: 3.0.10
|
alova: 3.0.11
|
||||||
axios: 1.7.4
|
axios: 1.7.4
|
||||||
|
|
||||||
'@alova/shared@1.0.4': {}
|
'@alova/shared@1.0.4': {}
|
||||||
@ -4219,7 +4222,7 @@ snapshots:
|
|||||||
json-schema-traverse: 0.4.1
|
json-schema-traverse: 0.4.1
|
||||||
uri-js: 4.4.1
|
uri-js: 4.4.1
|
||||||
|
|
||||||
alova@3.0.10:
|
alova@3.0.11:
|
||||||
dependencies:
|
dependencies:
|
||||||
'@alova/shared': 1.0.4
|
'@alova/shared': 1.0.4
|
||||||
rate-limiter-flexible: 5.0.3
|
rate-limiter-flexible: 5.0.3
|
||||||
|
@ -4,5 +4,6 @@ const VITE_BUILD_COMMIT = import.meta.env.VITE_BUILD_COMMIT;
|
|||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div fixed rounded-br-4 bottom-0 left-0 z-9999 px-4 py-2 bg-black text-white>commit: {{ VITE_BUILD_COMMIT }}</div>
|
<div fixed rounded-br-4 bottom-0 left-0 z-9999 px-4 py-2 bg-black text-white>commit: {{ VITE_BUILD_COMMIT }}</div>
|
||||||
|
<div>$__DEV__: {{ $__DEV__ }}</div>
|
||||||
<RouterView />
|
<RouterView />
|
||||||
</template>
|
</template>
|
||||||
|
14
src/components/ReusableTemplate.vue
Normal file
14
src/components/ReusableTemplate.vue
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
<template>
|
||||||
|
<TemplateFoo.define v-slot="{ msg }">
|
||||||
|
<div>Hello {{ msg.toUpperCase() }}</div>
|
||||||
|
</TemplateFoo.define>
|
||||||
|
|
||||||
|
<TemplateFoo.reuse msg="World" />
|
||||||
|
<TemplateFoo.reuse msg="Reusable" />
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
|
import { createReusableTemplate } from '@vueuse/core';
|
||||||
|
|
||||||
|
const TemplateFoo = createReusableTemplate<{ msg: string }>();
|
||||||
|
</script>
|
@ -23,14 +23,15 @@ async function init() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
createApp(App)
|
const app = createApp(App)
|
||||||
.use(createHead())
|
.use(createHead())
|
||||||
.use(createPinia())
|
.use(createPinia())
|
||||||
// Register the plugin before the router
|
// Register the plugin before the router
|
||||||
.use(DataLoaderPlugin, { router })
|
.use(DataLoaderPlugin, { router })
|
||||||
// adding the router will trigger the initial navigation
|
// adding the router will trigger the initial navigation
|
||||||
.use(router)
|
.use(router);
|
||||||
.mount('#app');
|
app.config.globalProperties.$__DEV__ = $__DEV__;
|
||||||
|
app.mount('#app');
|
||||||
}
|
}
|
||||||
|
|
||||||
init();
|
init();
|
||||||
|
@ -1,6 +1,4 @@
|
|||||||
<script lang="tsx" setup>
|
<script lang="tsx" setup>
|
||||||
import type { FunctionalComponent } from 'vue';
|
|
||||||
|
|
||||||
useHead({
|
useHead({
|
||||||
// Titles
|
// Titles
|
||||||
title: 'Hello World',
|
title: 'Hello World',
|
||||||
@ -16,11 +14,14 @@ definePage({
|
|||||||
alias: '/',
|
alias: '/',
|
||||||
});
|
});
|
||||||
|
|
||||||
|
import type { FunctionalComponent } from 'vue';
|
||||||
|
|
||||||
// https://cn.vuejs.org/guide/extras/render-function#typing-functional-components
|
// https://cn.vuejs.org/guide/extras/render-function#typing-functional-components
|
||||||
const FComponent: FunctionalComponent<{ prop: string }> = (props, context) => (
|
const FComponent: FunctionalComponent<{ prop: string }> = (props, context) => (
|
||||||
<>
|
<>
|
||||||
<div>This is a functional component with prop: {props.prop}</div>
|
<div b="1 solid pink" text="pink">
|
||||||
<div>{props.prop}</div>
|
<span>This is a functional component with prop: {JSON.stringify(props)}</span>
|
||||||
|
</div>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
</script>
|
</script>
|
||||||
@ -35,4 +36,9 @@ const FComponent: FunctionalComponent<{ prop: string }> = (props, context) => (
|
|||||||
<li><router-link :to="{ name: 'MdPage' }">Markdown Page</router-link></li>
|
<li><router-link :to="{ name: 'MdPage' }">Markdown Page</router-link></li>
|
||||||
</ul>
|
</ul>
|
||||||
<FComponent prop="Hello World" />
|
<FComponent prop="Hello World" />
|
||||||
|
<div text-orange></div>
|
||||||
|
|
||||||
|
<div b="1px solid pink" mt-8>
|
||||||
|
<ReusableTemplate />
|
||||||
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
12
src/types/shims.d.ts
vendored
12
src/types/shims.d.ts
vendored
@ -1,12 +0,0 @@
|
|||||||
export {};
|
|
||||||
|
|
||||||
declare global {
|
|
||||||
const $__DEV__: boolean;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* declare module 'vue' {
|
|
||||||
export interface ComponentCustomProperties {
|
|
||||||
$__DEV__: boolean;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
*/
|
|
11
src/types/shims/global.ts
Normal file
11
src/types/shims/global.ts
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
declare global {
|
||||||
|
const $__DEV__: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
declare module 'vue' {
|
||||||
|
export interface ComponentCustomProperties {
|
||||||
|
$__DEV__: boolean;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export {};
|
@ -1,8 +1,5 @@
|
|||||||
import 'vue-router';
|
import 'vue-router';
|
||||||
|
|
||||||
// 为了确保这个文件被当作一个模块,添加至少一个 `export` 声明
|
|
||||||
export {};
|
|
||||||
|
|
||||||
// declare module 'vue-router' {
|
// declare module 'vue-router' {
|
||||||
// interface RouteMeta {
|
// interface RouteMeta {
|
||||||
// // fromList?: RouteLocationNormalized[]
|
// // fromList?: RouteLocationNormalized[]
|
||||||
@ -19,3 +16,5 @@ export {};
|
|||||||
// // stackIndex: number
|
// // stackIndex: number
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
export {};
|
15
src/types/shims/unocss.ts
Normal file
15
src/types/shims/unocss.ts
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
// https://unocss.dev/presets/attributify#vue-3
|
||||||
|
import type { BasicAttributes, PseudoPrefix } from '@unocss/preset-attributify';
|
||||||
|
|
||||||
|
// https://github.com/unocss/unocss/pull/4095
|
||||||
|
type BasicAttributesFix = BasicAttributes | 'b';
|
||||||
|
|
||||||
|
type AttributifyNames<Prefix extends string = ''> =
|
||||||
|
| `${Prefix}${BasicAttributesFix}`
|
||||||
|
| `${Prefix}${PseudoPrefix}:${BasicAttributes}`;
|
||||||
|
|
||||||
|
declare module '@vue/runtime-dom' {
|
||||||
|
interface HTMLAttributes extends Partial<Record<AttributifyNames, string | boolean>> {}
|
||||||
|
}
|
||||||
|
|
||||||
|
export {};
|
@ -10,15 +10,18 @@
|
|||||||
"src/**/*",
|
"src/**/*",
|
||||||
"src/**/*.vue"
|
"src/**/*.vue"
|
||||||
],
|
],
|
||||||
"exclude": ["src/**/__tests__/*"],
|
"exclude": [
|
||||||
|
"src/**/__tests__/*"
|
||||||
|
],
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"composite": true,
|
"composite": true,
|
||||||
// "skipLibCheck": false,
|
|
||||||
"moduleResolution": "Bundler",
|
"moduleResolution": "Bundler",
|
||||||
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo",
|
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo",
|
||||||
"baseUrl": ".",
|
"baseUrl": ".",
|
||||||
"paths": {
|
"paths": {
|
||||||
"@/*": ["./src/*"]
|
"@/*": [
|
||||||
|
"./src/*"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
108
vite.config.ts
108
vite.config.ts
@ -24,58 +24,7 @@ export default defineConfig(({ mode, command }) => {
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
base: env.VITE_BASE,
|
base: env.VITE_BASE,
|
||||||
plugins: [
|
plugins: Plugins(),
|
||||||
VueRouter({
|
|
||||||
// https://uvr.esm.is/guide/configuration.html
|
|
||||||
exclude: ['**/__*', '**/__*/**/*'],
|
|
||||||
getRouteName: (routeNode) => getPascalCaseRouteName(routeNode),
|
|
||||||
logs: false,
|
|
||||||
extensions: ['.vue', '.page.vue', '.md'],
|
|
||||||
}),
|
|
||||||
// other plugins
|
|
||||||
AutoImport({
|
|
||||||
resolvers: [
|
|
||||||
TDesignResolver({
|
|
||||||
library: 'mobile-vue',
|
|
||||||
esm: true,
|
|
||||||
}),
|
|
||||||
VantResolver({
|
|
||||||
importStyle: true,
|
|
||||||
}),
|
|
||||||
],
|
|
||||||
imports: ['pinia', 'vue', VueRouterAutoImports, unheadVueComposablesImports],
|
|
||||||
}),
|
|
||||||
Components({
|
|
||||||
// allow auto load markdown components under `./src/components/`
|
|
||||||
extensions: ['vue', 'md'],
|
|
||||||
// allow auto import and register components used in markdown
|
|
||||||
include: [/\.vue$/, /\.vue\?vue/, /\.md$/],
|
|
||||||
resolvers: [
|
|
||||||
TDesignResolver({
|
|
||||||
library: 'mobile-vue',
|
|
||||||
esm: true,
|
|
||||||
}),
|
|
||||||
VantResolver({
|
|
||||||
importStyle: true,
|
|
||||||
}),
|
|
||||||
],
|
|
||||||
}),
|
|
||||||
UnoCSS(),
|
|
||||||
Vue({
|
|
||||||
include: [/\.vue$/, /\.md$/], // <-- allows Vue to compile Markdown files
|
|
||||||
}),
|
|
||||||
vueJsx(),
|
|
||||||
Markdown({
|
|
||||||
headEnabled: true,
|
|
||||||
}),
|
|
||||||
vueDevTools(),
|
|
||||||
cdnImport({
|
|
||||||
// https://github.com/mmf-fe/vite-plugin-cdn-import/blob/HEAD/README.zh-CN.md
|
|
||||||
modules: ['vue'],
|
|
||||||
prodUrl: '//fastly.jsdelivr.net/npm/{name}@{version}/{path}',
|
|
||||||
enableInDevMode: true,
|
|
||||||
}),
|
|
||||||
],
|
|
||||||
define: {
|
define: {
|
||||||
$__DEV__: JSON.stringify(!isBuild),
|
$__DEV__: JSON.stringify(!isBuild),
|
||||||
},
|
},
|
||||||
@ -127,3 +76,58 @@ function isInNodeModules(id: string): boolean {
|
|||||||
}
|
}
|
||||||
/* const CSS_LANGS_RE = /\.(css|less|sass|scss|styl|stylus|pcss|postcss|sss)(?:$|\?)/;
|
/* const CSS_LANGS_RE = /\.(css|less|sass|scss|styl|stylus|pcss|postcss|sss)(?:$|\?)/;
|
||||||
const isCSSRequest = (request: string): boolean => CSS_LANGS_RE.test(request); */
|
const isCSSRequest = (request: string): boolean => CSS_LANGS_RE.test(request); */
|
||||||
|
|
||||||
|
function Plugins() {
|
||||||
|
return [
|
||||||
|
VueRouter({
|
||||||
|
// https://uvr.esm.is/guide/configuration.html
|
||||||
|
exclude: ['**/__*', '**/__*/**/*'],
|
||||||
|
getRouteName: (routeNode) => getPascalCaseRouteName(routeNode),
|
||||||
|
logs: false,
|
||||||
|
extensions: ['.vue', '.page.vue', '.md'],
|
||||||
|
}),
|
||||||
|
// other plugins
|
||||||
|
AutoImport({
|
||||||
|
resolvers: [
|
||||||
|
TDesignResolver({
|
||||||
|
library: 'mobile-vue',
|
||||||
|
esm: true,
|
||||||
|
}),
|
||||||
|
VantResolver({
|
||||||
|
importStyle: true,
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
imports: ['pinia', 'vue', VueRouterAutoImports, unheadVueComposablesImports],
|
||||||
|
}),
|
||||||
|
Components({
|
||||||
|
// allow auto load markdown components under `./src/components/`
|
||||||
|
extensions: ['vue', 'md'],
|
||||||
|
// allow auto import and register components used in markdown
|
||||||
|
include: [/\.vue$/, /\.vue\?vue/, /\.md$/],
|
||||||
|
resolvers: [
|
||||||
|
TDesignResolver({
|
||||||
|
library: 'mobile-vue',
|
||||||
|
esm: true,
|
||||||
|
}),
|
||||||
|
VantResolver({
|
||||||
|
importStyle: true,
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
}),
|
||||||
|
UnoCSS(),
|
||||||
|
Vue({
|
||||||
|
include: [/\.vue$/, /\.md$/], // <-- allows Vue to compile Markdown files
|
||||||
|
}),
|
||||||
|
vueJsx(),
|
||||||
|
Markdown({
|
||||||
|
headEnabled: true,
|
||||||
|
}),
|
||||||
|
vueDevTools(),
|
||||||
|
cdnImport({
|
||||||
|
// https://github.com/mmf-fe/vite-plugin-cdn-import/blob/HEAD/README.zh-CN.md
|
||||||
|
modules: ['vue'],
|
||||||
|
prodUrl: '//fastly.jsdelivr.net/npm/{name}@{version}/{path}',
|
||||||
|
enableInDevMode: true,
|
||||||
|
}),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user