代码整理

This commit is contained in:
Anyon 2020-07-08 10:14:58 +08:00
parent 3f5fc57c55
commit 60a59b1601
2 changed files with 235 additions and 248 deletions

View File

@ -161,8 +161,8 @@ echo 'Resource';
} }
.echo pre > pre { .echo pre > pre {
padding: 0;
margin: 0; margin: 0;
padding: 0;
} }
/* Exception Info */ /* Exception Info */
@ -171,11 +171,11 @@ echo 'Resource';
} }
.exception .message { .exception .message {
padding: 12px;
border: 1px solid #ddd; border: 1px solid #ddd;
border-bottom: 0 none; padding: 12px;
line-height: 18px;
font-size: 16px; font-size: 16px;
line-height: 18px;
border-bottom: 0 none;
border-top-left-radius: 4px; border-top-left-radius: 4px;
border-top-right-radius: 4px; border-top-right-radius: 4px;
font-family: Consolas, "Liberation Mono", Courier, Verdana, "微软雅黑", serif; font-family: Consolas, "Liberation Mono", Courier, Verdana, "微软雅黑", serif;
@ -192,12 +192,10 @@ echo 'Resource';
} }
.exception .source-code { .exception .source-code {
padding: 6px;
border: 1px solid #ddd; border: 1px solid #ddd;
padding: 6px;
background: #f9f9f9;
overflow-x: auto; overflow-x: auto;
background: #f9f9f9;
} }
.exception .source-code pre { .exception .source-code pre {
@ -209,25 +207,24 @@ echo 'Resource';
color: #4288ce; color: #4288ce;
display: inline-block; display: inline-block;
min-width: 100%; min-width: 100%;
box-sizing: border-box;
font-size: 14px; font-size: 14px;
box-sizing: border-box;
font-family: "Century Gothic", Consolas, "Liberation Mono", Courier, Verdana, serif; font-family: "Century Gothic", Consolas, "Liberation Mono", Courier, Verdana, serif;
padding-left: < ? php echo (isset($ source) & & ! empty($ source)) ? parse_padding($ source): 40; padding-left: <?php echo (isset($source) && ! empty($source)) ? parse_padding($source): 40;?> px;
? > px;
} }
.exception .source-code pre li { .exception .source-code pre li {
border-left: 1px solid #ddd;
height: 18px; height: 18px;
line-height: 18px; line-height: 18px;
border-left: 1px solid #ddd;
} }
.exception .source-code pre code { .exception .source-code pre code {
color: #333; color: #333;
height: 100%; height: 100%;
font-size: 14px;
display: inline-block; display: inline-block;
border-left: 1px solid #fff; border-left: 1px solid #fff;
font-size: 14px;
font-family: Consolas, "Liberation Mono", Courier, Verdana, "微软雅黑", serif; font-family: Consolas, "Liberation Mono", Courier, Verdana, "微软雅黑", serif;
} }
@ -374,7 +371,7 @@ echo 'Resource';
</head> </head>
<body> <body>
<?php if (\think\facade\App::isDebug()) { ?> <?php if (\think\facade\App::isDebug()) { ?>
<?php foreach ($traces as $index => $trace) { ?> <?php if (isset($traces)) foreach ($traces as $index => $trace) { ?>
<div class="exception"> <div class="exception">
<div class="message"> <div class="message">
<div class="info"> <div class="info">
@ -386,7 +383,16 @@ echo 'Resource';
</div> </div>
<?php if (!empty($trace['source'])) { ?> <?php if (!empty($trace['source'])) { ?>
<div class="source-code"> <div class="source-code">
<pre class="prettyprint lang-php"><ol start="<?php echo $trace['source']['first']; ?>"><?php foreach ((array)$trace['source']['source'] as $key => $value) { ?><li class="line-<?php echo " {$index}-" . ($key + $trace['source']['first']) . ($trace['line'] === $key + $trace['source']['first'] ? ' line-error' : ''); ?>"><code><?php echo htmlentities($value); ?></code></li><?php } ?></ol></pre> <pre class="prettyprint lang-php">
<?php
echo "<ol start='{$trace['source']['first']}'>";
foreach ((array)$trace['source']['source'] as $key => $value) {
$class = " {$index}-" . ($key + $trace['source']['first']) . ($trace['line'] === $key + $trace['source']['first'] ? ' line-error' : '');
echo "<li class='{$class}'><code>" . htmlentities($value) . "</code></li>";
}
echo "</ol>";
?>
</pre>
</div> </div>
<?php } ?> <?php } ?>
<div class="trace"> <div class="trace">
@ -406,7 +412,6 @@ echo 'Resource';
isset($value['args']) ? parse_args($value['args']) : '' isset($value['args']) ? parse_args($value['args']) : ''
); );
} }
// Show line // Show line
if (isset($value['file']) && isset($value['line'])) { if (isset($value['file']) && isset($value['line'])) {
echo sprintf(' in %s', parse_file($value['file'], $value['line'])); echo sprintf(' in %s', parse_file($value['file'], $value['line']));
@ -474,7 +479,6 @@ echo 'Resource';
<script> <script>
function $(selector, node) { function $(selector, node) {
var elements; var elements;
node = node || document; node = node || document;
if (document.querySelectorAll) { if (document.querySelectorAll) {
elements = node.querySelectorAll(selector); elements = node.querySelectorAll(selector);
@ -497,49 +501,36 @@ echo 'Resource';
return elements; return elements;
function get_elements_by_class(search_class, node, tag) { function get_elements_by_class(search_class, node, tag) {
var elements = [], eles, var elements = [], eles, pattern = new RegExp('(^|\\s)' + search_class + '(\\s|$)');
pattern = new RegExp('(^|\\s)' + search_class + '(\\s|$)'); node = node || document, tag = tag || '*', eles = node.getElementsByTagName(tag);
node = node || document;
tag = tag || '*';
eles = node.getElementsByTagName(tag);
for (var i = 0; i < eles.length; i++) { for (var i = 0; i < eles.length; i++) {
if (pattern.test(eles[i].className)) { if (pattern.test(eles[i].className)) {
elements.push(eles[i]) elements.push(eles[i])
} }
} }
return elements; return elements;
} }
} }
$.getScript = function (src, func) { $.getScript = function (src, func) {
var script = document.createElement('script'); var script = document.createElement('script');
script.async = 'async';
script.src = src; script.src = src;
script.async = 'async';
script.onload = func || function () { script.onload = func || function () {
}; };
$('head')[0].appendChild(script); $('head')[0].appendChild(script);
} }
;(function () { ;(function () {
var files = $('.toggle'); var files = $('.toggle');
var ol = $('ol', $('.prettyprint')[0]);
var li = $('li', ol[0]);
// 短路径和长路径变换 // 短路径和长路径变换
for (var i = 0; i < files.length; i++) { for (var i = 0; i < files.length; i++) {
files[i].ondblclick = function () { files[i].ondblclick = function () {
var title = this.title; var title = this.title;
this.title = this.innerHTML; this.title = this.innerHTML;
this.innerHTML = title; this.innerHTML = title;
} }
} }
(function () { (function () {
var expand = function (dom, expand) { var expand = function (dom, expand) {
var ol = $('ol', dom.parentNode)[0]; var ol = $('ol', dom.parentNode)[0];

View File

@ -36,8 +36,8 @@ require.config({
'michat': ['plugs/michat/michat'], 'michat': ['plugs/michat/michat'],
'base64': ['plugs/jquery/base64.min'], 'base64': ['plugs/jquery/base64.min'],
'upload': [tapiRoot + '/api.upload?.js'], 'upload': [tapiRoot + '/api.upload?.js'],
'echarts': ['plugs/echarts/echarts.min'],
'angular': ['plugs/angular/angular.min'], 'angular': ['plugs/angular/angular.min'],
'echarts': ['plugs/echarts/echarts.min'],
'ckeditor': ['plugs/ckeditor/ckeditor'], 'ckeditor': ['plugs/ckeditor/ckeditor'],
'websocket': ['plugs/socket/websocket'], 'websocket': ['plugs/socket/websocket'],
'pcasunzips': ['plugs/jquery/pcasunzips'], 'pcasunzips': ['plugs/jquery/pcasunzips'],
@ -474,15 +474,14 @@ $(function () {
/*! 表单转JSON */ /*! 表单转JSON */
$.fn.formToJson = function () { $.fn.formToJson = function () {
var self = this, data = {}, pushCounters = {}; var self = this, data = {}, push = {};
var patterns = {"key": /[a-zA-Z0-9_]+|(?=\[\])/g, "push": /^$/, "fixed": /^\d+$/, "named": /^[a-zA-Z0-9_]+$/}; var patterns = {"key": /[a-zA-Z0-9_]+|(?=\[\])/g, "push": /^$/, "fixed": /^\d+$/, "named": /^[a-zA-Z0-9_]+$/};
this.build = function (base, key, value) { this.build = function (base, key, value) {
base[key] = value; return (base[key] = value), base;
return base;
}; };
this.pushCounter = function (name) { this.pushCounter = function (name) {
if (pushCounters[name] === undefined) pushCounters[name] = 0; if (push[name] === undefined) push[name] = 0;
return pushCounters[name]++; return push[name]++;
}; };
$.each($(this).serializeArray(), function () { $.each($(this).serializeArray(), function () {
var key, keys = this.name.match(patterns.key), merge = this.value, name = this.name; var key, keys = this.name.match(patterns.key), merge = this.value, name = this.name;
@ -601,8 +600,7 @@ $(function () {
$body.on('click', '[data-check-target]', function () { $body.on('click', '[data-check-target]', function () {
var checked = !!this.checked; var checked = !!this.checked;
$($(this).attr('data-check-target')).map(function () { $($(this).attr('data-check-target')).map(function () {
this.checked = checked; (this.checked = checked), $(this).trigger('change');
$(this).trigger('change');
}); });
}); });
@ -642,8 +640,7 @@ $(function () {
data[attrs[i].split('#')[0]] = attrs[i].split('#')[1]; data[attrs[i].split('#')[0]] = attrs[i].split('#')[1];
} }
that.callback = function (ret) { that.callback = function (ret) {
$this.css('border', (ret && ret.code) ? '1px solid #e6e6e6' : '1px solid red'); return $this.css('border', (ret && ret.code) ? '1px solid #e6e6e6' : '1px solid red'), false;
return false;
}; };
data['_token_'] = $this.attr('data-token') || $this.attr('data-csrf') || '--'; data['_token_'] = $this.attr('data-token') || $this.attr('data-csrf') || '--';
if (!confirm) return $.form.load(action, data, method, that.callback, load, tips, time); if (!confirm) return $.form.load(action, data, method, that.callback, load, tips, time);
@ -734,8 +731,7 @@ $(function () {
$body.on('click', '[data-history-back]', function (title) { $body.on('click', '[data-history-back]', function (title) {
title = this.getAttribute('data-history-back') || '确定要返回上一页吗?'; title = this.getAttribute('data-history-back') || '确定要返回上一页吗?';
$.msg.confirm(title, function (index) { $.msg.confirm(title, function (index) {
history.back(); history.back(), $.msg.close(index);
$.msg.close(index);
}) })
}); });