feat(vite): 引入 @uni-helper/vite-plugin-uni-layouts

This commit is contained in:
Burt 2023-12-23 11:20:24 +08:00
parent 600274d573
commit da5284331f
7 changed files with 187 additions and 0 deletions

View File

@ -92,6 +92,7 @@
"@typescript-eslint/parser": "^6.15.0", "@typescript-eslint/parser": "^6.15.0",
"@uni-helper/uni-app-types": "^0.5.12", "@uni-helper/uni-app-types": "^0.5.12",
"@uni-helper/unocss-preset-uni": "^0.2.5", "@uni-helper/unocss-preset-uni": "^0.2.5",
"@uni-helper/vite-plugin-uni-layouts": "^0.1.7",
"@uni-helper/vite-plugin-uni-pages": "^0.2.12", "@uni-helper/vite-plugin-uni-pages": "^0.2.12",
"@vue/runtime-core": "^3.2.45", "@vue/runtime-core": "^3.2.45",
"@vue/tsconfig": "^0.1.3", "@vue/tsconfig": "^0.1.3",

166
pnpm-lock.yaml generated
View File

@ -97,6 +97,9 @@ devDependencies:
'@uni-helper/unocss-preset-uni': '@uni-helper/unocss-preset-uni':
specifier: ^0.2.5 specifier: ^0.2.5
version: 0.2.5(eslint-import-resolver-typescript@3.6.1)(postcss@8.4.32)(typescript@4.9.5)(vite@4.1.4) version: 0.2.5(eslint-import-resolver-typescript@3.6.1)(postcss@8.4.32)(typescript@4.9.5)(vite@4.1.4)
'@uni-helper/vite-plugin-uni-layouts':
specifier: ^0.1.7
version: 0.1.7(eslint-import-resolver-typescript@3.6.1)(typescript@4.9.5)
'@uni-helper/vite-plugin-uni-pages': '@uni-helper/vite-plugin-uni-pages':
specifier: ^0.2.12 specifier: ^0.2.12
version: 0.2.12(@types/lodash-es@4.17.12)(lodash-es@4.17.21)(lodash@4.17.21) version: 0.2.12(@types/lodash-es@4.17.12)(lodash-es@4.17.21)(lodash@4.17.21)
@ -3904,6 +3907,29 @@ packages:
- vitest - vitest
dev: true dev: true
/@uni-helper/vite-plugin-uni-layouts@0.1.7(eslint-import-resolver-typescript@3.6.1)(typescript@4.9.5):
resolution: {integrity: sha512-15WO1XO5gd3IMWELgu2zt3mZh47u3Zlts/srzw+xgECteiQcuBAft89qxBNv+2/TJecg1HJF7z+fb7oFDJIyhA==}
dependencies:
'@babel/types': 7.23.6
'@uni-helper/uni-env': 0.1.1(eslint-import-resolver-typescript@3.6.1)(typescript@4.9.5)
'@vue/compiler-core': 3.3.13
'@vue/compiler-sfc': 3.3.13
ast-kit: 0.11.3
c12: 1.5.1
chokidar: 3.5.3
fast-glob: 3.3.2
jsonc-parser: 3.2.0
magic-string: 0.30.5
scule: 1.1.1
transitivePeerDependencies:
- eslint-import-resolver-typescript
- eslint-import-resolver-webpack
- rollup
- supports-color
- typescript
- vitest
dev: true
/@uni-helper/vite-plugin-uni-pages@0.2.12(@types/lodash-es@4.17.12)(lodash-es@4.17.21)(lodash@4.17.21): /@uni-helper/vite-plugin-uni-pages@0.2.12(@types/lodash-es@4.17.12)(lodash-es@4.17.21)(lodash@4.17.21):
resolution: {integrity: sha512-7Y5nX5o8BrUGWQyHYLSHbE5HxzXxkVpis988SDHAPOY+Kl6acpcg2hvfUNM99l1h4l1KwzW/JCr9u4Ib62HkjA==} resolution: {integrity: sha512-7Y5nX5o8BrUGWQyHYLSHbE5HxzXxkVpis988SDHAPOY+Kl6acpcg2hvfUNM99l1h4l1KwzW/JCr9u4Ib62HkjA==}
dependencies: dependencies:
@ -4759,6 +4785,15 @@ packages:
- supports-color - supports-color
dev: true dev: true
/agent-base@7.1.0:
resolution: {integrity: sha512-o/zjMZRhJxny7OyEF+Op8X+efiELC7k7yOjMzgfzVqOzXqkBkWI79YoTdOtsuWd5BWhAGAuOY/Xa6xpiaWXiNg==}
engines: {node: '>= 14'}
dependencies:
debug: 4.3.4
transitivePeerDependencies:
- supports-color
dev: true
/ajv@6.12.6: /ajv@6.12.6:
resolution: {integrity: sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g==} resolution: {integrity: sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g==}
dependencies: dependencies:
@ -4981,6 +5016,17 @@ packages:
engines: {node: '>=0.10.0'} engines: {node: '>=0.10.0'}
dev: true dev: true
/ast-kit@0.11.3:
resolution: {integrity: sha512-qdwwKEhckRk0XE22/xDdmU3v/60E8Edu4qFhgTLIhGGDs/PAJwLw9pQn8Rj99PitlbBZbYpx0k/lbir4kg0SuA==}
engines: {node: '>=16.14.0'}
dependencies:
'@babel/parser': 7.23.6
'@rollup/pluginutils': 5.1.0
pathe: 1.1.1
transitivePeerDependencies:
- rollup
dev: true
/astral-regex@2.0.0: /astral-regex@2.0.0:
resolution: {integrity: sha512-Z7tMw1ytTXt5jqMcOP+OQteU1VuNK9Y02uuJtKQ1Sv69jXQKKg5cibLwGJow8yzZP+eAc18EmLGPal0bp36rvQ==} resolution: {integrity: sha512-Z7tMw1ytTXt5jqMcOP+OQteU1VuNK9Y02uuJtKQ1Sv69jXQKKg5cibLwGJow8yzZP+eAc18EmLGPal0bp36rvQ==}
engines: {node: '>=8'} engines: {node: '>=8'}
@ -5373,6 +5419,24 @@ packages:
engines: {node: '>= 0.8'} engines: {node: '>= 0.8'}
dev: true dev: true
/c12@1.5.1:
resolution: {integrity: sha512-BWZRJgDEveT8uI+cliCwvYSSSSvb4xKoiiu5S0jaDbKBopQLQF7E+bq9xKk1pTcG+mUa3yXuFO7bD9d8Lr9Xxg==}
dependencies:
chokidar: 3.5.3
defu: 6.1.3
dotenv: 16.3.1
giget: 1.1.3
jiti: 1.21.0
mlly: 1.4.2
ohash: 1.1.3
pathe: 1.1.1
perfect-debounce: 1.0.0
pkg-types: 1.0.3
rc9: 2.1.1
transitivePeerDependencies:
- supports-color
dev: true
/cac@6.7.14: /cac@6.7.14:
resolution: {integrity: sha512-b6Ilus+c3RrdDk+JhLKUAQfzzgLEPy6wcXqS7f/xe1EETvsDP6GORG7SFuOs6cID5YkqchW/LXZbX5bc8j7ZcQ==} resolution: {integrity: sha512-b6Ilus+c3RrdDk+JhLKUAQfzzgLEPy6wcXqS7f/xe1EETvsDP6GORG7SFuOs6cID5YkqchW/LXZbX5bc8j7ZcQ==}
engines: {node: '>=8'} engines: {node: '>=8'}
@ -5531,6 +5595,11 @@ packages:
optionalDependencies: optionalDependencies:
fsevents: 2.3.3 fsevents: 2.3.3
/chownr@2.0.0:
resolution: {integrity: sha512-bIomtDF5KGpdogkLd9VspvFzk9KfpyyGlS8YFVZl7TGPBHL5snIOnxeshwVgPteQ9b4Eydl+pVbIyE1DcvCWgQ==}
engines: {node: '>=10'}
dev: true
/ci-info@3.9.0: /ci-info@3.9.0:
resolution: {integrity: sha512-NIxF55hv4nSqQswkAeiOi1r83xy8JldOFDTWiug55KBu9Jnblncd2U6ViHmYgHf01TPZS77NJBhBMKdWj9HQMQ==} resolution: {integrity: sha512-NIxF55hv4nSqQswkAeiOi1r83xy8JldOFDTWiug55KBu9Jnblncd2U6ViHmYgHf01TPZS77NJBhBMKdWj9HQMQ==}
engines: {node: '>=8'} engines: {node: '>=8'}
@ -6392,6 +6461,11 @@ packages:
is-obj: 2.0.0 is-obj: 2.0.0
dev: true dev: true
/dotenv@16.3.1:
resolution: {integrity: sha512-IPzF4w4/Rd94bA9imS68tZBaYyBWSCE47V1RGuMrB94iyTOIEwRmVL2x/4An+6mETpLrKJ5hQkB8W4kFAadeIQ==}
engines: {node: '>=12'}
dev: true
/download@6.2.5: /download@6.2.5:
resolution: {integrity: sha512-DpO9K1sXAST8Cpzb7kmEhogJxymyVUd5qz/vCOSyvwtp2Klj2XcDt5YUuasgxka44SxF0q5RriKIwJmQHG2AuA==} resolution: {integrity: sha512-DpO9K1sXAST8Cpzb7kmEhogJxymyVUd5qz/vCOSyvwtp2Klj2XcDt5YUuasgxka44SxF0q5RriKIwJmQHG2AuA==}
engines: {node: '>=4'} engines: {node: '>=4'}
@ -7808,6 +7882,11 @@ packages:
rimraf: 3.0.2 rimraf: 3.0.2
dev: true dev: true
/flat@5.0.2:
resolution: {integrity: sha512-b6suED+5/3rTpUBdG1gupIl8MPFCAMA0QXwmljLhvCUKcUvdE4gWky9zpuGCcXHOsz4J9wPGNWq6OKpmIzz3hQ==}
hasBin: true
dev: true
/flatted@3.2.9: /flatted@3.2.9:
resolution: {integrity: sha512-36yxDn5H7OFZQla0/jFJmbIKTdZAQHngCedGxiMmpNfEZM0sdEeT+WczLQrjK6D7o2aiyLYDnkw0R3JK0Qv1RQ==} resolution: {integrity: sha512-36yxDn5H7OFZQla0/jFJmbIKTdZAQHngCedGxiMmpNfEZM0sdEeT+WczLQrjK6D7o2aiyLYDnkw0R3JK0Qv1RQ==}
dev: true dev: true
@ -7880,6 +7959,13 @@ packages:
universalify: 2.0.1 universalify: 2.0.1
dev: true dev: true
/fs-minipass@2.1.0:
resolution: {integrity: sha512-V/JgOLFCS+R6Vcq0slCuaeWEdNC3ouDlJMNIsacH2VtALiu9mV4LPrHc5cDl8k5aw6J8jwgWWpiTo5RYhmIzvg==}
engines: {node: '>= 8'}
dependencies:
minipass: 3.3.6
dev: true
/fs.realpath@1.0.0: /fs.realpath@1.0.0:
resolution: {integrity: sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==} resolution: {integrity: sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==}
dev: true dev: true
@ -8021,6 +8107,21 @@ packages:
logalot: 2.1.0 logalot: 2.1.0
dev: true dev: true
/giget@1.1.3:
resolution: {integrity: sha512-zHuCeqtfgqgDwvXlR84UNgnJDuUHQcNI5OqWqFxxuk2BshuKbYhJWdxBsEo4PvKqoGh23lUAIvBNpChMLv7/9Q==}
hasBin: true
dependencies:
colorette: 2.0.20
defu: 6.1.3
https-proxy-agent: 7.0.2
mri: 1.2.0
node-fetch-native: 1.4.1
pathe: 1.1.1
tar: 6.2.0
transitivePeerDependencies:
- supports-color
dev: true
/git-raw-commits@2.0.11: /git-raw-commits@2.0.11:
resolution: {integrity: sha512-VnctFhw+xfj8Va1xtfEqCUD2XDrbAPSJx+hSrE5K7fGdjZruW7XV+QOrN7LF/RJyvspRiD2I0asWsxFp0ya26A==} resolution: {integrity: sha512-VnctFhw+xfj8Va1xtfEqCUD2XDrbAPSJx+hSrE5K7fGdjZruW7XV+QOrN7LF/RJyvspRiD2I0asWsxFp0ya26A==}
engines: {node: '>=10'} engines: {node: '>=10'}
@ -8393,6 +8494,16 @@ packages:
- supports-color - supports-color
dev: true dev: true
/https-proxy-agent@7.0.2:
resolution: {integrity: sha512-NmLNjm6ucYwtcUmL7JQC1ZQ57LmHP4lT15FQ8D61nak1rO6DH+fz5qNK2Ap5UN4ZapYICE3/0KodcLYSPsPbaA==}
engines: {node: '>= 14'}
dependencies:
agent-base: 7.1.0
debug: 4.3.4
transitivePeerDependencies:
- supports-color
dev: true
/human-signals@1.1.1: /human-signals@1.1.1:
resolution: {integrity: sha512-SEQu7vl8KjNL2eoGBLF3+wAjpsNfA9XMlXAYj/3EdaNfAlxKthD1xjEQfGOUhllCGGJVNY34bRr6lPINhNjyZw==} resolution: {integrity: sha512-SEQu7vl8KjNL2eoGBLF3+wAjpsNfA9XMlXAYj/3EdaNfAlxKthD1xjEQfGOUhllCGGJVNY34bRr6lPINhNjyZw==}
engines: {node: '>=8.12.0'} engines: {node: '>=8.12.0'}
@ -10318,6 +10429,26 @@ packages:
/minimist@1.2.8: /minimist@1.2.8:
resolution: {integrity: sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA==} resolution: {integrity: sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA==}
/minipass@3.3.6:
resolution: {integrity: sha512-DxiNidxSEK+tHG6zOIklvNOwm3hvCrbUrdtzY74U6HKTJxvIDfOUL5W5P2Ghd3DTkhhKPYGqeNUIh5qcM4YBfw==}
engines: {node: '>=8'}
dependencies:
yallist: 4.0.0
dev: true
/minipass@5.0.0:
resolution: {integrity: sha512-3FnjYuehv9k6ovOEbyOswadCDPX1piCfhV8ncmYtHOjuPwylVWsghTLo7rabjC3Rx5xD4HDx8Wm1xnMF7S5qFQ==}
engines: {node: '>=8'}
dev: true
/minizlib@2.1.2:
resolution: {integrity: sha512-bAxsR8BVfj60DWXHE3u30oHzfl4G7khkSuPW+qvpd7jFRHm7dLxOjUk1EHACJ/hxLY8phGJ0YhYHZo7jil7Qdg==}
engines: {node: '>= 8'}
dependencies:
minipass: 3.3.6
yallist: 4.0.0
dev: true
/mixin-deep@1.3.2: /mixin-deep@1.3.2:
resolution: {integrity: sha512-WRoDn//mXBiJ1H40rqa3vH0toePwSsGb45iInWlTySa+Uu4k3tYUSxa2v1KqAiLtvlrSzaExqS1gtk96A9zvEA==} resolution: {integrity: sha512-WRoDn//mXBiJ1H40rqa3vH0toePwSsGb45iInWlTySa+Uu4k3tYUSxa2v1KqAiLtvlrSzaExqS1gtk96A9zvEA==}
engines: {node: '>=0.10.0'} engines: {node: '>=0.10.0'}
@ -10333,6 +10464,12 @@ packages:
minimist: 1.2.8 minimist: 1.2.8
dev: false dev: false
/mkdirp@1.0.4:
resolution: {integrity: sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw==}
engines: {node: '>=10'}
hasBin: true
dev: true
/mlly@1.4.2: /mlly@1.4.2:
resolution: {integrity: sha512-i/Ykufi2t1EZ6NaPLdfnZk2AX8cs0d+mTzVKuPfqPKPatxLApaBoxJQ9x1/uckXtrS/U5oisPMDkNs0yQTaBRg==} resolution: {integrity: sha512-i/Ykufi2t1EZ6NaPLdfnZk2AX8cs0d+mTzVKuPfqPKPatxLApaBoxJQ9x1/uckXtrS/U5oisPMDkNs0yQTaBRg==}
dependencies: dependencies:
@ -10355,6 +10492,11 @@ packages:
bin-wrapper: 4.1.0 bin-wrapper: 4.1.0
dev: true dev: true
/mri@1.2.0:
resolution: {integrity: sha512-tzzskb3bG8LvYGFF/mDTpq3jpI6Q9wc3LEmBaghu+DdCssd1FakN7Bc0hVNmEyGq1bq3RgfkCb3cmQLpNPOroA==}
engines: {node: '>=4'}
dev: true
/mrmime@2.0.0: /mrmime@2.0.0:
resolution: {integrity: sha512-eu38+hdgojoyq63s+yTpN4XMBdt5l8HhMhc4VKLO9KM5caLIBvUm4thi7fFaxyTmCKeNnXZ5pAlBwCUnhA09uw==} resolution: {integrity: sha512-eu38+hdgojoyq63s+yTpN4XMBdt5l8HhMhc4VKLO9KM5caLIBvUm4thi7fFaxyTmCKeNnXZ5pAlBwCUnhA09uw==}
engines: {node: '>=10'} engines: {node: '>=10'}
@ -10589,6 +10731,10 @@ packages:
ufo: 1.3.2 ufo: 1.3.2
dev: true dev: true
/ohash@1.1.3:
resolution: {integrity: sha512-zuHHiGTYTA1sYJ/wZN+t5HKZaH23i4yI1HMwbuXm24Nid7Dv0KcuRlKoNKS9UNfAVSBlnGLcuQrnOKWOZoEGaw==}
dev: true
/omggif@1.0.10: /omggif@1.0.10:
resolution: {integrity: sha512-LMJTtvgc/nugXj0Vcrrs68Mn2D1r0zf630VNtqtpI1FEO7e+O9FP4gqs9AcnBaSEeoHIPm28u6qgPR0oyEpGSw==} resolution: {integrity: sha512-LMJTtvgc/nugXj0Vcrrs68Mn2D1r0zf630VNtqtpI1FEO7e+O9FP4gqs9AcnBaSEeoHIPm28u6qgPR0oyEpGSw==}
dev: false dev: false
@ -11410,6 +11556,14 @@ packages:
unpipe: 1.0.0 unpipe: 1.0.0
dev: true dev: true
/rc9@2.1.1:
resolution: {integrity: sha512-lNeOl38Ws0eNxpO3+wD1I9rkHGQyj1NU1jlzv4go2CtEnEQEUfqnIvZG7W+bC/aXdJ27n5x/yUjb6RoT9tko+Q==}
dependencies:
defu: 6.1.3
destr: 2.0.2
flat: 5.0.2
dev: true
/react-is@17.0.2: /react-is@17.0.2:
resolution: {integrity: sha512-w2GsyukL62IJnlaff/nRegPQR94C/XXamvMWmSHRJ4y7Ts/4ocGRmTHvOs8PSE6pB3dWOrD/nueuU5sduBsQ4w==} resolution: {integrity: sha512-w2GsyukL62IJnlaff/nRegPQR94C/XXamvMWmSHRJ4y7Ts/4ocGRmTHvOs8PSE6pB3dWOrD/nueuU5sduBsQ4w==}
dev: true dev: true
@ -12641,6 +12795,18 @@ packages:
xtend: 4.0.2 xtend: 4.0.2
dev: true dev: true
/tar@6.2.0:
resolution: {integrity: sha512-/Wo7DcT0u5HUV486xg675HtjNd3BXZ6xDbzsCUZPt5iw8bTQ63bP0Raut3mvro9u+CUyq7YQd8Cx55fsZXxqLQ==}
engines: {node: '>=10'}
dependencies:
chownr: 2.0.0
fs-minipass: 2.1.0
minipass: 5.0.0
minizlib: 2.1.2
mkdirp: 1.0.4
yallist: 4.0.0
dev: true
/temp-dir@1.0.0: /temp-dir@1.0.0:
resolution: {integrity: sha512-xZFXEGbG7SNC3itwBzI3RYjq/cEhBkx2hJuKGIUOcEULmkQExXiHat2z/qkISYsuR+IKumhEfKKbV5qXmhICFQ==} resolution: {integrity: sha512-xZFXEGbG7SNC3itwBzI3RYjq/cEhBkx2hJuKGIUOcEULmkQExXiHat2z/qkISYsuR+IKumhEfKKbV5qXmhICFQ==}
engines: {node: '>=4'} engines: {node: '>=4'}

6
src/layouts/default.vue Normal file
View File

@ -0,0 +1,6 @@
<template>
<view class="default-layout">
<slot />
<view class="mx-auto mt-5 text-center text-sm opacity-25"> [Default Layout] </view>
</view>
</template>

6
src/layouts/home.vue Normal file
View File

@ -0,0 +1,6 @@
<template>
<view class="home-layout">
<slot />
<view class="mx-auto mt-5 text-center text-sm opacity-25"> [Home Layout] </view>
</view>
</template>

View File

@ -3,6 +3,7 @@
{ {
"path": "pages/index/index", "path": "pages/index/index",
"type": "home", "type": "home",
"layout": "home",
"style": { "style": {
"navigationBarTitleText": "我才是标题" "navigationBarTitleText": "我才是标题"
} }

View File

@ -13,6 +13,7 @@
<route lang="json"> <route lang="json">
{ {
"layout": "home",
"style": { "style": {
"navigationBarTitleText": "我才是标题" "navigationBarTitleText": "我才是标题"
} }
@ -25,6 +26,9 @@ import { useCountStore } from '@/store/count'
const countStore = useCountStore() const countStore = useCountStore()
const title = ref('Hello') const title = ref('Hello')
const uniLayout = ref()
console.log(uniLayout)
</script> </script>
<style> <style>

View File

@ -2,6 +2,7 @@ import path from 'node:path'
import { defineConfig, loadEnv } from 'vite' import { defineConfig, loadEnv } from 'vite'
import Uni from '@dcloudio/vite-plugin-uni' import Uni from '@dcloudio/vite-plugin-uni'
import UniPages from '@uni-helper/vite-plugin-uni-pages' import UniPages from '@uni-helper/vite-plugin-uni-pages'
import UniLayouts from '@uni-helper/vite-plugin-uni-layouts'
import dayjs from 'dayjs' import dayjs from 'dayjs'
import svgLoader from 'vite-svg-loader' import svgLoader from 'vite-svg-loader'
import { visualizer } from 'rollup-plugin-visualizer' import { visualizer } from 'rollup-plugin-visualizer'
@ -41,6 +42,8 @@ export default ({ mode }) => {
plugins: [ plugins: [
// https://github.com/uni-helper/vite-plugin-uni-pages // https://github.com/uni-helper/vite-plugin-uni-pages
UniPages(), UniPages(),
// https://github.com/uni-helper/vite-plugin-uni-layouts
UniLayouts(),
Uni(), Uni(),
UnoCSS(), UnoCSS(),
htmlPlugin(), htmlPlugin(),