✨ feat: 优化代码编辑器样式和增强预览功能
This commit is contained in:
@@ -24,14 +24,57 @@ if ($pr_flag) {
|
||||
}
|
||||
|
||||
.copy {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
min-width: 68px;
|
||||
font-size: 12px;
|
||||
color: #4d4d4d;
|
||||
background-color: white;
|
||||
padding: 2px 8px;
|
||||
margin: 8px;
|
||||
border-radius: 4px;
|
||||
font-weight: 600;
|
||||
color: #2f4f7f;
|
||||
background: rgba(255, 255, 255, 0.96);
|
||||
padding: 6px 12px;
|
||||
margin: 0;
|
||||
border: 1px solid #c8d3e6;
|
||||
border-radius: 999px;
|
||||
cursor: pointer;
|
||||
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05), 0 2px 4px rgba(0, 0, 0, 0.05);
|
||||
box-shadow: 0 4px 10px rgba(15, 23, 42, 0.08);
|
||||
}
|
||||
|
||||
.copy:hover {
|
||||
background: #ffffff;
|
||||
}
|
||||
|
||||
.sample-header {
|
||||
display: flex !important;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
.sample-box {
|
||||
border: 1px solid #cfd7e6 !important;
|
||||
background: linear-gradient(180deg, #f9fbff 0%, #f3f7ff 100%) !important;
|
||||
box-shadow: 0 8px 20px rgba(15, 23, 42, 0.06);
|
||||
}
|
||||
|
||||
.sample-box pre {
|
||||
margin: 0;
|
||||
padding: 16px 18px;
|
||||
overflow: auto;
|
||||
background: transparent;
|
||||
}
|
||||
|
||||
.sample-box code {
|
||||
display: block;
|
||||
font-family: "Cascadia Mono", "JetBrains Mono", Consolas, "Courier New", monospace;
|
||||
font-size: 15px;
|
||||
line-height: 1.7;
|
||||
}
|
||||
|
||||
.hustoj-md-io-label {
|
||||
margin: 12px 0 8px;
|
||||
font-weight: 600;
|
||||
color: #3d4d66;
|
||||
}
|
||||
|
||||
</style>
|
||||
@@ -213,12 +256,12 @@ if ($pr_flag) {
|
||||
<?php if (strlen($sinput) > 0 && $sinput != "\n" || isset($_GET['spa'])) { ?>
|
||||
<div class="row">
|
||||
<div class="column">
|
||||
<h4 class="ui top attached block header"><?php echo $MSG_Sample_Input ?>
|
||||
<h4 class="ui top attached block header sample-header"><?php echo $MSG_Sample_Input ?>
|
||||
<span class="copy" id="copyin"
|
||||
data-clipboard-text="<?php echo htmlentities($sinput, ENT_QUOTES, 'UTF-8'); ?>"><?php echo $MSG_COPY; ?></span>
|
||||
</h4>
|
||||
<!-- <span class=copy id=\"copyin\" data-clipboard-text=\"".($sinput)."\"><?php echo $MSG_COPY; ?></span> -->
|
||||
<div class="ui bottom attached segment font-content">
|
||||
<div class="ui bottom attached segment font-content sample-box">
|
||||
<!-- <pre><?php echo ($sinput); ?></pre> -->
|
||||
<pre
|
||||
style="margin-top: 0; margin-bottom: 0; "><code id='sinput' class="lang-plain"><?php echo ($sinput); ?></code></pre>
|
||||
@@ -229,12 +272,12 @@ if ($pr_flag) {
|
||||
<?php if (strlen($soutput) > 0 && $soutput != "\n" || isset($_GET['spa'])) { ?>
|
||||
<div class="row">
|
||||
<div class="column">
|
||||
<h4 class="ui top attached block header"><?php echo $MSG_Sample_Output ?>
|
||||
<h4 class="ui top attached block header sample-header"><?php echo $MSG_Sample_Output ?>
|
||||
<span class="copy" id="copyout"
|
||||
data-clipboard-text="<?php echo htmlentities($soutput, ENT_QUOTES, 'UTF-8'); ?>"><?php echo $MSG_COPY; ?></span>
|
||||
</h4>
|
||||
<!-- <span class=copy id=\"copyout\" data-clipboard-text=\"".($soutput)."\"><?php echo $MSG_COPY; ?></span> -->
|
||||
<div class="ui bottom attached segment font-content">
|
||||
<div class="ui bottom attached segment font-content sample-box">
|
||||
<!-- <div class="ui existing segment"> -->
|
||||
<pre
|
||||
style="margin-top: 0; margin-bottom: 0; "><code id='soutput' class="lang-plain"><?php echo ($soutput); ?></code></pre>
|
||||
|
||||
@@ -2,9 +2,26 @@
|
||||
<?php include("template/$OJ_TEMPLATE/header.php");?>
|
||||
|
||||
<style>
|
||||
#frmSolution {
|
||||
width: 100%;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
#source {
|
||||
width: 80%;
|
||||
display: block;
|
||||
width: 100% !important;
|
||||
height: 600px;
|
||||
margin: 14px 0 0 !important;
|
||||
text-align: left !important;
|
||||
}
|
||||
|
||||
.hustoj-vditor-code,
|
||||
.hustoj-vditor-code .vditor,
|
||||
.hustoj-vditor-code .vditor-content,
|
||||
.hustoj-vditor-code .vditor-reset,
|
||||
.hustoj-vditor-code textarea {
|
||||
width: 100% !important;
|
||||
text-align: left !important;
|
||||
}
|
||||
|
||||
.ace-chrome .ace_marker-layer .ace_active-line{ /*当前行*/
|
||||
@@ -412,6 +429,8 @@ function reloadtemplate(lang){
|
||||
document.cookie="lastlang="+lang;
|
||||
var url=window.location.href;
|
||||
var i=url.indexOf("sid=");
|
||||
if(lang!=<?php echo $lastlang?>)
|
||||
autoSave(<?php echo $lastlang ?>);
|
||||
switchLang(lang);
|
||||
if(lang!=<?php echo $lastlang?>)
|
||||
document.location.href=url;
|
||||
@@ -471,11 +490,21 @@ function loadFromBlockly(){
|
||||
fontSize: "18px"
|
||||
});
|
||||
reloadtemplate($("#language").val());
|
||||
function autoSave(){
|
||||
function getSourceDraftKey(languageOverride){
|
||||
let language=languageOverride;
|
||||
if(language===undefined||language===null||language===""){
|
||||
language=$("#language").val();
|
||||
}
|
||||
if(language===undefined||language===null||language===""){
|
||||
language="<?php echo $lastlang ?>";
|
||||
}
|
||||
return "<?php echo $_SESSION[$OJ_NAME.'_user_id']?>source:"+location.href+":lang:"+language;
|
||||
}
|
||||
function autoSave(languageOverride){
|
||||
var mark="<?php echo isset($id)?'problem_id':'cid';?>";
|
||||
var problem_id=$("#"+mark).val();
|
||||
if(!!localStorage){
|
||||
let key="<?php echo $_SESSION[$OJ_NAME.'_user_id']?>source:"+location.href;
|
||||
let key=getSourceDraftKey(languageOverride);
|
||||
if(typeof(editor) != "undefined")
|
||||
$("#hide_source").val(editor.getValue());
|
||||
localStorage.setItem(key,$("#hide_source").val());
|
||||
@@ -486,7 +515,7 @@ function loadFromBlockly(){
|
||||
$("#source").css("height",window.innerHeight-180);
|
||||
if($("#vcode")!=undefined) $("#vcode").click();
|
||||
if(!!localStorage){
|
||||
let key="<?php echo $_SESSION[$OJ_NAME.'_user_id']?>source:"+location.href;
|
||||
let key=getSourceDraftKey();
|
||||
let saved=localStorage.getItem(key);
|
||||
if(saved!=null&&saved!=""&&saved.length>editor.getValue().length){
|
||||
//let load=confirm("发现自动保存的源码,是否加载?(仅有一次机会)");
|
||||
|
||||
Reference in New Issue
Block a user