Commit 40767b2aaba488647d68e41f9fa987099a009cee

Authored by xp.Huang
2 parents 7805b31c 1d119818

Merge branch 'fix/DEFECT-1349' into 'main_dev'

fix: DEFECT-1349修复切换组件后未将设备属性置空

See merge request yunteng/thingskit-front!646
... ... @@ -28,6 +28,7 @@
28 28 import { useGetComponentConfig } from '../packages/hook/useGetComponetConfig';
29 29 import { MessageAlert } from './components/MessageAlert';
30 30 import { createSelectWidgetKeysContext, createSelectWidgetModeContext } from './useContext';
  31 + import { useGetCategoryByComponentKey } from '../packages/hook/useGetCategoryByComponentKey';
31 32
32 33 const props = defineProps<{
33 34 layout: Layout[];
... ... @@ -119,10 +120,16 @@
119 120 */
120 121 watch(
121 122 () => selectWidgetKeys.value.componentKey,
122   - (value) => {
  123 + (value, oldValue) => {
123 124 if (value) {
  125 + const oldCategory = useGetCategoryByComponentKey(oldValue);
  126 + const category = useGetCategoryByComponentKey(value);
  127 + const needReset =
  128 + [oldCategory, category].some((item) => item === PackagesCategoryEnum.CONTROL) &&
  129 + oldCategory !== category;
124 130 dataSource.value = unref(dataSource).map((item) => ({
125 131 ...item,
  132 + ...(needReset ? { attribute: null } : {}),
126 133 componentInfo: { ...unref(getComponentConfig).persetOption, ...item.componentInfo },
127 134 }));
128 135 if ((window as any).requestIdleCallback as unknown as boolean) {
... ...
... ... @@ -48,13 +48,9 @@
48 48 });
49 49
50 50 const getOptions = computed<VideoJsPlayerOptions>(() => {
51   - const { option } = props.config;
52   - const { itemHeightRatio, itemWidthRatio, widthPx, heightPx } = option;
53   - const currentW = widthPx * (itemWidthRatio / 100);
54   - const currentH = heightPx * (itemHeightRatio / 100);
55 51 return {
56   - width: currentW - 8,
57   - height: currentH - 8,
  52 + width: '100%' as unknown as number,
  53 + height: '100%' as unknown as number,
58 54 sources: unref(getVideoPlaySources).src
59 55 ? ([unref(getVideoPlaySources)] as VideoJsPlayerOptions['sources'])
60 56 : [],
... ...
  1 +import { PackagesCategoryEnum } from '../index.type';
  2 +import { packageList } from '../package';
  3 +
  4 +export const useGetCategoryByComponentKey = (componentKey: string) => {
  5 + for (const key of Object.keys(packageList) as PackagesCategoryEnum[]) {
  6 + for (const item of packageList[key]) {
  7 + if (item.key === componentKey) {
  8 + return key;
  9 + }
  10 + }
  11 + }
  12 +};
... ...