From 3282e95db0207ee133d1e98d9771dec9d83b0fc4 Mon Sep 17 00:00:00 2001
From: riku <risaku@163.com>
Date: 星期四, 02 四月 2026 16:24:38 +0800
Subject: [PATCH] 2026.4.2 新增专题管理功能
---
miniprogram_npm/tdesign-miniprogram/navbar/navbar.js | 156 ---------------------------------------------------
1 files changed, 1 insertions(+), 155 deletions(-)
diff --git a/miniprogram_npm/tdesign-miniprogram/navbar/navbar.js b/miniprogram_npm/tdesign-miniprogram/navbar/navbar.js
index 0355032..bf3b0a9 100644
--- a/miniprogram_npm/tdesign-miniprogram/navbar/navbar.js
+++ b/miniprogram_npm/tdesign-miniprogram/navbar/navbar.js
@@ -1,155 +1 @@
-var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
- return c > 3 && r && Object.defineProperty(target, key, r), r;
-};
-import { SuperComponent, wxComponent } from '../common/src/index';
-import { getRect } from '../common/utils';
-import config from '../common/config';
-import props from './props';
-const { prefix } = config;
-const name = `${prefix}-navbar`;
-let Navbar = class Navbar extends SuperComponent {
- constructor() {
- super(...arguments);
- this.externalClasses = [
- `${prefix}-class`,
- `${prefix}-class-placeholder`,
- `${prefix}-class-content`,
- `${prefix}-class-title`,
- `${prefix}-class-left`,
- `${prefix}-class-center`,
- `${prefix}-class-left-icon`,
- `${prefix}-class-home-icon`,
- `${prefix}-class-capsule`,
- `${prefix}-class-nav-btn`,
- ];
- this.timer = null;
- this.options = {
- multipleSlots: true,
- };
- this.properties = props;
- this.observers = {
- visible(visible) {
- const { animation } = this.properties;
- const visibleClass = `${name}${visible ? '--visible' : '--hide'}`;
- this.setData({
- visibleClass: `${visibleClass}${animation ? '-animation' : ''}`,
- });
- if (this.timer) {
- clearTimeout(this.timer);
- }
- if (animation) {
- this.timer = setTimeout(() => {
- this.setData({
- visibleClass,
- });
- }, 300);
- }
- },
- 'title,titleMaxLength'() {
- const { title } = this.properties;
- const titleMaxLength = this.properties.titleMaxLength || Number.MAX_SAFE_INTEGER;
- let temp = title.slice(0, titleMaxLength);
- if (titleMaxLength < title.length)
- temp += '...';
- this.setData({
- showTitle: temp,
- });
- },
- };
- this.data = {
- prefix,
- classPrefix: name,
- boxStyle: '',
- showTitle: '',
- hideLeft: false,
- hideCenter: false,
- };
- this.methods = {
- queryElements(capsuleRect) {
- Promise.all([
- getRect(this, `.${this.data.classPrefix}__left`),
- getRect(this, `.${this.data.classPrefix}__center`),
- ]).then(([leftRect, centerRect]) => {
- if (leftRect.right > capsuleRect.left) {
- this.setData({
- hideLeft: true,
- hideCenter: true,
- });
- }
- else if (centerRect.right > capsuleRect.left) {
- this.setData({
- hideLeft: false,
- hideCenter: true,
- });
- }
- else {
- this.setData({
- hideLeft: false,
- hideCenter: false,
- });
- }
- });
- },
- goBack() {
- const { delta } = this.data;
- const that = this;
- this.triggerEvent('go-back');
- if (delta > 0) {
- wx.navigateBack({
- delta,
- fail(e) {
- that.triggerEvent('fail', e);
- },
- complete(e) {
- that.triggerEvent('complete', e);
- },
- success(e) {
- that.triggerEvent('success', e);
- },
- });
- }
- },
- };
- }
- attached() {
- let rect = null;
- if (wx.getMenuButtonBoundingClientRect) {
- rect = wx.getMenuButtonBoundingClientRect();
- }
- if (!rect)
- return;
- wx.getSystemInfo({
- success: (res) => {
- const boxStyleList = [];
- boxStyleList.push(`--td-navbar-padding-top: ${res.statusBarHeight}px`);
- if (rect && (res === null || res === void 0 ? void 0 : res.windowWidth)) {
- boxStyleList.push(`--td-navbar-right: ${res.windowWidth - rect.left}px`);
- }
- boxStyleList.push(`--td-navbar-capsule-height: ${rect.height}px`);
- boxStyleList.push(`--td-navbar-capsule-width: ${rect.width}px`);
- boxStyleList.push(`--td-navbar-height: ${(rect.top - res.statusBarHeight) * 2 + rect.height}px`);
- this.setData({
- boxStyle: `${boxStyleList.join('; ')}`,
- });
- if (wx.onMenuButtonBoundingClientRectWeightChange) {
- wx.onMenuButtonBoundingClientRectWeightChange((res) => this.queryElements(res));
- }
- },
- fail: (err) => {
- console.error('navbar 鑾峰彇绯荤粺淇℃伅澶辫触', err);
- },
- });
- }
- detached() {
- if (wx.offMenuButtonBoundingClientRectWeightChange) {
- wx.offMenuButtonBoundingClientRectWeightChange((res) => this.queryElements(res));
- }
- }
-};
-Navbar = __decorate([
- wxComponent()
-], Navbar);
-export default Navbar;
+import{__decorate}from"tslib";import{SuperComponent,wxComponent}from"../common/src/index";import{getRect,systemInfo}from"../common/utils";import config from"../common/config";import props from"./props";const{prefix:prefix}=config,name=`${prefix}-navbar`;let Navbar=class extends SuperComponent{constructor(){super(...arguments),this.externalClasses=[`${prefix}-class`,`${prefix}-class-placeholder`,`${prefix}-class-content`,`${prefix}-class-title`,`${prefix}-class-left`,`${prefix}-class-center`,`${prefix}-class-left-icon`,`${prefix}-class-home-icon`,`${prefix}-class-capsule`,`${prefix}-class-nav-btn`],this.timer=null,this.options={multipleSlots:!0},this.properties=props,this.observers={visible(t){const{animation:e}=this.properties,i=`${name}${t?"--visible":"--hide"}`;this.setData({visibleClass:`${i}${e?"-animation":""}`}),this.timer&&clearTimeout(this.timer),e&&(this.timer=setTimeout(()=>{this.setData({visibleClass:i})},300))},"title,titleMaxLength"(){const{title:t}=this.properties,e=this.properties.titleMaxLength||Number.MAX_SAFE_INTEGER;let i=t.slice(0,e);e<t.length&&(i+="..."),this.setData({showTitle:i})}},this.data={prefix:prefix,classPrefix:name,boxStyle:"",showTitle:"",hideLeft:!1,hideCenter:!1,_menuRect:null,_leftRect:null,_boxStyle:{}},this.methods={initStyle(){this.getMenuRect();const{_menuRect:t,_leftRect:e}=this.data;if(!t||!e||!systemInfo)return;const i={"--td-navbar-padding-top":`${systemInfo.statusBarHeight}px`,"--td-navbar-right":systemInfo.windowWidth-t.left+"px","--td-navbar-left-max-width":`${t.left}px`,"--td-navbar-capsule-height":`${t.height}px`,"--td-navbar-capsule-width":`${t.width}px`,"--td-navbar-height":`${2*(t.top-systemInfo.statusBarHeight)+t.height}px`};this.calcCenterStyle(e,t,i)},calcCenterStyle(t,e,i){const n=Math.max(t.right,systemInfo.windowWidth-e.left),s=Object.assign(Object.assign({},i),{"--td-navbar-center-left":`${n}px`,"--td-navbar-center-width":`${Math.max(e.left-n,0)}px`}),a=Object.entries(s).map(([t,e])=>`${t}: ${e}`).join("; ");this.setData({boxStyle:a,_boxStyle:s})},getLeftRect(){getRect(this,`.${name}__left`).then(t=>{t.right>this.data._leftRect.right&&this.calcCenterStyle(t,this.data._menuRect,this.data._boxStyle)})},getMenuRect(){if(wx.getMenuButtonBoundingClientRect){const t=wx.getMenuButtonBoundingClientRect();this.setData({_menuRect:t,_leftRect:{right:systemInfo.windowWidth-t.left}})}},onMenuButtonBoundingClientRectWeightChange(){wx.onMenuButtonBoundingClientRectWeightChange&&(this.onMenuButtonBoundingClientRectWeightChangeCallback=t=>this.queryElements(t),wx.onMenuButtonBoundingClientRectWeightChange(this.onMenuButtonBoundingClientRectWeightChangeCallback))},offMenuButtonBoundingClientRectWeightChange(){this.onMenuButtonBoundingClientRectWeightChangeCallback&&wx.offMenuButtonBoundingClientRectWeightChange(this.onMenuButtonBoundingClientRectWeightChangeCallback)},queryElements(t){Promise.all([getRect(this,`.${this.data.classPrefix}__left`),getRect(this,`.${this.data.classPrefix}__center`)]).then(([e,i])=>{const n=Math.round(e.right),s=Math.round(i.right),a=t.left;this.setData({hideLeft:n>a,hideCenter:n>a||s>a})})},goBack(){const{delta:t}=this.data,e=this;this.triggerEvent("go-back"),t>0&&wx.navigateBack({delta:t,fail(t){e.triggerEvent("fail",t)},complete(t){e.triggerEvent("complete",t)},success(t){e.triggerEvent("success",t)}})}}}attached(){this.initStyle(),this.getLeftRect(),this.onMenuButtonBoundingClientRectWeightChange()}detached(){this.offMenuButtonBoundingClientRectWeightChange()}};Navbar=__decorate([wxComponent()],Navbar);export default Navbar;
\ No newline at end of file
--
Gitblit v1.9.3