bestuni 1.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.
- package/index.js +73 -0
- package/package.json +15 -0
- package/template/basic/.env +3 -0
- package/template/basic/.env.development +3 -0
- package/template/basic/.env.production +3 -0
- package/template/basic/.eslintrc-auto-import.json +103 -0
- package/template/basic/.eslintrc.js +23 -0
- package/template/basic/.prettierrc.js +14 -0
- package/template/basic/.vscode/settings.json +23 -0
- package/template/basic/index.html +20 -0
- package/template/basic/package.json +93 -0
- package/template/basic/pnpm-lock.yaml +11048 -0
- package/template/basic/shims-uni.d.ts +10 -0
- package/template/basic/src/App.vue +18 -0
- package/template/basic/src/api/user.ts +17 -0
- package/template/basic/src/enums/constantEnums.ts +11 -0
- package/template/basic/src/enums/request.ts +22 -0
- package/template/basic/src/env.d.ts +8 -0
- package/template/basic/src/hooks/useRequest.ts +38 -0
- package/template/basic/src/hooks/useUpload.ts +170 -0
- package/template/basic/src/main.ts +11 -0
- package/template/basic/src/manifest.json +71 -0
- package/template/basic/src/pages/index/index.vue +21 -0
- package/template/basic/src/pages/tabBar/index.vue +7 -0
- package/template/basic/src/pages/tabBar/records.vue +7 -0
- package/template/basic/src/pages/tabBar/user.vue +7 -0
- package/template/basic/src/pages.json +68 -0
- package/template/basic/src/request/cancel.ts +29 -0
- package/template/basic/src/request/http.ts +150 -0
- package/template/basic/src/request/index.ts +98 -0
- package/template/basic/src/request/type.d.ts +30 -0
- package/template/basic/src/shime-uni.d.ts +6 -0
- package/template/basic/src/static/tabbar/home.png +0 -0
- package/template/basic/src/static/tabbar/home_s.png +0 -0
- package/template/basic/src/static/tabbar/news.png +0 -0
- package/template/basic/src/static/tabbar/news_s.png +0 -0
- package/template/basic/src/static/tabbar/user.png +0 -0
- package/template/basic/src/static/tabbar/user_s.png +0 -0
- package/template/basic/src/stores/index.ts +17 -0
- package/template/basic/src/stores/user.ts +117 -0
- package/template/basic/src/types/auto-import.d.ts +189 -0
- package/template/basic/src/types/pinia.d.ts +0 -0
- package/template/basic/src/types/type.ts +21 -0
- package/template/basic/src/uni.scss +76 -0
- package/template/basic/src/utils/cache.ts +50 -0
- package/template/basic/src/utils/config.ts +29 -0
- package/template/basic/src/utils/env.ts +13 -0
- package/template/basic/tsconfig.json +21 -0
- package/template/basic/uno.config.ts +99 -0
- package/template/basic/vite.config.ts +27 -0
package/index.js
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
const { promisify } = require('util')
|
|
3
|
+
const { resolve } = require('path')
|
|
4
|
+
const { blue, green, red } = require('kolorist')
|
|
5
|
+
const argv = require('minimist')(process.argv.slice(2))
|
|
6
|
+
const { existsSync, readJsonSync } = require('fs-extra')
|
|
7
|
+
const download = promisify(require('download-git-repo'))
|
|
8
|
+
const prompts = require('prompts')
|
|
9
|
+
|
|
10
|
+
async function main() {
|
|
11
|
+
// 获取项目名称
|
|
12
|
+
const targetDir = argv._[0] || 'my-unibest-app'
|
|
13
|
+
const cwd = process.cwd()
|
|
14
|
+
const root = resolve(cwd, targetDir)
|
|
15
|
+
|
|
16
|
+
// 验证目录
|
|
17
|
+
if (existsSync(root)) {
|
|
18
|
+
console.log(red(`✖ 目录 ${targetDir} 已存在`))
|
|
19
|
+
process.exit(1)
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
// 交互式选项
|
|
23
|
+
const options = await prompts([
|
|
24
|
+
{
|
|
25
|
+
type: 'select',
|
|
26
|
+
name: 'template',
|
|
27
|
+
message: '选择模板类型',
|
|
28
|
+
choices: [
|
|
29
|
+
{ title: '基础模板', value: 'basic' },
|
|
30
|
+
{ title: '高级模板 (含状态管理)', value: 'advanced' }
|
|
31
|
+
]
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
type: 'toggle',
|
|
35
|
+
name: 'typescript',
|
|
36
|
+
message: '启用 TypeScript?',
|
|
37
|
+
initial: true,
|
|
38
|
+
active: 'yes',
|
|
39
|
+
inactive: 'no'
|
|
40
|
+
}
|
|
41
|
+
])
|
|
42
|
+
|
|
43
|
+
// 下载模板
|
|
44
|
+
console.log(blue('⬇ 正在下载模板...'))
|
|
45
|
+
await download('github:yourname/unibest-template#main', root, {
|
|
46
|
+
clone: true,
|
|
47
|
+
headers: { 'User-Agent': 'create-unibest' }
|
|
48
|
+
})
|
|
49
|
+
|
|
50
|
+
// 修改 package.json
|
|
51
|
+
const pkgPath = resolve(root, 'package.json')
|
|
52
|
+
const pkg = readJsonSync(pkgPath)
|
|
53
|
+
pkg.name = targetDir
|
|
54
|
+
writeJsonSync(pkgPath, pkg, { spaces: 2 })
|
|
55
|
+
|
|
56
|
+
// 完成提示
|
|
57
|
+
console.log(green('✓ 项目创建成功!'))
|
|
58
|
+
console.log(`
|
|
59
|
+
进入项目目录:
|
|
60
|
+
cd ${targetDir}
|
|
61
|
+
|
|
62
|
+
安装依赖:
|
|
63
|
+
pnpm install
|
|
64
|
+
|
|
65
|
+
启动开发服务器:
|
|
66
|
+
pnpm dev
|
|
67
|
+
`)
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
main().catch(err => {
|
|
71
|
+
console.error(red('✖ 创建失败:'), err)
|
|
72
|
+
process.exit(1)
|
|
73
|
+
})
|
package/package.json
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
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
|
+
}
|
|
15
|
+
}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
{
|
|
2
|
+
"globals": {
|
|
3
|
+
"Component": true,
|
|
4
|
+
"ComponentPublicInstance": true,
|
|
5
|
+
"ComputedRef": true,
|
|
6
|
+
"DirectiveBinding": true,
|
|
7
|
+
"EffectScope": true,
|
|
8
|
+
"ExtractDefaultPropTypes": true,
|
|
9
|
+
"ExtractPropTypes": true,
|
|
10
|
+
"ExtractPublicPropTypes": true,
|
|
11
|
+
"InjectionKey": true,
|
|
12
|
+
"MaybeRef": true,
|
|
13
|
+
"MaybeRefOrGetter": true,
|
|
14
|
+
"PropType": true,
|
|
15
|
+
"Ref": true,
|
|
16
|
+
"VNode": true,
|
|
17
|
+
"WritableComputedRef": true,
|
|
18
|
+
"computed": true,
|
|
19
|
+
"createApp": true,
|
|
20
|
+
"customRef": true,
|
|
21
|
+
"defineAsyncComponent": true,
|
|
22
|
+
"defineComponent": true,
|
|
23
|
+
"effectScope": true,
|
|
24
|
+
"getCurrentInstance": true,
|
|
25
|
+
"getCurrentScope": true,
|
|
26
|
+
"h": true,
|
|
27
|
+
"inject": true,
|
|
28
|
+
"isProxy": true,
|
|
29
|
+
"isReactive": true,
|
|
30
|
+
"isReadonly": true,
|
|
31
|
+
"isRef": true,
|
|
32
|
+
"markRaw": true,
|
|
33
|
+
"nextTick": true,
|
|
34
|
+
"onActivated": true,
|
|
35
|
+
"onAddToFavorites": true,
|
|
36
|
+
"onBackPress": true,
|
|
37
|
+
"onBeforeMount": true,
|
|
38
|
+
"onBeforeUnmount": true,
|
|
39
|
+
"onBeforeUpdate": true,
|
|
40
|
+
"onDeactivated": true,
|
|
41
|
+
"onError": true,
|
|
42
|
+
"onErrorCaptured": true,
|
|
43
|
+
"onHide": true,
|
|
44
|
+
"onLaunch": true,
|
|
45
|
+
"onLoad": true,
|
|
46
|
+
"onMounted": true,
|
|
47
|
+
"onNavigationBarButtonTap": true,
|
|
48
|
+
"onNavigationBarSearchInputChanged": true,
|
|
49
|
+
"onNavigationBarSearchInputClicked": true,
|
|
50
|
+
"onNavigationBarSearchInputConfirmed": true,
|
|
51
|
+
"onNavigationBarSearchInputFocusChanged": true,
|
|
52
|
+
"onPageNotFound": true,
|
|
53
|
+
"onPageScroll": true,
|
|
54
|
+
"onPullDownRefresh": true,
|
|
55
|
+
"onReachBottom": true,
|
|
56
|
+
"onReady": true,
|
|
57
|
+
"onRenderTracked": true,
|
|
58
|
+
"onRenderTriggered": true,
|
|
59
|
+
"onResize": true,
|
|
60
|
+
"onScopeDispose": true,
|
|
61
|
+
"onServerPrefetch": true,
|
|
62
|
+
"onShareAppMessage": true,
|
|
63
|
+
"onShareTimeline": true,
|
|
64
|
+
"onShow": true,
|
|
65
|
+
"onTabItemTap": true,
|
|
66
|
+
"onThemeChange": true,
|
|
67
|
+
"onUnhandledRejection": true,
|
|
68
|
+
"onUnload": true,
|
|
69
|
+
"onUnmounted": true,
|
|
70
|
+
"onUpdated": true,
|
|
71
|
+
"onWatcherCleanup": true,
|
|
72
|
+
"provide": true,
|
|
73
|
+
"reactive": true,
|
|
74
|
+
"readonly": true,
|
|
75
|
+
"ref": true,
|
|
76
|
+
"resolveComponent": true,
|
|
77
|
+
"shallowReactive": true,
|
|
78
|
+
"shallowReadonly": true,
|
|
79
|
+
"shallowRef": true,
|
|
80
|
+
"toRaw": true,
|
|
81
|
+
"toRef": true,
|
|
82
|
+
"toRefs": true,
|
|
83
|
+
"toValue": true,
|
|
84
|
+
"triggerRef": true,
|
|
85
|
+
"unref": true,
|
|
86
|
+
"useAttrs": true,
|
|
87
|
+
"useCssModule": true,
|
|
88
|
+
"useCssVars": true,
|
|
89
|
+
"useId": true,
|
|
90
|
+
"useModel": true,
|
|
91
|
+
"useRequest": true,
|
|
92
|
+
"useSlots": true,
|
|
93
|
+
"useTemplateRef": true,
|
|
94
|
+
"useUploadFile": true,
|
|
95
|
+
"watch": true,
|
|
96
|
+
"watchEffect": true,
|
|
97
|
+
"watchPostEffect": true,
|
|
98
|
+
"watchSyncEffect": true,
|
|
99
|
+
"useUpload": true,
|
|
100
|
+
"uploadFile": true,
|
|
101
|
+
"useFileUpload": true
|
|
102
|
+
}
|
|
103
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
root: true,
|
|
3
|
+
env: {
|
|
4
|
+
node: true
|
|
5
|
+
},
|
|
6
|
+
extends: [
|
|
7
|
+
'plugin:vue/vue3-essential',
|
|
8
|
+
'eslint:recommended',
|
|
9
|
+
'@vue/typescript/recommended',
|
|
10
|
+
'@vue/prettier',
|
|
11
|
+
'@vue/prettier/@typescript-eslint',
|
|
12
|
+
'plugin:prettier/recommended'
|
|
13
|
+
],
|
|
14
|
+
parserOptions: {
|
|
15
|
+
parsar: '@typescript-eslint/parsar',
|
|
16
|
+
ecmaVersion: 2020,
|
|
17
|
+
sourceType: 'module'
|
|
18
|
+
},
|
|
19
|
+
rules: {
|
|
20
|
+
'no-console': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
|
|
21
|
+
'no-debugger': process.env.NODE_ENV === 'production' ? 'warn' : 'off'
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
printWidth: 120, // 换行字符串阈值
|
|
3
|
+
tabWidth: 2, // 设置工具每一个水平缩进的空格数
|
|
4
|
+
useTabs: false,
|
|
5
|
+
semi: false, // 句末是否加分号
|
|
6
|
+
vueIndentScriptAndStyle: true,
|
|
7
|
+
singleQuote: true, // 用单引号
|
|
8
|
+
trailingComma: 'none', // 最后一个对象元素符加逗号
|
|
9
|
+
bracketSpacing: true,
|
|
10
|
+
jsxBracketSameLine: true, // jsx > 是否另取一行
|
|
11
|
+
arrowParens: 'always', // 不需要写文件开头的 @prettier
|
|
12
|
+
insertPragma: false, // 不需要自动在文件开头加入 @prettier
|
|
13
|
+
endOfLine: 'lf' // 换行符使用 lf
|
|
14
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
{
|
|
2
|
+
"editor.fontSize": 19, // 编辑器字体大小
|
|
3
|
+
"terminal.integrated.fontSize": 18, // terminal 框的字体大小
|
|
4
|
+
"editor.tabSize": 2, // Tab 的大小 2个空格
|
|
5
|
+
"editor.formatOnSave": true, // 保存是格式化
|
|
6
|
+
"prettier.singleQuote": true, // 单引号
|
|
7
|
+
"editor.defaultFormatter": "esbenp.prettier-vscode",
|
|
8
|
+
"[vue]": {
|
|
9
|
+
"editor.defaultFormatter": "esbenp.prettier-vscode"
|
|
10
|
+
},
|
|
11
|
+
"editor.codeActionsOnSave": {
|
|
12
|
+
"source.fixAll.eslint": "explicit"
|
|
13
|
+
},
|
|
14
|
+
"eslint.format.enable": true,
|
|
15
|
+
"eslint.validate": [
|
|
16
|
+
"javascript",
|
|
17
|
+
"javascriptreact",
|
|
18
|
+
"html",
|
|
19
|
+
"vue",
|
|
20
|
+
"typescript",
|
|
21
|
+
"typescriptreact"
|
|
22
|
+
]
|
|
23
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html>
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8" />
|
|
5
|
+
<script>
|
|
6
|
+
var coverSupport = 'CSS' in window && typeof CSS.supports === 'function' && (CSS.supports('top: env(a)') ||
|
|
7
|
+
CSS.supports('top: constant(a)'))
|
|
8
|
+
document.write(
|
|
9
|
+
'<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0' +
|
|
10
|
+
(coverSupport ? ', viewport-fit=cover' : '') + '" />')
|
|
11
|
+
</script>
|
|
12
|
+
<title></title>
|
|
13
|
+
<!--preload-links-->
|
|
14
|
+
<!--app-context-->
|
|
15
|
+
</head>
|
|
16
|
+
<body>
|
|
17
|
+
<div id="app"><!--app-html--></div>
|
|
18
|
+
<script type="module" src="/src/main.ts"></script>
|
|
19
|
+
</body>
|
|
20
|
+
</html>
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "uni-preset-vue",
|
|
3
|
+
"version": "0.0.0",
|
|
4
|
+
"scripts": {
|
|
5
|
+
"dev:custom": "uni -p",
|
|
6
|
+
"dev:h5": "uni",
|
|
7
|
+
"dev:h5:ssr": "uni --ssr",
|
|
8
|
+
"dev:mp-alipay": "uni -p mp-alipay",
|
|
9
|
+
"dev:mp-baidu": "uni -p mp-baidu",
|
|
10
|
+
"dev:mp-jd": "uni -p mp-jd",
|
|
11
|
+
"dev:mp-kuaishou": "uni -p mp-kuaishou",
|
|
12
|
+
"dev:mp-lark": "uni -p mp-lark",
|
|
13
|
+
"dev:mp-qq": "uni -p mp-qq",
|
|
14
|
+
"dev:mp-toutiao": "uni -p mp-toutiao",
|
|
15
|
+
"dev:mp-weixin": "uni -p mp-weixin",
|
|
16
|
+
"dev:mp-xhs": "uni -p mp-xhs",
|
|
17
|
+
"dev:quickapp-webview": "uni -p quickapp-webview",
|
|
18
|
+
"dev:quickapp-webview-huawei": "uni -p quickapp-webview-huawei",
|
|
19
|
+
"dev:quickapp-webview-union": "uni -p quickapp-webview-union",
|
|
20
|
+
"build:custom": "uni build -p",
|
|
21
|
+
"build:h5": "uni build",
|
|
22
|
+
"build:h5:ssr": "uni build --ssr",
|
|
23
|
+
"build:mp-alipay": "uni build -p mp-alipay",
|
|
24
|
+
"build:mp-baidu": "uni build -p mp-baidu",
|
|
25
|
+
"build:mp-jd": "uni build -p mp-jd",
|
|
26
|
+
"build:mp-kuaishou": "uni build -p mp-kuaishou",
|
|
27
|
+
"build:mp-lark": "uni build -p mp-lark",
|
|
28
|
+
"build:mp-qq": "uni build -p mp-qq",
|
|
29
|
+
"build:mp-toutiao": "uni build -p mp-toutiao",
|
|
30
|
+
"build:mp-weixin": "uni build -p mp-weixin",
|
|
31
|
+
"build:mp-xhs": "uni build -p mp-xhs",
|
|
32
|
+
"build:quickapp-webview": "uni build -p quickapp-webview",
|
|
33
|
+
"build:quickapp-webview-huawei": "uni build -p quickapp-webview-huawei",
|
|
34
|
+
"build:quickapp-webview-union": "uni build -p quickapp-webview-union",
|
|
35
|
+
"type-check": "vue-tsc --noEmit"
|
|
36
|
+
},
|
|
37
|
+
"dependencies": {
|
|
38
|
+
"@climblee/uv-ui": "^1.1.20",
|
|
39
|
+
"@dcloudio/uni-app": "3.0.0-4030620241128001",
|
|
40
|
+
"@dcloudio/uni-app-harmony": "3.0.0-4030620241128001",
|
|
41
|
+
"@dcloudio/uni-app-plus": "3.0.0-4030620241128001",
|
|
42
|
+
"@dcloudio/uni-components": "3.0.0-4030620241128001",
|
|
43
|
+
"@dcloudio/uni-h5": "3.0.0-4030620241128001",
|
|
44
|
+
"@dcloudio/uni-mp-alipay": "3.0.0-4030620241128001",
|
|
45
|
+
"@dcloudio/uni-mp-baidu": "3.0.0-4030620241128001",
|
|
46
|
+
"@dcloudio/uni-mp-jd": "3.0.0-4030620241128001",
|
|
47
|
+
"@dcloudio/uni-mp-kuaishou": "3.0.0-4030620241128001",
|
|
48
|
+
"@dcloudio/uni-mp-lark": "3.0.0-4030620241128001",
|
|
49
|
+
"@dcloudio/uni-mp-qq": "3.0.0-4030620241128001",
|
|
50
|
+
"@dcloudio/uni-mp-toutiao": "3.0.0-4030620241128001",
|
|
51
|
+
"@dcloudio/uni-mp-weixin": "3.0.0-4030620241128001",
|
|
52
|
+
"@dcloudio/uni-mp-xhs": "3.0.0-4030620241128001",
|
|
53
|
+
"@dcloudio/uni-quickapp-webview": "3.0.0-4030620241128001",
|
|
54
|
+
"@vue/shared": "^3.5.13",
|
|
55
|
+
"deep-pick-omit": "^1.2.1",
|
|
56
|
+
"destr": "^2.0.3",
|
|
57
|
+
"lodash-es": "^4.17.21",
|
|
58
|
+
"pinia": "^3.0.1",
|
|
59
|
+
"pinia-plugin-persistedstate": "^4.2.0",
|
|
60
|
+
"sass": "^1.85.1",
|
|
61
|
+
"vue": "^3.4.21",
|
|
62
|
+
"vue-i18n": "^9.1.9",
|
|
63
|
+
"z-paging": "^2.8.5"
|
|
64
|
+
},
|
|
65
|
+
"devDependencies": {
|
|
66
|
+
"@dcloudio/types": "^3.4.8",
|
|
67
|
+
"@dcloudio/uni-automator": "3.0.0-4030620241128001",
|
|
68
|
+
"@dcloudio/uni-cli-shared": "3.0.0-4030620241128001",
|
|
69
|
+
"@dcloudio/uni-stacktracey": "3.0.0-4030620241128001",
|
|
70
|
+
"@dcloudio/vite-plugin-uni": "3.0.0-4030620241128001",
|
|
71
|
+
"@types/lodash-es": "^4.17.12",
|
|
72
|
+
"@types/node": "^22.13.9",
|
|
73
|
+
"@typescript-eslint/eslint-plugin": "^6.21.0",
|
|
74
|
+
"@typescript-eslint/parser": "^6.21.0",
|
|
75
|
+
"@unocss/preset-legacy-compat": "66.1.0-beta.3",
|
|
76
|
+
"@vue/runtime-core": "^3.4.21",
|
|
77
|
+
"@vue/tsconfig": "^0.1.3",
|
|
78
|
+
"autoprefixer": "^10.4.20",
|
|
79
|
+
"eslint": "^8.57.1",
|
|
80
|
+
"eslint-config-prettier": "^9.1.0",
|
|
81
|
+
"eslint-config-standard": "^17.1.0",
|
|
82
|
+
"eslint-import-resolver-typescript": "^3.7.0",
|
|
83
|
+
"eslint-plugin-import": "^2.31.0",
|
|
84
|
+
"eslint-plugin-prettier": "^5.2.1",
|
|
85
|
+
"eslint-plugin-vue": "^9.32.0",
|
|
86
|
+
"typescript": "^4.9.4",
|
|
87
|
+
"unocss": "66.1.0-beta.3",
|
|
88
|
+
"unocss-applet": "^0.7.8",
|
|
89
|
+
"unplugin-auto-import": "^19.1.1",
|
|
90
|
+
"vite": "5.2.8",
|
|
91
|
+
"vue-tsc": "^1.0.24"
|
|
92
|
+
}
|
|
93
|
+
}
|