diff --git a/.eslintrc.cjs b/.eslintrc.cjs
index aff8be4..dc507ec 100644
--- a/.eslintrc.cjs
+++ b/.eslintrc.cjs
@@ -2,7 +2,7 @@ module.exports = {
env: {
browser: true,
es2021: true,
- node: true,
+ node: true
},
extends: [
'eslint:recommended',
@@ -15,23 +15,23 @@ module.exports = {
// 1. 接入 prettier 的规则
'prettier',
'plugin:prettier/recommended',
- './.eslintrc-auto-import.json',
+ './.eslintrc-auto-import.json'
],
overrides: [
{
env: {
- node: true,
+ node: true
},
files: ['.eslintrc.{js,cjs}'],
parserOptions: {
- sourceType: 'script',
- },
- },
+ sourceType: 'script'
+ }
+ }
],
parserOptions: {
ecmaVersion: 'latest',
parser: '@typescript-eslint/parser',
- sourceType: 'module',
+ sourceType: 'module'
},
plugins: [
'@typescript-eslint',
@@ -39,7 +39,7 @@ module.exports = {
// 2. 加入 prettier 的 eslint 插件
'prettier',
// eslint-import-resolver-typescript 插件,@see https://www.npmjs.com/package/eslint-import-resolver-typescript
- 'import',
+ 'import'
],
rules: {
// 3. 注意要加上这一句,开启 prettier 自动修复的功能
@@ -50,7 +50,7 @@ module.exports = {
'import/extensions': [
'error',
'ignorePackages',
- { js: 'never', jsx: 'never', ts: 'never', tsx: 'never' },
+ { js: 'never', jsx: 'never', ts: 'never', tsx: 'never' }
],
// 只允许1个默认导出,关闭,否则不能随意export xxx
'import/prefer-default-export': ['off'],
@@ -71,16 +71,16 @@ module.exports = {
'@typescript-eslint/no-unused-vars': 'off',
// 避免 `eslint` 对于 `typescript` 函数重载的误报
'no-redeclare': 'off',
- '@typescript-eslint/no-redeclare': 'error',
+ '@typescript-eslint/no-redeclare': 'error'
},
// eslint-import-resolver-typescript 插件,@see https://www.npmjs.com/package/eslint-import-resolver-typescript
settings: {
'import/parsers': {
- '@typescript-eslint/parser': ['.ts', '.tsx'],
+ '@typescript-eslint/parser': ['.ts', '.tsx']
},
'import/resolver': {
- typescript: {},
- },
+ typescript: {}
+ }
},
globals: {
$t: true,
@@ -92,6 +92,6 @@ module.exports = {
UniHelper: true,
Page: true,
App: true,
- NodeJS: true,
- },
+ NodeJS: true
+ }
}
diff --git a/.prettierrc.cjs b/.prettierrc.cjs
index 3986355..1a0849d 100644
--- a/.prettierrc.cjs
+++ b/.prettierrc.cjs
@@ -1,19 +1,30 @@
-// @see https://prettier.io/docs/en/options
module.exports = {
singleQuote: true,
printWidth: 100,
tabWidth: 2,
useTabs: false,
semi: false,
- trailingComma: 'all',
+ trailingComma: 'none',
endOfLine: 'auto',
+ quoteProps: 'as-needed',
+ jsxSingleQuote: false,
+ bracketSpacing: true,
+ jsxBracketSameLine: false,
+ bracketSameLine: false,
+ arrowParens: 'avoid',
+ embeddedLanguageFormatting: 'auto',
+ vueIndentScriptAndStyle: true,
+ singleAttributePerLine: false,
+ requirePragma: false,
+ insertPragma: false,
+ proseWrap: 'preserve',
htmlWhitespaceSensitivity: 'ignore',
overrides: [
{
files: '*.json',
options: {
- trailingComma: 'none',
- },
- },
- ],
+ trailingComma: 'none'
+ }
+ }
+ ]
}
diff --git a/.stylelintrc.cjs b/.stylelintrc.cjs
index 574beef..6d20db6 100644
--- a/.stylelintrc.cjs
+++ b/.stylelintrc.cjs
@@ -9,19 +9,19 @@ module.exports = {
'stylelint-config-recommended-scss',
'stylelint-config-recommended-vue/scss',
'stylelint-config-html/vue',
- 'stylelint-config-recess-order',
+ 'stylelint-config-recess-order'
],
plugins: ['stylelint-prettier'],
overrides: [
// 扫描 .vue/html 文件中的
diff --git a/src/hooks/useRequest.ts b/src/hooks/useRequest.ts
index 9a0c8e5..2f28f60 100644
--- a/src/hooks/useRequest.ts
+++ b/src/hooks/useRequest.ts
@@ -17,7 +17,7 @@ type IUseRequestOptions = {
*/
export default function useRequest(
func: () => Promise>,
- options: IUseRequestOptions = { immediate: false },
+ options: IUseRequestOptions = { immediate: false }
) {
const loading = ref(false)
const error = ref(false)
@@ -25,12 +25,12 @@ export default function useRequest(
const run = async () => {
loading.value = true
return func()
- .then((res) => {
+ .then(res => {
data.value = res.data as UnwrapRef
error.value = false
return data.value
})
- .catch((err) => {
+ .catch(err => {
error.value = err
throw err
})
diff --git a/src/hooks/useUpload.ts b/src/hooks/useUpload.ts
index adc083d..6a2277e 100644
--- a/src/hooks/useUpload.ts
+++ b/src/hooks/useUpload.ts
@@ -19,29 +19,29 @@ export default function useUpload(formData: Record = {}
uni.chooseMedia({
count: 1,
mediaType: ['image'],
- success: (res) => {
+ success: res => {
loading.value = true
const tempFilePath = res.tempFiles[0].tempFilePath
uploadFile({ tempFilePath, formData, data, error, loading })
},
- fail: (err) => {
+ fail: err => {
console.error('uni.chooseMedia err->', err)
error.value = true
- },
+ }
})
// #endif
// #ifndef MP-WEIXIN
uni.chooseImage({
count: 1,
- success: (res) => {
+ success: res => {
loading.value = true
const tempFilePath = res.tempFilePaths[0]
uploadFile({ tempFilePath, formData, data, error, loading })
},
- fail: (err) => {
+ fail: err => {
console.error('uni.chooseImage err->', err)
error.value = true
- },
+ }
})
// #endif
}
@@ -55,15 +55,15 @@ function uploadFile({ tempFilePath, formData, data, error, loading }) {
filePath: tempFilePath,
name: 'file',
formData,
- success: (uploadFileRes) => {
+ success: uploadFileRes => {
data.value = uploadFileRes.data as T
},
- fail: (err) => {
+ fail: err => {
console.error('uni.uploadFile err->', err)
error.value = true
},
complete: () => {
loading.value = false
- },
+ }
})
}
diff --git a/src/interceptors/prototype.ts b/src/interceptors/prototype.ts
index 4e19e02..dd9ac2a 100644
--- a/src/interceptors/prototype.ts
+++ b/src/interceptors/prototype.ts
@@ -9,5 +9,5 @@ export const prototypeInterceptor = {
return this[index]
}
}
- },
+ }
}
diff --git a/src/interceptors/request.ts b/src/interceptors/request.ts
index 1f84b31..d24db1d 100644
--- a/src/interceptors/request.ts
+++ b/src/interceptors/request.ts
@@ -47,7 +47,7 @@ const httpInterceptor = {
// 2. (可选)添加小程序端请求头标识
options.header = {
platform, // 可选,与 uniapp 定义的平台一致,告诉后台来源
- ...options.header,
+ ...options.header
}
// 3. 添加 token 请求头标识
const userStore = useUserStore()
@@ -55,7 +55,7 @@ const httpInterceptor = {
if (token) {
options.header.Authorization = `Bearer ${token}`
}
- },
+ }
}
export const requestInterceptor = {
@@ -64,5 +64,5 @@ export const requestInterceptor = {
uni.addInterceptor('request', httpInterceptor)
// 拦截 uploadFile 文件上传
uni.addInterceptor('uploadFile', httpInterceptor)
- },
+ }
}
diff --git a/src/interceptors/route.ts b/src/interceptors/route.ts
index fb8ad33..4fae647 100644
--- a/src/interceptors/route.ts
+++ b/src/interceptors/route.ts
@@ -1,5 +1,4 @@
/**
- * by 菲鸽 on 2024-03-06
* 路由拦截,通常也是登录拦截
* 可以设置路由白名单,或者黑名单,看业务需要选哪一个
* 我这里应为大部分都可以随便进入,所以使用黑名单
@@ -41,7 +40,7 @@ const navigateToInterceptor = {
const redirectRoute = `${loginRoute}?redirect=${encodeURIComponent(url)}`
uni.navigateTo({ url: redirectRoute })
return false
- },
+ }
}
export const routeInterceptor = {
@@ -49,5 +48,5 @@ export const routeInterceptor = {
uni.addInterceptor('navigateTo', navigateToInterceptor)
uni.addInterceptor('reLaunch', navigateToInterceptor)
uni.addInterceptor('redirectTo', navigateToInterceptor)
- },
+ }
}
diff --git a/src/layouts/default.vue b/src/layouts/default.vue
index 768d875..fabacde 100644
--- a/src/layouts/default.vue
+++ b/src/layouts/default.vue
@@ -7,11 +7,11 @@
diff --git a/src/layouts/demo.vue b/src/layouts/demo.vue
index 768d875..fabacde 100644
--- a/src/layouts/demo.vue
+++ b/src/layouts/demo.vue
@@ -7,11 +7,11 @@
diff --git a/src/main.ts b/src/main.ts
index 8e4466e..f538f7e 100644
--- a/src/main.ts
+++ b/src/main.ts
@@ -12,6 +12,6 @@ export function createApp() {
app.use(requestInterceptor)
app.use(prototypeInterceptor)
return {
- app,
+ app
}
}
diff --git a/src/manifest.json b/src/manifest.json
index 80400f8..ac9b61f 100644
--- a/src/manifest.json
+++ b/src/manifest.json
@@ -35,7 +35,7 @@
"",
""
],
- "minSdkVersion": 30,
+ "minSdkVersion": 29,
"targetSdkVersion": 30,
"abiFilters": [
"armeabi-v7a",
@@ -108,4 +108,4 @@
"base": "/unibest/"
}
}
-}
\ No newline at end of file
+}
diff --git a/src/pages-sub/demo/index.vue b/src/pages-sub/demo/index.vue
deleted file mode 100644
index 6126ddc..0000000
--- a/src/pages-sub/demo/index.vue
+++ /dev/null
@@ -1,20 +0,0 @@
-
-{
- style: { navigationBarTitleText: '分包页面 标题' },
-}
-
-
-
-
- http://localhost:9000/#/pages-sub/demo/index
- 分包页面demo
-
-
-
-
-
-
diff --git a/src/pages.json b/src/pages.json
index 075e6aa..0c1bb86 100644
--- a/src/pages.json
+++ b/src/pages.json
@@ -14,26 +14,38 @@
}
},
"tabBar": {
- "color": "#999999",
- "selectedColor": "#018d71",
- "backgroundColor": "#F8F8F8",
+ "color": "#0d0f10",
+ "selectedColor": "#255cf7",
+ "backgroundColor": "#FFFFFF",
"borderStyle": "black",
"height": "50px",
"fontSize": "10px",
"iconWidth": "24px",
- "spacing": "3px",
+ "spacing": "5px",
"list": [
{
"iconPath": "static/tabbar/home.png",
"selectedIconPath": "static/tabbar/homeHL.png",
- "pagePath": "pages/index/index",
+ "pagePath": "pages/home/home",
"text": "首页"
},
+ {
+ "iconPath": "static/tabbar/home.png",
+ "selectedIconPath": "static/tabbar/homeHL.png",
+ "pagePath": "pages/workbench/workbench",
+ "text": "工作台"
+ },
+ {
+ "iconPath": "static/tabbar/home.png",
+ "selectedIconPath": "static/tabbar/homeHL.png",
+ "pagePath": "pages/notification/notification",
+ "text": "消息"
+ },
{
"iconPath": "static/tabbar/example.png",
"selectedIconPath": "static/tabbar/exampleHL.png",
- "pagePath": "pages/about/about",
- "text": "关于"
+ "pagePath": "pages/mine/mine",
+ "text": "我的"
}
]
},
@@ -55,4 +67,4 @@
}
],
"subPackages": []
-}
\ No newline at end of file
+}
diff --git a/src/pages/about/about.vue b/src/pages/about/about.vue
index 2ba2e3c..4276540 100644
--- a/src/pages/about/about.vue
+++ b/src/pages/about/about.vue
@@ -1,8 +1,8 @@
{
style: {
- navigationBarTitleText: '关于',
- },
+ navigationBarTitleText: '关于'
+ }
}
@@ -21,16 +21,16 @@
diff --git a/src/pages/about/components/request.vue b/src/pages/about/components/request.vue
index 89a656d..3ccb18f 100644
--- a/src/pages/about/components/request.vue
+++ b/src/pages/about/components/request.vue
@@ -2,8 +2,8 @@
{
layout: 'demo',
style: {
- navigationBarTitleText: '请求',
- },
+ navigationBarTitleText: '请求'
+ }
}
@@ -36,21 +36,21 @@
diff --git a/src/pages/about/components/upload.vue b/src/pages/about/components/upload.vue
index 07f81f5..2b2ee83 100644
--- a/src/pages/about/components/upload.vue
+++ b/src/pages/about/components/upload.vue
@@ -2,8 +2,8 @@
{
layout: 'default',
style: {
- navigationBarTitleText: '上传-状态一体化',
- },
+ navigationBarTitleText: '上传-状态一体化'
+ }
}
@@ -22,9 +22,9 @@
diff --git a/src/pages/index/index.vue b/src/pages/index/index.vue
index 84d3606..8fb2be9 100644
--- a/src/pages/index/index.vue
+++ b/src/pages/index/index.vue
@@ -3,8 +3,8 @@
{
style: {
navigationStyle: 'custom',
- navigationBarTitleText: '首页',
- },
+ navigationBarTitleText: '首页'
+ }
}
@@ -31,26 +31,26 @@
diff --git a/src/store/index.ts b/src/store/index.ts
index 74b1b2f..964ce63 100644
--- a/src/store/index.ts
+++ b/src/store/index.ts
@@ -6,9 +6,9 @@ store.use(
createPersistedState({
storage: {
getItem: uni.getStorageSync,
- setItem: uni.setStorageSync,
- },
- }),
+ setItem: uni.setStorageSync
+ }
+ })
)
export default store
diff --git a/src/store/user.ts b/src/store/user.ts
index 82bd873..4921ba9 100644
--- a/src/store/user.ts
+++ b/src/store/user.ts
@@ -26,10 +26,10 @@ export const useUserStore = defineStore(
setUserInfo,
clearUserInfo,
isLogined,
- reset,
+ reset
}
},
{
- persist: true,
- },
+ persist: true
+ }
)
diff --git a/src/types/uni-pages.d.ts b/src/types/uni-pages.d.ts
index 1644db7..b87aa55 100644
--- a/src/types/uni-pages.d.ts
+++ b/src/types/uni-pages.d.ts
@@ -10,7 +10,7 @@ interface NavigateToOptions {
interface RedirectToOptions extends NavigateToOptions {}
interface SwitchTabOptions {
- url: "/pages/index/index" | "/pages/about/about"
+ url: "/pages/home/home" | "/pages/workbench/workbench" | "/pages/notification/notification" | "/pages/mine/mine"
}
type ReLaunchOptions = NavigateToOptions | SwitchTabOptions;
diff --git a/src/typings.ts b/src/typings.ts
index 06354be..d564304 100644
--- a/src/typings.ts
+++ b/src/typings.ts
@@ -25,5 +25,5 @@ type IUserInfo = {
enum TestEnum {
A = 'a',
- B = 'b',
+ B = 'b'
}
diff --git a/src/utils/http.ts b/src/utils/http.ts
index 4e3f38c..dd422eb 100644
--- a/src/utils/http.ts
+++ b/src/utils/http.ts
@@ -25,7 +25,7 @@ export const http = (options: CustomRequestOptions) => {
!options.hideErrorToast &&
uni.showToast({
icon: 'none',
- title: (res.data as IResData).msg || '请求错误',
+ title: (res.data as IResData).msg || '请求错误'
})
reject(res)
}
@@ -34,10 +34,10 @@ export const http = (options: CustomRequestOptions) => {
fail(err) {
uni.showToast({
icon: 'none',
- title: '网络错误,换个网络试试',
+ title: '网络错误,换个网络试试'
})
reject(err)
- },
+ }
})
})
}
@@ -52,7 +52,7 @@ export const httpGet = (url: string, query?: Record) => {
return http({
url,
query,
- method: 'GET',
+ method: 'GET'
})
}
@@ -66,13 +66,13 @@ export const httpGet = (url: string, query?: Record) => {
export const httpPost = (
url: string,
data?: Record,
- query?: Record,
+ query?: Record
) => {
return http({
url,
query,
data,
- method: 'POST',
+ method: 'POST'
})
}
diff --git a/src/utils/index.ts b/src/utils/index.ts
index be21dd6..591dbe8 100644
--- a/src/utils/index.ts
+++ b/src/utils/index.ts
@@ -20,7 +20,7 @@ export const getIsTabbar = () => {
}
const lastPage = getLastPage()
const currPath = lastPage.route
- return !!tabBar.list.find((e) => e.pagePath === currPath)
+ return !!tabBar.list.find(e => e.pagePath === currPath)
}
/**
@@ -61,11 +61,11 @@ export const getUrlObj = (url: string) => {
if (!queryStr) {
return {
path,
- query: {},
+ query: {}
}
}
const query: Record = {}
- queryStr.split('&').forEach((item) => {
+ queryStr.split('&').forEach(item => {
const [key, value] = item.split('=')
// console.log(key, value)
query[key] = ensureDecodeURIComponent(value) // 这里需要统一 decodeURIComponent 一下,可以兼容h5和微信y
@@ -81,24 +81,24 @@ export const getAllPages = (key = 'needLogin') => {
// 这里处理主包
const mainPages = [
...pages
- .filter((page) => !key || page[key])
- .map((page) => ({
+ .filter(page => !key || page[key])
+ .map(page => ({
...page,
- path: `/${page.path}`,
- })),
+ path: `/${page.path}`
+ }))
]
// 这里处理分包
const subPages: any[] = []
- subPackages.forEach((subPageObj) => {
+ subPackages.forEach(subPageObj => {
// console.log(subPageObj)
const { root } = subPageObj
subPageObj.pages
- .filter((page) => !key || page[key])
+ .filter(page => !key || page[key])
.forEach((page: { path: string } & Record) => {
subPages.push({
...page,
- path: `/${root}/${page.path}`,
+ path: `/${root}/${page.path}`
})
})
})
@@ -111,13 +111,13 @@ export const getAllPages = (key = 'needLogin') => {
* 得到所有的需要登录的pages,包括主包和分包的
* 只得到 path 数组
*/
-export const getNeedLoginPages = (): string[] => getAllPages('needLogin').map((page) => page.path)
+export const getNeedLoginPages = (): string[] => getAllPages('needLogin').map(page => page.path)
/**
* 得到所有的需要登录的pages,包括主包和分包的
* 只得到 path 数组
*/
-export const needLoginPages: string[] = getAllPages('needLogin').map((page) => page.path)
+export const needLoginPages: string[] = getAllPages('needLogin').map(page => page.path)
/**
* 根据微信小程序当前环境,判断应该获取的BaseUrl
@@ -129,7 +129,7 @@ export const getEnvBaseUrl = () => {
// 小程序端环境区分
if (isMp) {
const {
- miniProgram: { envVersion },
+ miniProgram: { envVersion }
} = uni.getAccountInfoSync()
switch (envVersion) {
@@ -158,7 +158,7 @@ export const getEnvBaseUploadUrl = () => {
// 小程序端环境区分
if (isMp) {
const {
- miniProgram: { envVersion },
+ miniProgram: { envVersion }
} = uni.getAccountInfoSync()
switch (envVersion) {
diff --git a/src/utils/platform.ts b/src/utils/platform.ts
index a42200c..5c345ad 100644
--- a/src/utils/platform.ts
+++ b/src/utils/platform.ts
@@ -12,6 +12,6 @@ const PLATFORM = {
platform,
isH5,
isApp,
- isMp,
+ isMp
}
export default PLATFORM
diff --git a/uno.config.ts b/uno.config.ts
index 1c15aad..765cb55 100644
--- a/uno.config.ts
+++ b/uno.config.ts
@@ -6,7 +6,7 @@ import {
presetAttributify,
presetIcons,
transformerDirectives,
- transformerVariantGroup,
+ transformerVariantGroup
} from 'unocss'
import { presetApplet, presetRemRpx, transformerAttributify } from 'unocss-applet'
@@ -25,7 +25,7 @@ if (isMp) {
// 非小程序用官方预设
presetUno(),
// 支持css class属性化
- presetAttributify(),
+ presetAttributify()
)
}
export default defineConfig({
@@ -37,9 +37,9 @@ export default defineConfig({
warn: true,
extraProperties: {
display: 'inline-block',
- '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)`
@@ -63,20 +63,25 @@ export default defineConfig({
transformerAttributify({
// 解决与第三方框架样式冲突问题
prefixedOnly: true,
- prefix: 'fg',
- }),
+ prefix: 'fg'
+ })
],
rules: [
[
'p-safe',
{
padding:
- 'env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left)',
- },
+ 'env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left)'
+ }
],
['pt-safe', { 'padding-top': 'env(safe-area-inset-top)' }],
['pb-safe', { 'padding-bottom': 'env(safe-area-inset-bottom)' }],
- ],
+ ['custom-color-black', { color: '#0d0f10' }],
+ ['custom-color-grey', { color: '#505253' }],
+ ['custom-color-blue', { color: '#255cf7' }],
+ ['custom-bg-blue', { backGround: '#255cf7' }],
+ ['custom-bg-default', { backGround: '#f3f5fa' }]
+ ]
})
/**
diff --git a/vite-plugins/copyNativeRes.ts b/vite-plugins/copyNativeRes.ts
index f92aebc..b50f96c 100644
--- a/vite-plugins/copyNativeRes.ts
+++ b/vite-plugins/copyNativeRes.ts
@@ -8,7 +8,7 @@ export function copyNativeRes() {
'../dist',
process.env.NODE_ENV === 'production' ? 'build' : 'dev',
process.env.UNI_PLATFORM!,
- 'nativeResources',
+ 'nativeResources'
)
return {
@@ -29,11 +29,11 @@ export function copyNativeRes() {
// 执行文件夹复制
await fs.copy(waitPath, buildPath)
console.log(
- `[copyNativeRes] 成功将 nativeResources 目录中的资源移动到构建目录:${buildPath}`,
+ `[copyNativeRes] 成功将 nativeResources 目录中的资源移动到构建目录:${buildPath}`
)
} catch (error) {
console.error(`[copyNativeRes] 复制资源失败:`, error)
}
- },
+ }
}
}
diff --git a/vite.config.ts b/vite.config.ts
index 2d5e56a..2841da9 100644
--- a/vite.config.ts
+++ b/vite.config.ts
@@ -43,7 +43,7 @@ export default ({ command, mode }) => {
VITE_DELETE_CONSOLE,
VITE_SHOW_SOURCEMAP,
VITE_APP_PROXY,
- VITE_APP_PROXY_PREFIX,
+ VITE_APP_PROXY_PREFIX
} = env
console.log('环境变量 env -> ', env)
@@ -57,7 +57,7 @@ export default ({ command, mode }) => {
// homePage 通过 vue 文件的 route-block 的type="home"来设定
// pages 目录为 src/pages,分包目录不能配置在pages目录下
// subPackages: ['src/pages-sub'], // 是个数组,可以配置多个,但是不能为pages里面的目录
- dts: 'src/types/uni-pages.d.ts',
+ dts: 'src/types/uni-pages.d.ts'
}),
UniLayouts(),
UniPlatform(),
@@ -70,11 +70,11 @@ export default ({ command, mode }) => {
// 自定义插件禁用 vite:vue 插件的 devToolsEnabled,强制编译 vue 模板时 inline 为 true
name: 'fix-vite-plugin-vue',
configResolved(config) {
- const plugin = config.plugins.find((p) => p.name === 'vite:vue')
+ const plugin = config.plugins.find(p => p.name === 'vite:vue')
if (plugin && plugin.api && plugin.api.options) {
plugin.api.options.devToolsEnabled = false
}
- },
+ }
},
UnoCSS(),
AutoImport({
@@ -82,19 +82,19 @@ export default ({ command, mode }) => {
dts: 'src/types/auto-import.d.ts',
dirs: ['src/hooks'], // 自动导入 hooks
eslintrc: { enabled: true },
- vueTemplate: true, // default false
+ vueTemplate: true // default false
}),
ViteRestart({
// 通过这个插件,在修改vite.config.js文件则不需要重新运行也生效配置
- restart: ['vite.config.js'],
+ restart: ['vite.config.js']
}),
// h5环境增加 BUILD_TIME 和 BUILD_BRANCH
UNI_PLATFORM === 'h5' && {
name: 'html-transform',
transformIndexHtml(html) {
return html.replace('%BUILD_TIME%', dayjs().format('YYYY-MM-DD HH:mm:ss'))
- },
+ }
},
// 打包分析插件,h5 + 生产环境才弹出
UNI_PLATFORM === 'h5' &&
@@ -103,14 +103,14 @@ export default ({ command, mode }) => {
filename: './node_modules/.cache/visualizer/stats.html',
open: true,
gzipSize: true,
- brotliSize: true,
+ brotliSize: true
}),
// 只有在 app 平台时才启用 copyNativeRes 插件
- UNI_PLATFORM === 'app' && copyNativeRes(),
+ UNI_PLATFORM === 'app' && copyNativeRes()
],
define: {
__UNI_PLATFORM__: JSON.stringify(UNI_PLATFORM),
- __VITE_APP_PROXY__: JSON.stringify(VITE_APP_PROXY),
+ __VITE_APP_PROXY__: JSON.stringify(VITE_APP_PROXY)
},
css: {
postcss: {
@@ -119,15 +119,15 @@ export default ({ command, mode }) => {
// // 指定目标浏览器
// overrideBrowserslist: ['> 1%', 'last 2 versions'],
// }),
- ],
- },
+ ]
+ }
},
resolve: {
alias: {
'@': path.join(process.cwd(), './src'),
- '@img': path.join(process.cwd(), './src/static/images'),
- },
+ '@img': path.join(process.cwd(), './src/static/images')
+ }
},
server: {
host: '0.0.0.0',
@@ -139,10 +139,10 @@ export default ({ command, mode }) => {
[VITE_APP_PROXY_PREFIX]: {
target: VITE_SERVER_BASEURL,
changeOrigin: true,
- rewrite: (path) => path.replace(new RegExp(`^${VITE_APP_PROXY_PREFIX}`), ''),
- },
+ rewrite: path => path.replace(new RegExp(`^${VITE_APP_PROXY_PREFIX}`), '')
+ }
}
- : undefined,
+ : undefined
},
build: {
// 方便非h5端调试
@@ -153,9 +153,9 @@ export default ({ command, mode }) => {
terserOptions: {
compress: {
drop_console: VITE_DELETE_CONSOLE === 'true',
- drop_debugger: true,
- },
- },
- },
+ drop_debugger: true
+ }
+ }
+ }
})
}