Skip to content

Commit cb9c8a9

Browse files
committed
fix(uni-app-x web): 修复条件编译错误导致cjs版依赖UniElement的Bug
1 parent 4a03a1c commit cb9c8a9

File tree

8 files changed

+147
-351
lines changed

8 files changed

+147
-351
lines changed

packages/uni-components/lib-x/unicloud-db/unicloud-db.vue

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,8 @@
110110
}
111111
//#endif
112112
//#ifdef WEB || APP-IOS
113-
export class UniCloudDBElement extends UniElementImpl {
113+
const RealUniElementImpl = typeof UniElementImpl === 'undefined' ? class {} : UniElementImpl
114+
export class /*#__PURE__*/ UniCloudDBElement extends RealUniElementImpl {
114115
constructor(data : INodeData, pageNode : PageNode) {
115116
super(data, pageNode);
116117
const TagName = 'UNICLOUD-DB';
@@ -198,10 +199,12 @@
198199
199200
export default {
200201
name: 'UniCloudDB',
202+
//#if !_NODE_JS_
201203
rootElement: {
202204
name: 'uni-cloud-db-element',
203205
class: UniCloudDBElement
204206
},
207+
//#endif
205208
slots: Object as SlotsType<{
206209
default : {
207210
data : Array<UTSJSONObject>,
@@ -303,7 +306,7 @@
303306
error: null as UniCloudError | null
304307
}
305308
},
306-
//#ifdef WEB || APP-IOS
309+
//#ifdef (WEB || APP-IOS) && !_NODE_JS_
307310
beforeCreate() {
308311
if (!registerFlag) {
309312
registerFlag = true

packages/uni-components/src/vue/button/index.tsx

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
import { inject, onBeforeUnmount, ref, onMounted } from 'vue'
2-
import { useI18n, initI18nButtonMsgsOnce } from '@dcloudio/uni-core'
1+
import { inject, onBeforeUnmount, onMounted, ref } from 'vue'
2+
import { initI18nButtonMsgsOnce, useI18n } from '@dcloudio/uni-core'
33
import { defineBuiltInComponent } from '../../helpers/component'
44
import { useHover } from '../../helpers/useHover'
55
import { useBooleanAttr } from '../../helpers/useBooleanAttr'
66
import { withWebEvent } from '../../helpers/useEvent'
7-
import { UniFormCtx, uniFormKey } from '../form'
8-
import { uniLabelKey, UniLabelCtx } from '../label'
7+
import { type UniFormCtx, uniFormKey } from '../form'
8+
import { type UniLabelCtx, uniLabelKey } from '../label'
99
import { useListeners } from '../../helpers/useListeners'
1010
import { buttonProps } from '../../components/button'
1111
import { UniElement } from '../../helpers/UniElement'
@@ -102,7 +102,6 @@ export default /*#__PURE__*/ defineBuiltInComponent({
102102

103103
function openFeedback(titleText: string, sendText: string) {
104104
const feedback = plus.webview.create(
105-
// @ts-ignore
106105
'https://service.dcloud.net.cn/uniapp/feedback.html',
107106
'feedback',
108107
{

packages/uni-components/src/vue/slider/index-x.tsx

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,13 @@ import { computed, inject, onBeforeUnmount, onMounted, ref, watch } from 'vue'
22
import type { ExtractPropTypes, Ref } from 'vue'
33
import { defineBuiltInComponent } from '../../helpers/component'
44
import { UniElement } from '../../helpers/UniElement'
5-
import { useCustomEvent, withWebEvent } from '../../helpers/useEvent'
6-
import type { CustomEventTrigger, EmitEvent } from '../../helpers/useEvent'
7-
import { uniFormKey } from '../form'
8-
import type { UniFormCtx } from '../form'
5+
import {
6+
type CustomEventTrigger,
7+
type EmitEvent,
8+
useCustomEvent,
9+
withWebEvent,
10+
} from '../../helpers/useEvent'
11+
import { type UniFormCtx, uniFormKey } from '../form'
912

1013
const SLIDER_BLOCK_SIZE_MIN_VALUE = 12
1114
const SLIDER_BLOCK_SIZE_MAX_VALUE = 28
@@ -139,10 +142,12 @@ export default /*#__PURE__*/ defineBuiltInComponent({
139142
name: 'Slider',
140143
props,
141144
emits: ['changing', 'change'],
145+
//#if _X_ && !_NODE_JS_
142146
rootElement: {
143147
name: 'uni-slider',
144148
class: UniSliderElement,
145149
},
150+
//#endif
146151
setup(props, { emit }) {
147152
const sliderRef: HTMLRef = ref(null)
148153
const sliderValueRef: HTMLRef = ref(null)

packages/uni-components/src/vue/slider/index.tsx

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,18 @@
1-
import { computed, inject, onMounted, onBeforeUnmount, ref, watch } from 'vue'
1+
import { computed, inject, onBeforeUnmount, onMounted, ref, watch } from 'vue'
22
import type { ExtractPropTypes, Ref } from 'vue'
33
import { defineBuiltInComponent } from '../../helpers/component'
4-
import { useTouchtrack, TouchtrackEvent } from '../../helpers/useTouchtrack'
4+
import {
5+
type TouchtrackEvent,
6+
useTouchtrack,
7+
} from '../../helpers/useTouchtrack'
58
import { UniElement } from '../../helpers/UniElement'
69
import {
7-
CustomEventTrigger,
10+
type CustomEventTrigger,
11+
type EmitEvent,
812
useCustomEvent,
9-
EmitEvent,
1013
withWebEvent,
1114
} from '../../helpers/useEvent'
12-
import { UniFormCtx, uniFormKey } from '../form'
15+
import { type UniFormCtx, uniFormKey } from '../form'
1316

1417
const props = {
1518
name: {
@@ -74,7 +77,7 @@ export default /*#__PURE__*/ defineBuiltInComponent({
7477
name: 'Slider',
7578
props,
7679
emits: ['changing', 'change'],
77-
//#if _X_ && !_NODE_JS_ /* 仅限X项目以及非SSR环境,使用条件编译,可以尽量减少其他平台生成多余的代码 */
80+
//#if _X_ && !_NODE_JS_
7881
rootElement: {
7982
name: 'uni-slider',
8083
class: UniSliderElement,

0 commit comments

Comments
 (0)