File size: 2,342 Bytes
b3b0b53
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
<!-- wechat-miniprogram-translator/index.wxml -->
<view class="container">
    <!-- IO Boxes -->
    <view class="io-container">
        <!-- Source Box -->
        <view class="io-box" id="source-box">
            <view class="language-panel">
                <view class="panel-label">您说的话 (选择语言)</view>
                <view class="language-buttons">
                    <block wx:for="{{sourceLanguages}}" wx:key="langCode">
                        <view class="lang-button {{sourceLang === item.langCode ? 'selected' : ''}}" data-lang-code="{{item.langCode}}" bindtap="selectSourceLanguage">
                            <image src="https://flagcdn.com/w40/{{item.flag}}.png" alt="{{item.name}}" class="flag-icon"></image>
                        </view>
                    </block>
                </view>
            </view>
            <scroll-view scroll-y class="text-content" id="transcript">{{transcript}}</scroll-view>
        </view>

        <!-- Swap Button -->
        <view class="swap-controls">
            <button id="swap-btn" title="交换语言" bindtap="swapLanguages">
                <text>🔄</text> <!-- Swap icon -->
            </button>
        </view>

        <!-- Target Box -->
        <view class="io-box" id="target-box">
            <view class="language-panel">
                <view class="panel-label">翻译成 (选择语言)</view>
                <view class="language-buttons">
                    <block wx:for="{{targetLanguages}}" wx:key="langCode">
                        <view class="lang-button {{targetLang === item.langCode ? 'selected' : ''}}" data-lang-code="{{item.langCode}}" bindtap="selectTargetLanguage">
                            <image src="https://flagcdn.com/w40/{{item.flag}}.png" alt="{{item.name}}" class="flag-icon"></image>
                        </view>
                    </block>
                </view>
            </view>
            <scroll-view scroll-y class="text-content" id="output-text">{{outputText}}</scroll-view>
        </view>
    </view>
</view>

<!-- Floating Mic Button -->
<view class="mic-container">
    <button id="mic-btn" title="按住说话" class="{{isRecording ? 'recording' : ''}}" bindtouchstart="handleRecordToggle" bindtouchend="stopRecording">
        <text>🎤</text> <!-- Microphone icon -->
    </button>
</view>