feat: 引入 uview-plus UI 框架 (Vue3 版 uView)
This commit is contained in:
parent
e32a1b530c
commit
503362eb64
84
package-lock.json
generated
84
package-lock.json
generated
@ -24,6 +24,9 @@
|
||||
"@dcloudio/uni-mp-weixin": "3.0.0-5020420260813003",
|
||||
"@dcloudio/uni-mp-xhs": "3.0.0-5020420260813003",
|
||||
"@dcloudio/uni-quickapp-webview": "3.0.0-5020420260813003",
|
||||
"clipboard": "^2.0.11",
|
||||
"dayjs": "^1.11.23",
|
||||
"uview-plus": "^3.8.125",
|
||||
"vue": "^3.4.21",
|
||||
"vue-i18n": "^9.1.9"
|
||||
},
|
||||
@ -35,6 +38,7 @@
|
||||
"@dcloudio/vite-plugin-uni": "3.0.0-5020420260813003",
|
||||
"@vue/runtime-core": "^3.4.21",
|
||||
"@vue/tsconfig": "^0.1.3",
|
||||
"sass": "^1.63.2",
|
||||
"typescript": "^4.9.4",
|
||||
"vite": "5.2.8",
|
||||
"vue-tsc": "^1.0.24"
|
||||
@ -6524,6 +6528,17 @@
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/clipboard": {
|
||||
"version": "2.0.11",
|
||||
"resolved": "https://registry.npmjs.org/clipboard/-/clipboard-2.0.11.tgz",
|
||||
"integrity": "sha512-C+0bbOqkezLIsmWSvlsXS0Q0bmkugu7jcfMIACB+RDEntIzQIkdr148we28AfSloQLRdZlYL/QYyrq05j/3Faw==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"good-listener": "^1.2.2",
|
||||
"select": "^1.1.2",
|
||||
"tiny-emitter": "^2.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/cliui": {
|
||||
"version": "7.0.4",
|
||||
"resolved": "https://registry.npmjs.org/cliui/-/cliui-7.0.4.tgz",
|
||||
@ -6836,6 +6851,12 @@
|
||||
"node": ">=10"
|
||||
}
|
||||
},
|
||||
"node_modules/dayjs": {
|
||||
"version": "1.11.23",
|
||||
"resolved": "https://registry.npmjs.org/dayjs/-/dayjs-1.11.23.tgz",
|
||||
"integrity": "sha512-QDTCU0M0MxR3hQfnlDJfwekQiaanm1ubOD231u73WBckQ/fsamwRLiE2GBz6D3a/xF1NgfiDLJjXBa1hYOYTtQ==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/de-indent": {
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmjs.org/de-indent/-/de-indent-1.0.2.tgz",
|
||||
@ -6907,6 +6928,12 @@
|
||||
"node": ">=0.4.0"
|
||||
}
|
||||
},
|
||||
"node_modules/delegate": {
|
||||
"version": "3.2.0",
|
||||
"resolved": "https://registry.npmjs.org/delegate/-/delegate-3.2.0.tgz",
|
||||
"integrity": "sha512-IofjkYBZaZivn0V8nnsMJGBr4jVLxHDheKSW88PyxS5QC4Vo9ZbZVvhzlSxY87fVq3STR6r+4cGepyHkcWOQSw==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/depd": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/depd/-/depd-2.0.0.tgz",
|
||||
@ -7738,6 +7765,15 @@
|
||||
"process": "^0.11.10"
|
||||
}
|
||||
},
|
||||
"node_modules/good-listener": {
|
||||
"version": "1.2.2",
|
||||
"resolved": "https://registry.npmjs.org/good-listener/-/good-listener-1.2.2.tgz",
|
||||
"integrity": "sha512-goW1b+d9q/HIwbVYZzZ6SsTr4IgE+WA44A0GmPIQstuOrgsFcT7VEJ48nmr9GaRtNu0XTKacFLGnBPAM6Afouw==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"delegate": "^3.1.2"
|
||||
}
|
||||
},
|
||||
"node_modules/gopd": {
|
||||
"version": "1.2.0",
|
||||
"resolved": "https://registry.npmjs.org/gopd/-/gopd-1.2.0.tgz",
|
||||
@ -7950,6 +7986,13 @@
|
||||
],
|
||||
"license": "BSD-3-Clause"
|
||||
},
|
||||
"node_modules/immutable": {
|
||||
"version": "4.3.9",
|
||||
"resolved": "https://registry.npmjs.org/immutable/-/immutable-4.3.9.tgz",
|
||||
"integrity": "sha512-ObHy4YN7ycwZOUCLI1/6svfyAFu7vL8RhAvVu/bh/RZW9EPlOyDaQ9jDQWCtdqzaXUjgXZCW1migtHE7YI7UGQ==",
|
||||
"devOptional": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/import-local": {
|
||||
"version": "3.2.0",
|
||||
"resolved": "https://registry.npmjs.org/import-local/-/import-local-3.2.0.tgz",
|
||||
@ -11779,6 +11822,25 @@
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/sass": {
|
||||
"version": "1.63.2",
|
||||
"resolved": "https://registry.npmjs.org/sass/-/sass-1.63.2.tgz",
|
||||
"integrity": "sha512-u56TU0AIFqMtauKl/OJ1AeFsXqRHkgO7nCWmHaDwfxDo9GUMSqBA4NEh6GMuh1CYVM7zuROYtZrHzPc2ixK+ww==",
|
||||
"devOptional": true,
|
||||
"license": "MIT",
|
||||
"peer": true,
|
||||
"dependencies": {
|
||||
"chokidar": ">=3.0.0 <4.0.0",
|
||||
"immutable": "^4.0.0",
|
||||
"source-map-js": ">=0.6.2 <2.0.0"
|
||||
},
|
||||
"bin": {
|
||||
"sass": "sass.js"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=14.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/sax": {
|
||||
"version": "1.6.1",
|
||||
"resolved": "https://registry.npmjs.org/sax/-/sax-1.6.1.tgz",
|
||||
@ -11807,6 +11869,12 @@
|
||||
"integrity": "sha512-6FtHJEvt+pVMIB9IBY+IcCJ6Z5f1iQnytgyfKMhDKgmzYG+TeH/wx1y3l27rshSbLiSanrR9ffZDrEsmjlQF2g==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/select": {
|
||||
"version": "1.1.2",
|
||||
"resolved": "https://registry.npmjs.org/select/-/select-1.1.2.tgz",
|
||||
"integrity": "sha512-OwpTSOfy6xSs1+pwcNrv0RBMOzI39Lp3qQKUTPVVPRjCdNa5JH/oPRiqsesIskK8TVgmRiHwO4KXlV2Li9dANA==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/semver": {
|
||||
"version": "6.3.1",
|
||||
"resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz",
|
||||
@ -12413,6 +12481,12 @@
|
||||
"integrity": "sha512-IjZc9KIotudix8bMaBW6QvMuq64BrJWFs1+4V0lXwWGQZwH+LnX87doAYhem4caOEusRP9/g6jVDQmZ8XOk1nw==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/tiny-emitter": {
|
||||
"version": "2.1.0",
|
||||
"resolved": "https://registry.npmjs.org/tiny-emitter/-/tiny-emitter-2.1.0.tgz",
|
||||
"integrity": "sha512-NB6Dk1A9xgQPMoGqC5CVXn123gWyte215ONT5Pp5a0yt4nlEoO1ZWeCwpncaekPHXO60i47ihFnZPiRPjRMq4Q==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/tinycolor2": {
|
||||
"version": "1.6.0",
|
||||
"resolved": "https://registry.npmjs.org/tinycolor2/-/tinycolor2-1.6.0.tgz",
|
||||
@ -12834,6 +12908,16 @@
|
||||
"node": ">= 0.4.0"
|
||||
}
|
||||
},
|
||||
"node_modules/uview-plus": {
|
||||
"version": "3.8.125",
|
||||
"resolved": "https://registry.npmjs.org/uview-plus/-/uview-plus-3.8.125.tgz",
|
||||
"integrity": "sha512-AKtqKwtMTVOjj6wZ/FbXY5NQMuV1/WJTSe7Fs83nwDlSs2VnVus4THHTVlm1D/Bbnl5Io8WWOJxd3diB8/Zg6w==",
|
||||
"engines": {
|
||||
"HBuilderX": "^3.1.0",
|
||||
"uni-app": "^4.66",
|
||||
"uni-app-x": ""
|
||||
}
|
||||
},
|
||||
"node_modules/v8-to-istanbul": {
|
||||
"version": "8.1.1",
|
||||
"resolved": "https://registry.npmjs.org/v8-to-istanbul/-/v8-to-istanbul-8.1.1.tgz",
|
||||
|
||||
@ -53,6 +53,9 @@
|
||||
"@dcloudio/uni-mp-weixin": "3.0.0-5020420260813003",
|
||||
"@dcloudio/uni-mp-xhs": "3.0.0-5020420260813003",
|
||||
"@dcloudio/uni-quickapp-webview": "3.0.0-5020420260813003",
|
||||
"clipboard": "^2.0.11",
|
||||
"dayjs": "^1.11.23",
|
||||
"uview-plus": "^3.8.125",
|
||||
"vue": "^3.4.21",
|
||||
"vue-i18n": "^9.1.9"
|
||||
},
|
||||
@ -62,8 +65,9 @@
|
||||
"@dcloudio/uni-cli-shared": "3.0.0-5020420260813003",
|
||||
"@dcloudio/uni-stacktracey": "3.0.0-5020420260813003",
|
||||
"@dcloudio/vite-plugin-uni": "3.0.0-5020420260813003",
|
||||
"@vue/tsconfig": "^0.1.3",
|
||||
"@vue/runtime-core": "^3.4.21",
|
||||
"@vue/tsconfig": "^0.1.3",
|
||||
"sass": "^1.63.2",
|
||||
"typescript": "^4.9.4",
|
||||
"vite": "5.2.8",
|
||||
"vue-tsc": "^1.0.24"
|
||||
|
||||
@ -10,4 +10,7 @@ onHide(() => {
|
||||
console.log("App Hide");
|
||||
});
|
||||
</script>
|
||||
<style></style>
|
||||
<style lang="scss">
|
||||
/* 必须写在 style 首行,且 style 标签需带 lang="scss" 属性 */
|
||||
@import "uview-plus/index.scss";
|
||||
</style>
|
||||
|
||||
@ -1,7 +1,11 @@
|
||||
import { createSSRApp } from "vue";
|
||||
import App from "./App.vue";
|
||||
import uviewPlus from "uview-plus";
|
||||
|
||||
export function createApp() {
|
||||
const app = createSSRApp(App);
|
||||
// 注册 uview-plus,注册后才可使用 uni.$u 等全局工具方法
|
||||
app.use(uviewPlus);
|
||||
return {
|
||||
app,
|
||||
};
|
||||
|
||||
@ -54,7 +54,9 @@
|
||||
"setting" : {
|
||||
"urlCheck" : false
|
||||
},
|
||||
"usingComponents" : true
|
||||
"usingComponents" : true,
|
||||
/* uview-plus 要求:将虚拟节点属性合并到根节点,否则组件样式可能异常 */
|
||||
"mergeVirtualHostAttributes" : true
|
||||
},
|
||||
"mp-alipay" : {
|
||||
"usingComponents" : true
|
||||
@ -63,7 +65,8 @@
|
||||
"usingComponents" : true
|
||||
},
|
||||
"mp-toutiao" : {
|
||||
"usingComponents" : true
|
||||
"usingComponents" : true,
|
||||
"mergeVirtualHostAttributes" : true
|
||||
},
|
||||
"uniStatistics": {
|
||||
"enable": false
|
||||
|
||||
@ -1,4 +1,15 @@
|
||||
{
|
||||
// easycom:uview-plus 组件按需自动引入,页面中无需手动 import
|
||||
// 注意:修改 easycom 规则不会热更新,需重启编译才生效
|
||||
"easycom": {
|
||||
"autoscan": true,
|
||||
// 规则必须写在 custom 中,否则无效
|
||||
"custom": {
|
||||
"^u--(.*)": "uview-plus/components/u-$1/u-$1.vue",
|
||||
"^up-(.*)": "uview-plus/components/u-$1/u-$1.vue",
|
||||
"^u-([^-].*)": "uview-plus/components/u-$1/u-$1.vue"
|
||||
}
|
||||
},
|
||||
"pages": [ //pages数组中第一项表示应用启动页,参考:https://uniapp.dcloud.io/collocation/pages
|
||||
{
|
||||
"path": "pages/index/index",
|
||||
|
||||
@ -4,15 +4,42 @@
|
||||
<view class="text-area">
|
||||
<text class="title">{{ title }}</text>
|
||||
</view>
|
||||
|
||||
<!-- uview-plus 组件:已配置 easycom,无需 import 即可直接使用 -->
|
||||
<view class="demo">
|
||||
<up-button type="primary" text="主要按钮" @click="onClick"></up-button>
|
||||
<up-button
|
||||
type="success"
|
||||
text="镂空按钮"
|
||||
:plain="true"
|
||||
customStyle="margin-top: 20rpx"
|
||||
></up-button>
|
||||
|
||||
<up-cell-group :border="false" customStyle="margin-top: 30rpx; width: 100%">
|
||||
<up-cell title="uview-plus 版本" :value="version"></up-cell>
|
||||
<up-cell title="运行平台" :value="platform"></up-cell>
|
||||
</up-cell-group>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref } from 'vue'
|
||||
const title = ref('Hello')
|
||||
|
||||
const title = ref('Hello uview-plus')
|
||||
|
||||
// uni.$u 为 uview-plus 挂载的全局工具对象
|
||||
const version = ref(uni.$u.config.v)
|
||||
|
||||
// 运行平台,用于确认各端编译结果
|
||||
const platform = ref(uni.getSystemInfoSync().uniPlatform)
|
||||
|
||||
const onClick = () => {
|
||||
uni.$u.toast('uview-plus 已成功引入')
|
||||
}
|
||||
</script>
|
||||
|
||||
<style>
|
||||
<style lang="scss" scoped>
|
||||
.content {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
@ -36,6 +63,12 @@ const title = ref('Hello')
|
||||
|
||||
.title {
|
||||
font-size: 36rpx;
|
||||
color: #8f8f94;
|
||||
color: $uni-text-color-grey;
|
||||
}
|
||||
|
||||
.demo {
|
||||
width: 100%;
|
||||
padding: 40rpx;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
</style>
|
||||
|
||||
@ -73,4 +73,11 @@ $uni-font-size-title: 20px;
|
||||
$uni-color-subtitle: #555; // 二级标题颜色
|
||||
$uni-font-size-subtitle: 18px;
|
||||
$uni-color-paragraph: #3f536e; // 文章段落颜色
|
||||
$uni-font-size-paragraph: 15px;
|
||||
$uni-font-size-paragraph: 15px;
|
||||
|
||||
/* ==================== uview-plus 主题变量 ==================== */
|
||||
/* theme.scss 内的变量均使用 !default,所以必须放在本文件末尾:
|
||||
这样你在上方自定义的 $u-* 变量才能覆盖 uview-plus 默认主题。
|
||||
注意:uview-plus/index.scss 基础样式严禁写在此处,必须写在 App.vue,
|
||||
否则会造成打包后体积异常增大。 */
|
||||
@import 'uview-plus/theme.scss';
|
||||
@ -7,7 +7,7 @@
|
||||
"@/*": ["./src/*"]
|
||||
},
|
||||
"lib": ["esnext", "dom"],
|
||||
"types": ["@dcloudio/types"]
|
||||
"types": ["@dcloudio/types", "uview-plus/types"]
|
||||
},
|
||||
"include": ["src/**/*.ts", "src/**/*.d.ts", "src/**/*.tsx", "src/**/*.vue"]
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user