Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
wjw-gavin committed Mar 2, 2023
1 parent b988507 commit 679873a
Show file tree
Hide file tree
Showing 36 changed files with 14,021 additions and 0 deletions.
11 changes: 11 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[*]
charset = utf-8
indent_style = space
indent_size = 2
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true

[*.md]
insert_final_newline = false
trim_trailing_whitespace = false
3 changes: 3 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
unpackage/
node_modules/
dist/
12 changes: 12 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
module.exports = {
root: true,
extends: ['@wjw-gavin/eslint-config-vue'],
rules: {
// Your custom rules
},
globals: {
wx: true,
uni: true,
getCurrentPages: true
}
}
23 changes: 23 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
.DS_Store
node_modules/
unpackage/
dist/

# local env files
.env.local
.env.*.local

# Log files
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# Editor directories and files
.project
.idea
.vscode
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw*
4 changes: 4 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

npx --no-install nano-staged
6 changes: 6 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"semi": false,
"printWidth": 90,
"singleQuote": true,
"trailingComma": "none"
}
31 changes: 31 additions & 0 deletions INSTRUCTION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# 使用须知

## 集成 unocss

- [unocss](https://github.com/unocss/unocss)
- [unocss-preset-weapp](https://github.com/MellowCo/unocss-preset-weapp)

## 内置 css

详情见 [src/assets/style/common.scss](https://git.nucarf.cn/frontend/example/mini-template-next/blob/master/src/assets/style/common.scss)

## tabbar 底部导航栏

建议把底部导航栏列表写在`store`中,方便引用和修改。

## 安全区适配

这里提供两种方式:

1. 自己编写 css,如底部安全区类名:`.safe-area-inset-bottom`,则:

```css
.safe-area-inset-bottom {
padding-bottom: constant(safe-area-inset-bottom);
padding-bottom: env(safe-area-inset-bottom);
}
```

顶部安全区同理。

2. uView 提供了组件`u-safe-bottom``u-status-bar`分别对应底部和顶部安全区。
38 changes: 38 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# mini-template-next
uni-app + uView-ui + native-lodash

- [uni-app](https://uniapp.dcloud.net.cn)
- [uView-ui](https://www.uviewui.com/components/intro.html)
- [native-lodash](https://git.nucarf.cn/frontend/example/native-lodash/blob/master/README.md)

## 目录结构

```code
├── src // 项目源码
│ ├── api // 与后端交互使用的api方法和数据处理
│ │
│ ├── assets // 放置一些资源
│ │ └── styles // 样式资源
│ │
│ ├── components // 公共组件
│ │
│ ├── http // http 相关
│ │ └── config.js // baseURL 配置
│ │ └── request.js // request 配置(请求拦截、响应拦截)
│ │
│ ├── static // 放置一些静态资源
│ │ └── images // 图片
│ │
│ ├── store // vuex 相关配置
│ │ └── modules // 功能模块状态管理
│ │ └── index.js // 自动导入 store module
│ │
│ ├── utils // 工具方法
│ │ └── auth.js // token 相关
│ │ └── global.js // 全局的一些方法,可以通过this.xxx调用
│ │ └── index.js // 常用的工具方法
│ │
└── vue.config.js // 详细见https://cli.vuejs.org/zh/config/#vue-config-js
```
81 changes: 81 additions & 0 deletions babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
const webpack = require('webpack')
const plugins = []

if (process.env.UNI_OPT_TREESHAKINGNG) {
plugins.push(require('@dcloudio/vue-cli-plugin-uni-optimize/packages/babel-plugin-uni-api/index.js'))
}

if (
(
process.env.UNI_PLATFORM === 'app-plus' &&
process.env.UNI_USING_V8
) ||
(
process.env.UNI_PLATFORM === 'h5' &&
process.env.UNI_H5_BROWSER === 'builtin'
)
) {
const path = require('path')

const isWin = /^win/.test(process.platform)

const normalizePath = path => (isWin ? path.replace(/\\/g, '/') : path)

const input = normalizePath(process.env.UNI_INPUT_DIR)
try {
plugins.push([
require('@dcloudio/vue-cli-plugin-hbuilderx/packages/babel-plugin-console'),
{
file (file) {
file = normalizePath(file)
if (file.indexOf(input) === 0) {
return path.relative(input, file)
}
return false
}
}
])
} catch (e) { }
}

process.UNI_LIBRARIES = process.UNI_LIBRARIES || ['@dcloudio/uni-ui']
process.UNI_LIBRARIES.forEach(libraryName => {
plugins.push([
'import',
{
'libraryName': libraryName,
'customName': (name) => {
return `${libraryName}/lib/${name}/${name}`
}
}
])
})

if (process.env.UNI_PLATFORM !== 'h5') {
plugins.push('@babel/plugin-transform-runtime')
}

const config = {
presets: [
[
'@vue/app',
{
modules: webpack.version[0] > 4 ? 'auto' : 'commonjs',
useBuiltIns: process.env.UNI_PLATFORM === 'h5' ? 'usage' : 'entry'
}
]
],
plugins
}

const UNI_H5_TEST = '**/@dcloudio/uni-h5/dist/index.umd.min.js'
if (process.env.NODE_ENV === 'production') {
config.overrides = [{
test: UNI_H5_TEST,
compact: true,
}]
} else {
config.ignore = [UNI_H5_TEST]
}

module.exports = config
9 changes: 9 additions & 0 deletions jsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"compilerOptions": {
"types": [
"@dcloudio/types",
"miniprogram-api-typings",
"mini-types"
]
}
}
131 changes: 131 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
{
"name": "uni-template",
"version": "0.1.0",
"private": true,
"scripts": {
"dev": "npm run dev:h5",
"serve": "npm run dev:h5",
"build": "npm run build:h5",
"build:app-plus": "cross-env NODE_ENV=production UNI_PLATFORM=app-plus vue-cli-service uni-build",
"build:custom": "cross-env NODE_ENV=production uniapp-cli custom",
"build:h5": "cross-env NODE_ENV=production UNI_PLATFORM=h5 vue-cli-service uni-build",
"build:mp-360": "cross-env NODE_ENV=production UNI_PLATFORM=mp-360 vue-cli-service uni-build",
"build:mp-alipay": "cross-env NODE_ENV=production UNI_PLATFORM=mp-alipay vue-cli-service uni-build",
"build:mp-baidu": "cross-env NODE_ENV=production UNI_PLATFORM=mp-baidu vue-cli-service uni-build",
"build:mp-jd": "cross-env NODE_ENV=production UNI_PLATFORM=mp-jd vue-cli-service uni-build",
"build:mp-kuaishou": "cross-env NODE_ENV=production UNI_PLATFORM=mp-kuaishou vue-cli-service uni-build",
"build:mp-lark": "cross-env NODE_ENV=production UNI_PLATFORM=mp-lark vue-cli-service uni-build",
"build:mp-qq": "cross-env NODE_ENV=production UNI_PLATFORM=mp-qq vue-cli-service uni-build",
"build:mp-toutiao": "cross-env NODE_ENV=production UNI_PLATFORM=mp-toutiao vue-cli-service uni-build",
"build:mp-weixin": "cross-env NODE_ENV=production UNI_PLATFORM=mp-weixin vue-cli-service uni-build",
"build:mp-xhs": "cross-env NODE_ENV=production UNI_PLATFORM=mp-xhs vue-cli-service uni-build",
"build:quickapp-native": "cross-env NODE_ENV=production UNI_PLATFORM=quickapp-native vue-cli-service uni-build",
"build:quickapp-webview": "cross-env NODE_ENV=production UNI_PLATFORM=quickapp-webview vue-cli-service uni-build",
"build:quickapp-webview-huawei": "cross-env NODE_ENV=production UNI_PLATFORM=quickapp-webview-huawei vue-cli-service uni-build",
"build:quickapp-webview-union": "cross-env NODE_ENV=production UNI_PLATFORM=quickapp-webview-union vue-cli-service uni-build",
"dev:app-plus": "cross-env NODE_ENV=development UNI_PLATFORM=app-plus vue-cli-service uni-build --watch",
"dev:custom": "cross-env NODE_ENV=development uniapp-cli custom",
"dev:h5": "cross-env NODE_ENV=development UNI_PLATFORM=h5 vue-cli-service uni-serve",
"dev:mp-360": "cross-env NODE_ENV=development UNI_PLATFORM=mp-360 vue-cli-service uni-build --watch",
"dev:mp-alipay": "cross-env NODE_ENV=development UNI_PLATFORM=mp-alipay vue-cli-service uni-build --watch",
"dev:mp-baidu": "cross-env NODE_ENV=development UNI_PLATFORM=mp-baidu vue-cli-service uni-build --watch",
"dev:mp-jd": "cross-env NODE_ENV=development UNI_PLATFORM=mp-jd vue-cli-service uni-build --watch",
"dev:mp-kuaishou": "cross-env NODE_ENV=development UNI_PLATFORM=mp-kuaishou vue-cli-service uni-build --watch",
"dev:mp-lark": "cross-env NODE_ENV=development UNI_PLATFORM=mp-lark vue-cli-service uni-build --watch",
"dev:mp-qq": "cross-env NODE_ENV=development UNI_PLATFORM=mp-qq vue-cli-service uni-build --watch",
"dev:mp-toutiao": "cross-env NODE_ENV=development UNI_PLATFORM=mp-toutiao vue-cli-service uni-build --watch",
"dev:mp-weixin": "cross-env NODE_ENV=development UNI_PLATFORM=mp-weixin vue-cli-service uni-build --watch",
"dev:mp-xhs": "cross-env NODE_ENV=development UNI_PLATFORM=mp-xhs vue-cli-service uni-build --watch",
"dev:quickapp-native": "cross-env NODE_ENV=development UNI_PLATFORM=quickapp-native vue-cli-service uni-build --watch",
"dev:quickapp-webview": "cross-env NODE_ENV=development UNI_PLATFORM=quickapp-webview vue-cli-service uni-build --watch",
"dev:quickapp-webview-huawei": "cross-env NODE_ENV=development UNI_PLATFORM=quickapp-webview-huawei vue-cli-service uni-build --watch",
"dev:quickapp-webview-union": "cross-env NODE_ENV=development UNI_PLATFORM=quickapp-webview-union vue-cli-service uni-build --watch",
"info": "node node_modules/@dcloudio/vue-cli-plugin-uni/commands/info.js",
"serve:quickapp-native": "node node_modules/@dcloudio/uni-quickapp-native/bin/serve.js",
"test:android": "cross-env UNI_PLATFORM=app-plus UNI_OS_NAME=android jest -i",
"test:h5": "cross-env UNI_PLATFORM=h5 jest -i",
"test:ios": "cross-env UNI_PLATFORM=app-plus UNI_OS_NAME=ios jest -i",
"test:mp-baidu": "cross-env UNI_PLATFORM=mp-baidu jest -i",
"test:mp-weixin": "cross-env UNI_PLATFORM=mp-weixin jest -i",
"postinstall": "npx husky install",
"cz": "czg"
},
"dependencies": {
"@dcloudio/uni-app": "^2.0.2-3061420221215003",
"@dcloudio/uni-app-plus": "^2.0.2-3061420221215003",
"@dcloudio/uni-h5": "^2.0.2-3061420221215003",
"@dcloudio/uni-i18n": "^2.0.2-3061420221215003",
"@dcloudio/uni-mp-360": "^2.0.2-3061420221215003",
"@dcloudio/uni-mp-alipay": "^2.0.2-3061420221215003",
"@dcloudio/uni-mp-baidu": "^2.0.2-3061420221215003",
"@dcloudio/uni-mp-jd": "^2.0.2-3061420221215003",
"@dcloudio/uni-mp-kuaishou": "^2.0.2-3061420221215003",
"@dcloudio/uni-mp-lark": "^2.0.2-3061420221215003",
"@dcloudio/uni-mp-qq": "^2.0.2-3061420221215003",
"@dcloudio/uni-mp-toutiao": "^2.0.2-3061420221215003",
"@dcloudio/uni-mp-vue": "^2.0.2-3061420221215003",
"@dcloudio/uni-mp-weixin": "^2.0.2-3061420221215003",
"@dcloudio/uni-mp-xhs": "^2.0.2-3061420221215003",
"@dcloudio/uni-quickapp-native": "^2.0.2-3061420221215003",
"@dcloudio/uni-quickapp-webview": "^2.0.2-3061420221215003",
"@dcloudio/uni-stacktracey": "^2.0.2-3061420221215003",
"@dcloudio/uni-stat": "^2.0.2-3061420221215003",
"@vue/shared": "^3.0.0",
"core-js": "^3.6.5",
"flyio": "^0.6.2",
"native-lodash": "^1.1.1",
"uview-ui": "^2.0.35",
"vue": "^2.6.11",
"vuex": "^3.2.0"
},
"devDependencies": {
"@dcloudio/types": "^3.0.4",
"@dcloudio/uni-automator": "^2.0.2-3061420221215003",
"@dcloudio/uni-cli-i18n": "^2.0.2-3061420221215003",
"@dcloudio/uni-cli-shared": "^2.0.2-3061420221215003",
"@dcloudio/uni-helper-json": "*",
"@dcloudio/uni-migration": "^2.0.2-3061420221215003",
"@dcloudio/uni-template-compiler": "^2.0.2-3061420221215003",
"@dcloudio/vue-cli-plugin-hbuilderx": "^2.0.2-3061420221215003",
"@dcloudio/vue-cli-plugin-uni": "^2.0.2-3061420221215003",
"@dcloudio/vue-cli-plugin-uni-optimize": "^2.0.2-3061420221215003",
"@dcloudio/webpack-uni-mp-loader": "^2.0.2-3061420221215003",
"@dcloudio/webpack-uni-pages-loader": "^2.0.2-3061420221215003",
"@vue/cli-plugin-babel": "~4.5.15",
"@vue/cli-service": "~4.5.15",
"@wjw-gavin/eslint-config": "^1.0.7",
"babel-plugin-import": "^1.11.0",
"cross-env": "^7.0.2",
"cz-git": "^1.4.1",
"eslint": "^8.31.0",
"husky": "^8.0.3",
"jest": "^25.4.0",
"mini-types": "*",
"miniprogram-api-typings": "*",
"nano-staged": "^0.8.0",
"postcss-comment": "^2.0.0",
"sass": "^1.49.8",
"sass-loader": "^8.0.2",
"unocss": "^0.49.4",
"unocss-preset-weapp": "^0.4.0",
"unocss-webpack-uniapp2": "^0.1.4",
"vue-template-compiler": "^2.6.11"
},
"browserslist": [
"Android >= 4.4",
"ios >= 9"
],
"uni-app": {
"scripts": {}
},
"config": {
"commitizen": {
"path": "node_modules/cz-git"
}
},
"nano-staged": {
"*.md": "prettier --write",
"*.{js,vue,scss,css}": "prettier --write",
"*.{js,vue}": "eslint --fix"
}
}
27 changes: 27 additions & 0 deletions postcss.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
const path = require('node:path')
const webpack = require('webpack')
const config = {
parser: require('postcss-comment'),
plugins: [
require('postcss-import')({
resolve(id) {
if (id.startsWith('~@/')) {
return path.resolve(process.env.UNI_INPUT_DIR, id.slice(3))
} else if (id.startsWith('@/')) {
return path.resolve(process.env.UNI_INPUT_DIR, id.slice(2))
} else if (id.startsWith('/') && !id.startsWith('//')) {
return path.resolve(process.env.UNI_INPUT_DIR, id.slice(1))
}
return id
}
}),
require('autoprefixer')({
remove: process.env.UNI_PLATFORM !== 'h5'
}),
require('@dcloudio/vue-cli-plugin-uni/packages/postcss')
]
}
if (webpack.version[0] > 4) {
delete config.parser
}
module.exports = config
Loading

0 comments on commit 679873a

Please sign in to comment.