Przeglądaj źródła

feat: 界面样式、前进后退按钮

ChenYangfan 6 lat temu
rodzic
commit
dbc0256964

+ 2 - 2
src/App.vue

@@ -6,7 +6,7 @@
       elevate-on-scroll
     >
       <v-app-bar-nav-icon @click.stop="drawer = !drawer"/>
-      <v-toolbar-title>JVVM 模拟器</v-toolbar-title>
+      <v-toolbar-title><strong>JVVM</strong></v-toolbar-title>
     </v-app-bar>
 
     <v-content>
@@ -87,5 +87,5 @@ export default {
 }
 </script>
 
-<style lang="scss" scoped>
+<style lang="scss">
 </style>

+ 12 - 5
src/components/JFrame.vue

@@ -1,15 +1,17 @@
 <template>
   <div>
-    {{name}}
-    <div>
+    <h3 class="pb-2">{{name}}</h3>
+    <div class="code">
       <div>
-        local vars
+        <strong>
+          local vars
+        </strong>
         <div :key="local + index" v-for="(local, index) in frame.localVars">
           {{local}}
         </div>
       </div>
       <div>
-        operand stack
+        <strong>operand stack</strong>
         <div :key="stack + index" v-for="(stack, index) in frame.operandStack">
           {{stack}}
         </div>
@@ -35,5 +37,10 @@ export default {
 </script>
 
 <style lang="scss" scoped>
-
+.code {
+  font-family: monospace;
+}
+strong {
+  color: rgb(176, 74, 75);
+}
 </style>

+ 7 - 44
src/components/JVMCode.vue

@@ -1,5 +1,6 @@
 <template>
   <div>
+    <h3 class="pb-2">当前帧字节码</h3>
     <pre v-for="(line, index) of code" :key="index + line"><code>{{line}}</code></pre>
   </div>
 </template>
@@ -7,50 +8,8 @@
 <script>
 export default {
   name: 'JVMCode',
-  data () {
-    return {
-      code: ['INVOKE_STATIC index: 12',
-        'BIPUSH value : 22',
-        'ISTORE_1',
-        'NEW index: 13',
-        'DUP',
-        'LDC index: 14',
-        'ILOAD_1',
-        'INVOKE_SPECIAL index: 15',
-        'ASTORE_2',
-        'ALOAD_2',
-        'GETFIELD index: 6',
-        'ISTORE_3',
-        'ALOAD_2',
-        'INSTANCEOF index: 13',
-        'IFEQ offset: 9',
-        'ALOAD_2',
-        'LDC index: 16',
-        'PUTFIELD index: 6',
-        'ALOAD_2',
-        'ASTORE_2',
-        'ALOAD_2',
-        'INVOKE_VIRTUAL index: 17',
-        'POP',
-        'ALOAD_2',
-        'GETFIELD index: 8',
-        'IFNE offset: 7',
-        'ALOAD_2',
-        'INVOKE_VIRTUAL index: 18',
-        'GETSTATIC index: 1',
-        'ISTORE index: 4',
-        'IINC index : 4num : 1',
-        'ILOAD index: 4',
-        'PUTSTATIC index: 1',
-        'ALOAD_2',
-        'INVOKE_VIRTUAL index: 19',
-        'ALOAD_2',
-        'ASTORE index: 5',
-        'ALOAD index: 5',
-        'INVOKE_INTERFACE index: 20',
-        'RETURN'
-      ]
-    }
+  props: {
+    code: Array
   }
 }
 </script>
@@ -60,4 +19,8 @@ code::before {
   content: '';
 }
 
+code {
+  box-shadow: none !important;
+}
+
 </style>

+ 1 - 1
src/components/Memory.vue

@@ -1,6 +1,6 @@
 <template>
   <div>
-    内存
+    <h3 class="pb-2">内存</h3>
     <slot></slot>
   </div>
 </template>

+ 17 - 4
src/components/MemoryObject.vue

@@ -1,8 +1,10 @@
 <template>
-  <div>
-    {{object.id}}
-    <div :key="index" v-for="(item, index) in object.members">
-      {{index}} : {{item}}
+  <div class="object">
+    <strong>
+      ID: {{object.id}}
+    </strong>
+    <div class="code" :key="index" v-for="(item, index) in object.members">
+      <strong class="index">{{index}} :</strong> {{item}}
     </div>
   </div>
 </template>
@@ -20,5 +22,16 @@ export default {
 </script>
 
 <style lang="scss" scoped>
+.object {
+  padding-bottom: 16px;
+}
+
+.index {
+  color: rgb(176, 74, 75);
+}
 
+.code {
+  font-family: monospace;
+  font-size: 14px;
+}
 </style>

+ 10 - 1
src/components/SourceCode.vue

@@ -1,5 +1,8 @@
 <template>
-  <prism language="java">{{ sourceCode }}</prism>
+  <div>
+    <h3>Java 源代码</h3>
+    <prism language="java">{{ sourceCode }}</prism>
+  </div>
 </template>
 
 <script>
@@ -39,6 +42,12 @@ export default {
 
 <style lang="scss" scoped>
 pre {
+  background: none;
   padding: 0;
 }
+
+code {
+  background: none !important;
+  box-shadow: none !important;
+}
 </style>

+ 27 - 2
src/views/JVVM.vue

@@ -1,12 +1,20 @@
 <template>
   <div class="jvvm">
     <source-code class="source-code"></source-code>
-    <j-v-m-code class="j-v-m-code"></j-v-m-code>
+    <j-v-m-code class="j-v-m-code" :code="state.currentFrame.code"></j-v-m-code>
     <j-frame class="current-frame" name="current frame" :frame="state.currentFrame"></j-frame>
     <j-frame class="optional-frame" name="optional frame" :frame="state.optionalNextFrame"></j-frame>
     <memory v-if="state.memory" class="memory">
       <memory-object :key="name" :object="value" v-for="(value, name) in state.memory.objects" class="object"></memory-object>
     </memory>
+    <div class="actions">
+      <v-btn class="mx-2" fab dark small color="#5a6a7a" @click="goPreFrame">
+        <v-icon dark>mdi-arrow-left</v-icon>
+      </v-btn>
+      <v-btn class="mx-2" fab dark small color="#5a6a7a" @click="goNextFrame">
+        <v-icon dark>mdi-arrow-right</v-icon>
+      </v-btn>
+    </div>
   </div>
 </template>
 
@@ -54,29 +62,46 @@ export default {
 <style lang="scss" scoped>
 .source-code {
   grid-area: source;
+  max-height: calc(100vh - 90px);
+  overflow: auto;
 }
 
 .j-v-m-code {
   grid-area: jvm-code;
+  max-height: calc(100vh - 90px);
+  overflow: auto;
 }
 
 .current-frame {
   grid-area: current-frame;
+  min-height: calc(50vh - 70px);
+  overflow: auto;
 }
 
 .optional-frame {
   grid-area: optional-frame;
+  min-height: calc(50vh - 70px);
+  overflow: auto;
 }
 
 .memory {
+
   grid-area: memory;
+  max-height: calc(50vh - 44px);
+  overflow: auto;
 }
 
 .jvvm {
   display: grid;
+  position: relative;
   grid-gap: 24px;
   grid-template-columns: 1fr 1fr 1fr 1fr;
-  grid-template-rows: 1fr 1fr 1fr 1fr;
   grid-template-areas: 'source jvm-code current-frame optional-frame' 'source jvm-code memory memory' 'source jvm-code memory memory';
 }
+
+.actions {
+  position: absolute;
+  left: 12px;
+  bottom: 24px;
+}
 </style>