Skip to content

Commit 9daacf4

Browse files
committed
fix(custom): 添加layouts布局、tabbar、刷新加载等
1 parent e1051f1 commit 9daacf4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+3505
-68
lines changed

.eslintignore

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
src/assets
2+
node_modules
3+
src/uni_modules
4+
dist

.eslintrc.cjs

+14-34
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ module.exports = {
22
env: {
33
browser: true,
44
es2021: true,
5-
node: true
5+
node: true,
66
},
77
extends: [
88
'eslint:recommended',
@@ -14,47 +14,36 @@ module.exports = {
1414
// 1. 接入 prettier 的规则
1515
'prettier',
1616
'plugin:prettier/recommended',
17-
'./.eslintrc-auto-import.json'
1817
],
1918
overrides: [
2019
{
2120
env: {
22-
node: true
21+
node: true,
2322
},
24-
files: ['.eslintrc.{js}'],
23+
files: ['.eslintrc.{js,cjs}'],
2524
parserOptions: {
26-
sourceType: 'script'
27-
}
28-
}
25+
sourceType: 'script',
26+
},
27+
},
2928
],
30-
parserOptions: {
31-
parser: '@babel/eslint-parser',
32-
requireConfigFile: false,
33-
ecmaVersion: 'latest',
34-
sourceType: 'module'
35-
},
29+
3630
plugins: [
3731
'vue',
3832
// 2. 加入 prettier 的 eslint 插件
39-
'prettier'
33+
'prettier',
4034
],
4135
rules: {
4236
// 3. 注意要加上这一句,开启 prettier 自动修复的功能
4337
'prettier/prettier': 'error',
4438
// turn on errors for missing imports
4539
'import/no-unresolved': 'off',
4640
// 对后缀的检测,否则 import 一个ts文件也会报错,需要手动添加'.ts', 增加了下面的配置后就不用了
47-
'import/extensions': [
48-
'error',
49-
'ignorePackages',
50-
{ js: 'never', jsx: 'never', ts: 'never', tsx: 'never' }
51-
],
41+
'import/extensions': 'off',
5242
// 只允许1个默认导出,关闭,否则不能随意export xxx
5343
'import/prefer-default-export': ['off'],
5444
'no-console': ['off'],
5545
// 'no-unused-vars': ['off'],
56-
// '@typescript-eslint/no-unused-vars': ['off'],
57-
// 解决vite.config.ts报错问题
46+
// 解决vite.config.js报错问题
5847
'import/no-extraneous-dependencies': 'off',
5948
'no-plusplus': 'off',
6049
'no-shadow': 'off',
@@ -64,26 +53,17 @@ module.exports = {
6453
'no-undef': 'off',
6554
'no-unused-vars': 'off',
6655
'no-param-reassign': 'off',
67-
'no-redeclare': 'off',
68-
'import/named': 'off'
69-
},
70-
// eslint-import-resolver-typescript 插件,@see https://www.npmjs.com/package/eslint-import-resolver-typescript
71-
settings: {
72-
'import/parsers': {
73-
'@babel/eslint-parser': ['.js', '.jsx']
74-
},
75-
'import/resolver': {
76-
node: {}
77-
}
7856
},
7957
globals: {
58+
$t: true,
8059
uni: true,
8160
UniApp: true,
8261
wx: true,
8362
WechatMiniprogram: true,
8463
getCurrentPages: true,
8564
UniHelper: true,
8665
Page: true,
87-
App: true
88-
}
66+
App: true,
67+
NodeJS: true,
68+
},
8969
}

manifest.config.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// manifest.config.ts
1+
// manifest.config.js
22
import { defineManifestConfig } from '@uni-helper/vite-plugin-uni-manifest'
33
import path from 'node:path'
44
import { loadEnv } from 'vite'

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@
8080
"@dcloudio/vite-plugin-uni": "3.0.0-3090920231225001",
8181
"@iconify-json/ep": "^1.1.15",
8282
"@uni-helper/vite-plugin-uni-components": "^0.1.0",
83+
"@uni-helper/vite-plugin-uni-layouts": "^0.1.10",
8384
"@uni-helper/vite-plugin-uni-manifest": "^0.2.6",
8485
"@unocss/preset-legacy-compat": "^0.59.4",
8586
"@unocss/preset-uno": "^0.59.4",

pnpm-lock.yaml

+33-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/App.vue

+5
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,9 @@
1515
<style lang="scss">
1616
/*每个页面公共css */
1717
@import 'nutui-uniapp/styles/index.scss';
18+
page,
19+
html,
20+
body {
21+
height: 100%;
22+
}
1823
</style>

src/layouts/default.vue

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<!-- default.vue -->
2+
<template>
3+
<slot>main</slot>
4+
</template>

src/pages.json

+49-19
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,54 @@
11
{
22
"easycom": {
3-
"autoscan": true,
4-
"custom": {
5-
// nutui 规则如下配置 https://nutui-uniapp.pages.dev/guide/quick-start.html
3+
"autoscan": true,
4+
"custom": {
65
"^nut-(.*)?-(.*)": "nutui-uniapp/components/$1$2/$1$2.vue",
76
"^nut-(.*)": "nutui-uniapp/components/$1/$1.vue"
8-
}
9-
},
10-
"pages": [ //pages数组中第一项表示应用启动页,参考:https://uniapp.dcloud.io/collocation/pages
11-
{
12-
"path": "pages/index/index",
13-
"style": {
14-
"navigationBarTitleText": "uni-app"
15-
}
16-
}
17-
],
18-
"globalStyle": {
19-
"navigationBarTextStyle": "black",
20-
"navigationBarTitleText": "uni-app",
21-
"navigationBarBackgroundColor": "#F8F8F8",
22-
"backgroundColor": "#F8F8F8"
23-
}
7+
}
8+
},
9+
"pages": [
10+
{
11+
"path": "pages/index/index",
12+
"type": "home",
13+
"layout": "default",
14+
"style": {
15+
"navigationBarTitleText": "uni-app"
16+
}
17+
},
18+
{
19+
"path": "pages/interaction/interaction",
20+
"type": "page",
21+
"layout": "default",
22+
"style": {
23+
"navigationBarTitleText": "互动"
24+
}
25+
}
26+
],
27+
"tabBar": {
28+
"color": "#bfbfbf",
29+
"selectedColor": "#1296db",
30+
"borderStyle": "black",
31+
"backgroundColor": "#ffffff",
32+
"list": [
33+
{
34+
"pagePath": "pages/index/index",
35+
"iconPath": "static/images/index_i_no.png",
36+
"selectedIconPath": "static/images/index_i_yes.png",
37+
"text": "首页"
38+
},
39+
{
40+
"pagePath": "pages/interaction/interaction",
41+
"iconPath": "static/images/interaction_i_no.png",
42+
"selectedIconPath": "static/images/interaction_i_yes.png",
43+
"text": "互动"
44+
}
45+
]
46+
},
47+
"globalStyle": {
48+
"navigationBarTextStyle": "black",
49+
"navigationBarTitleText": "uni-app",
50+
"navigationBarBackgroundColor": "#F8F8F8",
51+
"backgroundColor": "#F8F8F8"
52+
},
53+
"subPackages": []
2454
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
<template>
2+
<view class="h-full w-full">
3+
<mescroll-uni
4+
:down="{ auto: false }"
5+
:fixed="false"
6+
:safearea="true"
7+
@init="mescrollInit"
8+
@down="downCallback"
9+
@up="upCallback"
10+
>
11+
<view
12+
class="item my-15rpx b-b-solid b-b-1rpx b-b-color-[#cccccc]"
13+
v-for="(item, index) in dataList"
14+
:key="index"
15+
>
16+
<text class="text-28rpx font-bold">{{ item.title }}</text>
17+
<view class="mt-5 text-18rpx color-[#9999]">{{ item.body }}</view>
18+
</view>
19+
<nut-empty
20+
v-if="isError && dataList.length == 0"
21+
image="error"
22+
description="加载失败/错误"
23+
></nut-empty>
24+
</mescroll-uni>
25+
</view>
26+
</template>
27+
<script setup>
28+
// https://github.com/mescroll/mescroll
29+
import MescrollUni from '@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-uni.vue'
30+
31+
const { API_DEMO_GET } = useRequest()
32+
const dataList = ref([])
33+
const queryParams = reactive({
34+
pageNo: 1,
35+
pageSize: 10
36+
})
37+
const isError = ref(false)
38+
39+
const queryList = () => {
40+
return new Promise((resolve, reject) => {
41+
// 此处请求仅为演示,请替换为自己项目中的请求
42+
API_DEMO_GET({ _start: queryParams.pageNo, _limit: queryParams.pageSize })
43+
.then((res) => {
44+
resolve(res)
45+
})
46+
.catch(reject)
47+
})
48+
}
49+
const mescrollInit = async (mescroll) => {
50+
console.log(mescroll)
51+
}
52+
53+
const downCallback = async (mescroll) => {
54+
try {
55+
queryParams.pageNo = 1
56+
const res = await queryList()
57+
dataList.value = res
58+
mescroll.endSuccess() // 隐藏加载进度
59+
} catch (error) {
60+
mescroll.endErr()
61+
isError.value = true
62+
}
63+
}
64+
const upCallback = async (mescroll) => {
65+
try {
66+
const res = await queryList()
67+
dataList.value = dataList.value.concat(res)
68+
mescroll.endSuccess(dataList.value.length)
69+
queryParams.pageNo++
70+
} catch (error) {
71+
mescroll.endErr()
72+
isError.value = true
73+
}
74+
}
75+
</script>

src/pages/interaction/index.vue

-12
This file was deleted.

src/pages/interaction/interaction.vue

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<template>
2+
<view class="interaction h-full">
3+
<nut-tabs v-model="state.tab11value" type="smile" swipeable>
4+
<!-- #ifdef H5 -->
5+
<nut-tab-pane class="h-full important-p-0" title="NutUi">
6+
<iframe
7+
class="h-full w-full"
8+
src="https://nutui-uniapp.pages.dev/ui/#/"
9+
frameborder="0"
10+
></iframe>
11+
</nut-tab-pane>
12+
<!-- #endif -->
13+
<nut-tab-pane class="important-p-0 important-px-2" title="加载刷新"
14+
><MescrollBox
15+
/></nut-tab-pane>
16+
<nut-tab-pane title="Tab 3"> Tab 3 </nut-tab-pane>
17+
</nut-tabs>
18+
</view>
19+
</template>
20+
<script setup>
21+
import MescrollBox from './components/mescrollBox.vue'
22+
const state = reactive({
23+
tab11value: '0'
24+
})
25+
</script>
26+
<style lang="scss" scoped>
27+
:deep(.nut-tabs) {
28+
height: 100%;
29+
.nut-tabs__content {
30+
height: calc(100% - var(--window-bottom));
31+
}
32+
}
33+
</style>

src/static/images/index_i_no.png

1.43 KB
Loading

src/static/images/index_i_yes.png

1.58 KB
Loading
1.24 KB
Loading
1.31 KB
Loading

0 commit comments

Comments
 (0)