| | |
| | | }); |
| | | }); |
| | | break; |
| | | case 'serverInfo': |
| | | $.ajax({ |
| | | url: baseUrl + "/license/getServerInfos", |
| | | headers: {'token': localStorage.getItem('token')}, |
| | | method: 'GET', |
| | | success: function (res) { |
| | | var pretty = ''; |
| | | try { |
| | | pretty = JSON.stringify(res, null, 2); |
| | | } catch (e) { |
| | | pretty = res; |
| | | } |
| | | var html = '' |
| | | + '<div style="padding:15px 20px 5px 20px;">' |
| | | + '<div style="font-weight:600;margin-bottom:8px;">系统配置信息</div>' |
| | | + '<pre id="server-info-pre" style="background:#f7f7f7;border:1px solid #e6e6e6;border-radius:6px;padding:12px;white-space:pre-wrap;word-wrap:break-word;max-height:360px;overflow:auto;">' |
| | | + pretty |
| | | + '</pre>' |
| | | + '<div class="layui-btn-container" style="text-align:right;margin-top:6px;">' |
| | | + '<button class="layui-btn layui-btn-primary" id="copy-server-info">复制</button>' |
| | | + '</div>' |
| | | + '</div>'; |
| | | layer.open({ |
| | | type: 1, |
| | | title: '获取系统配置', |
| | | area: ['640px','480px'], |
| | | shadeClose: true, |
| | | content: html, |
| | | success: function (layero, index) { |
| | | layero.find('#copy-server-info').on('click', function () { |
| | | var text = layero.find('#server-info-pre').text(); |
| | | if (navigator.clipboard && navigator.clipboard.writeText) { |
| | | navigator.clipboard.writeText(text).then(function () { |
| | | layer.msg('已复制到剪贴板'); |
| | | }).catch(function () { |
| | | try { |
| | | var textarea = document.createElement('textarea'); |
| | | textarea.value = text; |
| | | textarea.style.position = 'fixed'; |
| | | textarea.style.opacity = '0'; |
| | | document.body.appendChild(textarea); |
| | | textarea.select(); |
| | | document.execCommand('copy'); |
| | | document.body.removeChild(textarea); |
| | | layer.msg('已复制到剪贴板'); |
| | | } catch (err) { |
| | | layer.msg('复制失败'); |
| | | } |
| | | }); |
| | | } else { |
| | | try { |
| | | var textarea = document.createElement('textarea'); |
| | | textarea.value = text; |
| | | textarea.style.position = 'fixed'; |
| | | textarea.style.opacity = '0'; |
| | | document.body.appendChild(textarea); |
| | | textarea.select(); |
| | | document.execCommand('copy'); |
| | | document.body.removeChild(textarea); |
| | | layer.msg('已复制到剪贴板'); |
| | | } catch (err) { |
| | | layer.msg('复制失败'); |
| | | } |
| | | } |
| | | }); |
| | | } |
| | | }); |
| | | }, |
| | | error: function () { |
| | | layer.msg('获取系统配置信息失败'); |
| | | } |
| | | }); |
| | | break; |
| | | } |
| | | }); |
| | | |