update component ShowLog
This commit is contained in:
parent
68123de87d
commit
431745d22e
|
|
@ -1,6 +1,6 @@
|
||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
import React, { useEffect, useState } from "react";
|
import React, { useEffect, useState } from "react";
|
||||||
import { useParams } from "react-router-dom";
|
import { Navigate, useParams } from "react-router-dom";
|
||||||
import { getLog } from "../../api/apiLog";
|
import { getLog } from "../../api/apiLog";
|
||||||
import "./ShowLog.css";
|
import "./ShowLog.css";
|
||||||
const ShowLog = () => {
|
const ShowLog = () => {
|
||||||
|
|
@ -12,14 +12,27 @@ const ShowLog = () => {
|
||||||
let tempContent = "";
|
let tempContent = "";
|
||||||
const res = await axios.get(getLog + "/" + name);
|
const res = await axios.get(getLog + "/" + name);
|
||||||
setLog(res.data);
|
setLog(res.data);
|
||||||
console.log(res.data)
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log(error);
|
console.log(error);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const scrollToElement = () => {
|
||||||
|
const hash = window.location.hash;
|
||||||
|
if (hash) {
|
||||||
|
const targetElement = document.getElementById(hash.slice(1)); // Replace "3" with the desired id
|
||||||
|
if (targetElement) {
|
||||||
|
targetElement.scrollIntoView({ behavior: "smooth" });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
getContentLog();
|
getContentLog();
|
||||||
|
setTimeout(() => {
|
||||||
|
scrollToElement()
|
||||||
|
}, 1000);
|
||||||
}, []);
|
}, []);
|
||||||
|
console.log(window.location.hash);
|
||||||
return (
|
return (
|
||||||
<div className="main">
|
<div className="main">
|
||||||
<div className="detectedDiv">
|
<div className="detectedDiv">
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue