Browse Source

更新页面布局和样式,新增作品展示组件,优化登录页面结构和样式,整合粒子特效和GSAP动画

pure
谢亚昕 2 months ago
parent
commit
7376d9e640
  1. 2
      src/middlewares/install.js
  2. 26
      src/views/page/extra/about.pug
  3. 22
      src/views/page/extra/style.css
  4. 42
      src/views/page/index/index.pug
  5. 57
      src/views/page/login/index.pug
  6. 22
      src/views/page/login/style.css

2
src/middlewares/install.js

@ -75,6 +75,8 @@ export default async app => {
"'unsafe-eval'", "'unsafe-eval'",
"https://cdnjs.cloudflare.com", "https://cdnjs.cloudflare.com",
"https://cdn.jsdelivr.net", "https://cdn.jsdelivr.net",
"https://unpkg.co",
"https://assets.codepen.io",
], ],
"img-src": ["'self'", "data:", "https://bpic.588ku.com", "https://user-images.githubusercontent.com"], "img-src": ["'self'", "data:", "https://bpic.588ku.com", "https://user-images.githubusercontent.com"],
}, },

26
src/views/page/extra/about.pug

@ -1,7 +1,25 @@
extends /layouts/empty.pug extends /layouts/root.pug
block pageHead block $$head
style
include ./style.css
block pageContent block $$content
.container.my-5 .page-layout.bg-gray-50
navbar
//- .placeholder(class="h-[75px] w-full opacity-0")
.fixed.top-0.left-0.right-0.z-10(class="h-[75px]")
.container.h-full
a.h-full.flex.items-center.float-left.text-2xl.font-bold(href="/") 烟霞渡
canvas#background.absolute.block.top-0.left-0.z-0
.container.relative(class="mt-[75px] pt-10")
include /htmx/markdown/index.pug include /htmx/markdown/index.pug
block $$scripts
+js("https://cdnjs.cloudflare.com/ajax/libs/particlesjs/2.2.2/particles.min.js")
script.
Particles.init({
selector: '#background',
maxParticles: 350,
});

22
src/views/page/extra/style.css

@ -0,0 +1,22 @@
.page-layout {
flex: 1;
display: flex;
flex-direction: column;
width: 100%;
position: relative;
}
.container {
max-width: 1226px;
margin-right: auto;
margin-left: auto;
/* padding-left: 20px;
padding-right: 20px; */
}
@media (max-width: 640px) {
.container {
padding-left: 10px;
padding-right: 10px;
}
}

42
src/views/page/index/index.pug

@ -4,6 +4,16 @@ block $$head
style style
include ./style.css include ./style.css
mixin Project()
.text-2xl.font-bold.mb-6.text-center 作品
.grid.grid-cols-1.gap-6(class="md:grid-cols-2 lg:grid-cols-3")
.p-3.flex.gap-4
img(src="https://bpic.588ku.com/element_origin_min_pic/23/07/11/d32dabe266d10da8b21bd640a2e9b611.jpg!r650", alt="", class="w-20 h-20 shadow rounded-[50%] object-cover")
.flex.justify-center.flex-col
a.font-bold.text-lg.mb-2(href="/") 灵巧代码
p.text-gray-600.line-clamp-2(style="min-height: 2em") 用electron开发
//- .text-center.text-sm.my-6.p-2(class) 查看更多
block $$content block $$content
.page-layout.bg-gray-50 .page-layout.bg-gray-50
navbar navbar
@ -14,38 +24,24 @@ block $$content
//- .float-left.h-full.flex(class="ml-[100px]") //- .float-left.h-full.flex(class="ml-[100px]")
//- a.flex.items-center.px-5(href="/") 关于 //- a.flex.items-center.px-5(href="/") 关于
.float-right.h-full.flex .float-right.h-full.flex
if !user
a.flex.items-center.px-5(href="/login") 登录 a.flex.items-center.px-5(href="/login") 登录
else
a.flex.items-center.px-5.cursor-pointer(hx-post="/logout") 退出
a.flex.items-center.px-5.cursor-pointer 后台
a.flex.items-center.px-5(href="/profile") 欢迎您,#{user.username}
canvas#background.absolute.block.top-0.left-0.z-0 canvas#background.absolute.block.top-0.left-0.z-0
.min-h-screen.relative .min-h-screen.relative
.container .container(class="mt-[75px] pt-10")
div(class="mt-[75px] p-[40px] h-[350px] flex justify-center items-center text-xl" style="line-height: 2.1;") +Project()
.typed(style="letter-spacing: 0.2em;")
.text-2xl.font-bold.mb-6.ml-3.text-center 作品
.grid.grid-cols-1.gap-6(class="md:grid-cols-2 lg:grid-cols-3")
.p-3.flex.gap-4
img(src="https://bpic.588ku.com/element_origin_min_pic/23/07/11/d32dabe266d10da8b21bd640a2e9b611.jpg!r650", alt="", class="w-20 h-20 shadow rounded-[50%] object-cover")
.flex.justify-center.flex-col
a.font-bold.text-lg.mb-2(href="/") 灵巧代码
p.text-gray-600.line-clamp-2(style="min-height: 2em") 管理文本
.text-center.text-sm.my-6.p-2(class) 查看更多
include /htmx/footer/index.pug include /htmx/footer/index.pug
block $$scripts block $$scripts
+js("https://cdn.jsdelivr.net/npm/typed.js@2.0.12")
+js("https://cdnjs.cloudflare.com/ajax/libs/particlesjs/2.2.2/particles.min.js") +js("https://cdnjs.cloudflare.com/ajax/libs/particlesjs/2.2.2/particles.min.js")
+js("https://unpkg.co/gsap@3/dist/gsap.min.js")
+js("https://assets.codepen.io/16327/SplitText3-beta.min.js?b=43")
script. script.
window.onload= function() {
Particles.init({ Particles.init({
selector: '#background', selector: '#background',
maxParticles: 350, maxParticles: 350,
}); });
var options = {
strings: [`烟锁长堤柳色新,<br>霞映归舟渡水滨。<br>过客停桡寻旧梦,<br>一川风月正宜人。`],
typeSpeed: 80,
shuffle: true,
showCursor: false,
};
var typed = new Typed('.typed', options);
};

57
src/views/page/login/index.pug

@ -1,20 +1,28 @@
extends /layouts/empty.pug extends /layouts/root.pug
block pageHead block $$head
//- style. style
//- body { include ./style.css
//- background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
//- min-height: 100vh;
//- }
block pageContent
.h-full(class="sm:px-6 lg:px-8") block $$content
.container.h-full.flex.items-center.justify-end.px-4 .page-layout.bg-gray-50
.max-w-md.w-full.space-y-8 navbar
.bg-white.py-8.px-4.shadow-xl.rounded-2xl(class="sm:px-10") //- .placeholder(class="h-[75px] w-full opacity-0")
.fixed.top-0.left-0.right-0.z-10(class="h-[75px]")
.container.h-full
a.h-full.flex.items-center.float-left.text-2xl.font-bold(href="/") 烟霞渡
canvas#background.absolute.block.top-0.left-0.z-0
.h-full.relative(class="sm:px-6 lg:px-8")
.container.h-full.flex.items-center
.flex-1.h-full.flex.items-center.justify-center
h1.text-4xl.font-bold#chars
div 烟霞渡!
.mt-5 欢迎您的到来
.flex-1.px-4.max-w-md
.w-full.space-y-8
.py-8.px-4(class="sm:px-10")
.text-center.mb-8 .text-center.mb-8
h2.text-3xl.font-bold.text-gray-900 欢迎回来
p.text-gray-600.mt-2 请登录您的账户
form.space-y-6(hx-post="/login") form.space-y-6(hx-post="/login")
include _ui/username.pug include _ui/username.pug
include _ui/password.pug include _ui/password.pug
@ -35,8 +43,27 @@ block pageContent
| 还没有账户? | 还没有账户?
a.font-medium.text-blue-600(href="/register" class="hover:text-blue-500") 立即注册 a.font-medium.text-blue-600(href="/register" class="hover:text-blue-500") 立即注册
block pageScripts block $$scripts
+js("https://cdnjs.cloudflare.com/ajax/libs/particlesjs/2.2.2/particles.min.js")
+js("https://unpkg.co/gsap@3/dist/gsap.min.js")
+js("https://assets.codepen.io/16327/SplitText3-beta.min.js?b=43")
script. script.
Particles.init({
selector: '#background',
maxParticles: 350,
});
gsap.registerPlugin(SplitText);
let split, animation;
split = SplitText.create("#chars", {type:"chars"});
animation && animation.revert();
animation = gsap.from(split.chars, {
x: 150,
opacity: 0,
duration: 1.7,
ease: "power4",
stagger: 0.04
})
document.addEventListener('htmx:error', function(evt) { document.addEventListener('htmx:error', function(evt) {
if(evt.detail.elt instanceof HTMLElement) { if(evt.detail.elt instanceof HTMLElement) {
if(evt.detail.elt.tagName === 'FORM' && evt.detail.xhr) { if(evt.detail.elt.tagName === 'FORM' && evt.detail.xhr) {

22
src/views/page/login/style.css

@ -0,0 +1,22 @@
.page-layout {
flex: 1;
display: flex;
flex-direction: column;
width: 100%;
position: relative;
}
.container {
max-width: 1226px;
margin-right: auto;
margin-left: auto;
/* padding-left: 20px;
padding-right: 20px; */
}
@media (max-width: 640px) {
.container {
padding-left: 10px;
padding-right: 10px;
}
}
Loading…
Cancel
Save