frame 美化

This commit is contained in:
fofolee 2022-04-22 01:43:37 +08:00
parent 3e1e72b7bc
commit 4957ba2030

View File

@ -14,18 +14,18 @@
<q-toolbar-title <q-toolbar-title
><span class="text-weight-bold">运行结果</span></q-toolbar-title ><span class="text-weight-bold">运行结果</span></q-toolbar-title
> >
<q-btn flat round icon="close" color="negative" v-close-popup />
</q-toolbar> </q-toolbar>
<q-card-section class="row items-center"> <iframe
<iframe ref="iframe"
ref="iframe" :srcdoc="frameStyle + runResult"
:srcdoc="runResult" :height="frameHeight"
:height="frameHeight" @load="frameLoad"
@load="frameLoad" frameborder="0"
frameborder="0" v-if="htmlOutput"
v-if="htmlOutput" ></iframe>
></iframe> <q-card-section v-else class="row items-center">
<pre <pre
v-else
:class="{ :class="{
'text-red': !runResultStatus, 'text-red': !runResultStatus,
result: 1, result: 1,
@ -33,16 +33,13 @@
v-text="runResult" v-text="runResult"
></pre> ></pre>
</q-card-section> </q-card-section>
<q-card-actions align="right">
<q-btn flat label="关闭" color="primary" v-close-popup />
</q-card-actions>
</q-card> </q-card>
</q-dialog> </q-dialog>
</div> </div>
<div v-else> <div v-else>
<iframe <iframe
ref="iframe" ref="iframe"
:srcdoc="runResult" :srcdoc="frameStyle + runResult"
:height="frameHeight" :height="frameHeight"
frameborder="0" frameborder="0"
@load="frameLoad" @load="frameLoad"
@ -68,6 +65,28 @@ import outputTypes from "../js/options/outputTypes.js";
import specialVars from "../js/options/specialVars.js"; import specialVars from "../js/options/specialVars.js";
import commandTypes from "../js/options/commandTypes.js"; import commandTypes from "../js/options/commandTypes.js";
const frameStyle = `<style>::-webkit-scrollbar {
width: 6px;
height: 6px;
}
::-webkit-scrollbar-thumb {
border-radius: 10px;
box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.2);
background: rgba(194, 194, 194, 0.4);
}
::-webkit-scrollbar-track {
border-radius: 10px;
box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.2);
}
body {
margin: 0;
color: ${utools.isDarkColors() ? "white" : "unset"}
}
</style>
`;
export default { export default {
data() { data() {
return { return {
@ -80,6 +99,7 @@ export default {
historyIdx: null, historyIdx: null,
htmlOutput: false, htmlOutput: false,
frameHeight: 0, frameHeight: 0,
frameStyle: frameStyle,
}; };
}, },
props: { props: {
@ -280,8 +300,6 @@ export default {
// //
frameLoad() { frameLoad() {
let cfw = this.$refs?.iframe?.contentWindow; let cfw = this.$refs?.iframe?.contentWindow;
if (this.$q.dark.isActive) cfw.document.body.style.color = "white";
cfw.document.body.style.margin = "0";
this.frameHeight = Math.min( this.frameHeight = Math.min(
cfw.document.body.scrollHeight, cfw.document.body.scrollHeight,
this.maxHeight this.maxHeight
@ -304,5 +322,6 @@ export default {
} }
iframe { iframe {
width: 100%; width: 100%;
display: block;
} }
</style> </style>