Skip to content

Commit d0a0a17

Browse files
更换首页,修改右边栏
1 parent 80d6758 commit d0a0a17

File tree

9 files changed

+1648
-85
lines changed

9 files changed

+1648
-85
lines changed

src/assets/BiaoChenXuYing.png

37.2 KB
Loading

src/components/home/index.js

Lines changed: 1309 additions & 0 deletions
Large diffs are not rendered by default.

src/components/home/index.less

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
.home {
2+
.content {
3+
position: fixed;
4+
left: 0;
5+
top: 0;
6+
right: 0;
7+
bottom: 0;
8+
font-size: 20px;
9+
text-align: center;
10+
// color: white;
11+
padding-top: 12%;
12+
.home-logo {
13+
width: 220px;
14+
border-radius: 50%;
15+
}
16+
.home-header {
17+
.link {
18+
display: block;
19+
}
20+
}
21+
.home-body {
22+
padding-top: 20px;
23+
.list {
24+
.link {
25+
display: inline-block;
26+
padding: 20px;
27+
color: #033767;
28+
min-width: 80px;
29+
}
30+
.link:hover {
31+
color: rgb(155, 35, 35);
32+
}
33+
}
34+
}
35+
.introduce{
36+
color: #960026;
37+
}
38+
}
39+
}

src/components/home/index2.js

Lines changed: 184 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,184 @@
1+
import './index.less';
2+
import React, { Component } from 'react';
3+
4+
class Index extends Component {
5+
constructor(props) {
6+
super(props);
7+
this.state = {};
8+
}
9+
componentDidMount() {
10+
var SEPARATION = 100,
11+
AMOUNTX = 50,
12+
AMOUNTY = 50;
13+
14+
var container;
15+
var camera, scene, renderer;
16+
17+
var particles,
18+
count = 0;
19+
20+
var mouseX = 0,
21+
mouseY = 0;
22+
23+
var windowHalfX = window.innerWidth / 2;
24+
var windowHalfY = window.innerHeight / 2;
25+
26+
var THREE = window.THREE
27+
// setTimeout(() => {
28+
init();
29+
animate();
30+
// }, 100);
31+
32+
function init() {
33+
container = document.createElement('div');
34+
container.style.position = 'fixed';
35+
container.style.top = '0';
36+
container.style.left = '0';
37+
container.style.zIndex = '-1';
38+
container.style.opacity = '1';
39+
document.body.appendChild(container);
40+
41+
camera = new THREE.PerspectiveCamera(
42+
75,
43+
window.innerWidth / window.innerHeight,
44+
1,
45+
10000,
46+
);
47+
camera.position.z = 1000;
48+
49+
scene = new THREE.Scene();
50+
51+
var numParticles = AMOUNTX * AMOUNTY;
52+
53+
var positions = new Float32Array(numParticles * 3);
54+
var scales = new Float32Array(numParticles);
55+
56+
var i = 0,
57+
j = 0;
58+
59+
for (var ix = 0; ix < AMOUNTX; ix++) {
60+
for (var iy = 0; iy < AMOUNTY; iy++) {
61+
positions[i] = ix * SEPARATION - (AMOUNTX * SEPARATION) / 2; // x
62+
positions[i + 1] = 0; // y
63+
positions[i + 2] = iy * SEPARATION - (AMOUNTY * SEPARATION) / 2; // z
64+
65+
scales[j] = 1;
66+
67+
i += 3;
68+
j++;
69+
}
70+
}
71+
72+
var geometry = new THREE.BufferGeometry();
73+
geometry.addAttribute(
74+
'position',
75+
new THREE.BufferAttribute(positions, 3),
76+
);
77+
geometry.addAttribute('scale', new THREE.BufferAttribute(scales, 1));
78+
79+
var material = new THREE.ShaderMaterial({
80+
uniforms: {
81+
color: { value: new THREE.Color(0x1890ff) },
82+
},
83+
vertexShader:
84+
'attribute float scale;void main() {vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );gl_PointSize = scale * ( 300.0 / - mvPosition.z );gl_Position = projectionMatrix * mvPosition;}',
85+
fragmentShader:
86+
'uniform vec3 color;void main() {if ( length( gl_PointCoord - vec2( 0.5, 0.5 ) ) > 0.475 ) discard;gl_FragColor = vec4( color, 1.0 );}',
87+
});
88+
89+
particles = new THREE.Points(geometry, material);
90+
scene.add(particles);
91+
92+
renderer = new THREE.WebGLRenderer({ antialias: true });
93+
renderer.setClearColor(0xffffff, 1.0);
94+
renderer.setPixelRatio(window.devicePixelRatio);
95+
renderer.setSize(window.innerWidth, window.innerHeight);
96+
container.appendChild(renderer.domElement);
97+
98+
document.addEventListener('mousemove', onDocumentMouseMove, false);
99+
document.addEventListener('touchstart', onDocumentTouchStart, false);
100+
document.addEventListener('touchmove', onDocumentTouchMove, false);
101+
102+
window.addEventListener('resize', onWindowResize, false);
103+
}
104+
105+
function onWindowResize() {
106+
windowHalfX = window.innerWidth / 2;
107+
windowHalfY = window.innerHeight / 2;
108+
109+
camera.aspect = window.innerWidth / window.innerHeight;
110+
camera.updateProjectionMatrix();
111+
112+
renderer.setSize(window.innerWidth, window.innerHeight);
113+
}
114+
115+
function onDocumentMouseMove(event) {
116+
mouseX = event.clientX - windowHalfX;
117+
mouseY = event.clientY - windowHalfY;
118+
}
119+
120+
function onDocumentTouchStart(event) {
121+
if (event.touches.length === 1) {
122+
event.preventDefault();
123+
124+
mouseX = event.touches[0].pageX - windowHalfX;
125+
mouseY = event.touches[0].pageY - windowHalfY;
126+
}
127+
}
128+
129+
function onDocumentTouchMove(event) {
130+
if (event.touches.length === 1) {
131+
event.preventDefault();
132+
133+
mouseX = event.touches[0].pageX - windowHalfX;
134+
mouseY = event.touches[0].pageY - windowHalfY;
135+
}
136+
}
137+
138+
function animate() {
139+
requestAnimationFrame(animate);
140+
141+
render();
142+
}
143+
144+
function render() {
145+
camera.position.x += (mouseX - camera.position.x) * 0.05;
146+
camera.position.y += (-mouseY - camera.position.y) * 0.05;
147+
camera.lookAt(scene.position);
148+
149+
var positions = particles.geometry.attributes.position.array;
150+
var scales = particles.geometry.attributes.scale.array;
151+
152+
var i = 0,
153+
j = 0;
154+
155+
for (var ix = 0; ix < AMOUNTX; ix++) {
156+
for (var iy = 0; iy < AMOUNTY; iy++) {
157+
positions[i + 1] =
158+
Math.sin((ix + count) * 0.3) * 50 +
159+
Math.sin((iy + count) * 0.5) * 50;
160+
161+
scales[j] =
162+
(Math.sin((ix + count) * 0.3) + 1) * 8 +
163+
(Math.sin((iy + count) * 0.5) + 1) * 8;
164+
165+
i += 3;
166+
j++;
167+
}
168+
}
169+
170+
particles.geometry.attributes.position.needsUpdate = true;
171+
particles.geometry.attributes.scale.needsUpdate = true;
172+
173+
renderer.render(scene, camera);
174+
175+
count += 0.1;
176+
}
177+
}
178+
179+
render() {
180+
return <div> 波浪效果 </div>;
181+
}
182+
}
183+
184+
export default Index;

src/components/nav/nav.js

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -95,14 +95,14 @@ class Nav extends Component {
9595
};
9696

9797
initMenu(name) {
98-
let key = '1';
98+
let key = '9';
9999
let navTitle = '';
100100
if (name === '/') {
101-
key = '1';
101+
key = '9';
102102
navTitle = '首页';
103-
} else if (name === '/home') {
103+
} else if (name === '/articles') {
104104
key = '1';
105-
navTitle = '首页';
105+
navTitle = '文章';
106106
} else if (name === '/hot') {
107107
key = '2';
108108
navTitle = '热门';
@@ -304,12 +304,18 @@ class Nav extends Component {
304304
selectedKeys={[this.state.menuCurrent]}
305305
style={{ lineHeight: '64px', borderBottom: 'none' }}
306306
>
307-
<Menu.Item key="1">
308-
<Link to="/home">
307+
<Menu.Item key="9">
308+
<Link to="/">
309309
<Icon type="home" theme="outlined" />
310310
首页
311311
</Link>
312312
</Menu.Item>
313+
<Menu.Item key="1">
314+
<Link to="/articles">
315+
<Icon type="ordered-list" theme="outlined" />
316+
文章
317+
</Link>
318+
</Menu.Item>
313319
<Menu.Item key="2">
314320
<Link to="/hot">
315321
<Icon type="fire" theme="outlined" />
@@ -411,19 +417,29 @@ class Nav extends Component {
411417
closable={false}
412418
onClose={this.onClose}
413419
visible={this.state.visible}
414-
height={335}
420+
height={420}
415421
>
416422
<div className="drawer">
417423
<p onClick={this.onClose}>
418-
<Link to="/home">
424+
<Link to="/">
419425
<Icon type="home" /> 首页
420426
</Link>
421427
</p>
428+
<p onClick={this.onClose}>
429+
<Link to="/articles">
430+
<Icon type="ordered-list" /> 文章
431+
</Link>
432+
</p>
422433
<p onClick={this.onClose}>
423434
<Link to="/hot">
424435
<Icon type="fire" onClick={this.showLoginModal} /> 热门
425436
</Link>
426437
</p>
438+
<p onClick={this.onClose}>
439+
<Link to="/archive">
440+
<Icon type="project" onClick={this.showLoginModal} /> 归档
441+
</Link>
442+
</p>
427443
<p onClick={this.onClose}>
428444
<Link to="/project">
429445
<Icon type="project" onClick={this.showLoginModal} /> 项目

0 commit comments

Comments
 (0)