Commit f6f4a030 authored by sheng du's avatar sheng du
Browse files

init

parents
No related merge requests found
Pipeline #826 failed with stages
# Editor configuration, see http://editorconfig.org
# 表示是最顶层的 EditorConfig 配置文件
root = true
[*] # 表示所有文件适用
charset = utf-8 # 设置文件字符集为 utf-8
indent_style = space # 缩进风格(tab | space)
indent_size = 2 # 缩进大小
end_of_line = lf # 控制换行类型(lf | cr | crlf), lf 适配 mac,linix ; cr 适配window;
trim_trailing_whitespace = true # 去除行首的任意空白字符
insert_final_newline = true # 始终在文件末尾插入一个新行
[*.md] # 表示仅 md 文件适用以下规则
max_line_length = off
trim_trailing_whitespace = false
# 开发环境配置
VITE_APP_ENV = 'development'
\ No newline at end of file
# 生产环境配置
VITE_APP_ENV = 'production'
\ No newline at end of file
dist
node_modules
\ No newline at end of file
/* eslint-env node */
require('@rushstack/eslint-patch/modern-module-resolution');
module.exports = {
root: true,
extends: [
'plugin:vue/vue3-essential',
'eslint:recommended',
'@vue/eslint-config-typescript',
'@vue/eslint-config-prettier',
],
// 小程序全局变量
globals: {
uni: true,
wx: true,
WechatMiniprogram: true,
getCurrentPages: true,
UniHelper: true,
},
parserOptions: {
ecmaVersion: 'latest',
},
rules: {
'prettier/prettier': [
'warn',
{
singleQuote: true,
semi: false,
printWidth: 80,
trailingComma: 'es5',
endOfLine: 'auto',
},
],
'vue/multi-word-component-names': ['off'],
'vue/no-setup-props-destructure': ['off'],
'vue/no-deprecated-html-element-is': ['off'],
'@typescript-eslint/no-unused-vars': ['off'],
},
};
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*
node_modules
.DS_Store
dist
*.local
# Editor directories and files
.idea
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
\ No newline at end of file
{ // launch.json 配置了启动调试时相关设置,configurations下节点名称可为 app-plus/h5/mp-weixin/mp-baidu/mp-alipay/mp-qq/mp-toutiao/mp-360/
// launchtype项可配置值为local或remote, local代表前端连本地云函数,remote代表前端连云端云函数
"version": "0.0",
"configurations": [{
"app-plus" :
{
"launchtype" : "local"
},
"default" :
{
"launchtype" : "local"
},
"mp-weixin" :
{
"launchtype" : "local"
},
"type" : "uniCloud"
}
]
}
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"
pnpm lint-staged
\ No newline at end of file
{
"$schema": "https://json.schemastore.org/prettierrc",
"printWidth": 120,
"tabWidth": 2,
"useTabs": true,
"semi": true,
"singleQuote": true,
"trailingComma": "es5",
"bracketSpacing": true,
"jsxBracketSameLine": true,
"arrowParens": "avoid",
"endOfLine": "auto"
}
### Lint with [ESLint](https://eslint.org/)
```sh
npm run lint
```
### prettier 全局格式化
```sh
npx prettier --write .
```
<!doctype html>
<html>
<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": "uni-preset-vue",
"version": "0.0.0",
"scripts": {
"dev:app": "uni -p app",
"dev:app-android": "uni -p app-android",
"dev:app-ios": "uni -p app-ios",
"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-jd": "uni -p mp-jd",
"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:app-android": "uni build -p app-android",
"build:app-ios": "uni build -p app-ios",
"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-jd": "uni build -p mp-jd",
"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",
"type-check": "vue-tsc --noEmit",
"lint": "eslint . --ext .vue,.js,.ts --fix --ignore-path .gitignore",
"prepare": "husky install",
"lint-staged": "lint-staged"
},
"lint-staged": {
"*.{vue,ts,js}": [
"eslint --fix"
]
},
"dependencies": {
"@dcloudio/uni-app": "3.0.0-3081220230817001",
"@dcloudio/uni-app-plus": "3.0.0-3081220230817001",
"@dcloudio/uni-components": "3.0.0-3081220230817001",
"@dcloudio/uni-h5": "3.0.0-3081220230817001",
"@dcloudio/uni-mp-alipay": "3.0.0-3081220230817001",
"@dcloudio/uni-mp-baidu": "3.0.0-3081220230817001",
"@dcloudio/uni-mp-jd": "3.0.0-3081220230817001",
"@dcloudio/uni-mp-kuaishou": "3.0.0-3081220230817001",
"@dcloudio/uni-mp-lark": "3.0.0-3081220230817001",
"@dcloudio/uni-mp-qq": "3.0.0-3081220230817001",
"@dcloudio/uni-mp-toutiao": "3.0.0-3081220230817001",
"@dcloudio/uni-mp-weixin": "3.0.0-3081220230817001",
"@dcloudio/uni-quickapp-webview": "3.0.0-3081220230817001",
"@dcloudio/uni-ui": "^1.5.2",
"dayjs": "^1.11.10",
"pinia": "2.0.36",
"ts-md5": "^1.3.1",
"vue": "^3.3.2",
"vue-i18n": "^9.1.9"
},
"devDependencies": {
"@dcloudio/types": "^3.3.2",
"@dcloudio/uni-automator": "3.0.0-3081220230817001",
"@dcloudio/uni-cli-shared": "3.0.0-3081220230817001",
"@dcloudio/uni-stacktracey": "3.0.0-3081220230817001",
"@dcloudio/vite-plugin-uni": "3.0.0-3081220230817001",
"@rushstack/eslint-patch": "^1.7.2",
"@types/node": "^20.11.22",
"@types/uni-app": "^1.4.8",
"@uni-helper/uni-app-types": "^0.5.12",
"@uni-helper/uni-ui-types": "^0.5.11",
"@vue/eslint-config-prettier": "^9.0.0",
"@vue/eslint-config-typescript": "^12.0.0",
"@vue/runtime-core": "^3.2.45",
"@vue/tsconfig": "^0.1.3",
"eslint": "^8.57.0",
"eslint-plugin-vue": "^9.22.0",
"husky": "^8.0.0",
"less": "^4.2.0",
"less-loader": "^12.2.0",
"lint-staged": "^15.2.2",
"miniprogram-api-typings": "^3.12.2",
"prettier": "^3.2.5",
"sass": "^1.71.1",
"typescript": "^4.9.4",
"vite": "4.1.4",
"vue-tsc": "^1.0.24"
}
}
This diff is collapsed.
/// <reference types='@dcloudio/types' />
import 'vue'
declare module '@vue/runtime-core' {
type Hooks = App.AppInstance & Page.PageInstance
interface ComponentCustomOptions extends Hooks {}
}
<script setup lang="ts">
import { onLaunch, onShow, onHide } from '@dcloudio/uni-app'
onLaunch(() => {
console.log('App Launch')
})
onShow(() => {
console.log('App Show')
})
onHide(() => {
console.log('App Hide')
})
</script>
<style lang="less">
@import url('@/style/public.less');
@import url('@/style/business.less');
</style>
import http from './http'
export default {
// 项目分页
projectPage(data: ParameterType) {
return http.post('/sysApi/ipProjectEntity/page', data)
},
}
/**
* http 请求封装
* @author tangsj
* @param {*} url 请求地址
* @param {*} options 请求参数
*/
import config from '../config'
import utils from '../utils'
import { useUserStore } from '@/stores/modules/user'
// 记录请求中的请求数,控制loading显示
let requestCount = 0
let hasError = false
export function fetch(url: string, options: ParameterType) {
const userStore = useUserStore()
const header = {
Authorization: userStore.token,
}
options = Object.assign(
{
loading: true,
method: 'GET',
data: {},
holdTip: false,
},
options
)
return new Promise((resolve, reject) => {
if (requestCount === 0 && options.loading) {
hasError = false
uni.showLoading({
title: '加载中...',
})
}
requestCount += 1
uni.request({
url: `${config.apiRoot}${url}`,
data: options.data,
method: options.method,
header,
success: (res: ParameterType) => {
if (
res.statusCode < 200 ||
res.statusCode > 300 ||
Number(res.data.code) !== 200
) {
if (!options.holdTip) {
uni.showToast({
title: res.data.msg || '服务器异常!',
icon: 'none',
})
hasError = true
}
if (res.data.code == 5001) {
uni.reLaunch({
url: '/pages/login/index',
})
}
return reject(res.data || {})
}
return resolve(res.data || {})
},
fail: () => {
hasError = true
uni.showToast({
title: '服务器异常!',
icon: 'none',
})
reject({
msg: '服务器异常!',
})
},
complete: () => {
requestCount -= 1
if (requestCount === 0 && options.loading) {
if (hasError) {
setTimeout(() => {
uni.hideLoading()
}, 2000)
} else {
uni.hideLoading()
}
}
},
})
})
}
const http = {
get(url: string, data: ParameterType = {}, options = {}) {
return fetch(url, {
method: 'GET',
data: data.params,
...options,
})
},
post(url: string, data: ParameterType = {}, options = {}) {
if (data.params) {
// 将param放到url 参数里面
const query = utils.buildQueryString(data.params)
url += `?${query}`
delete data.params
}
return fetch(url, {
method: 'POST',
data,
...options,
})
},
}
export default http
const files: any = import.meta.globEager('./*.ts')
const modules: any = {}
Object.keys(files).forEach(key => {
if (key === './index.ts' || key === './http.ts') return
const reg = /^\.\/(.*)\.ts$/
const m: any = key.match(reg)
if (m[1]) {
modules[m[1]] = files[key].default
}
})
export default modules
import http from './http'
export default {
/**
* 用户登录(密码)
*
* @param {*} data
* @returns
*/
login(data: ParameterType) {
return http.post('/sysApi/login', data)
},
logout(data: ParameterType) {
return http.post('/sysApi/logout', data)
},
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment