bestuni 1.0.0 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (74) hide show
  1. package/.env +7 -0
  2. package/.env.development +4 -0
  3. package/.env.production +4 -0
  4. package/LICENSE +21 -0
  5. package/README.md +131 -0
  6. package/package.json +69 -14
  7. package/src/App.vue +32 -0
  8. package/src/env.d.ts +17 -0
  9. package/src/main.ts +17 -0
  10. package/src/manifest.json +58 -0
  11. package/src/pages/index/index.vue +79 -0
  12. package/src/pages/mine/index.vue +82 -0
  13. package/src/pages.json +44 -0
  14. package/src/stores/app.ts +60 -0
  15. package/src/stores/index.ts +2 -0
  16. package/src/stores/user.ts +74 -0
  17. package/src/styles/index.scss +131 -0
  18. package/src/styles/variables.scss +38 -0
  19. package/src/uni.scss +4 -0
  20. package/src/utils/index.ts +2 -0
  21. package/src/utils/request.ts +100 -0
  22. package/src/utils/router.ts +88 -0
  23. package/tsconfig.json +37 -0
  24. package/uno.config.ts +45 -0
  25. package/vite.config.ts +72 -0
  26. package/index.js +0 -73
  27. package/template/basic/.env +0 -3
  28. package/template/basic/.env.development +0 -3
  29. package/template/basic/.env.production +0 -3
  30. package/template/basic/.eslintrc-auto-import.json +0 -103
  31. package/template/basic/.eslintrc.js +0 -23
  32. package/template/basic/.prettierrc.js +0 -14
  33. package/template/basic/.vscode/settings.json +0 -23
  34. package/template/basic/index.html +0 -20
  35. package/template/basic/package.json +0 -93
  36. package/template/basic/pnpm-lock.yaml +0 -11048
  37. package/template/basic/shims-uni.d.ts +0 -10
  38. package/template/basic/src/App.vue +0 -18
  39. package/template/basic/src/api/user.ts +0 -17
  40. package/template/basic/src/enums/constantEnums.ts +0 -11
  41. package/template/basic/src/enums/request.ts +0 -22
  42. package/template/basic/src/env.d.ts +0 -8
  43. package/template/basic/src/hooks/useRequest.ts +0 -38
  44. package/template/basic/src/hooks/useUpload.ts +0 -170
  45. package/template/basic/src/main.ts +0 -11
  46. package/template/basic/src/manifest.json +0 -71
  47. package/template/basic/src/pages/index/index.vue +0 -21
  48. package/template/basic/src/pages/tabBar/index.vue +0 -7
  49. package/template/basic/src/pages/tabBar/records.vue +0 -7
  50. package/template/basic/src/pages/tabBar/user.vue +0 -7
  51. package/template/basic/src/pages.json +0 -68
  52. package/template/basic/src/request/cancel.ts +0 -29
  53. package/template/basic/src/request/http.ts +0 -150
  54. package/template/basic/src/request/index.ts +0 -98
  55. package/template/basic/src/request/type.d.ts +0 -30
  56. package/template/basic/src/shime-uni.d.ts +0 -6
  57. package/template/basic/src/static/tabbar/home.png +0 -0
  58. package/template/basic/src/static/tabbar/home_s.png +0 -0
  59. package/template/basic/src/static/tabbar/news.png +0 -0
  60. package/template/basic/src/static/tabbar/news_s.png +0 -0
  61. package/template/basic/src/static/tabbar/user.png +0 -0
  62. package/template/basic/src/static/tabbar/user_s.png +0 -0
  63. package/template/basic/src/stores/index.ts +0 -17
  64. package/template/basic/src/stores/user.ts +0 -117
  65. package/template/basic/src/types/auto-import.d.ts +0 -189
  66. package/template/basic/src/types/pinia.d.ts +0 -0
  67. package/template/basic/src/types/type.ts +0 -21
  68. package/template/basic/src/uni.scss +0 -76
  69. package/template/basic/src/utils/cache.ts +0 -50
  70. package/template/basic/src/utils/config.ts +0 -29
  71. package/template/basic/src/utils/env.ts +0 -13
  72. package/template/basic/tsconfig.json +0 -21
  73. package/template/basic/uno.config.ts +0 -99
  74. package/template/basic/vite.config.ts +0 -27
package/.env ADDED
@@ -0,0 +1,7 @@
1
+ # 环境变量
2
+
3
+ # API 基础地址
4
+ VITE_API_BASE_URL=
5
+
6
+ # 应用标题
7
+ VITE_APP_TITLE=SMT UniApp
@@ -0,0 +1,4 @@
1
+ # 开发环境
2
+
3
+ VITE_API_BASE_URL=http://localhost:3000/api
4
+ VITE_APP_TITLE=SMT UniApp (Dev)
@@ -0,0 +1,4 @@
1
+ # 生产环境
2
+
3
+ VITE_API_BASE_URL=https://api.example.com
4
+ VITE_APP_TITLE=SMT UniApp
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 sumintong
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,131 @@
1
+ # BestUni
2
+
3
+ <p align="left">
4
+ <img src="https://img.shields.io/npm/v/bestuni.svg" alt="npm version">
5
+ <img src="https://img.shields.io/badge/license-MIT-green.svg" alt="License">
6
+ <img src="https://img.shields.io/badge/vue-3.x-green.svg" alt="Vue">
7
+ <img src="https://img.shields.io/badge/uniapp-compatible-green.svg" alt="UniApp">
8
+ </p>
9
+
10
+ **BestUni** - 基于 **Vue 3 + TypeScript + Vite** 的 UniApp 快速启动模板。
11
+
12
+ ## ✨ 特性
13
+
14
+ - 🚀 **Vue 3 + TypeScript** - 使用最新的 Vue 3 组合式 API
15
+ - 📦 **Vite 5** - 极速冷启动与热更新
16
+ - 🗃 **Pinia** - 状态管理 + 持久化存储
17
+ - 🔐 **请求封装** - Token 自动注入、错误统一处理
18
+ - 📱 **多端支持** - H5、微信小程序、支付宝小程序、App
19
+ - 🎨 **主题定制** - 支持亮色/暗黑模式切换
20
+
21
+ ## 📦 安装
22
+
23
+ ```bash
24
+ # 克隆模板
25
+ npx degit sumintong/bestuni my-app
26
+
27
+ # 或直接下载
28
+ npm init bestuni my-app
29
+ ```
30
+
31
+ ## 📂 目录结构
32
+
33
+ ```
34
+ src/
35
+ ├── composables/ # 组合式函数
36
+ ├── layouts/ # 布局组件
37
+ ├── pages/ # 页面目录
38
+ │ ├── index/ # 首页
39
+ │ └── mine/ # 我的
40
+ ├── stores/ # Pinia 状态管理
41
+ │ ├── app.ts # 应用状态
42
+ │ ├── user.ts # 用户状态
43
+ │ └── index.ts
44
+ ├── styles/ # 全局样式
45
+ │ ├── variables.scss # SCSS 变量
46
+ │ └── index.scss # 样式入口
47
+ ├── utils/ # 工具函数
48
+ │ ├── request.ts # 请求封装
49
+ │ ├── router.ts # 路由工具
50
+ │ └── index.ts
51
+ ├── static/ # 静态资源
52
+ ├── App.vue # 根组件
53
+ ├── main.ts # 入口文件
54
+ ├── manifest.json # 应用配置
55
+ ├── pages.json # 页面配置
56
+ └── uni.scss # 全局样式变量
57
+ ```
58
+
59
+ ## 🚀 快速开始
60
+
61
+ ### 安装依赖
62
+
63
+ ```bash
64
+ pnpm install
65
+ ```
66
+
67
+ ### 运行项目
68
+
69
+ ```bash
70
+ # H5
71
+ pnpm dev
72
+
73
+ # 微信小程序
74
+ pnpm dev:mp-weixin
75
+
76
+ # App
77
+ pnpm dev:app
78
+ ```
79
+
80
+ ### 打包发布
81
+
82
+ ```bash
83
+ # H5
84
+ pnpm build:h5
85
+
86
+ # 微信小程序
87
+ pnpm build:mp-weixin
88
+
89
+ # App
90
+ pnpm build:app
91
+ ```
92
+
93
+ ## 🗃 状态管理
94
+
95
+ 使用 Pinia 进行状态管理,已配置持久化存储:
96
+
97
+ ```typescript
98
+ import { useUserStore } from '@/stores'
99
+
100
+ const userStore = useUserStore()
101
+
102
+ // 登录
103
+ await userStore.login({ token: 'xxx', userInfo: { ... } })
104
+
105
+ // 登出
106
+ userStore.logout()
107
+ ```
108
+
109
+ ## 🔐 请求封装
110
+
111
+ ```typescript
112
+ import { request, get, post } from '@/utils'
113
+
114
+ // 基础请求
115
+ const res = await request({ url: '/api/user', method: 'GET' })
116
+
117
+ // 快捷方法
118
+ const data = await get('/api/user')
119
+ const result = await post('/api/login', { username: 'admin' })
120
+ ```
121
+
122
+ ## 🔗 相关链接
123
+
124
+ - [UniApp 官网](https://uniapp.dcloud.net.cn/)
125
+ - [Vue 3 文档](https://cn.vuejs.org/)
126
+ - [Pinia 文档](https://pinia.vuejs.org/zh/)
127
+ - [Vite 文档](https://cn.vitejs.dev/)
128
+
129
+ ## 📄 License
130
+
131
+ MIT License © 2026 sumintong
package/package.json CHANGED
@@ -1,15 +1,70 @@
1
- {
2
- "name": "bestuni",
3
- "version": "1.0.0",
4
- "bin": {
5
- "bestUNI": "./index.js"
6
- },
7
- "description": "",
8
- "main": "index.js",
9
- "keywords": [],
10
- "author": "",
11
- "license": "ISC",
12
- "scripts": {
13
- "test": "echo \"Error: no test specified\" && exit 1"
14
- }
1
+ {
2
+ "name": "bestuni",
3
+ "version": "2.0.0",
4
+ "description": "基于 Vue3 + TypeScript + Vite + UnoCSS 的 UniApp 快速启动模板,内置高颜值 UI 组件库",
5
+ "author": "sumintong",
6
+ "license": "MIT",
7
+ "keywords": [
8
+ "uniapp",
9
+ "vue3",
10
+ "typescript",
11
+ "vite",
12
+ "unocss",
13
+ "ui",
14
+ "template",
15
+ "mobile",
16
+ "wechat",
17
+ "miniprogram"
18
+ ],
19
+ "repository": {
20
+ "type": "git",
21
+ "url": "https://github.com/sumintong/bestuni"
22
+ },
23
+ "homepage": "https://github.com/sumintong/bestuni#readme",
24
+ "scripts": {
25
+ "dev": "uni",
26
+ "dev:h5": "uni",
27
+ "dev:mp-weixin": "uni -p mp-weixin",
28
+ "dev:mp-alipay": "uni -p mp-alipay",
29
+ "dev:app": "uni -p app",
30
+ "build": "uni build",
31
+ "build:h5": "uni build",
32
+ "build:mp-weixin": "uni build -p mp-weixin",
33
+ "build:app": "uni build -p app",
34
+ "type-check": "vue-tsc --noEmit"
35
+ },
36
+ "files": [
37
+ "src",
38
+ "*.json",
39
+ "*.ts",
40
+ ".env*",
41
+ "README.md"
42
+ ],
43
+ "dependencies": {
44
+ "@dcloudio/uni-app": "3.0.0-4080420251103001",
45
+ "@dcloudio/uni-app-plus": "3.0.0-4080420251103001",
46
+ "@dcloudio/uni-components": "3.0.0-4080420251103001",
47
+ "@dcloudio/uni-h5": "3.0.0-4080420251103001",
48
+ "@dcloudio/uni-mp-weixin": "3.0.0-4080420251103001",
49
+ "@dcloudio/uni-mp-alipay": "3.0.0-4080420251103001",
50
+ "@sumintong/smt-ui": "^0.0.1",
51
+ "vue": "^3.4.21",
52
+ "pinia": "^2.1.7",
53
+ "pinia-plugin-persistedstate": "^3.2.1"
54
+ },
55
+ "devDependencies": {
56
+ "@dcloudio/types": "^3.4.8",
57
+ "@dcloudio/uni-cli-shared": "3.0.0-4080420251103001",
58
+ "@dcloudio/vite-plugin-uni": "3.0.0-4080420251103001",
59
+ "@iconify-json/carbon": "^1.1.0",
60
+ "@types/node": "^20.0.0",
61
+ "@unocss/preset-icons": "^0.58.0",
62
+ "typescript": "^5.0.0",
63
+ "unocss": "^0.58.0",
64
+ "unplugin-auto-import": "^0.17.0",
65
+ "unplugin-vue-components": "^0.26.0",
66
+ "vite": "^5.2.8",
67
+ "vue-tsc": "^2.0.0",
68
+ "sass": "^1.60.0"
69
+ }
15
70
  }
package/src/App.vue ADDED
@@ -0,0 +1,32 @@
1
+ <template>
2
+ <mt-config-provider :theme="theme" :dark="isDark">
3
+ <slot />
4
+ </mt-config-provider>
5
+ </template>
6
+
7
+ <script setup lang="ts">
8
+ const appStore = useAppStore()
9
+
10
+ const isDark = computed(() => appStore.theme === 'dark')
11
+
12
+ const theme = computed(() => ({
13
+ primaryColor: '#1989fa',
14
+ successColor: '#07c160',
15
+ warningColor: '#ff976a',
16
+ dangerColor: '#fa5151'
17
+ }))
18
+
19
+ onLaunch(() => {
20
+ console.log('App Launch')
21
+ appStore.initSystemInfo()
22
+ })
23
+ </script>
24
+
25
+ <style lang="scss">
26
+ /* 引入 UnoCSS 基础样式 */
27
+ @import 'uno.css';
28
+ /* 引入 UI 库样式 */
29
+ @import '@sumintong/smt-ui/src/index.scss';
30
+ /* 引入项目全局样式 */
31
+ @import '@/styles/index.scss';
32
+ </style>
package/src/env.d.ts ADDED
@@ -0,0 +1,17 @@
1
+ /// <reference types="vite/client" />
2
+ /// <reference types="@dcloudio/types" />
3
+
4
+ declare module '*.vue' {
5
+ import type { DefineComponent } from 'vue'
6
+ const component: DefineComponent<{}, {}, any>
7
+ export default component
8
+ }
9
+
10
+ interface ImportMetaEnv {
11
+ readonly VITE_API_BASE_URL: string
12
+ readonly VITE_APP_TITLE: string
13
+ }
14
+
15
+ interface ImportMeta {
16
+ readonly env: ImportMetaEnv
17
+ }
package/src/main.ts ADDED
@@ -0,0 +1,17 @@
1
+ import { createSSRApp } from 'vue'
2
+ import { createPinia } from 'pinia'
3
+ import piniaPluginPersistedstate from 'pinia-plugin-persistedstate'
4
+ import App from './App.vue'
5
+
6
+ export function createApp() {
7
+ const app = createSSRApp(App)
8
+
9
+ // 创建 Pinia 实例
10
+ const pinia = createPinia()
11
+ pinia.use(piniaPluginPersistedstate)
12
+ app.use(pinia)
13
+
14
+ return {
15
+ app
16
+ }
17
+ }
@@ -0,0 +1,58 @@
1
+ {
2
+ "name": "SMT UniApp",
3
+ "appid": "",
4
+ "description": "基于 Vue3 + TypeScript + @sumintong/smt-ui 的 UniApp 快速启动模板",
5
+ "versionName": "1.0.0",
6
+ "versionCode": "100",
7
+ "transformPx": false,
8
+ "h5": {
9
+ "title": "SMT UniApp",
10
+ "router": {
11
+ "mode": "hash",
12
+ "base": "./"
13
+ },
14
+ "optimization": {
15
+ "treeShaking": {
16
+ "enable": true
17
+ }
18
+ }
19
+ },
20
+ "mp-weixin": {
21
+ "appid": "",
22
+ "setting": {
23
+ "urlCheck": false,
24
+ "es6": true,
25
+ "minified": true
26
+ },
27
+ "usingComponents": true,
28
+ "optimization": {
29
+ "subPackages": true
30
+ }
31
+ },
32
+ "mp-alipay": {
33
+ "usingComponents": true
34
+ },
35
+ "app-plus": {
36
+ "usingComponents": true,
37
+ "nvueCompiler": "uni-app",
38
+ "compilerVersion": 3,
39
+ "splashscreen": {
40
+ "alwaysShowBeforeRender": true,
41
+ "waiting": true,
42
+ "autoclose": true,
43
+ "delay": 0
44
+ },
45
+ "modules": {},
46
+ "distribute": {
47
+ "android": {
48
+ "permissions": [
49
+ "<uses-permission android:name=\"android.permission.INTERNET\"/>"
50
+ ]
51
+ },
52
+ "ios": {}
53
+ }
54
+ },
55
+ "uniStatistics": {
56
+ "enable": false
57
+ }
58
+ }
@@ -0,0 +1,79 @@
1
+ <template>
2
+ <view class="min-h-100vh pb-10">
3
+ <!-- 欢迎区域 -->
4
+ <view class="pt-20 pb-15 px-4 text-center bg-gradient-to-br from-primary to-[#6dd5fa] text-white">
5
+ <view class="text-14 font-bold mb-4">BestUni</view>
6
+ <view class="text-3 opacity-90">基于 Vue3 + TS + Vite + UnoCSS + SMT-UI</view>
7
+ </view>
8
+
9
+ <!-- 功能展示 -->
10
+ <view class="p-4">
11
+ <view class="text-4 font-bold mb-4 text-[#323233]">🧩 组件展示</view>
12
+
13
+ <view class="card !m-0 !mb-4">
14
+ <view class="text-3.5 font-500 mb-4 text-[#323233]">Button 按钮 (Auto Import)</view>
15
+ <view class="flex flex-wrap gap-2">
16
+ <mt-button type="primary" size="small">主要按钮</mt-button>
17
+ <mt-button type="success" size="small">成功按钮</mt-button>
18
+ <mt-button type="warning" size="small">警告按钮</mt-button>
19
+ <mt-button type="danger" size="small">危险按钮</mt-button>
20
+ </view>
21
+ </view>
22
+
23
+ <view class="card !m-0 !mb-4">
24
+ <view class="text-3.5 font-500 mb-4 text-[#323233]">Cell 单元格</view>
25
+ <mt-cell-group inset>
26
+ <mt-cell title="自动路由" label="基于文件系统" is-link />
27
+ <mt-cell title="暗黑模式" label="支持一键切换" is-link />
28
+ </mt-cell-group>
29
+ </view>
30
+
31
+ <view class="card !m-0 !mb-4">
32
+ <view class="text-3.5 font-500 mb-4 text-[#323233]">UnoCSS 演示</view>
33
+ <view class="flex items-center gap-4">
34
+ <view class="w-12 h-12 bg-primary rd-full flex-center text-white">Uni</view>
35
+ <view class="w-12 h-12 bg-success rd-2 flex-center text-white">Vue</view>
36
+ <view class="w-12 h-12 bg-warning rd-lt-2 rd-rb-2 flex-center text-white">Vite</view>
37
+ </view>
38
+ <view class="mt-4 p-2 bg-gray-1 rd text-2.5 text-secondary">
39
+ 上面三个方块使用了 UnoCSS 的原子化类名构建。
40
+ </view>
41
+ </view>
42
+ </view>
43
+
44
+ <!-- 主题切换 -->
45
+ <view class="card flex-between !mb-4">
46
+ <text class="text-3.5">当前模式: {{ isDark ? '深色' : '浅色' }}</text>
47
+ <mt-switch :model-value="isDark" @update:model-value="toggleTheme" />
48
+ </view>
49
+
50
+ <view class="px-4">
51
+ <mt-button @click="handleRequest" block type="primary" plain>测试接口请求</mt-button>
52
+ </view>
53
+ </view>
54
+ </template>
55
+
56
+ <script setup lang="ts">
57
+ const appStore = useAppStore()
58
+
59
+ const isDark = computed(() => appStore.isDark)
60
+
61
+ const toggleTheme = () => {
62
+ appStore.toggleTheme()
63
+ }
64
+
65
+ const handleRequest = async () => {
66
+ try {
67
+ // 使用自动导入的 get 方法
68
+ const res = await get('/test')
69
+ console.log('请求结果:', res)
70
+ uni.showToast({ title: '请求成功', icon: 'success' })
71
+ } catch (err) {
72
+ uni.showToast({ title: '请求示例失败(未配接口)', icon: 'none' })
73
+ }
74
+ }
75
+ </script>
76
+
77
+ <style lang="scss" scoped>
78
+ // UnoCSS 处理了大部分样式,此处仅保留必要逻辑
79
+ </style>
@@ -0,0 +1,82 @@
1
+ <template>
2
+ <view class="min-h-100vh bg-[#f7f8fa]">
3
+ <!-- 用户信息 -->
4
+ <view class="flex items-center p-8 bg-gradient-to-br from-primary to-[#6dd5fa] text-white">
5
+ <view class="mr-6">
6
+ <mt-avatar
7
+ :src="userInfo?.avatar || ''"
8
+ size="large"
9
+ round
10
+ custom-class="border-2 border-white/50"
11
+ >
12
+ {{ userInfo?.nickname?.charAt(0) || '游' }}
13
+ </mt-avatar>
14
+ </view>
15
+ <view class="flex-1">
16
+ <view class="text-4.5 font-bold mb-1">{{ userInfo?.nickname || '未登录用户' }}</view>
17
+ <view class="text-3 opacity-80">{{ isLoggedIn ? '已通过认证' : '点击头像登录体验更多功能' }}</view>
18
+ </view>
19
+ </view>
20
+
21
+ <!-- 功能列表 -->
22
+ <view class="mt-4">
23
+ <mt-cell-group inset title="账户设置">
24
+ <mt-cell title="个人资料" icon="user-o" is-link />
25
+ <mt-cell title="通知设置" icon="bell" is-link />
26
+ <mt-cell title="清除缓存" icon="delete-o" is-link @click="handleClearCache" />
27
+ </mt-cell-group>
28
+ </view>
29
+
30
+ <view class="mt-4">
31
+ <mt-cell-group inset title="关于">
32
+ <mt-cell title="版本信息" value="v2.1.0" icon="info-o" />
33
+ <mt-cell title="开源声明" icon="github-o" is-link />
34
+ <mt-cell title="加入我们" icon="friends-o" is-link />
35
+ </mt-cell-group>
36
+ </view>
37
+
38
+ <view v-if="isLoggedIn" class="mt-8 px-4">
39
+ <mt-button type="danger" block round @click="handleLogout">退出登录</mt-button>
40
+ </view>
41
+
42
+ <view class="mt-10 pb-10 text-center text-2.5 text-gray-4">
43
+ BestUni & SMT-Design © 2026
44
+ </view>
45
+ </view>
46
+ </template>
47
+
48
+ <script setup lang="ts">
49
+ const userStore = useUserStore()
50
+
51
+ // 利用自动导入的 computed 和 stores
52
+ const userInfo = computed(() => userStore.userInfo)
53
+ const isLoggedIn = computed(() => userStore.isLoggedIn)
54
+
55
+ const handleClearCache = () => {
56
+ uni.showModal({
57
+ title: '提示',
58
+ content: '确定要清除所有本地数据吗?',
59
+ success: (res) => {
60
+ if (res.confirm) {
61
+ uni.clearStorageSync()
62
+ uni.showToast({ title: '清理完成', icon: 'success' })
63
+ }
64
+ }
65
+ })
66
+ }
67
+
68
+ const handleLogout = () => {
69
+ uni.showModal({
70
+ title: '确认退出',
71
+ content: '退出后需要重新验证身份',
72
+ success: (res) => {
73
+ if (res.confirm) {
74
+ userStore.logout()
75
+ }
76
+ }
77
+ })
78
+ }
79
+ </script>
80
+
81
+ <style lang="scss" scoped>
82
+ </style>
package/src/pages.json ADDED
@@ -0,0 +1,44 @@
1
+ {
2
+ "pages": [
3
+ {
4
+ "path": "pages/index/index",
5
+ "style": {
6
+ "navigationBarTitleText": "首页"
7
+ }
8
+ },
9
+ {
10
+ "path": "pages/mine/index",
11
+ "style": {
12
+ "navigationBarTitleText": "我的"
13
+ }
14
+ }
15
+ ],
16
+ "tabBar": {
17
+ "color": "#999999",
18
+ "selectedColor": "#1989fa",
19
+ "backgroundColor": "#ffffff",
20
+ "borderStyle": "black",
21
+ "list": [
22
+ {
23
+ "pagePath": "pages/index/index",
24
+ "text": "首页"
25
+ },
26
+ {
27
+ "pagePath": "pages/mine/index",
28
+ "text": "我的"
29
+ }
30
+ ]
31
+ },
32
+ "easycom": {
33
+ "autoscan": true,
34
+ "custom": {
35
+ "^mt-(.*)": "@sumintong/smt-ui/src/components/$1/$1.vue"
36
+ }
37
+ },
38
+ "globalStyle": {
39
+ "navigationBarTextStyle": "black",
40
+ "navigationBarTitleText": "SMT UniApp",
41
+ "navigationBarBackgroundColor": "#ffffff",
42
+ "backgroundColor": "#f5f5f5"
43
+ }
44
+ }
@@ -0,0 +1,60 @@
1
+ import { defineStore } from 'pinia'
2
+ import { ref, computed } from 'vue'
3
+
4
+ export const useAppStore = defineStore('app', () => {
5
+ // 主题模式
6
+ const theme = ref<'light' | 'dark'>('light')
7
+
8
+ // 系统信息
9
+ const systemInfo = ref<UniApp.GetSystemInfoResult | null>(null)
10
+
11
+ // 是否暗黑模式
12
+ const isDark = computed(() => theme.value === 'dark')
13
+
14
+ // 切换主题
15
+ const toggleTheme = () => {
16
+ theme.value = theme.value === 'light' ? 'dark' : 'light'
17
+ }
18
+
19
+ // 设置主题
20
+ const setTheme = (value: 'light' | 'dark') => {
21
+ theme.value = value
22
+ }
23
+
24
+ // 初始化系统信息
25
+ const initSystemInfo = () => {
26
+ uni.getSystemInfo({
27
+ success: (res) => {
28
+ systemInfo.value = res
29
+ }
30
+ })
31
+ }
32
+
33
+ // 安全区域
34
+ const safeAreaInsets = computed(() => {
35
+ if (!systemInfo.value) return { top: 0, bottom: 0 }
36
+ return {
37
+ top: systemInfo.value.safeAreaInsets?.top || 0,
38
+ bottom: systemInfo.value.safeAreaInsets?.bottom || 0
39
+ }
40
+ })
41
+
42
+ return {
43
+ theme,
44
+ systemInfo,
45
+ isDark,
46
+ safeAreaInsets,
47
+ toggleTheme,
48
+ setTheme,
49
+ initSystemInfo
50
+ }
51
+ }, {
52
+ persist: {
53
+ key: 'smt-app',
54
+ storage: {
55
+ getItem: (key) => uni.getStorageSync(key),
56
+ setItem: (key, value) => uni.setStorageSync(key, value)
57
+ },
58
+ pick: ['theme']
59
+ }
60
+ })
@@ -0,0 +1,2 @@
1
+ export { useAppStore } from './app'
2
+ export { useUserStore } from './user'