@xtdev/xt-miniprogram-ui 1.0.8 → 1.0.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/package.json +3 -12
- package/bin/index.js +0 -62
- package/template/list/components/index.js +0 -0
- package/template/list/index.js +0 -81
- package/template/list/index.json +0 -6
- package/template/list/index.wxml +0 -17
- package/template/list/index.wxss +0 -24
package/README.md
CHANGED
package/package.json
CHANGED
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xtdev/xt-miniprogram-ui",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.10",
|
|
4
4
|
"description": "",
|
|
5
|
-
"bin": {
|
|
6
|
-
"xt-page-cli": "bin/index.js"
|
|
7
|
-
},
|
|
8
5
|
"miniprogram": "libs",
|
|
9
6
|
"publishConfig": {
|
|
10
7
|
"access": "public",
|
|
@@ -12,16 +9,13 @@
|
|
|
12
9
|
},
|
|
13
10
|
"files": [
|
|
14
11
|
"libs",
|
|
15
|
-
"bin",
|
|
16
|
-
"template",
|
|
17
12
|
"README.md"
|
|
18
13
|
],
|
|
19
14
|
"scripts": {
|
|
20
15
|
"test": "echo \"Error: no test specified\" && exit 1",
|
|
21
16
|
"dev": "gulp",
|
|
22
17
|
"build": "gulp build",
|
|
23
|
-
"release": "yarn version --patch && yarn build && npm publish --access public --registry=https://registry.npmjs.org"
|
|
24
|
-
"cli:demo": "xt-page-cli create list"
|
|
18
|
+
"release": "yarn version --patch && yarn build && npm publish --access public --registry=https://registry.npmjs.org"
|
|
25
19
|
},
|
|
26
20
|
"repository": {
|
|
27
21
|
"type": "git",
|
|
@@ -30,15 +24,12 @@
|
|
|
30
24
|
"author": "",
|
|
31
25
|
"license": "ISC",
|
|
32
26
|
"devDependencies": {
|
|
33
|
-
"chalk": "^4.0.0",
|
|
34
|
-
"commander": "^10.0.1",
|
|
35
27
|
"del": "^3.0.0",
|
|
36
28
|
"gulp": "^4.0.2",
|
|
37
29
|
"gulp-changed": "^4.0.3",
|
|
38
30
|
"gulp-clean": "^0.4.0",
|
|
39
31
|
"gulp-json-transform": "^0.4.8",
|
|
40
|
-
"gulp-rename": "^2.0.0"
|
|
41
|
-
"mkdirp": "^3.0.1"
|
|
32
|
+
"gulp-rename": "^2.0.0"
|
|
42
33
|
},
|
|
43
34
|
"dependencies": {}
|
|
44
35
|
}
|
package/bin/index.js
DELETED
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
const program = require('commander');
|
|
4
|
-
const path = require('path');
|
|
5
|
-
const chalk = require('chalk');
|
|
6
|
-
const mkdirp = require('mkdirp');
|
|
7
|
-
const { readFileSync, existsSync, readdirSync, statSync, createReadStream, createWriteStream, writeFileSync } = require('fs');
|
|
8
|
-
chalk.enabled = true
|
|
9
|
-
/**
|
|
10
|
-
* 拷贝文件夹下的文件到指定位置
|
|
11
|
-
* @param {*} sourceDir
|
|
12
|
-
* @param {*} destDir
|
|
13
|
-
*/
|
|
14
|
-
function copyFiles(sourceDir, destDir) {
|
|
15
|
-
// 确保目标文件夹存在,如果不存在则创建它
|
|
16
|
-
mkdirp.sync(destDir);
|
|
17
|
-
const filenames = readdirSync(sourceDir);
|
|
18
|
-
filenames.forEach(function (filename) {
|
|
19
|
-
const sourceFile = path.join(sourceDir, filename);
|
|
20
|
-
const destFile = path.join(destDir, filename);
|
|
21
|
-
const stat = statSync(sourceFile);
|
|
22
|
-
if (stat.isDirectory()) {
|
|
23
|
-
// 如果当前文件是一个文件夹,则递归拷贝该文件夹下所有文件
|
|
24
|
-
copyFiles(sourceFile, destFile);
|
|
25
|
-
} else {
|
|
26
|
-
// 如果当前文件是一个普通文件,则复制文件到目标文件夹
|
|
27
|
-
const reader = createReadStream(sourceFile);
|
|
28
|
-
const writer = createWriteStream(destFile);
|
|
29
|
-
reader.pipe(writer);
|
|
30
|
-
}
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
// 新增创建
|
|
34
|
-
program.command('create <template-name>')
|
|
35
|
-
.description('根据模板名称,快速构建页面模板')
|
|
36
|
-
.action(async (templateName) => {
|
|
37
|
-
console.log('🎉 开始构建');
|
|
38
|
-
if (!templateName) {
|
|
39
|
-
console.error(chalk.red.dim('请填写模板名称'));
|
|
40
|
-
return;
|
|
41
|
-
}
|
|
42
|
-
// const tempFolder = `/template/${templateName}`;
|
|
43
|
-
const tempFolder = path.join(__dirname, '..', `./template/${templateName}`);
|
|
44
|
-
console.log(tempFolder);
|
|
45
|
-
const tempExist = existsSync(`${tempFolder}/index.js`);
|
|
46
|
-
if (!tempExist) {
|
|
47
|
-
console.error(chalk.red.dim('请填写正确的模板名称'));
|
|
48
|
-
return;
|
|
49
|
-
}
|
|
50
|
-
console.log('📋 开始拷贝');
|
|
51
|
-
copyFiles(tempFolder, process.cwd());
|
|
52
|
-
console.log('✅ 拷贝完成');
|
|
53
|
-
console.log('🔄 更改json引入路径');
|
|
54
|
-
const jsonPath = path.join(process.cwd(), './index.json');
|
|
55
|
-
// 延迟一秒读取文件
|
|
56
|
-
await new Promise(resolve => setTimeout(resolve, 1000))
|
|
57
|
-
const data = readFileSync(jsonPath);
|
|
58
|
-
const result = data.toString('utf-8').replace(/\.\.\/\.\./g, '@xtdev/xt-miniprogram-ui');
|
|
59
|
-
writeFileSync(jsonPath, result, 'utf-8');
|
|
60
|
-
console.log('🎉 创建完成');
|
|
61
|
-
});
|
|
62
|
-
program.parse(process.argv);
|
|
File without changes
|
package/template/list/index.js
DELETED
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
// template/index.js
|
|
2
|
-
Page({
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* 页面的初始数据
|
|
6
|
-
*/
|
|
7
|
-
data: {
|
|
8
|
-
page: {
|
|
9
|
-
isLoading: false,
|
|
10
|
-
size: 10,
|
|
11
|
-
over: false,
|
|
12
|
-
curPage: 0
|
|
13
|
-
},
|
|
14
|
-
list: []
|
|
15
|
-
},
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* 生命周期函数--监听页面加载
|
|
19
|
-
*/
|
|
20
|
-
onLoad(options) {
|
|
21
|
-
this.getListData();
|
|
22
|
-
},
|
|
23
|
-
handleSearch(e) {
|
|
24
|
-
console.log(e.detail);
|
|
25
|
-
this.setData({
|
|
26
|
-
page: {
|
|
27
|
-
isLoading: false,
|
|
28
|
-
size: 10,
|
|
29
|
-
over: false,
|
|
30
|
-
curPage: 0
|
|
31
|
-
}
|
|
32
|
-
})
|
|
33
|
-
this.getListData(true);
|
|
34
|
-
},
|
|
35
|
-
async getListData(refresh = false) {
|
|
36
|
-
const { isLoading, curPage, size } = this.data.page;
|
|
37
|
-
if (isLoading) return;
|
|
38
|
-
wx.showLoading();
|
|
39
|
-
this.setData({
|
|
40
|
-
'page.isLoading': true,
|
|
41
|
-
'page.curPage': curPage + 1
|
|
42
|
-
})
|
|
43
|
-
// 模拟接口请求,开发请切换成真实数据
|
|
44
|
-
const data = await new Promise(resolve => {
|
|
45
|
-
setTimeout(() => {
|
|
46
|
-
const temp = new Array(size).fill(1).map(num => ({
|
|
47
|
-
title: '北京老布鞋烟酒店',
|
|
48
|
-
subTitle: '合作中',
|
|
49
|
-
subTitleColor: '#6722ab',
|
|
50
|
-
state: 20,
|
|
51
|
-
dataList: [{
|
|
52
|
-
label: '店老板名称',
|
|
53
|
-
valueType: 'text',
|
|
54
|
-
value: '张三',
|
|
55
|
-
}, {
|
|
56
|
-
label: '联系电话',
|
|
57
|
-
valueType: 'tel',
|
|
58
|
-
value: '18080166584',
|
|
59
|
-
}, {
|
|
60
|
-
label: '报销金',
|
|
61
|
-
valueType: 'text',
|
|
62
|
-
value: '3000元',
|
|
63
|
-
}]
|
|
64
|
-
}));
|
|
65
|
-
resolve(temp);
|
|
66
|
-
}, 2000);
|
|
67
|
-
})
|
|
68
|
-
const list = refresh ? data : this.data.list.concat(data);
|
|
69
|
-
this.setData({
|
|
70
|
-
list,
|
|
71
|
-
'page.isLoading': false,
|
|
72
|
-
'page.over': list.length > 10
|
|
73
|
-
})
|
|
74
|
-
wx.hideLoading();
|
|
75
|
-
},
|
|
76
|
-
onReachBottom() {
|
|
77
|
-
if (!this.data.page.over) {
|
|
78
|
-
this.getListData();
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
})
|
package/template/list/index.json
DELETED
package/template/list/index.wxml
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
<view class="search-content">
|
|
2
|
-
<xt-search bind:onSearch="handleSearch"></xt-search>
|
|
3
|
-
</view>
|
|
4
|
-
<view wx:for="{{list}}" wx:key="id">
|
|
5
|
-
<xt-card-cell item="{{item}}">
|
|
6
|
-
<view slot="card-footer">
|
|
7
|
-
<!-- 列表按钮 -->
|
|
8
|
-
<view class="footer">
|
|
9
|
-
<view class="default-btn">
|
|
10
|
-
查看详情
|
|
11
|
-
</view>
|
|
12
|
-
</view>
|
|
13
|
-
</view>
|
|
14
|
-
</xt-card-cell>
|
|
15
|
-
</view>
|
|
16
|
-
<view wx:if="{{page.over}}" class="bottom-tips">没有更多数据</view>
|
|
17
|
-
<view wx:elif="{{page.isLoading && list.length}}" class="bottom-tips">加载中...</view>
|
package/template/list/index.wxss
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
page{
|
|
2
|
-
background-color: #f2f2f2;
|
|
3
|
-
padding: 24rpx;
|
|
4
|
-
box-sizing: border-box;
|
|
5
|
-
}
|
|
6
|
-
.search-content{
|
|
7
|
-
margin-bottom: 24rpx;
|
|
8
|
-
}
|
|
9
|
-
.default-btn {
|
|
10
|
-
display: inline-block;
|
|
11
|
-
color: #6722AB;
|
|
12
|
-
border: 2rpx solid #6722AB;
|
|
13
|
-
box-sizing: border-box;
|
|
14
|
-
border-radius: 120rpx;
|
|
15
|
-
margin-top: 32rpx;
|
|
16
|
-
font-size: 34rpx;
|
|
17
|
-
line-height: 48rpx;
|
|
18
|
-
font-weight: 800;
|
|
19
|
-
padding: 16rpx 32rpx;
|
|
20
|
-
}
|
|
21
|
-
.bottom-tips{
|
|
22
|
-
text-align: center;
|
|
23
|
-
padding: 20px;
|
|
24
|
-
}
|