liyongli 2 rokov pred
rodič
commit
944ca67399
7 zmenil súbory, kde vykonal 98 pridanie a 29 odobranie
  1. 2 1
      package.json
  2. 20 0
      pnpm-lock.yaml
  3. 3 6
      src/App.vue
  4. 8 0
      src/errorPage/404.vue
  5. 5 1
      src/main.js
  6. 22 0
      src/router/index.js
  7. 38 21
      src/view/onlineText.vue

+ 2 - 1
package.json

@@ -13,7 +13,8 @@
     "@wangeditor/editor-for-vue": "^5.1.12",
     "core-js": "^3.6.5",
     "element-plus": "^2.2.18",
-    "vue": "^3.0.0"
+    "vue": "^3.0.0",
+    "vue-router": "^4.1.6"
   },
   "devDependencies": {
     "@vue/cli-plugin-babel": "~4.5.15",

+ 20 - 0
pnpm-lock.yaml

@@ -15,6 +15,7 @@ specifiers:
   eslint: ^6.7.2
   eslint-plugin-vue: ^7.0.0
   vue: ^3.0.0
+  vue-router: ^4.1.6
 
 dependencies:
   '@element-plus/icons-vue': registry.npmmirror.com/@element-plus/icons-vue/2.0.10_vue@3.2.41
@@ -23,6 +24,7 @@ dependencies:
   core-js: registry.npmmirror.com/core-js/3.25.5
   element-plus: registry.npmmirror.com/element-plus/2.2.18_vue@3.2.41
   vue: registry.npmmirror.com/vue/3.2.41
+  vue-router: registry.npmmirror.com/vue-router/4.1.6_vue@3.2.41
 
 devDependencies:
   '@vue/cli-plugin-babel': registry.npmmirror.com/@vue/cli-plugin-babel/4.5.19_3e626a8f2db1292e54f20a65b7bf557f
@@ -2433,6 +2435,12 @@ packages:
       prettier: registry.npmmirror.com/prettier/2.7.1
     dev: true
 
+  registry.npmmirror.com/@vue/devtools-api/6.5.0:
+    resolution: {integrity: sha512-o9KfBeaBmCKl10usN4crU53fYtC1r7jJwdGKjPT24t348rHxgfpZ0xL3Xm/gLUYnc0oTp8LAmrxOeLyu6tbk2Q==, registry: https://registry.npm.taobao.org/, tarball: https://registry.npmmirror.com/@vue/devtools-api/-/devtools-api-6.5.0.tgz}
+    name: '@vue/devtools-api'
+    version: 6.5.0
+    dev: false
+
   registry.npmmirror.com/@vue/preload-webpack-plugin/1.1.2_502c618fc8a7d35df07e93275324a2d0:
     resolution: {integrity: sha512-LIZMuJk38pk9U9Ur4YzHjlIyMuxPlACdBIHH9/nGYVTsaGKOSnSuELiE8vS9wa+dJpIYspYUOqk+L1Q4pgHQHQ==, registry: https://registry.npm.taobao.org/, tarball: https://registry.npmmirror.com/@vue/preload-webpack-plugin/-/preload-webpack-plugin-1.1.2.tgz}
     id: registry.npmmirror.com/@vue/preload-webpack-plugin/1.1.2
@@ -12204,6 +12212,18 @@ packages:
     dev: true
     optional: true
 
+  registry.npmmirror.com/vue-router/4.1.6_vue@3.2.41:
+    resolution: {integrity: sha512-DYWYwsG6xNPmLq/FmZn8Ip+qrhFEzA14EI12MsMgVxvHFDYvlr4NXpVF5hrRH1wVcDP8fGi5F4rxuJSl8/r+EQ==, registry: https://registry.npm.taobao.org/, tarball: https://registry.npmmirror.com/vue-router/-/vue-router-4.1.6.tgz}
+    id: registry.npmmirror.com/vue-router/4.1.6
+    name: vue-router
+    version: 4.1.6
+    peerDependencies:
+      vue: ^3.2.0
+    dependencies:
+      '@vue/devtools-api': registry.npmmirror.com/@vue/devtools-api/6.5.0
+      vue: registry.npmmirror.com/vue/3.2.41
+    dev: false
+
   registry.npmmirror.com/vue-style-loader/4.1.3:
     resolution: {integrity: sha512-sFuh0xfbtpRlKfm39ss/ikqs9AbKCoXZBpHeVZ8Tx650o0k0q/YCM7FRvigtxpACezfq6af+a7JeqVTWvncqDg==, registry: https://registry.npm.taobao.org/, tarball: https://registry.npmmirror.com/vue-style-loader/-/vue-style-loader-4.1.3.tgz}
     name: vue-style-loader

+ 3 - 6
src/App.vue

@@ -1,14 +1,11 @@
 <template>
-  <online-text  />
+  <router-view />
 </template>
 
 <script>
-import onlineText from "./view/onlineText.vue";
 export default {
-  name: "App",
-  components: {
-    onlineText
-  },
+  name: 'App',
+  components: {},
 };
 </script>
 

+ 8 - 0
src/errorPage/404.vue

@@ -0,0 +1,8 @@
+<template>
+  <el-result icon="warning" title="404提示" sub-title="你找的页面走丢了~">
+  </el-result>
+</template>
+
+<script setup></script>
+
+<style></style>

+ 5 - 1
src/main.js

@@ -1,10 +1,14 @@
 import { createApp } from "vue";
 import ElementPlus from "element-plus";
 import "element-plus/dist/index.css";
+
+import router from "./router";
+
+
 import App from "./App.vue";
 import * as ElementPlusIconsVue from "@element-plus/icons-vue";
 
-const app = createApp(App);
+const app = createApp(App).use(router);
 for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
   app.component(key, component);
 }

+ 22 - 0
src/router/index.js

@@ -0,0 +1,22 @@
+import { createRouter, createWebHashHistory } from 'vue-router';
+
+import NotFound from "../errorPage/404.vue";
+
+const router = createRouter({
+  history: createWebHashHistory(process.env.BASE_URL),
+  routes: [
+    {
+      path: '/Home',
+      name: 'Home',
+      component: () =>
+        import(/* webpackChunkName: "Home" */ '../view/onlineText.vue'),
+    },
+    {
+        path: "/:pathMatch(.*)*",
+        name: "NotFound",
+        component: NotFound
+    }
+  ],
+});
+
+export default router;

+ 38 - 21
src/view/onlineText.vue

@@ -11,21 +11,26 @@
           文章内容
           <el-button
             type="primary"
-            style="float: right; margin-top: 0.3em; margin-right: 0.5em;padding: 0 1.8em;"
+            style="
+              float: right;
+              margin-top: 0.3em;
+              margin-right: 0.5em;
+              padding: 0 1.8em;
+            "
             @click="getServer"
             :loading="loading"
           >
             校验
           </el-button>
           <el-button
-              class="clearError"
-              type="primary"
-              style="float: right; margin-top: 0.3em; margin-right: 0.5em"
-              @click="clearError"
-              :icon="Delete"
-            >
-              清空
-            </el-button>
+            class="clearError"
+            type="primary"
+            style="float: right; margin-top: 0.3em; margin-right: 0.5em"
+            @click="clearError"
+            :icon="Delete"
+          >
+            清空
+          </el-button>
         </div>
         <div class="Fle">
           <Editor v-model:rawText="rawText" />
@@ -166,7 +171,6 @@
               <el-radio :label="1">已忽略: {{ search.list1.length }}</el-radio>
               <el-radio :label="2">已替换: {{ search.list2.length }}</el-radio>
             </el-radio-group>
-            
           </div>
         </div>
         <div class="search">
@@ -549,24 +553,37 @@ function back(v, i, type) {
 function getServer() {
   if (!window.fetch || !rawText.value) return;
   loading.value = true;
-  const ele = document.createElement("div");
+  const ele = document.createElement('div');
   ele.innerHTML = rawText.value;
+  if (!urlData.spm) {
+    if (location.replace) location.replace('https://home.sxtvs.net/');
+    else location.href = 'https://home.sxtvs.net/';
+  }
   window
     .fetch('https://topic.smcic.net/youmei/check', {
       method: 'POST',
       body: JSON.stringify({
         raw: ele.innerText,
-        text: rawText.value
+        text: rawText.value,
       }),
       headers: {
         'Content-Type': 'application/json',
-        "spm": urlData.spm || ""
+        spm: urlData.spm || '',
       },
     })
     .then(json => json.json())
     .then(res => {
       loading.value = false;
-      if (!res || res.code !== 0) return ElMessage.error('请稍后再试!');
+      if (!res || res.code !== 0)
+        return ElMessage({
+          type: 'error',
+          message: res.message || '请稍后再试!',
+          onClose() {
+            if (res.code !== 1000) return;
+            if (location.replace) location.replace('https://home.sxtvs.net/');
+            else location.href = 'https://home.sxtvs.net/';
+          },
+        });
       search.list = res.data.checklist || [];
       search.list1 = [];
       search.list2 = [];
@@ -599,13 +616,13 @@ function getServer() {
 }
 
 function geturl() {
-    let search = (location.search || "").replace("?", "").split("&");
-    let obj = {};
-    for (let i = 0; i < search.length; i++) {
-        const v = search[i].split("=");
-        obj[v[0]] = v[1] || "";
-    }
-    return obj
+  let search = (location.search || '').replace('?', '').split('&');
+  let obj = {};
+  for (let i = 0; i < search.length; i++) {
+    const v = search[i].split('=');
+    obj[v[0]] = v[1] || '';
+  }
+  return obj;
 }
 
 function changeTab(i) {