Skip to content

Commit d0e7e2e

Browse files
authored
Merge pull request dcloudio#881 from 18148764734:master
feat: 针对抖音小程序virtualHost特别判断
2 parents 64bf4eb + b5a3534 commit d0e7e2e

File tree

24 files changed

+492
-368
lines changed

24 files changed

+492
-368
lines changed

Diff for: pages/index/index.vue

+1-1
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@
169169
url: 'data-picker'
170170
},
171171
// #endif
172-
// #ifndef APP-NVUE || MP-KUAISHOU || MP-LARK || MP-TOUTIAO || MP-BAIDU
172+
// #ifndef APP-NVUE || MP-KUAISHOU || MP-LARK || MP-BAIDU
173173
{
174174
name: 'DatetimePicker 日期时间选择',
175175
url: 'datetime-picker'

Diff for: pages/vue/search-bar/search-bar.vue

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
</uni-card>
66

77
<uni-section title="基本用法" type="line">
8-
<uni-search-bar @confirm="search" :focus="true" v-model="searchValue" @blur="blur" @focus="focus" @input="input" class="search-result-text" @cancel="cancel" @clear="clear" text-color="#ff261d">
8+
<uni-search-bar textColor="#3c35f4" @confirm="search" :focus="true" v-model="searchValue" @blur="blur" @focus="focus" @input="input" class="search-result-text" @cancel="cancel" @clear="clear" text-color="#ff261d">
99
</uni-search-bar>
1010
<view class="search-result">
1111
<text class="search-result-text">当前输入为:{{ searchValue }}</text>

Diff for: uni_modules/uni-breadcrumb/components/uni-breadcrumb-item/uni-breadcrumb-item.vue

+9-4
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,14 @@
2121
return {
2222
currentPage: ""
2323
}
24-
},
25-
options: {
26-
virtualHost: true
24+
},
25+
options: {
26+
// #ifdef MP-TOUTIAO
27+
virtualHost: false,
28+
// #endif
29+
// #ifndef MP-TOUTIAO
30+
virtualHost: true
31+
// #endif
2732
},
2833
props: {
2934
to: {
@@ -113,7 +118,7 @@
113118
&:first-child &--slot {
114119
padding-left: 0;
115120
}
116-
121+
117122
&:last-child &--separator {
118123
display: none;
119124
}

Diff for: uni_modules/uni-breadcrumb/components/uni-breadcrumb/uni-breadcrumb.vue

+5
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,12 @@
1313
*/
1414
export default {
1515
options: {
16+
// #ifdef MP-TOUTIAO
17+
virtualHost: false,
18+
// #endif
19+
// #ifndef MP-TOUTIAO
1620
virtualHost: true
21+
// #endif
1722
},
1823
props: {
1924
separator: {

Diff for: uni_modules/uni-datetime-picker/changelog.md

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
## 2.2.33(2024-04-15)
2+
- 修复 抖音小程序事件传递失效bug
13
## 2.2.32(2024-02-20)
24
- 修复 日历的close事件触发异常的bug [详情](https://github.com/dcloudio/uni-ui/issues/844)
35
## 2.2.31(2024-02-20)

Diff for: uni_modules/uni-datetime-picker/components/uni-datetime-picker/calendar.vue

+87-68
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,8 @@
5858

5959
<view class="uni-calendar__weeks" v-for="(item,weekIndex) in weeks" :key="weekIndex">
6060
<view class="uni-calendar__weeks-item" v-for="(weeks,weeksIndex) in item" :key="weeksIndex">
61-
<calendar-item class="uni-calendar-item--hook" :weeks="weeks" :calendar="calendar"
62-
:selected="selected" :checkHover="range" @change="choiceDate"
63-
@handleMouse="handleMouse">
61+
<calendar-item class="uni-calendar-item--hook" :weeks="weeks" :calendar="calendar" :selected="selected"
62+
:checkHover="range" @change="choiceDate" @handleMouse="handleMouse">
6463
</calendar-item>
6564
</view>
6665
</view>
@@ -101,13 +100,21 @@
101100
</template>
102101

103102
<script>
104-
import { Calendar, getDate, getTime } from './util.js';
103+
import {
104+
Calendar,
105+
getDate,
106+
getTime
107+
} from './util.js';
105108
import calendarItem from './calendar-item.vue'
106109
import timePicker from './time-picker.vue'
107110
108-
import { initVueI18n } from '@dcloudio/uni-i18n'
111+
import {
112+
initVueI18n
113+
} from '@dcloudio/uni-i18n'
109114
import i18nMessages from './i18n/index.js'
110-
const { t } = initVueI18n(i18nMessages)
115+
const {
116+
t
117+
} = initVueI18n(i18nMessages)
111118
112119
/**
113120
* Calendar 日历
@@ -134,6 +141,15 @@
134141
calendarItem,
135142
timePicker
136143
},
144+
145+
options: {
146+
// #ifdef MP-TOUTIAO
147+
virtualHost: false,
148+
// #endif
149+
// #ifndef MP-TOUTIAO
150+
virtualHost: true
151+
// #endif
152+
},
137153
props: {
138154
date: {
139155
type: String,
@@ -163,8 +179,8 @@
163179
type: String,
164180
default: ''
165181
},
166-
startPlaceholder: {
167-
type: String,
182+
startPlaceholder: {
183+
type: String,
168184
default: ''
169185
},
170186
endPlaceholder: {
@@ -210,10 +226,10 @@
210226
}
211227
}
212228
},
213-
defaultValue: {
214-
type: [String, Object, Array],
215-
default: ''
216-
}
229+
defaultValue: {
230+
type: [String, Object, Array],
231+
default: ''
232+
}
217233
},
218234
data() {
219235
return {
@@ -260,7 +276,7 @@
260276
},
261277
startDate(val) {
262278
// 字节小程序 watch 早于 created
263-
if(!this.cale){
279+
if (!this.cale) {
264280
return
265281
}
266282
this.cale.setStartDate(val)
@@ -269,7 +285,7 @@
269285
},
270286
endDate(val) {
271287
// 字节小程序 watch 早于 created
272-
if(!this.cale){
288+
if (!this.cale) {
273289
return
274290
}
275291
this.cale.setEndDate(val)
@@ -278,7 +294,7 @@
278294
},
279295
selected(newVal) {
280296
// 字节小程序 watch 早于 created
281-
if(!this.cale){
297+
if (!this.cale) {
282298
return
283299
}
284300
this.cale.setSelectInfo(this.nowDate.fullDate, newVal)
@@ -309,16 +325,16 @@
309325
this.cale.lastHover = false
310326
}
311327
} else {
312-
// 字节小程序 watch 早于 created
313-
if(!this.cale){
314-
return
315-
}
328+
// 字节小程序 watch 早于 created
329+
if (!this.cale) {
330+
return
331+
}
316332
317333
this.cale.setDefaultMultiple(before, after)
318334
if (which === 'left' && before) {
319335
this.setDate(before)
320336
this.weeks = this.cale.weeks
321-
} else if(after) {
337+
} else if (after) {
322338
this.setDate(after)
323339
this.weeks = this.cale.weeks
324340
}
@@ -423,7 +439,7 @@
423439
},
424440
// 蒙版点击事件
425441
maskClick() {
426-
this.close()
442+
this.close()
427443
this.$emit('maskClose')
428444
},
429445
@@ -454,36 +470,38 @@
454470
* @param {Object} date
455471
*/
456472
init(date) {
457-
// 字节小程序 watch 早于 created
458-
if(!this.cale){
473+
// 字节小程序 watch 早于 created
474+
if (!this.cale) {
459475
return
460476
}
461477
this.cale.setDate(date || new Date())
462478
this.weeks = this.cale.weeks
463479
this.nowDate = this.cale.getInfo(date)
464-
this.calendar = {...this.nowDate}
465-
if(!date){
466-
// 优化date为空默认不选中今天
467-
this.calendar.fullDate = ''
468-
if(this.defaultValue && !this.range){
469-
// 暂时只支持移动端非范围选择
470-
const defaultDate = new Date(this.defaultValue)
471-
const fullDate = getDate(defaultDate)
472-
const year = defaultDate.getFullYear()
473-
const month = defaultDate.getMonth()+1
474-
const date = defaultDate.getDate()
475-
const day = defaultDate.getDay()
476-
this.calendar = {
477-
fullDate,
478-
year,
479-
month,
480-
date,
481-
day
482-
},
483-
this.tempSingleDate = fullDate
484-
this.time = getTime(defaultDate, this.hideSecond)
485-
}
486-
}
480+
this.calendar = {
481+
...this.nowDate
482+
}
483+
if (!date) {
484+
// 优化date为空默认不选中今天
485+
this.calendar.fullDate = ''
486+
if (this.defaultValue && !this.range) {
487+
// 暂时只支持移动端非范围选择
488+
const defaultDate = new Date(this.defaultValue)
489+
const fullDate = getDate(defaultDate)
490+
const year = defaultDate.getFullYear()
491+
const month = defaultDate.getMonth() + 1
492+
const date = defaultDate.getDate()
493+
const day = defaultDate.getDay()
494+
this.calendar = {
495+
fullDate,
496+
year,
497+
month,
498+
date,
499+
day
500+
},
501+
this.tempSingleDate = fullDate
502+
this.time = getTime(defaultDate, this.hideSecond)
503+
}
504+
}
487505
},
488506
/**
489507
* 打开日历弹窗
@@ -545,13 +563,13 @@
545563
* @param {Object} name
546564
*/
547565
setEmit(name) {
548-
if(!this.range){
549-
if(!this.calendar.fullDate){
550-
this.calendar = this.cale.getInfo(new Date())
551-
this.tempSingleDate = this.calendar.fullDate
566+
if (!this.range) {
567+
if (!this.calendar.fullDate) {
568+
this.calendar = this.cale.getInfo(new Date())
569+
this.tempSingleDate = this.calendar.fullDate
552570
}
553-
if(this.hasTime && !this.time) {
554-
this.time = getTime(new Date(), this.hideSecond)
571+
if (this.hasTime && !this.time) {
572+
this.time = getTime(new Date(), this.hideSecond)
555573
}
556574
}
557575
let {
@@ -595,17 +613,17 @@
595613
}
596614
this.change()
597615
},
598-
changeMonth(type) {
599-
let newDate
600-
if(type === 'pre') {
601-
newDate = this.cale.getPreMonthObj(this.nowDate.fullDate).fullDate
602-
} else if(type === 'next') {
603-
newDate = this.cale.getNextMonthObj(this.nowDate.fullDate).fullDate
604-
}
616+
changeMonth(type) {
617+
let newDate
618+
if (type === 'pre') {
619+
newDate = this.cale.getPreMonthObj(this.nowDate.fullDate).fullDate
620+
} else if (type === 'next') {
621+
newDate = this.cale.getNextMonthObj(this.nowDate.fullDate).fullDate
622+
}
605623
606-
this.setDate(newDate)
624+
this.setDate(newDate)
607625
this.monthSwitch()
608-
},
626+
},
609627
/**
610628
* 设置日期
611629
* @param {Object} date
@@ -619,7 +637,7 @@
619637
}
620638
</script>
621639

622-
<style lang="scss" >
640+
<style lang="scss">
623641
$uni-primary: #007aff !default;
624642
625643
.uni-calendar {
@@ -855,17 +873,17 @@
855873
856874
.uni-date-changed--time-end {
857875
/* #ifndef APP-NVUE */
858-
display: flex;
876+
display: flex;
859877
/* #endif */
860878
align-items: center;
861879
}
862880
863881
.uni-date-changed--time-date {
864-
color: #999;
882+
color: #999;
865883
line-height: 50px;
866-
/* #ifdef MP-TOUTIAO */
867-
font-size: 16px;
868-
/* #endif */
884+
/* #ifdef MP-TOUTIAO */
885+
font-size: 16px;
886+
/* #endif */
869887
margin-right: 5px;
870888
// opacity: 0.6;
871889
}
@@ -924,5 +942,6 @@
924942
.uni-datetime-picker--btn:active {
925943
opacity: 0.7;
926944
}
945+
927946
/* #endif */
928-
</style>
947+
</style>

0 commit comments

Comments
 (0)