forked from xhgit/webup-cloud
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
fecb1d3976 | ||
|
|
347e723583 |
No files matched your search
@@ -38,7 +38,7 @@ public class AuthController {
|
||||
@NotBlank @Size(max = 10) String captchaCode) {}
|
||||
|
||||
public static String ip(HttpServletRequest req) {
|
||||
return req.getRemoteAddr();
|
||||
return ClientIp.of(req);
|
||||
}
|
||||
|
||||
public static String ua(HttpServletRequest req) {
|
||||
@@ -52,8 +52,13 @@ public class AuthController {
|
||||
}
|
||||
|
||||
private void check(String email, String id, String code, HttpServletRequest r) {
|
||||
store.limit("auth-ip:" + ip(r), 20, 60);
|
||||
String address = ip(r);
|
||||
// Per-address bucket: a single client cannot exhaust the shared allowance for everyone.
|
||||
store.limit("auth-ip:" + address, 20, 60);
|
||||
store.limit("auth-email:" + SecurityConfig.hash(email.toLowerCase(Locale.ROOT)), 10, 300);
|
||||
// Global ceiling across all addresses, raised well above the per-address limit so ordinary
|
||||
// traffic is never affected while total login throughput stays bounded.
|
||||
store.limit("auth-global", 600, 60);
|
||||
captcha.verify(id, code);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,114 @@
|
||||
package run.webup.platform;
|
||||
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import java.net.InetAddress;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Resolves the real client address behind the bundled reverse proxy.
|
||||
*
|
||||
* <p>The control plane is normally reached through the frontend nginx container. Because that proxy
|
||||
* overwrites the forwarded headers, {@code request.getRemoteAddr()} is always the proxy address;
|
||||
* using it directly would collapse every user into one rate-limit bucket and let a single caller
|
||||
* lock out the whole platform.
|
||||
*
|
||||
* <p>Forwarded headers are only honoured when the direct peer is a proxy we operate (loopback or a
|
||||
* private/container address). A public peer therefore cannot spoof its address by sending the
|
||||
* header itself.
|
||||
*/
|
||||
public final class ClientIp {
|
||||
private static final String FORWARDED_FOR = "X-Forwarded-For";
|
||||
private static final String REAL_IP = "X-Real-IP";
|
||||
|
||||
private ClientIp() {}
|
||||
|
||||
/** Returns the client address used for rate limiting and audit records. */
|
||||
public static String of(HttpServletRequest request) {
|
||||
String peer = normalize(request.getRemoteAddr());
|
||||
if (!trustedProxy(peer)) return peer;
|
||||
|
||||
// X-Real-IP is written by our own nginx from $remote_addr, so it cannot be spoofed by a client.
|
||||
String real = normalize(request.getHeader(REAL_IP));
|
||||
if (ipLiteral(real)) return real;
|
||||
|
||||
// Otherwise take the right-most X-Forwarded-For entry: that is the value our proxy appended.
|
||||
// Anything further left came from the client and is not trustworthy.
|
||||
String forwarded = lastValidForwardedFor(request.getHeader(FORWARDED_FOR));
|
||||
return forwarded == null ? peer : forwarded;
|
||||
}
|
||||
|
||||
private static String lastValidForwardedFor(String header) {
|
||||
if (header == null || header.isBlank()) return null;
|
||||
List<String> parts = List.of(header.split(","));
|
||||
for (int i = parts.size() - 1; i >= 0; i--) {
|
||||
String candidate = normalize(parts.get(i));
|
||||
if (ipLiteral(candidate)) return candidate;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/** Trims whitespace, strips IPv6 brackets and unwraps IPv4-mapped IPv6 addresses. */
|
||||
static String normalize(String value) {
|
||||
if (value == null) return "";
|
||||
String address = value.trim();
|
||||
if (address.isEmpty()) return "";
|
||||
if (address.startsWith("[")) {
|
||||
int end = address.indexOf(']');
|
||||
if (end > 0) address = address.substring(1, end);
|
||||
}
|
||||
if (address.regionMatches(true, 0, "::ffff:", 0, 7)) address = address.substring(7);
|
||||
return address.length() > 64 ? address.substring(0, 64) : address;
|
||||
}
|
||||
|
||||
/**
|
||||
* True for both IPv4 and IPv6 literals. Guards {@link InetAddress#getByName} so a malformed
|
||||
* header value can never trigger a DNS lookup.
|
||||
*/
|
||||
static boolean ipLiteral(String value) {
|
||||
if (value == null || value.isEmpty()) return false;
|
||||
boolean digitsAndDots = true;
|
||||
for (int i = 0; i < value.length(); i++) {
|
||||
char c = value.charAt(i);
|
||||
if (!Character.isDigit(c) && c != '.') {
|
||||
digitsAndDots = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (digitsAndDots) return value.indexOf('.') > 0;
|
||||
// Conservative IPv6 check: hex digits, colons and at most one embedded IPv4 tail.
|
||||
for (int i = 0; i < value.length(); i++) {
|
||||
char c = value.charAt(i);
|
||||
boolean ok =
|
||||
Character.digit(c, 16) >= 0 || c == ':' || c == '.' || c == '%' || c == ']' || c == '[';
|
||||
if (!ok) return false;
|
||||
}
|
||||
return value.indexOf(':') >= 0;
|
||||
}
|
||||
|
||||
/** True when the direct peer is a reverse proxy we operate rather than an arbitrary client. */
|
||||
static boolean trustedProxy(String peer) {
|
||||
if (!ipLiteral(peer)) return false;
|
||||
try {
|
||||
InetAddress address = InetAddress.getByName(peer);
|
||||
return address.isLoopbackAddress()
|
||||
|| address.isAnyLocalAddress()
|
||||
|| address.isSiteLocalAddress()
|
||||
|| sharedAddressSpace(peer);
|
||||
} catch (Exception e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/** RFC 6598 shared address space, used by container and overlay networks. */
|
||||
private static boolean sharedAddressSpace(String peer) {
|
||||
if (!peer.startsWith("100.")) return false;
|
||||
String[] parts = peer.split("\\.");
|
||||
if (parts.length != 4) return false;
|
||||
try {
|
||||
int second = Integer.parseInt(parts[1]);
|
||||
return second >= 64 && second <= 127;
|
||||
} catch (NumberFormatException e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
package run.webup.platform;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
class ClientIpTest {
|
||||
|
||||
private static HttpServletRequest request(String remoteAddr, String forwardedFor, String realIp) {
|
||||
HttpServletRequest request = mock(HttpServletRequest.class);
|
||||
when(request.getRemoteAddr()).thenReturn(remoteAddr);
|
||||
when(request.getHeader("X-Forwarded-For")).thenReturn(forwardedFor);
|
||||
when(request.getHeader("X-Real-IP")).thenReturn(realIp);
|
||||
return request;
|
||||
}
|
||||
|
||||
@Test
|
||||
void directPublicClientIsNeverRewrittenByHeaders() {
|
||||
// A public peer must not be able to spoof its address.
|
||||
assertEquals(
|
||||
"203.0.113.9",
|
||||
ClientIp.of(request("203.0.113.9", "1.2.3.4", "5.6.7.8")));
|
||||
}
|
||||
|
||||
@Test
|
||||
void trustedProxyResolvesRealClientFromRealIp() {
|
||||
assertEquals(
|
||||
"203.0.113.9",
|
||||
ClientIp.of(request("172.19.0.5", null, "203.0.113.9")));
|
||||
}
|
||||
|
||||
@Test
|
||||
void trustedProxyFallsBackToForwardedFor() {
|
||||
assertEquals(
|
||||
"203.0.113.9",
|
||||
ClientIp.of(request("172.19.0.5", "203.0.113.9", null)));
|
||||
}
|
||||
|
||||
@Test
|
||||
void usesRightMostForwardedEntrySoClientCannotSpoofPrefix() {
|
||||
// The client sent "1.2.3.4"; our proxy appended the real address on the right.
|
||||
assertEquals(
|
||||
"203.0.113.9",
|
||||
ClientIp.of(request("172.19.0.5", "1.2.3.4, 203.0.113.9", null)));
|
||||
}
|
||||
|
||||
@Test
|
||||
void separateClientsGetSeparateBuckets() {
|
||||
// Regression: behind the proxy these used to both resolve to 172.19.0.5.
|
||||
String first = ClientIp.of(request("172.19.0.5", null, "198.51.100.7"));
|
||||
String second = ClientIp.of(request("172.19.0.5", null, "198.51.100.8"));
|
||||
assertNotEquals(first, second);
|
||||
}
|
||||
|
||||
@Test
|
||||
void loopbackProxyIsTrusted() {
|
||||
assertEquals("203.0.113.9", ClientIp.of(request("127.0.0.1", null, "203.0.113.9")));
|
||||
assertEquals("203.0.113.9", ClientIp.of(request("::1", null, "203.0.113.9")));
|
||||
}
|
||||
|
||||
@Test
|
||||
void ipv4MappedIpv6IsUnwrapped() {
|
||||
assertEquals(
|
||||
"203.0.113.9",
|
||||
ClientIp.of(request("::ffff:172.19.0.5", null, "::ffff:203.0.113.9")));
|
||||
}
|
||||
|
||||
@Test
|
||||
void bracketedIpv6IsUnwrapped() {
|
||||
assertEquals("2001:db8::1", ClientIp.normalize("[2001:db8::1]"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void malformedForwardedValueFallsBackToPeerInsteadOfResolvingDns() {
|
||||
assertEquals(
|
||||
"172.19.0.5",
|
||||
ClientIp.of(request("172.19.0.5", "not-an-ip", "also-not-an-ip")));
|
||||
}
|
||||
|
||||
@Test
|
||||
void blankAndNullInputsAreSafe() {
|
||||
assertEquals("", ClientIp.normalize(null));
|
||||
assertEquals("", ClientIp.normalize(" "));
|
||||
assertFalse(ClientIp.ipLiteral(""));
|
||||
assertFalse(ClientIp.trustedProxy(""));
|
||||
assertEquals("172.19.0.5", ClientIp.of(request("172.19.0.5", " ", " ")));
|
||||
}
|
||||
}
|
||||
+15
-6
@@ -4,26 +4,35 @@ server {
|
||||
root /usr/share/nginx/html;
|
||||
index index.html;
|
||||
server_tokens off;
|
||||
client_max_body_size 1m;
|
||||
client_max_body_size 26m;
|
||||
add_header X-Content-Type-Options nosniff always;
|
||||
add_header Referrer-Policy strict-origin-when-cross-origin always;
|
||||
add_header Content-Security-Policy "default-src 'self'; script-src 'self'; style-src 'self' 'unsafe-inline' https://fonts.googleapis.com; font-src 'self' https://fonts.gstatic.com; img-src 'self' data: https:; connect-src 'self'; frame-ancestors 'none'; base-uri 'self'; form-action 'self'" always;
|
||||
# Oversized uploads are answered in the same JSON shape as the API instead of nginx's HTML page.
|
||||
error_page 413 = @upload_too_large;
|
||||
location @upload_too_large {
|
||||
default_type application/json;
|
||||
return 413 '{"message":"单文件不能超过 25MiB"}';
|
||||
}
|
||||
location /api/public/extensions/plugin-frame/ {
|
||||
# This response carries the backend's sandbox policy. The app shell remains non-frameable.
|
||||
add_header X-Content-Type-Options nosniff always;
|
||||
proxy_pass http://backend:8080;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Forwarded-For "";
|
||||
proxy_set_header X-Real-IP "";
|
||||
# Overwrite rather than append: a client-supplied value must never reach the backend. The
|
||||
# backend only reads these when the direct peer is a trusted proxy.
|
||||
proxy_set_header X-Forwarded-For $remote_addr;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
}
|
||||
location /api/ {
|
||||
proxy_pass http://backend:8080;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Host $host;
|
||||
# Backend intentionally does not trust user-supplied forwarded IP headers.
|
||||
proxy_set_header X-Forwarded-For "";
|
||||
proxy_set_header X-Real-IP "";
|
||||
# Overwrite rather than append: a client-supplied value must never reach the backend. The
|
||||
# backend only trusts these when the direct peer is a private/loopback proxy address.
|
||||
proxy_set_header X-Forwarded-For $remote_addr;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
}
|
||||
location / { try_files $uri $uri/ /index.html; }
|
||||
}
|
||||
@@ -913,6 +913,10 @@
|
||||
.landing-menu {
|
||||
display: none;
|
||||
}
|
||||
/* Only rendered inside the collapsed mobile menu; desktop keeps the standalone 登录 link. */
|
||||
.landing-nav-login {
|
||||
display: none;
|
||||
}
|
||||
.mobile-break {
|
||||
display: none;
|
||||
}
|
||||
@@ -996,8 +1000,50 @@
|
||||
}
|
||||
}
|
||||
@media (max-width: 850px) {
|
||||
.landing-nav {
|
||||
position: relative;
|
||||
gap: 10px;
|
||||
}
|
||||
.landing-menu {
|
||||
display: inline-flex;
|
||||
margin-left: auto;
|
||||
}
|
||||
.landing-nav nav {
|
||||
position: absolute;
|
||||
top: calc(100% + 1px);
|
||||
left: 16px;
|
||||
right: 16px;
|
||||
display: none;
|
||||
flex-direction: column;
|
||||
gap: 2px;
|
||||
padding: 8px;
|
||||
background: var(--landing-surface, #fff);
|
||||
border: 1px solid var(--landing-border, #eef1f6);
|
||||
border-radius: 12px;
|
||||
box-shadow: 0 18px 40px #1d2d4814;
|
||||
z-index: 40;
|
||||
}
|
||||
.landing-nav nav.expanded {
|
||||
display: flex;
|
||||
}
|
||||
.landing-nav nav > a {
|
||||
padding: 12px 14px;
|
||||
border-radius: 8px;
|
||||
font-size: 13px;
|
||||
}
|
||||
.landing-nav nav > a:hover {
|
||||
background: var(--landing-accentSoft, #edf3ff);
|
||||
}
|
||||
.landing-nav nav .landing-nav-login {
|
||||
display: block;
|
||||
padding: 12px 14px;
|
||||
border-radius: 8px;
|
||||
font-size: 13px;
|
||||
color: var(--landing-muted, #7a879b);
|
||||
}
|
||||
.landing-nav nav .landing-nav-login:hover {
|
||||
background: var(--landing-accentSoft, #edf3ff);
|
||||
color: var(--landing-accent, #3868f5);
|
||||
}
|
||||
.landing-hero {
|
||||
grid-template-columns: 1fr;
|
||||
|
||||
@@ -28,6 +28,8 @@ import AdminExtensions from "./views/AdminExtensions.vue";
|
||||
import PluginTools from "./views/PluginTools.vue";
|
||||
import "./style.css";
|
||||
import "./landing.css";
|
||||
import "./motion.css";
|
||||
import { initMotion } from "./motion";
|
||||
const router = createRouter({
|
||||
history: createWebHistory(),
|
||||
routes: [
|
||||
@@ -106,3 +108,4 @@ router.beforeEach(async (to) => {
|
||||
});
|
||||
app.use(router);
|
||||
app.mount("#app");
|
||||
initMotion();
|
||||
@@ -0,0 +1,347 @@
|
||||
/* ==========================================================================
|
||||
Motion system
|
||||
--------------------------------------------------------------------------
|
||||
All animation is additive: this file is loaded after style.css / landing.css
|
||||
and only appends transitions and keyframes. No existing layout rule is
|
||||
rewritten, so removing this import restores the original static UI.
|
||||
|
||||
Rules:
|
||||
1. Animate only `transform` and `opacity` where possible: they stay on the
|
||||
compositor and never trigger layout or paint of siblings.
|
||||
2. No transform on scroll containers or ancestors of sticky/fixed elements
|
||||
(it would create a containing block and break position:sticky).
|
||||
3. Decorative motion is slow, low-amplitude and loops only where it conveys
|
||||
"alive" (status dots, hero glow). No attention-grabbing bouncing.
|
||||
4. `prefers-reduced-motion: reduce` disables everything, including smooth
|
||||
scrolling. Scroll reveal is JS-gated so content is visible without JS.
|
||||
========================================================================== */
|
||||
|
||||
:root {
|
||||
--ease-out: cubic-bezier(0.22, 1, 0.36, 1);
|
||||
--ease-in-out: cubic-bezier(0.4, 0, 0.2, 1);
|
||||
--dur-fast: 140ms;
|
||||
--dur: 220ms;
|
||||
--dur-slow: 420ms;
|
||||
}
|
||||
|
||||
html {
|
||||
scroll-behavior: smooth;
|
||||
/* Anchor links (#features, #workflow, ...) must clear the sticky header. */
|
||||
scroll-padding-top: 96px;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------
|
||||
1. Interaction feedback — buttons, links, controls
|
||||
-------------------------------------------------------------------------- */
|
||||
|
||||
.primary,
|
||||
.secondary {
|
||||
transition:
|
||||
background-color var(--dur) var(--ease-in-out),
|
||||
border-color var(--dur) var(--ease-in-out),
|
||||
box-shadow var(--dur) var(--ease-out),
|
||||
transform var(--dur-fast) var(--ease-out);
|
||||
}
|
||||
|
||||
.primary:hover {
|
||||
transform: translateY(-2px);
|
||||
box-shadow: 0 7px 16px #3868f526;
|
||||
}
|
||||
|
||||
.secondary:hover {
|
||||
transform: translateY(-2px);
|
||||
}
|
||||
|
||||
.primary:active,
|
||||
.secondary:active {
|
||||
transform: translateY(0) scale(0.985);
|
||||
transition-duration: var(--dur-fast);
|
||||
}
|
||||
|
||||
.icon-button,
|
||||
.link,
|
||||
.text-link,
|
||||
.landing-login,
|
||||
.landing-nav-login,
|
||||
.logout,
|
||||
.pagination a,
|
||||
.pagination button,
|
||||
.breadcrumb button {
|
||||
transition:
|
||||
color var(--dur-fast) var(--ease-in-out),
|
||||
background-color var(--dur-fast) var(--ease-in-out),
|
||||
opacity var(--dur-fast) var(--ease-in-out);
|
||||
}
|
||||
|
||||
.link:hover,
|
||||
.text-link:hover,
|
||||
.landing-login:hover {
|
||||
opacity: 0.75;
|
||||
}
|
||||
|
||||
/* Form controls: focus ring and border currently snap instantly. */
|
||||
input,
|
||||
textarea,
|
||||
select {
|
||||
transition:
|
||||
border-color var(--dur) var(--ease-in-out),
|
||||
box-shadow var(--dur) var(--ease-out),
|
||||
background-color var(--dur) var(--ease-in-out);
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------
|
||||
2. Surfaces — cards, panels, rows
|
||||
A 1px lift plus a softened shadow reads as "interactive" without motion
|
||||
sickness. Shadow transitions do paint, but only on hover of one element.
|
||||
-------------------------------------------------------------------------- */
|
||||
|
||||
.project-card,
|
||||
.stat-card,
|
||||
.capability,
|
||||
.guide-step,
|
||||
.usecase-visual article,
|
||||
.landing-plan-grid article {
|
||||
transition:
|
||||
transform var(--dur) var(--ease-out),
|
||||
box-shadow var(--dur) var(--ease-out),
|
||||
border-color var(--dur) var(--ease-in-out);
|
||||
}
|
||||
|
||||
.project-card:hover,
|
||||
.stat-card:hover,
|
||||
.capability:hover {
|
||||
transform: translateY(-3px);
|
||||
box-shadow: 0 10px 26px #1a396012;
|
||||
}
|
||||
|
||||
.table-scroll tbody tr,
|
||||
.task-item,
|
||||
.version-row,
|
||||
.project-row,
|
||||
.file-entry,
|
||||
.event-log > div {
|
||||
transition: background-color var(--dur-fast) var(--ease-in-out);
|
||||
}
|
||||
|
||||
/* Sidebar navigation: the active item is currently an instant colour swap. */
|
||||
.member-shell aside nav a {
|
||||
transition:
|
||||
background-color var(--dur-fast) var(--ease-in-out),
|
||||
color var(--dur-fast) var(--ease-in-out),
|
||||
transform var(--dur-fast) var(--ease-out);
|
||||
}
|
||||
|
||||
.member-shell aside nav a:hover {
|
||||
transform: translateX(2px);
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------
|
||||
3. Overlays and feedback banners
|
||||
-------------------------------------------------------------------------- */
|
||||
|
||||
.modal-backdrop {
|
||||
animation: motion-fade-in var(--dur) var(--ease-out) both;
|
||||
}
|
||||
|
||||
.modal {
|
||||
animation: motion-rise var(--dur-slow) var(--ease-out) both;
|
||||
}
|
||||
|
||||
.alert,
|
||||
.notice {
|
||||
animation: motion-fade-in var(--dur-slow) var(--ease-out) both;
|
||||
}
|
||||
|
||||
/* FAQ chevron already has a transform transition; give it a softer curve. */
|
||||
.faq-items svg {
|
||||
transition: transform var(--dur) var(--ease-out);
|
||||
}
|
||||
|
||||
/* Mobile dropdown added for the collapsed landing navigation. */
|
||||
.landing-nav nav.expanded {
|
||||
animation: motion-dropdown var(--dur) var(--ease-out) both;
|
||||
}
|
||||
|
||||
/* Captcha refresh: brief feedback that the image actually changed. */
|
||||
.captcha img {
|
||||
animation: motion-fade-in var(--dur) var(--ease-out) both;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------
|
||||
4. Ambient decoration — landing page
|
||||
Amplitudes are deliberately tiny; these should be felt, not watched.
|
||||
-------------------------------------------------------------------------- */
|
||||
|
||||
.product-glow {
|
||||
animation: motion-breathe 7s var(--ease-in-out) infinite;
|
||||
}
|
||||
|
||||
.status-dot,
|
||||
.notice-dot {
|
||||
animation: motion-pulse 2.8s var(--ease-in-out) infinite;
|
||||
}
|
||||
|
||||
.floating-prompt {
|
||||
animation: motion-float 6s var(--ease-in-out) infinite;
|
||||
will-change: transform;
|
||||
}
|
||||
|
||||
.hero-kicker > span,
|
||||
.prompt-spark {
|
||||
animation: motion-breathe 4.5s var(--ease-in-out) infinite;
|
||||
}
|
||||
|
||||
/* Hero artwork is tilted with a perspective transform. Do NOT animate its
|
||||
transform (it would override the 3D tilt); only fade it in on entry. */
|
||||
.hero-product {
|
||||
animation: motion-fade-in var(--dur-slow) var(--ease-out) both;
|
||||
}
|
||||
|
||||
.hero-copy {
|
||||
animation: motion-rise var(--dur-slow) var(--ease-out) both;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------
|
||||
5. Scroll reveal (progressive enhancement)
|
||||
The hidden state is gated on `html.motion-ready`, which JS sets only after
|
||||
an IntersectionObserver has been created successfully. Without JS, with a
|
||||
legacy browser, or with reduced motion, everything stays fully visible.
|
||||
-------------------------------------------------------------------------- */
|
||||
|
||||
html.motion-ready [data-reveal] {
|
||||
opacity: 0;
|
||||
transform: translateY(18px);
|
||||
transition:
|
||||
opacity var(--dur-slow) var(--ease-out),
|
||||
transform var(--dur-slow) var(--ease-out);
|
||||
}
|
||||
|
||||
html.motion-ready [data-reveal].is-visible {
|
||||
opacity: 1;
|
||||
transform: none;
|
||||
}
|
||||
|
||||
/* Stagger children of a revealed group without a second observer. */
|
||||
html.motion-ready [data-reveal-group] > * {
|
||||
opacity: 0;
|
||||
transform: translateY(14px);
|
||||
transition:
|
||||
opacity var(--dur-slow) var(--ease-out),
|
||||
transform var(--dur-slow) var(--ease-out);
|
||||
transition-delay: calc(var(--stagger, 0) * 70ms);
|
||||
}
|
||||
|
||||
html.motion-ready [data-reveal-group].is-visible > * {
|
||||
opacity: 1;
|
||||
transform: none;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------
|
||||
6. Keyframes — opacity / transform only
|
||||
-------------------------------------------------------------------------- */
|
||||
|
||||
@keyframes motion-fade-in {
|
||||
from {
|
||||
opacity: 0;
|
||||
}
|
||||
to {
|
||||
opacity: 1;
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes motion-rise {
|
||||
from {
|
||||
opacity: 0;
|
||||
transform: translateY(14px);
|
||||
}
|
||||
to {
|
||||
opacity: 1;
|
||||
transform: none;
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes motion-dropdown {
|
||||
from {
|
||||
opacity: 0;
|
||||
transform: translateY(-8px);
|
||||
}
|
||||
to {
|
||||
opacity: 1;
|
||||
transform: none;
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes motion-float {
|
||||
0%,
|
||||
100% {
|
||||
transform: translateY(0);
|
||||
}
|
||||
50% {
|
||||
transform: translateY(-6px);
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes motion-breathe {
|
||||
0%,
|
||||
100% {
|
||||
opacity: 0.55;
|
||||
}
|
||||
50% {
|
||||
opacity: 1;
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes motion-pulse {
|
||||
0%,
|
||||
100% {
|
||||
opacity: 1;
|
||||
}
|
||||
50% {
|
||||
opacity: 0.35;
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes motion-spin {
|
||||
to {
|
||||
transform: rotate(360deg);
|
||||
}
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------
|
||||
7. Accessibility — full opt-out
|
||||
`animation-duration: 0.01ms` (rather than `animation: none`) keeps the end
|
||||
state of `both`-filled animations, so no element is left invisible.
|
||||
-------------------------------------------------------------------------- */
|
||||
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
html {
|
||||
scroll-behavior: auto;
|
||||
}
|
||||
|
||||
*,
|
||||
*::before,
|
||||
*::after {
|
||||
animation-duration: 0.01ms !important;
|
||||
animation-iteration-count: 1 !important;
|
||||
transition-duration: 0.01ms !important;
|
||||
transition-delay: 0ms !important;
|
||||
scroll-behavior: auto !important;
|
||||
}
|
||||
|
||||
html.motion-ready [data-reveal],
|
||||
html.motion-ready [data-reveal-group] > *,
|
||||
html.motion-ready [data-reveal].is-visible,
|
||||
html.motion-ready [data-reveal-group].is-visible > * {
|
||||
opacity: 1 !important;
|
||||
transform: none !important;
|
||||
}
|
||||
|
||||
.primary:hover,
|
||||
.secondary:hover,
|
||||
.project-card:hover,
|
||||
.stat-card:hover,
|
||||
.capability:hover,
|
||||
.member-shell aside nav a:hover {
|
||||
transform: none;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,108 @@
|
||||
/**
|
||||
* Progressive-enhancement scroll reveal.
|
||||
*
|
||||
* The hidden state in motion.css is gated on `html.motion-ready`, which this
|
||||
* module adds only after an IntersectionObserver has been created. If JS is
|
||||
* disabled, the browser is old, or the user prefers reduced motion, nothing
|
||||
* is ever hidden.
|
||||
*/
|
||||
|
||||
const REVEAL_SELECTOR = "[data-reveal], [data-reveal-group]";
|
||||
const registered = new WeakSet<Element>();
|
||||
let revealObserver: IntersectionObserver | null = null;
|
||||
let mutationObserver: MutationObserver | null = null;
|
||||
let pendingScan = 0;
|
||||
|
||||
function reducedMotion(): boolean {
|
||||
return window.matchMedia?.("(prefers-reduced-motion: reduce)").matches ?? false;
|
||||
}
|
||||
|
||||
function onReveal(entries: IntersectionObserverEntry[]) {
|
||||
for (const entry of entries) {
|
||||
if (!entry.isIntersecting) continue;
|
||||
entry.target.classList.add("is-visible");
|
||||
// Each element animates once; no need to keep observing it.
|
||||
revealObserver?.unobserve(entry.target);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Register newly mounted reveal targets and assign stagger indices to the
|
||||
* children of a group. Works for async content (e.g. plans loaded from the
|
||||
* API) because the parent keeps its `is-visible` class while new children
|
||||
* inherit the revealed state from the CSS descendant selector.
|
||||
*/
|
||||
function scan() {
|
||||
const root = document.documentElement;
|
||||
if (!root.classList.contains("motion-ready")) return;
|
||||
|
||||
const targets = Array.from(
|
||||
document.querySelectorAll<HTMLElement>(REVEAL_SELECTOR),
|
||||
);
|
||||
for (const element of targets) {
|
||||
if (element.hasAttribute("data-reveal-group")) {
|
||||
const children = Array.from(element.children) as HTMLElement[];
|
||||
children.forEach((child, index) => {
|
||||
child.style.setProperty("--stagger", String(Math.min(index, 8)));
|
||||
});
|
||||
}
|
||||
if (registered.has(element)) continue;
|
||||
registered.add(element);
|
||||
revealObserver?.observe(element);
|
||||
}
|
||||
}
|
||||
|
||||
function scheduleScan() {
|
||||
if (pendingScan) return;
|
||||
pendingScan = requestAnimationFrame(() => {
|
||||
pendingScan = 0;
|
||||
scan();
|
||||
});
|
||||
}
|
||||
|
||||
function disableMotion() {
|
||||
document.documentElement.classList.remove("motion-ready");
|
||||
revealObserver?.disconnect();
|
||||
revealObserver = null;
|
||||
// Show anything that was mid-transition when the preference changed.
|
||||
const hidden = Array.from(document.querySelectorAll(REVEAL_SELECTOR));
|
||||
for (const element of hidden) {
|
||||
element.classList.add("is-visible");
|
||||
}
|
||||
}
|
||||
|
||||
export function initMotion() {
|
||||
if (
|
||||
reducedMotion() ||
|
||||
typeof IntersectionObserver === "undefined" ||
|
||||
document.documentElement.classList.contains("motion-ready")
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
revealObserver = new IntersectionObserver(onReveal, {
|
||||
// Trigger slightly before the element enters the viewport so the
|
||||
// transition has time to play while scrolling.
|
||||
rootMargin: "0px 0px -8% 0px",
|
||||
threshold: 0.05,
|
||||
});
|
||||
|
||||
document.documentElement.classList.add("motion-ready");
|
||||
|
||||
mutationObserver = new MutationObserver(scheduleScan);
|
||||
mutationObserver.observe(document.getElementById("app") ?? document.body, {
|
||||
childList: true,
|
||||
subtree: true,
|
||||
});
|
||||
|
||||
const media = window.matchMedia?.("(prefers-reduced-motion: reduce)");
|
||||
media?.addEventListener?.("change", (event) => {
|
||||
if (event.matches) {
|
||||
disableMotion();
|
||||
mutationObserver?.disconnect();
|
||||
mutationObserver = null;
|
||||
}
|
||||
});
|
||||
|
||||
scan();
|
||||
}
|
||||
@@ -64,7 +64,7 @@ const modules = [
|
||||
>
|
||||
</div>
|
||||
<div v-if="error" class="alert error">{{ error }}</div>
|
||||
<section class="welcome-banner">
|
||||
<section class="welcome-banner" data-reveal>
|
||||
<div>
|
||||
<span class="banner-tag"><i />你的创造空间,已就绪</span>
|
||||
<h2>让想法,有一个开始。</h2>
|
||||
@@ -89,7 +89,7 @@ const modules = [
|
||||
<div class="art-float"><CloudIcon /></div>
|
||||
</div>
|
||||
</section>
|
||||
<section class="stats">
|
||||
<section class="stats" data-reveal-group>
|
||||
<div class="stat-card">
|
||||
<div><span>我的项目</span><FolderKanban :size="18" /></div>
|
||||
<strong>{{ loading ? "—" : projects.length }}</strong
|
||||
|
||||
@@ -105,7 +105,13 @@ onMounted(async () => {
|
||||
<a href="#features" @click="menu = false">平台能力</a
|
||||
><a href="#workflow" @click="menu = false">开发流程</a
|
||||
><a href="#plans" @click="menu = false">托管套餐</a
|
||||
><a href="#questions" @click="menu = false">常见问题</a>
|
||||
><a href="#questions" @click="menu = false">常见问题</a
|
||||
><RouterLink
|
||||
class="landing-nav-login"
|
||||
to="/login"
|
||||
@click="menu = false"
|
||||
>登录</RouterLink
|
||||
>
|
||||
</nav>
|
||||
<div class="landing-nav-actions">
|
||||
<RouterLink class="landing-login" to="/login">登录</RouterLink
|
||||
@@ -225,7 +231,7 @@ onMounted(async () => {
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
<section class="landing-values">
|
||||
<section class="landing-values" data-reveal-group>
|
||||
<span>创造的每一步,都在一个地方。</span>
|
||||
<div><Code2 :size="18" />AI 辅助开发</div>
|
||||
<div><GitBranch :size="18" />文件与版本</div>
|
||||
@@ -233,14 +239,14 @@ onMounted(async () => {
|
||||
<div><Wallet :size="18" />透明计费</div>
|
||||
</section>
|
||||
<section id="features" class="landing-section">
|
||||
<div class="landing-section-heading">
|
||||
<div class="landing-section-heading" data-reveal>
|
||||
<span class="eyebrow">ONE WORKSPACE. MORE POSSIBILITIES.</span>
|
||||
<h2>不止生成代码。<br />让开发过程,连成一条路。</h2>
|
||||
<p>
|
||||
把模型、项目、执行过程与运行配置连接起来,<br />让你把注意力留给真正想创造的东西。
|
||||
</p>
|
||||
</div>
|
||||
<div class="landing-feature-grid">
|
||||
<div class="landing-feature-grid" data-reveal-group>
|
||||
<article v-for="f in features" :key="f.title">
|
||||
<div class="landing-feature-icon">
|
||||
<component :is="f.icon" :size="24" />
|
||||
@@ -252,7 +258,7 @@ onMounted(async () => {
|
||||
</div>
|
||||
</section>
|
||||
<section id="workflow" class="landing-section workflow-section">
|
||||
<div class="workflow-intro">
|
||||
<div class="workflow-intro" data-reveal>
|
||||
<span class="eyebrow">FROM IDEA TO WORKSPACE</span>
|
||||
<h2>从一句“我想要”,<br />到你的下一个作品。</h2>
|
||||
<p>
|
||||
@@ -262,7 +268,7 @@ onMounted(async () => {
|
||||
>创建第一个项目 <ArrowRight :size="15"
|
||||
/></RouterLink>
|
||||
</div>
|
||||
<div class="workflow-steps">
|
||||
<div class="workflow-steps" data-reveal-group>
|
||||
<article
|
||||
v-for="(step, i) in [
|
||||
[
|
||||
@@ -293,11 +299,11 @@ onMounted(async () => {
|
||||
</div>
|
||||
</section>
|
||||
<section class="landing-section usecases">
|
||||
<div class="landing-section-heading">
|
||||
<div class="landing-section-heading" data-reveal>
|
||||
<span class="eyebrow">MAKE ROOM FOR YOUR NEXT IDEA</span>
|
||||
<h2>你的下一站,<br />可以有很多种样子。</h2>
|
||||
</div>
|
||||
<div class="usecase-grid">
|
||||
<div class="usecase-grid" data-reveal-group>
|
||||
<article>
|
||||
<span>01 / PRESENT</span>
|
||||
<h3>个人品牌与产品展示</h3>
|
||||
@@ -336,14 +342,14 @@ onMounted(async () => {
|
||||
</div>
|
||||
</section>
|
||||
<section id="plans" class="landing-section landing-pricing">
|
||||
<div class="landing-section-heading">
|
||||
<div class="landing-section-heading" data-reveal>
|
||||
<span class="eyebrow">CLEAR RESOURCES. CLEAR CHOICES.</span>
|
||||
<h2>选择适合项目的运行空间。</h2>
|
||||
<p>
|
||||
AI 开发与网站托管分别计费,<br />托管资源与价格由平台实际开放的套餐决定。
|
||||
</p>
|
||||
</div>
|
||||
<div v-if="plans.length" class="landing-plan-grid">
|
||||
<div v-if="plans.length" class="landing-plan-grid" data-reveal-group>
|
||||
<article v-for="p in plans" :key="p.id">
|
||||
<span class="plan-eyebrow">云托管</span>
|
||||
<h3>{{ p.name }}</h3>
|
||||
@@ -388,12 +394,12 @@ onMounted(async () => {
|
||||
</div>
|
||||
</section>
|
||||
<section id="questions" class="landing-section landing-faq">
|
||||
<div>
|
||||
<div data-reveal>
|
||||
<span class="eyebrow">A LITTLE MORE CLARITY</span>
|
||||
<h2>开始之前,<br />你可能想了解。</h2>
|
||||
<p>让每一次选择,都更加清楚。</p>
|
||||
</div>
|
||||
<div class="faq-items">
|
||||
<div class="faq-items" data-reveal-group>
|
||||
<article v-for="(q, i) in questions" :key="q[0]">
|
||||
<button
|
||||
@click="faq = faq === i ? -1 : i"
|
||||
@@ -406,7 +412,7 @@ onMounted(async () => {
|
||||
</article>
|
||||
</div>
|
||||
</section>
|
||||
<section class="landing-cta">
|
||||
<section class="landing-cta" data-reveal>
|
||||
<div>
|
||||
<span class="eyebrow">YOUR NEXT CHAPTER STARTS HERE</span>
|
||||
<h2>让下一次灵感,有处生长。</h2>
|
||||
|
||||
Reference in new issue
Block a user