@cloudbase/weda-ui 2.0.27 → 2.0.28

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cloudbase/weda-ui",
3
- "version": "2.0.27",
3
+ "version": "2.0.28",
4
4
  "main": "./src/index.js",
5
5
  "module": "./src/index",
6
6
  "miniprogram": "mpdist",
@@ -426,7 +426,7 @@ Component({
426
426
  return { value: item.Value, code: item.Code };
427
427
  }); //保存省级名称
428
428
  this.setData({
429
- multiArray: JSON.parse(JSON.stringify(provinceArr)),
429
+ multiArray: [destr(JSON.stringify(provinceArr))],
430
430
  provinceList, //保存省级原始数据
431
431
  provinceArr, //省级所有的名称
432
432
  });
@@ -460,7 +460,7 @@ Component({
460
460
  if (regionType == 'levelTwo') {
461
461
  const cityData = [this.data.provinceArr, cityArr];
462
462
  this.setData({
463
- multiArray: JSON.parse(JSON.stringify(cityData)),
463
+ multiArray: destr(JSON.stringify(cityData)),
464
464
  });
465
465
  }
466
466
  var defaultCode = cityList[0]?.Code;
@@ -493,7 +493,7 @@ Component({
493
493
  });
494
494
  const threeRegion = [this.data.provinceArr, this.data.cityArr, regionArr];
495
495
  this.setData({
496
- multiArray: JSON.parse(JSON.stringify(threeRegion)),
496
+ multiArray: destr(JSON.stringify(threeRegion)),
497
497
  regionList,
498
498
  regionArr,
499
499
  });
@@ -507,8 +507,8 @@ Component({
507
507
  const { regionType } = this.properties;
508
508
  var column = e.detail.column; // 当前改变的列
509
509
  var data = {
510
- multiIndex: JSON.parse(JSON.stringify(this.data.multiIndex)),
511
- multiArray: JSON.parse(JSON.stringify(this.data.multiArray)),
510
+ multiIndex: destr(JSON.stringify(this.data.multiIndex)),
511
+ multiArray: destr(JSON.stringify(this.data.multiArray)),
512
512
  };
513
513
  data.multiIndex[column] = e.detail.value; // 第几列改变了就是对应multiIndex的第几个,更新它
514
514
  switch (
@@ -1152,7 +1152,7 @@
1152
1152
  .weda-grid-navigation__col--small
1153
1153
  .weda-grid-navigation__icon
1154
1154
  .weda-icon {
1155
- font-size: 3.428571em;
1155
+ font-size: 2.2857em;
1156
1156
  }
1157
1157
  .weda-grid-navigation
1158
1158
  .weda-grid-navigation__col--big
@@ -1,6 +1,6 @@
1
1
  import destr from '../../utils/destr';
2
2
  import { isUrl } from '../../utils/platform';
3
- import { getAppCustomNav } from '../../utils/tcb';
3
+ import { getAppCustomNav, resolveStaticResourceUrl } from '../../utils/tcb';
4
4
 
5
5
  Component({
6
6
  properties: {
@@ -31,6 +31,7 @@ Component({
31
31
  showTitle: true,
32
32
  title: '标题',
33
33
  showLogo: true,
34
+ logoPath: '',
34
35
  logoUrl:
35
36
  'https://imgcache.qq.com/qcloud/tcloud_dtc/static/static_source_business/43d3b2b7-445c-4858-8eb0-50ac5d5cc08e.svg ',
36
37
  titleFontSize: '18',
@@ -59,6 +60,12 @@ Component({
59
60
  } = navigationData;
60
61
  let menus = isMultiTerminal ? mobileMenuData : menuData;
61
62
  let selectedKey = this.defaultSelectedMenu(menus);
63
+ // 从cdn中读取图片
64
+ const logoUrl =
65
+ resolveStaticResourceUrl(navigationStyle.logoPath) ||
66
+ navigationStyle.logoUrl;
67
+ navigationStyle.logoUrl = logoUrl;
68
+
62
69
  this.setData({
63
70
  menuData: this.generateMenuData(
64
71
  menus,
@@ -89,16 +96,20 @@ Component({
89
96
  generateMenuData(menuData, menuItem, init = false) {
90
97
  let menus = JSON.parse(JSON.stringify(menuData));
91
98
  return menus?.map((i) => {
92
- let { iconUrl = 'td:view-module', children } = i;
99
+ let { iconUrl = 'td:view-module', children, iconPath } = i;
93
100
  let iconType = 'image';
94
101
  let ticon = '';
95
- if (!isUrl(iconUrl)) {
102
+ if (isUrl(iconUrl)) {
103
+ // 从cdn中读取图片
104
+ iconUrl = resolveStaticResourceUrl(iconPath) || iconUrl;
105
+ } else {
96
106
  iconType = 'icon';
97
107
  if (iconUrl.includes('td:')) {
98
108
  iconType = 't-icon';
99
109
  ticon = iconUrl?.replace('td:', '');
100
110
  }
101
111
  }
112
+
102
113
  if (init) {
103
114
  i.expand = this.hasSelectedMenu(i, menuItem.key);
104
115
  } else if (i.key === menuItem.key) {
@@ -118,7 +129,7 @@ Component({
118
129
  },
119
130
  menuClick(itemInfo) {
120
131
  const menu = itemInfo?.currentTarget?.dataset?.menu;
121
- const { path, type, key, children, expand } = menu;
132
+ const { path, type, children, expand } = menu;
122
133
  if (children.length) {
123
134
  this.setData({
124
135
  menuData: this.generateMenuData(this.data.menuData, {
@@ -74,3 +74,17 @@ export async function callDataSourceApi(param) {
74
74
  return {};
75
75
  }
76
76
  }
77
+
78
+ /**
79
+ * 返回静态托管cdn域名
80
+ */
81
+ export const resolveStaticResourceUrl = (path) => {
82
+ try {
83
+ // eslint-disable-next-line no-unsafe-optional-chaining
84
+ const resourceUrl =
85
+ getApp()?.app?.__internal__?.resolveStaticResourceUrl(path);
86
+ return resourceUrl;
87
+ } catch (error) {
88
+ return '';
89
+ }
90
+ };
@@ -78,7 +78,7 @@ export function UploaderPCInner(props) {
78
78
  const [progress, setProgress] = React.useState(0);
79
79
  // 文件列表
80
80
  const [fileIDList, setfileIDList] = React.useState([]);
81
- const fileRef = React.useRef(['']);
81
+ const fileRef = React.useRef<string[] | string>([]);
82
82
  React.useEffect(() => {
83
83
  let initialValue = []
84
84
  .concat(defaultValue)
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
- import { IMenuItem, INavigationStyle } from './type';
3
- import { isUrl } from '../../utils/platform';
2
+ import type { IMenuItem, INavigationStyle } from './type';
3
+ import { isUrl, resolveStaticResourceUrl } from '../../utils/platform';
4
4
  import { IconFont } from 'tdesign-icons-react';
5
5
  const CLASS_PREFIX = 'weda-menu';
6
6
 
@@ -30,7 +30,7 @@ export const renderMenuTitle = (
30
30
  hasIcon: boolean
31
31
  ) => {
32
32
  const { menuColor, menuFontSize, showMenuIcon } = navigationStyle;
33
- const { title, level, iconUrl } = item;
33
+ const { title, level, iconUrl, iconPath } = item;
34
34
  return (
35
35
  <span
36
36
  className="menu-text"
@@ -43,7 +43,7 @@ export const renderMenuTitle = (
43
43
  {showMenuIcon &&
44
44
  level === 0 &&
45
45
  hasIcon &&
46
- renderMenuIcon(iconUrl, navigationStyle)}
46
+ renderMenuIcon(iconUrl, iconPath, navigationStyle)}
47
47
  {title}
48
48
  </span>
49
49
  );
@@ -57,14 +57,16 @@ export const renderLogo = (
57
57
  navigationStyle: INavigationStyle,
58
58
  className: string
59
59
  ) => {
60
- const { showLogo, logoHeight, logoWidth, logoUrl } = navigationStyle;
60
+ const { showLogo, logoHeight, logoWidth, logoUrl, logoPath } =
61
+ navigationStyle;
62
+ const src = resolveStaticResourceUrl(logoPath) || logoUrl;
61
63
  return (
62
64
  showLogo && (
63
65
  <img
64
66
  data-testid="navigationBar-logo"
65
67
  className={className}
66
68
  style={{ width: `${logoWidth}px`, height: `${logoHeight}px` }}
67
- src={logoUrl || defaultLogoUrl}
69
+ src={src || defaultLogoUrl}
68
70
  alt="logo"
69
71
  />
70
72
  )
@@ -93,11 +95,14 @@ export const IconShow = ({ onIcon, menuColor, menuFontSize }) => {
93
95
  // 菜单图标
94
96
  export const renderMenuIcon = (
95
97
  iconUrl: string,
98
+ iconPath: string,
96
99
  navigationStyle: INavigationStyle
97
100
  ) => {
98
101
  const { menuColor, menuFontSize } = navigationStyle;
99
102
  let icon = iconUrl || 'td:view-module';
103
+
100
104
  if (iconUrl && isUrl(iconUrl)) {
105
+ icon = resolveStaticResourceUrl(iconPath) || iconUrl;
101
106
  return (
102
107
  <img
103
108
  className={`${CLASS_PREFIX}__item-icon`}
@@ -1,7 +1,7 @@
1
1
  /* eslint-disable react/jsx-key */
2
2
  import React, { useState } from 'react';
3
3
  import { Menu, Drawer } from 'tea-component';
4
- import { IMenuItem, INavigationStyle } from './type';
4
+ import type { IMenuItem, INavigationStyle } from './type';
5
5
  import classNames from '../../utils/classnames';
6
6
  import {
7
7
  renderMenuTitle,
@@ -1,7 +1,7 @@
1
1
  /* eslint-disable react/jsx-key */
2
2
  import React, { useState, useRef, useEffect, useCallback } from 'react';
3
3
  import { NavMenu, List, Dropdown } from 'tea-component';
4
- import { IMenuItem, INavigationStyle } from './type';
4
+ import type { IMenuItem, INavigationStyle } from './type';
5
5
  import { usePlatform } from '../../utils/platform';
6
6
  import classNames from '../../utils/classnames';
7
7
  import {
@@ -157,7 +157,8 @@ const HorizontalMenu: React.FC<{
157
157
  }
158
158
  }}
159
159
  >
160
- {showMenuIcon && renderMenuIcon(i?.iconUrl, navigationStyle)}
160
+ {showMenuIcon &&
161
+ renderMenuIcon(i?.iconUrl, i?.iconPath, navigationStyle)}
161
162
  {i?.children?.length ? (
162
163
  <Dropdown
163
164
  trigger={'hover'}
@@ -32,6 +32,7 @@ const defaultNavigationBar: {
32
32
  showTitle: true,
33
33
  title: '菜单标题',
34
34
  showLogo: true,
35
+ logoPath: '',
35
36
  logoUrl:
36
37
  'https://imgcache.qq.com/qcloud/tcloud_dtc/static/static_source_business/43d3b2b7-445c-4858-8eb0-50ac5d5cc08e.svg',
37
38
  titleFontSize: 18,
@@ -34,7 +34,10 @@ export interface IMenuItem {
34
34
  * 图标链接
35
35
  */
36
36
  iconUrl?: string;
37
-
37
+ /**
38
+ * 图标path
39
+ */
40
+ iconPath?: string;
38
41
  /**
39
42
  * 子菜单
40
43
  */
@@ -92,6 +95,10 @@ export interface INavigationStyle {
92
95
  * 图标地址
93
96
  */
94
97
  logoUrl: string;
98
+ /**
99
+ * 图标path
100
+ */
101
+ logoPath: string;
95
102
  /**
96
103
  * 标题字号
97
104
  */
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
2
  import { Menu } from 'tea-component';
3
- import { IMenuItem, INavigationStyle } from './type';
3
+ import type { IMenuItem, INavigationStyle } from './type';
4
4
  import {
5
5
  renderMenuTitle,
6
6
  renderLogo,
@@ -122,6 +122,20 @@ export const cutFileTitle = (str = '', count = 10) => {
122
122
  */
123
123
  export const isInIde = () => !!window?.app?.cloud?.IS_WEDA_IDE;
124
124
 
125
+ /**
126
+ * 解析素材资源
127
+ */
128
+ export const resolveStaticResourceUrl = (path) => {
129
+ try {
130
+ // eslint-disable-next-line no-unsafe-optional-chaining
131
+ const resourceUrl =
132
+ window?.app?.__internal__?.resolveStaticResourceUrl(path);
133
+ return resourceUrl;
134
+ } catch (error) {
135
+ return '';
136
+ }
137
+ };
138
+
125
139
  /**
126
140
  * cloudid和文件名转换
127
141
  */