Browse Source

修改,新增学车必看和考前须知样式6

JXDS18FUJT 2 years ago
parent
commit
5b07a9b56e
2 changed files with 12 additions and 5 deletions
  1. 5 1
      src/api/index.ts
  2. 7 4
      src/views/marked/index.tsx

+ 5 - 1
src/api/index.ts

@@ -46,7 +46,11 @@ const api = {
     markdown(name:string){
         return request({
             url:`https://nbjk-h5.zzxcx.net/markdown/${name}.json`,
-            method:'get'
+            method:'get',
+            headers: {
+                isLogin: "1",
+            }
+            
         })
 
     }

+ 7 - 4
src/views/marked/index.tsx

@@ -1,5 +1,5 @@
 import './index.less'
-import React, { useState } from "react";
+import React, { useEffect, useState } from "react";
 import Item from 'antd/lib/list/Item';
 import api from '~/api'
 export const Marked: React.FC = (props: any) => {
@@ -411,9 +411,12 @@ export const Marked: React.FC = (props: any) => {
     ])
     let query = new URLSearchParams(window.location.search)
     let name = query.get('markdown')
-    api.markdown(name || '').then(res => {
-        setJsonData(res.data.data)
-    })
+    useEffect(()=>{
+        api.markdown(name || '').then(res => {
+            setJsonData(res.data.data)
+        })
+    },[])
+
     return (
         <div id="marked">
             {jsonData.map((oneLevel, index0) => {