web-development by tencentcloudbase/skills
npx skills add https://github.com/tencentcloudbase/skills --skill web-development../auth-tool/SKILL.md,然后 ../auth-web/SKILL.md../ui-design/SKILL.mdui-design 技能前就开始 UI 实现。当您需要进行 Web 前端项目开发 时,请使用此技能,例如:
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
请勿用于:
遵循项目结构约定
src 目录dist 目录cloudfunctions 目录正确使用 CloudBase Web SDK
envQuery 工具获取环境 ID正确部署和预览
npm install)publicPath 配置使用相对路径目录组织 :
src 目录dist 目录cloudfunctions 目录构建系统 :
路由 :
静态托管部署 :
本地预览 :
npx live-server公共路径配置 :
publicPath 及类似配置应使用相对路径而非绝对路径@cloudbase/js-sdk@latesthttps://static.cloudbase.net/cloudbase-js-sdk/latest/cloudbase.full.jsCDN 快速开始(静态 HTML / 无构建) :
<script src="https://static.cloudbase.net/cloudbase-js-sdk/latest/cloudbase.full.js"></script>
<script>
const app = cloudbase.init({
env: "xxxx-yyy",
});
</script>
重要:认证必须使用 SDK 内置功能。严禁使用云函数实现登录认证逻辑!
import cloudbase from "@cloudbase/js-sdk";
const app = cloudbase.init({
env: "xxxx-yyy", // 可通过 envQuery 工具查询环境 ID
});
const auth = app.auth();
// 检查当前登录状态
let loginState = await auth.getLoginState();
if (loginState && loginState.user) {
// 已登录
const user = await auth.getCurrentUser();
console.log("当前用户:", user);
} else {
// 未登录 - 使用 SDK 内置认证功能
// 通过提供输入 UI 将用户的手机号收集到变量 `phoneNum` 中
// 发送短信验证码
const verificationInfo = await auth.getVerification({
phone_number: `+86 ${phoneNum}`,
});
// 通过提供输入 UI 将用户的验证码收集到变量 `verificationCode` 中
// 登录
await auth.signInWithSms({
verificationInfo,
verificationCode,
phoneNum,
});
}
初始化规则(Web,@cloudbase/js-sdk):
import("@cloudbase/js-sdk") 懒加载 SDKinitPromise 缓存的异步助手函数中,例如 initCloudBase()app/auth 实例;复用该实例,而不是重新初始化app、auth、db 或其他 SDK 对象上的任何方法之前,确认该方法存在于官方 CloudBase Web SDK 文档中必须使用 SDK 内置认证:CloudBase Web SDK 提供了完整的认证功能,包括短信登录、匿名登录、自定义登录等。
禁止使用云函数实现登录:不要创建云函数来处理登录逻辑,这是错误的方法
用户数据管理:登录后,可以通过 auth.getCurrentUser() 获取用户信息,然后存储到数据库
错误处理:所有认证操作都应包含完整的错误处理逻辑
Web 项目构建流程:确保已先执行 npm install 命令,然后参考项目文档进行构建
每周安装数
860
仓库
GitHub 星标数
38
首次出现
Jan 22, 2026
安全审计
安装于
opencode768
codex758
gemini-cli756
github-copilot730
cursor729
kimi-cli706
../auth-tool/SKILL.md, then ../auth-web/SKILL.md../ui-design/SKILL.md firstui-design.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 applicationhttps://static.cloudbase.net/cloudbase-js-sdk/latest/cloudbase.full.jsCDN quick start (static HTML / no-build) :
<script src="https://static.cloudbase.net/cloudbase-js-sdk/latest/cloudbase.full.js"></script>
<script>
const app = cloudbase.init({
env: "xxxx-yyy",
});
</script>
Important: 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
Weekly Installs
860
Repository
GitHub Stars
38
First Seen
Jan 22, 2026
Security Audits
Gen Agent Trust HubPassSocketPassSnykPass
Installed on
opencode768
codex758
gemini-cli756
github-copilot730
cursor729
kimi-cli706
React 组合模式指南:Vercel 组件架构最佳实践,提升代码可维护性
103,800 周安装