Compare commits

..

265 Commits

Author SHA1 Message Date
feige996
0dd0cab15d chore: 更新 package.json 中的版本号至 3.1.0 2025-06-22 16:58:18 +08:00
feige996
02d8fb1268 feat(utils): 添加查询字符串序列化工具函数替代qs库
实现一个轻量级的查询字符串序列化工具,支持基本类型和数组,用于替代第三方qs库以减少打包体积
2025-06-22 16:55:57 +08:00
feige996
ee8fc19a47 feat(env): 添加 VITE_APP_PROXY 和 UNI_PLATFORM 类型声明 2025-06-22 14:22:08 +08:00
feige996
dd11e45d5f refactor: 将类型定义文件移动到src/types目录下并添加登录相关类型
将types目录移动到src下以保持项目结构一致性
新增登录相关的类型定义文件,包含用户信息、登录返回数据等接口
2025-06-22 14:04:49 +08:00
feige996
8455f09e8c chore: 调整 vscode 文件嵌套配置 2025-06-22 13:12:42 +08:00
feige996
edefc99702 refactor(api): 将登录相关类型定义移动到types目录下 2025-06-22 13:02:10 +08:00
feige996
946ad7c976 feat(首页): 添加作者和官网信息并调整顶部间距
在首页添加作者和官网信息展示,同时将顶部图片间距从mt-12调整为mt-10以优化布局
2025-06-22 12:06:39 +08:00
feige996
cfe5634c91 ci(workflow): 添加 base-uv-ui 和 base-uview-plus 的自动合并工作流
添加两个新的工作流用于将 main 分支自动合并到 base-uv-ui 和 base-uview-plus 分支
2025-06-22 11:59:30 +08:00
feige996
2000eda414 chore: 禁用prettier并启用eslint作为默认格式化工具 2025-06-22 10:07:22 +08:00
feige996
69b7429909 style: 修改页面配置和代码片段格式
- 将首页图标类型从 'wot' 改为 'uiLib'
- 调整 Vue3 代码片段中 template 和 script 的顺序
- 格式化代码片段的缩进和换行
2025-06-22 10:04:44 +08:00
feige996
926d700b60 docs: tabbarList 2025-06-21 22:51:51 +08:00
feige996
f0cd8ee943 docs: tabbar.md 2025-06-21 22:46:42 +08:00
feige996
67f76415e1 build: auto merge to base-sard-ui 2025-06-21 19:44:24 +08:00
feige996
e67da2203c feat: uiLib 匹配 2025-06-21 19:36:04 +08:00
feige996
cb033104ee chore: // @ts-expect-error 预知的判断 2025-06-21 19:35:26 +08:00
feige996
28e59cd599 chore: 更新项目版本号至3.0.0,分支合并和eslint等重大变更 2025-06-21 17:40:14 +08:00
feige996
1af7213e96 chore: 移除oxlint及相关配置
清理不再使用的oxlint依赖及其配置文件
更新vscode设置以反映lint工具变更
2025-06-21 17:32:13 +08:00
feige996
d5c14ac3ae build: 将 ESLint 配置从 @antfu 迁移到 @uni-helper
统一使用 uni-app 生态的 ESLint 配置,保持工具链一致性
2025-06-21 17:29:42 +08:00
feige996
27d4441ca6 chore: 更新版本号至2.16.0, 使用 antfu/eslint-config 2025-06-21 17:23:51 +08:00
feige996
ea50a639ed Merge branch 'eslint' 2025-06-21 17:22:34 +08:00
feige996
e171c29d28 chore: 将 lint 工具从 oxlint 切换为 eslint 并启用多语言支持
更新 package.json 中的 lint 脚本,使用 eslint 替代 oxlint
在 .vscode/settings.json 中启用 eslint 对所有支持语言的校验
2025-06-21 17:22:06 +08:00
feige996
ae515cd85e chore: 将eslint替换为oxlint并更新vscode配置
更新package.json中的lint脚本,从eslint改为oxlint
调整.vscode/settings.json中的格式化配置,启用prettier并优化保存时的自动修复行为
2025-06-21 17:18:35 +08:00
feige996
e1654359fd style: 总算处理好所有的 eslint 报错 2025-06-21 17:11:17 +08:00
feige996
32cf872405 refactor: 在多个文件中添加process导入并调整tsconfig顺序
统一添加node:process导入以提高代码一致性
调整tsconfig.json中配置项的顺序以提升可读性
2025-06-21 17:03:45 +08:00
feige996
c355f6e8f1 chore(eslint): 更新eslint配置,禁用部分规则并添加忽略目录
添加markdown支持为false,并配置忽略目录src/uni_modules/和dist
禁用no-console等规则以提升开发体验
2025-06-21 16:59:01 +08:00
feige996
227f19a93c style: 统一代码格式和类型定义,测试eslint --fix, 还是有报错 2025-06-21 16:56:24 +08:00
feige996
9cf0c212bf build: 将 lint 工具从 oxlint 替换为 eslint
统一使用 eslint 作为代码检查工具,简化 lint-staged 配置
2025-06-21 16:53:10 +08:00
feige996
79c333e647 feat: 添加 ESLint 配置并集成到 VSCode
pnpm dlx @antfu/eslint-config@latest
2025-06-21 16:50:31 +08:00
feige996
9c074652e1 chore: 简化 commitlint 配置 2025-06-21 16:28:17 +08:00
feige996
6402f8825f docs: 修正描述中Vite的版本号从6改为5 2025-06-21 15:56:51 +08:00
feige996
4fc50a6bb5 Revert "chore: 更新.gitignore并删除未使用的配置文件"
This reverts commit 28d8000ad82b20e749f50dc1848f1e24ed588220.
2025-06-21 15:53:24 +08:00
feige996
28d8000ad8 chore: 更新.gitignore并删除未使用的配置文件
移除src/pages.json和src/manifest.json配置文件
更新.gitignore以忽略src/types目录和删除的配置文件
2025-06-21 15:50:13 +08:00
feige996
144dec8881 chore: 更新版本号至2.15.0 2025-06-21 15:33:19 +08:00
feige996
e2c319079a refactor(about): 移除未使用的导航代码并简化页面结构 2025-06-21 15:30:53 +08:00
feige996
1efb68cb9b docs: 将模板分支从tabbar更新为base 2025-06-21 15:29:36 +08:00
feige996
ba7252c332 ci(workflow): 移除不再需要的自动合并工作流
删除针对 tabbar 和 spa 分支的自动合并工作流配置,仅保留 i18n 分支的配置
2025-06-21 15:11:43 +08:00
feige996
548b0515f6 docs(pages.config): 添加关于 tabbar 配置位置的注释 2025-06-21 15:04:54 +08:00
feige996
b03f7ee310 docs: 更新README中微信平台的命令名称
将微信平台开发和生产环境的命令从`dev:mp-weixin`和`build:mp-weixin`统一简化为`dev:mp`和`build:mp`,保持命令一致性
2025-06-21 14:59:00 +08:00
feige996
e2eda79403 docs(fg-tabbar): 完善 tabbar 策略的注释说明
添加更详细的注释说明 tabbar 策略选项及其使用注意事项
提醒代码更改后需要重新运行以更新 pages.json
2025-06-21 14:55:06 +08:00
feige996
2a97bf0aaa chore(fg-tabbar): 将selectedTabbarStrategy默认值改为0 2025-06-21 14:46:50 +08:00
feige996
f8641457ad refactor(fg-tabbar): 更新tabbar策略并添加safelist配置
将selectedTabbarStrategy从0改为1以切换tabbar策略
在uno.config.ts中添加空的safelist配置
移除注释掉的i-carbon-code导入
2025-06-21 14:36:30 +08:00
feige996
407bc849ec Revert "chore: pnpm-lock.yaml"
This reverts commit 21234cdbe2bd40104cbb4abf1da2d62b44c0227e.
2025-06-21 14:31:00 +08:00
feige996
38328280c4 chore: 回退esbuild版本至0.20.2 解决ios模拟器报错 2025-06-21 14:24:30 +08:00
feige996
d2f7b5e1ec docs(layouts): 添加tabbar组件使用说明文档 2025-06-21 14:17:23 +08:00
feige996
7b3e757301 refactor(utils): 移除未使用的 tabBar 相关代码并简化导入
清理不再使用的 tabBar 相关函数和变量,简化 pages.json 的导入方式
2025-06-21 13:37:17 +08:00
feige996
2a71d02ab8 refactor(tabbar): 将 tabbar 组件从 components 移动到 layouts 目录
重构 tabbar 组件结构,将其从 components 目录迁移至 layouts 目录以更符合项目结构规范
移除未使用的 midButton 配置
2025-06-21 13:35:29 +08:00
feige996
4b77ca6c13 chore: midButton 2025-06-21 13:30:41 +08:00
feige996
21234cdbe2 chore: pnpm-lock.yaml 2025-06-21 13:30:26 +08:00
feige996
5250fac0a1 refactor(tabbar): 重构自定义tabbar逻辑并添加图标路径
移除冗余注释并整理tabbar相关配置
添加自定义tabbar的图标路径配置
优化tabbar显示逻辑,根据CUSTOM_TABBAR_ENABLE决定显示方式
2025-06-21 13:09:14 +08:00
feige996
91faa0f301 refactor(tabbar): 重构底部导航栏配置及逻辑
将底部导航栏配置从 pages.config.ts 移动到单独的文件中
添加 CUSTOM_TABBAR_ENABLE 开关控制自定义导航栏行为
优化导航栏切换逻辑,根据开关选择不同跳转方式
2025-06-21 12:54:52 +08:00
GitHub Actions
13ebc5aacc Auto merge main into tabbar 2025-06-21 02:53:22 +00:00
feige996
d86bfa719d ci: 将自动合并工作流中的基础分支从base改为main 2025-06-21 10:52:02 +08:00
GitHub Actions
72c261ef67 Auto merge base into tabbar 2025-06-21 02:38:08 +00:00
feige996
a7671ce4a9 docs(pages.config.ts): 更新tabBar配置的注释说明 2025-06-21 10:36:22 +08:00
GitHub Actions
de32f4515f Auto merge base into tabbar 2025-06-21 02:35:28 +00:00
feige996
74e52f000a docs(useUpload): 更新注释以明确不同平台的返回值差异
补充说明H5和App平台返回的File对象字段差异,并调整注释顺序使其更清晰
2025-06-21 10:33:22 +08:00
feige996
7bd338e07c fix(useUpload): 修复文件路径和大小获取逻辑错误
调整条件编译逻辑,确保在非微信小程序环境下也能正确获取文件路径和大小
2025-06-21 10:29:55 +08:00
feige996
119edac05a refactor(页面布局): 移除自定义导航栏相关代码并简化样式
移除about页面的自定义导航栏代码及相关配置,统一使用默认导航栏样式
优化index页面布局,移除多余的overflow-hidden样式
修复upload组件图片显示条件判断
2025-06-21 10:27:59 +08:00
GitHub Actions
f93ed08cb2 Auto merge base into tabbar 2025-06-21 02:14:34 +00:00
feige996
393c37bd56 chore: 更新版本号至2.14.0 2025-06-21 10:14:20 +08:00
GitHub Actions
7a1ae5b0f3 Auto merge base into tabbar 2025-06-21 02:12:02 +00:00
feige996
c47564e51a build: 添加对@dcloudio/uni-h5的补丁支持
添加pnpm-workspace.yaml配置文件并创建补丁文件,修复uni-h5组件中tabBar高度可能为undefined的问题
2025-06-21 10:11:39 +08:00
feige996
7a2e870641 chore: 在.prettierignore中添加node_modules目录 2025-06-21 10:08:35 +08:00
GitHub Actions
3b7688a20b Auto merge base into tabbar 2025-06-21 01:26:18 +00:00
feige996
e2c0ac4721 refactor(layout): 移除隐私弹窗组件 2025-06-21 09:20:04 +08:00
GitHub Actions
11c6f158d0 Auto merge base into tabbar 2025-06-21 01:19:12 +00:00
feige996
9ef3b7d7d4 build: 将 uno.css 替换为 virtual:uno.css 2025-06-20 23:16:20 +08:00
feige996
4f67168494 feat(tabbar): 添加中间按钮并移除自定义tabbar配置
添加发布按钮作为tabbar中间按钮,同时移除不再需要的custom配置
2025-06-20 21:40:52 +08:00
feige996
bf61c3d1f0 chore: 在页面中添加调试日志
添加console.log语句用于调试index和about页面
2025-06-20 19:35:31 +08:00
feige996
9a34868fb7 refactor(tabbar): 将tabbar配置抽离为单独模块以提高可维护性
将pages.config.ts中的tabbar配置抽离到单独的tabbarList.ts文件
移除pages.json中无用的__esModule字段
2025-06-20 19:32:34 +08:00
GitHub Actions
fe751745e5 Auto merge base into tabbar 2025-06-20 02:45:43 +00:00
feige996
29f526242d ci: 移除不再需要的自动合并到main的工作流 2025-06-20 10:45:22 +08:00
GitHub Actions
ba8c0a2e7f Auto merge base into tabbar 2025-06-20 02:43:41 +00:00
feige996
33638c5a9e build: 添加 prettier 依赖并升级至 3.5.3 版本 2025-06-20 10:43:18 +08:00
GitHub Actions
6a7ece9b3f Auto merge base into tabbar 2025-06-17 14:57:59 +00:00
feige996
47d8401c47 chore: 更新 package.json 版本号至 2.13.1 2025-06-17 22:57:37 +08:00
feige996
11b7880810 refactor: 移除未使用的"我的"页面及相关路由配置 2025-06-17 22:39:31 +08:00
feige996
c1b12eab84 Merge branch 'base' into tabbar 2025-06-17 22:39:11 +08:00
feige996
136fb5d507 chore: 更新版本号至2.13.0 2025-06-17 22:36:31 +08:00
feige996
4445e18b02 refactor: 移除用户中心相关页面和隐私弹窗组件
删除与用户中心相关的所有页面,包括个人资料、修改密码、关于我们等
移除不再使用的隐私协议弹窗组件及相关样式文件
清理路由配置中不再需要的页面路径
2025-06-17 22:35:29 +08:00
feige996
7dd210e427 docs(package.json): 修复bugs.url字段的命名错误 2025-06-17 18:17:37 +08:00
feige996
2f2a14cd06 docs: 更新废弃仓库字段名从repository-deprecated到repository-old 2025-06-17 18:16:32 +08:00
GitHub Actions
3eb06627c2 Auto merge base into tabbar 2025-06-17 10:15:28 +00:00
feige996
c6d4a46968 fix(vite-plugins): 仅在生产环境构建时更新package.json 2025-06-17 18:15:08 +08:00
GitHub Actions
09e048ba85 Auto merge base into tabbar 2025-06-17 10:14:14 +00:00
feige996
968a090876 refactor(vite): 将 updatePackageJson 插件从 scripts 移动到 vite-plugins 目录 2025-06-17 18:11:41 +08:00
feige996
39f4ba793d chore: 更新 package.json 中的 update-time 字段 2025-06-17 18:11:15 +08:00
GitHub Actions
ea2f3a6990 Auto merge base into tabbar 2025-06-17 10:10:22 +00:00
feige996
f6208a191d feat(build): 添加自动更新package.json时间戳的vite插件
添加updatePackageJson插件,在构建时自动更新package.json中的时间戳字段
2025-06-17 18:09:51 +08:00
GitHub Actions
23cd9a522e Auto merge base into tabbar 2025-06-16 01:53:25 +00:00
feige996
f2119f3f73 fix: await getUserInfo need await 2025-06-16 09:53:03 +08:00
GitHub Actions
61a2fd8a27 Auto merge base into tabbar 2025-06-15 14:28:46 +00:00
菲鸽
3808f515cf !16 让http工具方法支持传递更多参数
Merge pull request !16 from 浑宣凯/N/A
2025-06-15 20:51:37 +08:00
GitHub Actions
61bb8363cd Auto merge base into tabbar 2025-06-15 09:04:45 +00:00
feige996
bd64215f86 chore: 更新版本至 2.12.2 2025-06-15 16:46:57 +08:00
GitHub Actions
a4d366c01e Auto merge base into tabbar 2025-06-15 08:46:51 +00:00
feige996
8f711caada chore: 更新 z-paging 依赖至 2.8.7 版本 2025-06-15 16:46:28 +08:00
GitHub Actions
3a2b4febd2 Auto merge base into tabbar 2025-06-14 04:36:21 +00:00
feige996
da79ac04e6 chore: 移除.eslintignore并将忽略规则移至.oxlintrc.json
将原本在.eslintignore中配置的忽略文件移动到.oxlintrc.json的ignorePatterns中,简化配置文件管理
2025-06-14 12:36:00 +08:00
GitHub Actions
95dbb93256 Auto merge base into tabbar 2025-06-14 04:00:41 +00:00
feige996
6996037cd4 Revert "chore: 更新 unocss 依赖至 66.2.0 版本"
This reverts commit c1200eabe875019b4ff2e1aff53dff49d0ef9bcf.
2025-06-14 12:00:17 +08:00
GitHub Actions
cc886bd326 Auto merge base into tabbar 2025-06-14 03:13:50 +00:00
feige996
c1200eabe8 chore: 更新 unocss 依赖至 66.2.0 版本 2025-06-14 10:55:57 +08:00
feige996
0864bc9e3f chore: 降级依赖版本至vue@3.4.21和vite@5.2.8
更新package.json和pnpm-lock.yaml文件,将vue从3.5.15降级至3.4.21,vite从6.3.5降级至5.2.8版本
2025-06-14 10:54:05 +08:00
GitHub Actions
26d49ac5bc Auto merge base into tabbar 2025-06-14 02:46:12 +00:00
feige996
907c20d9d8 chore: 更新 @uni-helper 相关依赖版本 2025-06-14 10:45:08 +08:00
GitHub Actions
25fb9705cc Auto merge base into tabbar 2025-06-13 10:34:52 +00:00
GitHub Actions
4efb14cbff Auto merge base into tabbar 2025-06-13 10:33:46 +00:00
GitHub Actions
0723fb178b Auto merge base into tabbar 2025-06-13 09:01:21 +00:00
GitHub Actions
6866c17184 Auto merge base into tabbar 2025-06-13 09:00:53 +00:00
GitHub Actions
1558430435 Auto merge base into tabbar 2025-06-13 08:47:40 +00:00
GitHub Actions
6da7d46913 Auto merge base into tabbar 2025-06-13 08:38:56 +00:00
GitHub Actions
5f97a3ff8a Auto merge base into tabbar 2025-06-11 15:39:50 +00:00
GitHub Actions
12b9384df6 Auto merge base into tabbar 2025-06-10 09:14:21 +00:00
GitHub Actions
1f3749d08d Auto merge base into tabbar 2025-06-06 15:46:16 +00:00
GitHub Actions
2c566253f3 Auto merge base into tabbar 2025-06-06 14:59:38 +00:00
GitHub Actions
28fad4a480 Auto merge base into tabbar 2025-06-06 14:42:50 +00:00
GitHub Actions
8233556683 Auto merge base into tabbar 2025-06-06 04:45:21 +00:00
GitHub Actions
8464a040ab Auto merge base into tabbar 2025-06-06 04:41:25 +00:00
GitHub Actions
0d42825314 Auto merge base into tabbar 2025-06-05 14:56:49 +00:00
GitHub Actions
8a434fa761 Auto merge base into tabbar 2025-06-04 14:44:02 +00:00
GitHub Actions
b286d07623 Auto merge base into tabbar 2025-06-04 09:41:11 +00:00
GitHub Actions
9dcea8189e Auto merge base into tabbar 2025-06-04 07:20:27 +00:00
GitHub Actions
d5a3772b3a Auto merge base into tabbar 2025-06-04 01:03:41 +00:00
GitHub Actions
3bf7fcb844 Auto merge base into tabbar 2025-06-04 01:03:12 +00:00
GitHub Actions
7b61242611 Auto merge base into tabbar 2025-06-04 01:00:58 +00:00
GitHub Actions
51d399f38b Auto merge base into tabbar 2025-06-03 12:04:11 +00:00
GitHub Actions
e79ae9a17f Auto merge base into tabbar 2025-06-03 11:51:51 +00:00
GitHub Actions
3f08e45e06 Auto merge base into tabbar 2025-06-03 11:50:30 +00:00
GitHub Actions
a0a2106fe7 Auto merge base into tabbar 2025-06-03 11:43:14 +00:00
GitHub Actions
291be04925 Auto merge base into tabbar 2025-06-03 10:12:13 +00:00
GitHub Actions
81a1e8e42d Auto merge base into tabbar 2025-06-03 09:48:13 +00:00
GitHub Actions
3e604e3c7f Auto merge base into tabbar 2025-06-03 09:26:52 +00:00
GitHub Actions
bb0a57bd1f Auto merge base into tabbar 2025-06-03 06:49:14 +00:00
GitHub Actions
22ce0f481d Auto merge base into tabbar 2025-06-03 04:55:35 +00:00
feige996
d76a5baad9 Merge branch 'tabbar' of github.com:feige996/unibest into tabbar 2025-06-03 12:42:18 +08:00
GitHub Actions
667e0647c4 Auto merge base into tabbar 2025-06-03 04:40:02 +00:00
feige996
0042afe215 refactor(fg-tabbar): 使用工具函数中的tabBarList替代直接导入
从直接导入pages.json中的tabBar改为使用utils中封装的_tabBarList,提高代码复用性和维护性
2025-06-03 12:38:13 +08:00
GitHub Actions
b857669c0c Auto merge base into tabbar 2025-06-03 02:20:33 +00:00
GitHub Actions
b454473591 Auto merge base into tabbar 2025-06-03 02:14:09 +00:00
GitHub Actions
91d66fda51 Auto merge base into tabbar 2025-06-03 01:28:54 +00:00
GitHub Actions
6777d20d41 Auto merge base into tabbar 2025-06-03 01:17:55 +00:00
GitHub Actions
1905a3f8bb Auto merge base into tabbar 2025-05-30 03:17:55 +00:00
GitHub Actions
54105b9968 Auto merge base into tabbar 2025-05-28 08:18:01 +00:00
GitHub Actions
d980dbb97a Auto merge base into tabbar 2025-05-28 07:21:17 +00:00
GitHub Actions
c594222abd Auto merge base into tabbar 2025-05-28 07:15:45 +00:00
GitHub Actions
53d68c10a0 Auto merge base into tabbar 2025-05-28 03:40:44 +00:00
feige996
b5cd1319c0 Merge branch 'base' into tabbar 2025-05-28 11:35:54 +08:00
feige996
b6fbf54c1c Merge branch 'base' into tabbar 2025-05-28 00:59:32 +08:00
feige996
d35fabd893 feat(tabbar): 调整 2025-05-28 00:51:49 +08:00
feige996
6673c2e269 Merge branch 'base' into tabbar 2025-05-28 00:46:30 +08:00
GitHub Actions
a57d4c08b3 Auto merge base into tabbar 2025-05-27 08:55:54 +00:00
GitHub Actions
cb33ed7a00 Auto merge base into tabbar 2025-05-26 16:32:23 +00:00
feige996
efe570c8c9 Merge branch 'base' into tabbar 2025-05-26 23:30:37 +08:00
GitHub Actions
3c398ab101 Auto merge base into tabbar 2025-05-22 12:02:38 +00:00
GitHub Actions
aed4b934ed Auto merge base into tabbar 2025-05-21 02:17:02 +00:00
GitHub Actions
56bfdfaf70 Auto merge base into tabbar 2025-05-19 07:12:12 +00:00
feige996
2959974f86 Merge branch 'base' into tabbar 2025-05-19 14:54:48 +08:00
GitHub Actions
085a1d73a2 Auto merge base into tabbar 2025-04-22 06:47:50 +00:00
GitHub Actions
7f80ded4c2 Auto merge base into tabbar 2025-04-12 06:09:19 +00:00
GitHub Actions
639c2a0e75 Auto merge base into tabbar 2025-03-07 11:43:14 +00:00
GitHub Actions
3c7701d21b Auto merge base into tabbar 2025-02-25 03:51:55 +00:00
GitHub Actions
5952515ac7 Auto merge base into tabbar 2025-01-23 15:50:34 +00:00
GitHub Actions
13c3e78cc6 Auto merge base into tabbar 2025-01-14 13:59:27 +00:00
GitHub Actions
e5103ddb7a Auto merge base into tabbar 2025-01-14 11:30:02 +00:00
Burt
ac2128bb76 Merge branch 'base' into tabbar 2025-01-14 19:26:40 +08:00
Burt
5b55e01089 Merge branch 'base' into tabbar 2025-01-06 23:27:20 +08:00
Burt
e57853fda0 Merge branch 'base' into tabbar 2025-01-06 14:00:47 +08:00
Burt
16c27345ed Merge branch 'base' into tabbar 2025-01-05 12:38:34 +08:00
Burt
c214a15bb7 Merge branch 'base' into tabbar 2025-01-01 18:09:03 +08:00
Burt
24b43088a9 Merge branch 'base' into tabbar 2024-12-31 12:21:03 +08:00
Burt
1ee3d06ed8 Merge branch 'base' into tabbar 2024-12-26 12:33:51 +08:00
Burt
5144ceabd1 Merge branch 'base' into tabbar 2024-12-10 21:45:05 +08:00
Burt
7eb4c23116 Merge branch 'base' into tabbar 2024-12-06 14:49:33 +08:00
Burt
53ebadf0a2 Merge branch 'base' into tabbar 2024-12-04 09:42:36 +08:00
Burt
8c1dda51ed Merge branch 'base' into tabbar 2024-12-02 21:02:12 +08:00
Burt
637ca983cf build: 降级uni版本,确保样式正确 2024-12-02 20:57:33 +08:00
Burt
1b61a262da Merge branch 'base' into tabbar 2024-12-02 20:54:08 +08:00
Burt
6fe2b888e4 Merge branch 'base' into tabbar 2024-12-02 16:25:40 +08:00
Burt
cd130de1cf Merge branch 'base' into tabbar 2024-11-15 16:47:22 +08:00
Burt
988cf6aa53 Merge branch 'base' into tabbar 2024-11-10 22:59:55 +08:00
Burt
7afa74d381 Merge branch base into tabbar 2024-11-10 22:52:08 +08:00
Burt
1bec786aaa Merge branch 'base' into tabbar 2024-11-10 22:48:37 +08:00
Burt
46ae55c73c Merge branch 'base' into tabbar 2024-09-11 20:50:58 +08:00
Burt
0865a33ad4 Merge branch 'base' into tabbar 2024-09-05 20:57:43 +08:00
Burt
f01b98693e Merge branch 'base' 2024-09-05 20:51:47 +08:00
菲鸽
8b357ab8c5 Merge branch 'base' into tabbar 2024-07-16 21:09:37 +08:00
菲鸽
7f41078fa0 Merge branch 'base' into tabbar 2024-06-28 13:08:08 +08:00
菲鸽
e4571097c8 Merge branch 'base' into tabbar 2024-06-25 21:59:57 +08:00
菲鸽
dec635a59d Merge branch 'base' into tabbar 2024-06-25 17:48:07 +08:00
菲鸽
5823f89e5f Merge branch 'base' into tabbar 2024-06-19 14:11:45 +08:00
菲鸽
d20f359769 Merge branch 'base' into tabbar 2024-06-17 17:24:21 +08:00
菲鸽
18d52a8e48 Merge branch 'base' into tabbar 2024-06-17 17:23:20 +08:00
菲鸽
3b2395da26 Merge branch 'base' into tabbar 2024-06-17 16:25:52 +08:00
菲鸽
12aae659fe Merge branch 'base' into tabbar 2024-06-16 16:47:37 +08:00
菲鸽
45744d412e Merge branch 'base' into tabbar 2024-06-16 16:39:14 +08:00
菲鸽
4b7a28fe97 Merge branch 'base' into tabbar 2024-06-07 10:48:09 +08:00
菲鸽
c1ed654ff3 Merge branch 'base' into tabbar 2024-06-04 18:03:36 +08:00
菲鸽
bb30afe1b6 Merge branch 'base' into tabbar 2024-06-03 12:33:53 +08:00
菲鸽
4ebc32dd3b Merge branch 'base' into tabbar 2024-06-01 21:53:56 +08:00
菲鸽
b1bfd0d336 Merge branch 'base' into tabbar 2024-06-01 21:48:43 +08:00
菲鸽
208f2395a6 build: pnpm-lock.yaml 2024-06-01 21:46:39 +08:00
菲鸽
a616867641 Merge branch 'base' into tabbar 2024-06-01 21:45:48 +08:00
菲鸽
bde0332183 refine: my 2024-05-28 11:36:23 +08:00
菲鸽
588c3a446f chore: 注意tabbar路由需要使用 layout:tabbar 布局 2024-05-28 11:34:30 +08:00
菲鸽
a9d3eccad5 feat: 优化tabbar,精简tabbar 2024-05-28 11:33:15 +08:00
菲鸽
01679809b8 fix: tabBar 我的 icon 不见了 2024-05-28 10:15:50 +08:00
菲鸽
a4fd81d2a8 Merge branch 'base' into tabbar 2024-05-26 09:52:31 +08:00
菲鸽
7ab753ee8d Merge branch 'base' into tabbar 2024-05-25 19:28:18 +08:00
菲鸽
e20b84c8d5 Merge branch 'base' into tabbar 2024-05-19 18:48:46 +08:00
菲鸽
77020a13a0 Merge branch 'base' into tabbar 2024-05-18 18:01:12 +08:00
菲鸽
79bbc09850 feat: 优化btn宽度 2024-05-18 17:58:02 +08:00
菲鸽
556f9052d1 Merge branch 'base' into tabbar 2024-05-18 17:46:50 +08:00
菲鸽
3e2cc7be81 chore: 运行 2024-05-18 17:43:34 +08:00
菲鸽
5871cb5fd8 Merge branch 'base' into tabbar 2024-05-12 19:53:51 +08:00
菲鸽
3a088be68b build: pnpm upgrade wot-design-uni 2024-05-12 17:46:37 +08:00
菲鸽
eab3de02fd build(manifest): ignoreVersion: true 2024-05-12 17:43:25 +08:00
菲鸽
7e26a71db8 chore: json 2024-05-12 17:24:47 +08:00
菲鸽
8bf7145752 Merge branch 'base' into tabbar 2024-05-12 17:24:11 +08:00
菲鸽
fd1102b425 Merge branch 'base' into tabbar 2024-05-12 17:19:28 +08:00
菲鸽
005d2406ab Merge branch 'base' into tabbar 2024-05-12 17:06:16 +08:00
菲鸽
fbd6343b2b Merge branch 'base' into tabbar 2024-05-12 16:47:28 +08:00
菲鸽
b11b17ec40 feat: tabbar 支持4种图标 2024-05-12 16:37:25 +08:00
菲鸽
9736931bfd Merge branch 'base' into tabbar 2024-05-12 16:25:53 +08:00
菲鸽
85c34bc922 build: uni-pages.d.ts 2024-05-12 11:54:50 +08:00
菲鸽
70801959ea Merge branch 'base' into tabbar 2024-05-12 11:54:22 +08:00
菲鸽
aa758845f6 build: 运行出自己的pages.json 2024-05-12 10:28:53 +08:00
菲鸽
c6eccbfa19 Merge branch 'base' into tabbar 2024-05-12 10:28:19 +08:00
菲鸽
3ae09fc804 refine: unocss icon 生效提示 2024-05-11 21:27:46 +08:00
菲鸽
695486e41f feat: 三种方式的图标,tabbar都支持 2024-05-11 21:26:56 +08:00
菲鸽
7cf16d608c feat: 续上,H5 也需要隐藏 2024-05-11 20:11:54 +08:00
菲鸽
0d948a0691 feat: app 里面才需要 hideTabBar 2024-05-11 20:10:26 +08:00
菲鸽
50cb3419c2 refine: store key 2024-05-11 11:36:44 +08:00
菲鸽
7271f3c618 fix: tabbar 2个BUG 2024-05-11 11:32:34 +08:00
菲鸽
d6c6022a18 fix: app 未隐藏原生tabbar 2024-05-11 11:26:04 +08:00
菲鸽
84d4607b2a fix: isUnocssIcon 没有了 2024-05-11 09:43:58 +08:00
菲鸽
4f6d271c28 feat: 使用 tabbar layout + wot icon 2024-05-11 09:41:33 +08:00
菲鸽
ee52ae132d refactor: 自定义tabbar 2024-05-11 09:36:26 +08:00
菲鸽
de8df540c2 Merge branch 'base' into tabbar 2024-05-09 08:49:40 +08:00
菲鸽
6d4bb21f52 Merge branch 'base' into tabbar 2024-05-08 21:02:02 +08:00
菲鸽
ffa5c68e66 Merge branch 'base' into tabbar 2024-05-08 20:27:06 +08:00
菲鸽
5eadda62de Merge branch 'base' into tabbar 2024-05-03 20:01:03 +08:00
菲鸽
041403f5d8 Merge branch 'base' into tabbar 2024-05-02 16:55:26 +08:00
菲鸽
137fa5846b Merge branch 'base' into tabbar 2024-04-30 15:00:40 +08:00
菲鸽
ffc37d9030 build: 写成 easycom 规范可以不用显式custom 规则 2024-04-20 11:08:54 +08:00
菲鸽
7e3ab3ca19 fix: tabbar 引入 2024-04-20 11:02:20 +08:00
菲鸽
cdae57adce Merge branch 'base' into tabbar 2024-04-20 10:53:07 +08:00
菲鸽
39007ec045 Merge branch 'base' into tabbar 2024-04-12 15:12:47 +08:00
菲鸽
d4935d1186 Merge branch 'base' into tabbar 2024-04-11 18:40:25 +08:00
菲鸽
12acce4575 Merge branch 'base' into tabbar 2024-04-11 09:25:03 +08:00
菲鸽
3f15da98de Merge branch 'base' into tabbar 2024-04-09 14:27:21 +08:00
菲鸽
fb4a6e7bec Merge branch 'base' into tabbar 2024-04-07 17:23:25 +08:00
菲鸽
6cdb56bb12 Merge branch 'base' into tabbar 2024-04-07 09:02:55 +08:00
菲鸽
e7d0a685d4 Merge branch 'base' into tabbar 2024-04-06 22:22:06 +08:00
菲鸽
c3debbb636 fix: code-snippets 2024-04-05 15:00:03 +08:00
菲鸽
a7c3dbaea2 Merge branch 'base' into tabbar 2024-04-05 14:20:06 +08:00
菲鸽
c032fe5a1e build(tsconfig.json): add components.d.ts ,自定义组件就有提示了 2024-04-04 16:55:26 +08:00
菲鸽
6a018d89be fix: 自动导入的函数,在模板报错 2024-04-04 16:17:29 +08:00
菲鸽
cc716a1e0c build: remove @uni-helper/uni-app-types 才有提示 2024-04-03 16:34:16 +08:00
菲鸽
be35efd530 Merge branch 'base' into tabbar 2024-04-02 21:32:38 +08:00
菲鸽
37b52d1243 refine: 显示模板分支 2024-04-02 21:05:29 +08:00
菲鸽
4770817fdc fix: ts 报错 2024-04-02 20:51:53 +08:00
菲鸽
3a12eb35eb refine: about 页面 2024-04-02 20:46:44 +08:00
菲鸽
01916970e8
!7 自定义tabbar
Merge pull request !7 from summer/custom-tabbar
2024-04-02 12:37:42 +00:00
summer
ee43df4fa6 feat: 新增自定义tabbar分支 2024-04-02 17:31:39 +08:00
242 changed files with 3033 additions and 8301 deletions

View File

@ -1,106 +1,3 @@
const fs = require('fs')
const path = require('path')
const { execSync } = require('child_process')
const scopes = fs
.readdirSync(path.resolve(__dirname, 'src'), { withFileTypes: true })
.filter((dirent) => dirent.isDirectory())
.map((dirent) => dirent.name.replace(/s$/, ''))
// precomputed scope
const scopeComplete = execSync('git status --porcelain || true')
.toString()
.trim()
.split('\n')
.find((r) => ~r.indexOf('M src'))
?.replace(/(\/)/g, '%%')
?.match(/src%%((\w|-)*)/)?.[1]
?.replace(/s$/, '')
module.exports = {
ignores: [(commit) => commit.includes('init')],
extends: ['@commitlint/config-conventional'],
rules: {
'body-leading-blank': [2, 'always'],
'footer-leading-blank': [1, 'always'],
'header-max-length': [2, 'always', 108],
'subject-empty': [2, 'never'],
'type-empty': [2, 'never'],
'subject-case': [0],
'type-enum': [
2,
'always',
[
'feat',
'fix',
'perf',
'style',
'docs',
'test',
'refactor',
'build',
'ci',
'chore',
'revert',
'wip',
'workflow',
'types',
'release',
],
],
},
prompt: {
/** @use `pnpm commit :f` */
alias: {
f: 'docs: fix typos',
r: 'docs: update README',
s: 'style: update code format',
b: 'build: bump dependencies',
c: 'chore: update config',
},
customScopesAlign: !scopeComplete ? 'top' : 'bottom',
defaultScope: scopeComplete,
scopes: [...scopes, 'mock'],
allowEmptyIssuePrefixs: false,
allowCustomIssuePrefixs: false,
// English
typesAppend: [
{ value: 'wip', name: 'wip: work in process' },
{ value: 'workflow', name: 'workflow: workflow improvements' },
{ value: 'types', name: 'types: type definition file changes' },
],
// 中英文对照版
// messages: {
// type: '选择你要提交的类型 :',
// scope: '选择一个提交范围 (可选):',
// customScope: '请输入自定义的提交范围 :',
// subject: '填写简短精炼的变更描述 :\n',
// body: '填写更加详细的变更描述 (可选)。使用 "|" 换行 :\n',
// breaking: '列举非兼容性重大的变更 (可选)。使用 "|" 换行 :\n',
// footerPrefixsSelect: '选择关联issue前缀 (可选):',
// customFooterPrefixs: '输入自定义issue前缀 :',
// footer: '列举关联issue (可选) 例如: #31, #I3244 :\n',
// confirmCommit: '是否提交或修改commit ?',
// },
// types: [
// { value: 'feat', name: 'feat: 新增功能' },
// { value: 'fix', name: 'fix: 修复缺陷' },
// { value: 'docs', name: 'docs: 文档变更' },
// { value: 'style', name: 'style: 代码格式' },
// { value: 'refactor', name: 'refactor: 代码重构' },
// { value: 'perf', name: 'perf: 性能优化' },
// { value: 'test', name: 'test: 添加疏漏测试或已有测试改动' },
// { value: 'build', name: 'build: 构建流程、外部依赖变更 (如升级 npm 包、修改打包配置等)' },
// { value: 'ci', name: 'ci: 修改 CI 配置、脚本' },
// { value: 'revert', name: 'revert: 回滚 commit' },
// { value: 'chore', name: 'chore: 对构建过程或辅助工具和库的更改 (不影响源文件、测试用例)' },
// { value: 'wip', name: 'wip: 正在开发中' },
// { value: 'workflow', name: 'workflow: 工作流程改进' },
// { value: 'types', name: 'types: 类型定义文件修改' },
// ],
// emptyScopesAlias: 'empty: 不填写',
// customScopesAlias: 'custom: 自定义',
},
}

View File

@ -1,4 +0,0 @@
vite.config.ts
uno.config.ts
pages.config.ts
manifest.config.ts

View File

@ -1,24 +0,0 @@
---
name: Bug report报告问题
about: Create a report to help us improve
---
<!--
注意:为更好的解决你的问题,请参考模板提供完整信息,准确描述问题,信息不全的 issue 将被关闭。
Note: In order to better solve your problem, please refer to the template to provide complete information, accurately describe the problem, and the incomplete information issue will be closed.
-->
# Bug report问题描述
写清楚 unibest 版本号平台是什么小程序、APP还是h5以及具体问题描述。期望是什么实际是什么。
## Steps to reproduce问题复现步骤
这里写问题复现步骤
<!--
1. [xxx]
2. [xxx]
3. [xxxx]
-->

View File

@ -1,6 +0,0 @@
---
name: Feature Request新功能建议
about: Suggest an idea for this project
---
# Feature request新功能建议

60
.github/release.yml vendored
View File

@ -1,31 +1,31 @@
categories:
- title: '🚀 新功能'
labels: ['feat', 'feature']
- title: '🛠️ 修复'
labels: ['fix', 'bugfix']
- title: '💅 样式'
labels: ['style']
- title: '📄 文档'
labels: ['docs']
- title: '⚡️ 性能'
labels: ['perf']
- title: '🧪 测试'
labels: ['test']
- title: '♻️ 重构'
labels: ['refactor']
- title: '📦 构建'
labels: ['build']
- title: '🚨 补丁'
labels: ['patch', 'hotfix']
- title: '🌐 发布'
labels: ['release', 'publish']
- title: '🔧 流程'
labels: ['ci', 'cd', 'workflow']
- title: '⚙️ 配置'
labels: ['config', 'chore']
- title: '📁 文件'
labels: ['file']
- title: '🎨 格式化'
labels: ['format']
- title: '🔀 其他'
labels: ['other', 'misc']
- title: 🚀 新功能
labels: [feat, feature]
- title: 🛠️ 修复
labels: [fix, bugfix]
- title: 💅 样式
labels: [style]
- title: 📄 文档
labels: [docs]
- title: ⚡️ 性能
labels: [perf]
- title: 🧪 测试
labels: [test]
- title: ♻️ 重构
labels: [refactor]
- title: 📦 构建
labels: [build]
- title: 🚨 补丁
labels: [patch, hotfix]
- title: 🌐 发布
labels: [release, publish]
- title: 🔧 流程
labels: [ci, cd, workflow]
- title: ⚙️ 配置
labels: [config, chore]
- title: 📁 文件
labels: [file]
- title: 🎨 格式化
labels: [format]
- title: 🔀 其他
labels: [other, misc]

View File

@ -1,25 +0,0 @@
name: Auto Merge aliyun
on:
push:
branches:
- main
workflow_dispatch: # 手动触发
jobs:
auto-merge:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.GH_TOKEN_AUTO_MERGE }}
- name: Merge main into aliyun
run: |
git config user.name "GitHub Actions"
git config user.email "actions@github.com"
git checkout aliyun
git merge main --no-ff -m "Auto merge main into aliyun"
git push origin aliyun

80
.github/workflows/auto-merge.yml vendored Normal file
View File

@ -0,0 +1,80 @@
name: Auto Merge Main to Other Branches
on:
push:
branches:
- main
workflow_dispatch: # 手动触发
jobs:
merge-to-i18n:
name: Merge main into i18n
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.GH_TOKEN_AUTO_MERGE }}
- name: Merge main into i18n
run: |
git config user.name "GitHub Actions"
git config user.email "actions@github.com"
git checkout i18n
git merge main --no-ff -m "Auto merge main into i18n"
git push origin i18n
merge-to-base-sard-ui:
name: Merge main into base-sard-ui
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.GH_TOKEN_AUTO_MERGE }}
- name: Merge main into base-sard-ui
run: |
git config user.name "GitHub Actions"
git config user.email "actions@github.com"
git checkout base-sard-ui
git merge main --no-ff -m "Auto merge main into base-sard-ui"
git push origin base-sard-ui
merge-to-base-uv-ui:
name: Merge main into base-uv-ui
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.GH_TOKEN_AUTO_MERGE }}
- name: Merge main into base-uv-ui
run: |
git config user.name "GitHub Actions"
git config user.email "actions@github.com"
git checkout base-uv-ui
git merge main --no-ff -m "Auto merge main into base-uv-ui"
git push origin base-uv-ui
merge-to-base-uview-plus:
name: Merge main into base-uview-plus
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.GH_TOKEN_AUTO_MERGE }}
- name: Merge main into base-uview-plus
run: |
git config user.name "GitHub Actions"
git config user.email "actions@github.com"
git checkout base-uview-plus
git merge main --no-ff -m "Auto merge main into base-uview-plus"
git push origin base-uview-plus

View File

@ -1,63 +0,0 @@
# 构建 VitePress 站点并将其部署到 GitHub Pages 的示例工作流程
#
name: Deploy VitePress site to Pages
on:
push:
branches: [main]
# 允许你从 Actions 选项卡手动运行此工作流程
workflow_dispatch:
# 设置 GITHUB_TOKEN 的权限,以允许部署到 GitHub Pages
permissions:
contents: read
pages: write
id-token: write
# 只允许同时进行一次部署,跳过正在运行和最新队列之间的运行队列
# 但是,不要取消正在进行的运行,因为我们希望允许这些生产部署完成
concurrency:
group: pages
cancel-in-progress: false
jobs:
# 构建工作
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0 # 如果未启用 lastUpdated则不需要
- uses: pnpm/action-setup@v3 # 如果使用 pnpm请取消此区域注释
with:
version: 9
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 18
cache: pnpm
- name: Setup Pages
uses: actions/configure-pages@v4
- name: Install dependencies
run: pnpm i
- name: Build with VitePress
run: pnpm run docs:build
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: docs/.vitepress/dist
# 部署工作
deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
needs: build
runs-on: ubuntu-latest
name: Deploy
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4

2
.gitignore vendored
View File

@ -27,7 +27,7 @@ dist
docs/.vitepress/dist
docs/.vitepress/cache
types
src/types
# lock 文件还是不要了,我主要的版本写死就好了
# pnpm-lock.yaml

View File

@ -1,25 +0,0 @@
{
"$schema": "./node_modules/oxlint/configuration_schema.json",
"extends": ["config:recommended"],
"plugins": ["import", "typescript", "unicorn"],
"rules": {
"no-console": "off",
"no-unused-vars": "off"
},
"env": {
"es6": true
},
"globals": {
"foo": "readonly"
},
"ignorePatterns": ["node_modules", "dist", "src/static/**", "src/uni_modules/**"],
"settings": {},
"overrides": [
{
"files": ["*.test.ts", "*.spec.ts"],
"rules": {
"@typescript-eslint/no-explicit-any": "off"
}
}
]
}

View File

@ -1,3 +1,5 @@
node_modules
# unplugin-auto-import 生成的类型文件,每次提交都改变,所以加入这里吧,与 .gitignore 配合使用
auto-import.d.ts

78
.vscode/settings.json vendored
View File

@ -1,14 +1,7 @@
{
// prettier
"editor.defaultFormatter": "esbenp.prettier-vscode",
//
"editor.formatOnSave": true,
//
"editor.codeActionsOnSave": {
"source.fixAll": "explicit",
"source.fixAll.eslint": "explicit",
"source.fixAll.stylelint": "explicit"
},
// stylelint
"stylelint.validate": ["css", "scss", "vue", "html"], // package.jsonscripts
"stylelint.enable": true,
@ -36,7 +29,6 @@
"manifest.json": "jsonc" // manifest.json
},
"cSpell.words": [
"aliyun",
"Aplipay",
"climblee",
"commitlint",
@ -49,8 +41,8 @@
"tabbar",
"Toutiao",
"unibest",
"uview",
"uvui",
"vitepress",
"Wechat",
"WechatMiniprogram",
"Weixin"
@ -61,7 +53,67 @@
"explorer.fileNesting.patterns": {
"README.md": "index.html,favicon.ico,robots.txt,CHANGELOG.md",
"pages.config.ts": "manifest.config.ts,openapi-ts-request.config.ts",
"package.json": "pnpm-lock.yaml,pnpm-workspace.yaml,LICENSE,.gitattributes,.gitignore,.gitpod.yml,CNAME,.npmrc,.browserslistrc",
".oxlintrc.json": "tsconfig.json,.commitlintrc.*,.prettier*,.editorconfig,.commitlint.cjs,.eslint*"
}
"package.json": "tsconfig.json,pnpm-lock.yaml,pnpm-workspace.yaml,LICENSE,.gitattributes,.gitignore,.gitpod.yml,CNAME,.npmrc,.browserslistrc",
"eslint.config.mjs": ".commitlintrc.*,.prettier*,.editorconfig,.commitlint.cjs,.eslint*"
},
// //
// "prettier.enable": true,
// "editor.formatOnSave": true,
// //
// "editor.codeActionsOnSave": {
// "source.fixAll": "explicit",
// "source.fixAll.eslint": "explicit",
// "source.fixAll.stylelint": "explicit"
// },
// Disable the default formatter, use eslint instead
"prettier.enable": false,
"editor.formatOnSave": false,
// Auto fix
"editor.codeActionsOnSave": {
"source.fixAll.eslint": "explicit",
"source.organizeImports": "never"
},
// Silent the stylistic rules in you IDE, but still auto fix them
"eslint.rules.customizations": [
{ "rule": "style/*", "severity": "off", "fixable": true },
{ "rule": "format/*", "severity": "off", "fixable": true },
{ "rule": "*-indent", "severity": "off", "fixable": true },
{ "rule": "*-spacing", "severity": "off", "fixable": true },
{ "rule": "*-spaces", "severity": "off", "fixable": true },
{ "rule": "*-order", "severity": "off", "fixable": true },
{ "rule": "*-dangle", "severity": "off", "fixable": true },
{ "rule": "*-newline", "severity": "off", "fixable": true },
{ "rule": "*quotes", "severity": "off", "fixable": true },
{ "rule": "*semi", "severity": "off", "fixable": true }
],
// Enable eslint for all supported languages
"eslint.validate": [
"javascript",
"javascriptreact",
"typescript",
"typescriptreact",
"vue",
"html",
"markdown",
"json",
"json5",
"jsonc",
"yaml",
"toml",
"xml",
"gql",
"graphql",
"astro",
"svelte",
"css",
"less",
"scss",
"pcss",
"postcss"
]
}

View File

@ -27,12 +27,12 @@
" },",
"}",
"</route>\n",
"<template>",
" <view class=\"\">$2</view>",
"</template>\n",
"<script lang=\"ts\" setup>",
"//$3",
"</script>\n",
"<template>",
" <view class=\"\">$2</view>",
"</template>\n",
"<style lang=\"scss\" scoped>",
"//$4",
"</style>\n",
@ -41,16 +41,28 @@
"Print unibest style": {
"scope": "vue",
"prefix": "st",
"body": ["<style lang=\"scss\" scoped>", "//", "</style>\n"],
"body": [
"<style lang=\"scss\" scoped>",
"//",
"</style>\n"
],
},
"Print unibest script": {
"scope": "vue",
"prefix": "sc",
"body": ["<script lang=\"ts\" setup>", "//$3", "</script>\n"],
"body": [
"<script lang=\"ts\" setup>",
"//$3",
"</script>\n"
],
},
"Print unibest template": {
"scope": "vue",
"prefix": "te",
"body": ["<template>", " <view class=\"\">$1</view>", "</template>\n"],
"body": [
"<template>",
" <view class=\"\">$1</view>",
"</template>\n"
],
},
}
}

1
CNAME
View File

@ -1 +0,0 @@
unibest.tech

View File

@ -22,7 +22,6 @@
[![GitHub forks](https://img.shields.io/github/forks/feige996/unibest?style=flat&logo=github)](https://github.com/feige996/unibest)
[![star](https://gitee.com/feige996/unibest/badge/star.svg?theme=dark)](https://gitee.com/feige996/unibest/stargazers)
[![fork](https://gitee.com/feige996/unibest/badge/fork.svg?theme=dark)](https://gitee.com/feige996/unibest/members)
[![star](https://gitcode.com/feige996/unibest/star/badge.svg?theme=gray)](https://gitcode.com/feige996/unibest/stargazers)
![node version](https://img.shields.io/badge/node-%3E%3D18-green)
![pnpm version](https://img.shields.io/badge/pnpm-%3E%3D7.30-green)
![GitHub package.json version (subfolder of monorepo)](https://img.shields.io/github/package-json/v/feige996/unibest)
@ -57,7 +56,7 @@
## ⚙️ 环境
- node>=18
- pnpm>=8
- pnpm>=7.30
- Vue Official>=2.1.10
- TypeScript>=5.0
@ -71,29 +70,15 @@
## 📦 运行(支持热更新)
- web平台 `pnpm dev:h5`, 然后打开 [http://localhost:9000/](http://localhost:9000/)。
- weixin平台`pnpm dev:mp-weixin` 然后打开微信开发者工具,导入本地文件夹,选择本项目的`dist/dev/mp-weixin` 文件。
- weixin平台`pnpm dev:mp` 然后打开微信开发者工具,导入本地文件夹,选择本项目的`dist/dev/mp-weixin` 文件。
- APP平台`pnpm dev:app`, 然后打开 `HBuilderX`,导入刚刚生成的`dist/dev/app` 文件夹,选择运行到模拟器(开发时优先使用),或者运行的安卓/ios基座。
## 🔗 发布
- web平台 `pnpm build:h5`,打包后的文件在 `dist/build/h5`可以放到web服务器如nginx运行。如果最终不是放在根目录可以在 `manifest.config.ts` 文件的 `h5.router.base` 属性进行修改。
- weixin平台`pnpm build:mp-weixin`, 打包后的文件在 `dist/build/mp-weixin`,然后通过微信开发者工具导入,并点击右上角的“上传”按钮进行上传。
- weixin平台`pnpm build:mp`, 打包后的文件在 `dist/build/mp-weixin`,然后通过微信开发者工具导入,并点击右上角的“上传”按钮进行上传。
- APP平台`pnpm build:app`, 然后打开 `HBuilderX`,导入刚刚生成的`dist/build/app` 文件夹,选择发行 - APP云打包。
## 🤔 如何贡献
非常欢迎您的加入!提一个 [Issue](https://github.com/feige996/unibest/issues) 或者提交一个 [Pull Request](https://github.com/feige996/unibest/pulls)
**Pull Request:**
- 1. `Fork` 代码到自己的项目下,不要直接在仓库下建分支
- 2. 请选择 `base` 分支,进行 `PR`
- 3. 提交 `PR` 前请 `rebase`,确保 `commit` 记录的整洁
- 4. 注意 `commit` 信息规范,要以 `type: 描述信息` 的形式填写,注意 `type` 得是下面规范之中的一个
- 5. 示例 `commit 信息``fix: 修复样式问题`
- 6. 可以使用项目中的 `pnpm cz` 进行 `commit` 提交
- 7. 等待作者 `review` 通过后,即可合并
## 📄 License
[MIT](https://opensource.org/license/mit/)

View File

@ -1,23 +0,0 @@
<!-- .vitepress/components/BuildInfo.vue -->
<template>
<div class="build-info" :data-build-time="buildTime" :data-version="version">
<p>构建时间: {{ buildTime }}</p>
<p>版本号: {{ version }}</p>
</div>
</template>
<script setup>
import { inject } from 'vue'
const buildTime = inject('buildTime')
const version = inject('version')
</script>
<style scoped>
.build-info {
padding: 10px;
margin-top: 20px;
text-align: center;
background-color: #f8f8f8;
}
</style>

View File

@ -1,259 +0,0 @@
import dayjs from 'dayjs'
import { defineConfig } from 'vitepress'
import llmsPlugin from 'vitepress-plugin-llms'
import packageJson from '../../package.json'
const buildTime = dayjs().format('YYYY-MM-DD HH:mm:ss')
const base = '/unibest/' // default is /
// https://vitepress.dev/reference/site-config
export default defineConfig({
lang: 'zh-CN',
base: base,
title: 'unibest 官方文档',
description: '最好用的 uniapp 开发模板',
lastUpdated: true,
cleanUrls: true,
head: [
['link', { rel: 'icon', href: `${base}favicon.ico` }],
// 增加构建信息
['meta', { name: 'build-time', content: buildTime }],
['meta', { name: 'version', content: packageJson.version }],
[
'meta',
{
name: 'keywords',
content: 'unibest, uniapp, uni-app, vue, vue3, vite,template, typescript, ts',
},
],
[
'meta',
{
name: 'author',
content: '菲鸽, 菲哥, 鸽鸽, feige996, feige996, 1020103647@qq.com',
},
],
[
'meta',
{
name: 'twitter:title',
content: '最好用的 uniapp 开发模板',
},
],
// 添加 ICP 备案信息
['meta', { name: 'icp', content: '粤ICP备2024160998号' }],
['link', { rel: 'license', href: 'https://beian.miit.gov.cn/' }],
// 百度联盟meta
['meta', { property: 'baidu_union_verify', content: '8ab9e6068e7febf94e684886f81f406f' }],
// 其他杂七杂八的 meta 标签
['meta', { name: 'twitter:card', content: 'summary_large_image' }],
['meta', { name: 'twitter:site', content: 'feige996' }],
[
'meta',
{
name: 'twitter:image:src',
content:
'https://opengraph.githubassets.com/1cac1150838995e1f7d1643c00eee51a5d884f2054f995c9d3225b07b0eddb39/feige996/unibest',
},
],
[
'meta',
{
property: 'og:image',
content:
'https://opengraph.githubassets.com/1cac1150838995e1f7d1643c00eee51a5d884f2054f995c9d3225b07b0eddb39/feige996/unibest',
},
],
[
'meta',
{
property: 'og:image:alt',
content: '最好用的 uniapp 开发模板',
},
],
['meta', { property: 'og:image:width', content: '1200' }],
['meta', { property: 'og:image:height', content: '600' }],
['meta', { property: 'og:site_name', content: 'GitHub' }],
['meta', { property: 'og:type', content: 'object' }],
[
'meta',
{
property: 'og:title',
content: '最好用的 uniapp 开发模板',
},
],
['meta', { property: 'og:url', content: 'https://github.com/feige996/unibest' }],
[
'meta',
{
property: 'og:description',
content: '最好用的 uniapp 开发模板',
},
],
// 下面是百度统计代码
['script', { async: '', src: 'https://hm.baidu.com/hm.js?081c2ec121383d9e7d5a35c5833ab6ff' }],
// 下面是不蒜子统计代码
['script', { async: '', src: '//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js' }],
],
markdown: {
theme: {
light: 'vitesse-light',
dark: 'vitesse-dark',
},
},
themeConfig: {
// https://vitepress.dev/reference/default-theme-config
logo: '/logo.svg',
siteTitle: 'unibest',
nav: [
{
text: '快速开始',
link: '/base/2-start',
activeMatch: '/base',
},
{
text: '🥤 打赏',
link: '/advanced/rewards/rewards',
},
{
text: '更新日志',
link: '/changelog/CHANGELOG',
},
{
text: '备用地址',
items: [
{ text: 'unibest.tech(首选)', link: 'https://unibest.tech' },
{ text: 'github page(备选)', link: 'https://feige996.github.io/unibest/' },
],
},
],
sidebar: [
{
text: '基础·必看',
base: '/base/',
items: [
{ text: '介绍', link: '1-introduction' },
{
text: '快速开始',
link: '2-start',
},
{ text: 'uni 插件', link: '3-plugin' },
{ text: '样式篇', link: '4-style' },
{ text: '样式篇2', link: '4-style2' },
{ text: '图标篇', link: '5-icons' },
{ text: 'SVG篇', link: '6-svg' },
{ text: 'UI库选型篇', link: 'ui/ui' },
{ text: 'UI库替换篇', link: '7-ui' },
{ text: '请求篇', link: '8-request' },
{ text: '状态篇', link: '9-state' },
{ text: '多语言篇', link: '10-i18n' },
{ text: '运行发布', link: '11-build' },
{ text: '环境变量', link: '12-env' },
{ text: 'hbx 模板', link: '13-hbx' },
{ text: '常见问题', link: '14-faq' },
{ text: '常见问题2', link: '15-faq' },
{ text: '小程序标识', link: '16-terminology' },
{ text: '自动生成代码', link: '17-generate' },
{ text: 'App 专题', link: '18-app' },
{ text: '最佳实践', link: '20-best' },
],
},
{
text: '更新日志',
link: '/changelog/CHANGELOG',
},
{
text: '社交',
base: '/advanced/',
items: [
{ text: '🥤 打赏', link: 'rewards/rewards' },
{ text: '微信交流群', link: 'wechat/wechat' },
{ text: '赞助榜', link: 'sponsor/sponsor' },
],
},
{
text: '延伸',
base: '/other/',
items: [
{ text: '相关链接', link: 'links/links' },
{ text: '图片占位图', link: 'image/image' },
{ text: 'iconfont详细版', link: 'iconfont/iconfont' },
{ text: 'Git 提交优化', link: 'czg/czg' },
{ text: '文件资源展示优化', link: 'files/files' },
{ text: 'unibest博客', link: 'blog' },
],
},
],
footer: {
message: 'Released under the MIT License.',
copyright: 'Copyright (c) 2024 菲鸽',
},
socialLinks: [
{ icon: 'github', link: 'https://github.com/feige996/unibest' },
{
icon: {
svg: `<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 24 24"><path fill="currentColor" d="M11.984 0A12 12 0 0 0 0 12a12 12 0 0 0 12 12a12 12 0 0 0 12-12A12 12 0 0 0 12 0a12 12 0 0 0-.016 0m6.09 5.333c.328 0 .593.266.592.593v1.482a.594.594 0 0 1-.593.592H9.777c-.982 0-1.778.796-1.778 1.778v5.63c0 .327.266.592.593.592h5.63c.982 0 1.778-.796 1.778-1.778v-.296a.593.593 0 0 0-.592-.593h-4.15a.592.592 0 0 1-.592-.592v-1.482a.593.593 0 0 1 .593-.592h6.815c.327 0 .593.265.593.592v3.408a4 4 0 0 1-4 4H5.926a.593.593 0 0 1-.593-.593V9.778a4.444 4.444 0 0 1 4.445-4.444h8.296Z"/></svg>`,
},
link: 'https://gitee.com/feige996/unibest',
ariaLabel: 'Gitee',
},
{
icon: {
svg: `<svg width="28" height="28" viewBox="0 0 28 28" fill="none" xmlns="http://www.w3.org/2000/svg">
<path fill-rule="evenodd" clip-rule="evenodd" d="M18.059 5.80628C18.2234 5.71425 18.3973 5.61696 18.585 5.51037C18.6076 5.63327 18.6297 5.74058 18.6497 5.83784C18.685 6.00943 18.714 6.15059 18.728 6.29005C18.8392 7.50125 19.448 8.39222 20.3108 8.59286C21.5726 8.88583 22.7623 8.40159 23.4033 7.33318C24.1733 6.05123 23.839 4.4812 22.5279 3.53618C18.8826 0.907049 14.8777 0.18191 10.5636 1.44819C1.2616 4.1927 -1.92121 15.6199 4.68062 22.6274C7.50507 25.6249 11.0914 26.9182 15.1624 26.8204C20.3774 26.6979 24.1333 24.099 26.5309 19.5947C28.2308 16.3988 26.3829 12.9055 22.8439 12.1795C20.8227 11.7726 18.7559 11.6405 16.6993 11.7869C16.0151 11.8526 15.3509 12.0547 14.7459 12.3811C14.0691 12.7324 13.8734 13.4614 13.9493 14.1838C14.02 14.8421 14.5247 15.2369 15.1258 15.3362C16.3361 15.5256 17.5609 15.6357 18.7833 15.7361C19.1371 15.7659 19.4942 15.7694 19.8507 15.773C20.3623 15.7781 20.873 15.7832 21.3718 15.8657C22.7949 16.1009 23.2836 17.2557 22.5517 18.4911C22.3724 18.7882 22.1633 19.0662 21.9277 19.3209C20.9703 20.3738 19.7183 21.1144 18.3344 21.4465C15.8084 22.0649 13.2798 22.0996 10.7655 21.3054C7.90238 20.4021 6.19549 18.2991 6.13552 15.4682C6.1131 13.7223 6.55634 12.002 7.41963 10.4843C7.80967 9.77686 8.02376 9.04827 7.96359 8.24664C7.93826 7.90488 7.92423 7.56273 7.90915 7.19506C7.90113 6.99938 7.89281 6.79647 7.88233 6.58254C8.17231 6.6434 8.45871 6.72023 8.74022 6.81271C9.83531 7.25229 10.9132 7.45284 12.0986 7.13019C12.7728 6.96895 13.4697 6.92433 14.159 6.99829C15.269 7.08878 16.3785 6.81759 17.3215 6.22521C17.5569 6.08724 17.7963 5.9533 18.059 5.80628Z" fill="#99989E"/>
</svg>
`,
},
link: 'https://gitcode.com/feige996/unibest',
ariaLabel: 'GitCode',
},
// #1f80ff 是掘金的 logo 的颜色
{
icon: {
svg: `<svg class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="2449" width="200" height="200">
<path fill="#1f80ff" d="M465.189 161.792c-22.967 18.14-44.325 35.109-47.397 37.742l-5.851 4.68 10.971 8.632c5.998 4.827 11.85 9.508 13.02 10.532 1.17 1.024 17.993 14.336 37.156 29.696l34.962 27.795 5.267-3.95c2.925-2.194 23.259-18.432 45.348-35.986 21.943-17.555 41.253-32.768 42.716-33.646 1.609-1.024 2.779-2.194 2.779-2.78 0-0.438-9.655-8.63-21.504-17.846-11.995-9.363-22.674-17.847-23.845-18.871-15.945-13.02-49.737-39.059-50.76-39.059-0.586 0.147-19.896 14.922-42.862 33.061z m233.325 180.37C507.465 493.275 508.928 492.105 505.417 489.911c-3.072-1.902-11.556-8.485-64.073-50.03-9.07-7.168-18.578-14.775-21.358-16.823-2.78-2.194-8.777-6.875-13.312-10.532-4.68-3.657-10.679-8.339-13.312-10.533-13.165-10.24-71.095-56.027-102.107-80.457-5.852-4.681-11.41-8.485-12.142-8.485-0.731 0-10.971 7.754-22.674 17.116-11.703 9.508-22.674 18.286-24.284 19.456-1.755 1.17-5.12 3.95-7.46 6.144-2.34 2.34-4.828 4.096-5.413 4.096-3.072 0-0.731 3.072 6.437 8.777 4.096 3.218 8.777 6.875 10.094 8.046 1.316 1.024 10.24 8.045 19.748 15.506s23.26 18.286 30.428 23.99c19.31 15.215 31.89 25.308 127.853 101.084 47.836 37.742 88.796 69.779 90.844 71.095 3.657 2.487 3.95 2.487 7.46-0.292a1041.42 1041.42 0 0 0 16.092-12.727c6.875-5.413 14.775-11.703 17.554-13.897 30.135-23.699 80.018-63.05 81.774-64.512 1.17-1.024 12.434-9.802 24.868-19.603s37.888-29.696 56.32-44.324c18.579-14.629 46.227-36.425 61.733-48.567 15.506-12.142 27.794-22.528 27.502-23.26-0.878-1.17-57.637-47.104-59.978-48.274-0.731-0.439-18.578 12.727-39.497 29.257z"></path>
<path fill="#1f80ff" d="M57.93 489.326c-15.215 12.288-28.527 23.405-29.697 24.576-2.34 2.194-5.412-0.44 80.018 66.852 33.207 26.185 32.622 25.747 57.637 45.495 10.386 8.192 36.279 28.672 57.783 45.495 38.18 30.135 44.91 35.401 52.663 41.545 2.048 1.756 22.967 18.14 46.372 36.572 23.26 18.432 74.167 58.514 112.933 89.088 38.912 30.573 71.095 55.734 71.826 56.027 0.732 0.293 7.46-4.389 14.921-10.386 21.797-16.97 90.259-70.949 101.523-79.872 5.705-4.535 12.873-10.24 15.945-12.58 3.072-2.488 6.436-5.12 7.314-5.852 0.878-0.878 11.85-9.509 24.283-19.31 20.773-16.091 59.1-46.226 64.366-50.615 1.17-1.024 5.12-4.096 8.777-6.875 3.657-2.78 7.9-6.29 9.509-7.607 1.609-1.317 14.775-11.703 29.257-23.113 29.11-22.82 42.277-33.207 88.503-69.632 17.262-13.605 32.475-25.454 33.646-26.478 2.486-2.048 31.451-24.869 44.617-35.255 4.827-3.657 9.07-7.168 9.508-7.607 0.44-0.585 5.998-4.827 12.435-9.8 6.436-4.828 13.165-10.24 15.067-11.85l3.365-2.926-9.948-7.753c-5.412-4.388-10.24-8.192-10.679-8.63-1.17-1.317-22.381-18.433-30.135-24.284-3.95-3.072-7.314-5.998-7.606-6.73-1.317-3.071-6.73 0.147-29.258 17.994-13.458 10.532-25.746 20.187-27.355 21.504-1.61 1.463-10.533 8.338-19.749 15.652-9.216 7.168-17.115 13.459-17.554 13.898-0.439 0.438-6.583 5.412-13.897 10.971-7.168 5.559-15.214 11.703-17.7 13.75-4.974 4.097-5.413 4.39-20.334 16.239-5.56 4.388-11.264 8.777-12.435 9.8-1.17 1.025-20.333 16.092-42.422 33.354-22.09 17.408-41.546 32.768-43.155 34.084-1.609 1.463-14.482 11.557-28.525 22.528s-40.814 32.037-59.539 46.812c-18.578 14.775-42.276 33.353-52.516 41.399s-23.26 18.285-28.965 22.82l-10.386 8.339-4.389-3.072c-2.34-1.756-4.68-3.511-5.12-3.95-0.439-0.439-4.973-4.096-10.24-8.046-11.849-9.216-14.482-11.264-16.676-13.166-0.878-0.877-4.243-3.51-7.46-5.851-3.22-2.487-6.145-4.681-6.584-5.12-0.439-0.439-6.875-5.705-14.482-11.703-7.607-5.851-14.921-11.556-16.091-12.58-1.317-1.17-17.116-13.605-35.255-27.795-17.993-14.19-35.109-27.648-38.035-29.842-5.705-4.681-33.499-26.624-125.074-98.743-34.523-27.209-72.704-57.344-84.846-66.852-49.737-39.498-55.15-43.594-56.905-43.447-0.877 0-14.043 10.24-29.257 22.528z" >
</path>
</svg>`,
},
link: 'https://juejin.cn/user/3263006241460792/posts',
ariaLabel: '菲鸽的掘金主页',
},
],
search: {
provider: 'local',
options: {
locales: {
root: {
translations: {
button: {
buttonText: '搜索文档',
buttonAriaLabel: '搜索文档',
},
modal: {
displayDetails: '显示详情',
resetButtonTitle: '清除查询条件',
backButtonTitle: '返回',
noResultsText: '无法找到相关结果',
footer: {
selectText: '选择',
selectKeyAriaLabel: '选择',
navigateText: '切换',
navigateUpKeyAriaLabel: '切换',
navigateDownKeyAriaLabel: '切换',
closeText: '关闭',
closeKeyAriaLabel: '关闭',
},
},
},
},
},
},
},
},
vite: {
// 其他配置...
plugins: [llmsPlugin() as any],
},
})

View File

@ -1,26 +0,0 @@
<!-- .vitepress/layouts/Default.vue -->
<template>
<div class="custom-layout">
<VPLayout>
<template #layout-bottom>
<footer class="footer">
<p>© 2024 菲鸽科技</p>
<p><a href="https://beian.miit.gov.cn" target="_blank">粤ICP备2024160998号</a></p>
<BuildInfo />
</footer>
</template>
</VPLayout>
</div>
</template>
<script setup>
import VPLayout from '@theme-default/Layout.vue'
</script>
<style scoped>
.footer {
padding: 20px;
text-align: center;
background-color: #f8f8f8;
}
</style>

View File

@ -1,21 +0,0 @@
<template>
<img :src="freshUrl" :alt="alt" />
</template>
<script setup>
import { computed } from 'vue'
const props = defineProps({
src: {
type: String,
required: true,
},
alt: {
type: String,
default: '',
},
})
const freshUrl = computed(() => {
return `${props.src}?t=${Date.now()}`
})
</script>

View File

@ -1,50 +0,0 @@
<template>
<p class="home-star">
<a href="https://github.com/codercup/unibest">
<img
alt="GitHub Repo stars"
src="https://img.shields.io/github/stars/codercup/unibest?logo=github&color=%234d80f0&link=https%3A%2F%2Fgithub.com%2Fcodercup%2Funibest"
/>
</a>
<a href="https://github.com/feige996/unibest">
<img
alt="GitHub Repo stars"
src="https://img.shields.io/github/stars/feige996/unibest?logo=github&color=%234d80f0&link=https%3A%2F%2Fgithub.com%2Ffeige996%2Funibest"
/>
</a>
<a href="https://gitee.com/codercup/unibest/stargazers">
<img src="https://gitee.com/codercup/unibest/badge/star.svg?theme=gray" alt="star" />
</a>
<a href="https://gitcode.com/feige996/unibest/stargazers">
<img src="https://gitcode.com/feige996/unibest/star/badge.svg?theme=gray" alt="star" />
</a>
<!-- <a href="https://github.com/feige996/unibest">
<img alt="GitHub" src="https://img.shields.io/github/license/feige996/unibest?logo=github" />
</a> -->
<a href="https://www.npmjs.com/package/create-unibest">
<img
alt="npm"
src="https://img.shields.io/npm/dw/create-unibest?logo=npm&link=https%3A%2F%2Fwww.npmjs.com%2Fpackage%2Fcreate-unibest"
/>
</a>
<!-- <a href="https://www.npmjs.com/package/create-unibest">
<img src="https://img.shields.io/npm/dt/create-unibest?style=flat-square" />
</a> -->
</p>
</template>
<style>
.home-star {
display: flex;
flex-wrap: wrap;
gap: 12px;
align-items: center;
justify-content: center;
padding-top: 24px;
}
</style>

View File

@ -1,20 +0,0 @@
<script setup lang="ts">
import { version } from '../../../../package.json'
</script>
<template>
<span
style="
display: inline-block;
padding: 0px 8px;
margin-left: 4px;
font-size: 10px;
font-weight: 700;
color: var(--vp-button-brand-text);
background-color: var(--vp-button-brand-bg);
border-radius: 16px;
"
>
{{ version }}
</span>
</template>

View File

@ -1,84 +0,0 @@
/**
* Colors
* -------------------------------------------------------------------------- */
:root {
--vp-c-brand-1: hsl(128, 56%, 38%);
--vp-c-brand-2: hsl(128, 56%, 55%);
--vp-c-brand-3: hsl(128, 56%, 45%);
--vp-c-brand-soft: rgba(98, 133, 208, 0.16);
}
/**
* Component: Home
* -------------------------------------------------------------------------- */
:root {
--vp-home-hero-name-color: transparent;
--vp-home-hero-name-background: -webkit-linear-gradient(
120deg,
hsl(128, 56%, 38%) 30%,
hsl(128, 56%, 60%)
);
--vp-home-hero-image-background-image: linear-gradient(
120deg,
hsl(100, 56%, 45%) 30%,
hsl(120, 56%, 38%)
);
--vp-home-hero-image-filter: blur(40px);
}
@media (min-width: 640px) {
:root {
--vp-home-hero-image-filter: blur(56px);
}
}
@media (min-width: 960px) {
:root {
--vp-home-hero-image-filter: blur(72px);
}
}
.md-center > p {
display: flex;
/* justify-content: center; */
flex-wrap: wrap;
margin-top: -4px;
margin-right: -4px;
}
.md-center img {
display: inline-block;
height: 1.4em;
margin-top: 4px;
margin-right: 4px;
line-height: 1.6;
}
.md-center2 img {
display: inline-block;
margin-top: 4px;
margin-right: 4px;
}
.busuanzi_container {
display: flex;
justify-content: space-around;
opacity: 0.3;
}
@media (max-width: 960px) {
.busuanzi_container {
flex-direction: column;
padding-top: 12px;
padding-left: 30px;
}
}
@media (min-width: 961px) {
.busuanzi_container {
height: 60px;
line-height: 60px;
}
}
.icp_container {
display: flex;
align-items: center;
justify-content: center;
}

View File

@ -1,24 +0,0 @@
// https://vitepress.dev/guide/custom-theme
import type { Theme } from 'vitepress'
import DefaultTheme from 'vitepress/theme'
import { h } from 'vue'
import './custom.css'
import HomeStar from './components/HomeStar.vue'
import NavBarTitleAfter from './components/NavBarTitleAfter.vue'
import FreshImage from './components/FreshImage.vue'
export default {
extends: DefaultTheme,
Layout: () => {
return h(DefaultTheme.Layout, null, {
// https://vitepress.dev/guide/extending-default-theme#layout-slots
'home-hero-info-after': () => h(HomeStar),
'nav-bar-title-after': () => h(NavBarTitleAfter),
})
},
enhanceApp({ app, router, siteData }) {
// ...
app.component('FreshImage', FreshImage)
},
} satisfies Theme

Binary file not shown.

Before

Width:  |  Height:  |  Size: 282 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 358 KiB

View File

@ -1,30 +0,0 @@
# 关于我
我叫 `菲鸽`,江西宋城人。前端工程师,全栈实践者,精通 `vue``react``uniapp``typescript``小程序``Nodejs` 等。
热爱编程,喜欢分享,平时比较宅,喜欢撸代码,偶尔打篮球和玩王者荣耀。
<!-- ![alt text](image-2.png) -->
## 找到我
- Github: [feige996](https://github.com/feige996)
- Gitee: [feige996](https://gitee.com/feige996)
- 掘金:[菲鸽](https://juejin.cn/user/3263006241460792/posts)
- 微信:`feige996` = `菲鸽`,大家都叫我 `鸽鸽`
- QQ`1020103647`
- 邮箱:`1020103647@qq.com`
## 微信公众号
微信公众号:`菲鸽爱编程`
![微信公众号](./screenshots/wx-gzh.png)
<!-- ## 靓照
五一陪儿子玩,不料给我拍出来美美的靓照,正好没有合适的照片,就用它了。
`2024年5月5日`,最新鲜的照片了。
![alt text](image-3.png) -->

Binary file not shown.

Before

Width:  |  Height:  |  Size: 141 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 286 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 83 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 114 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 159 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 116 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 134 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 154 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 147 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 147 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 146 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 146 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 146 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 141 KiB

View File

@ -1,8 +0,0 @@
# 🥤 打赏
如果本项目对你的工作起到了帮助,加快了您的项目进展,解决了您的问题,欢迎 `打赏`
<p align='center'>
<img alt="special sponsor appwrite" src="./assets/pay-1.png" height="330" style="display:inline-block; height:330px;">
<img alt="special sponsor appwrite" src="./assets/pay-2.png" height="330" style="display:inline-block; height:330px; margin-left:10px;">
</p>

View File

@ -1,62 +0,0 @@
# 赞助榜
感谢所有赞助者!
如需更改展示信息,或者需要展示更详细的信息,请联系我。
如果需要展示产品、博客、友链啥的,也可以联系我,很乐意为您展示。
> 金牌赞助者将额外获得首页产品展示位。
## 200 元
- 麦可
- 程序员云创 [https://www.codecommitter.com/](https://www.codecommitter.com/)
- 海鲜™ 深圳金济福科技有限公司[https://www.jinjifu.com/](https://www.jinjifu.com/)
## 50 元
- \*皮
- 暗月隐落 [飞鸟快验 - 一个通用网络验证后台](https://www.fnkuaiyan.cn)
## 20 元
- \*捷
- \*度
- \*恼
## 10-20 元
- 薛柳(15)
- 是魔王哒(12)
## 10 元
- \*辛
- \*y
- \*边
## 5-10 元
- Leo 9.90
- \*熙 6.66
- 阿森纳 6.66
- I am 小萝北 ²º²4 6.60
- SUMMER 5
- \*峰 5
- 阿云 5
- nuYoah 5
- 许志成 5
- JY_en_ke_hao 5
## 2 元及以下
`15` 人,这里不一一列出。(如果希望展示,请联系我)
## 红包打赏
还有一部分群友是发 `专属红包` 打赏的,这里没有统计,如果需要展示,请联系我。
---
> 再次感谢所有赞助者、打赏者!

View File

@ -1,12 +0,0 @@
# 微信交流群
千万记得 `先看一遍文档`,可以解决大部分基础疑问。
<!-- ![alt text](https://oss.laf.run/ukw0y1-site/unibest-discussion-group/wechat.jpg) -->
<!-- 上面的固定地址的方式会导致刷新后还是旧的图片,所以使用下面这种动态地址的方式。 -->
<FreshImage src="https://oss.laf.run/ukw0y1-site/unibest-discussion-group/wechat.jpg" alt="微信群二维码" />
> 如果上面的微信群满了,请使用下面的 QQ 群QQ 群不会过期,长期有效。
①②③ 群已满,下面是 ④ 群。
![alt text](https://oss.laf.run/ukw0y1-site/unibest-discussion-group/qq.jpg)

View File

@ -1,208 +0,0 @@
# 简介
<div class="md-center" style="margin-top: 20px;">
[![GitHub Repo stars](https://img.shields.io/github/stars/codercup/unibest?style=flat&logo=github)](https://github.com/codercup/unibest)
[![GitHub Repo stars](https://img.shields.io/github/stars/feige996/unibest?style=flat&logo=github)](https://github.com/feige996/unibest)
[![star](https://gitee.com/codercup/unibest/badge/star.svg?theme=dark)](https://gitee.com/codercup/unibest)
![node version](https://img.shields.io/badge/node-%3E%3D18-green)
![pnpm version](https://img.shields.io/badge/pnpm-%3E%3D7.30-green)
![GitHub License](https://img.shields.io/github/license/codercup/unibest)
</div>
> 上面前 2 个 `star` 分别是旧仓库 `codercup` 和新仓库 `feige996``star` 数。
`unibest` 是最好的 `uniapp` 开发框架,由 `uniapp` + `Vue3` + `Ts` + `Vite5` + `UnoCss` + `VSCode`(可选 `webstorm`) + `uni插件`+ `wot-ui`(可选其他 UI 库)构建,集成了多种工具和技术,使用了最新的前端技术栈,无需依靠 `HBuilderX`,通过命令行方式即可运行 `web``小程序``App`。(注:`App` 还是需要 `HBuilderX`
`unibest` 内置了 `约定式路由``layout布局``请求封装``请求拦截``登录拦截``UnoCSS``i18n多语言` 等基础功能,提供了 `代码提示``自动格式化``统一配置``代码片段` 等辅助功能,让你编写 `uniapp` 拥有 `best` 体验 `unibest 的由来`)。
> `unibest` 目前支持 `H5``小程序``App`
::: tip ⭐⭐⭐⭐⭐
如果 `unibest` 对您有帮助,希望你可以去 **Github** 或者 **Gitee(码云)** 帮我点个 ⭐ ,这将是对我极大的鼓励。
<!-- - github - feige996/unibest -->
[![star](https://img.shields.io/github/stars/feige996/unibest?style=flat&logo=github)](https://github.com/feige996/unibest)
<!-- - gitee - feige996/unibest -->
[![star](https://gitee.com/feige996/unibest/badge/star.svg?theme=dark)](https://gitee.com/feige996/unibest)
:::
::: tip 🌟🌟🌟🌟🌟
旧的文档地址 [codercup/unibest](https://codercup.github.io/unibest-docs/)不再维护,尽量使用新地址[unibest.tech](https://unibest.tech)。
:::
## ⭐ Star History
同类模板对比实时地址:[https://www.star-history.com/#Ares-Chang/uni-vitesse&uni-helper/vitesse-uni-app&codercup/unibest&feige996/unibest&DaMaiCoding/uni-plus&Date](https://www.star-history.com/#Ares-Chang/uni-vitesse&uni-helper/vitesse-uni-app&codercup/unibest&feige996/unibest&DaMaiCoding/uni-plus&Date)
如图所示,两个高高的都是 `unibest`,分别是新旧仓库。
黄色的是旧的 `codercup`,秘钥丢失,进不去了。粉色的新的仓库(`feige996`),目前正在积极维护。
[![Star History Chart](https://api.star-history.com/svg?repos=Ares-Chang/uni-vitesse,uni-helper/vitesse-uni-app,codercup/unibest,feige996/unibest,DaMaiCoding/uni-plus&type=Date)](https://www.star-history.com/#Ares-Chang/uni-vitesse&uni-helper/vitesse-uni-app&codercup/unibest&feige996/unibest&DaMaiCoding/uni-plus&Date)
## 🗂 生成过程
`unibest` 由最初始的官方 cli 脚手架模板生成,执行的命令如下:
```sh
npx degit dcloudio/uni-preset-vue#vite-ts my-vue3-project
```
`uniapp` 官方链接:[点击跳转 - quickstart-cli](https://uniapp.dcloud.net.cn/quickstart-cli.html)
在官方生成的项目基础上,增加了如下内容:
- 前端基础配置六件套
- prettier
- eslint
- stylelint
- husky
- lint-staged
- commitlint
- UnoCSS
- UnoCSS Icons
- Uni 插件
- vite-plugin-uni-pages
- vite-plugin-uni-layouts
- vite-plugin-uni-manifest
- vite-plugin-uni-platform
- UI 库(默认 `wot-ui`,支持替换其他 `UI库`)
- pinia + pinia-plugin-persistedstate
- 通用功能
- 请求封装
- 请求拦截
- 路由拦截
## ✨ 特性
- ⚡️ [Vue 3](https://github.com/vuejs/core), [Vite](https://github.com/vitejs/vite), [pnpm](https://pnpm.io/), [esbuild](https://github.com/evanw/esbuild) - 就是快!
- 🔥 最新语法 - `<script lang="ts" setup>` 语法
- 🎨 [UnoCSS](https://unocss.dev/) - 高性能且极具灵活性的即时原子化 CSS 引擎
- 😃 [UnoCSS Icons](https://unocss.dev/presets/icons) & [icones](https://icones.js.org/) - 海量图标供你选择
- 🍍 [pinia](https://pinia.vuejs.org/) & [pinia-plugin-persistedstate](https://prazdevs.github.io/pinia-plugin-persistedstate/zh/guide/) - 全端适配的全局数据管理
- 🗂 `uni.request` 请求封装 - 一键引入,快捷使用
- 📦 `路由拦截` 基础封装,支持扩展,快捷使用,拒绝黑盒
- 📥 [API 自动加载](https://github.com/antfu/unplugin-auto-import) - 直接使用 Composition API 无需引入
- 🎉 `v3` Code Snippets 加快你的页面生成
- 🦾 `Pritter` & `ESLint` & `Stylelint` & `husky` & `lint-staged` + `commitlint` - 保证代码质量
- 🌈 `TypeScript` 加持,同时又兼容 `js` ,同时满足不同人群
- 💡 `ES6 import` 自动排序,`css 属性` 自动排序,增强编码一致性
- 🖥 `多环境` 配置分开,想则怎么配置就怎么配置
## 📦 目录结构
通过 `tree -I node_modules -I dist -I .git -a > tree.md` 命令生成。
```txt
.
├── .editorconfig
├── .eslintignore
├── .eslintrc-auto-import.json
├── .eslintrc.cjs
├── .gitignore
├── .husky
├── .npmrc
├── .prettierignore
├── .prettierrc.cjs
├── .stylelintignore
├── .stylelintrc.cjs
├── .vscode
├── LICENSE
├── README.md
├── commitlint.config.cjs
├── env
│   ├── .env
│   ├── .env.development
│   ├── .env.production
│   └── .env.test
├── favicon.ico
├── index.html
├── manifest.config.ts
├── package.json
├── pages.config.ts
├── src
│   ├── App.vue
│   ├── components
│   │   └── .gitkeep
│   ├── env.d.ts
│   ├── hooks
│   │   ├── .gitkeep
│   │   ├── useRequest.ts
│   │   └── useUpload.ts
│   ├── interceptors
│   │   ├── index.ts
│   │   ├── prototype.ts
│   │   ├── request.ts
│   │   └── route.ts
│   ├── layouts
│   │   ├── default.vue
│   │   └── demo.vue
│   ├── main.ts
│   ├── manifest.json
│   ├── pages
│   │   ├── about
│   │   │   ├── about.vue
│   │   │   └── components
│   │   │   ├── request.vue
│   │   │   └── upload.vue
│   │   └── index
│   │   └── index.vue
│   ├── pages-sub
│   │   └── demo
│   │   └── index.vue
│   ├── pages.json
│   ├── service
│   │   └── index
│   │   └── foo.ts
│   ├── static
│   │   ├── images
│   │   │   └── .gitkeep
│   │   ├── logo.svg
│   │   └── tabbar
│   │   ├── example.png
│   │   ├── exampleHL.png
│   │   ├── home.png
│   │   ├── homeHL.png
│   │   ├── personal.png
│   │   └── personalHL.png
│   ├── store
│   │   ├── index.ts
│   │   └── user.ts
│   ├── style
│   │   └── index.scss
│   ├── types
│   │   ├── auto-import.d.ts
│   │   ├── global.d.ts
│   │   ├── shims-uni.d.ts
│   │   └── uni-pages.d.ts
│   ├── typings.ts
│   ├── uni.scss
│   ├── uni_modules
│   │   └── .gitkeep
│   └── utils
│   ├── http.ts
│   ├── index.ts
│   └── platform.ts
├── tsconfig.json
├── uni-pages.d.ts
├── uno.config.ts
└── vite.config.ts
```

View File

@ -1,163 +0,0 @@
# 多语言篇
`多语言` 是一个常见的需求, `unibest` 专门开发了一个 `i18n`模板,可以直接生成 `多语言模板项目`
```sh
pnpm create unibest my-project -t i18n
```
`vue组件` 里面使用方式如下:
```html
<view class="m-4">{{ $t('app.name') }}</view>
```
`非vue组件` 里面怎么使用呢?比如 `ts` 文件。
这时需要用到作者编写的 `translate` 函数,使用方式如下:
```ts
import { translate as t } from '@/locale/index'
/** 非vue 文件使用 i18n */
export const testI18n = () => {
console.log(t('app.name'))
// 下面同样生效
uni.showModal({
title: 'i18n 测试',
content: t('app.name'),
})
}
```
上面基本的使用都是没问题的,但是传递参数时,只有 `H5端` 生效,`其他端` 是不生效的,代码如下:
```html
<view class="m-4">{{ $t('weight', { heavy: 100 }) }}</view>
```
`H5端` 效果如下,正常显示:
![alt text](./assets/10-1.png)
`非H5端` 效果如下,异常显示:
![alt text](./assets/10-2.png)
下面我们就来处理这个问题。
## 多语言传参
上面提到 `vue-i18n``非H5端` 传参时显示异常,那我们就来处理一下,主要方式就是通过 `正则` 替换 `多语言字符串`
编写一个函数 `formatI18n`,如下:
```ts
/**
* formatI18n('我是{name},身高{detail.height},体重{detail.weight}',{name:'张三',detail:{height:178,weight:'75kg'}})
* 暂不支持数组
* @param template 多语言模板字符串eg: `我是{name}`
* @param obj 需要传递的对象里面的key与多语言字符串对应eg: `{name:'菲鸽'}`
* @returns
*/
export function formatI18n(template, data) {
const match = /\{(.*?)\}/g.exec(template)
if (match) {
const variableList = match[0].replace('{', '').replace('}', '').split('.')
let result = data
for (let i = 0; i < variableList.length; i++) {
result = result[variableList[i]] || ''
}
return formatStr(template.replace(match[0], result), data)
} else {
return template
}
}
```
`vue组件` 里面使用方式如下:
```html
<view class="m-4">{{ formatI18n(translate('introduction'), user) }}</view>
```
用到的函数引入如下:
```js
import { formatI18n, translate } from '@/locale/index'
```
对应的 en.json 文件如下:
```json
{ "introduction": "I am {name},height:{detail.height},weight:{detail.weight}" }
```
`user` 对象如下:
```js
{name:'张三',detail:{height:178,weight:'75kg'}}
```
这样,在 `H5端``非H5端` 都能正常显示,如下:
![alt text](./assets/10-3.png)
very good !
## 导航栏标题
目前发现 `导航栏标题``小程序端` 不会跟随多语言切换而切换,比如说刚开始是中文,切换成英文后,页面内容都变成英文了,标题栏还是中文。
> `App端` 说明:`App模拟器`,以我的 `mac电脑` `ios模拟器` 来说,是正常的,可以直接切换,多语言也是生效的。
>
> 但是 `安卓真机` 会出现`切换多语言后,自动重启,然后界面多语言是生效的`
>
> 既然 `App 正常`,这里主要说 `小程序端` 不正常的处理。
`小程序端` 需要使用 `uni.setNavigationBarTitle` 来手动处理,`API` 使用如下:
```js
uni.setNavigationBarTitle({
title: '新的标题',
})
```
结合 `translate` 函数,则:
```js
uni.setNavigationBarTitle({
title: translate('app.name'),
})
```
可以满足大部分场景。
## tabbar 标题
`导航栏标题`。使用 `uni.setTabBarItem` 来手动处理。
## App 端视频
这里给出 `2``App端` 的视频,加深开发者的认识和印象。
:::details
### `ios模拟器` 多语言直接就是生效的
<video src="./assets/10-ios.mp4" controls="controls" width="300px" height="100%"></video>
### `安卓真机` 会自动重启,重启后界面多语言是生效的
<video src="./assets/10-android.mp4" controls="controls" width="300px" height="100%"></video>
:::
## 总结
本文介绍了 `unibest` 里面使用 `多语言` 的基本方式,还处理了 `3` 个多端异常的问题:
- `多语言传参` 不生效 BUG
- `导航栏标题` 切换多语言不生效 BUG
- `tabbar标题` 切换多语言不生效 BUG
全文完~

View File

@ -1,111 +0,0 @@
# 运行发布
## 运行
- `h5 平台` `pnpm dev:h5` 或者简单点 `pnpm dev` ),然后浏览器打开 `http://localhost:9000/`
- `wx 小程序``pnpm dev:mp-weixin`,然后打开微信开发者工具,导入本地文件夹,选择本项目的 `dist/dev/mp-weixin` 文件。
- ![alt text](./assets/11-1.png)
- `APP 平台``pnpm dev:app`,然后打开 `HBuilderX`,导入刚刚生成的 `dist/dev/app` 文件夹,选择运行到 `模拟器`( `开发时优先使用` ),或者 `运行到安卓/ios 基座` (真机调试时使用) 。
![alt text](./assets/11-2.png)
![alt text](./assets/11-3.png)
![alt text](./assets/11-4.png)
> 如果需要配置其他模拟器,可以参考:[安装模拟器](https://uniapp.dcloud.net.cn/tutorial/run/installSimulator.html)
> 这样操作的话,开发时都会有热更新,开发体验很爽!
## 发布
- `h5 平台` `pnpm build:h5`,打包后的文件在 `dist/build/h5`,可以放到 web 服务器,如 nginx 运行。如果最终不是放在根目录,可以在 `manifest.config.ts` 文件的 `h5.router.base` 属性进行修改。
- `wx 小程序``pnpm build:mp-weixin`,打包后的文件在 `dist/build/mp-weixin`,然后通过微信开发者工具导入,并点击右上角的“上传”按钮进行上传。
- `APP 平台``pnpm build:app`,然后打开 `HBuilderX`,导入刚刚生成的 `dist/build/app` 文件夹,选择 `发行` - `原生APP-云打包`
![alt text](./assets/11-13.png)
![alt text](./assets/11-5.png)
![alt text](./assets/11-6.png)
> 熟悉原生 APP 开发的开发者也可以使用 `原生APP-本地打包`
## APP 打包注意事项(上)
很多开发者发现打包失败,或者打包白屏,这里简单说明一下。
- 1. 重新获取自己的 `AppId`
![alt text](./assets/11-7.png)
- 2. 根据上面获取到的 `AppId` 修改 `env/.env` 文件的 `VITE_UNI_APPID` 字段
![alt text](./assets/11-8.png)
- 3. (可选)云打包如果有出现解析时出问题的,把 `minSdkVersion` 版本改低一点就好了,比如 `21`。(最低 `21`,不能低于 `21`;我模板里面设置的是 `30`)。
![alt text](./assets/11-9.png)
## APP 打包注意事项 (下)
### `uni-app SDK` 版本
> 特别备注:`2024-05-03`,新的 `base` 模板的 `uni-app SDK` 版本已经升级到 `4.14` 了。
>
> ![alt text](./assets/11-100.png)
`2024-04-14`,新的 `base` 模板的 `uni-app SDK` 版本已经升级到 `4.08` ,记得更新您的 `HBuilderx` 版本。
`"@dcloudio/uni-app": "3.0.0-4000820240401001"` 表示 `uni-app``3.0.0` 版本,对应的 `HBuilderx` 版本为 `4.08`,后面的 `20240401001` 是发布日期。
> `40008` 第一个数字 `4` 表示主要版本,后面每 `2` 位数为一组,所以代表 `4.0.8`
>
> 类似的,`30812` 代表 `3.8.12` 版本,`30909` 代表 `3.9.9` 版本。
>
> 另外,从 `3.99` 开始,后面 2 个小版本合并书写,于是 `3.9.9` 变成 `3.99``4.0.8` 变成 `4.08`
`unibest` 历史用过的 `@dcloudio/uni-app` 版本:
```text
"@dcloudio/uni-app": "3.0.0-3081220230817001", => 3.8.12
"@dcloudio/uni-app": "3.0.0-3090920231225001", => 3.99
"@dcloudio/uni-app": "3.0.0-4000820240401001", => 4.08
"@dcloudio/uni-app": "3.0.0-4010420240430001", => 4.14
```
![alt text](./assets/11-10.png)
### `uni-app SDK` 版本匹配 `HBuilderX`
> 温馨提示:下面的部分是使用 `uni-app` 版本为 `3.8.12` 时写的文档,适当参考~
本模板使用的是 `3.8.12` 的库版本(`"@dcloudio/uni-app": "3.0.0-3081220230817001",`),所以尽量使用 `3.8.12` 版本的 `HBuilderX` 来打包,否则可能有未知的风险,出现情况如下图。
> 原来的图不见了,重新补了一张。
![alt text](./assets/11-11.png)
上图表示您的 `HBuilderX` 版本是 `4.08`,但是代码 `uni-app SDK` (即 `"@dcloudio/uni-app": "3.0.0-4010420240430001"` ) 是 `4.14`,版本不匹配。
- 点击 `ignore`(忽略) 后若可以正常使用,那就不用管。(可选添加如下配置)
```json
"app-plus" : { "compatible": { "ignoreVersion": true } }
```
- 如果出现白屏啥的,请更新您的 `HBuilderX``uni-app SDK` 相同版本(这里是 `4.14` )。
### 多个 `HBuilderX` 版本安装
> 温馨提示:下面的部分是使用 `uni-app` 版本为 `3.8.12` 时写的文档,适当参考~
`MAC` 可以安装多个版本的软件,如下图我安装了 `3.8.12` (3.8.12.20230817) 和最新的 `3.99` (3.99.2023122611) 两个版本,平时的项目使用 `3.99`, 打包 `unibest` 的时候使用 `3.8.12`
![alt text](./assets/11-12.png)
> `window` 系统也可以同时安装多个 `HBuilderX` 版本,安装时选择安装到不同目录下即可。
## 总结
本文描述了多端的运行和发布,希望对您有帮助。
全文完~

View File

@ -1,89 +0,0 @@
# 环境变量
主要介绍 `vite` 环境变量和 `uni` 环境变量。
## `vite` 环境变量
`Vite` 在一个特殊的 `import.meta.env` 对象上暴露环境变量。环境变量定义在 `.env` 文件里。
### .env 文件
创建环境文件:
```yml
.env # 所有情况下都会加载
.env.local # 所有情况下都会加载,但会被 git 忽略
.env.[mode] # 只在指定模式下加载
.env.[mode].local # 只在指定模式下加载,但会被 git 忽略
# 注意 .env.local 无法覆盖 .env.[mode]
```
环境文件只包含环境变量的 `键值对`
```yml
VITE_SOME_KEY=123
DB_PASSWORD=foobar
```
> 为了防止意外地将一些环境变量泄漏到客户端,只有以 `VITE_` 为前缀的变量才会暴露给经过 `vite` 处理的代码。
如上配置,只有 `VITE_SOME_KEY` 会被暴露为 `import.meta.env.VITE_SOME_KEY` 提供给客户端源码,而 `DB_PASSWORD` 则不会。
```js
console.log(import.meta.env.VITE_SOME_KEY) // "123"
console.log(import.meta.env.DB_PASSWORD) // undefined
```
### mode 模式
Vite 允许你为不同的构建环境指定不同的模式。通常在 `npm scripts` 里面指定 `mode` 参数:
```sh
"scripts": {
"dev": "uni",
"dev-dev": "uni --mode development",
"dev-test": "uni --mode test",
"dev-prod": "uni --mode production",
}
```
运行不同模式的脚本时,`Vite` 会自动加载对应的 `.env.[mode]` 文件,就能获取到不同的环境变量。
`Vite` 运行 `dev` 时默认会加载 `.env.development` 文件(若有)。
`Vite` 运行 `build` 时默认会加载 `.env.production` 文件(若有)。
故,如上配置 `pnpm dev``pnpm dev-dev` 是一个效果。
## `uni` 环境变量
`uni` 环境变量这里指运行 `uni` 的平台变量,通过 `vite``define` 配置可以暴露出来。
```
define: {
__UNI_PLATFORM__: JSON.stringify(UNI_PLATFORM),
},
```
代码里面使用:
```js
export const platform = __UNI_PLATFORM__
export const isH5 = __UNI_PLATFORM__ === 'h5'
export const isApp = __UNI_PLATFORM__ === 'app'
export const isMp = __UNI_PLATFORM__.startsWith('mp-')
const PLATFORM = {
platform,
isH5,
isApp,
isMp,
}
export default PLATFORM
```
## 总结
本文描写了 `vite` 环境变量和 `uni` 环境变量如何配置和使用。
全文完~

View File

@ -1,74 +0,0 @@
# hbx 模板
为了方便使用 `HBuilderX` 的开发者,`unibest` 也提供 `hbx` 模板。
`hbx 模板` 适用于 `2 类用户`
- ~~使用 `uniCloud` 云开发的用户,必须使用 `hbx 版本`,因为 `uniCloud``HBuilderX` 是绑定的。~~
- 开发 `App` 的用户,可选使用 `hbx 版本`
> 现在 `base` 模板已经完全可以替代 `hbx` 模板了,所以 `hbx` 模板不再维护。
>
> 1. `base` 模板一样可以使用 `uniCloud` 云开发。
> 2. `base` 模板支持 `App` 开发,并且也可以热更新,详情请见 [APP 专区](./18-app)。
## 仓库地址
> `hbx` 目前由 `青谷` 大佬维护,微信号:`qingguxixi`[青谷 github 地址](https://github.com/Xiphin) 。
- gitee: [unibest-hbx](https://github.com/uni-run/unibest-hbx)
- github: [unibest-hbx](https://github.com/uni-run/unibest-hbx)
没有梯子的用户优先推荐使用 `gitee` 仓库,速度更快。(两个仓库会实时同步,无差别。)
## 导入项目
有 2 种方式导入项目:
- 从 `Git` 导入...
- 从本地目录导入...
## 运行项目
此时运行菜单会提示 `本项目类型无法运行`,如下图
![alt text](./assets/13-1.png)
![alt text](./assets/13-2.png)
需要执行如下 2 步:
- 项目下执行 `pnpm i`
- 右键项目,选择 `重新识别项目类型`
![alt text](./assets/13-3.png)
## 运行效果
经过上面的操作后,就可以正常运行了。
- ios 模拟器运行效果如下:
![alt text](./assets/13-4.png)
![alt text](./assets/13-5.png)
![alt text](./assets/13-6.png)
- 微信小程序运行效果如下:
![alt text](./assets/13-7.png)
> 目前微信小程序静态资源还有点问题,如下图 `logo 不见了`,后续会修复。
![alt text](./assets/13-8.png)
> 另外还发现 `UnoCSS Icon` 不生效,原因未知。
## 总结
本文描述了 `hbx` 模板的由来,使用方式。
有需要的可以试试,但是不太建议使用。另外精力有限,该模板不再维护。
全文完~

View File

@ -1,128 +0,0 @@
# 常见问题
本篇介绍一些常见的问题,会持续更新。
## 1. 如何设置/修改首页?
`vue` 文件的 `route-block` 块里面设置 `type="home"` 即可,请确保项目里面 `只有一个页面` 是这个配置。
> 注意:如果有多个,会按照字母顺序排列,第一个是首页。(可能不是您的想要的效果。)
## 2. 修改 `pages.json``manifest.json` 被覆盖问题
- `pages.json`
本项目引入了 `@uni-helper/vite-plugin-uni-pages``pages.json` 文件将会自动生成,手动修改 `pages.json` 将会被覆盖。
全局的东西请在 `pages.config.ts` 里面配置,页面的东西请在 `vue` 文件的 `route-block` 配置。
- `manifest.json`
与上面类似。本项目引入了 `@uni-helper/vite-plugin-uni-manifest``manifest.json` 文件将会自动生成,手动修改 `manifest.json` 将会被覆盖。
如需修改,请在 `manifest.config.ts` 里面修改。
## 3. 怎么分包?
`vite.config.ts` 里面有一个配置,如下:(其中 `subPackages` 就是用来分包的)
```ts [vite.config.ts]{3}
UniPages({
exclude: ['**/components/**/**.*'],
subPackages: ['src/pages-sub'], // 是个数组,可以配置多个
}),
```
## 4. 首次运行 `pnpm:mp` 时报错。
首次运行 `pnpm:mp` 时报错,报错如下:
```text
Error: ENOENT: no such file or directory, open '/Users/burtlai/unibest-projects/unibest/src/manifest.json'
```
首次运行 `非h5端` 时都可能出现上面的问题,需要先执行一下 `pnpm i` 以生成 `src/manifest.json` 文件,后面就不会报错了。
## 5. `git commit` 报错。
请看 `commitlint.config.ts` 里面的配置,需要满足对应的设定。根据自己的需要,可以修改 `commitlint.config.ts` 里面的配置。
如果是一次的(比如引入了某个第三方库),可以通过 `--no-verify` 参数跳过校验:
```sh
git commit -m "feat: xxx" --no-verify
```
第三方库还有另外一种处理方式,放到特定的文件夹,然后在 `.eslintignore``.styleintignore` 里面加上该文件夹。
## 6. 不想要严格的 `git` 提交检测,怎么办?
直接把 `.husky` 这个文件删掉即可。(或者不删除,只把里面的文件内容注释掉。)
## 7. `uni-app` 无法使用 `process.env` 变量,怎么办?
使用 `import.meta.env` 替代!
## 8. 如何跟随 `uni-app` 官方升级?
项目下,执行 `npx @dcloudio/uvm@latest` 即可更新。
![alt text](./assets/14-1.png)
> 注意,上面的命令会自动安装 `vue-i18n`,可以手动删除(`pnpm un vue-i18n`),也可以不理它(没多大影响)。
## 9. 如何把已经加入 `git` 管理的文件移出 `git` 管理?
- 第一步,先把文件移出`git` 管理,操作如下:
```text
# git rm -r --cached file1 file2 ## 针对某些文件
# git rm -r --cached dir1 dir2 ## 针对某些文件夹
# git rm -r --cached . ## 针对所有文件
```
- 第二步,提交 `commit` 以正式删除的文件
> 总结:`git rm -r --cached .` + `git commit` 即可。
## 10. 支付宝小程序运行报错。
- 默认运行是会报错的,如下图
![alt text](./assets/14-2.png)
- 只需要勾上 `本地开发跳过 ES5 转译` 即可正常运行,如下图
![alt text](./assets/14-3.png)
> 总结:勾上 `本地开发跳过 ES5 转译` 即可。
## 11. 支持 `uni-app x` 吗?
不支持。但我们一直保持关注。[uni-app x 传送门](https://doc.dcloud.net.cn/uni-app-x/)
目前 `unibest` 已经有 `hbx` 模板,后续接入 `uni-app x` 会很容易,坐等官方发布。
## 12. 为啥 `package.json``vue` 已经 `3.4+` 了,还不支持 `defineModel` ?
`uni-app` 官方虽然已经把 `vue` 升级到 `3.4+` 了,但是目前只有 `H5端` 支持 `defineModel`,其他端目前运行报错,详情请看 `uni-app` 官网的发布日志:
[HBuilder X - Release Notes](https://3085868976.hiecheimaetu.com:22443/qn-GO8xCsKgpKDZWIBAkVCUkI1EnGmQUMT4.update.dcloud.net.cn/hbuilderx/changelog/4.14.2024043013.html)
关键截图如下:(仅支持 `H5端`
![alt text](./assets/14-4.png)
真实运行报错截图如下:(分别是 `小程序``APP` 都会报错
![alt text](./assets/14-5.png)
![alt text](./assets/14-6.png)
## 13. `base` 模板如何接 `uniCloud` ?
- 1. 操作方案:直接在原始项目目录上右键,重新识别项目类型,就可以关联 `uniCloud` 了,然后用原始项目直接运行就可以了,不需要再 `pnpm dev:app` 后导入 `dist/dev/app` 再运行了。
- 2. 问:其他模板可以吗?答:其他模板也可以,操作同上。
- 3. 我写的文章链接:[【unibest】可以去掉 hbx 模版了base 模板一统天下](https://mp.weixin.qq.com/s?__biz=MzUxMzAwNzMwNw==&mid=2247484792&idx=1&sn=b6116198f265384e5a51bd2bd95bea90&chksm=f95a8edcce2d07caba60782e17e48d766612c0ad85c019379fd5ac37890e31b6ca7049e670f7&scene=178&cur_album_id=3438500614009782275#rd)
全文完~

View File

@ -1,284 +0,0 @@
# 常见问题 2
## 1. `wot-ui``toast` + `message-box` 不生效。
- 1. `layout` 引入 `wot-ui``toast` + `message-box`
```vue [src/layouts/default.vue]
<!-- src/layouts/default.vue -->
<template>
<view>
<slot />
<wd-toast />
<wd-message-box />
</view>
</template>
```
> `unibest@2.1.0` 开始已经默认引入。
- 2.页面使用
```ts
import { useMessage } from 'wot-design-uni'
const message = useMessage()
const handleClick = () => {
// 顺便测试 message 的使用
message.show('显示隐藏切换')
}
```
## 2. `uni-app` 插件市场的插件如何使用?
`hbx` 模板可以直接引入,不在讨论范围内,下面描述的是 `普通模板`
> 如果该插件支持 `npm` 安装,则直接安装即可,推荐统一使用 `pnpm` 安装。接着根据该插件的文档使用即可。
下面描写的是不支持 `npm` 安装的插件。
这里以 `sp-editor` 富文本插件为例,[插件地址](https://ext.dcloud.net.cn/plugin?id=14726)
- 1. 下载 `uni-app` 插件市场的代码。(居然要登录+看广告)
![alt text](./assets/15-1.png)
- 2. 解压并拷贝到 `unibest` 项目的 `uni_modules` 目录下。
![alt text](./assets/15-2.png)
- 3. 整理插件文件夹名称,把 `sp-editor_1.3.7` 改为 `sp-editor`
> 不改会报错,因为内部代码都是用 `sp-editor` 不带版本号的。会导致查找文件失败。
![alt text](./assets/15-3.png)
- 4. 代码直接使用,无需引入组件。( `uni-app插件` 有一套规范,`uni-app` 会自动查找,跟 `easycom` 类似。)
```html
<template>
<view class="home">
<view class="editor-box">
<sp-editor
:toolbar-config="{
excludeKeys: ['direction', 'date', 'lineHeight', 'letterSpacing', 'listCheck'],
iconSize: '18px',
}"
@init="initEditor"
@input="inputOver"
@upinImage="upinImage"
@overMax="overMax"
@addLink="addLink"
@exportHtml="exportHtml"
></sp-editor>
</view>
</view>
</template>
```
完整版见下:
:::details
```vue
<route lang="json5">
{
layout: 'demo',
style: { navigationBarTitleText: '富文本' },
}
</route>
<template>
<view class="home">
<view class="editor-box">
<sp-editor
:toolbar-config="{
excludeKeys: ['direction', 'date', 'lineHeight', 'letterSpacing', 'listCheck'],
iconSize: '18px',
}"
@init="initEditor"
@input="inputOver"
@upinImage="upinImage"
@overMax="overMax"
@addLink="addLink"
@exportHtml="exportHtml"
></sp-editor>
</view>
</view>
</template>
<script setup>
import { ref } from 'vue'
const editorIns = ref(null)
/**
* 获取输入内容
* @param {Object} e {html,text} 内容的html文本和text文本
*/
function inputOver(e) {
// 可以在此处获取到编辑器已编辑的内容
console.log('==== inputOver :', e)
}
/**
* 超出最大内容限制
* @param {Object} e {html,text} 内容的html文本和text文本
*/
function overMax(e) {
// 若设置了最大字数限制,可在此处触发超出限制的回调
console.log('==== overMax :', e)
}
/**
* 编辑器就绪
* @param {Object} editor 编辑器实例你可以自定义调用editor实例的方法
* @tutorial editor组件 https://uniapp.dcloud.net.cn/component/editor.html#editor-%E7%BB%84%E4%BB%B6
* @tutorial 相关api https://uniapp.dcloud.net.cn/api/media/editor-context.html
*/
function initEditor(editor) {
editorIns.value = editor // 保存编辑器实例
// 保存编辑器实例后,可以在此处获取后端数据,并赋值给编辑器初始化内容
preRender()
}
function preRender() {
setTimeout(() => {
// 异步获取后端数据后,初始化编辑器内容
editorIns.value.setContents({
html: `<div>&nbsp;&nbsp;猫猫<img src="https://img.yzcdn.cn/vant/cat.jpeg"/></div>`,
})
}, 1000)
}
/**
* 直接运行示例工程插入图片无法正常显示的看这里
* 因为插件默认采用云端存储图片的方式
* 以$emit('upinImage', tempFiles, this.editorCtx)的方式回调
* @param {Object} tempFiles
* @param {Object} editorCtx
*/
function upinImage(tempFiles, editorCtx) {
/**
* 本地临时插入图片预览
* 注意:这里仅是示例本地图片预览,因为需要将图片先上传到云端,再将图片插入到编辑器中
* 正式开发时,还请将此处注释,并解开下面 使用 uniCloud.uploadFile 上传图片的示例方法 的注释
* @tutorial https://uniapp.dcloud.net.cn/api/media/editor-context.html#editorcontext-insertimage
*/
// #ifdef MP-WEIXIN
// 注意微信小程序的图片路径是在tempFilePath字段中
editorCtx.insertImage({
src: tempFiles[0].tempFilePath,
width: '80%', // 默认不建议铺满宽度100%,预留一点空隙以便用户编辑
success: function () {},
})
// #endif
// #ifndef MP-WEIXIN
editorCtx.insertImage({
src: tempFiles[0].path,
width: '80%', // 默认不建议铺满宽度100%,预留一点空隙以便用户编辑
success: function () {},
})
// #endif
/**
* 使用 uniCloud.uploadFile 上传图片的示例方法(可适用多选上传)
* 正式开发环境中,请将上面 本地临时插入图片预览 注释后,模仿以下写法
*/
// tempFiles.forEach(async (item) => {
// uni.showLoading({
// title: '上传中请稍后',
// mask: true
// })
// let upfile = await uniCloud.uploadFile({
// filePath: item.path,
// // 同名会导致报错 policy_does_not_allow_file_overwrite
// // cloudPath可由 想要存储的文件夹/文件名 拼接若不拼文件夹名则默认存储在cloudstorage文件夹中
// cloudPath: `cloudstorage/${item.name}`,
// cloudPathAsRealPath: true
// })
// editorCtx.insertImage({
// src: upfile.fileID,
// width: '80%', // 默认不建议铺满宽度100%,预留一点空隙以便用户编辑
// success: function () {
// uni.hideLoading()
// }
// })
// })
}
/**
* 导出 - toolbar需要开启export工具
* @param {string} e 导出的html内容
*/
function exportHtml(e) {
uni.navigateTo({
url: '/pages/out/out',
success(res) {
// 传至导出页面解析即可
res.eventChannel.emit('e-transmit-html', {
data: e,
})
},
})
}
/**
* 添加超链接
* @param {Object} e { text: '链接描述', href: '链接地址' }
*/
function addLink(e) {
console.log('==== addLink :', e)
}
</script>
```
:::
## 3. Vue-Official ` vue.volar` 使用哪个版本?
`2025-05-22` 更新 :经测试,最新可用版本为 `v2.2.8` `v2.2.10` 会报错。(可以关闭 vue.volar 的自动更新)
![alt text](./assets/15-4.png)
## 4. 为啥不用 `vant-ui`
`vant-ui``WEB``UI 库`,不适用于 `uni-app`
`uni-app` 没有 `window`, `document``WEB API`,所以凡是使用 `WEB API``框架``UI 库` 等都不适用于 `uni-app`
## 4. 控制台报错 `[plugin:uni:mp-using-component] Unexpected token S in JSON at position 208`
控制台报错如下:
![alt text](./assets/15-6.png)
原因是 `uni-pages` 这个插件最新版本 `0.2.22` 有问题,需要回退到 `0.2.20`
![alt text](./assets/15-5.png)
执行如下命令即可:
```
pnpm add @uni-helper/vite-plugin-uni-pages@0.2.20
```
> 因为 `unibest``2.3.0(含)` 之前没有把 `pnpm-lock.yaml` 加入到版本管理,导致小版还是有细微差别。
>
> 在 `2.4.0` 开始已经加入,不会再出现这个问题。
## 5.不会 TypeScript 怎么办
不管个人还是团队、产品或者项目,从长远考虑我们都建议你学习 TypeScript因为它是未来的趋势而且大部分框架、库、插件都是用 TypeScript 开发的,足以证明它是构建一款成熟稳健产品的基石。
但考虑到实际情况,会各种客观原因存在,如果必须要用传统 JavaScript 进行开发,你可以在 `tsconfig.json` 里将 `allowJs` 设置为 `true` 即可,框架原有的 TypeScript 代码不会受到影响,并且你也可以在项目中使用 JavaScript 编写代码。
## 6.微信小程序 `INVALID_LOGIN`
微信小程序开发进入登录页时,可能导致如下问题:
```text
{errMsg: "navigateTo:fail Error: INVALID_LOGIN,
access_token expired [20250103 17:08:03][touristappid]"}
```
> 解答:游客模式会出现该错误,微信扫码登录一下就可以了。

View File

@ -1,17 +0,0 @@
# 小程序的标识
目前有以下 `9` 种小程序标识,对应小程序平台类型如下:
| 类型 | 标识 |
| ------------ | ----------- |
| 微信小程序 | mp-weixin |
| 支付宝小程序 | mp-alipay |
| 抖音小程序 | mp-toutiao |
| 飞书小程序 | mp-lark |
| QQ小程序 | mp-qq |
| 京东小程序 | mp-jd |
| 小红书小程序 | mp-xhs |
| 百度小程序 | mp-baidu |
| 快手小程序 | mp-kuaishou |
> 注意: `mp-toutiao` 就是抖音小程序,其他的都很好辨别。

View File

@ -1,136 +0,0 @@
# 自动生成代码
集成 [openapi-ts-request](https://github.com/openapi-ui/openapi-ts-request) 插件,可以根据接口文档自动生成 js,ts,uni.request,vue-query 代码。
支持 apifox/swagger/opeanpi/yapi 等接口文档,更多配置详情请查看 [openapi-ts-request](https://github.com/openapi-ui/openapi-ts-request) 插件。
## 如何使用
你只需要将接口文档对应的接口配置url复制到根目录的 `openapi-ts-request.config.ts` 插件的配置文件中的 `schemaPath` 字段中,然后运行 `npm run openapi-ts-request` 命令,就可以生成代码。
支持同时配置多个接口文档url生成的代码默认会放在 `src/service/app` 目录下,你可以自己调整生成代码的目录。
配置如下:
```ts
import type { GenerateServiceProps } from 'openapi-ts-request'
export default [
{
schemaPath: 'http://petstore.swagger.io/v2/swagger.json',
serversPath: './src/service/app',
requestLibPath: `import request from '@/utils/request';\n import { CustomRequestOptions } from '@/interceptors/request';`,
requestOptionsType: 'CustomRequestOptions',
isGenReactQuery: true,
reactQueryMode: 'vue',
isGenJavaScript: false,
},
] as GenerateServiceProps[]
```
## 生成 ts 代码
ts 的 type 类型会默认生成在 `src/service/app/types.ts` 文件,你可以通过引入它们进行使用。
```ts
import { type Category } from '@/service/app'
const category: Category = {
id: 1,
name: '张三',
}
```
## 生成 uni.request 代码
ts 的 uni.request 客户端会默认生成在 `src/service/app` 目录下,以模块名进行分类,你可以通过引入它们进行使用。
```ts
import { getPetById } from '@/service/app'
onShow(() => {
const res = await getPetById({ id: 1 });
console.log('res: ', res)
})
```
## 生成 vue-query 代码
vue-query 的代码会默认生成在 `src/service/app` 目录下,以模块名进行分类,后缀为 `moduleName.vuequery.ts`,你可以通过引入它们进行使用。
```ts
import { useQuery } from '@tanstack/vue-query'
import { findPetsByStatusQueryOptions, usePlaceOrderMutation } from '@/service/app'
// get请求使用findPetsByStatusQueryOptions 方法为自动生成 react-query 函数
export function findPetsByStatusQueryOptions(options: {
// 叠加生成的Param类型 (非body参数openapi默认没有生成对象)
params: API.findPetsByStatusParams;
options?: CustomRequestOptions;
}) {
return queryOptions({
queryFn: async ({ queryKey }) => {
return apis.findPetsByStatus(queryKey[1] as typeof options);
},
queryKey: ['findPetsByStatus', options],
});
}
// vue-query useQuery 默认使用
const {
data,
error
isLoading,
refetch,
} = useQuery(findPetsByStatusQueryOptions({ params: { status: ['available'] } }))
// vue-query useQuery 额外配置
const {
data,
error
isLoading,
refetch,
} = useQuery({
...findPetsByStatusQueryOptions({ params: { status: ['available'] } }),
enabled: !!token,
})
// post, delete, patch请求使用usePlaceOrderMutation 为自动生成 vue-query hook函数
export function usePlaceOrderMutation(options?: {
onSuccess?: (value?: API.Order) => void;
onError?: (error?: DefaultError) => void;
}) {
const { onSuccess, onError } = options || {};
const response = useMutation({
mutationFn: apis.placeOrder,
onSuccess(data: API.Order) {
onSuccess?.(data);
},
onError(error) {
onError?.(error);
},
});
return response;
}
// 定义请求
const { mutate, isPending } = usePlaceOrderMutation({
onSuccess: (data) => {
console.log('success data: ', data)
},
})
// 提交请求
mutate({
body: {
status: 'placed',
complete: true,
}
})
```

Binary file not shown.

Before

Width:  |  Height:  |  Size: 269 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 241 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 142 KiB

View File

@ -1,70 +0,0 @@
# App 专题
## 1. 其他端正常,`App` 白屏
请检查 `useXxxStore` 的调用,需要在函数内部调用,而不是在函数外部调用。(估计是顶层调用的时候 `pinia` 没有初始化,导致的问题,`app` 端独有的问题。)
```ts
// 错误写法
const userStore = useUserStore()
function foo() {
userStore.xxx
}
// 正确写法
function foo() {
const userStore = useUserStore()
userStore.xxx
}
```
## 2.unibest 的 `App` 模块配置
> 核心解决办法就是把 `manifest.json` 的内容搬运到 `manifest.config.ts` 中。
我们默认的的 `manifest.config.ts` 只包含了比较基础的 `uniapp` 配置,有的时候我们需要在打包 `app` 时在 `hbuilderx` 里面额外设置一些配置,那么就需要配置好后把 `manifest.json` 中的内容拷贝到 `manifest.config.ts` 中,后面运行就不会丢失了。
举例子,我在 `manifest.json` 里面配置了 2个模块配置如下
![alt text](image-18.png)
点击左侧下面的 `源码视图` 就可以看到增加了如下内容:
![alt text](image-18-2.png)
只需要把对应的内容拷贝到 `manifest.config.ts` 中的 `distribute.plugins` 里面即可。
## 3.unibest 的 `原生插件` 模块配置
> [参考文献: 掘金教程 - Unibest 原生插件模块配置](https://juejin.cn/post/7496807547447427081)
## 4. `app` 热更新
### 4.1 `ios` 模拟器热更新
- `pnpm dev:app`
- 把 `dist/dev/app` 文件夹加入到 `hbx编辑器` 里面,然后运行。这样在编码的时候是可以热更新的。
> 但是上面的方法在android 模拟器里面不生效。
### 4.2 `android` 热更新
- 在 `android` 里面,把`dist/dev/app` 文件夹加入到 `hbx编辑器` 里面运行,无法热更新!!
- 需要把整个 `unibest 项目中的 src 文件夹` 加入到 `hbx编辑器` 里面,然后运行,这样就可以热更新。
- 不管是模拟器还是真机调试,都是这样。
## 5. 打包原生插件
> 思路:你把整个 `unibest项目的src` 放到 `hbx编辑器`,然后在 `src/mainifest.json` 里面配置好 `原生插件`。然后 `copy``manifest.config.ts`,接着自定义打包基座。
> 注意,全程不需要用到 `pnp build dev:app` 这个命令.
步骤:
- 1. 先配置好 `原生插件`,再 `copy``manifest.config.ts`
![alt text](18-app-1.png)
- 2. 先打包自定义基座
![alt text](18-app-2.png)
- 3. 使用自定义基座
![alt text](18-app-3.png)

View File

@ -1,131 +0,0 @@
# 快速开始
- 前置依赖
- **Node.js** - `>=v18`
- **pnpm** - `>=7.30`(推荐使用 `8.12+`
- **`VSCode`** - 可选 `WebStrom`
- **`HBuilderX`** - `APP` 的运行和发布还是离不开它
## 创建项目
通过下面的命令可以快速生成项目模板,`pnpm create unibest <项目名称>` ,如果不写 `<项目名称>` 会进入命令行交互模式。
```bash
# 如果没有 pnpm请先安装: npm i -g pnpm
pnpm create unibest my-project
# 时不时加一下 @latest 标识,这样可以使用最新版本的 create-unibest (2025-06-04 发布了 v1.18.5)
pnpm create unibest@latest my-project
```
npm 创建如下(不推荐)
:::details
如果使用 `npm`,可能有缓存,需要加上 `@latest` 标识,如果创建失败,请使用 `pnpm` 安装。
```bash
npm create unibest my-project
# 如果提示报错,或者生成的项目版本太旧,请使用下面的命令,增加 @latest 标识
npm create unibest@latest my-project
```
:::
实际操作截图如下:
![create project](./assets/2-1.png)
`create-unibest``v1.10.0` 开始会有版本号,如下:
![alt text](./assets/2-2.png)
![unibest templates](https://oss.laf.run/ukw0y1-site/xmind/unibest模板.png)
`create unibest` 支持 `-t` 参数选择模板,目前已有两大类 `8` 个模板
- `普通` 模板( `4个` ):分别是 `base``tabbar``spa``i18n``demo`
- `hbx` 模板(`2个` ):分别是 `hbx-base``hbx-demo`
不带 `-t` 参数时会默认生成 `base` 模板。
`base` 模板是最基本的模板,更新最及时,推荐使用 `base` 模板创建新项目。其他几个模板也是基于 `base` 模板得到的。 `demo` 模板则作为参考用。
`base` 模板的改动会自动同步到其他几个分支,通过 `github actions` 实现。
::: details `tabbar 模板``spa 模板` 的区别
- `tabbar` 模板里面的tabbar 路由是属于 `tabbar` 级别的,需要使用 `switchTabbar` 切换,`tabbar` 页面会有缓存,渲染性能较好。
- `spa` 模板类似于前端的 `SPA 应用``tabbar` 完全是一个组件实现的。页面之间切换是通过前端状态控制,简单灵活,不受 `tabbar` 的配置限制,但性能不如 `tabbar` 模板。
- 两者各有优点,按需选用。
:::
```sh
# VS Code 模板
pnpm create unibest my-project # 默认用 base 模板
pnpm create unibest my-project -t base # 基础模板
pnpm create unibest my-project -t tabbar # 自定义 tabbar 模板
pnpm create unibest my-project -t spa # 单页应用 模板使用一个组件模拟tabbar
pnpm create unibest my-project -t i18n # 多语言模板
pnpm create unibest my-project -t demo # 所有demo的模板(包括i18n)
# HBuilderX 模板,方便使用 uniCloud 云开发 (未来可以对接 uni-app x)
pnpm create unibest my-project -t hbx-base # hbx的base模板
pnpm create unibest my-project -t hbx-demo # hbx的demo模板包含所有的demo
```
> 2024-12-29<周日> 发表了一篇文章:[【unibest】可以去掉hbx模版了base模板一统天下](https://mp.weixin.qq.com/s/ybunFNkjKfV5yVLOMvqscg?token=1696234630&lang=zh_CN)
>
> 就是说 hbx 模板可以退出历史舞台了。
## 项目仓库地址
`github``gitee` 实时同步,代码一致。
### 普通模板:
- https://github.com/feige996/unibest
- https://gitee.com/feige996/unibest
> `demo` 模板是在 `hello-unibest` 项目中,仓库地址如下:
- https://github.com/feige996/hello-unibest
- https://gitee.com/feige996/hello-unibest
### hbx 模板
- https://github.com/uni-run/unibest-hbx
> `hbx` 目前由 `青谷` 大佬维护,微信号:`qingguxixi`[青谷 github 地址](https://github.com/Xiphin) 。
## 安装、运行
```bash [pnpm]
pnpm i
pnpm dev
# dev默认运行的是h5其他平台执行dev:<uni-platform>,如:
pnpm dev:mp-weixin
```
`pnpm dev` 之后在浏览器打开 `http://localhost:9000/`
> 其他平台构建和发布,查看 [运行发布篇](./11-build)。
## 第一次 `commit`
```bash
git add .
git commit -m "feat: init project"
```
## `v3` 代码块
`vue` 文件中,输入 `v3``tab` 即可快速生成页面模板,可以大大加快页面生成。
> 原理:基于 `VSCode` 代码块生成。
![alt text](./assets/2-4.gif)
## 注意事项
- 若代码里面自动引入的 `API` 报错,只需要 `pnpm dev` 即可。
- 若代码运行后,`H5端` 浏览器界面底部没有 `tabbar` 刷新浏览器或者再次 `pnpm dev` 即可。

View File

@ -1,31 +0,0 @@
# 最佳实践
新项目使用 `base` 模板,可选 `tabbar` 模板。如果需要多语言,可以选 `i18n` 模板。
同时参考 `demo` 模板,可以直接 `clone` `demo` 项目,用来参考用。
![unibest templates](https://oss.laf.run/ukw0y1-site/xmind/unibest模板.png)
## 创建项目
推荐使用 `pnpm` :
```sh
# 新项目创建
pnpm create unibest my-project -t base
```
## DEMO 模板
`demo` 模版-在线地址:<https://feige996.github.io/hello-unibest/>
推荐先全部体验一下 `demo` 的示例
## 必看章节
- [介绍](/base/1-introduction)
- [快速开始](/base/2-start)
- [uni 插件](/base/3-plugin)
- [常见问题](/base/14-faq)
- [常见问题 2](/base/15-faq)
- [运行发布](/base/11-build)

View File

@ -1,158 +0,0 @@
# uni 插件
## 引言
有群友第一次看到 `unibest` 里面 `vue` 文件 `route-block` 这种写法,表示很奇怪,从来没见过!
```vue
<route lang="json5">
{
layout: 'demo',
style: {
navigationBarTitleText: '标题',
},
}
</route>
<template>
<view class="text-green-500">菲鸽,你好,我喜欢你!</view>
</template>
```
## uni 插件总览
哈哈,这个当然是 `uni插件` 的功劳了,具体点是 `@uni-helper/vite-plugin-uni-pages` 插件的功劳,该插件由 `uni-helper` 官方团队开发。
本文就来说说 `unibest` 都引入了哪些有用的 `uni插件`。下面这个表格描述了各个插件的主要作用。
| 插件名 | 作用 |
| :----------------------------------: | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| @dcloudio/vite-plugin-uni | **最核心的 `uni 插件`**,没有它就不能在 vite 项目跑 uniapp其他所有的 `uni插件` 都需要经通过它的手来编译,所以写法上,都是先写 `UniXXX`,再写 `Uni`,见下文 |
| @uni-helper/vite-plugin-uni-pages | `uni 插件`,也是 `unibest 灵魂插件``route-block` 就是它的功劳,让你可以直接在本文件就能设置页面的路元信息,无需跑去 `pages.json` 配置,同时支持 `pages.config.ts` 编写 `pages.json` |
| @uni-helper/vite-plugin-uni-layouts | `uni 插件`,支持多种 `layouts` 布局,群友脑洞大开,充分利用这个特性实现平时不容易实现的布局 |
| @uni-helper/vite-plugin-uni-manifest | `uni 插件`,支持 `manifest.config.ts` 编写 `manifest.json` |
`UniXXX()` 插件都需要在 `uni()` 之前引入,因为最终都需要 `Uni` 来处理所有的代码。如下图:
![vite uni plugin](./assets/3-1.png)
接下来介绍一下 `uni 插件`,其他 `通用插件` 大家都比较熟悉,不再赘述。
`unibest` 引入了 `uni-helper` 团队的几个重要插件,少了它们 `unibest` 就缺少了灵魂,感谢 `uni-helper` 团队的贡献。`Uni 插件` 列表如下:
- `vite-plugin-uni-pages`
- 介绍:为 `Vite` 下的 `uni-app` 提供基于文件系统的路由
- 额外:使用 `TypeScript` 来编写 `uni-app``pages.json`
- 访问地址:[@uni-helper/vite-plugin-uni-pages](https://github.com/uni-helper/vite-plugin-uni-pages)
- `vite-plugin-uni-layouts`
- 介绍:为 `Vite` 下的 `uni-app` 提供类 `nuxt``layouts` 系统
- 访问地址:[@uni-helper/vite-plugin-uni-layouts](https://github.com/uni-helper/vite-plugin-uni-layouts)
- `vite-plugin-uni-manifest`
- 介绍:使用 `TypeScript` 来编写 `uni-app``manifest.json`
- 访问地址:[@uni-helper/vite-plugin-uni-manifest](https://github.com/uni-helper/vite-plugin-uni-manifest)
## vite-plugin-uni-pages
得益于 [@uni-helper/vite-plugin-uni-pages](https://github.com/uni-helper/vite-plugin-uni-pages),约定式路由(文件路由)的实现轻而易举。
`src/pages` 目录下的每个文件都代表着一个路由。要创建新页面,只需要在这个目录里新增 `.vue` 文件,插件会自动生成对应的 `pages.json` 文件。
`route` 代码块则可以配置页面相关信息,这些信息会自动同步到 `page.json`,无需切换到 `page.json` 进行配置。
> `pages.json` 文件是自动生成的,请不要手动修改,全局的东西请在 `pages.config.ts` 里面配置,页面上的东西请在 `vue` 文件的 `route` 代码块配置,如下图。
```vue [src/pages/index.vue]
<!-- 使用 type="home" 属性设置首页其他页面不需要设置默认为page -->
<!-- 推荐使用json5更强大且允许注释 -->
<route lang="json5" type="home">
{
style: {
navigationStyle: 'custom',
navigationBarTitleText: '首页',
},
}
</route>
<template>
<div>
<h1>欢迎使用 unibest</h1>
<h4>unibest 是最好的 uniapp 开发模板</h4>
</div>
</template>
```
```vue [src/pages/about.vue]
<route lang="json5">
{
style: {
navigationBarTitleText: '关于',
},
}
</route>
<template>
<view>
<view>通过 `/pages/about` 来访问这个页面</view>
</view>
</template>
```
### 设置首页
通过在 `route-block` 里面配置 `type="home"` 即可,尽量保证一个项目 `只有一个` 这个配置,如果有多个,会按照字母顺序来排列,最终可能不是您想要的效果。
### 设置 pages 过滤和分包
- 过滤:默认 `src/pages` 里面的 `vue` 文件都会生成一个页面,如果不需要生成页面可以对 `vite.config.ts` 中的 `UniPages` 进行 `exclude` 配置。
- 分包:如果需要设置 `分包` 则可以通过 `subPackages` 进行配置,该配置项是个数组,可以配置多个 `分包`,注意分包的目录不能为 `src/pages` 里面的子目录。
```ts [vite.config.ts]
UniPages({
exclude: ['**/components/**/**.*'],
subPackages: ['src/pages-sub'], // 是个数组,可以配置多个,但不能为 `src/pages` 里面的子目录
})
```
## vite-plugin-uni-layouts
得益于 [@uni-helper/vite-plugin-uni-layouts](https://github.com/uni-helper/vite-plugin-uni-layouts),你可以轻松地切换不同的布局。
`src/layouts` 文件夹下的 `vue` 文件都会自动生成一个布局,默认的布局文件名为 `default` ,路径 `src/layouts/default.vue`
如果需要修改使用的布局,可以通过 `vue` 文件内 `route` 代码块指定需要的布局,如下示例使用 `demo` 布局。
```vue [src/pages/demo.vue]{3}
<route lang="json5">
{
layout: 'demo',
style: {
navigationBarTitleText: '关于',
},
}
</route>
```
```vue [src/layouts/demo.vue]
<template>
<view>
<!-- 这里可以写通用的布局比如导航栏tabbar等 -->
<!-- slot里面装的就是子页面的内容 -->
<slot />
</view>
</template>
```
## vite-plugin-uni-manifest
得益于 [@uni-helper/vite-plugin-uni-manifest](https://github.com/uni-helper/vite-plugin-uni-manifest),你可以使用 `TypeScript` 来编写 `manifest.json`
> `manifest.json` 文件是自动生成的,请不要手动修改,需要配置的内容请在 `manifest.config.ts` 里面配置。
## 总结
本文介绍了 `unibest` 引入的几个重要的 `uni插件`
如果还想了解更多信息,可以去 `uni-helper` [github 仓库](https://github.com/uni-helper) 看看。

View File

@ -1,220 +0,0 @@
# 样式篇
本篇主要介绍 `UnoCSS` 的使用,以及如何与 `设计稿尺寸` 对应。
## UnoCSS
[UnoCSS](https://unocss.dev/) 是按需使用的原子 CSS 引擎,提供了良好的样式支持。
![alt text](./assets/4-1.png)
在 VSCode 中还可以预览,
![alt text](./assets/4-2.png)
![alt text](./assets/4-3.png)
> 如果原子化 `UnoCSS` 没有预览效果,请安装 `VSCode` 插件 `antfu.unocss`
如果不记得原子类,可以查 `UnoCSS 的原子类`[UnoCSS Interactive](https://unocss.dev/interactive/),如下图
![alt text](./assets/4-4.png)
也可以查看 `tailwindcss` 的原子类,更加清晰明了,[链接 - tailwindcss](https://tailwindcss.com/),如下图:
![alt text](./assets/4-5.png)
## 常用的原子类
- 宽高内外边距: `w-2`, `h-4`, `px-6`, `mt-8`
- 前景色背景色:`text-green-400`, `bg-green-500`
- border: `border-2`, `border-solid`, `border-green-600`, `b-r-2` (注意 `border` = `border-1`,就是说边框 `1px` 时,一般简写为 `border` )
- border-radius: `rounded-full`, `rounded-6`, `rounded-sm` (不是 `br-10`, 也不是 `b-r-10`)
- line-height: `leading-10` (不是 `l-10`, 也不是 `lh-10`)
- hover: `hover:text-green-200`, `hover:bg-green-300`, `hover:border-dashed`
- flex: `flex`, `items-center`, `justify-center`, `flex-1`
## `UnoCSS` 配置
下面内容选读:
:::details
`unocss.config.ts` 文件内容如下:
```ts
// uno.config.ts
import {
type Preset,
defineConfig,
presetUno,
presetAttributify,
presetIcons,
transformerDirectives,
transformerVariantGroup,
} from 'unocss'
import { presetApplet, presetRemRpx, transformerAttributify } from 'unocss-applet'
// @see https://unocss.dev/presets/legacy-compat
import { presetLegacyCompat } from '@unocss/preset-legacy-compat'
const isMp = process.env?.UNI_PLATFORM?.startsWith('mp') ?? false
const presets: Preset[] = []
if (isMp) {
// 使用小程序预设
presets.push(presetApplet(), presetRemRpx())
} else {
presets.push(
// 非小程序用官方预设
presetUno(),
// 支持css class属性化
presetAttributify(),
)
}
export default defineConfig({
presets: [
...presets,
// 支持图标需要搭配图标库eg: @iconify-json/carbon, 使用 `<button class="i-carbon-sun dark:i-carbon-moon" />`
presetIcons({
scale: 1.2,
warn: true,
extraProperties: {
display: 'inline-block',
'vertical-align': 'middle',
},
}),
// 将颜色函数 (rgb()和hsl()) 从空格分隔转换为逗号分隔更好的兼容性app端example
// `rgb(255 0 0)` -> `rgb(255, 0, 0)`
// `rgba(255 0 0 / 0.5)` -> `rgba(255, 0, 0, 0.5)`
presetLegacyCompat({
commaStyleColorFunction: true,
}) as Preset,
],
/**
* 自定义快捷语句
* @see https://github.com/unocss/unocss#shortcuts
*/
shortcuts: [['center', 'flex justify-center items-center']],
transformers: [
// 启用 @apply 功能
transformerDirectives(),
// 启用 () 分组功能
// 支持css class组合eg: `<div class="hover:(bg-gray-400 font-medium) font-(light mono)">测试 unocss</div>`
transformerVariantGroup(),
// Don't change the following order
transformerAttributify({
// 解决与第三方框架样式冲突问题
prefixedOnly: true,
prefix: 'fg',
}),
],
rules: [
[
'p-safe',
{
padding:
'env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left)',
},
],
['pt-safe', { 'padding-top': 'env(safe-area-inset-top)' }],
['pb-safe', { 'padding-bottom': 'env(safe-area-inset-bottom)' }],
],
})
/**
* 最终这一套组合下来会得到:
* mp 里面mt-4 => margin-top: 32rpx == 16px
* h5 里面mt-4 => margin-top: 1rem == 16px
*
* 另外,我们还可以推算出 UnoCSS 单位与设计稿差别4倍。
* 375 * 4 = 1500把设计稿设置为1500那么设计稿里多少pxunocss就写多少数值。
* 举个例子设计稿显示某元素宽度100px就写w-100即可。
*
* 如果是传统方式写样式,则推荐设计稿设置为 750这样设计稿1px代码写1rpx。
* rpx是响应式的可以让不同设备的屏幕显示效果保持一致。
*/
```
### UnoCSS presets
主要有 `4`个:
- `presetUno` —— `UnoCSS` 默认的预设,`H5端` 适用,`非H5端` 不支持,代码已经作区别处理。
- `presetApplet` 小程序预设,因为默认 `Unocss 预设` 是针对 `WEB` 的,如果不加以处理,会报错,比如小程序不支持 `*` 没有 `body` 等。该预设同样对 `APP` 生效。
- `presetIcons`,专门使用 `UnoCSS Icons`需要搭配图标库使用eg: `@iconify-json/carbon`, 代码编写如 `<button class="i-carbon-sun dark:i-carbon-moon" />`
- `presetLegacyCompat` 针对低端 `APP` 不认识新的函数颜色的兼容性预设,可以将颜色函数 `rgb()和hsl()` 里面空格分隔转换为逗号分隔,更好的兼容性`APP`example
> `rgb(255 0 0)` -> `rgb(255, 0, 0)`
>
> `rgba(255 0 0 / 0.5)` -> `rgba(255, 0, 0, 0.5)`
### UnoCSS shortcuts
```ts
/**
* 自定义快捷语句
* @see https://github.com/unocss/unocss#shortcuts
*/
shortcuts: [['center', 'flex justify-center items-center']],
```
可以编写一些常用的快捷类名,如上表示 `center` 就是 `flex justify-center items-center` 的组合,合理的添加快捷类名可以加快样式编写。
:::
## 设计稿尺寸
不同的编写方式,需要设置不同的设计稿尺寸,请看下文:
### 1. 传统编写方式
如果有设计稿,通常使用传统的编写 `CSS` 的方式,里面的对应尺寸规律如下。以蓝湖为例,假如设计稿宽度为 `750px`,则直接复制样式代码到 css 代码,同时把 `px` 批量替换为 `rpx` 即可。
如果设计稿不是 `750px` 可以调整蓝湖的设置,让设计稿宽度为 `750px`
> 下面为一段辅助说明文案,从 `uniapp` 官网搬运而来。
`rpx` 是相对于基准宽度的单位,可以根据屏幕宽度进行自适应。`uni-app` 规定屏幕基准宽度 `750rpx`
开发者可以通过设计稿基准宽度计算页面元素 `rpx` 值,设计稿 `1px` 与框架样式 `1rpx` 转换公式如下:
`设计稿 1px / 设计稿基准宽度 = 框架样式 1rpx / 750rpx`
换言之,页面元素宽度在 `uni-app` 中的宽度计算公式:
`750 * 元素在设计稿中的宽度 / 设计稿基准宽度`
举例说明:
若设计稿宽度为 `750px`,元素 `A` 在设计稿上的宽度为 `100px`,那么元素 `A``uni-app` 里面的宽度应该设为:`750 * 100 / 750`,结果为:`100rpx`
若设计稿宽度为 `640px`,元素 `A` 在设计稿上的宽度为 `100px`,那么元素 `A``uni-app` 里面的宽度应该设为:`750 * 100 / 640`,结果为:`117rpx`
若设计稿宽度为 `375px`,元素 `B` 在设计稿上的宽度为 `200px`,那么元素 `B``uni-app` 里面的宽度应该设为:`750 * 200 / 375`,结果为:`400rpx`
### 2. UnoCSS 编写方式
经过上一节的 `unocss.config.ts` 配置,可以得到下面的组合:
> mp 里面mt-4 => margin-top: 32rpx == 16px
>
> h5 里面mt-4 => margin-top: 1rem == 16px
我们还是把设计稿设置为 `750`,设计稿上多少 `px` 的元素,写成多少 `rpx` 即可。
元素 `A` 在设计稿上的宽度为 `100px`,则写 `w-100rpx` 即可。
就是把 `传统编写方式` 中写在 `css` 中的样式搬到了 `UnoCSS` 中。
如果要想用 `w-100` 这种方式,需要做额外的处理(待验证):
:::details
太忙了,有空再写吧。
:::
## 总结
本文主要介绍了 `UnoCSS` 的使用,以及 `unocss.config.ts` 中的一些配置项。
同时说明了设计稿在两种编写方式下的宽度的设置,分别为 `750``1500`.
最后说明一下,`原子化CSS``传统方式` 两者不是互斥的,他们是互补的,合适的地方使用合适的方式。

View File

@ -1,41 +0,0 @@
# 关于使用 TailwindCSS
对于 unibest 项目使用 TailwindCSS 的评估如下:
1. **直接使用TailwindCSS的限制**
- 原生TailwindCSS是为Web设计的在小程序环境下会有兼容性问题
- 不支持rpx单位在小程序适配上有困难
- 需要额外配置postcss和purgeCSS才能在小程序工作
2. **当前UnoCSS的优势**
- 您的项目已经配置了`unocss-applet`,专门为小程序优化
- 支持rpx单位转换通过presetRemRpx
- 支持小程序属性化写法transformerAttributify
- 体积更小,按需生成样式
3. **替代方案建议**
- 保持使用UnoCSS它已经实现了Tailwind的大部分功能
- 可以通过安装`@unocss/preset-wind`来获得Tailwind风格的类名
```bash
pnpm add -D @unocss/preset-wind
```
然后在uno.config.ts中添加
```typescript
import { presetWind } from '@unocss/preset-wind'
export default defineConfig({
presets: [
presetWind(),
// 其他presets...
],
})
```
4. **结论**
在uni-app项目中UnoCSS是比原生TailwindCSS更合适的选择特别是针对小程序开发。通过`preset-wind`可以获得类似Tailwind的开发体验。

View File

@ -1,195 +0,0 @@
# 图标篇
本文主要介绍了 `图标` 的使用方式,通常有以下几种方式使用图标:
- `UI 库 Icons`
- `UnoCSS Icons`
- `iconfont`
下面笔者一一介绍
## UI 库 Icons
如果您已经引入了 `UI库`,并且正好该 `UI库` 已经有你想要的 `Icons`,那直接用最方便了,无需额外引入其他库,代码也是最少的。
这里介绍几个常用 `UI库` 的图标使用。
### `uni-ui Icons`
> 注意:`uni-ui Icons` 颜色只能通过 `color` 属性设置;使用 `UnoCSS` 设置无效。
```html
<uni-icons type="contact" size="30"></uni-icons>
<uni-icons type="contact" size="30" color="red"></uni-icons>
<uni-icons type="contact" size="30" class="text-green"></uni-icons>
<uni-icons type="contact" size="30" color="red" class="text-green"></uni-icons>
```
![alt text](./assets/5-1.png)
### `wot-ui Icons`
> 注意:`wot-ui icons` 颜色可以通过 `color` 属性设置,也可以通过 `UnoCSS` 设置;同时设置时,`color` 属性优先级高。
```html
<wd-icon name="add-circle"></wd-icon>
<wd-icon name="add-circle" color="red"></wd-icon>
<wd-icon name="add-circle" class="text-green"></wd-icon>
<wd-icon name="add-circle" class="text-green" color="red"></wd-icon>
```
![alt text](./assets/5-2.png)
### `uv-ui Icons`
> 注意:跟 `uni-ui Icons` 一样,`uv-ui Icons` 的颜色只能通过 `color` 属性设置;使用 `UnoCSS` 设置无效。
```html
<uv-icon name="home"></uv-icon>
<uv-icon name="home" color="red"></uv-icon>
<uv-icon name="home" class="text-green"></uv-icon>
<uv-icon name="home" color="red" class="text-green"></uv-icon>
```
![alt text](./assets/5-3.png)
> 注意,经过检测这 `3个UI库Icons` 都不支持使用 `UnoCSS` 改变大小(优先级低被覆盖),必须使用 `size` 属性来设置大小才有效果(行内样式优先于 css 样式)。
>
> 另外,经过检测,都支持动态 `iconName`和动态 `color` ! 即下面这样的写法是生效的:
```ts
const iconName = ref<string>('contact')
const colorName = ref<string>('red')
onLoad(() => {
setTimeout(() => {
iconName.value = 'chat'
colorName.value = 'green'
}, 1000)
})
```
```html
<uni-icons :type="iconName" :color="colorName" class="text-green w-8"></uni-icons>
<!-- 其他2个UI库同样生效 -->
```
## `UnoCSS Icons`
`UnoCSS Icons` 可以方便接入 `iconify` 图标库,后者拥有 `10万+` 的海量图标,总能找到你想要的。
### 1. 安装 iconify
在使用 `iconify` 之前需要安装对应的图标库,安装格式如下:
`pnpm i -D @iconify-json/[the-collection-you-want]`
以安装 `carbon` 为例,执行 `pnpm i -D @iconify-json/carbon` 即可。
> `unibest` 已经装好了 `carbon` 图标库,可以直接使用。
### 2. 找到 iconify 想要的图标名
打开网址:<https://icones.js.org/>
- 在里面找到某个库,如 `carbon`
![alt text](./assets/5-4.png)
- 搜索想要的图表,如 `avatar`,出现的搜索结果,查看类名,也可以点击图标,会出现详情( `details` 里面)。
![alt text](./assets/5-5.png)
![alt text](./assets/5-6.png)
- 如上图( `details` 里面),拿到 `carbon:user-avatar`
### 3. 编写代码
- 代码里面 `class` 填写 `i-carbon-user-avatar`(所有的单词用中划线连接即可)并且支持改颜色。
```html
<view class="i-carbon-user-avatar text-red" />
```
![alt text](./assets/5-7.png)
> 如果图标没有预览效果,请安装 `VSCode` 插件 `antfu.iconify`
预览效果:
![alt text](./assets/5-8.png)
### 4. 动态图标名
昨天有网友反馈,`UnoCSS Icons` 无法使用动态类名,我来试试:(我先说结论:是支持的!)
```ts
const iconName = ref<string>('i-carbon-car')
onLoad(() => {
setTimeout(() => {
iconName.value = 'i-carbon-user-avatar'
}, 1000)
})
```
```html
<view :class="iconName" />
```
一秒后会由 `i-carbon-car`(一辆车) 变成 `i-carbon-user-avatar`(一个头像),一切都是 OK 的。
### 5.再说动态图标名
有的时候类名是动态的,比如是 a+b 拼凑的,比如是后端返回的,比如是跨文件的,这时候页面是无法显示出该图标的。因为 `UnoCSS` 还不知道具体的类名是啥无法得到对应的图标。解决方案有2种
- 1. 在代码里写出完整的图标类名,并注释掉。(SFC 的任何位置都可以)
- 2. 在 `unocss.config.ts``safelist` 配置该完整类名。[unocss safelist](https://unocss.dev/config/#safelist)
## iconfont 图标库
`iconfont` 同样有海量免费的图标,同时支持上传自己的图标。公司项目通常会有自己的图标,由专业的 `UI设计师` 设计,这时通常会使用 `iconfont` 方式使用图标。
- 1. 打开`阿里巴巴矢量图标库 iconfont`,地址:[https://www.iconfont.cn/](https://www.iconfont.cn/),并登录。
- 2. 寻找需要的图标,加入项目,也可以上传自己的图标。
- 3. 图标方式选择 `Font class``项目设置` 勾选上 `base64`,否则`非H5端` 不支持,然后点击生成链接。
![alt text](./assets/5-9.png)
![alt text](./assets/5-10.png)
- 4. 把上面的 `css` 链接里面的内容写入在 `style/iconfont.css`,并引入到 `style/index.scss`
- 5. 页面上直接写 `<i class="iconfont icon-package text-red"></i>` 即可!
```html
<view class="m-4">
<text mr-2>iconfont:</text>
<i class="iconfont icon-package text-red"></i>
<i class="iconfont icon-chat text-red"></i>
<i class="iconfont icon-my text-red"></i>
</view>
```
预览如下:
![alt text](./assets/5-11.png)
> 上面的选择有疑问的可以看详细版 - [iconfont 详细版](/other/iconfont/iconfont)
## 其它图标库
其他优秀的可以免费商用的图标库:
- 字节跳动的 `IconPark`,链接 [https://iconpark.oceanengine.com](https://iconpark.oceanengine.com/)。
- 不知道谁家的 `yesicon`,链接 [https://yesicon.app](https://yesicon.app/)。
## 总结
本文介绍了 `3` 种使用图标的方式,分别是 `UI 库 Icons``UnoCSS Icons``iconfont`
- `UI 库 Icons` 颜色和大小属性都主要由 `UI 库` 本身控制,且都支持动态图标名和动态颜色。
- `UnoCSS Icons` 最省心,强烈推荐使用。
- `iconfont` 需要勾选 `Base64` 才能兼容多端。
全文完~

View File

@ -1,176 +0,0 @@
# SVG 篇
上一章《五、图标篇》主要介绍了 `线上图标` 的使用,今天带给大家本地 `SVG` 图标的使用。
> 注意:`小程序``APP` 都不支持 `SVG` 标签,只能通过 `image` 的方式使用。即下面的 `image + src` 方式。
- `image + src` 方式
- `static目录` 图标
- `相对目录` 图标
- `线上地址` 图标
> PS`小程序``APP``图片` 也是这面几种方式,下面统一称为 “图片”。
## `image + src` 方式
如果图片在项目里面,根据放的位置不同,分为 2 种:`static目录`图标 `相对目录`图标。
### 1. `static目录` 图标
这种方式直接编写代码即可,如下:
```html
<image src="/static/svg/demo.svg" mode="scaleToFill" class="h-20 w-20" />
```
### 2. `相对目录` 图标
这种方式需要先引入,再使用,代码编写如下:
```html
<script lang="ts" setup>
import iconUrl from './demo.svg'
</script>
<template>
<image :src="iconUrl" mode="scaleToFill" class="h-20 w-20" />
</template>
```
### 3. `线上地址` 图标
这种方式直接使用,代码编写如下:
```html
<template>
<image src="https://xxx.com/demo.svg" mode="scaleToFill" class="h-20 w-20" />
</template>
```
## H5 额外支持的其他方式
> `SvgComponent` 方式 和 `SvgIcon` 方式,仅 `H5端` 适用,感兴趣的可以阅读下。
> 因为只有 `H5端` 支持,所以 unibest 没有引入这些,但是其他 `web` 项目可以参考。
:::details
### `SvgComponent` 方式
`Web端` 过来的同学都知道 `SvgComponent` 这种方式,只需要引入 `vite-svg-loader` 插件即可,支持 `3种` 方式引入 `svg`: `url`, `raw`, `component`
- URL
SVGs can be imported as URLs using the `?url` suffix:
```js
import iconUrl from './my-icon.svg?url'
// 'data:image/svg+xml...'
```
Used in template:
```html
<template>
<image :src="iconUrl" mode="scaleToFill" class="h-20 w-20" />
</template>
```
- Raw
SVGs can be imported as strings using the `?raw` suffix:
```js
import iconRaw from './my-icon.svg?raw'
// '<?xml version="1.0"?>...'
```
Used in template:
```html
<template>{{ iconRaw }}</template>
```
- Component
SVGs can be explicitly imported as Vue components using the `?component` suffix:
```js
import IconComponent from './my-icon.svg?component'
// <IconComponent />
```
Used in template:
```html
<template>
<IconComponent />
</template>
```
但是目前经过测试,只有 `url` 的方式所有端可以使用,与上面的 `image + src - 相对目录 图标` 是一个效果。至于 `component` 只有 `H5端生效`,其他端不行。
### `SvgIcon` 方式
`Web端` 过来的同学都知道 `SvgIcon` 这种方式,只需要引入 `vite-plugin-svg-icons` 插件 + `vite 配置`,再编写一个通用的 `SvgIcon` 即可,但是同样只有 `H5端生效`,其他端不行。
`vite` 配置如下:
```
createSvgIconsPlugin({
// 指定要缓存的文件夹
iconDirs: [path.resolve(process.cwd(), 'src/assets')],
// 指定symbolId格式
symbolId: 'icon-[dir]-[name]',
}),
```
如上,只需要把 `svg` 放到 `src/assets` 目录即可。
`SvgIcon` 代码如下:
```html
<template>
<svg aria-hidden="true">
<use :href="symbolId" :fill="color" />
</svg>
</template>
<script lang="ts" setup name="SvgIcon">
const props = withDefaults(
defineProps<{
prefix?: string
name: string
color?: string
}>(),
{
prefix: 'icon',
name: '',
color: '#333',
},
)
const symbolId = computed(() => `#${props.prefix}-${props.name}`)
</script>
```
使用方式如下:
```html
<!-- src/assets/demo.svg -->
<SvgIcon name="demo" class="h-20 w-20"></SvgIcon>
<!-- src/assets/dir/demo.svg -->
<SvgIcon name="dir-demo" class="h-20 w-20"></SvgIcon>
```
> `SvgComponent` 依赖 `vite-svg-loader` 插件
>
> `SvgIcon` 依赖 `vite-plugin-svg-icons` 插件
:::
## 总结
适用于跨端的 `svg 和 图片` 的使用方式,只有 `image + src` 的方式。其他方式只能用于 `web` 端,仅供参考。
全文完~

View File

@ -1,120 +0,0 @@
# UI 库替换篇
## 默认 UI 库
`unibest` 经过几次更迭,先后使用 `uni-ui``uv-ui`作为默认 UI 库,目前使用 `wot-ui` 为默认 UI 库。
`wot-ui``vue3+ts` 编写的全端支持的 UI 库,编码体验比 `uv-ui` 更好;而官方维护的 `uni-ui` 则样式略丑,组件较少,故弃之。
> `wot-ui` 全称 `wot-design-uni`,是 `wot-design``uniapp` 版本,文档地址:[https://wot-design-uni.netlify.app/](https://wot-design-uni.netlify.app/).
---
很多群友反馈有其他 `UI` 库的需求,那么更换 `UI 库` 需要哪些步骤呢?
- 先卸载原有的 `wot-ui`
- 再安装其他 `UI 库`
下面我们简单描述一下更换 2 个主流 `UI库` —— `uni-ui` + `uv-ui` 的过程。
> 当然也支持同时存在多个 `UI 库`,有 ES 摇树特性,不必担心打包后的体积。
## 卸载 wot-ui 库
卸载 `wot-ui` 过程如下:
- 1. 删除 `wot-ui` 库:
```sh
pnpm un wot-design-uni
```
- 2. `pages.config.ts` 文件 `easycom.custom` 删除相关配置:
```diff
easycom: {
autoscan: true,
custom: {
- '^wd-(.*)': 'wot-design-uni/components/wd-$1/wd-$1.vue',
},
},
```
- 3. ` tsconfig.json` 文件 `compilerOptions.types` 删除相关配置:
```diff
"types": [
"@dcloudio/types",
"@types/wechat-miniprogram",
- "wot-design-uni/global.d.ts",
"./components.d.ts",
"./global.d.ts"
]
```
## 安装 `uni-ui`
- 1. 安装 `uni-ui` 库:
```sh
pnpm add @dcloudio/uni-ui
```
- 2. `pages.config.ts` 文件 `easycom.custom` 添加相关配置:
```diff
easycom: {
autoscan: true,
custom: {
+ '^uni-(.*)': '@dcloudio/uni-ui/lib/uni-$1/uni-$1.vue',
},
},
```
- 3. ` tsconfig.json` 文件 `compilerOptions.types` 添加相关配置:
```diff
"types": [
"@dcloudio/types",
"@types/wechat-miniprogram",
+ "@uni-helper/uni-ui-types",
"./components.d.ts",
"./global.d.ts"
]
```
## 安装 `uv-ui`
- 1. 安装 `uv-ui` 库:
```sh
pnpm add @climblee/uv-ui
```
- 2. `pages.config.ts` 文件 `easycom.custom` 添加相关配置:
```diff
easycom: {
autoscan: true,
custom: {
+ '^uv-(.*)': '@climblee/uv-ui/components/uv-$1/uv-$1.vue',
},
},
```
- 3. ` tsconfig.json` 文件 `compilerOptions.types` 添加相关配置:
```diff
"types": [
"@dcloudio/types",
"@types/wechat-miniprogram",
+ "@ttou/uv-typings/shim",
+ "@ttou/uv-typings/v2",
"./components.d.ts",
"./global.d.ts"
]
```
> 其他 UI 库的安装类似,不再赘述。
全文完~

View File

@ -1,252 +0,0 @@
# 请求篇
本篇分为三块内容:
- 普通请求
- 图片上传
- 多后台地址
## 普通请求
普通请求分 2 种处理,一种是只在页面请求一次的一次性请求,这种请求占大多数;一种是项目多处用到的请求,这种请求占小部分,需要单独编写一个请求函数放到 `api文件夹` or `service文件夹`
> `unibest` 里面是使用 `service文件夹` 后面不再说明。
下面来分别演示:
### 一次性请求
`template` 部分编码如下:
```html
<template>
<button @click="run">请求</button>
<view v-if="loading" class="text-blue h-10">请求中...</view>
<view v-if="error" class="text-red h-10">请求错误</view>
<view v-else class="text-green h-10">{{ JSON.stringify(data) }}</view>
</template>
```
`script` 部分使用 `菲鸽` 封装好的 `useRequest` 即可实现请求状态一体化,如下:
```ts
<script setup>
type IFooItem = { name: string }
const { loading, error, data, run } = useRequest<IFooItem>(() => httpGet('/foo', { name: '菲鸽' }))
</script>
```
看吧,使用非常简单。
### 重复性请求
`重复性请求``一次性请求``html部分` 是一样的,唯一的区别是 `请求函数` 放到了 `service文件夹`,如下所示:
```ts
<script setup>
import { getFooAPI, IFooItem } from '@/service/index/foo' // 看这里
const { loading, error, data, run } = useRequest<IFooItem>(() => getFooAPI('菲鸽'))
</script>
```
对应的 `src/service/index/foo.ts` 文件如下:
```ts
import { http, httpGet } from '@/utils/http'
export interface IFooItem {
id: string
name: string
}
/** GET 请求 */
export const getFooAPI = (name: string) => {
return http<IFooItem>({
url: `/foo`,
method: 'GET',
query: { name },
})
}
/** GET 请求 - 再次简化,看大家是否喜欢这种简化 */
export const getFooAPI2 = (name: string) => {
return httpGet<IFooItem>('/foo', { name })
}
```
依然非常简洁,深受妹子喜爱。
> 完成范例如下
```ts
/** GET 请求 */
export const getFooAPI = (name: string) => {
return http.get<IFooItem>('/foo', { name })
}
/** GET 请求;支持 传递 header 的范例 */
export const getFooAPI2 = (name: string) => {
return http.get<IFooItem>('/foo', { name }, { 'Content-Type-100': '100' })
}
/** POST 请求 */
export const postFooAPI = (name: string) => {
return http.post<IFooItem>('/foo', { name })
}
/** POST 请求;需要传递 query 参数的范例微信小程序经常有同时需要query参数和body参数的场景 */
export const postFooAPI2 = (name: string) => {
return http.post<IFooItem>('/foo', { name })
}
/** POST 请求;支持 传递 header 的范例 */
export const postFooAPI3 = (name: string) => {
return http.post<IFooItem>('/foo', { name }, { name }, { 'Content-Type-100': '100' })
}
```
## 图片上传
`template` 部分编码如下:
```html
<template>
<view class="p-4 text-center">
<wd-button @click="run">选择图片并上传</wd-button>
<view v-if="loading" class="text-blue h-10">上传...</view>
<template v-else>
<view class="m-2">上传后返回的图片地址:</view>
<view class="m-2">{{ data }}</view>
<view class="h-80 w-full">
<image v-if="data" :src="data" mode="scaleToFill" />
</view>
</template>
</view>
</template>
```
`script` 部分使用 `菲鸽` 封装好的 `useUpload` 即可实现请求状态一体化,如下:
```ts
<script lang="ts" setup>
const { loading, data, run } = useUpload<string>({ user: '菲鸽' })
</script>
```
使用非常简单,深受汉子和妹子的喜爱。
## 多后台地址
上面的 `普通请求` 默认是只有一个请求地址的,在 `.env` 里面配置 `VITE_SERVER_BASEURL`,如下:
```text
VITE_SERVER_BASEURL = 'https://ukw0y1.laf.run'
```
并且在 `src/interceptors/request.ts` 里面有设置:
- 如果是 `http` 开头的请求路径,则直接请求
- 如果不是,则拼接上 `VITE_SERVER_BASEURL`
![alt text](./assets/8-1.png)
但在多后台地址时就不能这么玩了,需要处理如下:(关注上图的箭头部分)
```ts
// 可以写一个映射对象,如:
const proxyMap = {
cms:'http://localhost:8080/cms',
ums:'http://localhost:8080/ums',
}
// 拦截器部分(上图箭头部分)修改如下
Object.keys(proxyMap).forEach(key=>{
if(options.url.startsWith(`/${key}`)){
options.url = proxyMap[key] + options.url
}
}
// 接口调用的地方使用如下格式:
export const getFooAPI = (name: string) => {
return http<IFooItem>({
url: `/cms/foo`, // 看这里,前缀不用!!!
method: 'GET',
query: { name },
})
}
```
## 支持header传递
目前v2.6.2)已经支持 `header` 了,具体使用方法如下:(最后一个参数就是 `header`,不需要不用传,需要才传。)
```ts
/** GET 请求 */
export const getFooAPI = (name: string) => {
return http.get<IFooItem>('/foo', { name }, { 'Content-Type': 'multipart/form-data' })
}
/** POST 请求 */
export const postFooAPI = (name: string) => {
return http.post<IFooItem>('/foo', { name }, { name }, { 'Content-Type': 'multipart/form-data' })
}
```
低于v2.6.2版本需要手动设置header具体使用方法如下(`utils/http.ts`)
```diff
/**
* GET 请求
* @param url 后台地址
* @param query 请求query参数
+ * @param header 请求头默认为json格式
* @returns
*/
export const httpGet = <T>(
url: string,
query?: Record<string, any>,
+ header?: Record<string, any>,
) => {
return http<T>({
url,
query,
method: 'GET',
+ header,
})
}
/**
* POST 请求
* @param url 后台地址
* @param data 请求body参数
* @param query 请求query参数post请求也支持query很多微信接口都需要
+ * @param header 请求头默认为json格式
* @returns
*/
export const httpPost = <T>(
url: string,
data?: Record<string, any>,
query?: Record<string, any>,
+ header?: Record<string, any>,
) => {
return http<T>({
url,
query,
data,
method: 'POST',
+ header,
})
}
```
## 环境变量配置
- `普通请求` 需要在 `.env` 里面配置 `VITE_SERVER_BASEURL`,用在 `src/interceptors/request.ts` 文件拼接请求地址;而 `多后台地址` 时则用不上,可以删除。
```text
VITE_SERVER_BASEURL = 'https://ukw0y1.laf.run'
```
- `图片上传` 需要在 `.env` 里面配置 `VITE_UPLOAD_BASEURL`:
```text
VITE_UPLOAD_BASEURL = 'https://ukw0y1.laf.run/upload'
```
全文完~

View File

@ -1,165 +0,0 @@
# 状态篇
本文主要介绍了全局状态管理 `pinia` 和 简单状态 `ref` + `reactive`
## pinia
`unibest` 已经内置了 `Pinia` + `pinia-plugin-persistedstate`(数据持久化插件),并提供了开箱即用的示例。
### 兼容性处理
本身 `pinia-plugin-persistedstate` 是不支持 `uniapp` 的,但是 `pinia-plugin-persistedstate` 提供了修改 `storage` 存储 API 的方式(默认是 `localStorage`,是一个 `WEB API``非H5端` 不支持),目前 `unibest` 已经处理好了。关键代码如下:
```ts
import { createPinia } from 'pinia'
import { createPersistedState } from 'pinia-plugin-persistedstate' // 数据持久化
const store = createPinia()
store.use(
createPersistedState({
storage: {
getItem: uni.getStorageSync, // 看这里
setItem: uni.setStorageSync, // 看这里
},
}),
)
```
### 定义 `pinia` 全局状态
`src/store/xxx.ts` 里面编写代码,如下是 `src/store/count.ts` 文件。
注意 `defineStore` 第三个参数可以设置是否需要持久化,默认不需要。
```ts [src/store/count.ts]{26}
import { defineStore } from 'pinia'
import { ref } from 'vue'
export const useCountStore = defineStore(
'count',
() => {
const count = ref(0)
const increment = () => {
count.value++
}
const decrement = () => {
count.value--
}
const reset = () => {
count.value = 0
}
return {
count,
decrement,
increment,
reset,
}
},
{
// 如果需要持久化就写 true, 不需要持久化就写 false或者去掉这个配置项
persist: true,
},
)
```
> 请不要随意把数据丢到 `pinia`,能不用就不用。简单状态尽量使用 `ref` 或者 `reactive`
### 使用 `pinia` 全局状态
`vue` 文件中就可以使用了,如下是 `src/pages/demo.vue` 文件:
```vue
<template>
<view class="flex justify-center items-center text-blue-500 mt-4 mb-4">
<view class="w-20">Count: {{ countStore.count }}</view>
<button class="ml-2 mr-2" @click="countStore.decrement">-1</button>
<button class="ml-2 mr-2" @click="countStore.increment">+1</button>
<button class="ml-2 mr-2" @click="countStore.reset">重置</button>
</view>
</template>
<script lang="ts" setup>
import { useCountStore } from '@/store'
const countStore = useCountStore()
</script>
```
## 简单状态
你可以直接使用 `Vue` 提供的 `ref``reactive` 方法来做简单状态管理。
### ref
如下是 `src/pages/demo/useCount.ts` 文件,定义简单状态。
```ts [src/pages/demo/useCount.ts]
// 全局状态
const globalCount = ref(1)
export function useCount() {
// 本地状态
const localCount = ref(1)
function increment() {
globalCount.value++
localCount.value++
}
return {
globalCount,
localCount,
increment,
}
}
```
如下是 `src/pages/demo/index.vue`,与 `ref` 简单状态文件放到同一个目录下,方便管理。
```vue [src/pages/demo/index.vue]
<script setup lang="ts">
import useCount from './useCount.ts'
const { globalCount, localCount, increment } = useCount()
</script>
<template>
<button @click="increment()">
{{ globalCount }}
{{ localCount }}
</button>
</template>
```
## reactive
`reactive``ref` 类似。
如下是 `src/pages/demo/count.ts` 文件,定义状态。
```ts [src/pages/demo/count.ts]
export const countStore = reactive({
count: 0,
increment() {
this.count++
},
})
```
如下是 `src/pages/demo/index.vue`,与 `reactive` 简单状态文件放到同一个目录下,方便管理。
```vue [src/pages/demo/index.vue]
<script setup lang="ts">
import { countStore } from './count.ts'
</script>
<template>
<button @click="countStore.increment()">
{{ countStore.count }}
</button>
</template>
```
## 总结
本文介绍了 `unibest` 里面状态管理的 `2` 种方式:`pinia` 全局状态 和 `ref\reactive` 简单状态,分别演示了如何定义状态和使用状态。
注意需要灵活使用 `pinia``简单状态`,局部的状态尽量使用 `简单状态` 的方式来处理,减少 `pinia` 里面全局变量的数量。
全文完~

Binary file not shown.

Before

Width:  |  Height:  |  Size: 291 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 485 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 33 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 202 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 484 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 245 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 49 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 50 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 84 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 33 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 236 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 642 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 888 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 705 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 43 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 45 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 60 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 120 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 94 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 220 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 211 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 286 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 166 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 513 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 549 KiB

Some files were not shown because too many files have changed in this diff Show More