适配小程序代码结构

This commit is contained in:
zhonghua1
2026-01-20 08:46:36 +08:00
parent 3b169467ac
commit 9c00db8ff5
615 changed files with 62726 additions and 8 deletions

View File

@@ -0,0 +1,69 @@
"use strict";
const common_vendor = require("../../../../common/vendor.js");
const _sfc_main = {
name: "UniGridItem",
inject: ["grid"],
props: {
index: {
type: Number,
default: 0
}
},
data() {
return {
column: 0,
showBorder: true,
square: true,
highlight: true,
left: 0,
top: 0,
openNum: 2,
width: 0,
borderColor: "#e5e5e5"
};
},
created() {
this.column = this.grid.column;
this.showBorder = this.grid.showBorder;
this.square = this.grid.square;
this.highlight = this.grid.highlight;
this.top = this.hor === 0 ? this.grid.hor : this.hor;
this.left = this.ver === 0 ? this.grid.ver : this.ver;
this.borderColor = this.grid.borderColor;
this.grid.children.push(this);
this.width = this.grid.width;
},
beforeDestroy() {
this.grid.children.forEach((item, index) => {
if (item === this) {
this.grid.children.splice(index, 1);
}
});
},
methods: {
_onClick() {
this.grid.change({
detail: {
index: this.index
}
});
}
}
};
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
return common_vendor.e({
a: $data.width
}, $data.width ? {
b: $data.showBorder ? 1 : "",
c: $data.showBorder && $props.index < $data.column ? 1 : "",
d: $data.highlight ? 1 : "",
e: $data.borderColor,
f: $data.borderColor,
g: $data.borderColor,
h: common_vendor.o((...args) => $options._onClick && $options._onClick(...args)),
i: common_vendor.s("width:" + $data.width + ";" + ($data.square ? "height:" + $data.width : ""))
} : {});
}
const Component = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render], ["__scopeId", "data-v-7a807eb7"]]);
wx.createComponent(Component);
//# sourceMappingURL=../../../../../.sourcemap/mp-weixin/uni_modules/uni-grid/components/uni-grid-item/uni-grid-item.js.map

View File

@@ -0,0 +1,4 @@
{
"component": true,
"usingComponents": {}
}

View File

@@ -0,0 +1 @@
<view wx:if="{{a}}" style="{{i}}" class="uni-grid-item data-v-7a807eb7"><view class="{{[b && 'uni-grid-item--border', c && 'uni-grid-item--border-top', d && 'uni-highlight', 'uni-grid-item__box', 'data-v-7a807eb7']}}" style="{{'border-right-color:' + e + ';' + ('border-bottom-color:' + f) + ';' + ('border-top-color:' + g)}}" bindtap="{{h}}"><slot/></view></view>

View File

@@ -0,0 +1,50 @@
/**
* 这里是uni-app内置的常用样式变量
*
* uni-app 官方扩展插件及插件市场https://ext.dcloud.net.cn上很多三方插件均使用了这些样式变量
* 如果你是插件开发者建议你使用scss预处理并在插件代码中直接使用这些变量无需 import 这个文件方便用户通过搭积木的方式开发整体风格一致的App
*
*/
/**
* 如果你是App开发者插件使用者你可以通过修改这些变量来定制自己的插件主题实现自定义主题功能
*
* 如果你的项目同样使用了scss预处理你也可以直接在你的 scss 代码中使用如下变量,同时无需 import 这个文件
*/
/* 颜色变量 */
/* 行为相关颜色 */
/* 文字基本颜色 */
/* 背景颜色 */
/* 边框颜色 */
/* 尺寸变量 */
/* 文字尺寸 */
/* 图片尺寸 */
/* Border Radius */
/* 水平间距 */
/* 垂直间距 */
/* 透明度 */
/* 文章场景相关 */
.uni-grid-item.data-v-7a807eb7 {
height: 100%;
display: flex;
}
.uni-grid-item__box.data-v-7a807eb7 {
display: flex;
width: 100%;
position: relative;
flex: 1;
flex-direction: column;
}
.uni-grid-item--border.data-v-7a807eb7 {
position: relative;
z-index: 0;
border-bottom: 1px #D2D2D2 solid;
border-right: 1px #D2D2D2 solid;
}
.uni-grid-item--border-top.data-v-7a807eb7 {
position: relative;
border-top: 1px #D2D2D2 solid;
z-index: 0;
}
.uni-highlight.data-v-7a807eb7:active {
background-color: #f1f1f1;
}

View File

@@ -0,0 +1,82 @@
"use strict";
const common_vendor = require("../../../../common/vendor.js");
const _sfc_main = {
name: "UniGrid",
emits: ["change"],
props: {
// 每列显示个数
column: {
type: Number,
default: 3
},
// 是否显示边框
showBorder: {
type: Boolean,
default: true
},
// 边框颜色
borderColor: {
type: String,
default: "#D2D2D2"
},
// 是否正方形显示,默认为 true
square: {
type: Boolean,
default: true
},
highlight: {
type: Boolean,
default: true
}
},
provide() {
return {
grid: this
};
},
data() {
const elId = `Uni_${Math.ceil(Math.random() * 1e6).toString(36)}`;
return {
elId,
width: 0
};
},
created() {
this.children = [];
},
mounted() {
this.$nextTick(() => {
this.init();
});
},
methods: {
init() {
setTimeout(() => {
this._getSize((width) => {
this.children.forEach((item, index) => {
item.width = width;
});
});
}, 50);
},
change(e) {
this.$emit("change", e);
},
_getSize(fn) {
common_vendor.index.createSelectorQuery().in(this).select(`#${this.elId}`).boundingClientRect().exec((ret) => {
this.width = parseInt((ret[0].width - 1) / this.column) + "px";
fn(this.width);
});
}
}
};
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
return {
a: $data.elId,
b: $props.showBorder ? 1 : "",
c: $props.borderColor
};
}
const Component = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render], ["__scopeId", "data-v-07acefee"]]);
wx.createComponent(Component);
//# sourceMappingURL=../../../../../.sourcemap/mp-weixin/uni_modules/uni-grid/components/uni-grid/uni-grid.js.map

View File

@@ -0,0 +1,4 @@
{
"component": true,
"usingComponents": {}
}

View File

@@ -0,0 +1 @@
<view class="uni-grid-wrap data-v-07acefee"><view id="{{a}}" ref="uni-grid" class="{{['uni-grid', 'data-v-07acefee', b && 'uni-grid--border']}}" style="{{'border-left-color:' + c}}"><slot/></view></view>

View File

@@ -0,0 +1,40 @@
/**
* 这里是uni-app内置的常用样式变量
*
* uni-app 官方扩展插件及插件市场https://ext.dcloud.net.cn上很多三方插件均使用了这些样式变量
* 如果你是插件开发者建议你使用scss预处理并在插件代码中直接使用这些变量无需 import 这个文件方便用户通过搭积木的方式开发整体风格一致的App
*
*/
/**
* 如果你是App开发者插件使用者你可以通过修改这些变量来定制自己的插件主题实现自定义主题功能
*
* 如果你的项目同样使用了scss预处理你也可以直接在你的 scss 代码中使用如下变量,同时无需 import 这个文件
*/
/* 颜色变量 */
/* 行为相关颜色 */
/* 文字基本颜色 */
/* 背景颜色 */
/* 边框颜色 */
/* 尺寸变量 */
/* 文字尺寸 */
/* 图片尺寸 */
/* Border Radius */
/* 水平间距 */
/* 垂直间距 */
/* 透明度 */
/* 文章场景相关 */
.uni-grid-wrap.data-v-07acefee {
display: flex;
flex: 1;
flex-direction: column;
}
.uni-grid.data-v-07acefee {
display: flex;
flex-direction: row;
flex-wrap: wrap;
}
.uni-grid--border.data-v-07acefee {
position: relative;
z-index: 1;
border-left: 1px #D2D2D2 solid;
}