From b62bc2537093f6fda13eb26589de71bee44a22fc Mon Sep 17 00:00:00 2001 From: qiukai <123456@qq.com> Date: Wed, 27 Nov 2024 08:43:17 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E7=89=B9=E8=89=B2=E4=B8=93=E5=8C=BA?= =?UTF-8?q?=E5=89=8D=E7=AB=AF=E5=9F=8B=E7=82=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/forge/Information/Pages/help.jsx | 12 ++++ src/forge/Information/Pages/homepage/uos.jsx | 15 ++++- src/forge/Information/Pages/main.jsx | 13 +++- src/forge/Information/Pages/newsDetail.jsx | 12 ++++ src/forge/Information/Pages/projectSource.jsx | 13 +++- src/forge/Information/Pages/source.jsx | 13 ++++ src/forge/Information/Pages/sourceDetail.jsx | 13 ++++ src/forge/Information/Pages/zoneVIP.jsx | 13 ++++ src/forge/Information/api.js | 8 +++ src/forge/Information/index.jsx | 6 +- src/forge/Information/utils.js | 63 +++++++++++++++++++ 11 files changed, 175 insertions(+), 6 deletions(-) create mode 100644 src/forge/Information/utils.js diff --git a/src/forge/Information/Pages/help.jsx b/src/forge/Information/Pages/help.jsx index 62ebcefb..f1f2952c 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 a83dc33c..b00f9abf 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 ff5659fc..35e7407f 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 62cb7b5f..98f547e6 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 c5f5aecb..0bcbf56b 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 eafa8121..f5ba0939 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 fcf77b0f..775df358 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 0351e2ac..2ecec220 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 62f6b46a..84ec1293 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 9dadf8f5..582e7667 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 00000000..7abf1ebd --- /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 From 0f09a0e8b0cf534800ee8625e7cb3458ca700035 Mon Sep 17 00:00:00 2001 From: qiukai <123456@qq.com> Date: Wed, 27 Nov 2024 14:27:48 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E5=85=B6=E4=BD=99=E9=A6=96=E9=A1=B5?= =?UTF-8?q?=E5=9F=8B=E7=82=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/forge/Information/Pages/JCC/homePage.jsx | 13 ++++++++ src/forge/Information/Pages/headerPage.jsx | 14 ++++++++- .../Information/Pages/headerPageZone1.jsx | 15 ++++++++- .../Information/Pages/headerPagebyCCF.jsx | 14 +++++++++ src/forge/Information/utils.js | 31 +++++++++++-------- 5 files changed, 72 insertions(+), 15 deletions(-) diff --git a/src/forge/Information/Pages/JCC/homePage.jsx b/src/forge/Information/Pages/JCC/homePage.jsx index 8faf0209..ad040ec8 100644 --- a/src/forge/Information/Pages/JCC/homePage.jsx +++ b/src/forge/Information/Pages/JCC/homePage.jsx @@ -15,6 +15,8 @@ import PartnerJcc from './Component/partnerJcc'; import '../../indexZone1.scss' import './index.scss' import { Popover, Tabs } from 'antd'; +import {getUniqueIdentifier,getUserName,getBrowserPlatform,getBrowserBrand} from '../../utils' +import {setZoneVisits} from '../../api' let tabTimer = undefined; @@ -33,6 +35,17 @@ function HeaderPageJCC(props){ {imageUrl: visionZy, title: '资源易共享'}, {imageUrl: visionJz, title: '价值可交换'} ] + + 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/headerPage.jsx b/src/forge/Information/Pages/headerPage.jsx index 654fa1dc..3060d378 100644 --- a/src/forge/Information/Pages/headerPage.jsx +++ b/src/forge/Information/Pages/headerPage.jsx @@ -7,7 +7,8 @@ import shijian from '../img/shijian.png'; import { getHomePageList , gethomePageDocList , getAllList, getPartnerList } from '../api'; import axios from 'axios'; import Partner from '../Component/partner'; - +import {getUniqueIdentifier,getUserName,getBrowserPlatform,getBrowserBrand} from '../utils' +import {setZoneVisits} from '../api' function HeaderPage(props){ const [ projectList , setProjectList ] = useState(undefined); const [ personList , setPersonList ] = useState(undefined); @@ -16,6 +17,17 @@ function HeaderPage(props){ const { deptId } = props.match.params; const { data, id, 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(id){ getProjectList(); diff --git a/src/forge/Information/Pages/headerPageZone1.jsx b/src/forge/Information/Pages/headerPageZone1.jsx index 92735fa8..5fc23f12 100644 --- a/src/forge/Information/Pages/headerPageZone1.jsx +++ b/src/forge/Information/Pages/headerPageZone1.jsx @@ -30,7 +30,8 @@ import ra from '../img/ra.png' import title from '../img/title.png' import Partner from '../Component/partner'; import '../indexZone1.scss'; -import { getProjectsLists, getPartnerList, getHomePageList, gethomePageDocList , getDocList , getSubDocList } from '../api' +import { getProjectsLists, getPartnerList, getHomePageList, gethomePageDocList , getDocList , getSubDocList,setZoneVisits } from '../api' +import {getUniqueIdentifier,getUserName,getBrowserPlatform,getBrowserBrand} from '../utils' function HeaderPage(props){ @@ -72,6 +73,18 @@ function HeaderPage(props){ { title: '成长认证', icon: intro3, desc: '开发者可以通过完成开源项⽬对应的任务,赢取对应能⼒成长认证,开源项⽬对应的⾼级任务将获得对应等级L2或⾼级别的知识产权授权,同时解锁下⼀级别成长任务' }, { title: '顶级认证', icon: intro4, desc: '参与顶级项⽬“⾹⼭”的贡献者,将获得中国科学院计算技术研究所副所长、研究员,北京开源芯⽚研究院⾸席科学家,RISC-V国际基⾦会理事会成员包云岗签名贡献者证书' } ] + + 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){ // getProjectList(); diff --git a/src/forge/Information/Pages/headerPagebyCCF.jsx b/src/forge/Information/Pages/headerPagebyCCF.jsx index 6aec5786..81bffc52 100644 --- a/src/forge/Information/Pages/headerPagebyCCF.jsx +++ b/src/forge/Information/Pages/headerPagebyCCF.jsx @@ -15,6 +15,9 @@ import "slick-carousel/slick/slick-theme.css"; import Slider from 'react-slick'; import Left from '../../../home/Img/left.png'; import Right from '../../../home/Img/right.png'; +import {getUniqueIdentifier,getUserName,getBrowserPlatform,getBrowserBrand} from '../utils' +import {setZoneVisits} from '../api' + function HeaderPageCCF(props) { @@ -42,6 +45,17 @@ function HeaderPageCCF(props) { afterChange: (index)=> setTag(index) } + 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||cateId) { getProjectList(); diff --git a/src/forge/Information/utils.js b/src/forge/Information/utils.js index 7abf1ebd..3113730f 100644 --- a/src/forge/Information/utils.js +++ b/src/forge/Information/utils.js @@ -16,23 +16,23 @@ export const getUniqueIdentifier = () => { //获取uuid } export const getUserName = (user) => { //获取用户名 - if(user && user.username) return user.username + if(user && user.login) return user.login return '' } export const getBrowserPlatform = () => { const userAgent = navigator.userAgent; let platform; - if (userAgent.indexOf("Win") !== -1) { - platform = "Windows"; - } else if (userAgent.indexOf("Mac") !== -1) { + if (userAgent.includes("Mac")) { platform = "MacOS"; - } else if (userAgent.indexOf("X11") !== -1 || userAgent.indexOf("Linux") !== -1) { + } else if (userAgent.includes("X11") || userAgent.includes("Linux")) { platform = "Linux"; - } else if (userAgent.indexOf("Android") !== -1) { + } else if (userAgent.includes("Android")) { platform = "Android"; - } else if (userAgent.indexOf("like Mac") !== -1) { + } else if (userAgent.includes("iPhone") || userAgent.includes("iPad")) { platform = "iOS"; + } else if (userAgent.includes("Win")) { + platform = "Windows"; } else { platform = "Unknown"; } @@ -45,19 +45,24 @@ export const getBrowserBrand = () => { //获取浏览器信息 let brand = "Unknown"; // 检测浏览器品牌 - if (userAgent.includes("Chrome")) { - brand = "Chrome"; - } else if (userAgent.includes("Firefox")) { + 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")) { + } else if (userAgent.includes("Edge") || userAgent.includes("Edg")) { brand = "Edge"; + }else if (userAgent.includes("QQBrowser")) { + brand = "QQBrowser"; + } else if (userAgent.includes("LBBrowser") ) { + brand = "liebao"; + }else if (userAgent.includes("360")) { + brand = "360Browser"; } else if (userAgent.includes("Opera") || userAgent.includes("OPR")) { brand = "Opera"; - } - + } else if (userAgent.includes("Chrome")) { + brand = "Chrome"; + } return brand; } \ No newline at end of file