Commit 248418762fc8b5309d8ca341ab9229fc2b2d83ad

Authored by 潘钊
1 parent 8de956dc

add tts

src/main/resources/static/real_control_v2/css/line_schedule.css
... ... @@ -190,6 +190,10 @@
190 190 font-weight: 600;
191 191 }
192 192  
  193 +.schedule-body .ct_table dl._search_hide{
  194 + display: none !important;
  195 +}
  196 +
193 197 .context-menu-list.schedule-ct-menu {
194 198 /*font-size: 13px;*/
195 199 font-family: 微软雅黑;
... ... @@ -333,6 +337,12 @@ dd.tl-zzzx {
333 337 width: 100%;
334 338 }
335 339  
  340 +.ct-form-modal span.uk-form-help-inline,
  341 +.ct-form-modal p.uk-form-help-block{
  342 + color: #888888;
  343 + font-size: 13px;
  344 +}
  345 +
336 346  
337 347 /** 批量待发调整 */
338 348  
... ... @@ -721,8 +731,29 @@ input.i-cbox[type=checkbox]{
721 731 transition: all .3s ease;
722 732 }
723 733  
724   -.search_sch_panel .uk-form input.active[type=text]{
725   - width: 130px;
  734 +.search_sch_panel .uk-form div.uk-form-icon.active input[type=text]{
  735 + width: 145px;
  736 +}
  737 +
  738 +.search_sch_panel .uk-form div.uk-form-icon i.cancel{
  739 + position: absolute;
  740 + right: 8px;
  741 + font-size: 13px;
  742 + color: #c3b9ba;
  743 + cursor: pointer;
  744 + display: none;
  745 + padding: 0;
  746 + pointer-events: auto;
  747 + width: 18px;
  748 + text-indent: 0;
  749 +}
  750 +
  751 +/*.search_sch_panel .uk-form div.uk-form-icon i.cancel:before{*/
  752 +
  753 +/*}*/
  754 +
  755 +.search_sch_panel .uk-form div.uk-form-icon.active i.cancel{
  756 + display: block;
726 757 }
727 758  
728 759 .search_sch_panel .uk-form input[type=text]::-webkit-input-placeholder{
... ...
src/main/resources/static/real_control_v2/css/sch_autocomp_result.css
... ... @@ -15,8 +15,9 @@
15 15  
16 16 .sch-search-results small {
17 17 /*display: block;*/
18   - color: #9b9797;
19   - margin-left: 9px;
  18 + /*color: #9b9797;
  19 + margin-left: 9px;*/
  20 + color: #009dd8;
20 21 }
21 22  
22 23 .sch-search-results small.search-result-desc {
... ... @@ -25,6 +26,7 @@
25 26 display: block;
26 27 text-overflow: ellipsis;
27 28 margin-left: 0;
  29 + color: #9b9797;
28 30 }
29 31  
30 32  
... ...
src/main/resources/static/real_control_v2/fragments/line_schedule/sch_table.html
... ... @@ -7,16 +7,17 @@
7 7 {{else}}
8 8 下行/{{line.endStationName}}
9 9 {{/if}}
10   - <!-- <div class="search_sch_panel">
11   - <form class="uk-form">
  10 + <div class="search_sch_panel">
  11 + <form class="uk-form" onsubmit="javascript:return false;">
12 12 <div class="uk-autocomplete sch-search-autocom">
13 13 <div class="uk-form-icon">
14 14 <i class="uk-icon-search"></i>
15 15 <input type="text" placeholder="search">
  16 + <i class="cancel uk-icon-times-circle" data-uk-tooltip="{pos:'right'}" title="取消过滤"></i>
16 17 </div>
17 18 </div>
18 19 </form>
19   - </div> -->
  20 + </div>
20 21 </h3>
21 22 <div class="schedule-body">
22 23 <div class="ct_table_wrap">
... ...
src/main/resources/static/real_control_v2/fragments/line_schedule/sys_mailbox.html
... ... @@ -16,9 +16,9 @@
16 16 <div class="uk-width-medium-1-1 sys-note-42" id="{{domId}}">
17 17 <div class="uk-panel uk-panel-box uk-panel-box-secondary">
18 18 <h5 class="title">
19   - {{t.fcsjActual}} {{t.clZbh}} 已由 {{t.qdzName}} 发出
  19 + {{t.fcsjActual}} {{t.clZbh}} 已由 {{t.qdzName}} 发出,执行班次 {{t.dfsj}}
20 20 </h5>
21   - <code>{{dataStr}}</code>
  21 + <code>{{t.fcsjActual}}</code>
22 22 <div class="uk-button-group">
23 23 <a class="uk-button uk-button-mini uk-button-primary" >确定</a>
24 24 </div>
... ... @@ -36,7 +36,7 @@
36 36 已完成当日所有班次。
37 37 {{/if}}
38 38 </h5>
39   - <code>{{dataStr}}</code>
  39 + <code>{{t.zdsjActual}}</code>
40 40 <div class="uk-button-group">
41 41 <a class="uk-button uk-button-mini uk-button-primary" >确定</a>
42 42 </div>
... ...
src/main/resources/static/real_control_v2/fragments/north/nav/tts_config.html 0 → 100644
  1 +<div class="uk-modal ct-form-modal" id="tts-config-modal">
  2 + <div class="uk-modal-dialog" style="width: 530px;">
  3 + <a href="" class="uk-modal-close uk-close"></a>
  4 + <div class="uk-modal-header">
  5 + <h2>TTS 语音设置</h2></div>
  6 +
  7 + <p style="border-bottom: 1px solid #efefef;color: grey;padding-bottom: 9px;">
  8 + <small>
  9 + <i class="uk-icon-question-circle"> </i>
  10 + 设置项将会保存在本地客户端,清理缓存和更换电脑会重置.</small>
  11 + </p>
  12 + <form class="uk-form uk-form-horizontal">
  13 + <div class="uk-grid">
  14 + <div class="uk-width-2-3 uk-container-center">
  15 + <div class="uk-form-row">
  16 + <label class="uk-form-label">启用TTS</label>
  17 + <div class="uk-form-controls">
  18 + <select name="enable">
  19 + <option value="1">启用</option>
  20 + <option value="0">禁用</option>
  21 + </select>
  22 + </div>
  23 + </div>
  24 + </div>
  25 + </div>
  26 + <div class="uk-grid">
  27 + <div class="uk-width-2-3 uk-container-center">
  28 + <div class="uk-form-row">
  29 + <label class="uk-form-label">发音速度</label>
  30 + <div class="uk-form-controls">
  31 + <input name="rate" max=10 data-fv-lessthan-inclusive="false" style="width: calc(100% - 80px);" />
  32 + <span class="uk-form-help-inline">1 ~ 10</span>
  33 + </div>
  34 + </div>
  35 + </div>
  36 + </div>
  37 +
  38 + <div class="uk-grid">
  39 + <div class="uk-width-2-3 uk-container-center">
  40 + <div class="uk-form-row">
  41 + <label class="uk-form-label">播放队列</label>
  42 + <div class="uk-form-controls">
  43 + <select name="queueModel">
  44 + <option value="1">总是最新</option>
  45 + <option value="-1">按顺序完整播报</option>
  46 + </select>
  47 + <p class="uk-form-help-block"></p>
  48 + </div>
  49 + </div>
  50 + </div>
  51 + </div>
  52 +
  53 + <div class="uk-grid">
  54 + <div class="uk-width-1-1" style="margin-top: 25px;">
  55 + <div class="uk-panel uk-panel-box" style="font-size: 12px;color: grey;">
  56 + 我能吞下玻璃而不伤身体&nbsp;
  57 + <button class="uk-button uk-button-success uk-button-mini" type="button" id="tts-audition-btn">
  58 + <i class="uk-icon-volume-down"> </i> 试听</button>
  59 + </div>
  60 + </div>
  61 + </div>
  62 +
  63 + <div class="uk-modal-footer uk-text-right" style="margin-bottom: -20px;">
  64 + <button type="button" class="uk-button uk-modal-close">取消</button>
  65 + <button type="submit" class="uk-button uk-button-primary"><i class="uk-icon-check"></i> &nbsp;保存</button>
  66 + </div>
  67 + </form>
  68 + </div>
  69 +
  70 + <script>
  71 + (function() {
  72 + var modal = '#tts-config-modal';
  73 + var f = $('form', modal);
  74 +
  75 + $(modal).on('init', function(e, data) {
  76 + var config=gb_tts.defaultConfig();
  77 + for(var name in config)
  78 + $('[name='+name+']', f).val(config[name]).trigger('change');
  79 +
  80 + });
  81 +
  82 + $('select[name=queueModel]', f).on('change', function(){
  83 + var val=$(this).val()
  84 + ,$help=$(this).next('.uk-form-help-block');
  85 +
  86 + if(val == 1)
  87 + $help.text('有新的语音,强制中断未结束的语音');
  88 + else
  89 + $help.text('按照队列顺序依次完整播报');
  90 + });
  91 +
  92 + $('#tts-audition-btn', f).on('click', function(){
  93 + var msg='我能吞下玻璃而不伤身体'
  94 + ,rate=$('[name=rate]',f).val();
  95 + gb_tts.audition(msg, rate);
  96 + });
  97 +
  98 + f.formValidation(gb_form_validation_opts);
  99 + f.on('success.form.fv', function(e) {
  100 + e.preventDefault();
  101 + var data = $(this).serializeJSON();
  102 + gb_tts.writeConfig(data);
  103 + UIkit.modal(modal).hide();
  104 + notify_succ('TTS配置修改成功!');
  105 + });
  106 +
  107 + })();
  108 + </script>
  109 +</div>
... ...
src/main/resources/static/real_control_v2/js/utils/tts.js 0 → 100644
  1 +var gb_tts = (function() {
  2 +
  3 + var storage = window.localStorage;
  4 + var defaultConfig = {
  5 + //发音速度 1 ~ 10
  6 + rate: 1.2,
  7 + //播放队列 1:覆盖式(总是播放最新) -1:完整的按顺序播报
  8 + queueModel: 1,
  9 + enable: 1
  10 + };
  11 +
  12 + var readLocal = function() {
  13 + //从本地客户端读取配置信息
  14 + var cofig = storage.getItem('tts_cofig');
  15 + if (cofig) {
  16 + cofig = JSON.parse(cofig);
  17 + defaultConfig = cofig;
  18 + }
  19 + }
  20 +
  21 + var writeConfig = function(newConfig) {
  22 + storage.setItem('tts_cofig', JSON.stringify(newConfig));
  23 + defaultConfig = newConfig;
  24 + }
  25 +
  26 + var synth = window.speechSynthesis;
  27 + readLocal();
  28 +
  29 + var speak = function(t, lineCode) {
  30 + if (defaultConfig.enable != 1)
  31 + return;
  32 + if (defaultConfig.queueModel == 1)
  33 + synth.cancel();
  34 +
  35 + t = gb_data_basic.codeToLine[lineCode].name + t;
  36 + //延迟100毫秒,防止中断旧语音时 将新的语音也中断
  37 + setTimeout(function() {
  38 + var msg = new SpeechSynthesisUtterance(t);
  39 + msg.rate = defaultConfig.rate;
  40 + synth.speak(msg);
  41 + }, 100);
  42 + }
  43 +
  44 + var audition = function(t, rate) {
  45 + var msg = new SpeechSynthesisUtterance(t);
  46 + msg.rate = rate;
  47 + synth.speak(msg);
  48 + }
  49 +
  50 + return {
  51 + readLocal: readLocal,
  52 + writeConfig: writeConfig,
  53 + defaultConfig: function() {
  54 + return defaultConfig
  55 + },
  56 + speak: speak,
  57 + audition: audition
  58 + };
  59 +})();
... ...