算法艺术创作
algorithmic-art
通过代码和可调参数创作生成艺术与交互式视觉效果。
web-development【设计与创意】Web frontend project development rules. Use this skill when developing web frontend pages, deploying static hosting, and integrating CloudBase Web SDK.
独立 GitHub 快照 · 自动分类 · 以原作者文档为准
Use this skill for Web frontend project development when you need to:
Do NOT use for:
Follow project structure conventions
src directorydist directorycloudfunctions directoryUse CloudBase Web SDK correctly
envQuery tool to get environment IDDeploy and preview properly
npm install is executed)publicPath configurationDirectory Organization:
src directorydist directorycloudfunctions directoryBuild System:
Routing:
Static Hosting Deployment:
Local Preview:
npx live-serverPublic Path Configuration:
publicPath and similar configurations should use relative paths instead of absolute paths@cloudbase/js-sdk@latest in the web applicationImportant: Authentication must use SDK built-in features. It is strictly forbidden to implement login authentication logic using cloud functions!
import cloudbase from "@cloudbase/js-sdk";
const app = cloudbase.init({
env: "xxxx-yyy", // Can query environment ID via envQuery tool
});
const auth = app.auth();
// Check current login state
let loginState = await auth.getLoginState();
if (loginState && loginState.user) {
// Logged in
const user = await auth.getCurrentUser();
console.log("Current user:", user);
} else {
// Not logged in - use SDK built-in authentication features
// Collect user's phone number into variable `phoneNum` by providing a input UI
// Send SMS code
const verificationInfo = await auth.getVerification({
phone_number: `+86 ${phoneNum}`,
});
// Collect user's phone number into variable `verificationCode` by providing a input UI
// Sign in
await auth.signInWithSms({
verificationInfo,
verificationCode,
phoneNum,
});
}
Initialization rules (Web, @cloudbase/js-sdk):
import("@cloudbase/js-sdk")initCloudBase() with internal initPromise cachesapp/auth instance in your frontend app; reuse it instead of re-initializingapp, auth, db, or other SDK objects, confirm it exists in the official CloudBase Web SDK documentationMust use SDK built-in authentication: CloudBase Web SDK provides complete authentication features, including login by SMS, anonymous login, custom login, etc.
Forbidden to implement login using cloud functions: Do not create cloud functions to handle login logic, this is the wrong approach
User data management: After login, user information can be obtained via auth.getCurrentUser(), then stored to database
Error handling: All authentication operations should include complete error handling logic
Web project build process: Ensure npm install command has been executed first, then refer to project documentation for building