Ver código fonte

Merge branch 'master' of http://47.100.18.120:3000/ChenYangFan/jvvm-front-end

ChenYangfan 6 anos atrás
pai
commit
f191c9dd3e
2 arquivos alterados com 14 adições e 23 exclusões
  1. 8 20
      src/components/SourceCode.vue
  2. 6 3
      src/views/JVVM.vue

+ 8 - 20
src/components/SourceCode.vue

@@ -1,7 +1,10 @@
 <template>
   <div>
     <h3>Java 源代码</h3>
-    <prism language="java">{{ sourceCode }}</prism>
+    <section :key="item.filename" v-for="item in sourceCode" style="margin-bottom: 24px">
+      <div><strong>{{item.filename}}</strong></div>
+      <prism language="java">{{ item.code }}</prism>
+    </section>
   </div>
 </template>
 
@@ -16,25 +19,10 @@ export default {
   components: {
     Prism
   },
-  data () {
-    return {
-      sourceCode: `public class MyArray {
-    MyArray next;
-    char[] letters;
-    int[][] nums;
-    MyArray[][] refs;
-
-    public static void main(String[] args) {
-        MyArray a = new MyArray();
-        a.next = new MyArray();
-        a.letters = new char[10];
-        a.nums = new int[4][5];
-        a.nums[2][2] = 1;
-        a.refs = new MyArray[3][3];
-        a.refs[1][1] = new MyArray();
-    }
-}
-`
+  props: {
+    sourceCode: {
+      default: () => [],
+      type: Array
     }
   }
 }

+ 6 - 3
src/views/JVVM.vue

@@ -2,17 +2,18 @@
   <div class="jvvm">
     <j-heap class="heap" :objects="state.memory?state.memory.objects:[]"
             @click-detail="handleCheckDetail($event, 'j-heap-detail')"></j-heap>
-    <j-method class="method" :objects="state.memory?state.memory.classes:[]"
+    <j-method class="method" :methods="state.memory?state.memory.classes:[]"
               @click-detail="handleCheckDetail($event, 'j-method-detail')"></j-method>
-    <j-thread class="thread" :objects="state.thread?state.thread.threadStack:[]"
+    <j-thread class="thread" :thread-stack="state.thread?state.thread.threadStack:[]"
               @click-detail="handleCheckDetail($event, 'j-thread-detail')"></j-thread>
     <component class="detail" :is="detailComponent" :data="detail"></component>
     <div class="other-info">
       info
+      <source-code :source-code="currentCodeData" />
     </div>
     <div class="actions">
       <v-btn class="mx-2" dark small color="#5a6a7a" @click="()=>{}">
-        查看源码
+        {{showSource?'查看字节码':'查看源码'}}
       </v-btn>
       <v-btn class="mx-2" fab dark small color="#5a6a7a" @click="goPreFrame">
         <v-icon dark>mdi-arrow-left</v-icon>
@@ -32,10 +33,12 @@ import JThread from '@/components/JThread'
 import JMethodDetail from '@/components/JMethodDetail'
 import JThreadDetail from '@/components/JThreadDetail'
 import JHeapDetail from '@/components/JHeapDetail'
+import SourceCode from '@/components/SourceCode'
 
 export default {
   name: 'JVVM',
   components: {
+    SourceCode,
     JThread,
     JThreadDetail,
     JMethod,