liyongli 2 anos atrás
pai
commit
343d897800
3 arquivos alterados com 8 adições e 635 exclusões
  1. 4 4
      README.md
  2. 0 627
      src/view/onlineText copy.vue
  3. 4 4
      src/view/onlineText.vue

+ 4 - 4
README.md

@@ -2,22 +2,22 @@
 
 ## Project setup
 ```
-yarn install
+pnpm install
 ```
 
 ### Compiles and hot-reloads for development
 ```
-yarn serve
+pnpm serve
 ```
 
 ### Compiles and minifies for production
 ```
-yarn build
+pnpm build
 ```
 
 ### Lints and fixes files
 ```
-yarn lint
+pnpm lint
 ```
 
 ### Customize configuration

+ 0 - 627
src/view/onlineText copy.vue

@@ -1,627 +0,0 @@
-<template>
-  <div>
-    <Head />
-    <div class="onlineTextMain">
-      <div class="flex1">
-        <div class="btn-grounp">
-          文章内容
-          <el-button
-            type="primary"
-            size="small"
-            style="float: right; margin-top: 0.6em; margin-right: 0.5em"
-            @click="getServer"
-            :loading="loading"
-            >校验</el-button
-          >
-        </div>
-        <div class="Fle">
-          <Editor ref="editor" :rawText="rawText" />
-        </div>
-      </div>
-      <div class="flex2" :loading="loading">
-        <div class="btn-grounp">检索结果</div>
-        <div style="padding: 1em 1em 0 1em">
-          <div class="tabs">
-            <div class="tab" style="background-color: #2974ff; color: #fff">
-              <p>全部错误</p>
-              {{ search.tabs[0] ? search.tabs[0].num : 0 }}
-            </div>
-            <div
-              class="tab"
-              @click="() => changeTab(1)"
-              v-if="tabSelect[1]"
-              :style="{
-                backgroundColor: getTypeError(1, 'rgba'),
-                color: getTypeError(1, 'rgb'),
-              }"
-            >
-              <p>严重错误</p>
-              {{ search.tabs[1] ? search.tabs[1].num : 0 }}
-            </div>
-            <div class="tab" @click="() => changeTab(1)" v-else>
-              <p>严重错误</p>
-              {{ search.tabs[1] ? search.tabs[1].num : 0 }}
-            </div>
-            <div
-              class="tab"
-              @click="() => changeTab(3)"
-              v-if="tabSelect[3]"
-              :style="{
-                backgroundColor: getTypeError(3, 'rgba'),
-                color: getTypeError(3, 'rgb'),
-              }"
-            >
-              <p>一般错误</p>
-              {{ search.tabs[3] ? search.tabs[3].num : 0 }}
-            </div>
-            <div class="tab" @click="() => changeTab(3)" v-else>
-              <p>一般错误</p>
-              {{ search.tabs[3] ? search.tabs[3].num : 0 }}
-            </div>
-            <div
-              class="tab"
-              @click="() => changeTab(2)"
-              v-if="tabSelect[2]"
-              :style="{
-                backgroundColor: getTypeError(2, 'rgba'),
-                color: 'rgba(73, 92, 202, 1)',
-              }"
-            >
-              <p>疑错</p>
-              {{ search.tabs[2] ? search.tabs[2].num : 0 }}
-            </div>
-            <div class="tab" @click="() => changeTab(2)" v-else>
-              <p>疑错</p>
-              {{ search.tabs[2] ? search.tabs[2].num : 0 }}
-            </div>
-            <div
-              class="tab"
-              v-if="tabSelect[4]"
-              @click="() => changeTab(4)"
-              :style="{
-                backgroundColor: getTypeError(4, 'rgba'),
-                color: 'rgba(156, 133, 255, 1)',
-              }"
-            >
-              <p>
-                自定义错误
-                <el-popover
-                  placement="top-start"
-                  :width="200"
-                  trigger="hover"
-                  content="若自定义的词语(除正词外)与系统通用逻辑检测出的错误重叠,则该词语会展示两条错误。例:“尊守”为系统检出的错误,若同时设置“尊守”为禁用词,则当文章中出现“尊守”时,会展示两条错误,一条为系统检出,一条为自定义禁用词错误。"
-                >
-                  <template #reference>
-                    <div
-                      style="
-                        display: inline-block;
-                        border: 1px solid rgb(156, 133, 255);
-                        vertical-align: middle;
-                        border-radius: 50%;
-                        width: 1.2em;
-                        height: 1.2em;
-                        line-height: 1.2em;
-                        text-align: center;
-                        color: #5e5e5e;
-                      "
-                    >
-                      ?
-                    </div>
-                  </template>
-                </el-popover>
-              </p>
-              {{ search.tabs[4] ? search.tabs[4].num : 0 }}
-            </div>
-            <div class="tab" v-else @click="() => changeTab(4)">
-              <p>
-                自定义错误
-                <el-popover
-                  placement="top-start"
-                  :width="200"
-                  trigger="hover"
-                  content="若自定义的词语(除正词外)与系统通用逻辑检测出的错误重叠,则该词语会展示两条错误。例:“尊守”为系统检出的错误,若同时设置“尊守”为禁用词,则当文章中出现“尊守”时,会展示两条错误,一条为系统检出,一条为自定义禁用词错误。"
-                >
-                  <template #reference>
-                    <div
-                      style="
-                        display: inline-block;
-                        border: 1px solid rgb(156, 133, 255);
-                        vertical-align: middle;
-                        border-radius: 50%;
-                        width: 1.2em;
-                        height: 1.2em;
-                        line-height: 1.2em;
-                        text-align: center;
-                        color: #5e5e5e;
-                      "
-                    >
-                      ?
-                    </div>
-                  </template>
-                </el-popover>
-              </p>
-              {{ search.tabs[4] ? search.tabs[4].num : 0 }}
-            </div>
-          </div>
-          <div>
-            <el-radio-group v-model="tabAct">
-              <el-radio :label="0">未处理: {{ search.list.length }}</el-radio>
-              <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">
-          <div v-if="tabAct === 0">
-            <div v-for="(item, index) in search.list" :key="index">
-              <div v-for="(v, i) in item.htmlWords" :key="'son' + i">
-                <div
-                  v-if="tabSelect[item.um_error_level]"
-                  class="searchEnd"
-                  :style="{
-                    borderColor: getTypeError(item.um_error_level, 'rgb'),
-                    backgroundColor:
-                      select === index
-                        ? getTypeError(item.um_error_level, 'rgba')
-                        : '',
-                  }"
-                  @click="() => changeselect(index, item.type.belongId)"
-                >
-                  <p style="display: flex">
-                    <span
-                      v-text="v.word"
-                      :style="{
-                        flex: 1,
-                        color: getTypeError(item.um_error_level, 'rgb'),
-                      }"
-                    ></span>
-                    <span
-                      style="flex: 1; text-align: right; color: #2dc76d"
-                      v-text="item.suggest[i]"
-                    ></span>
-                  </p>
-                  <p style="line-height: 2.5em">
-                    <span
-                      :style="{
-                        float: 'left',
-                        fontSize: '12px',
-                      }"
-                    >
-                      <span style="vertical-align: middle; margin-right: 5px">
-                        错误原因:{{ item.youmeiWordName }}
-                      </span>
-                      <el-popover
-                        v-if="item.explanation"
-                        placement="top-start"
-                        :width="200"
-                        trigger="hover"
-                        :content="item.explanation"
-                      >
-                        <template #reference>
-                          <div
-                            style="
-                              display: inline-block;
-                              border: 1px solid #5e5e5e;
-                              vertical-align: middle;
-                              border-radius: 50%;
-                              width: 1.2em;
-                              height: 1.2em;
-                              line-height: 1.2em;
-                              text-align: center;
-                              color: #5e5e5e;
-                            "
-                          >
-                            ?
-                          </div>
-                        </template>
-                      </el-popover>
-                    </span>
-                    <span style="float: right; text-align: right">
-                      <span
-                        class="btn"
-                        @click.stop="
-                          () =>
-                            clearEle(
-                              item.colorPosition,
-                              item.suggest[i],
-                              index,
-                              2
-                            )
-                        "
-                        >替换</span
-                      >
-                      <span
-                        class="btn"
-                        @click.stop="
-                          () =>
-                            clearEle(
-                              item.colorPosition,
-                              item.wordHtml,
-                              index,
-                              1
-                            )
-                        "
-                        >忽略</span
-                      >
-                    </span>
-                    <span style="clear: both; display: block"></span>
-                  </p>
-                </div>
-              </div>
-            </div>
-            <el-empty
-              description="所选类型下暂无信息"
-              v-if="!search.list || !search.list.length"
-            />
-          </div>
-          <div v-if="tabAct === 1">
-            <div v-for="(item, index) in search.list1 || []" :key="index">
-              <div v-for="(v, i) in item.htmlWords" :key="'son' + i">
-                <div
-                  class="searchEnd"
-                  v-if="tabSelect[item.um_error_level]"
-                  :style="{
-                    borderColor: getTypeError(item.um_error_level, 'rgb'),
-                    backgroundColor:
-                      select === index
-                        ? getTypeError(item.um_error_level, 'rgba')
-                        : '',
-                  }"
-                  @click="() => changeselect(index, item.type.belongId)"
-                >
-                  <p style="display: flex">
-                    <span
-                      v-text="v.word"
-                      :style="{
-                        flex: 1,
-                        color: getTypeError(item.um_error_level, 'rgb'),
-                      }"
-                    ></span>
-                    <span
-                      style="flex: 1; text-align: right; color: #2dc76d"
-                      v-text="item.suggest[i]"
-                    ></span>
-                  </p>
-                  <p style="line-height: 2.5em">
-                    <span
-                      :style="{
-                        float: 'left',
-                        fontSize: '12px',
-                      }"
-                    >
-                      <span style="vertical-align: middle; margin-right: 5px">
-                        错误原因:{{ item.youmeiWordName }}
-                      </span>
-                      <el-popover
-                        v-if="item.explanation"
-                        placement="top-start"
-                        :width="200"
-                        trigger="hover"
-                        :content="item.explanation"
-                      >
-                        <template #reference>
-                          <div
-                            style="
-                              display: inline-block;
-                              border: 1px solid #5e5e5e;
-                              vertical-align: middle;
-                              border-radius: 50%;
-                              width: 1.2em;
-                              height: 1.2em;
-                              line-height: 1.2em;
-                              text-align: center;
-                              color: #5e5e5e;
-                            "
-                          >
-                            ?
-                          </div>
-                        </template>
-                      </el-popover>
-                    </span>
-                    <span style="float: right; text-align: right">
-                      <span class="btn" @click.stop="() => back(item, index, 1)"
-                        >撤销</span
-                      >
-                    </span>
-                    <span style="clear: both; display: block"></span>
-                  </p>
-                </div>
-              </div>
-            </div>
-            <el-empty
-              description="所选类型下暂无信息"
-              v-if="!search.list1 || !search.list1.length"
-            />
-          </div>
-          <div v-if="tabAct === 2">
-            <div v-for="(item, index) in search.list2 || []" :key="index">
-              <div v-for="(v, i) in item.htmlWords" :key="'son' + i">
-                <div
-                  class="searchEnd"
-                  v-if="tabSelect[item.um_error_level]"
-                  :style="{
-                    borderColor: getTypeError(item.um_error_level, 'rgb'),
-                    backgroundColor:
-                      select === index
-                        ? getTypeError(item.um_error_level, 'rgba')
-                        : '',
-                  }"
-                  @click="() => changeselect(index, item.type.belongId)"
-                >
-                  <p style="display: flex">
-                    <span
-                      v-text="v.word"
-                      :style="{
-                        flex: 1,
-                        color: getTypeError(item.um_error_level, 'rgb'),
-                      }"
-                    ></span>
-                    <span
-                      style="flex: 1; text-align: right; color: #2dc76d"
-                      v-text="item.suggest[i]"
-                    ></span>
-                  </p>
-                  <p style="line-height: 2.5em">
-                    <span
-                      :style="{
-                        float: 'left',
-                        fontSize: '12px',
-                      }"
-                    >
-                      <span style="vertical-align: middle; margin-right: 5px">
-                        错误原因:{{ item.youmeiWordName }}
-                      </span>
-                      <el-popover
-                        v-if="item.explanation"
-                        placement="top-start"
-                        :width="200"
-                        trigger="hover"
-                        :content="item.explanation"
-                      >
-                        <template #reference>
-                          <div
-                            style="
-                              display: inline-block;
-                              border: 1px solid #5e5e5e;
-                              vertical-align: middle;
-                              border-radius: 50%;
-                              width: 1.2em;
-                              height: 1.2em;
-                              line-height: 1.2em;
-                              text-align: center;
-                              color: #5e5e5e;
-                            "
-                          >
-                            ?
-                          </div>
-                        </template>
-                      </el-popover>
-                    </span>
-                    <span style="float: right; text-align: right">
-                      <span class="btn" @click.stop="() => back(item, index, 2)"
-                        >撤销</span
-                      >
-                    </span>
-
-                    <span style="clear: both; display: block"></span>
-                  </p>
-                </div>
-              </div>
-            </div>
-            <el-empty
-              description="所选类型下暂无信息"
-              v-if="!search.list2 || !search.list2.length"
-            />
-          </div>
-        </div>
-      </div>
-    </div>
-  </div>
-</template>
-
-<script setup>
-import Head from "../components/head.vue";
-import Editor from "../components/editor.vue";
-import { ElMessage } from "element-plus";
-import { reactive, ref, nextTick } from "vue";
-import errType from "../../config/errtype";
-document.title = "文本检测";
-const loading = ref(false);
-const rawText = ref("");
-const editor = ref(null);
-const tabSelect = reactive([true, true, true, true, true]);
-
-let search = reactive({
-  list: [],
-  list1: [],
-  list2: [],
-  tabs: [
-    {
-      num: 0,
-    },
-  ],
-});
-const tabAct = ref(0);
-const select = ref(0);
-
-function getTypeError(key, type) {
-  if (type == "rgb") return type + "(" + errType[key] + ")";
-  if (type == "rgba") return type + "(" + errType[key] + ", 0.1)";
-  return "";
-}
-
-function changeselect(index) {
-  const oldEle = document.querySelector(
-    "[data-umpos='" + search.list[select.value].colorPosition + "']"
-  );
-  const newEle = document.querySelector(
-    "[data-umpos='" + search.list[index].colorPosition + "']"
-  );
-  oldEle.style.backgroundColor = "";
-  newEle.style.backgroundColor =
-    "rgba(" + errType[search.list[index].um_error_level] + ", 0.5)";
-  select.value = index;
-}
-
-function clearEle(colorPosition, text, i, type) {
-  const newEle = document.querySelector("[data-umpos='" + colorPosition + "']");
-  newEle.setAttribute("style", "");
-  newEle.innerText = text;
-  const item = JSON.parse(JSON.stringify(search.list[i]));
-  search["list" + type].push(item);
-  search.list.splice(i, 1);
-  rawText.value = document.querySelector(".Fle .text").innerHTML;
-}
-
-function back(v, i, type) {
-  const newEle = document.querySelector(
-    "[data-umpos='" + v.colorPosition + "']"
-  );
-  newEle.style.borderColor = "rgb(" + errType[v.um_error_level] + ")";
-  const item = JSON.parse(JSON.stringify(search["list" + type][i]));
-  search.list.push(item);
-  search["list" + type].splice(i, 1);
-}
-function getServer() {
-  if (!window.fetch) return;
-  loading.value = true;
-  window
-    .fetch("https://topic.smcic.net/youmei/check", {
-      method: "POST",
-      body: JSON.stringify({
-        text: editor.value.valueHtml,
-      }),
-      headers: {
-        "Content-Type": "application/json",
-      },
-    })
-    .then(json => {
-      return json.json();
-    })
-    .then(res => {
-      loading.value = false;
-      console.log(res);
-      if (!res || res.code !== 0) return ElMessage.error("请稍后再试!");
-      search.list = res.data.checklist || [];
-      rawText.value = res.data.rawText || "";
-      nextTick(() => {
-        const tabs = [
-            {
-                num: 0
-            }
-        ]
-        for (let i = 0; i < search.list.length; i++) {
-          const item = search.list[i];
-        //   const ele = document.querySelector(
-        //     "[data-umpos='" + item.colorPosition + "']"
-        //   );
-        //   ele.style.borderColor = "rgb(" + errType[item.um_error_level] + ")";
-          if (!tabs[item.um_error_level])
-          tabs[item.um_error_level] = {
-              num: 0,
-            };
-            tabs[0].num += 1;
-          tabs[item.um_error_level].num += 1;
-          if (i !== 0) continue;
-        //   ele.style.backgroundColor =
-        //     "rgba(" + errType[item.um_error_level] + ",0.5)";
-        }
-        search.tabs = tabs;
-        console.log(tabs)
-      });
-    });
-}
-
-function changeTab(i) {
-  console.log(i);
-  tabSelect[i] = !tabSelect[i];
-}
-</script>
-
-<style scoped>
-.onlineTextMain {
-  padding: 1em;
-  display: flex;
-}
-
-.onlineTextMain > div {
-  flex: 3;
-  margin-right: 0.5em;
-  border: 1px solid #eee;
-  height: calc(100vh - 106px);
-}
-.onlineTextMain .flex2 {
-  flex: 2;
-}
-.onlineTextMain > div:last-child {
-  margin-right: 0;
-}
-.btn-grounp {
-  color: #666;
-  background-color: #f9fafc;
-  line-height: 2.52em;
-  padding-left: 0.5em;
-  border-bottom: 1px solid #eee;
-}
-.search {
-  padding: 1em;
-  font-size: 12px;
-  height: calc(100% - 172px);
-  overflow: auto;
-}
-.searchEnd {
-  border: 1px solid;
-  border-top: 4px solid;
-  margin-bottom: 1em;
-  padding: 5px 35px;
-  font-size: 14px;
-  line-height: 1.5em;
-}
-.btn {
-  display: inline-block;
-  background: rgba(41, 116, 255, 0.1);
-  color: #2974ff;
-  padding: 3px 15px;
-  height: 1.5em;
-  line-height: 1.5em;
-  margin-left: 0.3em;
-  cursor: pointer;
-}
-
-.flex1 {
-  line-height: 1.5em;
-  min-height: 1.5em;
-}
-.flex1 span {
-  display: inline-block;
-}
-.tabs {
-  display: flex;
-  margin: 0.5em 0;
-}
-.tab {
-  flex: 1;
-  margin-left: 0.3em;
-  border-radius: 2px;
-  background-color: rgba(144, 144, 144, 0.1);
-  color: #909090;
-  line-height: 1.6em;
-  padding: 3px 15px;
-  text-align: center;
-  font-size: 12px;
-  cursor: pointer;
-}
-
-.Fle {
-    height: calc(100vh-226px);
-}
-</style>
-
-<style>
-.el-popper.is-light,
-.el-popper .el-popper__arrow::before {
-  background-color: #2974ff !important;
-  color: #fff;
-  border-color: #2974ff !important;
-}
-</style>

+ 4 - 4
src/view/onlineText.vue

@@ -1,7 +1,7 @@
 <template>
   <div class="edito">
     <Head />
-    <div class="onlineTextMain">
+    <div class="onlineTextMain" v-loading="loading" element-loading-background="rgba(225,225,225,0.1)">
       <div class="flex1">
         <div class="btn-grounp">
           文章内容
@@ -13,11 +13,11 @@
             >校验</el-button
           >
         </div>
-        <div class="Fle" v-loading="loading">
+        <div class="Fle">
           <Editor ref="editor" :rawText="rawText" />
         </div>
       </div>
-      <div class="flex2" v-loading="loading">
+      <div class="flex2">
         <div class="btn-grounp">检索结果</div>
         <div style="padding: 1em 1em 0 1em">
           <div class="tabs">
@@ -525,7 +525,7 @@ function getServer() {
       return json.json();
     })
     .then(res => {
-      loading.value = false;
+    //   loading.value = false;
       if (!res || res.code !== 0) return ElMessage.error("请稍后再试!");
       search.list = res.data.checklist || [];
       search.list1 = [];