样式暂时确认版本

This commit is contained in:
2026-03-27 18:08:08 +08:00
parent 6244c7ac0a
commit 6e07cab51f
50 changed files with 106 additions and 1141 deletions
@@ -1,31 +0,0 @@
"use strict";
const uni_modules_uviewPro_components_common_props = require("../common/props.js");
const SubsectionProps = {
...uni_modules_uviewPro_components_common_props.baseProps,
/** tab的数据 */
list: { type: Array, default: () => [] },
/** 当前活动的tab的index */
current: { type: [Number, String], default: 0 },
/** 激活的颜色 */
activeColor: { type: String, default: "var(--u-main-color)" },
/** 未激活的颜色 */
inactiveColor: { type: String, default: "var(--u-content-color)" },
/** 模式选择,mode=button为按钮形式,mode=subsection时为分段模式 */
mode: { type: String, default: "button" },
/** 字体大小,单位rpx */
fontSize: { type: [Number, String], default: 28 },
/** 是否开启动画效果 */
animation: { type: Boolean, default: true },
/** 组件的高度,单位rpx */
height: { type: [Number, String], default: 70 },
/** 激活tab的字体是否加粗 */
bold: { type: Boolean, default: true },
/** mode=button时,组件背景颜色 */
bgColor: { type: String, default: "var(--u-divider-color)" },
/** mode = button时,滑块背景颜色 */
buttonColor: { type: String, default: "var(--u-bg-white)" },
/** 在切换分段器的时候,是否让设备震一下 */
vibrateShort: { type: Boolean, default: false }
};
exports.SubsectionProps = SubsectionProps;
//# sourceMappingURL=../../../../../.sourcemap/mp-weixin/uni_modules/uview-pro/components/u-subsection/types.js.map
@@ -1,228 +0,0 @@
"use strict";
const common_vendor = require("../../../../common/vendor.js");
const uni_modules_uviewPro_libs_index = require("../../libs/index.js");
require("../../libs/util/logger.js");
require("../../libs/config/theme-tokens.js");
const uni_modules_uviewPro_components_uSubsection_types = require("./types.js");
const __default__ = {
name: "u-subsection",
options: {
addGlobalClass: true,
virtualHost: true,
styleIsolation: "shared"
}
};
const _sfc_main = /* @__PURE__ */ common_vendor.defineComponent({
...__default__,
props: uni_modules_uviewPro_components_uSubsection_types.SubsectionProps,
emits: ["change"],
setup(__props, { emit: __emit }) {
const props = __props;
const emit = __emit;
const listInfo = common_vendor.ref([]);
const itemBgStyle = common_vendor.ref({
width: 0,
left: 0,
backgroundColor: "var(--u-bg-white)",
height: "100%",
transition: ""
});
const currentIndex = common_vendor.ref(Number(props.current));
const buttonPadding = 3;
const borderRadius = 5;
const firstTimeVibrateShort = common_vendor.ref(true);
const instanceId = uni_modules_uviewPro_libs_index.$u.guid();
const instance = common_vendor.getCurrentInstance();
common_vendor.watch(
() => props.current,
(nVal) => {
currentIndex.value = Number(nVal);
changeSectionStatus(currentIndex.value);
},
{ immediate: true }
);
common_vendor.watch(
() => props.list,
() => {
if (!props.list || !props.list.length)
return;
initListInfo();
common_vendor.nextTick$1(() => {
setTimeout(() => {
getTabsInfo();
}, 10);
});
},
{ deep: true, immediate: true }
);
common_vendor.watch(
() => props.mode,
() => {
common_vendor.nextTick$1(() => {
setTimeout(() => {
getTabsInfo();
}, 10);
});
}
);
function initListInfo() {
listInfo.value = props.list.map((val) => {
if (typeof val !== "object") {
return { width: 0, name: val };
} else {
return { ...val, width: 0 };
}
});
}
const noBorderRight = common_vendor.computed(() => {
return (index) => {
if (props.mode !== "subsection")
return "";
let classs = "";
if (index < props.list.length - 1)
classs += " u-none-border-right";
if (index === 0)
classs += " u-item-first";
if (index === props.list.length - 1)
classs += " u-item-last";
return classs;
};
});
const textStyle = common_vendor.computed(() => {
return (index) => {
const style = {};
if (props.mode === "subsection") {
style.color = index === currentIndex.value ? "var(--u-white-color)" : props.activeColor;
} else {
style.color = index === currentIndex.value ? props.activeColor : props.inactiveColor;
}
if (index === currentIndex.value && props.bold)
style.fontWeight = "bold";
style.fontSize = props.fontSize + "rpx";
return style;
};
});
const itemStyle = common_vendor.computed(() => {
return (index) => {
const style = {};
if (props.mode === "subsection") {
style.borderColor = props.activeColor;
style.borderWidth = "1px";
style.borderStyle = "solid";
}
return style;
};
});
const subsectionStyle = common_vendor.computed(() => {
const style = {};
style.height = common_vendor.index.upx2px(Number(props.height)) + "px";
if (props.mode === "button") {
style.backgroundColor = props.bgColor;
style.padding = `${buttonPadding}px`;
style.borderRadius = `${borderRadius}px`;
}
return style;
});
const itemBarStyle = common_vendor.computed(() => {
const style = {};
style.backgroundColor = props.activeColor;
style.zIndex = 1;
if (props.mode === "button") {
style.backgroundColor = props.buttonColor;
style.borderRadius = `${borderRadius}px`;
style.bottom = `${buttonPadding}px`;
style.height = common_vendor.index.upx2px(Number(props.height)) - buttonPadding * 2 + "px";
style.zIndex = 0;
}
return Object.assign({}, itemBgStyle.value, style);
});
function changeSectionStatus(nVal) {
if (props.mode === "subsection") {
if (nVal === props.list.length - 1) {
itemBgStyle.value.borderRadius = `0 ${buttonPadding}px ${buttonPadding}px 0`;
}
if (nVal === 0) {
itemBgStyle.value.borderRadius = `${buttonPadding}px 0 0 ${buttonPadding}px`;
}
if (nVal > 0 && nVal < props.list.length - 1) {
itemBgStyle.value.borderRadius = "0";
}
}
setTimeout(() => {
itemBgLeft();
}, 10);
if (props.vibrateShort && !firstTimeVibrateShort.value) {
common_vendor.index.vibrateShort();
}
firstTimeVibrateShort.value = false;
}
function click(index) {
if (index === currentIndex.value)
return;
currentIndex.value = index;
changeSectionStatus(index);
emit("change", index);
}
function getTabsInfo() {
const view = common_vendor.index.createSelectorQuery().in(instance == null ? void 0 : instance.proxy);
for (let i = 0; i < props.list.length; i++) {
view.select(`#${instanceId} .u-item-${i}`).boundingClientRect();
}
view.exec((res) => {
var _a;
if (!res.length) {
setTimeout(() => {
getTabsInfo();
return;
}, 10);
}
res.map((val, index) => {
listInfo.value[index].width = val.width;
});
if (props.mode === "subsection" || props.mode === "button") {
itemBgStyle.value.width = ((_a = listInfo.value[0]) == null ? void 0 : _a.width) + "px";
}
itemBgLeft();
});
}
function itemBgLeft() {
if (props.animation) {
itemBgStyle.value.transition = "all 0.35s";
} else {
itemBgStyle.value.transition = "all 0s";
}
let left = 0;
listInfo.value.forEach((val, index) => {
if (index < currentIndex.value)
left += val.width ?? 0;
});
if (props.mode === "subsection") {
itemBgStyle.value.left = left + "px";
} else if (props.mode === "button") {
itemBgStyle.value.left = left + buttonPadding + "px";
}
}
return (_ctx, _cache) => {
return {
a: common_vendor.f(listInfo.value, (item, index, i0) => {
return {
a: common_vendor.t(item.name),
b: common_vendor.s(textStyle.value(index)),
c: common_vendor.s(itemStyle.value(index)),
d: common_vendor.o(($event) => click(index), index),
e: common_vendor.n(noBorderRight.value(index)),
f: common_vendor.n(`u-item-${index}`),
g: index
};
}),
b: common_vendor.s(itemBarStyle.value),
c: common_vendor.unref(instanceId),
d: common_vendor.n(_ctx.customClass),
e: common_vendor.s(common_vendor.unref(uni_modules_uviewPro_libs_index.$u).toStyle(subsectionStyle.value, _ctx.customStyle))
};
};
}
});
const Component = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-28418ae2"]]);
wx.createComponent(Component);
//# sourceMappingURL=../../../../../.sourcemap/mp-weixin/uni_modules/uview-pro/components/u-subsection/u-subsection.js.map
@@ -1,4 +0,0 @@
{
"component": true,
"usingComponents": {}
}
@@ -1 +0,0 @@
<view id="{{c}}" class="{{['u-subsection', 'data-v-28418ae2', d]}}" style="{{e}}"><view wx:for="{{a}}" wx:for-item="item" wx:key="g" style="{{item.c}}" bindtap="{{item.d}}" class="{{['u-item', 'u-line-1', 'data-v-28418ae2', item.e, item.f]}}"><view style="{{item.b}}" class="u-item-text u-line-1 data-v-28418ae2">{{item.a}}</view></view><view class="u-item-bg data-v-28418ae2" style="{{b}}"></view></view>
@@ -1,114 +0,0 @@
/**
* 这里是uni-app内置的常用样式变量
*
* uni-app 官方扩展插件及插件市场(https://ext.dcloud.net.cn)上很多三方插件均使用了这些样式变量
* 如果你是插件开发者,建议你使用scss预处理,并在插件代码中直接使用这些变量(无需 import 这个文件),方便用户通过搭积木的方式开发整体风格一致的App
*
*/
/**
* 如果你是App开发者(插件使用者),你可以通过修改这些变量来定制自己的插件主题,实现自定义主题功能
*
* 如果你的项目同样使用了scss预处理,你也可以直接在你的 scss 代码中使用如下变量,同时无需 import 这个文件
*/
.data-v-28418ae2:root,
page.data-v-28418ae2 {
/* 纯色 */
--u-white-color: #ffffff;
--u-black-color: #000000;
--u-main-color: #303133;
--u-content-color: #606266;
--u-tips-color: #909399;
--u-light-color: #c0c4cc;
--u-border-color: #e4e7ed;
--u-divider-color: #e4e7ed;
--u-mask-color: rgba(0, 0, 0, 0.4);
--u-shadow-color: rgba(0, 0, 0, 0.1);
/* 背景色 */
--u-bg-color: #f3f4f6;
--u-bg-white: #ffffff;
--u-bg-gray-light: #f1f1f1;
--u-bg-gray-dark: #2f343c;
--u-bg-black: #000000;
/* 主色 */
--u-type-primary: #17447a;
--u-type-primary-light: #d5dde7;
--u-type-primary-disabled: #8fa6c3;
--u-type-primary-dark: #123662;
/* 警告色 */
--u-type-warning: #ff9900;
--u-type-warning-disabled: #fcbd71;
--u-type-warning-dark: #f29100;
--u-type-warning-light: #fdf6ec;
/* 成功色 */
--u-type-success: #19be6b;
--u-type-success-disabled: #71d5a1;
--u-type-success-dark: #18b566;
--u-type-success-light: #dbf1e1;
/* 错误色 */
--u-type-error: #fa3534;
--u-type-error-disabled: #fab6b6;
--u-type-error-dark: #dd6161;
--u-type-error-light: #fef0f0;
/* 信息色 */
--u-type-info: #909399;
--u-type-info-disabled: #c8c9cc;
--u-type-info-dark: #82848a;
--u-type-info-light: #f4f4f5;
}
/* 颜色变量 */
/* 行为相关颜色 */
/* 文字基本颜色 */
/* 背景颜色 */
/* 边框颜色 */
/* 尺寸变量 */
/* 文字尺寸 */
/* 图片尺寸 */
/* Border Radius */
/* 水平间距 */
/* 垂直间距 */
/* 透明度 */
/* 文章场景相关 */
.u-subsection.data-v-28418ae2 {
display: flex;
flex-direction: row;
align-items: center;
overflow: hidden;
position: relative;
}
.u-item.data-v-28418ae2 {
flex: 1;
text-align: center;
font-size: 26rpx;
height: 100%;
display: flex;
flex-direction: row;
align-items: center;
justify-content: center;
color: var(--u-main-color);
padding: 0 6rpx;
}
.u-item-bg.data-v-28418ae2 {
background-color: var(--u-type-primary);
position: absolute;
z-index: -1;
}
.u-none-border-right.data-v-28418ae2 {
border-right: none !important;
}
.u-item-first.data-v-28418ae2 {
border-top-left-radius: 8rpx;
border-bottom-left-radius: 8rpx;
}
.u-item-last.data-v-28418ae2 {
border-top-right-radius: 8rpx;
border-bottom-right-radius: 8rpx;
}
.u-item-text.data-v-28418ae2 {
transition: all 0.35s;
color: var(--u-main-color);
display: flex;
flex-direction: row;
align-items: center;
position: relative;
z-index: 3;
}