提交 9e0d2f7e 作者: 方治民

feat: init

上级
root = true
[*]
charset=utf-8
end_of_line=lf
insert_final_newline=true
indent_style=space
indent_size=4
max_line_length = 100
[*.{yml,yaml}]
indent_style = space
indent_size = 2
[*.md]
trim_trailing_whitespace = false
[Makefile]
indent_style = tab
# APP 名称
VITE_GLOB_APP_NAME = 智慧化工
# APP 描述
VITE_GLOB_APP_DESCRIPTION = 湖北可赛化工 APP
# API 接口地址
VITE_GLOB_API_URL=http://localhost:8080
# API 接口地址前缀
VITE_GLOB_API_URL_PREFIX=/api
# API 接口地址
VITE_GLOB_API_URL=http://localhost:8080
# API 接口地址前缀
VITE_GLOB_API_URL_PREFIX=/api
*.sh
node_modules
*.md
*.woff
*.ttf
.vscode
.idea
dist
/public
/docs
.husky
.local
/bin
Dockerfile
/example
unpackage
module.exports = {
root: true,
parser: 'vue-eslint-parser',
parserOptions: {
parser: '@typescript-eslint/parser',
ecmaVersion: 2020,
sourceType: 'module',
jsxPragma: 'React',
ecmaFeatures: {
jsx: true,
},
},
extends: [
'prettier',
'plugin:prettier/recommended',
'plugin:vue/vue3-recommended',
'plugin:@typescript-eslint/recommended',
],
rules: {
'prettier/prettier': 'error',
'@typescript-eslint/no-explicit-any': 0,
'@typescript-eslint/no-namespace': 'off',
'no-alert': 'error',
'vue/html-self-closing': 0,
'vue/html-indent': ['error', 4],
'vue/max-attributes-per-line': [
2,
{
singleline: 120,
multiline: { max: 80 },
},
],
'vue/singleline-html-element-content-newline': 0,
},
}
public/* linguist-vendored
* text=auto eol=lf
node_modules
.DS_Store
dist
.npmrc
.cache
tests/server/static
tests/server/static/upload
.local
# local env files
.env.local
.env.*.local
.eslintcache
# Log files
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
# Editor directories and files
.idea
# .vscode
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
.vite
.hbuilderx
unpackage
#!/bin/sh
# shellcheck source=./_/husky.sh
. "$(dirname "$0")/_/husky.sh"
npx --no-install commitlint --edit "$1"
#!/bin/sh
command_exists () {
command -v "$1" >/dev/null 2>&1
}
# Workaround for Windows 10, Git Bash and Yarn
if command_exists winpty && test -t 1; then
exec < /dev/tty
fi
module.exports = {
'*.{js,jsx,ts,tsx}': ['eslint --fix', 'prettier --write'],
'{!(package)*.json,*.code-snippets,.!(browserslist)*rc}': ['prettier --write--parser json'],
'package.json': ['sort-package-json', 'prettier --write'],
'*.vue': ['eslint --fix', 'prettier --write', 'stylelint --fix --allow-empty-input'],
'*.{scss,less,styl,html}': ['stylelint --fix --allow-empty-input', 'prettier --write'],
'*.md': ['prettier --write'],
}
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"
. "$(dirname "$0")/common.sh"
[ -n "$CI" ] && exit 0
# Format and submit code according to lintstagedrc.js configuration
npm run lint:lint-staged
MD041: false
MD013:
line_length: 300
/dist/*
.local
.output.js
/node_modules/**
**/*.svg
**/*.sh
/public/*
manifest.json
/dist/*
/public/*
public/*
example/*
# 可赛化工 APP
## 开发规范
[规范说明](./doc/workflow.md)
---
## 开发环境
<!-- prettier-ignore -->
- Visual Studio Code [latest](https://code.visualstudio.com)
- HBuilderX [latest](https://www.dcloud.io/hbuilderx.html)
- [常用插件清单](./doc/plugins.md)
## 技术栈
[技术栈说明](./doc/technique.md)
## 开发工具说明
> 运行/调试/编译/发布环境使用 `HBuilderX`, 开发工具统一使用 `Visual Studio Code`
## TODO
<!-- prettier-ignore -->
- [x] 完成项目构建,开发文档编写
- [x] [conventional-changelog](https://www.cnblogs.com/mengfangui/p/12634845.html)
- [ ] 完善网络请求相关配置
- [ ] 完善页面主体布局
- [ ] 设计模块化权限控制
- [ ] 接入 [消息推送](https://uniapp.dcloud.net.cn/unipush.html)
- [ ] 接入 [APP 升级中心](https://uniapp.dcloud.net.cn/uniCloud/upgrade-center.html)
import fs from 'fs'
import path from 'path'
import dotenv from 'dotenv'
export function isDevFn(mode: string): boolean {
return mode === 'development'
}
export function isProdFn(mode: string): boolean {
return mode === 'production'
}
/**
* Whether to generate package preview
*/
export function isReportMode(): boolean {
return process.env.REPORT === 'true'
}
// Read all environment variable configuration files to process.env
export function wrapperEnv(envConf: Recordable): ViteEnv {
const ret: any = {}
for (const envName of Object.keys(envConf)) {
let realName = envConf[envName].replace(/\\n/g, '\n')
realName = realName === 'true' ? true : realName === 'false' ? false : realName
ret[envName] = realName
if (typeof realName === 'string') {
process.env[envName] = realName
} else if (typeof realName === 'object') {
process.env[envName] = JSON.stringify(realName)
}
}
return ret
}
/**
* 获取当前环境下生效的配置文件名
*/
function getConfFiles() {
const script = process.env.npm_lifecycle_script
const reg = new RegExp('--mode ([a-z_\\d]+)')
const result = reg.exec(script as string) as any
if (result) {
const mode = result[1] as string
return ['.env', `.env.${mode}`]
}
return ['.env', '.env.production']
}
/**
* Get the environment variables starting with the specified prefix
* @param match prefix
* @param confFiles ext
*/
export function getEnvConfig(match = 'VITE_GLOB_', confFiles = getConfFiles()) {
let envConfig = {}
confFiles.forEach((item) => {
try {
const env = dotenv.parse(fs.readFileSync(path.resolve(process.cwd(), item)))
envConfig = { ...envConfig, ...env }
} catch (e) {
console.error(`Error in parsing ${item}`, e)
}
})
const reg = new RegExp(`^(${match})`)
Object.keys(envConfig).forEach((key) => {
if (!reg.test(key)) {
Reflect.deleteProperty(envConfig, key)
}
})
return envConfig
}
/**
* Get user root directory
* @param dir file path
*/
export function getRootPath(...dir: string[]) {
return path.resolve(process.cwd(), ...dir)
}
import type { Plugin } from 'vite'
// https://github.com/antfu/unplugin-auto-import
import AutoImport from 'unplugin-auto-import/vite'
/**
* unplugin-auto-import
* @returns Plugin
*/
export function configAutoImportPlugin(): Plugin {
return AutoImport({
dts: 'types/auto-imports.d.ts',
imports: [
'vue',
'uni-app',
// '@vueuse/core',
{ '/@/config/app': ['$app'] },
{ '/@/api/types': ['API'] },
],
})
}
import type { Plugin } from 'vite'
import { configUniPlugin } from './uni'
import { configAutoImportPlugin } from './autoImport'
export function createVitePlugins(viteEnv: ViteEnv) {
const { VITE_GLOB_APP_NAME, VITE_GLOB_APP_DESCRIPTION } = viteEnv
console.log('APP 名称: ', VITE_GLOB_APP_NAME)
console.log('APP 描述: ', VITE_GLOB_APP_DESCRIPTION)
// plugins
const vitePlugins: (Plugin | Plugin[])[] = []
// uni-app
vitePlugins.push(configUniPlugin())
// unplugin-auto-import
vitePlugins.push(configAutoImportPlugin())
return vitePlugins
}
import type { Plugin } from 'vite'
import fs from 'fs'
import prettier from 'prettier'
// uni-app
import uni from '@dcloudio/vite-plugin-uni'
function generateUniComponentsTypes() {
const tags = fs.readFileSync('./node_modules/@dcloudio/uni-helper-json/dist/tags.json', 'utf8')
const json = JSON.parse(tags)
const components = Object.keys(json).map((key) => `'${key}': typeof HTMLElement`)
const content = `
// generated by @dcloudio/uni-helper-json/dist/tags.json
declare module 'vue' {
// uni-app 内置组件高亮
export interface GlobalComponents {
${components.join(',\n\t')}
}
}
export {}
`
const formatted = prettier.format(content, { parser: 'typescript', tabWidth: 4, semi: false })
fs.writeFileSync('./types/uni-components.d.ts', formatted, 'utf8')
}
/**
* uni-app
* @returns Plugin[]
*/
export function configUniPlugin(): Plugin[] {
// 生成 uni-components.d.ts
generateUniComponentsTypes()
return uni()
}
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',
[
'upd',
'feat',
'fix',
'perf',
'style',
'docs',
'test',
'refactor',
'build',
'ci',
'chore',
'revert',
'wip',
'workflow',
'types',
'release',
],
],
},
}
### IDE 插件推荐清单
> Visual Studio Code
<!-- prettier-ignore -->
- ⭐GitHub Copilot
- ⭐Visual Studio IntelliCode
- ⭐Chinese (Simplified) Language Pack for Visual Studio Code
- ⭐Material Icon Theme
- ⭐Prettier - Code formatter
- ⭐EditorConfig
- ⭐TODO Highlight
- ESLint
- stylelint
- markdownlint
- Auto Close Tag
- Auto Rename Tag
- Better Comments
- Trailing Spaces
- Bracket Pair Colorizer
- DotENV
- filesize
- vscode-fileheader
- Output Colorizer
- Path Intellisense
- Turbo Console Log
- Vetur/Volar (eg: 两者二选一, Volar 对于 Vue3+TS 相对较友好, **本项目采用 Volar**)
- Ant-Design-Vue-Helper
- GitLens
- Git History
- gitignore
## 技术栈
### 基础
<!-- prettier-ignore -->
- [Vue v3.x](https://v3.vuejs.org/guide/introduction.html)
- [uni-app@vue3 v3.x-alpha](https://uniapp.dcloud.io/tutorial/migration-to-vue3.html), 依赖 `HBuilderX Alpha` 版本编辑器
- [TypeScript](https://www.typescriptlang.org/zh/)
- [Sass](https://www.sass.hk/)
### UI
<!-- prettier-ignore -->
- [uni-ui@vue3](https://github.com/dcloudio/uni-ui)
- 备选方案: [uView](https://uviewui.com/), 由于尚未完成 Vue3 的适配, 暂不推荐使用
### Tools
<!-- prettier-ignore -->
- [Lodash](https://github.com/lodash/lodash) 函数库
- [Dayjs](https://github.com/iamkun/dayjs) 时间库
- [@vueuse/core](https://github.com/vueuse/vueuse) Vue2/3 实用工具集
- [mock.js](https://github.com/nuysoft/Mock) 数据模拟
### 网络
<!-- prettier-ignore -->
- [uni.request](https://uniapp.dcloud.net.cn/api/request/request.html)
- [uni-ajax](https://uniajax.ponjs.com/)
### 图表
<!-- prettier-ignore -->
- [ucharts](https://gitee.com/uCharts/uCharts)
### 构建工具
<!-- prettier-ignore -->
- [HBuilderX Alpha](https://download1.dcloud.net.cn/hbuilderx/changelog/3.4.2.20220310-alpha.html)
- [Vite v2.x](https://vitejs.dev)
### 其他插件
<!-- prettier-ignore -->
- [prettier](https://prettier.io) 代码格式化工具
- [husky](https://github.com/typicode/husky) Git hooks 插件
- [ESLint](https://eslint.org) 代码规范检查工具
- [stylelint](https://stylelint.io) CSS 规范检查工具
- [commitizen](https://github.com/commitizen) Git 提交规范工具
- [lint-staged](https://github.com/okonet/lint-staged)
- ...
# 开发工作流规范
> 🥇 适用于前后端项目开发
## 开发前必读 🔥
以下内容,项目负责人及开发团队成员务必遵守,共同营造一个良好的开发环境
1. 使用代码规范检查工具(前端:`ESLint`,后端:`Spotless`),规范项通常使用业内标准,再由团队协商调整部分检查项
2. 使用代码格式规范工具统一编码风格(前端:`Prettier`,后端:`Spotless + Prettier for Java`
3. 使用 `GitHook` 来自动化规范提交前的代码初步检查
4. ~~TODO...~~
## 代码管理规范 ⚠️
重要:所有项目统一由负责人在 GitLab 上创建群组,与项目有关的前后端工程,全部在群组内预先创建好,并分配人员,不允许将项目挂在私人账号下进行协同开发。
## Git 规范 ✅
简化使用 [git-flow](https://www.gitflow.com/),具体说明参考如下
### 分支规范
1. master (主分支)
2. develop (开发分支)
3. dev_fzm (开发人员分支,fzm 代表用户方治民)
4. release、hotfix (视情况产生的分支,用完删除)
共包含五种类型的分支,暂定工作流程图如下
![image](http://img.ifzm.cn/git-flow.2020-02-14.png)
develop 分支允许开发时用于代码合并,保持最新的汇总版本
develop 分支之上为权限分支,仅由负责人负责合并代码或创建新分支,以及发布版本
### 提交规范
> **推荐方式**: 使用 [cz-cli](https://github.com/commitizen/cz-cli) 来提交代码,推荐使用 `cz-conventional-changelog` 插件来提交更新日志
<!-- prettier-ignore -->
- 禁止提交自己的本地配置,如:`.idea/.vscode``local/env` 配置(特殊情况下需要团队保持强一致时可以提交)
- 禁止提交不能通过编译的代码
- 养成早提交、多提交习惯,最好每开发一个功能都 `commit` 一次,提交前需要先更新
### Commit Message 规范
规范 `Commit Message` 格式(注意冒号后面有空格)
```md
<type>: <subject> <#id>
```
#### 常用的 type 类别
<!-- prettier-ignore -->
- `upd`:更新 xxx 功能
- `feat`:新增 xxx 功能
- `fix`:修复 xxx Bug
- `docs`:变更 xxx 文档
- `style`: 变更 xxx 代码格式或注释
- `refactor`:重构 xxx 功能或方法
- `test`:调试 xxx 功能或新增 xxx 测试用例
- `chore`:构建过程或辅助工具的变动(较少出现,项目构建之初基本已确定好)
#### subject 简述
`subject``commit` 描述信息,尽可能简明扼要。
#### id 标识
`#id` 代表 [PingCode](https://yiring.pingcode.com) 任务、Bug 编号(可选,如果有对应的必须填写)
#### 示例
```sh
git commit -m 'feat: 新增用户登录功能'
git commit -m 'upd: 完善用户登录界面交互细节'
git commit -m 'fix: 修复由token问题引起的需要重复登录Bug #1002'
```
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<script>
var coverSupport =
'CSS' in window &&
typeof CSS.supports === 'function' &&
(CSS.supports('top: env(a)') || CSS.supports('top: constant(a)'))
document.write(
'<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0' +
(coverSupport ? ', viewport-fit=cover' : '') +
'" />',
)
</script>
<title></title>
<!--preload-links-->
<!--app-context-->
</head>
<body>
<div id="app"><!--app-html--></div>
<script type="module" src="/src/main.ts"></script>
</body>
</html>
{
"name": "kshg-app",
"version": "0.0.1",
"description": "可赛化工 APP",
"keywords": [
"chemical",
"kesai",
"kshg",
"可赛化工",
"APP"
],
"repository": {
"type": "git",
"url": "https://gitlab.yiring.com/chemical-kesai/kshg-app.git"
},
"author": {
"name": "yiring",
"email": "developer@yiring.com",
"url": "https://yiring.com"
},
"scripts": {
"dev:app": "uni -p app",
"dev:custom": "uni -p",
"dev:h5": "uni",
"dev:h5:ssr": "uni --ssr",
"dev:mp-alipay": "uni -p mp-alipay",
"dev:mp-baidu": "uni -p mp-baidu",
"dev:mp-kuaishou": "uni -p mp-kuaishou",
"dev:mp-lark": "uni -p mp-lark",
"dev:mp-qq": "uni -p mp-qq",
"dev:mp-toutiao": "uni -p mp-toutiao",
"dev:mp-weixin": "uni -p mp-weixin",
"dev:quickapp-webview": "uni -p quickapp-webview",
"dev:quickapp-webview-huawei": "uni -p quickapp-webview-huawei",
"dev:quickapp-webview-union": "uni -p quickapp-webview-union",
"build:app": "uni build -p app",
"build:custom": "uni build -p",
"build:h5": "uni build",
"build:h5:ssr": "uni build --ssr",
"build:mp-alipay": "uni build -p mp-alipay",
"build:mp-baidu": "uni build -p mp-baidu",
"build:mp-kuaishou": "uni build -p mp-kuaishou",
"build:mp-lark": "uni build -p mp-lark",
"build:mp-qq": "uni build -p mp-qq",
"build:mp-toutiao": "uni build -p mp-toutiao",
"build:mp-weixin": "uni build -p mp-weixin",
"build:quickapp-webview": "uni build -p quickapp-webview",
"build:quickapp-webview-huawei": "uni build -p quickapp-webview-huawei",
"build:quickapp-webview-union": "uni build -p quickapp-webview-union",
"clean:cache": "rimraf node_modules/.cache/ && rimraf node_modules/.vite",
"clean:lib": "rimraf node_modules",
"lint:eslint": "eslint --cache --max-warnings 0 \"{src,mock}/**/*.{vue,ts,tsx}\" --fix",
"lint:prettier": "prettier --write \"src/**/*.{js,ts,json,ts,tsx,css,less,scss,vue,html,md}\"",
"lint:stylelint": "stylelint --cache --fix \"**/*.{vue,less,postcss,css,scss}\" --cache --cache-location node_modules/.cache/stylelint/",
"lint:lint-staged": "lint-staged -c ./.husky/lintstagedrc.js",
"log": "conventional-changelog -p angular -i CHANGELOG.md -s",
"prepare": "husky install"
},
"config": {
"commitizen": {
"path": "./node_modules/cz-conventional-changelog"
}
},
"dependencies": {
"@dcloudio/uni-app": "^3.0.0-alpha-3040220220310005",
"@dcloudio/uni-app-plus": "^3.0.0-alpha-3040220220310005",
"@dcloudio/uni-components": "^3.0.0-alpha-3040220220310005",
"@dcloudio/uni-h5": "^3.0.0-alpha-3040220220310005",
"@dcloudio/uni-mp-alipay": "^3.0.0-alpha-3040220220310005",
"@dcloudio/uni-mp-baidu": "^3.0.0-alpha-3040220220310005",
"@dcloudio/uni-mp-kuaishou": "^3.0.0-alpha-3040220220310005",
"@dcloudio/uni-mp-lark": "^3.0.0-alpha-3040220220310005",
"@dcloudio/uni-mp-qq": "^3.0.0-alpha-3040220220310005",
"@dcloudio/uni-mp-toutiao": "^3.0.0-alpha-3040220220310005",
"@dcloudio/uni-mp-weixin": "^3.0.0-alpha-3040220220310005",
"@dcloudio/uni-quickapp-webview": "^3.0.0-alpha-3040220220310005",
"@vueuse/core": "^8.1.2",
"dayjs": "^1.11.0",
"lodash-es": "^4.17.21",
"mockjs": "^1.1.0",
"vue": "^3.2.31"
},
"devDependencies": {
"@commitlint/cli": "^16.2.3",
"@commitlint/config-conventional": "^16.2.1",
"@dcloudio/types": "^2.5.18",
"@dcloudio/uni-automator": "^3.0.0-alpha-3040220220310005",
"@dcloudio/uni-cli-shared": "^3.0.0-alpha-3040220220310005",
"@dcloudio/uni-helper-json": "^1.0.13",
"@dcloudio/vite-plugin-uni": "^3.0.0-alpha-3040220220310005",
"@types/lodash-es": "^4.17.6",
"@types/mockjs": "^1.0.6",
"@types/prettier": "^2.4.4",
"@typescript-eslint/eslint-plugin": "^5.16.0",
"@typescript-eslint/parser": "^5.16.0",
"commitizen": "^4.2.4",
"conventional-changelog-cli": "^2.2.2",
"cz-conventional-changelog": "^3.3.0",
"dotenv": "^16.0.0",
"eslint": "^8.11.0",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-prettier": "^4.0.0",
"eslint-plugin-vue": "^8.5.0",
"husky": "^7.0.4",
"less": "^4.1.2",
"lint-staged": "^12.3.7",
"npm-run-all": "^4.1.5",
"postcss": "^8.4.12",
"postcss-html": "^1.3.0",
"postcss-less": "^6.0.0",
"prettier": "^2.6.0",
"rimraf": "^3.0.2",
"sort-package-json": "^1.55.0",
"stylelint": "^14.6.0",
"stylelint-config-html": "^1.0.0",
"stylelint-config-prettier": "^9.0.3",
"stylelint-config-recommended": "^7.0.0",
"stylelint-config-standard": "^25.0.0",
"stylelint-order": "^5.0.0",
"stylus": "^0.56.0",
"typescript": "^4.6.2",
"unplugin-auto-import": "^0.6.6",
"vite": "^2.8.6",
"vue-eslint-parser": "^8.3.0"
},
"engines": {
"node": "^12 || >=14"
}
}
This source diff could not be displayed because it is too large. You can view the blob instead.
module.exports = {
plugins: {
autoprefixer: {},
},
}
module.exports = {
printWidth: 100,
semi: false,
tabWidth: 4,
vueIndentScriptAndStyle: true,
singleQuote: true,
trailingComma: 'all',
proseWrap: 'never',
htmlWhitespaceSensitivity: 'strict',
endOfLine: 'lf',
overrides: [
{
files: ['*.{yml,yaml,styl}'],
options: {
tabWidth: 2,
},
},
],
}
<script setup lang="ts">
onLaunch(() => {
console.log('App Launch')
})
onShow(() => {
console.log('App Show')
})
onHide(() => {
console.log('App Hide')
})
</script>
<style>
/* common css */
</style>
/**
* 通用响应内容包装
*/
namespace API {
export interface Result<T = any> {
/**
* 状态码
*/
status: Status
/**
* 消息
*/
message: string
/**
* 响应时间
*/
timestamp: string
/**
* 接口耗时(不含网络通信时间)
*/
times: string
/**
* 自定义错误码
*/
code: number
/**
* 详细信息
*/
details?: string
/**
* 异常信息
*/
error?: string
/**
* 响应内容
*/
body: T
}
export enum Status {
/**
* 成功
*/
OK = 200,
/**
* 用户认证失败
*/
NON_AUTHORITATIVE_INFORMATION = 203,
/**
* 失败的请求,通常是一些验证错误(当出现该状态码时,将产生对应的业务错误编码,可以使用 Result.details 进行交互提醒)
*/
FAIL = 400,
/**
* 鉴权失败
*/
UNAUTHORIZED = 401,
/**
* Token 错误/失效
*/
FORBIDDEN = 403,
/**
* 找不到资源
*/
NOT_FOUND = 404,
/**
* 不支持的请求类型
*/
METHOD_NOT_ALLOWED = 405,
/**
* 服务器错误
*/
INTERNAL_SERVER_ERROR = 500,
/**
* 未知错误
*/
UNKNOWN_ERROR = 500,
/**
* API 未实现
*/
NOT_IMPLEMENTED = 501,
/**
* 服务异常(网关提醒)
*/
BAD_GATEWAY = 502,
/**
* 服务暂停(网关提醒)
*/
SERVICE_UNAVAILABLE = 503,
}
export function toMessage(status: Status): string {
switch (status) {
case Status.OK:
return '成功'
case Status.FAIL:
return '失败'
case Status.UNAUTHORIZED:
return '用户认证失败'
case Status.FORBIDDEN:
return '拒绝访问'
case Status.NOT_FOUND:
return '找不到资源'
case Status.INTERNAL_SERVER_ERROR:
return '服务器错误'
case Status.NOT_IMPLEMENTED:
return '未实现'
case Status.BAD_GATEWAY:
return '网关错误'
case Status.SERVICE_UNAVAILABLE:
return '服务暂停'
default:
return '未知错误'
}
}
}
export { API }
const config: Application = {
name: __APP__.name,
version: __APP__.version,
description: __APP__.description,
author: __APP__.author,
lastBuildTime: __APP__.lastBuildTime,
}
export const $app = config
export function setupAppConfig() {
// 打印 App 信息
const infos: string[] = []
infos.push(`==================================================================`)
infos.push(`[App] name: ${config.name}`)
infos.push(`[App] version: ${config.version}`)
infos.push(`[App] description: ${config.description}`)
infos.push(`[App] author: ${config.author.name} ${config.author.url}`)
infos.push(`[App] lastBuildTime: ${config.lastBuildTime}`)
infos.push(`==================================================================`)
console.log('%c' + infos.join('\n'), 'color: #fadfa3;')
}
import { createSSRApp } from 'vue'
import App from './App.vue'
import { setupAppConfig } from '/@/config/app'
export function createApp() {
const app = createSSRApp(App)
// 打印 App 信息
// #ifdef H5
setupAppConfig()
// #endif
return {
app,
}
}
{
"name" : "智慧化工",
"appid" : "__UNI__534675B",
"description" : "湖北可赛化工 APP",
"versionName" : "1.0.0",
"versionCode" : "100",
"transformPx" : false,
/* 5+App特有相关 */
"app-plus" : {
"usingComponents" : true,
"nvueStyleCompiler" : "uni-app",
"compilerVersion" : 3,
"splashscreen" : {
"alwaysShowBeforeRender" : true,
"waiting" : true,
"autoclose" : true,
"delay" : 0
},
/* 模块配置 */
"modules" : {},
/* 应用发布信息 */
"distribute" : {
/* android打包配置 */
"android" : {
"permissions" : [
"<uses-permission android:name=\"android.permission.CHANGE_NETWORK_STATE\"/>",
"<uses-permission android:name=\"android.permission.MOUNT_UNMOUNT_FILESYSTEMS\"/>",
"<uses-permission android:name=\"android.permission.VIBRATE\"/>",
"<uses-permission android:name=\"android.permission.READ_LOGS\"/>",
"<uses-permission android:name=\"android.permission.ACCESS_WIFI_STATE\"/>",
"<uses-feature android:name=\"android.hardware.camera.autofocus\"/>",
"<uses-permission android:name=\"android.permission.ACCESS_NETWORK_STATE\"/>",
"<uses-permission android:name=\"android.permission.CAMERA\"/>",
"<uses-permission android:name=\"android.permission.GET_ACCOUNTS\"/>",
"<uses-permission android:name=\"android.permission.READ_PHONE_STATE\"/>",
"<uses-permission android:name=\"android.permission.CHANGE_WIFI_STATE\"/>",
"<uses-permission android:name=\"android.permission.WAKE_LOCK\"/>",
"<uses-permission android:name=\"android.permission.FLASHLIGHT\"/>",
"<uses-feature android:name=\"android.hardware.camera\"/>",
"<uses-permission android:name=\"android.permission.WRITE_SETTINGS\"/>"
]
},
/* ios打包配置 */
"ios" : {},
/* SDK配置 */
"sdkConfigs" : {}
}
},
/* 快应用特有相关 */
"quickapp" : {},
/* 小程序特有相关 */
"mp-weixin" : {
"appid" : "",
"setting" : {
"urlCheck" : false
},
"usingComponents" : true
},
"mp-alipay" : {
"usingComponents" : true
},
"mp-baidu" : {
"usingComponents" : true
},
"mp-toutiao" : {
"usingComponents" : true
},
"uniStatistics" : {
"enable" : false
},
"vueVersion" : "3"
}
{
"pages": [
//pages数组中第一项表示应用启动页,参考:https://uniapp.dcloud.io/collocation/pages
{
"path": "pages/index/index",
"style": {
"navigationBarTitleText": "智慧化工"
}
}
],
"globalStyle": {
"navigationBarTextStyle": "black",
"navigationBarTitleText": "uni-app",
"navigationBarBackgroundColor": "#F8F8F8",
"backgroundColor": "#F8F8F8"
}
}
<script setup lang="ts">
const title = ref('Hello World')
</script>
<template>
<view class="content">
<image class="logo" src="/static/logo.png" />
<view class="text-area">
<text class="title">{{ title }}</text>
</view>
</view>
</template>
<style>
.content {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}
.logo {
height: 200rpx;
width: 200rpx;
margin-top: 200rpx;
margin-left: auto;
margin-right: auto;
margin-bottom: 50rpx;
}
.text-area {
display: flex;
justify-content: center;
}
.title {
/* font-size: 36rpx; */
color: #8f8f94;
}
</style>
/**
* 这里是uni-app内置的常用样式变量
*
* uni-app 官方扩展插件及插件市场(https://ext.dcloud.net.cn)上很多三方插件均使用了这些样式变量
* 如果你是插件开发者,建议你使用scss预处理,并在插件代码中直接使用这些变量(无需 import 这个文件),方便用户通过搭积木的方式开发整体风格一致的App
*
*/
/**
* 如果你是App开发者(插件使用者),你可以通过修改这些变量来定制自己的插件主题,实现自定义主题功能
*
* 如果你的项目同样使用了scss预处理,你也可以直接在你的 scss 代码中使用如下变量,同时无需 import 这个文件
*/
/* 颜色变量 */
/* 行为相关颜色 */
$uni-color-primary: #007aff;
$uni-color-success: #4cd964;
$uni-color-warning: #f0ad4e;
$uni-color-error: #dd524d;
/* 文字基本颜色 */
$uni-text-color: #333; //基本色
$uni-text-color-inverse: #fff; //反色
$uni-text-color-grey: #999; //辅助灰色,如加载更多的提示信息
$uni-text-color-placeholder: #808080;
$uni-text-color-disable: #c0c0c0;
/* 背景颜色 */
$uni-bg-color: #fff;
$uni-bg-color-grey: #f8f8f8;
$uni-bg-color-hover: #f1f1f1; //点击状态颜色
$uni-bg-color-mask: rgb(0 0 0 / 40%); //遮罩颜色
/* 边框颜色 */
$uni-border-color: #c8c7cc;
/* 尺寸变量 */
/* 文字尺寸 */
$uni-font-size-sm: 24rpx;
$uni-font-size-base: 28rpx;
$uni-font-size-lg: 32rpx;
/* 图片尺寸 */
$uni-img-size-sm: 40rpx;
$uni-img-size-base: 52rpx;
$uni-img-size-lg: 80rpx;
/* Border Radius */
$uni-border-radius-sm: 4rpx;
$uni-border-radius-base: 6rpx;
$uni-border-radius-lg: 12rpx;
$uni-border-radius-circle: 50%;
/* 水平间距 */
$uni-spacing-row-sm: 10px;
$uni-spacing-row-base: 20rpx;
$uni-spacing-row-lg: 30rpx;
/* 垂直间距 */
$uni-spacing-col-sm: 8rpx;
$uni-spacing-col-base: 16rpx;
$uni-spacing-col-lg: 24rpx;
/* 透明度 */
$uni-opacity-disabled: 0.3; // 组件禁用态的透明度
/* 文章场景相关 */
$uni-color-title: #2c405a; // 文章标题颜色
$uni-font-size-title: 40rpx;
$uni-color-subtitle: #555; // 二级标题颜色
$uni-font-size-subtitle: 36rpx;
$uni-color-paragraph: #3f536e; // 文章段落颜色
$uni-font-size-paragraph: 30rpx;
module.exports = {
root: true,
plugins: ['stylelint-order'],
customSyntax: 'postcss-less',
extends: ['stylelint-config-standard', 'stylelint-config-prettier'],
rules: {
'selector-class-pattern': null,
'selector-pseudo-class-no-unknown': [
true,
{
ignorePseudoClasses: ['global'],
},
],
'selector-pseudo-element-no-unknown': [
true,
{
ignorePseudoElements: ['v-deep'],
},
],
'at-rule-no-unknown': [
true,
{
ignoreAtRules: [
'tailwind',
'apply',
'variants',
'responsive',
'screen',
'function',
'if',
'each',
'include',
'mixin',
],
},
],
'no-empty-source': null,
'named-grid-areas-no-invalid': null,
'unicode-bom': 'never',
'no-descending-specificity': null,
'font-family-no-missing-generic-family-keyword': null,
'declaration-colon-space-after': 'always-single-line',
'declaration-colon-space-before': 'never',
// 'declaration-block-trailing-semicolon': 'always',
'rule-empty-line-before': [
'always',
{
ignore: ['after-comment', 'first-nested'],
},
],
'unit-no-unknown': [true, { ignoreUnits: ['rpx'] }],
'order/order': [
[
'dollar-variables',
'custom-properties',
'at-rules',
'declarations',
{
type: 'at-rule',
name: 'supports',
},
{
type: 'at-rule',
name: 'media',
},
'rules',
],
{ severity: 'warning' },
],
},
ignoreFiles: ['**/*.js', '**/*.jsx', '**/*.tsx', '**/*.ts'],
overrides: [
{
files: ['**/*.(html|vue)'],
customSyntax: 'postcss-html',
},
{
files: ['*.vue', '**/*.vue'],
extends: ['stylelint-config-recommended', 'stylelint-config-html'],
rules: {
'selector-pseudo-class-no-unknown': [
true,
{
ignorePseudoClasses: ['deep', 'global'],
},
],
'selector-pseudo-element-no-unknown': [
true,
{
ignorePseudoElements: ['v-deep', 'v-global', 'v-slotted'],
},
],
},
},
],
}
{
"compilerOptions": {
"target": "esnext",
"useDefineForClassFields": true,
"module": "esnext",
"moduleResolution": "node",
"strict": true,
"jsx": "preserve",
"sourceMap": true,
"resolveJsonModule": true,
"esModuleInterop": true,
"lib": ["esnext", "dom"],
"types": ["@dcloudio/types"],
"baseUrl": ".",
"paths": {
"/@/*": ["src/*"],
"/#/*": ["types/*"]
}
},
"include": [
"src/**/*.ts",
"src/**/*.d.ts",
"src/**/*.tsx",
"src/**/*.vue",
"types/**/*.d.ts",
"build/**/*.ts"
],
"exclude": ["node_modules", "unpackage"]
}
/**
* App 信息
*/
type Application = {
/**
* 项目名称
*/
name: string
/**
* 版本号
*/
version: string
/**
* 项目描述信息
*/
description: string
/**
* 作者
*/
author: Author
/**
* 最后构建时间
*/
lastBuildTime: string
}
/**
* App 作者信息
*/
type Author = {
/**
* 作者名称
*/
name: string
/**
* 地址
*/
url: string
}
declare const __APP__: Application
// Generated by 'unplugin-auto-import'
// We suggest you to commit this file into source control
declare global {
const $app: typeof import('/@/config/app')['$app']
const API: typeof import('/@/api/types')['API']
const computed: typeof import('vue')['computed']
const createApp: typeof import('vue')['createApp']
const customRef: typeof import('vue')['customRef']
const defineAsyncComponent: typeof import('vue')['defineAsyncComponent']
const defineComponent: typeof import('vue')['defineComponent']
const effectScope: typeof import('vue')['effectScope']
const EffectScope: typeof import('vue')['EffectScope']
const getCurrentInstance: typeof import('vue')['getCurrentInstance']
const getCurrentScope: typeof import('vue')['getCurrentScope']
const h: typeof import('vue')['h']
const inject: typeof import('vue')['inject']
const isReadonly: typeof import('vue')['isReadonly']
const isRef: typeof import('vue')['isRef']
const markRaw: typeof import('vue')['markRaw']
const nextTick: typeof import('vue')['nextTick']
const onActivated: typeof import('vue')['onActivated']
const onAddToFavorites: typeof import('@dcloudio/uni-app')['onAddToFavorites']
const onBackPress: typeof import('@dcloudio/uni-app')['onBackPress']
const onBeforeMount: typeof import('vue')['onBeforeMount']
const onBeforeUnmount: typeof import('vue')['onBeforeUnmount']
const onBeforeUpdate: typeof import('vue')['onBeforeUpdate']
const onDeactivated: typeof import('vue')['onDeactivated']
const onError: typeof import('@dcloudio/uni-app')['onError']
const onErrorCaptured: typeof import('vue')['onErrorCaptured']
const onHide: typeof import('@dcloudio/uni-app')['onHide']
const onLaunch: typeof import('@dcloudio/uni-app')['onLaunch']
const onLoad: typeof import('@dcloudio/uni-app')['onLoad']
const onMounted: typeof import('vue')['onMounted']
const onNavigationBarButtonTap: typeof import('@dcloudio/uni-app')['onNavigationBarButtonTap']
const onNavigationBarSearchInputChanged: typeof import('@dcloudio/uni-app')['onNavigationBarSearchInputChanged']
const onNavigationBarSearchInputClicked: typeof import('@dcloudio/uni-app')['onNavigationBarSearchInputClicked']
const onNavigationBarSearchInputConfirmed: typeof import('@dcloudio/uni-app')['onNavigationBarSearchInputConfirmed']
const onNavigationBarSearchInputFocusChanged: typeof import('@dcloudio/uni-app')['onNavigationBarSearchInputFocusChanged']
const onPageNotFound: typeof import('@dcloudio/uni-app')['onPageNotFound']
const onPageScroll: typeof import('@dcloudio/uni-app')['onPageScroll']
const onPullDownRefresh: typeof import('@dcloudio/uni-app')['onPullDownRefresh']
const onReachBottom: typeof import('@dcloudio/uni-app')['onReachBottom']
const onReady: typeof import('@dcloudio/uni-app')['onReady']
const onRenderTracked: typeof import('vue')['onRenderTracked']
const onRenderTriggered: typeof import('vue')['onRenderTriggered']
const onResize: typeof import('@dcloudio/uni-app')['onResize']
const onScopeDispose: typeof import('vue')['onScopeDispose']
const onServerPrefetch: typeof import('vue')['onServerPrefetch']
const onShareAppMessage: typeof import('@dcloudio/uni-app')['onShareAppMessage']
const onShareTimeline: typeof import('@dcloudio/uni-app')['onShareTimeline']
const onShow: typeof import('@dcloudio/uni-app')['onShow']
const onTabItemTap: typeof import('@dcloudio/uni-app')['onTabItemTap']
const onThemeChange: typeof import('@dcloudio/uni-app')['onThemeChange']
const onUnhandledRejection: typeof import('@dcloudio/uni-app')['onUnhandledRejection']
const onUnload: typeof import('@dcloudio/uni-app')['onUnload']
const onUnmounted: typeof import('vue')['onUnmounted']
const onUpdated: typeof import('vue')['onUpdated']
const provide: typeof import('vue')['provide']
const reactive: typeof import('vue')['reactive']
const readonly: typeof import('vue')['readonly']
const ref: typeof import('vue')['ref']
const resolveComponent: typeof import('vue')['resolveComponent']
const shallowReactive: typeof import('vue')['shallowReactive']
const shallowReadonly: typeof import('vue')['shallowReadonly']
const shallowRef: typeof import('vue')['shallowRef']
const toRaw: typeof import('vue')['toRaw']
const toRef: typeof import('vue')['toRef']
const toRefs: typeof import('vue')['toRefs']
const triggerRef: typeof import('vue')['triggerRef']
const unref: typeof import('vue')['unref']
const useAttrs: typeof import('vue')['useAttrs']
const useCssModule: typeof import('vue')['useCssModule']
const useCssVars: typeof import('vue')['useCssVars']
const useSlots: typeof import('vue')['useSlots']
const watch: typeof import('vue')['watch']
const watchEffect: typeof import('vue')['watchEffect']
}
export {}
/// <reference types="vite/client" />
declare module '*.vue' {
import { DefineComponent } from 'vue'
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/ban-types
const component: DefineComponent<{}, {}, any>
export default component
}
declare type Recordable<T = any> = Record<string, T>
interface ImportMetaEnv extends ViteEnv {
__: unknown
}
declare interface ViteEnv {
// APP 名称
VITE_GLOB_APP_NAME: string
// APP 描述
VITE_GLOB_APP_DESCRIPTION?: string
// API 接口地址
VITE_GLOB_API_URL: string
// API 接口地址前缀
VITE_GLOB_API_URL_PREFIX?: string
// 公共文件上传 API URL
VITE_GLOB_UPLOAD_URL?: string
}
// generated by @dcloudio/uni-helper-json/dist/tags.json
declare module 'vue' {
// uni-app 全局组件高亮
export interface GlobalComponents {
block: typeof HTMLElement
view: typeof HTMLElement
'scroll-view': typeof HTMLElement
'match-media': typeof HTMLElement
swiper: typeof HTMLElement
'swiper-item': typeof HTMLElement
'movable-view': typeof HTMLElement
'movable-area': typeof HTMLElement
text: typeof HTMLElement
'rich-text': typeof HTMLElement
progress: typeof HTMLElement
button: typeof HTMLElement
'checkbox-group': typeof HTMLElement
checkbox: typeof HTMLElement
form: typeof HTMLElement
input: typeof HTMLElement
label: typeof HTMLElement
picker: typeof HTMLElement
'picker-view': typeof HTMLElement
'radio-group': typeof HTMLElement
radio: typeof HTMLElement
slider: typeof HTMLElement
switch: typeof HTMLElement
textarea: typeof HTMLElement
navigator: typeof HTMLElement
audio: typeof HTMLElement
image: typeof HTMLElement
video: typeof HTMLElement
map: typeof HTMLElement
canvas: typeof HTMLElement
'web-view': typeof HTMLElement
'cover-view': typeof HTMLElement
'cover-image': typeof HTMLElement
icon: typeof HTMLElement
'picker-view-column': typeof HTMLElement
camera: typeof HTMLElement
'live-player': typeof HTMLElement
'live-pusher': typeof HTMLElement
'open-data': typeof HTMLElement
ad: typeof HTMLElement
'ad-draw': typeof HTMLElement
'navigation-bar': typeof HTMLElement
'custom-tab-bar': typeof HTMLElement
'page-meta': typeof HTMLElement
editor: typeof HTMLElement
'unicloud-db': typeof HTMLElement
}
}
export {}
import { loadEnv } from 'vite'
import type { ConfigEnv, UserConfig } from 'vite'
import dayjs from 'dayjs'
import pkg from './package.json'
import { createVitePlugins } from './build/vite'
import { getRootPath, wrapperEnv } from './build/utils'
// https://vitejs.dev/config/
export default ({ mode }: ConfigEnv): UserConfig => {
const root = process.cwd()
const env = wrapperEnv(loadEnv(mode, root))
return {
resolve: {
alias: [
// /@xxxx => src/xxxx
{
find: /\/@\//,
replacement: getRootPath('./src') + '/',
},
// /#xxxx => types/xxxx
{
find: /\/#\//,
replacement: getRootPath('./types') + '/',
},
],
},
plugins: createVitePlugins(env),
optimizeDeps: {
include: ['lodash-es', '@vueuse/core'],
},
define: {
__APP__: {
name: pkg.name,
version: pkg.version,
description: pkg.description,
author: pkg.author,
lastBuildTime: dayjs().format('YYYY-MM-DD HH:mm:ss'),
},
},
}
}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论