Browse Source

修复错误

Kevin Jiang 2 years ago
parent
commit
d2c8cf0820

+ 14 - 0
package-lock.json

@@ -24,6 +24,7 @@
       "devDependencies": {
         "@rushstack/eslint-patch": "^1.1.4",
         "@types/jsdom": "^20.0.0",
+        "@types/marked": "^4.3.0",
         "@types/node": "^16.11.56",
         "@vitejs/plugin-vue": "^3.0.3",
         "@vitejs/plugin-vue-jsx": "^2.0.1",
@@ -1274,6 +1275,13 @@
       "resolved": "https://registry.npmmirror.com/@types/lodash/-/lodash-4.14.188.tgz",
       "integrity": "sha512-zmEmF5OIM3rb7SbLCFYoQhO4dGt2FRM9AMkxvA3LaADOF1n8in/zGJlWji9fmafLoNyz+FoL6FE0SLtGIArD7w=="
     },
+    "node_modules/@types/marked": {
+      "version": "4.3.0",
+      "resolved": "https://repo.huaweicloud.com/repository/npm/@types/marked/-/marked-4.3.0.tgz",
+      "integrity": "sha512-zK4gSFMjgslsv5Lyvr3O1yCjgmnE4pr8jbG8qVn4QglMwtpvPCf4YT2Wma7Nk95OxUUJI8Z+kzdXohbM7mVpGw==",
+      "dev": true,
+      "license": "MIT"
+    },
     "node_modules/@types/ms": {
       "version": "0.7.31",
       "resolved": "https://registry.npmmirror.com/@types/ms/-/ms-0.7.31.tgz",
@@ -9619,6 +9627,12 @@
       "resolved": "https://registry.npmmirror.com/@types/lodash/-/lodash-4.14.188.tgz",
       "integrity": "sha512-zmEmF5OIM3rb7SbLCFYoQhO4dGt2FRM9AMkxvA3LaADOF1n8in/zGJlWji9fmafLoNyz+FoL6FE0SLtGIArD7w=="
     },
+    "@types/marked": {
+      "version": "4.3.0",
+      "resolved": "https://repo.huaweicloud.com/repository/npm/@types/marked/-/marked-4.3.0.tgz",
+      "integrity": "sha512-zK4gSFMjgslsv5Lyvr3O1yCjgmnE4pr8jbG8qVn4QglMwtpvPCf4YT2Wma7Nk95OxUUJI8Z+kzdXohbM7mVpGw==",
+      "dev": true
+    },
     "@types/ms": {
       "version": "0.7.31",
       "resolved": "https://registry.npmmirror.com/@types/ms/-/ms-0.7.31.tgz",

+ 1 - 0
package.json

@@ -29,6 +29,7 @@
   "devDependencies": {
     "@rushstack/eslint-patch": "^1.1.4",
     "@types/jsdom": "^20.0.0",
+    "@types/marked": "^4.3.0",
     "@types/node": "^16.11.56",
     "@vitejs/plugin-vue": "^3.0.3",
     "@vitejs/plugin-vue-jsx": "^2.0.1",

+ 9 - 5
src/views/search/SearchView.vue

@@ -125,8 +125,8 @@ function search(kwd: string){
     </a-row>
     <a-row class="search-hotword">
       热门关键词:
-      <span v-for="item in hotWords" @click="search(item)" style="cursor: pointer;">
-          {{item}}&nbsp;&nbsp;
+      <span v-for="(item, index) in hotWords" @click="search(item)" :key="index">
+          {{item}}
       </span>
     </a-row>
     <a-row type="flex" class="search-result">
@@ -151,10 +151,14 @@ function search(kwd: string){
     text-align: center;
   }
 
-  .search-hotword{
+  .search-hotword {
     margin-top: 30px;
-    > sapn{
-      magin-left: 20px;
+    span {
+      cursor: pointer;
+      margin-left: 20px;
+      &:hover {
+        text-decoration: underline;
+      }
     }
   }
 

+ 2 - 2
src/views/search/components/SearchResultItem.vue

@@ -28,7 +28,7 @@ function highlight(name: string, content: string){
     let reg = new RegExp('<em>(.*?)<\\/em>', 'g')
     let hlTitles: string[] = []
     let hlTitleOrigins: string[] = []
-    console.log(highlight,"highlight")
+
     if (highlight) {
       hlTitles = highlight[name] || highlight[name+'.exact']
       for (let index in hlTitles) {
@@ -71,7 +71,7 @@ function highlight(name: string, content: string){
   padding: 5px;
   .metadata {
     padding-bottom: 5px;
-    
+
     .author-item {
       margin-left: 1em;