xiongzhu 2 лет назад
Родитель
Сommit
1b6251cd49
7 измененных файлов с 79 добавлено и 6 удалено
  1. 0 4
      index.html
  2. 2 0
      package.json
  3. 8 0
      src/main.ts
  4. 1 0
      src/typings/global.d.ts
  5. 35 0
      src/utils/console.ts
  6. 23 2
      src/views/page/HomeView.vue
  7. 10 0
      yarn.lock

+ 0 - 4
index.html

@@ -80,10 +80,6 @@
                 </div>
             </div>
         </div>
-        <!-- <script src="//cdn.jsdelivr.net/npm/eruda"></script>
-        <script>
-            eruda.init()
-        </script> -->
         <script type="module" src="/src/main.ts"></script>
     </body>
 </html>

+ 2 - 0
package.json

@@ -27,6 +27,8 @@
     "@vicons/tabler": "^0.12.0",
     "@vueuse/core": "^9.13.0",
     "date-fns": "^2.29.3",
+    "eruda": "^3.0.0",
+    "eruda-code": "^2.1.0",
     "highlight.js": "^11.7.0",
     "html2canvas": "^1.4.1",
     "katex": "^0.16.4",

+ 8 - 0
src/main.ts

@@ -7,6 +7,14 @@ import { setupRouter } from './router'
 import queryString from 'query-string'
 import { fetchOpenid, fetchJsapiSign, fetchPay, fetchRedirectUrl } from '@/api'
 import resolveUrl from 'resolve-url'
+import { useStorage } from '@vueuse/core'
+import { init as initEruda } from '@/utils/console'
+
+if (useStorage('showConsole', 0).value > new Date().getTime()) {
+    initEruda()
+} else if (location.origin.includes('http://192.168')) {
+    initEruda()
+}
 
 const query = queryString.parse(location.href.split('?')[1])
 

+ 1 - 0
src/typings/global.d.ts

@@ -7,6 +7,7 @@ interface Window {
     nc?: any
 }
 declare module 'resolve-url'
+declare module 'eruda'
 
 declare namespace wx {
     function addCard(a: any): any

+ 35 - 0
src/utils/console.ts

@@ -0,0 +1,35 @@
+
+let initialized = false
+let loading = false
+async function init() {
+    // eruda.init({
+    //     useShadowDom: false,
+    //     defaults: {
+    //         theme: 'Material Oceanic'
+    //     }
+    // })
+    // eruda.add(erudaCode)
+    // eruda.add(erudaFeatures)
+    // eruda.add(erudaFps)
+    // eruda.add(erudaTiming)
+    // eruda.add(erudaMemory)
+    if (loading || initialized) return
+    loading = true
+    import('eruda')
+        .then(res => {
+            loading = false
+            const eruda = res.default
+            eruda.init({
+                useShadowDom: true,
+                defaults: {
+                    theme: 'Material Oceanic'
+                }
+            })
+            initialized = true
+        })
+        .catch(e => {
+            loading = false
+            console.log(e)
+        })
+}
+export { init }

+ 23 - 2
src/views/page/HomeView.vue

@@ -5,7 +5,7 @@
     >
         <n-page-header>
             <template #title>
-                <div class="flex items-center py-3 lg:py-8 pl-4 lg:pl-52">
+                <div class="flex items-center py-3 lg:py-8 pl-4 lg:pl-52" @click="showConsoleEve">
                     <n-avatar :size="isMobile ? 'small' : 'large'" :src="logo"></n-avatar>
                     <span class="ml-3 text-white text-base lg:text-lg alimamaShuHeiTi">CHILLGPT </span>
                 </div>
@@ -38,7 +38,8 @@
             <img src="@/assets/brand.png" class="w-3/4 max-w-3xl" alt="" />
 
             <div class="text-xs leading-6 lg:text-lg text-white text-center mt-4 w-[90%] max-w-4xl">
-                CHILLGPT 是人工智能技术驱动的自然语言处理工具,它能够通过理解和学习人类的语言来进行对话,还能根据聊天的上下文进行互动,真正像人类一样来聊天交流,甚至能完成撰写邮件、视频脚本、文案、翻译、代码,写论文等任务。
+                CHILLGPT
+                是人工智能技术驱动的自然语言处理工具,它能够通过理解和学习人类的语言来进行对话,还能根据聊天的上下文进行互动,真正像人类一样来聊天交流,甚至能完成撰写邮件、视频脚本、文案、翻译、代码,写论文等任务。
             </div>
 
             <NConfigProvider
@@ -147,6 +148,8 @@ import imgItem03 from '@/assets/png-03.png'
 import imgItem05 from '@/assets/png-05.png'
 import imgItem06 from '@/assets/png-06.png'
 import imgItem07 from '@/assets/png-07.png'
+import { init as initEruda } from '@/utils/console'
+import { useStorage } from '@vueuse/core'
 
 const { isMobile } = useBasicLayout()
 
@@ -241,6 +244,24 @@ function logout() {
         }
     })
 }
+let clickNum = 0
+let to: any = null
+function showConsoleEve() {
+    clickNum++
+    if (clickNum >= 10) {
+        initEruda()
+        useStorage('showConsole', 0).value = new Date().getTime() + 60 * 60 * 1000
+        clickNum = 0
+        return
+    } else {
+        if (to) {
+            clearTimeout(to)
+        }
+        to = setTimeout(() => {
+            clickNum = 0
+        }, 1000)
+    }
+}
 </script>
 
 <style lang="less" scoped>

+ 10 - 0
yarn.lock

@@ -2803,6 +2803,16 @@ error-ex@^1.3.1:
   dependencies:
     is-arrayish "^0.2.1"
 
+eruda-code@^2.1.0:
+  version "2.1.0"
+  resolved "https://registry.npmmirror.com/eruda-code/-/eruda-code-2.1.0.tgz#c5bdfab1f3ba2455e4188279c2887209631f96b3"
+  integrity sha512-4RR6ct314ufDUG0b7nBYjCqaXThgcbiqnxblGJoN98SaWCSuSnMk3DEMUPXV522z0/BzkEcqfcRlayjO1EaQng==
+
+eruda@^3.0.0:
+  version "3.0.0"
+  resolved "https://registry.npmmirror.com/eruda/-/eruda-3.0.0.tgz#d54b2c9c727f1604796a82c4b62975d1e9988ef1"
+  integrity sha512-6L8A8aBHOQv0rqeBlNdJEl/hl6OAdLVRtJlVmBIlIJ6Fe1a92HFXO58jHLC0vFyuKV0deTjYjRaWwLo9lJ9K9A==
+
 es-abstract@^1.19.0, es-abstract@^1.20.4:
   version "1.21.2"
   resolved "https://registry.npmjs.org/es-abstract/-/es-abstract-1.21.2.tgz"