From ebf8d3069c4a3655c77b818fb33afa09abcbfadc Mon Sep 17 00:00:00 2001
From: 简律纯 <i@jyunko.cn>
Date: Fri, 3 Nov 2023 14:23:41 +0800
Subject: chore: 添加CNAME
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 logUploader.vue | 65 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 65 insertions(+)
 create mode 100644 logUploader.vue

(limited to 'logUploader.vue')

diff --git a/logUploader.vue b/logUploader.vue
new file mode 100644
index 0000000..4856bce
--- /dev/null
+++ b/logUploader.vue
@@ -0,0 +1,65 @@
+<template>
+    <v-app>
+      <v-container>
+        <v-file-input label="选择日志文件" v-model="selectedFile"></v-file-input>
+  
+        <v-btn color="primary" @click="uploadFile">上传</v-btn>
+  
+        <v-card>
+          <v-card-text>
+            <pre v-html="formattedLog"></pre>
+          </v-card-text>
+        </v-card>
+      </v-container>
+    </v-app>
+  </template>
+  
+  <script>
+  export default {
+    data() {
+      return {
+        selectedFile: null,
+        logContent: '',
+      }
+    },
+  
+    computed: {
+      formattedLog() {
+        return this.logContent.replace(/\[(.*?)\]/g, '<span class="log-tag">$1</span>');
+      },
+    },
+  
+    methods: {
+      async uploadFile() {
+        if (!this.selectedFile) {
+          alert('请先选择日志文件！');
+          return;
+        }
+  
+        const formData = new FormData();
+        formData.append('file', this.selectedFile);
+  
+        try {
+          const response = await fetch('/api/upload', { method: 'POST', body: formData });
+          const data = await response.json();
+  
+          if (data.success) {
+            this.logContent = data.logContent;
+          } else {
+            alert('上传出错！');
+          }
+        } catch (error) {
+          console.error(error);
+          alert('发生错误，请稍后重试！');
+        }
+      },
+    },
+  }
+  </script>
+  
+  <style>
+  .log-tag {
+    color: green;
+  }
+  </style>
+  
\ No newline at end of file
-- 
cgit v1.2.3-70-g09d2

