安装
环境要求
template-sdk 对运行环境有以下要求:
- Node.js:>= 16.x
- Vue:>= 3.5.32
- Vite:>= 8.0.4
包管理器
推荐使用 pnpm 或 npm 安装 SDK。
pnpm(推荐)
pnpm add git+https://gitee.com/CoolRainLy/template-sdk.git#main
npm
npm install git+https://gitee.com/CoolRainLy/template-sdk.git#main
yarn
yarn add git+https://gitee.com/CoolRainLy/template-sdk.git#main
Git 分发说明
SDK 当前通过 Gitee Git 仓库直接分发给模板项目,而不是从 npm registry 安装。
注意:
由于使用 Git 直接安装,每次更新 SDK 代码后,需要在模板项目中重新安装依赖,以确保使用最新的提交对应的 dist 产物。
验证安装
安装完成后,你可以通过以下方式验证 SDK 是否安装成功:
方式一:检查 node_modules
ls node_modules/template-sdk
方式二:在代码中导入
import TemplateSdk from 'template-sdk'
console.log(TemplateSdk)
IDE 配置
为了获得最佳的 TypeScript 类型提示和编辑器支持,建议在项目中添加 jsconfig.json 或 tsconfig.json 配置:
jsconfig.json
{
"include": [
".template-sdk/**/*.d.ts"
]
}
tsconfig.json
{
"include": [
".template-sdk/**/*.d.ts"
]
}
提示:
.template-sdk 目录下的 .d.ts 文件由 SDK 的 Vite 插件自动生成,用于提供类型提示。
下一步
安装完成后,请继续阅读 快速开始 了解如何使用 SDK。