Compare commits
10 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| d21e866bc2 | |||
| 9843afe0bc | |||
| 975e480578 | |||
| 5d9af01798 | |||
| 4afc10f4cf | |||
| 91afd0e04e | |||
| 0a74ef159b | |||
| 1d0b7d9765 | |||
| 6640cf3b14 | |||
| 9f79d1e11c |
@@ -3,6 +3,12 @@ name: Deploy Rust Bedrock
|
|||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches: [main]
|
branches: [main]
|
||||||
|
paths-ignore:
|
||||||
|
- 'home/**'
|
||||||
|
- 'dashboard/**'
|
||||||
|
- 'repository/**'
|
||||||
|
- 'package.json'
|
||||||
|
- 'package-lock.json'
|
||||||
|
|
||||||
concurrency:
|
concurrency:
|
||||||
group: bedrock-rust-deploy
|
group: bedrock-rust-deploy
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
/target
|
/target
|
||||||
/bedrock.sqlite3
|
/bedrock.sqlite3
|
||||||
/bedrock.sqlite3-*
|
/bedrock.sqlite3-*
|
||||||
|
|
||||||
|
/node_modules/
|
||||||
|
|||||||
@@ -13,11 +13,9 @@ name = "admin_backend"
|
|||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"axum",
|
"axum",
|
||||||
"bedrock-rpc",
|
|
||||||
"clusters",
|
"clusters",
|
||||||
"serde",
|
"serde",
|
||||||
"subtle",
|
"subtle",
|
||||||
"tokio",
|
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -159,28 +157,12 @@ version = "0.22.1"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6"
|
checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "base64"
|
|
||||||
version = "0.23.1"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "ac07cdecf99051d9a5238b80f35af32cdeba5b336e55d957b318b50137e18da5"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "base64ct"
|
name = "base64ct"
|
||||||
version = "1.8.3"
|
version = "1.8.3"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "2af50177e190e07a26ab74f8b1efbfe2ef87da2116221318cb1c2e82baf7de06"
|
checksum = "2af50177e190e07a26ab74f8b1efbfe2ef87da2116221318cb1c2e82baf7de06"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "bedrock-rpc"
|
|
||||||
version = "0.1.0"
|
|
||||||
dependencies = [
|
|
||||||
"axum",
|
|
||||||
"reqwest",
|
|
||||||
"serde_json",
|
|
||||||
"thiserror",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "bitflags"
|
name = "bitflags"
|
||||||
version = "2.13.2"
|
version = "2.13.2"
|
||||||
@@ -248,12 +230,6 @@ version = "1.0.5"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "4e7648175b45a9a48536d676f68d918270699102aa8dab5496df06904c914600"
|
checksum = "4e7648175b45a9a48536d676f68d918270699102aa8dab5496df06904c914600"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "cfg_aliases"
|
|
||||||
version = "0.2.2"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "f079e83a288787bcd14a6aea84cee5c87a67c5a3e660c30f557a3d24761b3527"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "chacha20"
|
name = "chacha20"
|
||||||
version = "0.10.2"
|
version = "0.10.2"
|
||||||
@@ -671,10 +647,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||||||
checksum = "ff2abc00be7fca6ebc474524697ae276ad847ad0a6b3faa4bcb027e9a4614ad0"
|
checksum = "ff2abc00be7fca6ebc474524697ae276ad847ad0a6b3faa4bcb027e9a4614ad0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cfg-if",
|
"cfg-if",
|
||||||
"js-sys",
|
|
||||||
"libc",
|
"libc",
|
||||||
"wasi 0.11.1+wasi-snapshot-preview1",
|
"wasi 0.11.1+wasi-snapshot-preview1",
|
||||||
"wasm-bindgen",
|
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -828,23 +802,6 @@ dependencies = [
|
|||||||
"pin-project-lite",
|
"pin-project-lite",
|
||||||
"smallvec",
|
"smallvec",
|
||||||
"tokio",
|
"tokio",
|
||||||
"want",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "hyper-rustls"
|
|
||||||
version = "0.27.10"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "dfa8e654703247911e29c23fbeaa261834bd9bb74efba2f9acddc37bfb127f53"
|
|
||||||
dependencies = [
|
|
||||||
"http",
|
|
||||||
"hyper",
|
|
||||||
"hyper-util",
|
|
||||||
"rustls",
|
|
||||||
"tokio",
|
|
||||||
"tokio-rustls",
|
|
||||||
"tower-service",
|
|
||||||
"webpki-roots 1.0.12",
|
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -853,22 +810,13 @@ version = "0.1.21"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "ddc03d96684f9226b8a787cdb71488417b53ab5ea8fdb1dac946cb9431cc8bff"
|
checksum = "ddc03d96684f9226b8a787cdb71488417b53ab5ea8fdb1dac946cb9431cc8bff"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"base64 0.23.1",
|
|
||||||
"bytes",
|
"bytes",
|
||||||
"futures-channel",
|
|
||||||
"futures-util",
|
|
||||||
"http",
|
"http",
|
||||||
"http-body",
|
"http-body",
|
||||||
"httparse",
|
|
||||||
"hyper",
|
"hyper",
|
||||||
"ipnet",
|
|
||||||
"libc",
|
|
||||||
"percent-encoding",
|
|
||||||
"pin-project-lite",
|
"pin-project-lite",
|
||||||
"socket2 0.6.5",
|
|
||||||
"tokio",
|
"tokio",
|
||||||
"tower-service",
|
"tower-service",
|
||||||
"tracing",
|
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -985,12 +933,6 @@ dependencies = [
|
|||||||
"hashbrown 0.17.2",
|
"hashbrown 0.17.2",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "ipnet"
|
|
||||||
version = "2.12.3"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "007d6e6b91097094791302ccc6cd0588e0700ddac5c6829035bcd71eff4dc433"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "itoa"
|
name = "itoa"
|
||||||
version = "1.0.19"
|
version = "1.0.19"
|
||||||
@@ -1079,12 +1021,6 @@ dependencies = [
|
|||||||
"hashbrown 0.16.1",
|
"hashbrown 0.16.1",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "lru-slab"
|
|
||||||
version = "0.1.3"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "4050469837a6ff301cd14c1f8f24f88549e6d548f24f64e2148eb0f72cebc51f"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "matchit"
|
name = "matchit"
|
||||||
version = "0.8.4"
|
version = "0.8.4"
|
||||||
@@ -1178,7 +1114,7 @@ version = "0.35.5"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "fbb9f371618ce723f095c61fbcdc36e8936956d2b62832f9c7648689b338e052"
|
checksum = "fbb9f371618ce723f095c61fbcdc36e8936956d2b62832f9c7648689b338e052"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"base64 0.22.1",
|
"base64",
|
||||||
"bitflags",
|
"bitflags",
|
||||||
"btoi",
|
"btoi",
|
||||||
"byteorder",
|
"byteorder",
|
||||||
@@ -1285,7 +1221,7 @@ version = "3.0.6"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "1d30c53c26bc5b31a98cd02d20f25a7c8567146caf63ed593a9d87b2775291be"
|
checksum = "1d30c53c26bc5b31a98cd02d20f25a7c8567146caf63ed593a9d87b2775291be"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"base64 0.22.1",
|
"base64",
|
||||||
"serde_core",
|
"serde_core",
|
||||||
]
|
]
|
||||||
|
|
||||||
@@ -1332,7 +1268,7 @@ version = "0.6.12"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "08808e3c483c46e999108051c78334f473d5adb59d78bb80a1268c7e6aa6c514"
|
checksum = "08808e3c483c46e999108051c78334f473d5adb59d78bb80a1268c7e6aa6c514"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"base64 0.22.1",
|
"base64",
|
||||||
"byteorder",
|
"byteorder",
|
||||||
"bytes",
|
"bytes",
|
||||||
"fallible-iterator 0.2.0",
|
"fallible-iterator 0.2.0",
|
||||||
@@ -1382,62 +1318,6 @@ dependencies = [
|
|||||||
"unicode-ident",
|
"unicode-ident",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "quinn"
|
|
||||||
version = "0.11.12"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "4051e23e9185c255a7e33ef59cdbca87a22d359052eecd22fc6b901fb37d9d11"
|
|
||||||
dependencies = [
|
|
||||||
"bytes",
|
|
||||||
"cfg_aliases",
|
|
||||||
"pin-project-lite",
|
|
||||||
"quinn-proto",
|
|
||||||
"quinn-udp",
|
|
||||||
"rustc-hash",
|
|
||||||
"rustls",
|
|
||||||
"socket2 0.6.5",
|
|
||||||
"thiserror",
|
|
||||||
"tokio",
|
|
||||||
"tracing",
|
|
||||||
"web-time",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "quinn-proto"
|
|
||||||
version = "0.11.19"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "0e750cca55fe4f0439a15d0bb529da9651e79993e8e72c61a899a36d462befbe"
|
|
||||||
dependencies = [
|
|
||||||
"bytes",
|
|
||||||
"getrandom 0.4.3",
|
|
||||||
"lru-slab",
|
|
||||||
"rand 0.10.4",
|
|
||||||
"rand_pcg",
|
|
||||||
"ring",
|
|
||||||
"rustc-hash",
|
|
||||||
"rustls",
|
|
||||||
"rustls-pki-types",
|
|
||||||
"slab",
|
|
||||||
"thiserror",
|
|
||||||
"tinyvec",
|
|
||||||
"tracing",
|
|
||||||
"web-time",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "quinn-udp"
|
|
||||||
version = "0.5.16"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "af66907df18639dcf4db56ca65490cabc4b27a97dbadd96f2926cca73298f016"
|
|
||||||
dependencies = [
|
|
||||||
"cfg_aliases",
|
|
||||||
"libc",
|
|
||||||
"once_cell",
|
|
||||||
"socket2 0.6.5",
|
|
||||||
"tracing",
|
|
||||||
"windows-sys 0.61.2",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "quote"
|
name = "quote"
|
||||||
version = "1.0.47"
|
version = "1.0.47"
|
||||||
@@ -1505,15 +1385,6 @@ version = "0.10.1"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "63b8176103e19a2643978565ca18b50549f6101881c443590420e4dc998a3c69"
|
checksum = "63b8176103e19a2643978565ca18b50549f6101881c443590420e4dc998a3c69"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "rand_pcg"
|
|
||||||
version = "0.10.3"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "eb95882a1e14462c69aea9984bb261293ccfe6022ef8de0eda18bd5afb0052df"
|
|
||||||
dependencies = [
|
|
||||||
"rand_core 0.10.1",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "redox_syscall"
|
name = "redox_syscall"
|
||||||
version = "0.5.18"
|
version = "0.5.18"
|
||||||
@@ -1552,44 +1423,6 @@ version = "0.8.12"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "d902046e6a28a1e4c3cab97258a0ce11e994903f01c2d97a9447a0b3df85f4f6"
|
checksum = "d902046e6a28a1e4c3cab97258a0ce11e994903f01c2d97a9447a0b3df85f4f6"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "reqwest"
|
|
||||||
version = "0.12.28"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "eddd3ca559203180a307f12d114c268abf583f59b03cb906fd0b3ff8646c1147"
|
|
||||||
dependencies = [
|
|
||||||
"base64 0.22.1",
|
|
||||||
"bytes",
|
|
||||||
"futures-core",
|
|
||||||
"http",
|
|
||||||
"http-body",
|
|
||||||
"http-body-util",
|
|
||||||
"hyper",
|
|
||||||
"hyper-rustls",
|
|
||||||
"hyper-util",
|
|
||||||
"js-sys",
|
|
||||||
"log",
|
|
||||||
"percent-encoding",
|
|
||||||
"pin-project-lite",
|
|
||||||
"quinn",
|
|
||||||
"rustls",
|
|
||||||
"rustls-pki-types",
|
|
||||||
"serde",
|
|
||||||
"serde_json",
|
|
||||||
"serde_urlencoded",
|
|
||||||
"sync_wrapper",
|
|
||||||
"tokio",
|
|
||||||
"tokio-rustls",
|
|
||||||
"tower",
|
|
||||||
"tower-http",
|
|
||||||
"tower-service",
|
|
||||||
"url",
|
|
||||||
"wasm-bindgen",
|
|
||||||
"wasm-bindgen-futures",
|
|
||||||
"web-sys",
|
|
||||||
"webpki-roots 1.0.12",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ring"
|
name = "ring"
|
||||||
version = "0.17.14"
|
version = "0.17.14"
|
||||||
@@ -1618,12 +1451,6 @@ dependencies = [
|
|||||||
"smallvec",
|
"smallvec",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "rustc-hash"
|
|
||||||
version = "2.1.3"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "6b1e7f9a428571be2dc5bc0505c13fb6bf936822b894ec87abf8a08a4e51742d"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rustix"
|
name = "rustix"
|
||||||
version = "1.1.6"
|
version = "1.1.6"
|
||||||
@@ -1666,7 +1493,6 @@ version = "1.16.0"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "102f35f7de7b06d8c61f1cff6592f5253e0dea431c74867aad5dfd70f44663fb"
|
checksum = "102f35f7de7b06d8c61f1cff6592f5253e0dea431c74867aad5dfd70f44663fb"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"web-time",
|
|
||||||
"zeroize",
|
"zeroize",
|
||||||
]
|
]
|
||||||
|
|
||||||
@@ -1687,12 +1513,6 @@ version = "1.0.23"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "cf54715a573b99ac80df0bc206da022bcd442c974952c7b9720069370852e21f"
|
checksum = "cf54715a573b99ac80df0bc206da022bcd442c974952c7b9720069370852e21f"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "ryu"
|
|
||||||
version = "1.0.23"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "9774ba4a74de5f7b1c1451ed6cd5285a32eddb5cccb8cc655a4e50009e06477f"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "saturating"
|
name = "saturating"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
@@ -1722,7 +1542,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||||||
checksum = "969cde0349344dbbf58b5f9badbfb8f806db13969364eb8007c057ef687007d9"
|
checksum = "969cde0349344dbbf58b5f9badbfb8f806db13969364eb8007c057ef687007d9"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"annotate-snippets",
|
"annotate-snippets",
|
||||||
"base64 0.22.1",
|
"base64",
|
||||||
"encoding_rs_io",
|
"encoding_rs_io",
|
||||||
"granit-parser",
|
"granit-parser",
|
||||||
"nohash-hasher",
|
"nohash-hasher",
|
||||||
@@ -1785,18 +1605,6 @@ dependencies = [
|
|||||||
"serde_core",
|
"serde_core",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "serde_urlencoded"
|
|
||||||
version = "0.7.1"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "d3491c14715ca2294c4d6a88f15e84739788c1d030eed8c110436aafdaa2f3fd"
|
|
||||||
dependencies = [
|
|
||||||
"form_urlencoded",
|
|
||||||
"itoa",
|
|
||||||
"ryu",
|
|
||||||
"serde",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "sha1"
|
name = "sha1"
|
||||||
version = "0.10.7"
|
version = "0.10.7"
|
||||||
@@ -1956,9 +1764,6 @@ name = "sync_wrapper"
|
|||||||
version = "1.0.2"
|
version = "1.0.2"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "0bf256ce5efdfa370213c1dabab5935a12e49f2c58d15e9eac2870d3b4f27263"
|
checksum = "0bf256ce5efdfa370213c1dabab5935a12e49f2c58d15e9eac2870d3b4f27263"
|
||||||
dependencies = [
|
|
||||||
"futures-core",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "synstructure"
|
name = "synstructure"
|
||||||
@@ -2198,24 +2003,6 @@ dependencies = [
|
|||||||
"tower-service",
|
"tower-service",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "tower-http"
|
|
||||||
version = "0.6.11"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "4cfcf7e2740e6fc6d4d688b4ef00650406bb94adf4731e43c096c3a19fe40840"
|
|
||||||
dependencies = [
|
|
||||||
"bitflags",
|
|
||||||
"bytes",
|
|
||||||
"futures-util",
|
|
||||||
"http",
|
|
||||||
"http-body",
|
|
||||||
"pin-project-lite",
|
|
||||||
"tower",
|
|
||||||
"tower-layer",
|
|
||||||
"tower-service",
|
|
||||||
"url",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "tower-layer"
|
name = "tower-layer"
|
||||||
version = "0.3.3"
|
version = "0.3.3"
|
||||||
@@ -2259,12 +2046,6 @@ dependencies = [
|
|||||||
"once_cell",
|
"once_cell",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "try-lock"
|
|
||||||
version = "0.2.5"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "twox-hash"
|
name = "twox-hash"
|
||||||
version = "2.1.5"
|
version = "2.1.5"
|
||||||
@@ -2365,15 +2146,6 @@ version = "0.9.5"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a"
|
checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "want"
|
|
||||||
version = "0.3.2"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "ec4cdd0dd910afe868b7ef477227d8d538b46b3075031afee8a9f2acb0a2ed0b"
|
|
||||||
dependencies = [
|
|
||||||
"try-lock",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "wasi"
|
name = "wasi"
|
||||||
version = "0.11.1+wasi-snapshot-preview1"
|
version = "0.11.1+wasi-snapshot-preview1"
|
||||||
@@ -2419,17 +2191,6 @@ dependencies = [
|
|||||||
"wasm-bindgen-shared",
|
"wasm-bindgen-shared",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "wasm-bindgen-futures"
|
|
||||||
version = "0.4.80"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "5e14e0327cb5368ad60ccb22d04a9827a693c95a926d8d125e9fa39e0baec501"
|
|
||||||
dependencies = [
|
|
||||||
"js-sys",
|
|
||||||
"tokio",
|
|
||||||
"wasm-bindgen",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "wasm-bindgen-macro"
|
name = "wasm-bindgen-macro"
|
||||||
version = "0.2.130"
|
version = "0.2.130"
|
||||||
@@ -2472,16 +2233,6 @@ dependencies = [
|
|||||||
"wasm-bindgen",
|
"wasm-bindgen",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "web-time"
|
|
||||||
version = "1.1.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "5a6580f308b1fad9207618087a65c04e7a10bc77e02c8e84e9b00dd4b12fa0bb"
|
|
||||||
dependencies = [
|
|
||||||
"js-sys",
|
|
||||||
"wasm-bindgen",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "webpki-roots"
|
name = "webpki-roots"
|
||||||
version = "0.26.11"
|
version = "0.26.11"
|
||||||
|
|||||||
@@ -1,16 +1,4 @@
|
|||||||
# Bedrock 集群 RPC 原型归档
|
# Bedrock storage
|
||||||
|
|
||||||
`codex/cluster-rpc-archive` 保存 Bedrock 早期的三个 Rust RPC 原型,供以后对照契约和传输实现。原型开发已暂停。Bedrock 的逻辑集群工作在 `codex/cluster-research` 的 `crates/clusters` 内继续。[研究分支 PR #33](https://gitea.entroia.com/Zayden-Jung/Bedrock/pulls/33)
|
|
||||||
|
|
||||||
| 原工作分支 | 值得查看的内容 | 完整版本 |
|
|
||||||
| --- | --- | --- |
|
|
||||||
| `codex/typed-service-bindings` | 同一份 Rust 声明生成 HTTP 客户端和 Axum 路由。部署状态查询接入管理监听器,集成测试覆盖鉴权和无效请求。归档分支默认展示这套源码。 | [`46b85a9`](https://gitea.entroia.com/Zayden-Jung/Bedrock/src/commit/46b85a9d474cafad1034b1d249c736cc8cfa2ce4) |
|
|
||||||
| `codex/typed-service-contracts` | 版本化服务名和稳定的方法编号驱动客户端与服务端分派。进程内测试和回环 TCP 示例展示同一契约如何适配不同传输。 | [`7a7ee45`](https://gitea.entroia.com/Zayden-Jung/Bedrock/src/commit/7a7ee457614461382e3a815a78617dd675dcc48e) |
|
|
||||||
| `codex/cluster-rpc` | 保存整理前的开发现场。HTTP 实现与方法编号版的示例、测试和依赖清单处于混用状态。此版本用于追溯中间改动。 | [`6a81ed9`](https://gitea.entroia.com/Zayden-Jung/Bedrock/src/commit/6a81ed95a177df9c1703009faadc4696e0454855) |
|
|
||||||
|
|
||||||
三个链接分别打开各自的源码树。这些提交都在本分支的合并历史中。原型中的 `crates/bedrock-rpc` 记录了当时单独分包的实验;后续实现可参考其中的契约和测试。以下为 HTTP 原型原有的项目说明。
|
|
||||||
|
|
||||||
## Bedrock storage
|
|
||||||
|
|
||||||
Bedrock stores JSON documents in SQLite, PostgreSQL or MySQL. Each backend has its own module in the `database` crate. SQLite is the default and creates `bedrock.sqlite3` in the current directory on first start.
|
Bedrock stores JSON documents in SQLite, PostgreSQL or MySQL. Each backend has its own module in the `database` crate. SQLite is the default and creates `bedrock.sqlite3` in the current directory on first start.
|
||||||
|
|
||||||
@@ -20,13 +8,6 @@ Bedrock stores JSON documents in SQLite, PostgreSQL or MySQL. Each backend has i
|
|||||||
|
|
||||||
Notion describes sharding online PostgreSQL block data by workspace and feeding a downstream S3 data lake from PostgreSQL changes. Bedrock supports named SQL roles and read replicas. The catalog can describe S3 buckets. Object I/O, workspace routing, and data-lake ingestion are future work. [Notion's PostgreSQL sharding](https://www.notion.com/blog/sharding-postgres-at-notion) · [Notion's data lake](https://www.notion.com/blog/building-and-scaling-notions-data-lake)
|
Notion describes sharding online PostgreSQL block data by workspace and feeding a downstream S3 data lake from PostgreSQL changes. Bedrock supports named SQL roles and read replicas. The catalog can describe S3 buckets. Object I/O, workspace routing, and data-lake ingestion are future work. [Notion's PostgreSQL sharding](https://www.notion.com/blog/sharding-postgres-at-notion) · [Notion's data lake](https://www.notion.com/blog/building-and-scaling-notions-data-lake)
|
||||||
|
|
||||||
## Cluster service calls
|
|
||||||
|
|
||||||
[bedrock-rpc](crates/bedrock-rpc/README.md) generates typed clients, handlers,
|
|
||||||
and Axum routes from a shared Rust declaration. The first contract reads
|
|
||||||
deployment status via `POST /admin/v1/deployment/status` with JSON body `{}`
|
|
||||||
and the admin listener's existing bearer authentication.
|
|
||||||
|
|
||||||
## Web backend
|
## Web backend
|
||||||
|
|
||||||
Run the Axum service with `cargo run --locked -p backend`. One process owns
|
Run the Axum service with `cargo run --locked -p backend`. One process owns
|
||||||
@@ -36,7 +17,7 @@ separate routers on the business and optional admin listeners.
|
|||||||
| Listener | Setting and default | Routes |
|
| Listener | Setting and default | Routes |
|
||||||
|---|---|---|
|
|---|---|---|
|
||||||
| Business | `BEDROCK_BACKEND_LISTEN`, default `127.0.0.1:8080` | `GET /healthz`, `GET /readyz` |
|
| Business | `BEDROCK_BACKEND_LISTEN`, default `127.0.0.1:8080` | `GET /healthz`, `GET /readyz` |
|
||||||
| Admin | `BEDROCK_ADMIN_LISTEN`, default `127.0.0.1:8081` when enabled | `GET /healthz`, `GET /readyz`, `GET /admin/v1/status`, `POST /admin/v1/deployment/status` |
|
| Admin | `BEDROCK_ADMIN_LISTEN`, default `127.0.0.1:8081` when enabled | `GET /healthz`, `GET /readyz`, `GET /admin/v1/status` |
|
||||||
|
|
||||||
The business readiness probe checks access to the current deployment revision.
|
The business readiness probe checks access to the current deployment revision.
|
||||||
Set `BEDROCK_ADMIN_TOKEN` from a private credential source to enable the admin
|
Set `BEDROCK_ADMIN_TOKEN` from a private credential source to enable the admin
|
||||||
|
|||||||
@@ -6,10 +6,6 @@ rust-version.workspace = true
|
|||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
axum.workspace = true
|
axum.workspace = true
|
||||||
bedrock-rpc = { path = "../bedrock-rpc" }
|
|
||||||
clusters.workspace = true
|
clusters.workspace = true
|
||||||
serde.workspace = true
|
serde.workspace = true
|
||||||
subtle.workspace = true
|
subtle.workspace = true
|
||||||
|
|
||||||
[dev-dependencies]
|
|
||||||
tokio = { workspace = true, features = ["net"] }
|
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
pub mod rpc;
|
|
||||||
|
|
||||||
use std::{io, sync::Arc};
|
use std::{io, sync::Arc};
|
||||||
|
|
||||||
use axum::{
|
use axum::{
|
||||||
@@ -11,7 +9,7 @@ use axum::{
|
|||||||
routing::get,
|
routing::get,
|
||||||
};
|
};
|
||||||
use clusters::{DOCUMENTS, ResolvedDeployment, SqlDriver};
|
use clusters::{DOCUMENTS, ResolvedDeployment, SqlDriver};
|
||||||
use rpc::DeploymentStatus;
|
use serde::Serialize;
|
||||||
use subtle::ConstantTimeEq;
|
use subtle::ConstantTimeEq;
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
@@ -22,24 +20,26 @@ struct AdminState {
|
|||||||
read_only: bool,
|
read_only: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl AdminState {
|
#[derive(Serialize)]
|
||||||
fn status(&self) -> DeploymentStatus {
|
struct DeploymentStatus<'a> {
|
||||||
let config = &self.config;
|
deployment: &'a str,
|
||||||
DeploymentStatus {
|
config_version: Option<&'a str>,
|
||||||
deployment: config.deployment.clone(),
|
storage_driver: &'static str,
|
||||||
config_version: self
|
read_only: bool,
|
||||||
.config_version
|
|
||||||
.clone()
|
|
||||||
.or_else(|| Some(config.config_version.clone())),
|
|
||||||
storage_driver: self.storage_driver.to_owned(),
|
|
||||||
read_only: self.read_only,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl rpc::Service for AdminState {
|
impl AdminState {
|
||||||
async fn status(&self, _: rpc::StatusRequest) -> Result<DeploymentStatus, StatusCode> {
|
fn status(&self) -> DeploymentStatus<'_> {
|
||||||
Ok(self.status())
|
let config = &self.config;
|
||||||
|
DeploymentStatus {
|
||||||
|
deployment: &config.deployment,
|
||||||
|
config_version: self
|
||||||
|
.config_version
|
||||||
|
.as_deref()
|
||||||
|
.or(Some(&config.config_version)),
|
||||||
|
storage_driver: self.storage_driver,
|
||||||
|
read_only: self.read_only,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -71,16 +71,8 @@ pub fn router(
|
|||||||
};
|
};
|
||||||
let read_only = settings.read_only;
|
let read_only = settings.read_only;
|
||||||
|
|
||||||
let state = AdminState {
|
|
||||||
config,
|
|
||||||
config_version,
|
|
||||||
storage_driver,
|
|
||||||
read_only,
|
|
||||||
};
|
|
||||||
let admin = Router::new()
|
let admin = Router::new()
|
||||||
.route("/admin/v1/status", get(deployment_status))
|
.route("/status", get(deployment_status))
|
||||||
.with_state(state.clone())
|
|
||||||
.merge(rpc::router(state))
|
|
||||||
.route_layer(middleware::from_fn_with_state(
|
.route_layer(middleware::from_fn_with_state(
|
||||||
Arc::<str>::from(token),
|
Arc::<str>::from(token),
|
||||||
require_admin,
|
require_admin,
|
||||||
@@ -88,7 +80,13 @@ pub fn router(
|
|||||||
Ok(Router::new()
|
Ok(Router::new()
|
||||||
.route("/healthz", get(|| async { StatusCode::NO_CONTENT }))
|
.route("/healthz", get(|| async { StatusCode::NO_CONTENT }))
|
||||||
.route("/readyz", get(|| async { StatusCode::NO_CONTENT }))
|
.route("/readyz", get(|| async { StatusCode::NO_CONTENT }))
|
||||||
.merge(admin))
|
.nest("/admin/v1", admin)
|
||||||
|
.with_state(AdminState {
|
||||||
|
config,
|
||||||
|
config_version,
|
||||||
|
storage_driver,
|
||||||
|
read_only,
|
||||||
|
}))
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn deployment_status(State(state): State<AdminState>) -> Response {
|
async fn deployment_status(State(state): State<AdminState>) -> Response {
|
||||||
|
|||||||
@@ -1,19 +0,0 @@
|
|||||||
//! Shared wire contract for querying the Bedrock instance serving the request.
|
|
||||||
use serde::{Deserialize, Serialize};
|
|
||||||
|
|
||||||
#[derive(Deserialize, Serialize)]
|
|
||||||
pub struct StatusRequest {}
|
|
||||||
|
|
||||||
#[derive(Deserialize, Serialize)]
|
|
||||||
pub struct DeploymentStatus {
|
|
||||||
pub deployment: String,
|
|
||||||
pub config_version: Option<String>,
|
|
||||||
pub storage_driver: String,
|
|
||||||
pub read_only: bool,
|
|
||||||
}
|
|
||||||
|
|
||||||
bedrock_rpc::service! {
|
|
||||||
"/admin/v1/deployment" {
|
|
||||||
fn status(StatusRequest) -> DeploymentStatus;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,45 +0,0 @@
|
|||||||
use std::{sync::Arc, time::Duration};
|
|
||||||
|
|
||||||
use admin_backend::rpc::{Client, StatusRequest};
|
|
||||||
use axum::http::{HeaderMap, HeaderValue, StatusCode, header};
|
|
||||||
use bedrock_rpc::{Error, HttpTransport, Transport};
|
|
||||||
use clusters::DeploymentConfig;
|
|
||||||
|
|
||||||
#[tokio::test]
|
|
||||||
async fn status_rpc_uses_the_admin_listener_and_its_authentication() {
|
|
||||||
let config = DeploymentConfig::default().resolve().unwrap();
|
|
||||||
let app =
|
|
||||||
admin_backend::router(Arc::new(config), Some("release-7".into()), "test".into()).unwrap();
|
|
||||||
let listener = tokio::net::TcpListener::bind(("127.0.0.1", 0))
|
|
||||||
.await
|
|
||||||
.unwrap();
|
|
||||||
let origin = format!("http://{}", listener.local_addr().unwrap());
|
|
||||||
let server = tokio::spawn(async move { axum::serve(listener, app).await.unwrap() });
|
|
||||||
|
|
||||||
let peer = |headers| HttpTransport::new(&origin, Duration::from_secs(3), headers).unwrap();
|
|
||||||
let anonymous = Client(peer(HeaderMap::new()));
|
|
||||||
assert!(matches!(
|
|
||||||
anonymous.status(&StatusRequest {}).await,
|
|
||||||
Err(Error::Status(StatusCode::UNAUTHORIZED))
|
|
||||||
));
|
|
||||||
|
|
||||||
let mut headers = HeaderMap::new();
|
|
||||||
headers.insert(
|
|
||||||
header::AUTHORIZATION,
|
|
||||||
HeaderValue::from_static("Bearer test"),
|
|
||||||
);
|
|
||||||
let client = Client(peer(headers));
|
|
||||||
let status = client.status(&StatusRequest {}).await.unwrap();
|
|
||||||
assert_eq!(status.config_version.as_deref(), Some("release-7"));
|
|
||||||
assert_eq!(status.deployment, "default");
|
|
||||||
|
|
||||||
let malformed = client
|
|
||||||
.0
|
|
||||||
.post("/admin/v1/deployment/status", b"{".to_vec())
|
|
||||||
.await;
|
|
||||||
assert!(matches!(
|
|
||||||
malformed,
|
|
||||||
Err(Error::Status(StatusCode::BAD_REQUEST))
|
|
||||||
));
|
|
||||||
server.abort();
|
|
||||||
}
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
[package]
|
|
||||||
name = "bedrock-rpc"
|
|
||||||
version = "0.1.0"
|
|
||||||
edition.workspace = true
|
|
||||||
rust-version.workspace = true
|
|
||||||
|
|
||||||
[dependencies]
|
|
||||||
axum.workspace = true
|
|
||||||
reqwest = { version = "0.12", default-features = false, features = ["rustls-tls"] }
|
|
||||||
serde_json.workspace = true
|
|
||||||
thiserror.workspace = true
|
|
||||||
@@ -1,45 +0,0 @@
|
|||||||
# Bedrock RPC
|
|
||||||
|
|
||||||
每个服务用一个 Rust 模块发布契约。编译时,`service!` 将前缀、方法名、请求类型和响应类型展开成三个入口。调用方使用 `Client<T>`,服务实现 `Service`,启动代码将 `router(service)` 合入 Axum。Rust 会检查调用参数、返回类型和处理方法是否齐全。跨版本节点的兼容性仍取决于线上的 JSON 格式和路径。
|
|
||||||
|
|
||||||
```rust
|
|
||||||
mod replica {
|
|
||||||
bedrock_rpc::service! {
|
|
||||||
"/replica/v1" {
|
|
||||||
fn revision(()) -> u64;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
struct Replica { applied_revision: u64 }
|
|
||||||
impl replica::Service for Replica {
|
|
||||||
async fn revision(&self, _: ()) -> Result<u64, bedrock_rpc::axum::http::StatusCode> {
|
|
||||||
Ok(self.applied_revision)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
此方法通过 POST /replica/v1/revision 发送 JSON null。成功时返回 HTTP 200 和一个 JSON 整数。handler 可返回 HTTP 错误状态;调用方可以分别处理远端状态、网络失败和 JSON 解码失败。
|
|
||||||
|
|
||||||
## 目标集群与传输
|
|
||||||
|
|
||||||
发送方为目标创建一个可复用的 HttpTransport,传入 origin、每次请求的超时和请求头。集群内 origin 可指向服务 DNS,跨集群时指向已配置的 HTTPS 网关。网关需将契约路径转发至目标服务。服务发现、凭据分发和网关策略由部署方负责。发送凭据时应使用 HTTPS 或由服务网格保护的连接。自有传输可以实现 Transport::post,按路径传送 JSON 字节并返回响应。
|
|
||||||
|
|
||||||
```rust
|
|
||||||
use std::time::Duration;
|
|
||||||
use admin_backend::rpc::{Client, StatusRequest};
|
|
||||||
use bedrock_rpc::{HeaderMap, HttpTransport};
|
|
||||||
|
|
||||||
async fn config_version(origin: &str, headers: HeaderMap)
|
|
||||||
-> Result<Option<String>, bedrock_rpc::Error>
|
|
||||||
{
|
|
||||||
let peer = HttpTransport::new(origin, Duration::from_secs(3), headers)?;
|
|
||||||
let status = Client(peer).status(&StatusRequest {}).await?;
|
|
||||||
Ok(status.config_version)
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
Bedrock 已在管理监听器挂载 [deployment 契约](../admin_backend/src/rpc.rs)。调用方通过 headers 传入现有 Bearer 令牌。请求使用与 GET /admin/v1/status 相同的状态来源及鉴权中间件。
|
|
||||||
|
|
||||||
## 协议演进
|
|
||||||
|
|
||||||
首版支持一次请求返回一次响应。服务路径和方法名是协议标识,双方共享可由 Serde 编解码的 DTO。兼容扩展可添加新方法或带默认值的可选字段;旧节点收到未知路径返回 404。已有字段类型、方法名或语义需要改变时,发布新的版本前缀并在滚动升级期间并行提供两个版本。调用超时后,服务端可能已经执行操作,写入方法需要业务定义幂等语义。
|
|
||||||
@@ -1,130 +0,0 @@
|
|||||||
//! Compile-time bindings for unary Bedrock service contracts.
|
|
||||||
use std::{future::Future, time::Duration};
|
|
||||||
|
|
||||||
use axum::http::StatusCode;
|
|
||||||
pub use reqwest::header::HeaderMap;
|
|
||||||
|
|
||||||
#[doc(hidden)]
|
|
||||||
pub use axum;
|
|
||||||
#[doc(hidden)]
|
|
||||||
pub use serde_json;
|
|
||||||
|
|
||||||
#[derive(Debug, thiserror::Error)]
|
|
||||||
pub enum Error {
|
|
||||||
#[error("invalid RPC origin (expected an HTTP(S) origin without a path or credentials)")]
|
|
||||||
Origin,
|
|
||||||
#[error("RPC transport error")]
|
|
||||||
Network(#[from] reqwest::Error),
|
|
||||||
#[error("application transport failed")]
|
|
||||||
Transport(#[source] Box<dyn std::error::Error + Send + Sync>),
|
|
||||||
#[error("RPC peer returned HTTP {0}")]
|
|
||||||
Status(StatusCode),
|
|
||||||
#[error("RPC body exceeds the size limit")]
|
|
||||||
TooLarge,
|
|
||||||
#[error("invalid RPC JSON")]
|
|
||||||
Json(#[from] serde_json::Error),
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Same limit for encoded requests and successful replies (2 MiB).
|
|
||||||
pub const MAX_BODY: usize = 2 * 1024 * 1024;
|
|
||||||
|
|
||||||
/// Implement to route a call through an application-owned connection.
|
|
||||||
pub trait Transport: Sync {
|
|
||||||
fn post(
|
|
||||||
&self,
|
|
||||||
path: &'static str,
|
|
||||||
json: Vec<u8>,
|
|
||||||
) -> impl Future<Output = Result<Vec<u8>, Error>> + Send;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Reuses pooled connections to a single configured peer.
|
|
||||||
pub struct HttpTransport {
|
|
||||||
origin: reqwest::Url,
|
|
||||||
client: reqwest::Client,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl HttpTransport {
|
|
||||||
pub fn new(origin: &str, timeout: Duration, headers: HeaderMap) -> Result<Self, Error> {
|
|
||||||
let origin = reqwest::Url::parse(origin).map_err(|_| Error::Origin)?;
|
|
||||||
if !matches!(origin.scheme(), "https" | "http")
|
|
||||||
|| origin.host_str().is_none()
|
|
||||||
|| !origin.username().is_empty()
|
|
||||||
|| origin.password().is_some()
|
|
||||||
|| origin.path() != "/"
|
|
||||||
|| origin.query().is_some()
|
|
||||||
|| origin.fragment().is_some()
|
|
||||||
{
|
|
||||||
return Err(Error::Origin);
|
|
||||||
}
|
|
||||||
let client = reqwest::Client::builder()
|
|
||||||
.timeout(timeout)
|
|
||||||
.redirect(reqwest::redirect::Policy::none())
|
|
||||||
.default_headers(headers)
|
|
||||||
.build()?;
|
|
||||||
Ok(Self { origin, client })
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Transport for HttpTransport {
|
|
||||||
async fn post(&self, path: &'static str, json: Vec<u8>) -> Result<Vec<u8>, Error> {
|
|
||||||
if json.len() > MAX_BODY {
|
|
||||||
return Err(Error::TooLarge);
|
|
||||||
}
|
|
||||||
let mut url = self.origin.clone();
|
|
||||||
url.set_path(path);
|
|
||||||
let mut response = self
|
|
||||||
.client
|
|
||||||
.post(url)
|
|
||||||
.header(reqwest::header::CONTENT_TYPE, "application/json")
|
|
||||||
.body(json)
|
|
||||||
.send()
|
|
||||||
.await?;
|
|
||||||
if response.status() != StatusCode::OK {
|
|
||||||
return Err(Error::Status(response.status()));
|
|
||||||
}
|
|
||||||
let mut bytes = Vec::new();
|
|
||||||
while let Some(chunk) = response.chunk().await? {
|
|
||||||
if chunk.len() > MAX_BODY - bytes.len() {
|
|
||||||
return Err(Error::TooLarge);
|
|
||||||
}
|
|
||||||
bytes.extend_from_slice(&chunk);
|
|
||||||
}
|
|
||||||
Ok(bytes)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Declare once inside a contract module. The service prefix and method names
|
|
||||||
/// are part of the wire protocol. See the crate README for evolution rules.
|
|
||||||
#[macro_export]
|
|
||||||
macro_rules! service {
|
|
||||||
($prefix:literal { $(fn $method:ident($input:ty) -> $output:ty;)+ }) => {
|
|
||||||
pub trait Service: Send + Sync + 'static {
|
|
||||||
$(fn $method(&self, request: $input) -> impl ::std::future::Future<
|
|
||||||
Output = Result<$output, $crate::axum::http::StatusCode>
|
|
||||||
> + Send;)+
|
|
||||||
}
|
|
||||||
|
|
||||||
pub struct Client<T>(pub T);
|
|
||||||
|
|
||||||
impl<T: $crate::Transport> Client<T> {
|
|
||||||
$(pub async fn $method(&self, request: &$input) -> Result<$output, $crate::Error> {
|
|
||||||
let bytes = $crate::serde_json::to_vec(request)?;
|
|
||||||
let reply = self.0.post(concat!($prefix, "/", stringify!($method)), bytes).await?;
|
|
||||||
Ok($crate::serde_json::from_slice(&reply)?)
|
|
||||||
})+
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn router<S: Service>(service: S) -> $crate::axum::Router {
|
|
||||||
use $crate::axum::{Json, Router, extract::State, routing::post};
|
|
||||||
use ::std::sync::Arc;
|
|
||||||
|
|
||||||
Router::new()
|
|
||||||
$(.route(concat!($prefix, "/", stringify!($method)), post(
|
|
||||||
|State(service): State<Arc<S>>, Json(request): Json<$input>| async move {
|
|
||||||
service.$method(request).await.map(Json)
|
|
||||||
}
|
|
||||||
)))+
|
|
||||||
.with_state(Arc::new(service))
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
@@ -16,4 +16,7 @@ pub use organization::{Organization, OrganizationId, OrganizationMembership, Org
|
|||||||
pub use rich_text::{Inline, RichText};
|
pub use rich_text::{Inline, RichText};
|
||||||
pub use tree::{DocumentTree, TreeError};
|
pub use tree::{DocumentTree, TreeError};
|
||||||
pub use user::{User, UserId};
|
pub use user::{User, UserId};
|
||||||
pub use workspace::{Workspace, WorkspaceId};
|
pub use workspace::{
|
||||||
|
Workspace, WorkspaceAccess, WorkspaceAccessError, WorkspaceId, WorkspaceInvitation,
|
||||||
|
WorkspaceMembership, WorkspaceRole,
|
||||||
|
};
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ use super::contextualize::Contextualize;
|
|||||||
use super::{
|
use super::{
|
||||||
id::{IdError, validate_id},
|
id::{IdError, validate_id},
|
||||||
user::UserId,
|
user::UserId,
|
||||||
|
workspace::{Workspace, WorkspaceAccess, WorkspaceAccessError, WorkspaceId},
|
||||||
};
|
};
|
||||||
|
|
||||||
#[derive(Clone, Debug, Eq, Hash, PartialEq)]
|
#[derive(Clone, Debug, Eq, Hash, PartialEq)]
|
||||||
@@ -42,6 +43,20 @@ pub struct OrganizationMembership {
|
|||||||
pub role: OrganizationRole,
|
pub role: OrganizationRole,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Organization {
|
||||||
|
pub fn create_workspace(&self, id: WorkspaceId, name: impl Into<String>) -> Workspace {
|
||||||
|
Workspace::owned_by(id, name, self.id.clone())
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn set_workspace_access(
|
||||||
|
&self,
|
||||||
|
workspace: &mut Workspace,
|
||||||
|
access: WorkspaceAccess,
|
||||||
|
) -> Result<(), WorkspaceAccessError> {
|
||||||
|
workspace.set_organization_access(&self.id, access)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl Contextualize for Organization {
|
impl Contextualize for Organization {
|
||||||
fn render_context(&self) -> String {
|
fn render_context(&self) -> String {
|
||||||
format!("Organization: {}", self.name)
|
format!("Organization: {}", self.name)
|
||||||
|
|||||||
@@ -1,7 +1,12 @@
|
|||||||
|
use thiserror::Error;
|
||||||
|
|
||||||
use super::contextualize::Contextualize;
|
use super::contextualize::Contextualize;
|
||||||
use super::{
|
use super::{
|
||||||
|
Document,
|
||||||
id::{IdError, validate_id},
|
id::{IdError, validate_id},
|
||||||
organization::OrganizationId,
|
organization::{OrganizationId, OrganizationMembership},
|
||||||
|
tree::{DocumentTree, TreeError},
|
||||||
|
user::UserId,
|
||||||
};
|
};
|
||||||
|
|
||||||
#[derive(Clone, Debug, Eq, Hash, PartialEq)]
|
#[derive(Clone, Debug, Eq, Hash, PartialEq)]
|
||||||
@@ -21,12 +26,188 @@ impl WorkspaceId {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A workspace belongs to one organization and contains documents.
|
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
|
||||||
|
pub enum WorkspaceRole {
|
||||||
|
Owner,
|
||||||
|
Admin,
|
||||||
|
Editor,
|
||||||
|
Viewer,
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Controls which roles can be granted to people outside the owning organization.
|
||||||
|
#[derive(Clone, Copy, Debug, Default, Eq, PartialEq)]
|
||||||
|
pub enum WorkspaceAccess {
|
||||||
|
#[default]
|
||||||
|
MembersOnly,
|
||||||
|
ExternalViewers,
|
||||||
|
ExternalEditors,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl WorkspaceAccess {
|
||||||
|
fn allows_external(self, role: WorkspaceRole) -> bool {
|
||||||
|
matches!(
|
||||||
|
(self, role),
|
||||||
|
(
|
||||||
|
Self::ExternalViewers | Self::ExternalEditors,
|
||||||
|
WorkspaceRole::Viewer
|
||||||
|
) | (Self::ExternalEditors, WorkspaceRole::Editor)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, Eq, PartialEq)]
|
||||||
|
struct OrganizationWorkspace {
|
||||||
|
id: OrganizationId,
|
||||||
|
access: WorkspaceAccess,
|
||||||
|
}
|
||||||
|
|
||||||
|
/// A workspace contains documents and may be owned by an organization.
|
||||||
#[derive(Clone, Debug, Eq, PartialEq)]
|
#[derive(Clone, Debug, Eq, PartialEq)]
|
||||||
pub struct Workspace {
|
pub struct Workspace {
|
||||||
pub id: WorkspaceId,
|
pub id: WorkspaceId,
|
||||||
pub organization_id: OrganizationId,
|
|
||||||
pub name: String,
|
pub name: String,
|
||||||
|
organization: Option<OrganizationWorkspace>,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, Eq, PartialEq)]
|
||||||
|
pub struct WorkspaceInvitation {
|
||||||
|
workspace_id: WorkspaceId,
|
||||||
|
invitee: UserId,
|
||||||
|
role: WorkspaceRole,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, Eq, PartialEq)]
|
||||||
|
pub struct WorkspaceMembership {
|
||||||
|
pub workspace_id: WorkspaceId,
|
||||||
|
pub user_id: UserId,
|
||||||
|
pub role: WorkspaceRole,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Error, Eq, PartialEq)]
|
||||||
|
pub enum WorkspaceAccessError {
|
||||||
|
#[error("the workspace does not belong to this organization")]
|
||||||
|
OrganizationMismatch,
|
||||||
|
#[error("the workspace access policy does not allow this role for the invitee")]
|
||||||
|
RoleNotAllowed,
|
||||||
|
#[error("the invitation is for a different workspace or user")]
|
||||||
|
InvitationMismatch,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Workspace {
|
||||||
|
pub fn independent(id: WorkspaceId, name: impl Into<String>) -> Self {
|
||||||
|
Self {
|
||||||
|
id,
|
||||||
|
name: name.into(),
|
||||||
|
organization: None,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub(super) fn owned_by(
|
||||||
|
id: WorkspaceId,
|
||||||
|
name: impl Into<String>,
|
||||||
|
organization_id: OrganizationId,
|
||||||
|
) -> Self {
|
||||||
|
Self {
|
||||||
|
id,
|
||||||
|
name: name.into(),
|
||||||
|
organization: Some(OrganizationWorkspace {
|
||||||
|
id: organization_id,
|
||||||
|
access: WorkspaceAccess::default(),
|
||||||
|
}),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn organization_id(&self) -> Option<&OrganizationId> {
|
||||||
|
self.organization
|
||||||
|
.as_ref()
|
||||||
|
.map(|organization| &organization.id)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn organization_access(&self) -> Option<WorkspaceAccess> {
|
||||||
|
self.organization
|
||||||
|
.as_ref()
|
||||||
|
.map(|organization| organization.access)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub(super) fn set_organization_access(
|
||||||
|
&mut self,
|
||||||
|
organization_id: &OrganizationId,
|
||||||
|
access: WorkspaceAccess,
|
||||||
|
) -> Result<(), WorkspaceAccessError> {
|
||||||
|
let organization = self
|
||||||
|
.organization
|
||||||
|
.as_mut()
|
||||||
|
.filter(|organization| &organization.id == organization_id)
|
||||||
|
.ok_or(WorkspaceAccessError::OrganizationMismatch)?;
|
||||||
|
organization.access = access;
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Evaluates the invitee against the current policy. The caller supplies the
|
||||||
|
/// invitee's current membership in the owning organization, if any.
|
||||||
|
pub fn invite(
|
||||||
|
&self,
|
||||||
|
invitee: UserId,
|
||||||
|
role: WorkspaceRole,
|
||||||
|
organization_membership: Option<&OrganizationMembership>,
|
||||||
|
) -> Result<WorkspaceInvitation, WorkspaceAccessError> {
|
||||||
|
self.check_access(&invitee, role, organization_membership)?;
|
||||||
|
Ok(WorkspaceInvitation {
|
||||||
|
workspace_id: self.id.clone(),
|
||||||
|
invitee,
|
||||||
|
role,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Rechecks policy and membership so a pending invitation cannot preserve
|
||||||
|
/// privileges after either has changed.
|
||||||
|
pub fn accept_invitation(
|
||||||
|
&self,
|
||||||
|
user: &UserId,
|
||||||
|
invitation: &WorkspaceInvitation,
|
||||||
|
organization_membership: Option<&OrganizationMembership>,
|
||||||
|
) -> Result<WorkspaceMembership, WorkspaceAccessError> {
|
||||||
|
if invitation.workspace_id != self.id || &invitation.invitee != user {
|
||||||
|
return Err(WorkspaceAccessError::InvitationMismatch);
|
||||||
|
}
|
||||||
|
self.check_access(user, invitation.role, organization_membership)?;
|
||||||
|
Ok(WorkspaceMembership {
|
||||||
|
workspace_id: self.id.clone(),
|
||||||
|
user_id: user.clone(),
|
||||||
|
role: invitation.role,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Assembles an ordered tree of document nodes in this workspace.
|
||||||
|
pub fn document_tree(
|
||||||
|
&self,
|
||||||
|
root: Document,
|
||||||
|
descendants: impl IntoIterator<Item = Document>,
|
||||||
|
) -> Result<DocumentTree, TreeError> {
|
||||||
|
if root.key.workspace != self.id {
|
||||||
|
return Err(TreeError::WorkspaceMismatch);
|
||||||
|
}
|
||||||
|
DocumentTree::new(root, descendants)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn check_access(
|
||||||
|
&self,
|
||||||
|
user: &UserId,
|
||||||
|
role: WorkspaceRole,
|
||||||
|
membership: Option<&OrganizationMembership>,
|
||||||
|
) -> Result<(), WorkspaceAccessError> {
|
||||||
|
let Some(organization) = &self.organization else {
|
||||||
|
return Ok(());
|
||||||
|
};
|
||||||
|
let internal = membership.is_some_and(|membership| {
|
||||||
|
membership.organization_id == organization.id && &membership.user_id == user
|
||||||
|
});
|
||||||
|
if internal || organization.access.allows_external(role) {
|
||||||
|
Ok(())
|
||||||
|
} else {
|
||||||
|
Err(WorkspaceAccessError::RoleNotAllowed)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Contextualize for Workspace {
|
impl Contextualize for Workspace {
|
||||||
|
|||||||
@@ -0,0 +1,174 @@
|
|||||||
|
use documents::{
|
||||||
|
Document, DocumentContent, DocumentId, DocumentKey, Organization, OrganizationId,
|
||||||
|
OrganizationMembership, OrganizationRole, TreeError, UserId, Workspace, WorkspaceAccess,
|
||||||
|
WorkspaceAccessError, WorkspaceId, WorkspaceRole,
|
||||||
|
};
|
||||||
|
|
||||||
|
fn organization(id: &str) -> Organization {
|
||||||
|
Organization {
|
||||||
|
id: OrganizationId::new(id).unwrap(),
|
||||||
|
name: id.into(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn member(organization: &Organization, user: &UserId) -> OrganizationMembership {
|
||||||
|
OrganizationMembership {
|
||||||
|
organization_id: organization.id.clone(),
|
||||||
|
user_id: user.clone(),
|
||||||
|
role: OrganizationRole::Member,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn workspace_id(value: &str) -> WorkspaceId {
|
||||||
|
WorkspaceId::new(value).unwrap()
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn organization_controls_the_roles_available_to_external_users() {
|
||||||
|
use WorkspaceAccess::{ExternalEditors, ExternalViewers, MembersOnly};
|
||||||
|
use WorkspaceRole::{Admin, Editor, Owner, Viewer};
|
||||||
|
|
||||||
|
let organization = organization("org");
|
||||||
|
let mut workspace = organization.create_workspace(workspace_id("workspace"), "Workspace");
|
||||||
|
let outside = UserId::new("outside").unwrap();
|
||||||
|
let inside = UserId::new("inside").unwrap();
|
||||||
|
let membership = member(&organization, &inside);
|
||||||
|
assert_eq!(workspace.organization_id(), Some(&organization.id));
|
||||||
|
assert_eq!(workspace.organization_access(), Some(MembersOnly));
|
||||||
|
|
||||||
|
for (policy, allowed) in [
|
||||||
|
(MembersOnly, &[][..]),
|
||||||
|
(ExternalViewers, &[Viewer][..]),
|
||||||
|
(ExternalEditors, &[Viewer, Editor][..]),
|
||||||
|
] {
|
||||||
|
organization
|
||||||
|
.set_workspace_access(&mut workspace, policy)
|
||||||
|
.unwrap();
|
||||||
|
for role in [Owner, Admin, Editor, Viewer] {
|
||||||
|
let invitation = workspace.invite(outside.clone(), role, None);
|
||||||
|
if allowed.contains(&role) {
|
||||||
|
let membership = workspace
|
||||||
|
.accept_invitation(&outside, &invitation.unwrap(), None)
|
||||||
|
.unwrap();
|
||||||
|
assert_eq!(membership.user_id, outside);
|
||||||
|
assert_eq!(membership.workspace_id, workspace.id);
|
||||||
|
assert_eq!(membership.role, role);
|
||||||
|
} else {
|
||||||
|
assert_eq!(invitation, Err(WorkspaceAccessError::RoleNotAllowed));
|
||||||
|
}
|
||||||
|
assert!(
|
||||||
|
workspace
|
||||||
|
.invite(inside.clone(), role, Some(&membership))
|
||||||
|
.is_ok()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn acceptance_checks_the_invite_target_and_current_policy() {
|
||||||
|
let owner = organization("owner");
|
||||||
|
let other = organization("other");
|
||||||
|
let mut workspace = owner.create_workspace(workspace_id("workspace"), "Workspace");
|
||||||
|
let independent = Workspace::independent(workspace_id("personal"), "Personal");
|
||||||
|
let outsider = UserId::new("outside").unwrap();
|
||||||
|
let insider = UserId::new("inside").unwrap();
|
||||||
|
let inside_membership = member(&owner, &insider);
|
||||||
|
let other_membership = member(&other, &outsider);
|
||||||
|
|
||||||
|
for membership in [&inside_membership, &other_membership] {
|
||||||
|
assert_eq!(
|
||||||
|
workspace.invite(outsider.clone(), WorkspaceRole::Admin, Some(membership)),
|
||||||
|
Err(WorkspaceAccessError::RoleNotAllowed)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
let invitation = workspace
|
||||||
|
.invite(
|
||||||
|
insider.clone(),
|
||||||
|
WorkspaceRole::Admin,
|
||||||
|
Some(&inside_membership),
|
||||||
|
)
|
||||||
|
.unwrap();
|
||||||
|
assert_eq!(
|
||||||
|
workspace.accept_invitation(&insider, &invitation, None),
|
||||||
|
Err(WorkspaceAccessError::RoleNotAllowed)
|
||||||
|
);
|
||||||
|
assert_eq!(
|
||||||
|
independent.accept_invitation(&insider, &invitation, Some(&inside_membership)),
|
||||||
|
Err(WorkspaceAccessError::InvitationMismatch)
|
||||||
|
);
|
||||||
|
assert_eq!(
|
||||||
|
workspace.accept_invitation(&outsider, &invitation, None),
|
||||||
|
Err(WorkspaceAccessError::InvitationMismatch)
|
||||||
|
);
|
||||||
|
assert_eq!(independent.organization_id(), None);
|
||||||
|
assert!(
|
||||||
|
independent
|
||||||
|
.invite(outsider.clone(), WorkspaceRole::Editor, None)
|
||||||
|
.is_ok()
|
||||||
|
);
|
||||||
|
|
||||||
|
assert_eq!(
|
||||||
|
other.set_workspace_access(&mut workspace, WorkspaceAccess::ExternalEditors),
|
||||||
|
Err(WorkspaceAccessError::OrganizationMismatch)
|
||||||
|
);
|
||||||
|
owner
|
||||||
|
.set_workspace_access(&mut workspace, WorkspaceAccess::ExternalEditors)
|
||||||
|
.unwrap();
|
||||||
|
let external = workspace
|
||||||
|
.invite(outsider.clone(), WorkspaceRole::Editor, None)
|
||||||
|
.unwrap();
|
||||||
|
owner
|
||||||
|
.set_workspace_access(&mut workspace, WorkspaceAccess::ExternalViewers)
|
||||||
|
.unwrap();
|
||||||
|
assert_eq!(
|
||||||
|
workspace.accept_invitation(&outsider, &external, None),
|
||||||
|
Err(WorkspaceAccessError::RoleNotAllowed)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn workspace_contains_nested_documents_of_different_kinds() {
|
||||||
|
let workspace = Workspace::independent(workspace_id("workspace"), "Workspace");
|
||||||
|
let key = |id: &str| DocumentKey {
|
||||||
|
workspace: workspace.id.clone(),
|
||||||
|
document: DocumentId::new(id).unwrap(),
|
||||||
|
};
|
||||||
|
let page = Document::new(
|
||||||
|
key("page"),
|
||||||
|
DocumentContent::Page {
|
||||||
|
title: "Page".into(),
|
||||||
|
},
|
||||||
|
);
|
||||||
|
let mut child_page = Document::new(
|
||||||
|
key("subpage"),
|
||||||
|
DocumentContent::Page {
|
||||||
|
title: "Nested".into(),
|
||||||
|
},
|
||||||
|
);
|
||||||
|
child_page.parent_id = Some(page.key.document.clone());
|
||||||
|
let mut code = Document::new(
|
||||||
|
key("code"),
|
||||||
|
DocumentContent::Code {
|
||||||
|
language: "rust".into(),
|
||||||
|
source: "fn main() {}".into(),
|
||||||
|
},
|
||||||
|
);
|
||||||
|
code.parent_id = Some(child_page.key.document.clone());
|
||||||
|
|
||||||
|
let tree = workspace
|
||||||
|
.document_tree(page.clone(), [code, child_page])
|
||||||
|
.unwrap();
|
||||||
|
assert_eq!(
|
||||||
|
tree.nodes()
|
||||||
|
.map(|(depth, document)| (depth, document.key.document.as_str()))
|
||||||
|
.collect::<Vec<_>>(),
|
||||||
|
[(0, "page"), (1, "subpage"), (2, "code")]
|
||||||
|
);
|
||||||
|
|
||||||
|
let other = Workspace::independent(workspace_id("other"), "Other");
|
||||||
|
assert!(matches!(
|
||||||
|
other.document_tree(page, []),
|
||||||
|
Err(TreeError::WorkspaceMismatch)
|
||||||
|
));
|
||||||
|
}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
/node_modules/
|
||||||
|
/.next/
|
||||||
|
/out/
|
||||||
|
/coverage/
|
||||||
|
*.tsbuildinfo
|
||||||
|
next-env.d.ts
|
||||||
|
.env*
|
||||||
|
.DS_Store
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
import type { Metadata } from "next";
|
||||||
|
import type { ReactNode } from "react";
|
||||||
|
|
||||||
|
export const metadata: Metadata = { title: "Dashboard" };
|
||||||
|
|
||||||
|
export default function RootLayout({ children }: { children: ReactNode }) {
|
||||||
|
return <html lang="zh-CN"><body>{children}</body></html>;
|
||||||
|
}
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
export default function Page() {
|
||||||
|
return <main><h1>Dashboard</h1></main>;
|
||||||
|
}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
import type { NextConfig } from "next";
|
||||||
|
|
||||||
|
const config: NextConfig = {
|
||||||
|
agentRules: false,
|
||||||
|
devIndicators: false,
|
||||||
|
};
|
||||||
|
|
||||||
|
export default config;
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
{
|
||||||
|
"name": "@bedrock/dashboard",
|
||||||
|
"private": true,
|
||||||
|
"scripts": {
|
||||||
|
"dev": "next dev --hostname 127.0.0.1 --port 3001",
|
||||||
|
"build": "next build",
|
||||||
|
"start": "next start --hostname 127.0.0.1 --port 3001"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"next": "16.4.6",
|
||||||
|
"react": "19.3.1",
|
||||||
|
"react-dom": "19.3.1"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@types/node": "22.20.7",
|
||||||
|
"@types/react": "19.3.0",
|
||||||
|
"@types/react-dom": "19.3.0",
|
||||||
|
"typescript": "5.9.3"
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,41 @@
|
|||||||
|
{
|
||||||
|
"compilerOptions": {
|
||||||
|
"target": "ES2017",
|
||||||
|
"lib": [
|
||||||
|
"dom",
|
||||||
|
"dom.iterable",
|
||||||
|
"esnext"
|
||||||
|
],
|
||||||
|
"skipLibCheck": true,
|
||||||
|
"strict": true,
|
||||||
|
"noEmit": true,
|
||||||
|
"esModuleInterop": true,
|
||||||
|
"module": "esnext",
|
||||||
|
"moduleResolution": "bundler",
|
||||||
|
"isolatedModules": true,
|
||||||
|
"jsx": "react-jsx",
|
||||||
|
"plugins": [
|
||||||
|
{
|
||||||
|
"name": "next"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"paths": {
|
||||||
|
"@/*": [
|
||||||
|
"./*"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"allowJs": true,
|
||||||
|
"incremental": true,
|
||||||
|
"resolveJsonModule": true
|
||||||
|
},
|
||||||
|
"include": [
|
||||||
|
"next-env.d.ts",
|
||||||
|
"**/*.ts",
|
||||||
|
"**/*.tsx",
|
||||||
|
".next/types/**/*.ts",
|
||||||
|
".next/dev/types/**/*.ts"
|
||||||
|
],
|
||||||
|
"exclude": [
|
||||||
|
"node_modules"
|
||||||
|
]
|
||||||
|
}
|
||||||
@@ -0,0 +1,59 @@
|
|||||||
|
# Bedrock Kubernetes 部署路线
|
||||||
|
|
||||||
|
建集群、构建 Bedrock 镜像、编写部署清单可以并行。集群内 PostgreSQL 的清单在目标集群和命名空间就绪后提交。数据库可连接、Bedrock 镜像和运行配置就绪后,再初始化 Bedrock 存储。
|
||||||
|
|
||||||
|
```mermaid
|
||||||
|
flowchart TD
|
||||||
|
start["准备首次部署"]
|
||||||
|
|
||||||
|
subgraph infra ["准备 Kubernetes 集群"]
|
||||||
|
mode{"如何建集群"}
|
||||||
|
servers["自建:开云服务器,安装容器运行时和 Kubernetes 组件"]
|
||||||
|
controlPlane["kubeadm init 初始化控制平面"]
|
||||||
|
workers["kubeadm join 加入工作节点,安装 Pod 网络插件"]
|
||||||
|
managed["托管:创建 Kubernetes 集群和节点池"]
|
||||||
|
nodesReady["取得部署用 kubeconfig,确认节点 Ready"]
|
||||||
|
mode -->|"自建"| servers --> controlPlane --> workers --> nodesReady
|
||||||
|
mode -->|"托管"| managed --> nodesReady
|
||||||
|
end
|
||||||
|
|
||||||
|
subgraph image ["构建并发布镜像"]
|
||||||
|
compile["构建 runner 检出代码,编译 Rust 发布版"]
|
||||||
|
package["把 Bedrock 二进制打包进运行时镜像"]
|
||||||
|
push["用 Git SHA 标记镜像并推送到镜像仓库"]
|
||||||
|
compile --> package --> push
|
||||||
|
end
|
||||||
|
|
||||||
|
subgraph config ["准备部署清单和运行配置"]
|
||||||
|
database{"PostgreSQL 在哪里运行"}
|
||||||
|
inCluster["集群内:编写 PostgreSQL 部署清单,声明工作负载、持久卷和 Service"]
|
||||||
|
external["集群外:取得数据库端点并配置网络访问"]
|
||||||
|
app["编写 Bedrock Deployment、Service 和运行配置"]
|
||||||
|
secrets["准备数据库 Secret,私有镜像仓库按需配置拉取权限"]
|
||||||
|
database -->|"集群内"| inCluster --> app
|
||||||
|
database -->|"集群外"| external --> app
|
||||||
|
app --> secrets
|
||||||
|
end
|
||||||
|
|
||||||
|
start --> mode
|
||||||
|
start --> compile
|
||||||
|
start --> database
|
||||||
|
nodesReady --> target["确认目标集群和命名空间"]
|
||||||
|
target -->|"集群内 PostgreSQL"| applyDatabase["kubectl apply 提交 PostgreSQL 清单"]
|
||||||
|
inCluster -->|"清单已写好"| applyDatabase
|
||||||
|
applyDatabase --> dbReady["从目标集群确认 PostgreSQL 可连接"]
|
||||||
|
target -->|"集群外 PostgreSQL"| dbReady
|
||||||
|
external -->|"端点已配置"| dbReady
|
||||||
|
push --> appReady["确认 Bedrock 镜像版本和运行配置"]
|
||||||
|
secrets --> appReady
|
||||||
|
dbReady --> init["首次部署时运行 Bedrock 存储初始化"]
|
||||||
|
appReady --> init
|
||||||
|
init --> apply["kubectl apply 将 Bedrock 清单提交给 API Server"]
|
||||||
|
apply --> schedule["集群调度 Pod,工作节点拉取镜像并启动 Bedrock"]
|
||||||
|
schedule --> verify["检查 rollout、Pod 就绪状态和接口连通性"]
|
||||||
|
```
|
||||||
|
|
||||||
|
- **现有构建入口**。[Gitea 发布构建脚本](../../deploy/gitea/build-release.sh) 在构建容器里编译 Rust,并产出 `target/bedrock-release/bedrock`。上图的镜像打包、镜像推送和 Kubernetes 发布是迁移时要接上的步骤。
|
||||||
|
- **数据库清单**。编写 YAML 可以与建集群并行。提交清单前先拿到 kubeconfig,确认目标集群、命名空间和节点均已就绪。
|
||||||
|
- **首次初始化**。可以用同一份 Bedrock 镜像运行一次性 Kubernetes Job,等它成功完成再启动应用。集群内的数据库通过 Service 地址连接,集群外的数据库通过其端点连接。
|
||||||
|
- **日常发布**。沿用已有集群,在 runner 编译并推送新镜像,更新 Deployment 的镜像引用,提交清单并检查滚动发布结果。
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
/node_modules/
|
||||||
|
/.next/
|
||||||
|
/out/
|
||||||
|
/coverage/
|
||||||
|
*.tsbuildinfo
|
||||||
|
next-env.d.ts
|
||||||
|
.env*
|
||||||
|
.DS_Store
|
||||||
@@ -0,0 +1,123 @@
|
|||||||
|
/* latin-ext */
|
||||||
|
@font-face {
|
||||||
|
font-family: 'Instrument Sans';
|
||||||
|
font-style: normal;
|
||||||
|
font-weight: 400;
|
||||||
|
font-stretch: 100%;
|
||||||
|
font-display: swap;
|
||||||
|
src: url(/stitch/instrument-sans-1.woff2) format('woff2');
|
||||||
|
unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
|
||||||
|
}
|
||||||
|
/* latin */
|
||||||
|
@font-face {
|
||||||
|
font-family: 'Instrument Sans';
|
||||||
|
font-style: normal;
|
||||||
|
font-weight: 400;
|
||||||
|
font-stretch: 100%;
|
||||||
|
font-display: swap;
|
||||||
|
src: url(/stitch/instrument-sans-2.woff2) format('woff2');
|
||||||
|
unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
|
||||||
|
}
|
||||||
|
/* latin-ext */
|
||||||
|
@font-face {
|
||||||
|
font-family: 'Instrument Sans';
|
||||||
|
font-style: normal;
|
||||||
|
font-weight: 500;
|
||||||
|
font-stretch: 100%;
|
||||||
|
font-display: swap;
|
||||||
|
src: url(/stitch/instrument-sans-1.woff2) format('woff2');
|
||||||
|
unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
|
||||||
|
}
|
||||||
|
/* latin */
|
||||||
|
@font-face {
|
||||||
|
font-family: 'Instrument Sans';
|
||||||
|
font-style: normal;
|
||||||
|
font-weight: 500;
|
||||||
|
font-stretch: 100%;
|
||||||
|
font-display: swap;
|
||||||
|
src: url(/stitch/instrument-sans-2.woff2) format('woff2');
|
||||||
|
unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
|
||||||
|
}
|
||||||
|
/* latin-ext */
|
||||||
|
@font-face {
|
||||||
|
font-family: 'Instrument Sans';
|
||||||
|
font-style: normal;
|
||||||
|
font-weight: 600;
|
||||||
|
font-stretch: 100%;
|
||||||
|
font-display: swap;
|
||||||
|
src: url(/stitch/instrument-sans-1.woff2) format('woff2');
|
||||||
|
unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
|
||||||
|
}
|
||||||
|
/* latin */
|
||||||
|
@font-face {
|
||||||
|
font-family: 'Instrument Sans';
|
||||||
|
font-style: normal;
|
||||||
|
font-weight: 600;
|
||||||
|
font-stretch: 100%;
|
||||||
|
font-display: swap;
|
||||||
|
src: url(/stitch/instrument-sans-2.woff2) format('woff2');
|
||||||
|
unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
|
||||||
|
}
|
||||||
|
/* latin-ext */
|
||||||
|
@font-face {
|
||||||
|
font-family: 'Instrument Sans';
|
||||||
|
font-style: normal;
|
||||||
|
font-weight: 700;
|
||||||
|
font-stretch: 100%;
|
||||||
|
font-display: swap;
|
||||||
|
src: url(/stitch/instrument-sans-1.woff2) format('woff2');
|
||||||
|
unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
|
||||||
|
}
|
||||||
|
/* latin */
|
||||||
|
@font-face {
|
||||||
|
font-family: 'Instrument Sans';
|
||||||
|
font-style: normal;
|
||||||
|
font-weight: 700;
|
||||||
|
font-stretch: 100%;
|
||||||
|
font-display: swap;
|
||||||
|
src: url(/stitch/instrument-sans-2.woff2) format('woff2');
|
||||||
|
unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* fallback */
|
||||||
|
@font-face {
|
||||||
|
font-family: 'Material Symbols Outlined';
|
||||||
|
font-style: normal;
|
||||||
|
font-weight: 100 700;
|
||||||
|
font-display: block;
|
||||||
|
src: url(/stitch/material-symbols-1.woff2) format('woff2');
|
||||||
|
}
|
||||||
|
|
||||||
|
.material-symbols-outlined {
|
||||||
|
font-family: 'Material Symbols Outlined';
|
||||||
|
font-weight: normal;
|
||||||
|
font-style: normal;
|
||||||
|
font-size: 24px;
|
||||||
|
line-height: 1;
|
||||||
|
letter-spacing: normal;
|
||||||
|
text-transform: none;
|
||||||
|
display: inline-block;
|
||||||
|
white-space: nowrap;
|
||||||
|
word-wrap: normal;
|
||||||
|
direction: ltr;
|
||||||
|
-webkit-font-feature-settings: 'liga';
|
||||||
|
-webkit-font-smoothing: antialiased;
|
||||||
|
}
|
||||||
|
|
||||||
|
@tailwind base;
|
||||||
|
@tailwind components;
|
||||||
|
@tailwind utilities;
|
||||||
|
|
||||||
|
.material-symbols-outlined, .material-symbols-rounded, .material-symbols-sharp, .material-icons {
|
||||||
|
display: inline-block;
|
||||||
|
width: 1em;
|
||||||
|
height: 1em;
|
||||||
|
line-height: 1 !important;
|
||||||
|
box-sizing: content-box;
|
||||||
|
overflow: hidden;
|
||||||
|
white-space: nowrap;
|
||||||
|
direction: ltr;
|
||||||
|
vertical-align: middle;
|
||||||
|
}
|
||||||
|
.no-scrollbar::-webkit-scrollbar { display: none; }
|
||||||
|
.no-scrollbar { -ms-overflow-style: none; scrollbar-width: none; }
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
import type { Metadata } from "next";
|
||||||
|
import type { ReactNode } from "react";
|
||||||
|
import "./globals.css";
|
||||||
|
|
||||||
|
export const metadata: Metadata = { title: "X × 小红书 动态交互版" };
|
||||||
|
|
||||||
|
export default function RootLayout({ children }: { children: ReactNode }) {
|
||||||
|
return (
|
||||||
|
<html lang="zh-CN" className="h-full">
|
||||||
|
<body className="min-h-full flex flex-col bg-light-surface text-light-on-surface font-body antialiased">{children}</body>
|
||||||
|
</html>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
import { HomeDesign } from "@/components/home-design";
|
||||||
|
import { HomeInteractions } from "@/components/home-interactions";
|
||||||
|
|
||||||
|
export default function Page() {
|
||||||
|
return <><HomeDesign /><HomeInteractions /></>;
|
||||||
|
}
|
||||||
@@ -0,0 +1,704 @@
|
|||||||
|
export function HomeDesign() {
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<div className="flex-1 min-h-screen w-full flex bg-light-surface">
|
||||||
|
|
||||||
|
{/* Left Navigation Rail (X Design: Full on xl, Icon-Only on sm..lg, Hidden on mobile) */}
|
||||||
|
<aside className="hidden sm:flex sm:flex-col sm:justify-between sm:items-center xl:items-stretch w-20 xl:w-60 shrink-0 px-gutter-sm xl:px-gutter-md py-gutter-md self-stretch bg-light-surface">
|
||||||
|
<div className="sticky top-gutter-md flex flex-col items-center xl:items-stretch gap-gutter-xs">
|
||||||
|
<button type="button" data-nav="home" aria-label="X Home" className="nav-switch inline-flex items-center justify-center w-12 h-12 rounded-full hover:bg-light-surface-container transition-colors duration-state-change">
|
||||||
|
<svg viewBox="0 0 24 24" className="w-7 h-7 fill-current text-light-on-surface" aria-hidden="true">
|
||||||
|
<path d="M18.244 2.25h3.308l-7.227 8.26 8.502 11.24H16.17l-5.214-6.817L4.99 21.75H1.68l7.73-8.835L1.254 2.25H8.08l4.713 6.231zm-1.161 17.52h1.833L7.084 4.126H5.117z"></path>
|
||||||
|
</svg>
|
||||||
|
</button>
|
||||||
|
|
||||||
|
<nav aria-label="Primary navigation" className="flex flex-col items-center xl:items-stretch gap-gutter-xs">
|
||||||
|
<button type="button" data-nav="home" aria-current="page" className="nav-switch nav-item inline-flex items-center justify-center xl:justify-start gap-gutter-lg p-2.5 xl:px-gutter-md xl:py-2.5 rounded-full hover:bg-light-surface-container text-light-on-surface font-title text-title-lg transition-colors duration-state-change text-left">
|
||||||
|
<span className="nav-icon material-symbols-outlined text-headline-lg" style={{ fontVariationSettings: "'FILL' 1" }} aria-hidden="true">home</span>
|
||||||
|
<span className="hidden xl:inline">Home</span>
|
||||||
|
</button>
|
||||||
|
<a href="#explore" className="inline-flex items-center justify-center xl:justify-start gap-gutter-lg p-2.5 xl:px-gutter-md xl:py-2.5 rounded-full hover:bg-light-surface-container text-light-on-surface font-body text-title-lg transition-colors duration-state-change">
|
||||||
|
<span className="material-symbols-outlined text-headline-lg" aria-hidden="true">search</span>
|
||||||
|
<span className="hidden xl:inline">Explore</span>
|
||||||
|
</a>
|
||||||
|
<a href="#notifications" className="inline-flex items-center justify-center xl:justify-start gap-gutter-lg p-2.5 xl:px-gutter-md xl:py-2.5 rounded-full hover:bg-light-surface-container text-light-on-surface font-body text-title-lg transition-colors duration-state-change">
|
||||||
|
<span className="relative inline-flex">
|
||||||
|
<span className="material-symbols-outlined text-headline-lg" aria-hidden="true">notifications</span>
|
||||||
|
<span className="absolute -top-1 -right-1 inline-flex items-center justify-center w-4 h-4 rounded-full bg-light-tertiary text-light-on-tertiary font-label text-label-sm">2</span>
|
||||||
|
</span>
|
||||||
|
<span className="hidden xl:inline">Notifications</span>
|
||||||
|
</a>
|
||||||
|
<a href="#follow" className="inline-flex items-center justify-center xl:justify-start gap-gutter-lg p-2.5 xl:px-gutter-md xl:py-2.5 rounded-full hover:bg-light-surface-container text-light-on-surface font-body text-title-lg transition-colors duration-state-change">
|
||||||
|
<span className="material-symbols-outlined text-headline-lg" aria-hidden="true">person_add</span>
|
||||||
|
<span className="hidden xl:inline">Follow</span>
|
||||||
|
</a>
|
||||||
|
<a href="#chat" className="inline-flex items-center justify-center xl:justify-start gap-gutter-lg p-2.5 xl:px-gutter-md xl:py-2.5 rounded-full hover:bg-light-surface-container text-light-on-surface font-body text-title-lg transition-colors duration-state-change">
|
||||||
|
<span className="material-symbols-outlined text-headline-lg" aria-hidden="true">mail</span>
|
||||||
|
<span className="hidden xl:inline">Chat</span>
|
||||||
|
</a>
|
||||||
|
<a href="#grok" className="inline-flex items-center justify-center xl:justify-start gap-gutter-lg p-2.5 xl:px-gutter-md xl:py-2.5 rounded-full hover:bg-light-surface-container text-light-on-surface font-body text-title-lg transition-colors duration-state-change">
|
||||||
|
<span className="material-symbols-outlined text-headline-lg" aria-hidden="true">blur_on</span>
|
||||||
|
<span className="hidden xl:inline">Grok</span>
|
||||||
|
</a>
|
||||||
|
<a href="#bookmarks" className="inline-flex items-center justify-center xl:justify-start gap-gutter-lg p-2.5 xl:px-gutter-md xl:py-2.5 rounded-full hover:bg-light-surface-container text-light-on-surface font-body text-title-lg transition-colors duration-state-change">
|
||||||
|
<span className="material-symbols-outlined text-headline-lg" aria-hidden="true">bookmark_border</span>
|
||||||
|
<span className="hidden xl:inline">Bookmarks</span>
|
||||||
|
</a>
|
||||||
|
<a href="#creator-studio" className="inline-flex items-center justify-center xl:justify-start gap-gutter-lg p-2.5 xl:px-gutter-md xl:py-2.5 rounded-full hover:bg-light-surface-container text-light-on-surface font-body text-title-lg transition-colors duration-state-change">
|
||||||
|
<span className="material-symbols-outlined text-headline-lg" aria-hidden="true">science</span>
|
||||||
|
<span className="hidden xl:inline">Creator Studio</span>
|
||||||
|
</a>
|
||||||
|
<a href="#premium" className="inline-flex items-center justify-center xl:justify-start gap-gutter-lg p-2.5 xl:px-gutter-md xl:py-2.5 rounded-full hover:bg-light-surface-container text-light-on-surface font-body text-title-lg transition-colors duration-state-change">
|
||||||
|
<span className="material-symbols-outlined text-headline-lg" aria-hidden="true">verified</span>
|
||||||
|
<span className="hidden xl:inline">Premium</span>
|
||||||
|
</a>
|
||||||
|
<button type="button" data-nav="profile" className="nav-switch nav-item inline-flex items-center justify-center xl:justify-start gap-gutter-lg p-2.5 xl:px-gutter-md xl:py-2.5 rounded-full hover:bg-light-surface-container text-light-on-surface font-body text-title-lg transition-colors duration-state-change text-left">
|
||||||
|
<span className="nav-icon material-symbols-outlined text-headline-lg" aria-hidden="true">person_outline</span>
|
||||||
|
<span className="hidden xl:inline">Profile</span>
|
||||||
|
</button>
|
||||||
|
<button type="button" className="inline-flex items-center justify-center xl:justify-start gap-gutter-lg p-2.5 xl:px-gutter-md xl:py-2.5 rounded-full hover:bg-light-surface-container text-light-on-surface font-body text-title-lg transition-colors duration-state-change text-left">
|
||||||
|
<span className="material-symbols-outlined text-headline-lg" aria-hidden="true">pending</span>
|
||||||
|
<span className="hidden xl:inline">More</span>
|
||||||
|
</button>
|
||||||
|
</nav>
|
||||||
|
|
||||||
|
<div className="pt-gutter-md xl:pr-gutter-md">
|
||||||
|
<button type="button" aria-label="Post" className="w-11 h-11 xl:w-full xl:h-auto xl:py-3 xl:px-gutter-xl rounded-full bg-light-primary text-light-on-primary font-label text-label-lg hover:opacity-90 transition-opacity duration-state-change inline-flex items-center justify-center">
|
||||||
|
<span className="material-symbols-outlined text-headline-md xl:hidden" aria-hidden="true">edit</span>
|
||||||
|
<span className="hidden xl:inline">Post</span>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<button type="button" data-nav="profile" className="nav-switch flex items-center justify-center xl:justify-between gap-gutter-sm p-2 xl:p-gutter-md rounded-full hover:bg-light-surface-container bg-light-surface transition-colors duration-state-change text-left">
|
||||||
|
<div className="flex items-center gap-gutter-md min-w-0">
|
||||||
|
<img src="/stitch/profile-avatar.jpg" alt="有点AI思" className="w-10 h-10 rounded-full object-cover shrink-0" />
|
||||||
|
<div className="hidden xl:flex flex-col min-w-0">
|
||||||
|
<span className="font-title text-title-md text-light-on-surface truncate">有点AI思</span>
|
||||||
|
<span className="font-body text-body-sm text-light-on-surface-variant truncate">@you_dian_ai</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<span className="hidden xl:inline material-symbols-outlined text-title-lg text-light-on-surface-variant shrink-0" aria-hidden="true">more_horiz</span>
|
||||||
|
</button>
|
||||||
|
</aside>
|
||||||
|
|
||||||
|
{/* Center Column: Dynamic Switchable Views (Home Feed <-> User Profile) */}
|
||||||
|
<main className="flex-1 min-w-0 border-x border-light-outline-variant min-h-screen flex flex-col">
|
||||||
|
|
||||||
|
{/* VIEW 1: HOME FEED */}
|
||||||
|
<div id="view-home" className="flex flex-col">
|
||||||
|
{/* Sticky Top Feed Tabs & Channel Strip + Column Switcher */}
|
||||||
|
<header className="sticky top-0 z-20 bg-light-surface/95 border-b border-light-outline-variant">
|
||||||
|
<div role="tablist" aria-label="Timeline feed" className="grid grid-cols-2 border-b border-light-outline-variant">
|
||||||
|
<button role="tab" data-feed="for-you" aria-selected="true" className="feed-tab relative py-gutter-md flex items-center justify-center font-title text-title-md text-light-on-surface hover:bg-light-surface-container-low transition-colors duration-state-change">
|
||||||
|
<span>For you</span>
|
||||||
|
<span className="tab-indicator absolute bottom-0 w-16 h-1 rounded-full bg-x-blue"></span>
|
||||||
|
</button>
|
||||||
|
<button role="tab" data-feed="following" aria-selected="false" className="feed-tab relative py-gutter-md flex items-center justify-center font-title text-title-md text-light-on-surface-variant hover:bg-light-surface-container-low transition-colors duration-state-change">
|
||||||
|
<span>Following</span>
|
||||||
|
<span className="tab-indicator hidden absolute bottom-0 w-20 h-1 rounded-full bg-x-blue"></span>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* Xiaohongshu Channel Filter Pills */}
|
||||||
|
<div role="tablist" aria-label="内容频道" className="flex items-center gap-gutter-sm px-gutter-lg py-gutter-sm overflow-x-auto no-scrollbar">
|
||||||
|
<button role="tab" data-category="all" aria-selected="true" className="channel-pill px-gutter-md py-1 rounded-full bg-light-primary text-light-on-primary font-label text-label-md whitespace-nowrap">
|
||||||
|
<span>推荐</span>
|
||||||
|
</button>
|
||||||
|
<button role="tab" data-category="旅行" aria-selected="false" className="channel-pill px-gutter-md py-1 rounded-full bg-light-surface-container text-light-on-surface-variant hover:text-light-on-surface font-label text-label-md whitespace-nowrap">
|
||||||
|
<span>旅行</span>
|
||||||
|
</button>
|
||||||
|
<button role="tab" data-category="游戏" aria-selected="false" className="channel-pill px-gutter-md py-1 rounded-full bg-light-surface-container text-light-on-surface-variant hover:text-light-on-surface font-label text-label-md whitespace-nowrap">
|
||||||
|
<span>游戏</span>
|
||||||
|
</button>
|
||||||
|
<button role="tab" data-category="视频" aria-selected="false" className="channel-pill px-gutter-md py-1 rounded-full bg-light-surface-container text-light-on-surface-variant hover:text-light-on-surface font-label text-label-md whitespace-nowrap">
|
||||||
|
<span>视频</span>
|
||||||
|
</button>
|
||||||
|
<button role="tab" data-category="职场" aria-selected="false" className="channel-pill px-gutter-md py-1 rounded-full bg-light-surface-container text-light-on-surface-variant hover:text-light-on-surface font-label text-label-md whitespace-nowrap">
|
||||||
|
<span>职场</span>
|
||||||
|
</button>
|
||||||
|
<button role="tab" data-category="情感" aria-selected="false" className="channel-pill px-gutter-md py-1 rounded-full bg-light-surface-container text-light-on-surface-variant hover:text-light-on-surface font-label text-label-md whitespace-nowrap">
|
||||||
|
<span>情感</span>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</header>
|
||||||
|
|
||||||
|
{/* Responsive Waterfall Grid (2-col on mobile/tablet, 3-col on lg+) */}
|
||||||
|
<div id="home-note-feed" className="p-gutter-sm sm:p-gutter-md columns-2 lg:columns-3 gap-gutter-md space-y-gutter-md">
|
||||||
|
|
||||||
|
|
||||||
|
<article data-category="游戏" data-following="true" className="note-card break-inside-avoid flex flex-col gap-gutter-xs group cursor-pointer">
|
||||||
|
<div className="relative overflow-hidden rounded-md bg-light-surface-container-low border border-light-outline-variant">
|
||||||
|
<img src="/stitch/fish-game.jpg" alt="彩色手绘小鱼游戏封面" className="w-full h-auto object-cover group-hover:scale-105 transition-transform duration-state-change" />
|
||||||
|
</div>
|
||||||
|
<div className="px-gutter-xs flex flex-col gap-gutter-xs">
|
||||||
|
<h3 className="font-body text-body-md text-light-on-surface truncate">这游戏能卖80万美元</h3>
|
||||||
|
<div className="flex items-center justify-between">
|
||||||
|
<button type="button" data-nav="profile" className="nav-switch flex items-center gap-gutter-xs min-w-0 hover:underline">
|
||||||
|
<img src="/stitch/bbg-avatar.jpg" alt="BBGame" className="w-4 h-4 rounded-full object-cover shrink-0" />
|
||||||
|
<span className="font-body text-body-sm text-light-on-surface-variant truncate">BBGame</span>
|
||||||
|
</button>
|
||||||
|
<button type="button" className="like-btn inline-flex items-center gap-gutter-xs text-light-on-surface-variant hover:text-light-error shrink-0" data-liked="false" data-count="483" aria-label="点赞">
|
||||||
|
<span className="material-symbols-outlined text-body-md like-icon" aria-hidden="true">favorite_border</span>
|
||||||
|
<span className="font-body text-body-sm tabular-nums like-count">483</span>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</article>
|
||||||
|
|
||||||
|
|
||||||
|
<article data-category="视频" data-following="true" className="note-card break-inside-avoid flex flex-col gap-gutter-xs group cursor-pointer">
|
||||||
|
<div className="relative overflow-hidden rounded-md bg-light-surface-container-low border border-light-outline-variant">
|
||||||
|
<img src="/stitch/rainy-harbor.jpg" alt="雨夜海港小镇体素场景" className="w-full h-auto object-cover group-hover:scale-105 transition-transform duration-state-change" />
|
||||||
|
<span className="absolute top-gutter-sm right-gutter-sm inline-flex items-center justify-center w-6 h-6 rounded-full bg-light-primary/70 text-light-on-primary">
|
||||||
|
<span className="material-symbols-outlined text-body-md" style={{ fontVariationSettings: "'FILL' 1" }} aria-hidden="true">play_arrow</span>
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<div className="px-gutter-xs flex flex-col gap-gutter-xs">
|
||||||
|
<h3 className="font-body text-body-md text-light-on-surface truncate">雨夜海港太治愈</h3>
|
||||||
|
<div className="flex items-center justify-between">
|
||||||
|
<button type="button" data-nav="profile" className="nav-switch flex items-center gap-gutter-xs min-w-0 hover:underline">
|
||||||
|
<img src="/stitch/rainy-harbor.jpg" alt="像素造梦师" className="w-4 h-4 rounded-full object-cover shrink-0" />
|
||||||
|
<span className="font-body text-body-sm text-light-on-surface-variant truncate">像素造梦师</span>
|
||||||
|
</button>
|
||||||
|
<button type="button" className="like-btn inline-flex items-center gap-gutter-xs text-light-on-surface-variant hover:text-light-error shrink-0" data-liked="false" data-count="1284" aria-label="点赞">
|
||||||
|
<span className="material-symbols-outlined text-body-md like-icon" aria-hidden="true">favorite_border</span>
|
||||||
|
<span className="font-body text-body-sm tabular-nums like-count">1284</span>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</article>
|
||||||
|
|
||||||
|
|
||||||
|
<article data-category="情感" data-following="false" className="note-card break-inside-avoid flex flex-col gap-gutter-xs group cursor-pointer">
|
||||||
|
<div className="relative overflow-hidden rounded-md bg-light-surface-container-low border border-light-outline-variant">
|
||||||
|
<img src="/stitch/golden-retriever.jpg" alt="家里新来的小金毛" className="w-full h-auto object-cover group-hover:scale-105 transition-transform duration-state-change" />
|
||||||
|
</div>
|
||||||
|
<div className="px-gutter-xs flex flex-col gap-gutter-xs">
|
||||||
|
<h3 className="font-body text-body-md text-light-on-surface truncate">小金毛太粘人啦</h3>
|
||||||
|
<div className="flex items-center justify-between">
|
||||||
|
<button type="button" data-nav="profile" className="nav-switch flex items-center gap-gutter-xs min-w-0 hover:underline">
|
||||||
|
<img src="/stitch/golden-retriever.jpg" alt="单棱镜" className="w-4 h-4 rounded-full object-cover shrink-0" />
|
||||||
|
<span className="font-body text-body-sm text-light-on-surface-variant truncate">单棱镜</span>
|
||||||
|
</button>
|
||||||
|
<button type="button" className="like-btn inline-flex items-center gap-gutter-xs text-light-on-surface-variant hover:text-light-error shrink-0" data-liked="false" data-count="1520" aria-label="点赞">
|
||||||
|
<span className="material-symbols-outlined text-body-md like-icon" aria-hidden="true">favorite_border</span>
|
||||||
|
<span className="font-body text-body-sm tabular-nums like-count">1520</span>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</article>
|
||||||
|
|
||||||
|
|
||||||
|
<article data-category="旅行" data-following="true" className="note-card break-inside-avoid flex flex-col gap-gutter-xs group cursor-pointer">
|
||||||
|
<div className="relative overflow-hidden rounded-md bg-light-surface-container-low border border-light-outline-variant">
|
||||||
|
<img src="/stitch/chengdu.jpg" alt="成都环形城市航拍图" className="w-full h-auto object-cover group-hover:scale-105 transition-transform duration-state-change" />
|
||||||
|
<div className="absolute inset-0 bg-light-primary/65 flex flex-col items-center justify-center p-gutter-sm">
|
||||||
|
<span className="font-headline text-title-lg text-light-on-primary">成都</span>
|
||||||
|
<span className="font-title text-title-md text-light-on-primary">巨大的“圈”</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div className="px-gutter-xs flex flex-col gap-gutter-xs">
|
||||||
|
<h3 className="font-body text-body-md text-light-on-surface truncate">成都到底有几个圈?</h3>
|
||||||
|
<div className="flex items-center justify-between">
|
||||||
|
<button type="button" data-nav="profile" className="nav-switch flex items-center gap-gutter-xs min-w-0 hover:underline">
|
||||||
|
<img src="/stitch/chengdu.jpg" alt="西游兔" className="w-4 h-4 rounded-full object-cover shrink-0" />
|
||||||
|
<span className="font-body text-body-sm text-light-on-surface-variant truncate">西游兔</span>
|
||||||
|
</button>
|
||||||
|
<button type="button" className="like-btn inline-flex items-center gap-gutter-xs text-light-on-surface-variant hover:text-light-error shrink-0" data-liked="false" data-count="3936" aria-label="点赞">
|
||||||
|
<span className="material-symbols-outlined text-body-md like-icon" aria-hidden="true">favorite_border</span>
|
||||||
|
<span className="font-body text-body-sm tabular-nums like-count">3936</span>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</article>
|
||||||
|
|
||||||
|
|
||||||
|
<article data-category="游戏" data-following="true" className="note-card break-inside-avoid flex flex-col gap-gutter-xs group cursor-pointer">
|
||||||
|
<div className="relative overflow-hidden rounded-md bg-light-surface-container-low border border-light-outline-variant">
|
||||||
|
<img src="/stitch/dungeon.jpg" alt="街机厅的玩家和游戏屏幕" className="w-full h-auto object-cover group-hover:scale-105 transition-transform duration-state-change" />
|
||||||
|
</div>
|
||||||
|
<div className="px-gutter-xs flex flex-col gap-gutter-xs">
|
||||||
|
<h3 className="font-body text-body-md text-light-on-surface truncate">独立游戏一周目实录</h3>
|
||||||
|
<div className="flex items-center justify-between">
|
||||||
|
<button type="button" data-nav="profile" className="nav-switch flex items-center gap-gutter-xs min-w-0 hover:underline">
|
||||||
|
<img src="/stitch/chengdu.jpg" alt="阿宅玩游戏" className="w-4 h-4 rounded-full object-cover shrink-0" />
|
||||||
|
<span className="font-body text-body-sm text-light-on-surface-variant truncate">阿宅玩游戏</span>
|
||||||
|
</button>
|
||||||
|
<button type="button" className="like-btn inline-flex items-center gap-gutter-xs text-light-on-surface-variant hover:text-light-error shrink-0" data-liked="false" data-count="742" aria-label="点赞">
|
||||||
|
<span className="material-symbols-outlined text-body-md like-icon" aria-hidden="true">favorite_border</span>
|
||||||
|
<span className="font-body text-body-sm tabular-nums like-count">742</span>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</article>
|
||||||
|
|
||||||
|
|
||||||
|
<article data-category="职场" data-following="true" className="note-card break-inside-avoid flex flex-col gap-gutter-xs group cursor-pointer">
|
||||||
|
<div className="relative overflow-hidden rounded-md bg-light-surface-container-low border border-light-outline-variant p-gutter-sm flex flex-col gap-gutter-xs">
|
||||||
|
<span className="font-title text-title-md text-light-on-surface">AI编程助手</span>
|
||||||
|
<img src="/stitch/ai-tools.jpg" alt="桌面上的笔记本电脑" className="w-full h-auto rounded-sm object-cover" />
|
||||||
|
</div>
|
||||||
|
<div className="px-gutter-xs flex flex-col gap-gutter-xs">
|
||||||
|
<h3 className="font-body text-body-md text-light-on-surface truncate">AI助手实测对比</h3>
|
||||||
|
<div className="flex items-center justify-between">
|
||||||
|
<button type="button" data-nav="profile" className="nav-switch flex items-center gap-gutter-xs min-w-0 hover:underline">
|
||||||
|
<img src="/stitch/profile-avatar.jpg" alt="有点AI思" className="w-4 h-4 rounded-full object-cover shrink-0" />
|
||||||
|
<span className="font-body text-body-sm text-light-on-surface-variant truncate">有点AI思</span>
|
||||||
|
</button>
|
||||||
|
<button type="button" className="like-btn inline-flex items-center gap-gutter-xs text-light-on-surface-variant hover:text-light-error shrink-0" data-liked="false" data-count="612" aria-label="点赞">
|
||||||
|
<span className="material-symbols-outlined text-body-md like-icon" aria-hidden="true">favorite_border</span>
|
||||||
|
<span className="font-body text-body-sm tabular-nums like-count">612</span>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</article>
|
||||||
|
|
||||||
|
|
||||||
|
<article data-category="旅行" data-following="false" className="note-card break-inside-avoid flex flex-col gap-gutter-xs group cursor-pointer">
|
||||||
|
<div className="relative overflow-hidden rounded-md bg-light-surface-container-low border border-light-outline-variant">
|
||||||
|
<img src="/stitch/skyline.jpg" alt="夜色雾气中的城市天际线" className="w-full h-auto object-cover group-hover:scale-105 transition-transform duration-state-change" />
|
||||||
|
</div>
|
||||||
|
<div className="px-gutter-xs flex flex-col gap-gutter-xs">
|
||||||
|
<h3 className="font-body text-body-md text-light-on-surface truncate">夜幕降临的城市天际线</h3>
|
||||||
|
<div className="flex items-center justify-between">
|
||||||
|
<button type="button" data-nav="profile" className="nav-switch flex items-center gap-gutter-xs min-w-0 hover:underline">
|
||||||
|
<img src="/stitch/rainy-harbor.jpg" alt="Wingman" className="w-4 h-4 rounded-full object-cover shrink-0" />
|
||||||
|
<span className="font-body text-body-sm text-light-on-surface-variant truncate">Wingman</span>
|
||||||
|
</button>
|
||||||
|
<button type="button" className="like-btn inline-flex items-center gap-gutter-xs text-light-on-surface-variant hover:text-light-error shrink-0" data-liked="false" data-count="528" aria-label="点赞">
|
||||||
|
<span className="material-symbols-outlined text-body-md like-icon" aria-hidden="true">favorite_border</span>
|
||||||
|
<span className="font-body text-body-sm tabular-nums like-count">528</span>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</article>
|
||||||
|
|
||||||
|
|
||||||
|
<article data-category="职场" data-following="true" className="note-card break-inside-avoid flex flex-col gap-gutter-xs group cursor-pointer">
|
||||||
|
<div className="relative overflow-hidden rounded-md bg-light-surface-container-low border border-light-outline-variant">
|
||||||
|
<img src="/stitch/workspace.jpg" alt="光线照进写字台" className="w-full h-auto object-cover group-hover:scale-105 transition-transform duration-state-change" />
|
||||||
|
</div>
|
||||||
|
<div className="px-gutter-xs flex flex-col gap-gutter-xs">
|
||||||
|
<h3 className="font-body text-body-md text-light-on-surface truncate">午后光影工作台灵感</h3>
|
||||||
|
<div className="flex items-center justify-between">
|
||||||
|
<button type="button" data-nav="profile" className="nav-switch flex items-center gap-gutter-xs min-w-0 hover:underline">
|
||||||
|
<img src="/stitch/profile-avatar.jpg" alt="有点AI思" className="w-4 h-4 rounded-full object-cover shrink-0" />
|
||||||
|
<span className="font-body text-body-sm text-light-on-surface-variant truncate">有点AI思</span>
|
||||||
|
</button>
|
||||||
|
<button type="button" className="like-btn inline-flex items-center gap-gutter-xs text-light-on-surface-variant hover:text-light-error shrink-0" data-liked="true" data-count="842" aria-label="点赞">
|
||||||
|
<span className="material-symbols-outlined text-body-md like-icon text-light-error" style={{ fontVariationSettings: "'FILL' 1" }} aria-hidden="true">favorite</span>
|
||||||
|
<span className="font-body text-body-sm tabular-nums like-count">842</span>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</article>
|
||||||
|
|
||||||
|
|
||||||
|
<article data-category="旅行" data-following="false" className="note-card break-inside-avoid flex flex-col gap-gutter-xs group cursor-pointer">
|
||||||
|
<div className="relative overflow-hidden rounded-md bg-light-surface-container-low border border-light-outline-variant">
|
||||||
|
<img src="/stitch/film-walk.jpg" alt="街头漫步摄影" className="w-full h-auto object-cover group-hover:scale-105 transition-transform duration-state-change" />
|
||||||
|
</div>
|
||||||
|
<div className="px-gutter-xs flex flex-col gap-gutter-xs">
|
||||||
|
<h3 className="font-body text-body-md text-light-on-surface truncate">城市街头胶片漫步</h3>
|
||||||
|
<div className="flex items-center justify-between">
|
||||||
|
<button type="button" data-nav="profile" className="nav-switch flex items-center gap-gutter-xs min-w-0 hover:underline">
|
||||||
|
<img src="/stitch/chengdu.jpg" alt="胶片日志" className="w-4 h-4 rounded-full object-cover shrink-0" />
|
||||||
|
<span className="font-body text-body-sm text-light-on-surface-variant truncate">胶片日志</span>
|
||||||
|
</button>
|
||||||
|
<button type="button" className="like-btn inline-flex items-center gap-gutter-xs text-light-on-surface-variant hover:text-light-error shrink-0" data-liked="false" data-count="946" aria-label="点赞">
|
||||||
|
<span className="material-symbols-outlined text-body-md like-icon" aria-hidden="true">favorite_border</span>
|
||||||
|
<span className="font-body text-body-sm tabular-nums like-count">946</span>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</article>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* VIEW 2: USER PROFILE */}
|
||||||
|
<div id="view-profile" className="hidden flex-col">
|
||||||
|
{/* Sticky Top Profile Bar (Back Arrow returns to Home) */}
|
||||||
|
<header className="sticky top-0 z-20 bg-light-surface/95 border-b border-light-outline-variant px-gutter-lg py-gutter-sm flex items-center justify-between gap-gutter-md">
|
||||||
|
<div className="flex items-center gap-gutter-lg min-w-0">
|
||||||
|
<button type="button" data-nav="home" aria-label="返回首页" className="nav-switch inline-flex items-center justify-center w-9 h-9 rounded-full hover:bg-light-surface-container text-light-on-surface transition-colors duration-state-change shrink-0">
|
||||||
|
<span className="material-symbols-outlined text-headline-md" aria-hidden="true">arrow_back</span>
|
||||||
|
</button>
|
||||||
|
<div className="flex flex-col min-w-0">
|
||||||
|
<div className="flex items-center gap-gutter-xs">
|
||||||
|
<h1 className="font-headline text-headline-md text-light-on-surface truncate">有点AI思</h1>
|
||||||
|
<span className="material-symbols-outlined text-title-lg text-x-blue shrink-0" style={{ fontVariationSettings: "'FILL' 1" }} aria-label="已认证">verified</span>
|
||||||
|
</div>
|
||||||
|
<span className="font-body text-body-sm text-light-on-surface-variant tabular-nums">128 篇笔记</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div className="flex items-center gap-gutter-xs shrink-0">
|
||||||
|
<button type="button" aria-label="搜索TA的笔记" className="inline-flex items-center justify-center w-9 h-9 rounded-full hover:bg-light-surface-container text-light-on-surface transition-colors duration-state-change">
|
||||||
|
<span className="material-symbols-outlined text-headline-md" aria-hidden="true">search</span>
|
||||||
|
</button>
|
||||||
|
<button type="button" aria-label="Grok 总结主页" className="inline-flex items-center justify-center w-9 h-9 rounded-full hover:bg-light-surface-container text-light-on-surface transition-colors duration-state-change">
|
||||||
|
<span className="material-symbols-outlined text-headline-md" aria-hidden="true">blur_on</span>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</header>
|
||||||
|
|
||||||
|
{/* Cover Banner & Overlapping Avatar + Actions */}
|
||||||
|
<section aria-label="个人资料头部">
|
||||||
|
<div className="h-48 w-full overflow-hidden bg-light-surface-container">
|
||||||
|
<img src="/stitch/profile-banner.jpg" alt="个人主页背景封面" className="w-full h-full object-cover" />
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="px-gutter-lg pb-gutter-md flex flex-col gap-gutter-md">
|
||||||
|
<div className="flex items-end justify-between gap-gutter-md">
|
||||||
|
<div className="-mt-14 w-28 h-28 rounded-full border-4 border-light-surface overflow-hidden bg-light-surface shrink-0">
|
||||||
|
<img src="/stitch/profile-avatar.jpg" alt="有点AI思头像" className="w-full h-full object-cover" />
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="relative flex items-center gap-gutter-sm pt-gutter-sm">
|
||||||
|
<button id="profile-more-btn" type="button" aria-label="更多选项" aria-expanded="false" aria-haspopup="menu" className="inline-flex items-center justify-center w-9 h-9 rounded-full border border-light-outline bg-light-surface hover:bg-light-surface-container text-light-on-surface transition-colors duration-state-change">
|
||||||
|
<span className="material-symbols-outlined text-title-lg" aria-hidden="true">more_horiz</span>
|
||||||
|
</button>
|
||||||
|
|
||||||
|
<div id="profile-more-menu" role="menu" className="hidden absolute right-0 top-12 z-30 w-60 rounded-lg bg-light-surface border border-light-outline-variant shadow-lg py-gutter-xs">
|
||||||
|
<button id="open-about-btn" type="button" role="menuitem" className="w-full px-gutter-lg py-2.5 flex items-center gap-gutter-md text-left hover:bg-light-surface-container-low text-light-on-surface font-title text-title-md">
|
||||||
|
<span className="material-symbols-outlined text-title-lg text-light-on-surface" aria-hidden="true">info</span>
|
||||||
|
<span>About this account</span>
|
||||||
|
</button>
|
||||||
|
<button type="button" role="menuitem" className="w-full px-gutter-lg py-2.5 flex items-center gap-gutter-md text-left hover:bg-light-surface-container-low text-light-on-surface font-title text-title-md">
|
||||||
|
<span className="material-symbols-outlined text-title-lg text-light-on-surface" aria-hidden="true">chat_bubble_outline</span>
|
||||||
|
<span>View Topics</span>
|
||||||
|
</button>
|
||||||
|
<button type="button" role="menuitem" className="w-full px-gutter-lg py-2.5 flex items-center gap-gutter-md text-left hover:bg-light-surface-container-low text-light-on-surface font-title text-title-md">
|
||||||
|
<span className="material-symbols-outlined text-title-lg text-light-on-surface" aria-hidden="true">link</span>
|
||||||
|
<span>Copy link to profile</span>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<button type="button" aria-label="发送私信" className="inline-flex items-center justify-center w-9 h-9 rounded-full border border-light-outline bg-light-surface hover:bg-light-surface-container text-light-on-surface transition-colors duration-state-change">
|
||||||
|
<span className="material-symbols-outlined text-title-lg" aria-hidden="true">mail</span>
|
||||||
|
</button>
|
||||||
|
<button type="button" aria-label="开启更新提醒" className="inline-flex items-center justify-center w-9 h-9 rounded-full border border-light-outline bg-light-surface hover:bg-light-surface-container text-light-on-surface transition-colors duration-state-change">
|
||||||
|
<span className="material-symbols-outlined text-title-lg" aria-hidden="true">notifications_none</span>
|
||||||
|
</button>
|
||||||
|
<button id="profile-follow-btn" type="button" data-following="false" className="px-gutter-lg py-2 rounded-full bg-light-primary text-light-on-primary font-label text-label-md hover:opacity-90 transition-opacity duration-state-change whitespace-nowrap">
|
||||||
|
<span>Follow</span>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="flex flex-col gap-gutter-sm">
|
||||||
|
<div className="flex flex-col gap-gutter-xs">
|
||||||
|
<div className="flex items-center gap-gutter-xs">
|
||||||
|
<h2 className="font-headline text-headline-lg text-light-on-surface">有点AI思</h2>
|
||||||
|
<span className="material-symbols-outlined text-title-lg text-x-blue" style={{ fontVariationSettings: "'FILL' 1" }} aria-label="已认证">verified</span>
|
||||||
|
</div>
|
||||||
|
<div className="flex flex-wrap items-center gap-gutter-sm font-body text-body-sm text-light-on-surface-variant">
|
||||||
|
<span>@you_dian_ai</span>
|
||||||
|
<span aria-hidden="true">·</span>
|
||||||
|
<span className="tabular-nums">小红书号:18665824520</span>
|
||||||
|
<span aria-hidden="true">·</span>
|
||||||
|
<span>IP属地:四川</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<p className="font-body text-body-md text-light-on-surface max-w-prose text-pretty">
|
||||||
|
Software is eating the world, AI is eating software. 分享 AI 产品拆解、独立开发实验与数字生活灵感。
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<div className="flex flex-wrap items-center gap-gutter-lg font-body text-body-sm text-light-on-surface-variant">
|
||||||
|
<span className="inline-flex items-center gap-gutter-xs">
|
||||||
|
<span className="material-symbols-outlined text-title-md" aria-hidden="true">location_on</span>
|
||||||
|
<span>成都 · 四川</span>
|
||||||
|
</span>
|
||||||
|
<button id="joined-date-btn" type="button" className="inline-flex items-center gap-gutter-xs hover:underline text-light-on-surface-variant">
|
||||||
|
<span className="material-symbols-outlined text-title-md" aria-hidden="true">calendar_month</span>
|
||||||
|
<span>Joined April 2022</span>
|
||||||
|
<span className="material-symbols-outlined text-title-md" aria-hidden="true">chevron_right</span>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="flex flex-wrap items-center gap-gutter-lg pt-gutter-xs">
|
||||||
|
<span className="inline-flex items-baseline gap-gutter-xs">
|
||||||
|
<span className="font-title text-title-md text-light-on-surface tabular-nums">10</span>
|
||||||
|
<span className="font-body text-body-sm text-light-on-surface-variant">关注</span>
|
||||||
|
</span>
|
||||||
|
<span className="inline-flex items-baseline gap-gutter-xs">
|
||||||
|
<span className="font-title text-title-md text-light-on-surface tabular-nums">87</span>
|
||||||
|
<span className="font-body text-body-sm text-light-on-surface-variant">粉丝</span>
|
||||||
|
</span>
|
||||||
|
<span className="inline-flex items-baseline gap-gutter-xs">
|
||||||
|
<span className="font-title text-title-md text-light-on-surface tabular-nums">2,987</span>
|
||||||
|
<span className="font-body text-body-sm text-light-on-surface-variant">获赞与收藏</span>
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
{/* Profile Content Tabs */}
|
||||||
|
<div role="tablist" aria-label="个人主页内容分类" className="grid grid-cols-4 border-b border-light-outline-variant bg-light-surface sticky top-14 z-10">
|
||||||
|
<button role="tab" data-tab="notes" aria-selected="true" className="profile-tab relative py-gutter-md flex items-center justify-center font-title text-title-md text-light-on-surface hover:bg-light-surface-container-low transition-colors duration-state-change">
|
||||||
|
<span>笔记</span>
|
||||||
|
<span className="tab-indicator absolute bottom-0 w-12 h-1 rounded-full bg-x-blue"></span>
|
||||||
|
</button>
|
||||||
|
<button role="tab" data-tab="saved" aria-selected="false" className="profile-tab relative py-gutter-md flex items-center justify-center font-title text-title-md text-light-on-surface-variant hover:bg-light-surface-container-low transition-colors duration-state-change">
|
||||||
|
<span>收藏</span>
|
||||||
|
<span className="tab-indicator hidden absolute bottom-0 w-12 h-1 rounded-full bg-x-blue"></span>
|
||||||
|
</button>
|
||||||
|
<button role="tab" data-tab="likes" aria-selected="false" className="profile-tab relative py-gutter-md flex items-center justify-center font-title text-title-md text-light-on-surface-variant hover:bg-light-surface-container-low transition-colors duration-state-change">
|
||||||
|
<span>点赞</span>
|
||||||
|
<span className="tab-indicator hidden absolute bottom-0 w-12 h-1 rounded-full bg-x-blue"></span>
|
||||||
|
</button>
|
||||||
|
<button role="tab" data-tab="history" aria-selected="false" className="profile-tab relative py-gutter-md flex items-center justify-center font-title text-title-md text-light-on-surface-variant hover:bg-light-surface-container-low transition-colors duration-state-change">
|
||||||
|
<span>浏览记录</span>
|
||||||
|
<span className="tab-indicator hidden absolute bottom-0 w-16 h-1 rounded-full bg-x-blue"></span>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* Profile Panel: 笔记 */}
|
||||||
|
<section id="panel-notes" role="tabpanel" className="p-gutter-lg columns-2 lg:columns-3 gap-gutter-md space-y-gutter-md">
|
||||||
|
<article className="break-inside-avoid flex flex-col gap-gutter-sm group cursor-pointer">
|
||||||
|
<div className="relative overflow-hidden rounded-lg bg-light-surface-container-low border border-light-outline-variant">
|
||||||
|
<img src="/stitch/workspace.jpg" alt="彩色玻璃光影桌面" className="w-full h-auto object-cover group-hover:scale-105 transition-transform duration-state-change" />
|
||||||
|
<span className="absolute top-gutter-sm left-gutter-sm px-gutter-sm py-0.5 rounded-full bg-light-primary/75 text-light-on-primary font-label text-label-sm">置顶</span>
|
||||||
|
</div>
|
||||||
|
<div className="px-gutter-xs flex flex-col gap-gutter-xs">
|
||||||
|
<h3 className="font-title text-title-md text-light-on-surface truncate">午后光影里的工作台灵感</h3>
|
||||||
|
<div className="flex items-center justify-between pt-gutter-xs">
|
||||||
|
<div className="flex items-center gap-gutter-xs min-w-0">
|
||||||
|
<img src="/stitch/profile-avatar.jpg" alt="有点AI思" className="w-5 h-5 rounded-full object-cover shrink-0" />
|
||||||
|
<span className="font-body text-body-sm text-light-on-surface-variant truncate">有点AI思</span>
|
||||||
|
</div>
|
||||||
|
<button type="button" className="like-btn inline-flex items-center gap-gutter-xs text-light-error shrink-0" data-liked="true" data-count="842" aria-label="点赞">
|
||||||
|
<span className="material-symbols-outlined text-title-md like-icon" style={{ fontVariationSettings: "'FILL' 1" }} aria-hidden="true">favorite</span>
|
||||||
|
<span className="font-body text-body-sm tabular-nums like-count">842</span>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</article>
|
||||||
|
|
||||||
|
<article className="break-inside-avoid flex flex-col gap-gutter-sm group cursor-pointer">
|
||||||
|
<div className="relative overflow-hidden rounded-lg bg-light-surface-container-low border border-light-outline-variant p-gutter-md flex flex-col gap-gutter-sm">
|
||||||
|
<span className="font-title text-title-md text-light-on-surface">AI 编程助手实测对比</span>
|
||||||
|
<img src="/stitch/ai-tools.jpg" alt="AI 编程助手实测插画" className="w-full h-auto rounded-md object-cover" />
|
||||||
|
</div>
|
||||||
|
<div className="px-gutter-xs flex flex-col gap-gutter-xs">
|
||||||
|
<h3 className="font-title text-title-md text-light-on-surface truncate">2026 个人开发者工作流</h3>
|
||||||
|
<div className="flex items-center justify-between pt-gutter-xs">
|
||||||
|
<div className="flex items-center gap-gutter-xs min-w-0">
|
||||||
|
<img src="/stitch/profile-avatar.jpg" alt="有点AI思" className="w-5 h-5 rounded-full object-cover shrink-0" />
|
||||||
|
<span className="font-body text-body-sm text-light-on-surface-variant truncate">有点AI思</span>
|
||||||
|
</div>
|
||||||
|
<button type="button" className="like-btn inline-flex items-center gap-gutter-xs text-light-on-surface-variant hover:text-light-error shrink-0" data-liked="false" data-count="615" aria-label="点赞">
|
||||||
|
<span className="material-symbols-outlined text-title-md like-icon" aria-hidden="true">favorite_border</span>
|
||||||
|
<span className="font-body text-body-sm tabular-nums like-count">615</span>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</article>
|
||||||
|
|
||||||
|
<article className="break-inside-avoid flex flex-col gap-gutter-sm group cursor-pointer">
|
||||||
|
<div className="relative overflow-hidden rounded-lg bg-light-surface-container-low border border-light-outline-variant">
|
||||||
|
<img src="/stitch/rainy-harbor.jpg" alt="雨夜海港小镇体素场景" className="w-full h-auto object-cover group-hover:scale-105 transition-transform duration-state-change" />
|
||||||
|
<span className="absolute top-gutter-sm right-gutter-sm inline-flex items-center justify-center w-6 h-6 rounded-full bg-light-primary/70 text-light-on-primary">
|
||||||
|
<span className="material-symbols-outlined text-body-md" style={{ fontVariationSettings: "'FILL' 1" }} aria-hidden="true">play_arrow</span>
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<div className="px-gutter-xs flex flex-col gap-gutter-xs">
|
||||||
|
<h3 className="font-title text-title-md text-light-on-surface truncate">用体素引擎做海港微缩模型</h3>
|
||||||
|
<div className="flex items-center justify-between pt-gutter-xs">
|
||||||
|
<div className="flex items-center gap-gutter-xs min-w-0">
|
||||||
|
<img src="/stitch/profile-avatar.jpg" alt="有点AI思" className="w-5 h-5 rounded-full object-cover shrink-0" />
|
||||||
|
<span className="font-body text-body-sm text-light-on-surface-variant truncate">有点AI思</span>
|
||||||
|
</div>
|
||||||
|
<button type="button" className="like-btn inline-flex items-center gap-gutter-xs text-light-on-surface-variant hover:text-light-error shrink-0" data-liked="false" data-count="429" aria-label="点赞">
|
||||||
|
<span className="material-symbols-outlined text-title-md like-icon" aria-hidden="true">favorite_border</span>
|
||||||
|
<span className="font-body text-body-sm tabular-nums like-count">429</span>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</article>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
{/* Profile Panel: 收藏 */}
|
||||||
|
<section id="panel-saved" role="tabpanel" className="hidden p-gutter-lg columns-2 lg:columns-3 gap-gutter-md space-y-gutter-md">
|
||||||
|
<article className="break-inside-avoid flex flex-col gap-gutter-sm group cursor-pointer">
|
||||||
|
<div className="relative overflow-hidden rounded-lg bg-light-surface-container-low border border-light-outline-variant">
|
||||||
|
<img src="/stitch/stairs.jpg" alt="建筑楼梯光影摄影" className="w-full h-auto object-cover group-hover:scale-105 transition-transform duration-state-change" />
|
||||||
|
</div>
|
||||||
|
<div className="px-gutter-xs flex flex-col gap-gutter-xs">
|
||||||
|
<h3 className="font-title text-title-md text-light-on-surface truncate">极简楼梯光影构图参考</h3>
|
||||||
|
<div className="flex items-center justify-between pt-gutter-xs">
|
||||||
|
<div className="flex items-center gap-gutter-xs min-w-0">
|
||||||
|
<img src="/stitch/rainy-harbor.jpg" alt="建筑笔记" className="w-5 h-5 rounded-full object-cover shrink-0" />
|
||||||
|
<span className="font-body text-body-sm text-light-on-surface-variant truncate">建筑笔记</span>
|
||||||
|
</div>
|
||||||
|
<span className="font-body text-body-sm text-light-on-surface-variant tabular-nums">1.2K</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</article>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
{/* Profile Panel: 点赞 */}
|
||||||
|
<section id="panel-likes" role="tabpanel" className="hidden p-gutter-lg columns-2 lg:columns-3 gap-gutter-md space-y-gutter-md">
|
||||||
|
<article className="break-inside-avoid flex flex-col gap-gutter-sm group cursor-pointer">
|
||||||
|
<div className="relative overflow-hidden rounded-lg bg-light-surface-container-low border border-light-outline-variant">
|
||||||
|
<img src="/stitch/golden-retriever.jpg" alt="小金毛日常" className="w-full h-auto object-cover group-hover:scale-105 transition-transform duration-state-change" />
|
||||||
|
</div>
|
||||||
|
<div className="px-gutter-xs flex flex-col gap-gutter-xs">
|
||||||
|
<h3 className="font-title text-title-md text-light-on-surface truncate">家里新来的小金毛太粘人</h3>
|
||||||
|
<div className="flex items-center justify-between pt-gutter-xs">
|
||||||
|
<div className="flex items-center gap-gutter-xs min-w-0">
|
||||||
|
<img src="/stitch/golden-retriever.jpg" alt="单棱镜" className="w-5 h-5 rounded-full object-cover shrink-0" />
|
||||||
|
<span className="font-body text-body-sm text-light-on-surface-variant truncate">单棱镜</span>
|
||||||
|
</div>
|
||||||
|
<span className="font-body text-body-sm text-light-error tabular-nums">1,520</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</article>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
{/* Profile Panel: 浏览记录 */}
|
||||||
|
<section id="panel-history" role="tabpanel" className="hidden p-gutter-lg flex flex-col items-center justify-center gap-gutter-sm py-section text-center">
|
||||||
|
<span className="material-symbols-outlined text-headline-lg text-light-on-surface-variant" aria-hidden="true">history</span>
|
||||||
|
<p className="font-title text-title-md text-light-on-surface">仅自己可见</p>
|
||||||
|
<p className="font-body text-body-sm text-light-on-surface-variant max-w-prose">近期浏览的笔记记录会保存在这里,方便随时回看。</p>
|
||||||
|
</section>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</main>
|
||||||
|
|
||||||
|
{/* Right Discovery Sidebar (X Design: Visible md+, Hidden below 768px) */}
|
||||||
|
<aside className="hidden md:flex md:flex-col md:justify-between gap-gutter-lg w-72 xl:w-80 shrink-0 px-gutter-lg xl:px-gutter-xl py-gutter-md self-stretch">
|
||||||
|
<div className="flex flex-col gap-gutter-lg">
|
||||||
|
<div className="sticky top-0 pt-gutter-xs pb-gutter-xs bg-light-surface z-10">
|
||||||
|
<form role="search" className="flex items-center gap-gutter-sm px-gutter-lg py-2.5 rounded-full bg-light-surface border border-light-outline focus-within:border-light-tertiary">
|
||||||
|
<span className="material-symbols-outlined text-title-lg text-light-on-surface-variant" aria-hidden="true">search</span>
|
||||||
|
<input type="search" aria-label="Search X" placeholder="Search" className="w-full bg-transparent border-none p-0 font-body text-body-md text-light-on-surface placeholder:text-light-on-surface-variant focus:ring-0" />
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<section aria-label="Subscribe to Premium" className="rounded-lg border border-light-outline-variant p-gutter-lg flex flex-col gap-gutter-sm bg-light-surface">
|
||||||
|
<div className="flex items-center justify-between gap-gutter-xs">
|
||||||
|
<h2 className="font-headline text-title-lg text-light-on-surface whitespace-nowrap">Subscribe to Premium</h2>
|
||||||
|
<span className="px-gutter-sm py-0.5 rounded-full bg-light-primary-container text-light-on-primary-container font-label text-label-sm whitespace-nowrap shrink-0">50% off</span>
|
||||||
|
</div>
|
||||||
|
<p className="font-body text-body-md text-light-on-surface">Get rid of ads, see your analytics, boost your replies and unlock 20+ features.</p>
|
||||||
|
<div className="pt-gutter-xs">
|
||||||
|
<button type="button" className="px-gutter-lg py-2 rounded-full bg-light-tertiary text-light-on-tertiary font-label text-label-lg hover:opacity-90">
|
||||||
|
<span>Subscribe</span>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<section aria-label="You might like" className="rounded-lg border border-light-outline-variant p-gutter-lg flex flex-col gap-gutter-md bg-light-surface">
|
||||||
|
<h2 className="font-headline text-headline-md text-light-on-surface">You might like</h2>
|
||||||
|
<div className="flex items-center justify-between gap-gutter-sm">
|
||||||
|
<div className="flex items-center gap-gutter-md min-w-0">
|
||||||
|
<img src="/stitch/bbg-avatar.jpg" alt="Low Quality Memes" className="w-10 h-10 rounded-full object-cover shrink-0" />
|
||||||
|
<div className="flex flex-col min-w-0">
|
||||||
|
<span className="font-title text-title-md text-light-on-surface truncate">Low Quality Memes</span>
|
||||||
|
<span className="font-body text-body-sm text-light-on-surface-variant truncate">@ipostlqmemes</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<button type="button" className="follow-btn px-gutter-lg py-1.5 rounded-full bg-light-primary text-light-on-primary font-label text-label-md shrink-0" data-following="false">
|
||||||
|
<span>Follow</span>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
<div className="flex items-center justify-between gap-gutter-sm">
|
||||||
|
<div className="flex items-center gap-gutter-md min-w-0">
|
||||||
|
<img src="/stitch/ai-tools.jpg" alt="极客小分队" className="w-10 h-10 rounded-full object-cover shrink-0" />
|
||||||
|
<div className="flex flex-col min-w-0">
|
||||||
|
<span className="font-title text-title-md text-light-on-surface truncate">极客小分队</span>
|
||||||
|
<span className="font-body text-body-sm text-light-on-surface-variant truncate">@geek_squad_cn</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<button type="button" className="follow-btn px-gutter-lg py-1.5 rounded-full bg-light-primary text-light-on-primary font-label text-label-md shrink-0" data-following="false">
|
||||||
|
<span>Follow</span>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
<a href="#show-more-people" className="font-body text-body-md text-light-tertiary hover:underline">Show more</a>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<section aria-label="What's happening" className="rounded-lg border border-light-outline-variant p-gutter-lg flex flex-col gap-gutter-md bg-light-surface">
|
||||||
|
<h2 className="font-headline text-headline-md text-light-on-surface">What's happening</h2>
|
||||||
|
<div className="flex flex-col gap-gutter-md">
|
||||||
|
<div className="flex flex-col">
|
||||||
|
<span className="font-body text-body-sm text-light-on-surface-variant">Technology · Trending</span>
|
||||||
|
<span className="font-title text-title-md text-light-on-surface">#AICoding2026</span>
|
||||||
|
</div>
|
||||||
|
<div className="flex flex-col">
|
||||||
|
<span className="font-body text-body-sm text-light-on-surface-variant">Design · Trending</span>
|
||||||
|
<span className="font-title text-title-md text-light-on-surface">小红书瀑布流</span>
|
||||||
|
</div>
|
||||||
|
<a href="#show-more" className="font-body text-body-md text-light-tertiary hover:underline">Show more</a>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<footer className="pt-gutter-md pb-gutter-sm flex flex-wrap gap-x-gutter-md gap-y-gutter-xs font-body text-body-sm text-light-on-surface-variant">
|
||||||
|
<a href="#terms" className="hover:underline">Terms of Service</a>
|
||||||
|
<a href="#privacy" className="hover:underline">Privacy Policy</a>
|
||||||
|
<a href="#cookies" className="hover:underline">Cookie Policy</a>
|
||||||
|
<span>© 2026 X Corp.</span>
|
||||||
|
</footer>
|
||||||
|
</aside>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* About This Account Modal */}
|
||||||
|
<div id="about-modal" role="dialog" aria-modal="true" aria-labelledby="about-modal-title" className="hidden fixed inset-0 z-40 bg-light-primary/50 flex items-center justify-center p-gutter-lg">
|
||||||
|
<div className="w-full max-w-md rounded-xl bg-light-surface border border-light-outline-variant shadow-xl p-gutter-xl flex flex-col gap-gutter-lg">
|
||||||
|
<div className="flex items-center justify-between">
|
||||||
|
<h2 id="about-modal-title" className="font-headline text-headline-md text-light-on-surface">About this account</h2>
|
||||||
|
<button id="close-about-btn" type="button" aria-label="关闭弹窗" className="inline-flex items-center justify-center w-8 h-8 rounded-full hover:bg-light-surface-container text-light-on-surface">
|
||||||
|
<span className="material-symbols-outlined text-title-lg" aria-hidden="true">close</span>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
<div className="flex items-center gap-gutter-md">
|
||||||
|
<img src="/stitch/profile-avatar.jpg" alt="有点AI思" className="w-12 h-12 rounded-full object-cover shrink-0" />
|
||||||
|
<div className="flex flex-col">
|
||||||
|
<span className="font-title text-title-lg text-light-on-surface">有点AI思</span>
|
||||||
|
<span className="font-body text-body-sm text-light-on-surface-variant">@you_dian_ai · 小红书号 18665824520</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div className="flex flex-col gap-gutter-md border-t border-light-outline-variant pt-gutter-md">
|
||||||
|
<div className="flex items-center gap-gutter-md">
|
||||||
|
<span className="material-symbols-outlined text-title-lg text-light-on-surface-variant" aria-hidden="true">calendar_month</span>
|
||||||
|
<div className="flex flex-col">
|
||||||
|
<span className="font-title text-title-md text-light-on-surface">Date joined</span>
|
||||||
|
<span className="font-body text-body-sm text-light-on-surface-variant">April 2022</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div className="flex items-center gap-gutter-md">
|
||||||
|
<span className="material-symbols-outlined text-title-lg text-light-on-surface-variant" aria-hidden="true">public</span>
|
||||||
|
<div className="flex flex-col">
|
||||||
|
<span className="font-title text-title-md text-light-on-surface">Account based in</span>
|
||||||
|
<span className="font-body text-body-sm text-light-on-surface-variant">Sichuan, China (IP属地:四川)</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div className="flex items-center gap-gutter-md">
|
||||||
|
<span className="material-symbols-outlined text-title-lg text-x-blue" style={{ fontVariationSettings: "'FILL' 1" }} aria-hidden="true">verified</span>
|
||||||
|
<div className="flex flex-col">
|
||||||
|
<span className="font-title text-title-md text-light-on-surface">Verified</span>
|
||||||
|
<span className="font-body text-body-sm text-light-on-surface-variant">Subscribed since March 2024</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* Floating Bottom-Right Dock */}
|
||||||
|
<div className="hidden md:flex fixed bottom-gutter-lg right-gutter-lg z-30 flex-col gap-gutter-sm">
|
||||||
|
<button type="button" aria-label="Open Grok" className="inline-flex items-center justify-center w-11 h-11 rounded-md bg-light-surface border border-light-outline shadow-sm text-light-on-surface hover:bg-light-surface-container-low">
|
||||||
|
<span className="material-symbols-outlined text-headline-md" aria-hidden="true">blur_on</span>
|
||||||
|
</button>
|
||||||
|
<button type="button" aria-label="Open Messages" className="inline-flex items-center justify-center w-11 h-11 rounded-md bg-light-surface border border-light-outline shadow-sm text-light-on-surface hover:bg-light-surface-container-low">
|
||||||
|
<span className="material-symbols-outlined text-headline-md" aria-hidden="true">mail</span>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -0,0 +1,159 @@
|
|||||||
|
"use client";
|
||||||
|
|
||||||
|
import { useEffect } from "react";
|
||||||
|
|
||||||
|
function selectTab(button: HTMLElement, selector: string) {
|
||||||
|
document.querySelectorAll<HTMLElement>(selector).forEach((tab) => {
|
||||||
|
const active = tab === button;
|
||||||
|
tab.setAttribute("aria-selected", String(active));
|
||||||
|
tab.classList.toggle("text-light-on-surface", active);
|
||||||
|
tab.classList.toggle("text-light-on-surface-variant", !active);
|
||||||
|
tab.querySelector(".tab-indicator")?.classList.toggle("hidden", !active);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
export function HomeInteractions() {
|
||||||
|
useEffect(() => {
|
||||||
|
const byId = (id: string) => document.getElementById(id);
|
||||||
|
const home = byId("view-home");
|
||||||
|
const profile = byId("view-profile");
|
||||||
|
const menu = byId("profile-more-menu");
|
||||||
|
const menuButton = byId("profile-more-btn");
|
||||||
|
const dialog = byId("about-modal");
|
||||||
|
let feed = "for-you";
|
||||||
|
let category = "all";
|
||||||
|
|
||||||
|
function switchView(view: string) {
|
||||||
|
const homeActive = view === "home";
|
||||||
|
home?.classList.toggle("hidden", !homeActive);
|
||||||
|
home?.classList.toggle("flex", homeActive);
|
||||||
|
profile?.classList.toggle("hidden", homeActive);
|
||||||
|
profile?.classList.toggle("flex", !homeActive);
|
||||||
|
|
||||||
|
document.querySelectorAll<HTMLElement>(".nav-item").forEach((item) => {
|
||||||
|
const active = item.dataset.nav === view;
|
||||||
|
if (active) item.setAttribute("aria-current", "page");
|
||||||
|
else item.removeAttribute("aria-current");
|
||||||
|
item.classList.toggle("font-title", active);
|
||||||
|
item.classList.toggle("font-body", !active);
|
||||||
|
const icon = item.querySelector<HTMLElement>(".nav-icon");
|
||||||
|
if (icon) {
|
||||||
|
icon.textContent = item.dataset.nav === "home" ? "home" : active ? "person" : "person_outline";
|
||||||
|
icon.style.fontVariationSettings = active ? "'FILL' 1" : "'FILL' 0";
|
||||||
|
}
|
||||||
|
});
|
||||||
|
window.scrollTo({ top: 0, behavior: "smooth" });
|
||||||
|
}
|
||||||
|
|
||||||
|
function updateCards() {
|
||||||
|
document.querySelectorAll<HTMLElement>("#home-note-feed .note-card").forEach((card) => {
|
||||||
|
const categoryMatches = category === "all" || card.dataset.category === category;
|
||||||
|
const feedMatches = feed === "for-you" || card.dataset.following === "true";
|
||||||
|
card.style.display = categoryMatches && feedMatches ? "" : "none";
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function changeChannel(button: HTMLElement) {
|
||||||
|
category = button.dataset.category ?? "all";
|
||||||
|
document.querySelectorAll(".channel-pill").forEach((pill) => {
|
||||||
|
const active = pill === button;
|
||||||
|
pill.setAttribute("aria-selected", String(active));
|
||||||
|
pill.classList.toggle("bg-light-primary", active);
|
||||||
|
pill.classList.toggle("text-light-on-primary", active);
|
||||||
|
pill.classList.toggle("bg-light-surface-container", !active);
|
||||||
|
pill.classList.toggle("text-light-on-surface-variant", !active);
|
||||||
|
});
|
||||||
|
updateCards();
|
||||||
|
}
|
||||||
|
|
||||||
|
function toggleFollow(button: HTMLElement) {
|
||||||
|
const following = button.dataset.following !== "true";
|
||||||
|
button.dataset.following = String(following);
|
||||||
|
for (const name of ["border", "border-light-outline", "bg-light-surface", "text-light-on-surface"]) {
|
||||||
|
button.classList.toggle(name, following);
|
||||||
|
}
|
||||||
|
for (const name of ["bg-light-primary", "text-light-on-primary"]) {
|
||||||
|
button.classList.toggle(name, !following);
|
||||||
|
}
|
||||||
|
const label = button.querySelector("span");
|
||||||
|
if (label) label.textContent = following ? "Following" : "Follow";
|
||||||
|
}
|
||||||
|
|
||||||
|
function toggleLike(button: HTMLElement) {
|
||||||
|
const liked = button.dataset.liked !== "true";
|
||||||
|
const count = Math.max(0, Number(button.dataset.count ?? "0") + (liked ? 1 : -1));
|
||||||
|
button.dataset.liked = String(liked);
|
||||||
|
button.dataset.count = String(count);
|
||||||
|
button.setAttribute("aria-pressed", String(liked));
|
||||||
|
button.classList.toggle("text-light-error", liked);
|
||||||
|
button.classList.toggle("text-light-on-surface-variant", !liked);
|
||||||
|
const icon = button.querySelector<HTMLElement>(".like-icon");
|
||||||
|
if (icon) {
|
||||||
|
icon.textContent = liked ? "favorite" : "favorite_border";
|
||||||
|
icon.style.fontVariationSettings = liked ? "'FILL' 1" : "'FILL' 0";
|
||||||
|
}
|
||||||
|
const countLabel = button.querySelector(".like-count");
|
||||||
|
if (countLabel) countLabel.textContent = String(count);
|
||||||
|
}
|
||||||
|
|
||||||
|
function setMenu(open: boolean) {
|
||||||
|
menu?.classList.toggle("hidden", !open);
|
||||||
|
menuButton?.setAttribute("aria-expanded", String(open));
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleClick(event: MouseEvent) {
|
||||||
|
const target = event.target;
|
||||||
|
if (!(target instanceof Element)) return;
|
||||||
|
const button = target.closest<HTMLElement>("button");
|
||||||
|
|
||||||
|
if (button === menuButton && menu) {
|
||||||
|
setMenu(menu.classList.contains("hidden"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!menu?.contains(target)) setMenu(false);
|
||||||
|
if (target === dialog || button?.id === "close-about-btn") {
|
||||||
|
dialog?.classList.add("hidden");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!button) return;
|
||||||
|
|
||||||
|
if (button.matches(".nav-switch") && button.dataset.nav) {
|
||||||
|
switchView(button.dataset.nav);
|
||||||
|
} else if (button.matches(".feed-tab")) {
|
||||||
|
feed = button.dataset.feed ?? "for-you";
|
||||||
|
selectTab(button, ".feed-tab");
|
||||||
|
updateCards();
|
||||||
|
} else if (button.matches(".channel-pill")) {
|
||||||
|
changeChannel(button);
|
||||||
|
} else if (button.matches(".profile-tab")) {
|
||||||
|
selectTab(button, ".profile-tab");
|
||||||
|
for (const panel of ["notes", "saved", "likes", "history"]) {
|
||||||
|
byId("panel-" + panel)?.classList.toggle("hidden", panel !== button.dataset.tab);
|
||||||
|
}
|
||||||
|
} else if (button.id === "profile-follow-btn") {
|
||||||
|
toggleFollow(button);
|
||||||
|
} else if (button.matches(".like-btn")) {
|
||||||
|
toggleLike(button);
|
||||||
|
} else if (button.id === "open-about-btn" || button.id === "joined-date-btn") {
|
||||||
|
setMenu(false);
|
||||||
|
dialog?.classList.remove("hidden");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleKey(event: KeyboardEvent) {
|
||||||
|
if (event.key === "Escape") {
|
||||||
|
setMenu(false);
|
||||||
|
dialog?.classList.add("hidden");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
document.addEventListener("click", handleClick);
|
||||||
|
document.addEventListener("keydown", handleKey);
|
||||||
|
return () => {
|
||||||
|
document.removeEventListener("click", handleClick);
|
||||||
|
document.removeEventListener("keydown", handleKey);
|
||||||
|
};
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
import type { NextConfig } from "next";
|
||||||
|
|
||||||
|
const config: NextConfig = {
|
||||||
|
agentRules: false,
|
||||||
|
devIndicators: false,
|
||||||
|
};
|
||||||
|
|
||||||
|
export default config;
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
{
|
||||||
|
"name": "@bedrock/home",
|
||||||
|
"private": true,
|
||||||
|
"scripts": {
|
||||||
|
"dev": "next dev --hostname 127.0.0.1 --port 3000",
|
||||||
|
"build": "next build",
|
||||||
|
"start": "next start --hostname 127.0.0.1 --port 3000"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"next": "16.4.6",
|
||||||
|
"react": "19.3.1",
|
||||||
|
"react-dom": "19.3.1"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@types/node": "22.20.7",
|
||||||
|
"@types/react": "19.3.0",
|
||||||
|
"@types/react-dom": "19.3.0",
|
||||||
|
"typescript": "5.9.3",
|
||||||
|
"@tailwindcss/container-queries": "0.1.1",
|
||||||
|
"@tailwindcss/forms": "0.5.10",
|
||||||
|
"autoprefixer": "10.4.21",
|
||||||
|
"postcss": "8.5.34",
|
||||||
|
"tailwindcss": "3.4.17"
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
export default {
|
||||||
|
plugins: {
|
||||||
|
tailwindcss: {},
|
||||||
|
autoprefixer: {},
|
||||||
|
},
|
||||||
|
};
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
Five original design images were embedded in the shared Stitch screen.
|
||||||
|
The following Unsplash photos are sample content used under the Unsplash License
|
||||||
|
https://unsplash.com/license
|
||||||
|
|
||||||
|
golden-retriever.jpg https://unsplash.com/photos/brown-dog-m07bsa3nG_4
|
||||||
|
dungeon.jpg https://unsplash.com/photos/a-group-of-people-playing-video-games-in-a-room-TobedMw621U
|
||||||
|
ai-tools.jpg https://unsplash.com/photos/a-laptop-computer-sitting-on-top-of-a-desk-ysZnFnexwRE
|
||||||
|
skyline.jpg https://unsplash.com/photos/a-view-of-a-city-at-night-from-the-top-of-a-building-xuNtZ_hEAhY
|
||||||
|
workspace.jpg https://unsplash.com/s/photos/writers-desk
|
||||||
|
film-walk.jpg https://unsplash.com/photos/a-group-of-people-walking-across-a-cross-walk-yCFKOJ5-F6U
|
||||||
|
profile-banner.jpg https://unsplash.com/photos/a-view-of-a-city-with-mountains-in-the-background-mxWViyBwOBM
|
||||||
|
stairs.jpg https://unsplash.com/photos/shadow-and-sunlight-cast-upon-a-concrete-staircase-xDV6YuFBkAo
|
||||||
|
After Width: | Height: | Size: 49 KiB |
|
After Width: | Height: | Size: 2.9 KiB |
|
After Width: | Height: | Size: 315 KiB |
|
After Width: | Height: | Size: 82 KiB |
|
After Width: | Height: | Size: 171 KiB |
|
After Width: | Height: | Size: 74 KiB |
|
After Width: | Height: | Size: 76 KiB |
@@ -0,0 +1,93 @@
|
|||||||
|
Copyright 2022 The Instrument Sans Project Authors (https://github.com/Instrument/instrument-sans)
|
||||||
|
|
||||||
|
This Font Software is licensed under the SIL Open Font License, Version 1.1.
|
||||||
|
This license is copied below, and is also available with a FAQ at:
|
||||||
|
https://scripts.sil.org/OFL
|
||||||
|
|
||||||
|
|
||||||
|
-----------------------------------------------------------
|
||||||
|
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
|
||||||
|
-----------------------------------------------------------
|
||||||
|
|
||||||
|
PREAMBLE
|
||||||
|
The goals of the Open Font License (OFL) are to stimulate worldwide
|
||||||
|
development of collaborative font projects, to support the font creation
|
||||||
|
efforts of academic and linguistic communities, and to provide a free and
|
||||||
|
open framework in which fonts may be shared and improved in partnership
|
||||||
|
with others.
|
||||||
|
|
||||||
|
The OFL allows the licensed fonts to be used, studied, modified and
|
||||||
|
redistributed freely as long as they are not sold by themselves. The
|
||||||
|
fonts, including any derivative works, can be bundled, embedded,
|
||||||
|
redistributed and/or sold with any software provided that any reserved
|
||||||
|
names are not used by derivative works. The fonts and derivatives,
|
||||||
|
however, cannot be released under any other type of license. The
|
||||||
|
requirement for fonts to remain under this license does not apply
|
||||||
|
to any document created using the fonts or their derivatives.
|
||||||
|
|
||||||
|
DEFINITIONS
|
||||||
|
"Font Software" refers to the set of files released by the Copyright
|
||||||
|
Holder(s) under this license and clearly marked as such. This may
|
||||||
|
include source files, build scripts and documentation.
|
||||||
|
|
||||||
|
"Reserved Font Name" refers to any names specified as such after the
|
||||||
|
copyright statement(s).
|
||||||
|
|
||||||
|
"Original Version" refers to the collection of Font Software components as
|
||||||
|
distributed by the Copyright Holder(s).
|
||||||
|
|
||||||
|
"Modified Version" refers to any derivative made by adding to, deleting,
|
||||||
|
or substituting -- in part or in whole -- any of the components of the
|
||||||
|
Original Version, by changing formats or by porting the Font Software to a
|
||||||
|
new environment.
|
||||||
|
|
||||||
|
"Author" refers to any designer, engineer, programmer, technical
|
||||||
|
writer or other person who contributed to the Font Software.
|
||||||
|
|
||||||
|
PERMISSION & CONDITIONS
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining
|
||||||
|
a copy of the Font Software, to use, study, copy, merge, embed, modify,
|
||||||
|
redistribute, and sell modified and unmodified copies of the Font
|
||||||
|
Software, subject to the following conditions:
|
||||||
|
|
||||||
|
1) Neither the Font Software nor any of its individual components,
|
||||||
|
in Original or Modified Versions, may be sold by itself.
|
||||||
|
|
||||||
|
2) Original or Modified Versions of the Font Software may be bundled,
|
||||||
|
redistributed and/or sold with any software, provided that each copy
|
||||||
|
contains the above copyright notice and this license. These can be
|
||||||
|
included either as stand-alone text files, human-readable headers or
|
||||||
|
in the appropriate machine-readable metadata fields within text or
|
||||||
|
binary files as long as those fields can be easily viewed by the user.
|
||||||
|
|
||||||
|
3) No Modified Version of the Font Software may use the Reserved Font
|
||||||
|
Name(s) unless explicit written permission is granted by the corresponding
|
||||||
|
Copyright Holder. This restriction only applies to the primary font name as
|
||||||
|
presented to the users.
|
||||||
|
|
||||||
|
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
|
||||||
|
Software shall not be used to promote, endorse or advertise any
|
||||||
|
Modified Version, except to acknowledge the contribution(s) of the
|
||||||
|
Copyright Holder(s) and the Author(s) or with their explicit written
|
||||||
|
permission.
|
||||||
|
|
||||||
|
5) The Font Software, modified or unmodified, in part or in whole,
|
||||||
|
must be distributed entirely under this license, and must not be
|
||||||
|
distributed under any other license. The requirement for fonts to
|
||||||
|
remain under this license does not apply to any document created
|
||||||
|
using the Font Software.
|
||||||
|
|
||||||
|
TERMINATION
|
||||||
|
This license becomes null and void if any of the above conditions are
|
||||||
|
not met.
|
||||||
|
|
||||||
|
DISCLAIMER
|
||||||
|
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
|
||||||
|
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
|
||||||
|
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
|
||||||
|
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||||
|
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
|
||||||
|
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||||
|
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
|
||||||
|
OTHER DEALINGS IN THE FONT SOFTWARE.
|
||||||
@@ -0,0 +1,202 @@
|
|||||||
|
|
||||||
|
Apache License
|
||||||
|
Version 2.0, January 2004
|
||||||
|
http://www.apache.org/licenses/
|
||||||
|
|
||||||
|
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||||
|
|
||||||
|
1. Definitions.
|
||||||
|
|
||||||
|
"License" shall mean the terms and conditions for use, reproduction,
|
||||||
|
and distribution as defined by Sections 1 through 9 of this document.
|
||||||
|
|
||||||
|
"Licensor" shall mean the copyright owner or entity authorized by
|
||||||
|
the copyright owner that is granting the License.
|
||||||
|
|
||||||
|
"Legal Entity" shall mean the union of the acting entity and all
|
||||||
|
other entities that control, are controlled by, or are under common
|
||||||
|
control with that entity. For the purposes of this definition,
|
||||||
|
"control" means (i) the power, direct or indirect, to cause the
|
||||||
|
direction or management of such entity, whether by contract or
|
||||||
|
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||||
|
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||||
|
|
||||||
|
"You" (or "Your") shall mean an individual or Legal Entity
|
||||||
|
exercising permissions granted by this License.
|
||||||
|
|
||||||
|
"Source" form shall mean the preferred form for making modifications,
|
||||||
|
including but not limited to software source code, documentation
|
||||||
|
source, and configuration files.
|
||||||
|
|
||||||
|
"Object" form shall mean any form resulting from mechanical
|
||||||
|
transformation or translation of a Source form, including but
|
||||||
|
not limited to compiled object code, generated documentation,
|
||||||
|
and conversions to other media types.
|
||||||
|
|
||||||
|
"Work" shall mean the work of authorship, whether in Source or
|
||||||
|
Object form, made available under the License, as indicated by a
|
||||||
|
copyright notice that is included in or attached to the work
|
||||||
|
(an example is provided in the Appendix below).
|
||||||
|
|
||||||
|
"Derivative Works" shall mean any work, whether in Source or Object
|
||||||
|
form, that is based on (or derived from) the Work and for which the
|
||||||
|
editorial revisions, annotations, elaborations, or other modifications
|
||||||
|
represent, as a whole, an original work of authorship. For the purposes
|
||||||
|
of this License, Derivative Works shall not include works that remain
|
||||||
|
separable from, or merely link (or bind by name) to the interfaces of,
|
||||||
|
the Work and Derivative Works thereof.
|
||||||
|
|
||||||
|
"Contribution" shall mean any work of authorship, including
|
||||||
|
the original version of the Work and any modifications or additions
|
||||||
|
to that Work or Derivative Works thereof, that is intentionally
|
||||||
|
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||||
|
or by an individual or Legal Entity authorized to submit on behalf of
|
||||||
|
the copyright owner. For the purposes of this definition, "submitted"
|
||||||
|
means any form of electronic, verbal, or written communication sent
|
||||||
|
to the Licensor or its representatives, including but not limited to
|
||||||
|
communication on electronic mailing lists, source code control systems,
|
||||||
|
and issue tracking systems that are managed by, or on behalf of, the
|
||||||
|
Licensor for the purpose of discussing and improving the Work, but
|
||||||
|
excluding communication that is conspicuously marked or otherwise
|
||||||
|
designated in writing by the copyright owner as "Not a Contribution."
|
||||||
|
|
||||||
|
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||||
|
on behalf of whom a Contribution has been received by Licensor and
|
||||||
|
subsequently incorporated within the Work.
|
||||||
|
|
||||||
|
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||||
|
this License, each Contributor hereby grants to You a perpetual,
|
||||||
|
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||||
|
copyright license to reproduce, prepare Derivative Works of,
|
||||||
|
publicly display, publicly perform, sublicense, and distribute the
|
||||||
|
Work and such Derivative Works in Source or Object form.
|
||||||
|
|
||||||
|
3. Grant of Patent License. Subject to the terms and conditions of
|
||||||
|
this License, each Contributor hereby grants to You a perpetual,
|
||||||
|
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||||
|
(except as stated in this section) patent license to make, have made,
|
||||||
|
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||||
|
where such license applies only to those patent claims licensable
|
||||||
|
by such Contributor that are necessarily infringed by their
|
||||||
|
Contribution(s) alone or by combination of their Contribution(s)
|
||||||
|
with the Work to which such Contribution(s) was submitted. If You
|
||||||
|
institute patent litigation against any entity (including a
|
||||||
|
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||||
|
or a Contribution incorporated within the Work constitutes direct
|
||||||
|
or contributory patent infringement, then any patent licenses
|
||||||
|
granted to You under this License for that Work shall terminate
|
||||||
|
as of the date such litigation is filed.
|
||||||
|
|
||||||
|
4. Redistribution. You may reproduce and distribute copies of the
|
||||||
|
Work or Derivative Works thereof in any medium, with or without
|
||||||
|
modifications, and in Source or Object form, provided that You
|
||||||
|
meet the following conditions:
|
||||||
|
|
||||||
|
(a) You must give any other recipients of the Work or
|
||||||
|
Derivative Works a copy of this License; and
|
||||||
|
|
||||||
|
(b) You must cause any modified files to carry prominent notices
|
||||||
|
stating that You changed the files; and
|
||||||
|
|
||||||
|
(c) You must retain, in the Source form of any Derivative Works
|
||||||
|
that You distribute, all copyright, patent, trademark, and
|
||||||
|
attribution notices from the Source form of the Work,
|
||||||
|
excluding those notices that do not pertain to any part of
|
||||||
|
the Derivative Works; and
|
||||||
|
|
||||||
|
(d) If the Work includes a "NOTICE" text file as part of its
|
||||||
|
distribution, then any Derivative Works that You distribute must
|
||||||
|
include a readable copy of the attribution notices contained
|
||||||
|
within such NOTICE file, excluding those notices that do not
|
||||||
|
pertain to any part of the Derivative Works, in at least one
|
||||||
|
of the following places: within a NOTICE text file distributed
|
||||||
|
as part of the Derivative Works; within the Source form or
|
||||||
|
documentation, if provided along with the Derivative Works; or,
|
||||||
|
within a display generated by the Derivative Works, if and
|
||||||
|
wherever such third-party notices normally appear. The contents
|
||||||
|
of the NOTICE file are for informational purposes only and
|
||||||
|
do not modify the License. You may add Your own attribution
|
||||||
|
notices within Derivative Works that You distribute, alongside
|
||||||
|
or as an addendum to the NOTICE text from the Work, provided
|
||||||
|
that such additional attribution notices cannot be construed
|
||||||
|
as modifying the License.
|
||||||
|
|
||||||
|
You may add Your own copyright statement to Your modifications and
|
||||||
|
may provide additional or different license terms and conditions
|
||||||
|
for use, reproduction, or distribution of Your modifications, or
|
||||||
|
for any such Derivative Works as a whole, provided Your use,
|
||||||
|
reproduction, and distribution of the Work otherwise complies with
|
||||||
|
the conditions stated in this License.
|
||||||
|
|
||||||
|
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||||
|
any Contribution intentionally submitted for inclusion in the Work
|
||||||
|
by You to the Licensor shall be under the terms and conditions of
|
||||||
|
this License, without any additional terms or conditions.
|
||||||
|
Notwithstanding the above, nothing herein shall supersede or modify
|
||||||
|
the terms of any separate license agreement you may have executed
|
||||||
|
with Licensor regarding such Contributions.
|
||||||
|
|
||||||
|
6. Trademarks. This License does not grant permission to use the trade
|
||||||
|
names, trademarks, service marks, or product names of the Licensor,
|
||||||
|
except as required for reasonable and customary use in describing the
|
||||||
|
origin of the Work and reproducing the content of the NOTICE file.
|
||||||
|
|
||||||
|
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||||
|
agreed to in writing, Licensor provides the Work (and each
|
||||||
|
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||||
|
implied, including, without limitation, any warranties or conditions
|
||||||
|
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||||
|
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||||
|
appropriateness of using or redistributing the Work and assume any
|
||||||
|
risks associated with Your exercise of permissions under this License.
|
||||||
|
|
||||||
|
8. Limitation of Liability. In no event and under no legal theory,
|
||||||
|
whether in tort (including negligence), contract, or otherwise,
|
||||||
|
unless required by applicable law (such as deliberate and grossly
|
||||||
|
negligent acts) or agreed to in writing, shall any Contributor be
|
||||||
|
liable to You for damages, including any direct, indirect, special,
|
||||||
|
incidental, or consequential damages of any character arising as a
|
||||||
|
result of this License or out of the use or inability to use the
|
||||||
|
Work (including but not limited to damages for loss of goodwill,
|
||||||
|
work stoppage, computer failure or malfunction, or any and all
|
||||||
|
other commercial damages or losses), even if such Contributor
|
||||||
|
has been advised of the possibility of such damages.
|
||||||
|
|
||||||
|
9. Accepting Warranty or Additional Liability. While redistributing
|
||||||
|
the Work or Derivative Works thereof, You may choose to offer,
|
||||||
|
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||||
|
or other liability obligations and/or rights consistent with this
|
||||||
|
License. However, in accepting such obligations, You may act only
|
||||||
|
on Your own behalf and on Your sole responsibility, not on behalf
|
||||||
|
of any other Contributor, and only if You agree to indemnify,
|
||||||
|
defend, and hold each Contributor harmless for any liability
|
||||||
|
incurred by, or claims asserted against, such Contributor by reason
|
||||||
|
of your accepting any such warranty or additional liability.
|
||||||
|
|
||||||
|
END OF TERMS AND CONDITIONS
|
||||||
|
|
||||||
|
APPENDIX: How to apply the Apache License to your work.
|
||||||
|
|
||||||
|
To apply the Apache License to your work, attach the following
|
||||||
|
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||||
|
replaced with your own identifying information. (Don't include
|
||||||
|
the brackets!) The text should be enclosed in the appropriate
|
||||||
|
comment syntax for the file format. We also recommend that a
|
||||||
|
file or class name and description of purpose be included on the
|
||||||
|
same "printed page" as the copyright notice for easier
|
||||||
|
identification within third-party archives.
|
||||||
|
|
||||||
|
Copyright [yyyy] [name of copyright owner]
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
After Width: | Height: | Size: 5.0 KiB |
|
After Width: | Height: | Size: 137 KiB |
|
After Width: | Height: | Size: 179 KiB |
|
After Width: | Height: | Size: 61 KiB |
|
After Width: | Height: | Size: 75 KiB |
|
After Width: | Height: | Size: 93 KiB |
@@ -0,0 +1,93 @@
|
|||||||
|
const forms = require("@tailwindcss/forms");
|
||||||
|
const containerQueries = require("@tailwindcss/container-queries");
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
content: { relative: true, files: ["./app/**/*.tsx", "./components/**/*.{ts,tsx}"] },
|
||||||
|
plugins: [forms, containerQueries],
|
||||||
|
...{
|
||||||
|
darkMode: 'class',
|
||||||
|
theme: {
|
||||||
|
extend: {
|
||||||
|
colors: {
|
||||||
|
'x-blue': '#1D9BF0',
|
||||||
|
'x-blue-dark': '#0B7BC1',
|
||||||
|
'light-primary': '#0F1419',
|
||||||
|
'light-on-primary': '#FFFFFF',
|
||||||
|
'light-primary-container': '#E8F5FD',
|
||||||
|
'light-on-primary-container': '#0A74B7',
|
||||||
|
'light-secondary': '#536471',
|
||||||
|
'light-on-secondary': '#FFFFFF',
|
||||||
|
'light-secondary-container': '#EFF3F4',
|
||||||
|
'light-on-secondary-container': '#0F1419',
|
||||||
|
'light-tertiary': '#0B7BC1',
|
||||||
|
'light-on-tertiary': '#FFFFFF',
|
||||||
|
'light-error': '#F4212E',
|
||||||
|
'light-on-error': '#131313',
|
||||||
|
'light-background': '#FFFFFF',
|
||||||
|
'light-on-background': '#0F1419',
|
||||||
|
'light-surface': '#FFFFFF',
|
||||||
|
'light-surface-container-low': '#F7F9F9',
|
||||||
|
'light-surface-container': '#EFF3F4',
|
||||||
|
'light-surface-container-high': '#E7E9EA',
|
||||||
|
'light-on-surface': '#0F1419',
|
||||||
|
'light-on-surface-variant': '#536471',
|
||||||
|
'light-outline': '#CFD9DE',
|
||||||
|
'light-outline-variant': '#EFF3F4',
|
||||||
|
'dark-primary': '#EFF3F4',
|
||||||
|
'dark-on-primary': '#0F1419',
|
||||||
|
'dark-surface': '#000000',
|
||||||
|
'dark-surface-container-low': '#16181C',
|
||||||
|
'dark-surface-container': '#202327',
|
||||||
|
'dark-on-surface': '#E7E9EA',
|
||||||
|
'dark-on-surface-variant': '#71767B',
|
||||||
|
'dark-outline': '#2F3336',
|
||||||
|
'dark-outline-variant': '#2F3336',
|
||||||
|
},
|
||||||
|
borderRadius: {
|
||||||
|
'sm': '6px',
|
||||||
|
'DEFAULT': '10px',
|
||||||
|
'md': '12px',
|
||||||
|
'lg': '16px',
|
||||||
|
'xl': '20px',
|
||||||
|
'full': '9999px',
|
||||||
|
},
|
||||||
|
spacing: {
|
||||||
|
'gutter-xs': '4px',
|
||||||
|
'gutter-sm': '8px',
|
||||||
|
'gutter-md': '12px',
|
||||||
|
'gutter-lg': '16px',
|
||||||
|
'gutter-xl': '24px',
|
||||||
|
'section': '32px',
|
||||||
|
'page-margin': '16px',
|
||||||
|
},
|
||||||
|
fontFamily: {
|
||||||
|
'headline': ['"Instrument Sans"', 'sans-serif'],
|
||||||
|
'title': ['"Instrument Sans"', 'sans-serif'],
|
||||||
|
'body': ['"Instrument Sans"', 'sans-serif'],
|
||||||
|
'label': ['"Instrument Sans"', 'sans-serif'],
|
||||||
|
},
|
||||||
|
fontSize: {
|
||||||
|
'headline-lg': ['22px', { lineHeight: '28px', letterSpacing: '-0.2px', fontWeight: '700' }],
|
||||||
|
'headline-md': ['20px', { lineHeight: '24px', letterSpacing: '-0.1px', fontWeight: '700' }],
|
||||||
|
'title-lg': ['17px', { lineHeight: '22px', letterSpacing: '0px', fontWeight: '600' }],
|
||||||
|
'title-md': ['15px', { lineHeight: '20px', letterSpacing: '0px', fontWeight: '600' }],
|
||||||
|
'body-lg': ['19px', { lineHeight: '24px', letterSpacing: '0px', fontWeight: '400' }],
|
||||||
|
'body-md': ['15px', { lineHeight: '20px', letterSpacing: '0px', fontWeight: '400' }],
|
||||||
|
'body-sm': ['13px', { lineHeight: '16px', letterSpacing: '0px', fontWeight: '400' }],
|
||||||
|
'label-lg': ['15px', { lineHeight: '20px', letterSpacing: '0px', fontWeight: '700' }],
|
||||||
|
'label-md': ['13px', { lineHeight: '16px', letterSpacing: '0px', fontWeight: '500' }],
|
||||||
|
'label-sm': ['12px', { lineHeight: '14px', letterSpacing: '0px', fontWeight: '600' }],
|
||||||
|
},
|
||||||
|
transitionDuration: {
|
||||||
|
'state-change': '120ms',
|
||||||
|
},
|
||||||
|
transitionDelay: {
|
||||||
|
'state-change': '0ms',
|
||||||
|
},
|
||||||
|
transitionTimingFunction: {
|
||||||
|
'state-change': 'ease-out',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
@@ -0,0 +1,41 @@
|
|||||||
|
{
|
||||||
|
"compilerOptions": {
|
||||||
|
"target": "ES2017",
|
||||||
|
"lib": [
|
||||||
|
"dom",
|
||||||
|
"dom.iterable",
|
||||||
|
"esnext"
|
||||||
|
],
|
||||||
|
"skipLibCheck": true,
|
||||||
|
"strict": true,
|
||||||
|
"noEmit": true,
|
||||||
|
"esModuleInterop": true,
|
||||||
|
"module": "esnext",
|
||||||
|
"moduleResolution": "bundler",
|
||||||
|
"isolatedModules": true,
|
||||||
|
"jsx": "react-jsx",
|
||||||
|
"plugins": [
|
||||||
|
{
|
||||||
|
"name": "next"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"paths": {
|
||||||
|
"@/*": [
|
||||||
|
"./*"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"allowJs": true,
|
||||||
|
"incremental": true,
|
||||||
|
"resolveJsonModule": true
|
||||||
|
},
|
||||||
|
"include": [
|
||||||
|
"next-env.d.ts",
|
||||||
|
"**/*.ts",
|
||||||
|
"**/*.tsx",
|
||||||
|
".next/types/**/*.ts",
|
||||||
|
".next/dev/types/**/*.ts"
|
||||||
|
],
|
||||||
|
"exclude": [
|
||||||
|
"node_modules"
|
||||||
|
]
|
||||||
|
}
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
{
|
||||||
|
"name": "bedrock-web-workspaces",
|
||||||
|
"private": true,
|
||||||
|
"engines": {
|
||||||
|
"node": ">=22"
|
||||||
|
},
|
||||||
|
"workspaces": [
|
||||||
|
"home",
|
||||||
|
"dashboard",
|
||||||
|
"repository"
|
||||||
|
]
|
||||||
|
}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
/node_modules/
|
||||||
|
/.next/
|
||||||
|
/out/
|
||||||
|
/coverage/
|
||||||
|
*.tsbuildinfo
|
||||||
|
next-env.d.ts
|
||||||
|
.env*
|
||||||
|
.DS_Store
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
import type { Metadata } from "next";
|
||||||
|
import type { ReactNode } from "react";
|
||||||
|
|
||||||
|
export const metadata: Metadata = { title: "Repository" };
|
||||||
|
|
||||||
|
export default function RootLayout({ children }: { children: ReactNode }) {
|
||||||
|
return <html lang="zh-CN"><body>{children}</body></html>;
|
||||||
|
}
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
export default function Page() {
|
||||||
|
return <main><h1>Repository</h1></main>;
|
||||||
|
}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
import type { NextConfig } from "next";
|
||||||
|
|
||||||
|
const config: NextConfig = {
|
||||||
|
agentRules: false,
|
||||||
|
devIndicators: false,
|
||||||
|
};
|
||||||
|
|
||||||
|
export default config;
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
{
|
||||||
|
"name": "@bedrock/repository",
|
||||||
|
"private": true,
|
||||||
|
"scripts": {
|
||||||
|
"dev": "next dev --hostname 127.0.0.1 --port 3002",
|
||||||
|
"build": "next build",
|
||||||
|
"start": "next start --hostname 127.0.0.1 --port 3002"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"next": "16.4.6",
|
||||||
|
"react": "19.3.1",
|
||||||
|
"react-dom": "19.3.1"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@types/node": "22.20.7",
|
||||||
|
"@types/react": "19.3.0",
|
||||||
|
"@types/react-dom": "19.3.0",
|
||||||
|
"typescript": "5.9.3"
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,41 @@
|
|||||||
|
{
|
||||||
|
"compilerOptions": {
|
||||||
|
"target": "ES2017",
|
||||||
|
"lib": [
|
||||||
|
"dom",
|
||||||
|
"dom.iterable",
|
||||||
|
"esnext"
|
||||||
|
],
|
||||||
|
"skipLibCheck": true,
|
||||||
|
"strict": true,
|
||||||
|
"noEmit": true,
|
||||||
|
"esModuleInterop": true,
|
||||||
|
"module": "esnext",
|
||||||
|
"moduleResolution": "bundler",
|
||||||
|
"isolatedModules": true,
|
||||||
|
"jsx": "react-jsx",
|
||||||
|
"plugins": [
|
||||||
|
{
|
||||||
|
"name": "next"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"paths": {
|
||||||
|
"@/*": [
|
||||||
|
"./*"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"allowJs": true,
|
||||||
|
"incremental": true,
|
||||||
|
"resolveJsonModule": true
|
||||||
|
},
|
||||||
|
"include": [
|
||||||
|
"next-env.d.ts",
|
||||||
|
"**/*.ts",
|
||||||
|
"**/*.tsx",
|
||||||
|
".next/types/**/*.ts",
|
||||||
|
".next/dev/types/**/*.ts"
|
||||||
|
],
|
||||||
|
"exclude": [
|
||||||
|
"node_modules"
|
||||||
|
]
|
||||||
|
}
|
||||||