Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 52 additions & 2 deletions packages/tdesign-uniapp/example/src/pages/home/home.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,15 @@
aria-label="TDesign Logo"
/>
</view>
<view class="desc">
<view
class="desc"
@click="onDescTap"
>
TDesign 适配 uni-app 的组件库{{ isSkyline?' (skyline render)':'' }}
<text
v-if="!isSkyline && showTrySkyline"
class="skyline-entry"
@click="goSkyline"
@click.stop="goSkyline"
>
try skyline
</text>
Expand Down Expand Up @@ -59,6 +62,8 @@
<script>
import TFooter from '@tdesign/uniapp/footer/footer.vue';
import { themeMixin } from '@tdesign/uniapp/mixins/theme-change';
import { simpleMorse } from 't-comm/lib/morse-pwd/index';
import { toggleVConsole } from 't-comm/lib/v-console/index';


import PullDownList from '../../components/pull-down-list/index.vue';
Expand Down Expand Up @@ -94,6 +99,7 @@ export default {
isSkyline: false,
showTrySkyline: false,
winStyle: false,
debugEnabled: false,
};
},
onLoad(options) {
Expand Down Expand Up @@ -144,6 +150,50 @@ export default {
});
},

onDescTap() {
// 连续点击 5 次(间隔 < 500ms)唤起调试面板,复用 t-comm simpleMorse
simpleMorse({
target: 5,
timeout: 500,
callback: () => this.toggleDebugConsole(),
});
},

toggleDebugConsole() {
// #ifdef H5
try {
const visible = toggleVConsole();
uni.showToast({
title: visible ? '已开启 vConsole' : '已关闭 vConsole',
icon: 'none',
});
} catch (e) {
console.error('[home] toggleVConsole failed', e);
uni.showToast({ title: '调试面板加载失败', icon: 'none' });
}
// #endif

// #ifndef H5
if (typeof uni !== 'undefined' && typeof uni.setEnableDebug === 'function') {
const enable = !this.debugEnabled;
uni.setEnableDebug({
enableDebug: enable,
success: () => {
this.debugEnabled = enable;
uni.showToast({
title: enable ? '已开启调试模式' : '已关闭调试模式',
icon: 'none',
});
},
fail: () => {
uni.showToast({ title: '当前环境不支持调试面板', icon: 'none' });
},
});
} else {
uni.showToast({ title: '当前环境不支持调试面板', icon: 'none' });
}
// #endif
},
showPrivacyWin() {
this.$refs.trdPrivacy?.showPrivacyWin();
},
Expand Down
Binary file not shown.
14 changes: 12 additions & 2 deletions packages/tdesign-uniapp/example/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,21 @@ import path from 'path';
import { defineConfig, loadEnv } from 'vite';

import uni from '@dcloudio/vite-plugin-uni';
import { genVersionMpVitePlugin } from '@plugin-light/vite-plugin-gen-version';
import {
genVersionMpVitePlugin,
genVersionWebVitePlugin,
} from '@plugin-light/vite-plugin-gen-version';
import { BUILD_NAME_MAP } from 't-comm/lib/v-console/config';

const diffPlugins: any[] = [];
if (process.env.UNI_PLATFORM !== 'h5') {
diffPlugins.push(genVersionMpVitePlugin());
} else {
diffPlugins.push(genVersionWebVitePlugin({
buildName: BUILD_NAME_MAP.build,
commitName: BUILD_NAME_MAP.commit,
delay: 0,
}));
}


Expand All @@ -32,7 +42,7 @@ export default ({ mode }: { mode: string }) => {
const result = defineConfig({
plugins: [
uni(),
diffPlugins,
...diffPlugins,
],
resolve: {
alias: {
Expand Down
25 changes: 25 additions & 0 deletions packages/uniapp-components/picker/_example/area/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,29 @@ export default {
this.counties = counties;
},

onPickFeedback() {
try {
if (typeof uni !== 'undefined' && uni.vibrateShort) {
uni.vibrateShort({ type: 'medium', fail: () => {} });
}
} catch (_) { /* noop */ }

// 音效:懒初始化单个音频实例,落点时 seek(0) + play() 重放
// 微信小程序需将 mp3 放到项目静态目录(如 /static/picker-tick.mp3)
try {
if (!this.innerTickAudio && typeof uni !== 'undefined' && uni.createInnerAudioContext) {
const audio = uni.createInnerAudioContext();
audio.src = '/static/picker-tick.mp3';
if ('obeyMuteSwitch' in audio) audio.obeyMuteSwitch = true;
this.innerTickAudio = audio;
}
if (this.innerTickAudio) {
if (typeof this.innerTickAudio.seek === 'function') this.innerTickAudio.seek(0);
this.innerTickAudio.play && this.innerTickAudio.play();
}
} catch (_) { /* noop */ }
},

onColumnChange(e) {
console.log('pick:', e);
const { column, index } = e;
Expand All @@ -94,6 +117,8 @@ export default {
if (column === 2) {
// 更改区县
}

this.onPickFeedback();
},

getCities(provinceValue) {
Expand Down
Loading