|
16 | 16 | aria-label="TDesign Logo" |
17 | 17 | /> |
18 | 18 | </view> |
19 | | - <view class="desc"> |
| 19 | + <view |
| 20 | + class="desc" |
| 21 | + @click="onDescTap" |
| 22 | + > |
20 | 23 | TDesign 适配 uni-app 的组件库{{ isSkyline?' (skyline render)':'' }} |
21 | 24 | <text |
22 | 25 | v-if="!isSkyline && showTrySkyline" |
23 | 26 | class="skyline-entry" |
24 | | - @click="goSkyline" |
| 27 | + @click.stop="goSkyline" |
25 | 28 | > |
26 | 29 | try skyline |
27 | 30 | </text> |
|
59 | 62 | <script> |
60 | 63 | import TFooter from '@tdesign/uniapp/footer/footer.vue'; |
61 | 64 | import { themeMixin } from '@tdesign/uniapp/mixins/theme-change'; |
| 65 | +import { simpleMorse } from 't-comm/lib/morse-pwd/index'; |
| 66 | +import { toggleVConsole } from 't-comm/lib/v-console/index'; |
62 | 67 |
|
63 | 68 |
|
64 | 69 | import PullDownList from '../../components/pull-down-list/index.vue'; |
@@ -94,6 +99,7 @@ export default { |
94 | 99 | isSkyline: false, |
95 | 100 | showTrySkyline: false, |
96 | 101 | winStyle: false, |
| 102 | + debugEnabled: false, |
97 | 103 | }; |
98 | 104 | }, |
99 | 105 | onLoad(options) { |
@@ -144,6 +150,50 @@ export default { |
144 | 150 | }); |
145 | 151 | }, |
146 | 152 |
|
| 153 | + onDescTap() { |
| 154 | + // 连续点击 5 次(间隔 < 500ms)唤起调试面板,复用 t-comm simpleMorse |
| 155 | + simpleMorse({ |
| 156 | + target: 5, |
| 157 | + timeout: 500, |
| 158 | + callback: () => this.toggleDebugConsole(), |
| 159 | + }); |
| 160 | + }, |
| 161 | +
|
| 162 | + toggleDebugConsole() { |
| 163 | + // #ifdef H5 |
| 164 | + try { |
| 165 | + const visible = toggleVConsole(); |
| 166 | + uni.showToast({ |
| 167 | + title: visible ? '已开启 vConsole' : '已关闭 vConsole', |
| 168 | + icon: 'none', |
| 169 | + }); |
| 170 | + } catch (e) { |
| 171 | + console.error('[home] toggleVConsole failed', e); |
| 172 | + uni.showToast({ title: '调试面板加载失败', icon: 'none' }); |
| 173 | + } |
| 174 | + // #endif |
| 175 | +
|
| 176 | + // #ifndef H5 |
| 177 | + if (typeof uni !== 'undefined' && typeof uni.setEnableDebug === 'function') { |
| 178 | + const enable = !this.debugEnabled; |
| 179 | + uni.setEnableDebug({ |
| 180 | + enableDebug: enable, |
| 181 | + success: () => { |
| 182 | + this.debugEnabled = enable; |
| 183 | + uni.showToast({ |
| 184 | + title: enable ? '已开启调试模式' : '已关闭调试模式', |
| 185 | + icon: 'none', |
| 186 | + }); |
| 187 | + }, |
| 188 | + fail: () => { |
| 189 | + uni.showToast({ title: '当前环境不支持调试面板', icon: 'none' }); |
| 190 | + }, |
| 191 | + }); |
| 192 | + } else { |
| 193 | + uni.showToast({ title: '当前环境不支持调试面板', icon: 'none' }); |
| 194 | + } |
| 195 | + // #endif |
| 196 | + }, |
147 | 197 | showPrivacyWin() { |
148 | 198 | this.$refs.trdPrivacy?.showPrivacyWin(); |
149 | 199 | }, |
|
0 commit comments