Merge branch 'base' into i18n
This commit is contained in:
commit
c874024221
4
.npmrc
4
.npmrc
@ -1,5 +1,5 @@
|
|||||||
# registry = https://registry.npmjs.org
|
registry = https://registry.npmjs.org
|
||||||
registry = https://registry.npmmirror.com
|
# registry = https://registry.npmmirror.com
|
||||||
|
|
||||||
strict-peer-dependencies=false
|
strict-peer-dependencies=false
|
||||||
auto-install-peers=true
|
auto-install-peers=true
|
||||||
|
55
package.json
55
package.json
@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "unibest",
|
"name": "unibest",
|
||||||
"type": "commonjs",
|
"type": "commonjs",
|
||||||
"version": "2.8.1",
|
"version": "2.9.1",
|
||||||
"description": "unibest - 最好的 uniapp 开发模板",
|
"description": "unibest - 最好的 uniapp 开发模板",
|
||||||
"author": {
|
"author": {
|
||||||
"name": "feige996",
|
"name": "feige996",
|
||||||
@ -82,39 +82,39 @@
|
|||||||
"bin-wrapper": "npm:bin-wrapper-china"
|
"bin-wrapper": "npm:bin-wrapper-china"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@dcloudio/uni-app": "3.0.0-4060520250512001",
|
"@dcloudio/uni-app": "3.0.0-4060620250520001",
|
||||||
"@dcloudio/uni-app-harmony": "3.0.0-4060520250512001",
|
"@dcloudio/uni-app-harmony": "3.0.0-4060620250520001",
|
||||||
"@dcloudio/uni-app-plus": "3.0.0-4060520250512001",
|
"@dcloudio/uni-app-plus": "3.0.0-4060620250520001",
|
||||||
"@dcloudio/uni-components": "3.0.0-4060520250512001",
|
"@dcloudio/uni-components": "3.0.0-4060620250520001",
|
||||||
"@dcloudio/uni-h5": "3.0.0-4060520250512001",
|
"@dcloudio/uni-h5": "3.0.0-4060620250520001",
|
||||||
"@dcloudio/uni-mp-alipay": "3.0.0-4060520250512001",
|
"@dcloudio/uni-mp-alipay": "3.0.0-4060620250520001",
|
||||||
"@dcloudio/uni-mp-baidu": "3.0.0-4060520250512001",
|
"@dcloudio/uni-mp-baidu": "3.0.0-4060620250520001",
|
||||||
"@dcloudio/uni-mp-harmony": "3.0.0-4060520250512001",
|
"@dcloudio/uni-mp-harmony": "3.0.0-4060620250520001",
|
||||||
"@dcloudio/uni-mp-jd": "3.0.0-4060520250512001",
|
"@dcloudio/uni-mp-jd": "3.0.0-4060620250520001",
|
||||||
"@dcloudio/uni-mp-kuaishou": "3.0.0-4060520250512001",
|
"@dcloudio/uni-mp-kuaishou": "3.0.0-4060620250520001",
|
||||||
"@dcloudio/uni-mp-lark": "3.0.0-4060520250512001",
|
"@dcloudio/uni-mp-lark": "3.0.0-4060620250520001",
|
||||||
"@dcloudio/uni-mp-qq": "3.0.0-4060520250512001",
|
"@dcloudio/uni-mp-qq": "3.0.0-4060620250520001",
|
||||||
"@dcloudio/uni-mp-toutiao": "3.0.0-4060520250512001",
|
"@dcloudio/uni-mp-toutiao": "3.0.0-4060620250520001",
|
||||||
"@dcloudio/uni-mp-weixin": "3.0.0-4060520250512001",
|
"@dcloudio/uni-mp-weixin": "3.0.0-4060620250520001",
|
||||||
"@dcloudio/uni-mp-xhs": "3.0.0-4060520250512001",
|
"@dcloudio/uni-mp-xhs": "3.0.0-4060620250520001",
|
||||||
"@dcloudio/uni-quickapp-webview": "3.0.0-4060520250512001",
|
"@dcloudio/uni-quickapp-webview": "3.0.0-4060620250520001",
|
||||||
"@tanstack/vue-query": "^5.62.16",
|
"@tanstack/vue-query": "^5.62.16",
|
||||||
"abortcontroller-polyfill": "^1.7.8",
|
"abortcontroller-polyfill": "^1.7.8",
|
||||||
"dayjs": "1.11.10",
|
"dayjs": "1.11.10",
|
||||||
"pinia": "2.0.36",
|
"pinia": "2.0.36",
|
||||||
"pinia-plugin-persistedstate": "3.2.1",
|
"pinia-plugin-persistedstate": "3.2.1",
|
||||||
"qs": "6.5.3",
|
"qs": "6.5.3",
|
||||||
"vue": "3.4.21",
|
"vue": "^3.5.15",
|
||||||
"vue-i18n": "9.1.9",
|
"vue-i18n": "9.1.9",
|
||||||
"wot-design-uni": "^1.4.0",
|
"wot-design-uni": "^1.4.0",
|
||||||
"z-paging": "^2.8.4"
|
"z-paging": "^2.8.4"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@dcloudio/types": "^3.4.14",
|
"@dcloudio/types": "^3.4.8",
|
||||||
"@dcloudio/uni-automator": "3.0.0-4060520250512001",
|
"@dcloudio/uni-automator": "3.0.0-4060620250520001",
|
||||||
"@dcloudio/uni-cli-shared": "3.0.0-4060520250512001",
|
"@dcloudio/uni-cli-shared": "3.0.0-4060620250520001",
|
||||||
"@dcloudio/uni-stacktracey": "3.0.0-4060520250512001",
|
"@dcloudio/uni-stacktracey": "3.0.0-4060620250520001",
|
||||||
"@dcloudio/vite-plugin-uni": "3.0.0-4060520250512001",
|
"@dcloudio/vite-plugin-uni": "3.0.0-4060620250520001",
|
||||||
"@esbuild/darwin-arm64": "0.20.2",
|
"@esbuild/darwin-arm64": "0.20.2",
|
||||||
"@esbuild/darwin-x64": "0.20.2",
|
"@esbuild/darwin-x64": "0.20.2",
|
||||||
"@iconify-json/carbon": "^1.2.4",
|
"@iconify-json/carbon": "^1.2.4",
|
||||||
@ -122,15 +122,17 @@
|
|||||||
"@types/node": "^20.17.9",
|
"@types/node": "^20.17.9",
|
||||||
"@types/wechat-miniprogram": "^3.4.8",
|
"@types/wechat-miniprogram": "^3.4.8",
|
||||||
"@uni-helper/uni-types": "1.0.0-alpha.3",
|
"@uni-helper/uni-types": "1.0.0-alpha.3",
|
||||||
|
"@uni-helper/unocss-preset-uni": "^0.2.11",
|
||||||
|
"@uni-helper/vite-plugin-uni-components": "^0.2.0",
|
||||||
"@uni-helper/vite-plugin-uni-layouts": "^0.1.10",
|
"@uni-helper/vite-plugin-uni-layouts": "^0.1.10",
|
||||||
"@uni-helper/vite-plugin-uni-manifest": "^0.2.8",
|
"@uni-helper/vite-plugin-uni-manifest": "^0.2.8",
|
||||||
"@uni-helper/vite-plugin-uni-pages": "0.2.20",
|
"@uni-helper/vite-plugin-uni-pages": "0.2.20",
|
||||||
"@uni-helper/vite-plugin-uni-platform": "^0.0.4",
|
"@uni-helper/vite-plugin-uni-platform": "^0.0.4",
|
||||||
|
"@uni-ku/bundle-optimizer": "^1.3.3",
|
||||||
"@unocss/preset-legacy-compat": "^0.59.4",
|
"@unocss/preset-legacy-compat": "^0.59.4",
|
||||||
"@vue/runtime-core": "^3.5.13",
|
"@vue/runtime-core": "^3.4.21",
|
||||||
"@vue/tsconfig": "^0.1.3",
|
"@vue/tsconfig": "^0.1.3",
|
||||||
"autoprefixer": "^10.4.20",
|
"autoprefixer": "^10.4.20",
|
||||||
"husky": "^8.0.3",
|
|
||||||
"lint-staged": "^15.2.10",
|
"lint-staged": "^15.2.10",
|
||||||
"openapi-ts-request": "^1.1.2",
|
"openapi-ts-request": "^1.1.2",
|
||||||
"oxlint": "^0.1.0",
|
"oxlint": "^0.1.0",
|
||||||
@ -141,8 +143,7 @@
|
|||||||
"sass": "1.77.8",
|
"sass": "1.77.8",
|
||||||
"terser": "^5.36.0",
|
"terser": "^5.36.0",
|
||||||
"typescript": "^5.7.2",
|
"typescript": "^5.7.2",
|
||||||
"unocss": "0.58.9",
|
"unocss": "^66.0.0",
|
||||||
"unocss-applet": "^0.7.8",
|
|
||||||
"unplugin-auto-import": "^0.17.8",
|
"unplugin-auto-import": "^0.17.8",
|
||||||
"vite": "5.2.8",
|
"vite": "5.2.8",
|
||||||
"vite-plugin-restart": "^0.4.2",
|
"vite-plugin-restart": "^0.4.2",
|
||||||
|
@ -11,6 +11,7 @@ export default defineUniPages({
|
|||||||
easycom: {
|
easycom: {
|
||||||
autoscan: true,
|
autoscan: true,
|
||||||
custom: {
|
custom: {
|
||||||
|
'^fg-(.*)': '@/components/fg-$1/fg-$1.vue',
|
||||||
'^wd-(.*)': 'wot-design-uni/components/wd-$1/wd-$1.vue',
|
'^wd-(.*)': 'wot-design-uni/components/wd-$1/wd-$1.vue',
|
||||||
'^(?!z-paging-refresh|z-paging-load-more)z-paging(.*)':
|
'^(?!z-paging-refresh|z-paging-load-more)z-paging(.*)':
|
||||||
'z-paging/components/z-paging$1/z-paging$1.vue',
|
'z-paging/components/z-paging$1/z-paging$1.vue',
|
||||||
|
2282
pnpm-lock.yaml
generated
2282
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
48
src/components/fg-navbar/fg-navbar.vue
Normal file
48
src/components/fg-navbar/fg-navbar.vue
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
<script lang="ts" setup>
|
||||||
|
withDefaults(defineProps<{
|
||||||
|
leftText?: string;
|
||||||
|
rightText?: string;
|
||||||
|
leftArrow?: boolean;
|
||||||
|
bordered?: boolean;
|
||||||
|
fixed?: boolean;
|
||||||
|
placeholder?: boolean;
|
||||||
|
zIndex?: number;
|
||||||
|
safeAreaInsetTop?: boolean;
|
||||||
|
leftDisabled?: boolean;
|
||||||
|
rightDisabled?: boolean;
|
||||||
|
}>(), {
|
||||||
|
leftText: '返回',
|
||||||
|
rightText: '',
|
||||||
|
leftArrow: true,
|
||||||
|
bordered: true,
|
||||||
|
fixed: false,
|
||||||
|
placeholder: true,
|
||||||
|
zIndex: 1,
|
||||||
|
safeAreaInsetTop: true,
|
||||||
|
leftDisabled: false,
|
||||||
|
rightDisabled: false,
|
||||||
|
});
|
||||||
|
|
||||||
|
function handleClickLeft() {
|
||||||
|
uni.navigateBack({
|
||||||
|
fail() {
|
||||||
|
uni.reLaunch({
|
||||||
|
url: '/pages/index/index',
|
||||||
|
});
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<wd-navbar
|
||||||
|
:left-text="leftText" :right-text="rightText" :left-arrow="leftArrow"
|
||||||
|
:bordered="bordered" :fixed="fixed" :placeholder="placeholder" :z-index="zIndex"
|
||||||
|
:safe-area-inset-top="safeAreaInsetTop" :left-disabled="leftDisabled" :right-disabled="rightDisabled"
|
||||||
|
@click-left="handleClickLeft"
|
||||||
|
>
|
||||||
|
<template #title>
|
||||||
|
<slot />
|
||||||
|
</template>
|
||||||
|
</wd-navbar>
|
||||||
|
</template>
|
@ -1,6 +1,6 @@
|
|||||||
import '@/style/index.scss'
|
import '@/style/index.scss'
|
||||||
import { VueQueryPlugin } from '@tanstack/vue-query'
|
import { VueQueryPlugin } from '@tanstack/vue-query'
|
||||||
import 'virtual:uno.css'
|
import 'uno.css'
|
||||||
import { createSSRApp } from 'vue'
|
import { createSSRApp } from 'vue'
|
||||||
import App from './App.vue'
|
import App from './App.vue'
|
||||||
import { prototypeInterceptor, requestInterceptor, routeInterceptor } from './interceptors'
|
import { prototypeInterceptor, requestInterceptor, routeInterceptor } from './interceptors'
|
||||||
|
@ -9,6 +9,7 @@
|
|||||||
"easycom": {
|
"easycom": {
|
||||||
"autoscan": true,
|
"autoscan": true,
|
||||||
"custom": {
|
"custom": {
|
||||||
|
"^fg-(.*)": "@/components/fg-$1/fg-$1.vue",
|
||||||
"^wd-(.*)": "wot-design-uni/components/wd-$1/wd-$1.vue",
|
"^wd-(.*)": "wot-design-uni/components/wd-$1/wd-$1.vue",
|
||||||
"^(?!z-paging-refresh|z-paging-load-more)z-paging(.*)": "z-paging/components/z-paging$1/z-paging$1.vue"
|
"^(?!z-paging-refresh|z-paging-load-more)z-paging(.*)": "z-paging/components/z-paging$1/z-paging$1.vue"
|
||||||
}
|
}
|
||||||
@ -50,7 +51,8 @@
|
|||||||
"path": "pages/about/about",
|
"path": "pages/about/about",
|
||||||
"type": "page",
|
"type": "page",
|
||||||
"style": {
|
"style": {
|
||||||
"navigationBarTitleText": "关于"
|
"navigationBarTitleText": "关于",
|
||||||
|
"navigationStyle": "custom"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -2,18 +2,25 @@
|
|||||||
{
|
{
|
||||||
style: {
|
style: {
|
||||||
navigationBarTitleText: '关于',
|
navigationBarTitleText: '关于',
|
||||||
|
navigationStyle: 'custom', // 开启自定义导航栏
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
</route>
|
</route>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<view
|
<view>
|
||||||
class="bg-white overflow-hidden pt-2 px-4"
|
<fg-navbar>关于</fg-navbar>
|
||||||
:style="{ marginTop: safeAreaInsets?.top + 'px' }"
|
<view
|
||||||
>
|
class="bg-white overflow-hidden pt-2 px-4"
|
||||||
<view class="text-center text-3xl mt-8">
|
:style="{ marginTop: safeAreaInsets?.top + 'px' }"
|
||||||
鸽友们好,我是
|
>
|
||||||
<text class="text-red-500">菲鸽</text>
|
<view class="text-center text-3xl mt-8">
|
||||||
|
鸽友们好,我是
|
||||||
|
<text class="text-red-500">菲鸽</text>
|
||||||
|
</view>
|
||||||
|
<view class="test-css">测试 scss 样式</view>
|
||||||
|
<RequestComp />
|
||||||
|
<UploadComp />
|
||||||
</view>
|
</view>
|
||||||
<view class="text-center mt-8 text-#fff">
|
<view class="text-center mt-8 text-#fff">
|
||||||
<wd-button type="success" @click="gotoPage('i18n')">进入多语言页面</wd-button>
|
<wd-button type="success" @click="gotoPage('i18n')">进入多语言页面</wd-button>
|
||||||
|
8
src/types/async-component.d.ts
vendored
Normal file
8
src/types/async-component.d.ts
vendored
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
/* eslint-disable */
|
||||||
|
/* prettier-ignore */
|
||||||
|
// @ts-nocheck
|
||||||
|
// Generated by @uni-ku/bundle-optimizer
|
||||||
|
declare module '*?async' {
|
||||||
|
const component: any
|
||||||
|
export = component
|
||||||
|
}
|
13
src/types/async-import.d.ts
vendored
Normal file
13
src/types/async-import.d.ts
vendored
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
/* eslint-disable */
|
||||||
|
/* prettier-ignore */
|
||||||
|
// @ts-nocheck
|
||||||
|
// Generated by @uni-ku/bundle-optimizer
|
||||||
|
export {}
|
||||||
|
|
||||||
|
interface ModuleMap {
|
||||||
|
[path: string]: any
|
||||||
|
}
|
||||||
|
|
||||||
|
declare global {
|
||||||
|
function AsyncImport<T extends keyof ModuleMap>(arg: T): Promise<ModuleMap[T]>
|
||||||
|
}
|
12
src/types/components.d.ts
vendored
Normal file
12
src/types/components.d.ts
vendored
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
/* eslint-disable */
|
||||||
|
/* prettier-ignore */
|
||||||
|
// @ts-nocheck
|
||||||
|
// Generated by vite-plugin-uni-components
|
||||||
|
// Read more: https://github.com/vuejs/core/pull/3399
|
||||||
|
export {}
|
||||||
|
|
||||||
|
declare module 'vue' {
|
||||||
|
export interface GlobalComponents {
|
||||||
|
FgNavbar: typeof import('./../components/fg-navbar/fg-navbar.vue')['default']
|
||||||
|
}
|
||||||
|
}
|
@ -1,37 +1,9 @@
|
|||||||
// uno.config.ts
|
import { presetUni } from '@uni-helper/unocss-preset-uni'
|
||||||
import {
|
import { defineConfig, presetIcons, transformerDirectives, transformerVariantGroup } from 'unocss'
|
||||||
type Preset,
|
|
||||||
defineConfig,
|
|
||||||
presetUno,
|
|
||||||
presetAttributify,
|
|
||||||
presetIcons,
|
|
||||||
transformerDirectives,
|
|
||||||
transformerVariantGroup,
|
|
||||||
} from 'unocss'
|
|
||||||
|
|
||||||
import { presetApplet, presetRemRpx, transformerAttributify } from 'unocss-applet'
|
|
||||||
|
|
||||||
// @see https://unocss.dev/presets/legacy-compat
|
|
||||||
// import { presetLegacyCompat } from '@unocss/preset-legacy-compat'
|
|
||||||
|
|
||||||
const isMp = process.env?.UNI_PLATFORM?.startsWith('mp') ?? false
|
|
||||||
|
|
||||||
const presets: Preset[] = []
|
|
||||||
if (isMp) {
|
|
||||||
// 使用小程序预设
|
|
||||||
presets.push(presetApplet(), presetRemRpx())
|
|
||||||
} else {
|
|
||||||
presets.push(
|
|
||||||
// 非小程序用官方预设
|
|
||||||
presetUno(),
|
|
||||||
// 支持css class属性化
|
|
||||||
presetAttributify(),
|
|
||||||
)
|
|
||||||
}
|
|
||||||
export default defineConfig({
|
export default defineConfig({
|
||||||
presets: [
|
presets: [
|
||||||
...presets,
|
presetUni(),
|
||||||
// 支持图标,需要搭配图标库,eg: @iconify-json/carbon, 使用 `<button class="i-carbon-sun dark:i-carbon-moon" />`
|
|
||||||
presetIcons({
|
presetIcons({
|
||||||
scale: 1.2,
|
scale: 1.2,
|
||||||
warn: true,
|
warn: true,
|
||||||
@ -40,31 +12,18 @@ export default defineConfig({
|
|||||||
'vertical-align': 'middle',
|
'vertical-align': 'middle',
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
// 将颜色函数 (rgb()和hsl()) 从空格分隔转换为逗号分隔,更好的兼容性app端,example:
|
|
||||||
// `rgb(255 0 0)` -> `rgb(255, 0, 0)`
|
|
||||||
// `rgba(255 0 0 / 0.5)` -> `rgba(255, 0, 0, 0.5)`
|
|
||||||
// 与群友的正常写法冲突,先去掉!(2024-05-25)
|
|
||||||
// presetLegacyCompat({
|
|
||||||
// commaStyleColorFunction: true,
|
|
||||||
// }) as Preset,
|
|
||||||
],
|
],
|
||||||
/**
|
|
||||||
* 自定义快捷语句
|
|
||||||
* @see https://github.com/unocss/unocss#shortcuts
|
|
||||||
*/
|
|
||||||
shortcuts: [['center', 'flex justify-center items-center']],
|
|
||||||
transformers: [
|
transformers: [
|
||||||
// 启用 @apply 功能
|
// 启用指令功能:主要用于支持 @apply、@screen 和 theme() 等 CSS 指令
|
||||||
transformerDirectives(),
|
transformerDirectives(),
|
||||||
// 启用 () 分组功能
|
// 启用 () 分组功能
|
||||||
// 支持css class组合,eg: `<div class="hover:(bg-gray-400 font-medium) font-(light mono)">测试 unocss</div>`
|
// 支持css class组合,eg: `<div class="hover:(bg-gray-400 font-medium) font-(light mono)">测试 unocss</div>`
|
||||||
transformerVariantGroup(),
|
transformerVariantGroup(),
|
||||||
// Don't change the following order
|
],
|
||||||
transformerAttributify({
|
shortcuts: [
|
||||||
// 解决与第三方框架样式冲突问题
|
{
|
||||||
prefixedOnly: true,
|
center: 'flex justify-center items-center',
|
||||||
prefix: 'fg',
|
},
|
||||||
}),
|
|
||||||
],
|
],
|
||||||
rules: [
|
rules: [
|
||||||
[
|
[
|
||||||
@ -77,13 +36,15 @@ export default defineConfig({
|
|||||||
['pt-safe', { 'padding-top': 'env(safe-area-inset-top)' }],
|
['pt-safe', { 'padding-top': 'env(safe-area-inset-top)' }],
|
||||||
['pb-safe', { 'padding-bottom': 'env(safe-area-inset-bottom)' }],
|
['pb-safe', { 'padding-bottom': 'env(safe-area-inset-bottom)' }],
|
||||||
],
|
],
|
||||||
|
theme: {
|
||||||
|
colors: {
|
||||||
|
/** 主题色,用法如: text-primary */
|
||||||
|
primary: 'var(--wot-color-theme,#0957DE)',
|
||||||
|
},
|
||||||
|
fontSize: {
|
||||||
|
/** 提供更小号的字体,用法如:text-2xs */
|
||||||
|
'2xs': ['20rpx', '28rpx'],
|
||||||
|
'3xs': ['18rpx', '26rpx'],
|
||||||
|
},
|
||||||
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
/**
|
|
||||||
* 最终这一套组合下来会得到:
|
|
||||||
* mp 里面:mt-4 => margin-top: 32rpx == 16px
|
|
||||||
* h5 里面:mt-4 => margin-top: 1rem == 16px
|
|
||||||
*
|
|
||||||
* 如果是传统方式写样式,则推荐设计稿设置为 750,这样设计稿1px,代码写1rpx。
|
|
||||||
* rpx是响应式的,可以让不同设备的屏幕显示效果保持一致。
|
|
||||||
*/
|
|
||||||
|
@ -11,15 +11,21 @@ import UniLayouts from '@uni-helper/vite-plugin-uni-layouts'
|
|||||||
import UniPlatform from '@uni-helper/vite-plugin-uni-platform'
|
import UniPlatform from '@uni-helper/vite-plugin-uni-platform'
|
||||||
// @see https://github.com/uni-helper/vite-plugin-uni-manifest
|
// @see https://github.com/uni-helper/vite-plugin-uni-manifest
|
||||||
import UniManifest from '@uni-helper/vite-plugin-uni-manifest'
|
import UniManifest from '@uni-helper/vite-plugin-uni-manifest'
|
||||||
// @see https://unocss.dev/
|
/**
|
||||||
|
* 分包优化、模块异步跨包调用、组件异步跨包引用
|
||||||
|
* @see https://github.com/uni-ku/bundle-optimizer
|
||||||
|
*/
|
||||||
|
import Optimization from '@uni-ku/bundle-optimizer'
|
||||||
import { visualizer } from 'rollup-plugin-visualizer'
|
import { visualizer } from 'rollup-plugin-visualizer'
|
||||||
import UnoCSS from 'unocss/vite'
|
|
||||||
import AutoImport from 'unplugin-auto-import/vite'
|
import AutoImport from 'unplugin-auto-import/vite'
|
||||||
import ViteRestart from 'vite-plugin-restart'
|
import ViteRestart from 'vite-plugin-restart'
|
||||||
import { copyNativeRes } from './vite-plugins/copyNativeRes'
|
import { copyNativeRes } from './vite-plugins/copyNativeRes'
|
||||||
|
import Components from '@uni-helper/vite-plugin-uni-components'
|
||||||
|
|
||||||
// https://vitejs.dev/config/
|
// https://vitejs.dev/config/
|
||||||
export default ({ command, mode }) => {
|
export default async ({ command, mode }) => {
|
||||||
|
// @see https://unocss.dev/
|
||||||
|
const UnoCSS = (await import('unocss/vite')).default
|
||||||
// console.log(mode === process.env.NODE_ENV) // true
|
// console.log(mode === process.env.NODE_ENV) // true
|
||||||
|
|
||||||
// mode: 区分生产环境还是开发环境
|
// mode: 区分生产环境还是开发环境
|
||||||
@ -62,7 +68,6 @@ export default ({ command, mode }) => {
|
|||||||
UniPlatform(),
|
UniPlatform(),
|
||||||
UniManifest(),
|
UniManifest(),
|
||||||
// UniXXX 需要在 Uni 之前引入
|
// UniXXX 需要在 Uni 之前引入
|
||||||
Uni(),
|
|
||||||
{
|
{
|
||||||
// 临时解决 dcloudio 官方的 @dcloudio/uni-mp-compiler 出现的编译 BUG
|
// 临时解决 dcloudio 官方的 @dcloudio/uni-mp-compiler 出现的编译 BUG
|
||||||
// 参考 github issue: https://github.com/dcloudio/uni-app/issues/4952
|
// 参考 github issue: https://github.com/dcloudio/uni-app/issues/4952
|
||||||
@ -82,6 +87,18 @@ export default ({ command, mode }) => {
|
|||||||
dirs: ['src/hooks'], // 自动导入 hooks
|
dirs: ['src/hooks'], // 自动导入 hooks
|
||||||
vueTemplate: true, // default false
|
vueTemplate: true, // default false
|
||||||
}),
|
}),
|
||||||
|
// Optimization 插件需要 page.json 文件,故应在 UniPages 插件之后执行
|
||||||
|
Optimization({
|
||||||
|
enable: {
|
||||||
|
optimization: true,
|
||||||
|
'async-import': true,
|
||||||
|
'async-component': true,
|
||||||
|
},
|
||||||
|
dts: {
|
||||||
|
base: 'src/types',
|
||||||
|
},
|
||||||
|
logger: false,
|
||||||
|
}),
|
||||||
|
|
||||||
ViteRestart({
|
ViteRestart({
|
||||||
// 通过这个插件,在修改vite.config.js文件则不需要重新运行也生效配置
|
// 通过这个插件,在修改vite.config.js文件则不需要重新运行也生效配置
|
||||||
@ -105,6 +122,13 @@ export default ({ command, mode }) => {
|
|||||||
}),
|
}),
|
||||||
// 只有在 app 平台时才启用 copyNativeRes 插件
|
// 只有在 app 平台时才启用 copyNativeRes 插件
|
||||||
UNI_PLATFORM === 'app' && copyNativeRes(),
|
UNI_PLATFORM === 'app' && copyNativeRes(),
|
||||||
|
Components({
|
||||||
|
extensions: ['vue'],
|
||||||
|
deep: true, // 是否递归扫描子目录,
|
||||||
|
directoryAsNamespace: false, // 是否把目录名作为命名空间前缀,true 时组件名为 目录名+组件名,
|
||||||
|
dts: 'src/types/components.d.ts', // 自动生成的组件类型声明文件路径(用于 TypeScript 支持)
|
||||||
|
}),
|
||||||
|
Uni(),
|
||||||
],
|
],
|
||||||
define: {
|
define: {
|
||||||
__UNI_PLATFORM__: JSON.stringify(UNI_PLATFORM),
|
__UNI_PLATFORM__: JSON.stringify(UNI_PLATFORM),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user