feat: add diff online tool

This commit is contained in:
Baoshuo Ren 2023-02-04 11:29:12 +08:00
parent d4d98f6d55
commit 9880357433
Signed by: baoshuo
GPG Key ID: 00CB9680AB29F51A
5 changed files with 300 additions and 242 deletions

View File

@ -0,0 +1,49 @@
<?php
requireLib('bootstrap5');
?>
<?php echoUOJPageHeader(UOJLocale::get('diff online')) ?>
<h1>
<?= UOJLocale::get('diff online') ?>
</h1>
<div class="card">
<div class="card-body">
<div style="height: 700px" id="diff-editor-container">
<div class="border d-flex justify-content-center align-items-center w-100 h-100">
<div class="spinner-border text-muted" style="width: 3rem; height: 3rem;"></div>
</div>
</div>
</div>
<div class="card-footer bg-transparent text-end">
<a href="https://s2oj.github.io/#/user/apps/diff_online" target="_blank">使用教程</a>
</div>
</div>
<script>
var div_editor = $('#diff-editor-container');
require_monaco({}, function() {
$(div_editor).html('');
var originalModel = monaco.editor.createModel("", "text/plain");
var modifiedModel = monaco.editor.createModel("", "text/plain");
var diffEditor = monaco.editor.createDiffEditor(div_editor[0], {
originalEditable: true, // for left pane
readOnly: false, // for right pane
fontSize: "16px",
automaticLayout: true,
});
diffEditor.setModel({
original: originalModel,
modified: modifiedModel,
});
$(div_editor).addClass('border overflow-hidden');
});
</script>
<?php echoUOJPageFooter() ?>

View File

@ -102,4 +102,5 @@ return [
'apps' => 'Apps',
'image hosting' => 'Image Hosting',
'html to markdown' => 'HTML to Markdown',
'diff online' => 'Diff Online',
];

View File

@ -102,4 +102,5 @@ return [
'apps' => '应用',
'image hosting' => '图床',
'html to markdown' => 'HTML 转 Markdown',
'diff online' => '在线比较',
];

View File

@ -96,6 +96,7 @@ Route::group(
// Apps
Route::any('/apps/image_hosting', '/apps/image_hosting.php');
Route::any('/apps/html2markdown', '/apps/html2markdown.php');
Route::any('/apps/diff_online', '/apps/diff_online.php');
}
);

View File

@ -125,6 +125,12 @@ mb-4
<?= UOJLocale::get('html to markdown') ?>
</a>
</li>
<li>
<a class="dropdown-item" href="<?= HTML::url('/apps/diff_online') ?>">
<i class="bi bi-file-earmark-diff"></i>
<?= UOJLocale::get('diff online') ?>
</a>
</li>
</ul>
</li>
<?php endif ?>