diff --git a/src/forge/Information/Pages/help.jsx b/src/forge/Information/Pages/help.jsx index 62ebcefbf..f1f2952c5 100644 --- a/src/forge/Information/Pages/help.jsx +++ b/src/forge/Information/Pages/help.jsx @@ -9,6 +9,8 @@ import RenderHtml from '../../../components/render-html'; import { Base64 } from 'js-base64'; import { getTocContent } from '../../../common/marked'; import TreeByWikiSidebar from '../../Wiki/components/treeByWikiSidebar'; +import {getUniqueIdentifier,getUserName,getBrowserPlatform,getBrowserBrand} from '../utils'; +import {setZoneVisits} from '../api' function ProjectSource(props) { const [loading, setLoading] = useState(false); @@ -102,7 +104,17 @@ function ProjectSource(props) { }) }, [wikiDetail]) + useEffect(() =>{ + //浏览埋点 + let uuid = getUniqueIdentifier() + let url = props.location.pathname + let platform = getBrowserPlatform() + let browser = getBrowserBrand() + let username = getUserName(props.current_user) + // if(!username) uuid = getUniqueIdentifier() + let remark = ` 操作系统:${platform};浏览器:${browser};` + setZoneVisits({url,username,uuid,remark}) // 点击事件 const handleClick = (event) => { let target = event.target; diff --git a/src/forge/Information/Pages/homepage/uos.jsx b/src/forge/Information/Pages/homepage/uos.jsx index a83dc33cc..b00f9abfc 100644 --- a/src/forge/Information/Pages/homepage/uos.jsx +++ b/src/forge/Information/Pages/homepage/uos.jsx @@ -1,4 +1,4 @@ -import React,{ } from 'react'; +import React,{ useEffect , useState } from 'react'; import Introduction from './component/introduction'; import News from './component/news'; import Project from './component/project'; @@ -8,8 +8,21 @@ import Partner from './component/partner'; import SpecialProjects from './component/specialProjects'; import '../../indexZone1.scss' import './index.scss' +import {getUniqueIdentifier,getUserName,getBrowserPlatform,getBrowserBrand} from '../../utils' +import {setZoneVisits} from '../../api' + function HeaderPageUos(props){ + useEffect(()=>{ + let uuid = getUniqueIdentifier() + let url = props.location.pathname + let platform = getBrowserPlatform() + let browser = getBrowserBrand() + let username = getUserName(props.current_user) + // if(!username) uuid = getUniqueIdentifier() + let remark = ` 操作系统:${platform};浏览器:${browser};` + setZoneVisits({url,username,uuid,remark}) + },[]) const { data } = props; return( diff --git a/src/forge/Information/Pages/main.jsx b/src/forge/Information/Pages/main.jsx index ff5659fcd..35e7407f6 100644 --- a/src/forge/Information/Pages/main.jsx +++ b/src/forge/Information/Pages/main.jsx @@ -13,6 +13,8 @@ import DefaultImg from '../Component/defaultImg'; import { getNewsAllList , getNewsHotList } from '../api'; import { tempConfig, tempEnum } from '../tempInfo'; import { httpUrl } from '../fetch'; +import {getUniqueIdentifier,getUserName,getBrowserPlatform,getBrowserBrand} from '../utils'; +import {setZoneVisits} from '../api' function Main(props){ @@ -26,7 +28,16 @@ function Main(props){ const { deptId , cateId } = props.match.params; const { id, temp, role, history, sectionCmsTitle } = props; - + useEffect(()=>{ + let uuid = getUniqueIdentifier() + let url = props.location.pathname + let platform = getBrowserPlatform() + let browser = getBrowserBrand() + let username = getUserName(props.current_user) + // if(!username) uuid = getUniqueIdentifier() + let remark = ` 操作系统:${platform};浏览器:${browser};` + setZoneVisits({url,username,uuid,remark}) + },[]) const menu = ( diff --git a/src/forge/Information/Pages/newsDetail.jsx b/src/forge/Information/Pages/newsDetail.jsx index 62cb7b5fd..98f547e6e 100644 --- a/src/forge/Information/Pages/newsDetail.jsx +++ b/src/forge/Information/Pages/newsDetail.jsx @@ -12,6 +12,8 @@ import CommentList from '../Component/comments/list' import { connect } from 'react-redux'; import { withRouter } from "react-router"; import { setZoneDetail, setNewsDetail } from '../../../redux/actions/server'; +import {getUniqueIdentifier,getUserName,getBrowserPlatform,getBrowserBrand} from '../utils'; +import {setZoneVisits} from '../api' function NewsDetail(props){ @@ -28,6 +30,16 @@ function NewsDetail(props){ setMeta() } + useEffect(()=>{ + let uuid = getUniqueIdentifier() + let url = props.location.pathname + let platform = getBrowserPlatform() + let browser = getBrowserBrand() + let username = getUserName(props.current_user) + // if(!username) uuid = getUniqueIdentifier() + let remark = ` 操作系统:${platform};浏览器:${browser};` + setZoneVisits({url,username,uuid,remark}) + },[]) useEffect(()=>{ let initialContent = undefined; // 设置网页标题 diff --git a/src/forge/Information/Pages/projectSource.jsx b/src/forge/Information/Pages/projectSource.jsx index c5f5aecb2..0bcbf56b5 100644 --- a/src/forge/Information/Pages/projectSource.jsx +++ b/src/forge/Information/Pages/projectSource.jsx @@ -8,7 +8,8 @@ import axios from 'axios'; import { getProjectsLists , getProjectsTypeLists } from '../api'; import nodata from '../img/nodata.png'; import { tempEnum } from '../tempInfo'; - +import {getUniqueIdentifier,getUserName,getBrowserPlatform,getBrowserBrand} from '../utils' +import {setZoneVisits} from '../api' const { Search } = Input; function ProjectSource(props){ @@ -23,6 +24,16 @@ function ProjectSource(props){ const [ value , setValue ] = useState(undefined); const [ loading , setLoading ] = useState(false); const { id, temp, sectionProjectTitle } = props; + useEffect(()=>{ + let uuid = getUniqueIdentifier() + let url = props.location.pathname + let platform = getBrowserPlatform() + let browser = getBrowserBrand() + let username = getUserName(props.current_user) + // if(!username) uuid = getUniqueIdentifier() + let remark = ` 操作系统:${platform};浏览器:${browser};` + setZoneVisits({url,username,uuid,remark}) + },[]) useEffect(()=>{ if(id){ diff --git a/src/forge/Information/Pages/source.jsx b/src/forge/Information/Pages/source.jsx index eafa81217..f5ba09396 100644 --- a/src/forge/Information/Pages/source.jsx +++ b/src/forge/Information/Pages/source.jsx @@ -8,6 +8,8 @@ import Nodata from '../../Nodata'; import ImgGreen from '../img/green_nodata.png'; import '../indexZone1.scss'; import { FlexAJ } from '../../Component/layout'; +import {getUniqueIdentifier,getUserName,getBrowserPlatform,getBrowserBrand} from '../utils'; +import {setZoneVisits} from '../api' const { Search } = Input; @@ -25,6 +27,17 @@ function Source(props){ const limit = 21; const { id , temp, history, role, sectionResourceTitle } = props; + useEffect(()=>{ + let uuid = getUniqueIdentifier() + let url = props.location.pathname + let platform = getBrowserPlatform() + let browser = getBrowserBrand() + let username = getUserName(props.current_user) + // if(!username) uuid = getUniqueIdentifier() + let remark = ` 操作系统:${platform};浏览器:${browser};` + setZoneVisits({url,username,uuid,remark}) + },[]) + useEffect(()=>{ id && getLists(); },[id,chooseTypeId,chooseZoneId,page,search]) diff --git a/src/forge/Information/Pages/sourceDetail.jsx b/src/forge/Information/Pages/sourceDetail.jsx index fcf77b0f4..775df358f 100644 --- a/src/forge/Information/Pages/sourceDetail.jsx +++ b/src/forge/Information/Pages/sourceDetail.jsx @@ -7,6 +7,8 @@ import { httpUrl } from '../fetch'; import { AlignCenter, FlexAJ } from '../../Component/layout'; import SourceIcon from '../img/sourceIcon.png'; import { addMeta, setSeoMeta } from 'educoder'; +import {getUniqueIdentifier,getUserName,getBrowserPlatform,getBrowserBrand} from '../utils'; +import {setZoneVisits} from '../api' function SourceDetail(props){ @@ -15,6 +17,17 @@ function SourceDetail(props){ const zonedetail = props.data; const {temp} = props; + useEffect(()=>{ + let uuid = getUniqueIdentifier() + let url = props.location.pathname + let platform = getBrowserPlatform() + let browser = getBrowserBrand() + let username = getUserName(props.current_user) + // if(!username) uuid = getUniqueIdentifier() + let remark = ` 操作系统:${platform};浏览器:${browser};` + setZoneVisits({url,username,uuid,remark}) + },[]) + useEffect(()=>{ if(sourceid){ getDetails(); diff --git a/src/forge/Information/Pages/zoneVIP.jsx b/src/forge/Information/Pages/zoneVIP.jsx index 0351e2ac8..2ecec220c 100644 --- a/src/forge/Information/Pages/zoneVIP.jsx +++ b/src/forge/Information/Pages/zoneVIP.jsx @@ -8,6 +8,8 @@ import MemberApply from '../Component/memberApply'; import { getVIPLists, getAuditStatus, applyJoin } from '../api'; import nodata from '../img/nodata.png'; import MemberList from '../Component/memberList'; +import {getUniqueIdentifier,getUserName,getBrowserPlatform,getBrowserBrand} from '../utils'; +import {setZoneVisits} from '../api' import '../indexZone1.scss'; @@ -25,6 +27,17 @@ function ZoneVIP(props){ const [ memberStatus , setMemberStatus] = useState(memberStatusEnum.notMember); const { id, showNotification, checkIfLogin, showLoginDialog, temp, sectionMemberTitle } = props; + useEffect(()=>{ + let uuid = getUniqueIdentifier() + let url = props.location.pathname + let platform = getBrowserPlatform() + let browser = getBrowserBrand() + let username = getUserName(props.current_user) + // if(!username) uuid = getUniqueIdentifier() + let remark = ` 操作系统:${platform};浏览器:${browser};` + setZoneVisits({url,username,uuid,remark}) + },[]) + useEffect(()=>{ if(id){ setIsSpin(true); diff --git a/src/forge/Information/api.js b/src/forge/Information/api.js index 62f6b46a5..84ec12934 100644 --- a/src/forge/Information/api.js +++ b/src/forge/Information/api.js @@ -439,3 +439,11 @@ export function getRoleList(){ }) } + // 组织升级为企业 +export function setZoneVisits(data) { + return fetch({ + url: `/zone/open/zoneVisits`, + method: 'POST', + data + }) +} diff --git a/src/forge/Information/index.jsx b/src/forge/Information/index.jsx index 9dadf8f5e..582e7667f 100644 --- a/src/forge/Information/index.jsx +++ b/src/forge/Information/index.jsx @@ -115,7 +115,6 @@ function Index(props){ const sourcedetail = pathname.indexOf(`/zone/${deptId}/newdetail/`)>-1 && isPhone(); const {current_user} = props; - console.log('deptId', deptId); useEffect(()=>{ @@ -149,8 +148,9 @@ function Index(props){ } setData(data); document.title= data && data.mainTitle; - setId(data.id); - if(data.id){ + + if(data && data.id){ + setId(data.id); getAdminUrl(data.id); getRole(data.id) } diff --git a/src/forge/Information/utils.js b/src/forge/Information/utils.js new file mode 100644 index 000000000..7abf1ebde --- /dev/null +++ b/src/forge/Information/utils.js @@ -0,0 +1,63 @@ +export const generateUUID = () => { //生成uuid + return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) { + var r = Math.random() * 16 | 0, + v = c === 'x' ? r : (r & 0x3 | 0x8); + return v.toString(16); + }); +} + +export const getUniqueIdentifier = () => { //获取uuid + let uniqueId = localStorage.getItem('uniqueId'); + if (!uniqueId) { + uniqueId = generateUUID(); + localStorage.setItem('uniqueId', uniqueId); + } + return uniqueId; +} + +export const getUserName = (user) => { //获取用户名 + if(user && user.username) return user.username + return '' +} + +export const getBrowserPlatform = () => { + const userAgent = navigator.userAgent; + let platform; + if (userAgent.indexOf("Win") !== -1) { + platform = "Windows"; + } else if (userAgent.indexOf("Mac") !== -1) { + platform = "MacOS"; + } else if (userAgent.indexOf("X11") !== -1 || userAgent.indexOf("Linux") !== -1) { + platform = "Linux"; + } else if (userAgent.indexOf("Android") !== -1) { + platform = "Android"; + } else if (userAgent.indexOf("like Mac") !== -1) { + platform = "iOS"; + } else { + platform = "Unknown"; + } + + return platform; +} + +export const getBrowserBrand = () => { //获取浏览器信息 + const userAgent = navigator.userAgent; + let brand = "Unknown"; + + // 检测浏览器品牌 + if (userAgent.includes("Chrome")) { + brand = "Chrome"; + } else if (userAgent.includes("Firefox")) { + brand = "Firefox"; + } else if (userAgent.includes("Safari") && !userAgent.includes("Chrome")) { + brand = "Safari"; + } else if (userAgent.includes("MSIE") || userAgent.includes("Trident")) { + brand = "Internet Explorer"; + } else if (userAgent.includes("Edge")) { + brand = "Edge"; + } else if (userAgent.includes("Opera") || userAgent.includes("OPR")) { + brand = "Opera"; + } + + return brand; +} \ No newline at end of file