Commit 82a6f534 authored by szq233's avatar szq233

chore: eslint

parent 62e8493f
Pipeline #1042 canceled with stages
module.exports = {
root: true,
env: {
browser: true,
es2021: true,
node: true
},
extends: [
'plugin:vue/essential',
'standard'
],
globals: {
uni: 'readonly',
dd: 'readonly',
plus: 'readonly',
wx: 'readonly'
},
parserOptions: {
ecmaVersion: 'latest',
parser: '@typescript-eslint/parser',
sourceType: 'module'
},
plugins: [
'vue',
'@typescript-eslint'
],
rules: {
camelcase: 'off',
semi: 'error',
'import/first': 'off',
'no-console': 'off',
'no-debugger': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
'vue/multi-word-component-names': 'off'
}
}
# uni-app-template
## Project setup
```
``` shell
yarn install
```
### Compiles and hot-reloads for development
```
``` shell
yarn serve
```
### Compiles and minifies for production
```
``` shell
yarn build
```
### Customize configuration
See [Configuration Reference](https://cli.vuejs.org/config/).
......@@ -42,8 +42,8 @@ process.UNI_LIBRARIES.forEach(libraryName => {
plugins.push([
'import',
{
'libraryName': libraryName,
'customName': (name) => {
libraryName,
customName: (name) => {
return `${libraryName}/lib/${name}/${name}`
}
}
......
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>
<%= htmlWebpackPlugin.options.title %>
</title>
<link rel="icon" href="<%= BASE_URL %>static/logo.png">
<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' : '') + '" />')
......@@ -21,5 +21,4 @@
<div id="app"></div>
<!-- built files will be auto injected -->
</body>
</html>
\ No newline at end of file
import Vue from 'vue';
import { $u } from './src/models/uview'; // 引入this.$u的相关类型定义
import { GlobalMixins } from './src/store/model'; // 引入混入到全局的vuex中state中属性类型扩展
declare module "vue/types/options" {
type Hooks = App.AppInstance & Page.PageInstance;
/* eslint-disable */
import Vue from 'vue'
import { $u } from './src/models/uview' // 引入this.$u的相关类型定义
import { GlobalMixins } from './src/store/model' // 引入混入到全局的vuex中state中属性类型扩展
declare module 'vue/types/options' {
type Hooks = App.AppInstance & Page.PageInstance
interface ComponentOptions<V extends Vue> extends Hooks {
mpType?: string;
}
......@@ -14,4 +15,4 @@ declare module 'vue/types/vue' {
}
}
declare var ROUTES=[];
declare var ROUTES=[]
declare module '*.vue' {
import Vue from 'vue';
export default Vue;
import Vue from 'vue'
export default Vue
}
declare module 'uview-ui'
......
<script lang="ts">
import Vue from 'vue';
export default Vue.extend({
import Vue from 'vue'
export default Vue.extend({
mpType: 'app',
onLaunch() {
onLaunch () {
// 隐藏原生的tabBar,只使用自定义的tabbar组件
uni.hideTabBar({
success: (res) => {
......@@ -11,13 +11,13 @@
})
console.log('App Launch')
},
onShow() {
onShow () {
console.log('App Show')
},
onHide() {
onHide () {
console.log('App Hide')
}
});
})
</script>
<style lang="scss">
......
......@@ -2,7 +2,7 @@
// 同时,我们也可以在此使用getApp().globalData,如果你把token放在getApp().globalData的话,也是可以使用的
const install = (Vue: any, vm: any) => {
Vue.prototype.$u.http.setConfig({
baseUrl: `https://test.test/api`,
baseUrl: 'https://test.test/api',
// 如果将此值设置为true,拦截回调中将会返回服务端返回的所有数据response,而不是response.data
// 设置为true后,就需要在this.$u.http.interceptor.response进行多一次的判断,请打印查看具体值
// 设置自定义头部content-type
......
import Vue from 'vue'
import { Component } from 'vue-property-decorator'
// import { Component } from 'vue-property-decorator'
import uView from "uview-ui";
import uView from 'uview-ui'
import Loading from './loading/loading.vue'
import TabBar from './tabbar/index.vue'
import scss from '@/uni.scss'
......
......@@ -3,7 +3,7 @@ import App from './App.vue'
import store from '@/store'
import eruda from 'eruda'
import { router, RouterMount } from './router'
import '@/components/register';
import '@/components/register'
import { VuexMixin } from '@/store/$u.mixin'
......@@ -14,7 +14,7 @@ Vue.mixin(VuexMixin)
// if (process.env.VUE_APP_ENV === 'test') {
// 默认开启eruda调试台,这里可以用环境变量判断开启关闭
eruda.init();
eruda.init()
// }
const app = new App({
......@@ -34,5 +34,5 @@ RouterMount(app, router, '#app')
// #endif
// #ifndef H5
app.$mount(); //为了兼容小程序及app端必须这样写才有效果
app.$mount() // 为了兼容小程序及app端必须这样写才有效果
// #endif
......@@ -12,6 +12,7 @@ interface UView {
/**
* 此属性用于获取设备的信息,相当于uni.getSystemInfoSync()的效果
*/
// eslint-disable-next-line no-undef
sys(): UniNamespace.GetSystemInfoResult
queryParams(data: any, isPrefix?: boolean, arrayFormat?: string): string
route(options: any, params: any): void
......
......@@ -6,7 +6,7 @@
</template>
<script lang="ts">
import { Vue, Component, Prop, Watch, Emit, Ref } from 'vue-property-decorator';
import { Vue, Component } from 'vue-property-decorator'
@Component
export default class About extends Vue {
......
......@@ -10,12 +10,13 @@
</template>
<script lang="ts">
import { Vue, Component, Watch, Emit, Ref } from 'vue-property-decorator';
// Vue, Component, Prop, Watch, Emit, Ref
import { Vue, Component } from 'vue-property-decorator'
@Component
export default class Home extends Vue {
private title = '这里是首页'
onShow() {
onShow () {
this.$u.toast('首页')
this.$u.vuex('vuex_user', {
name: '测试',
......
......@@ -5,7 +5,7 @@
</template>
<script lang="ts">
import { Vue, Component, Prop, Watch, Emit, Ref } from 'vue-property-decorator';
import { Vue, Component } from 'vue-property-decorator'
@Component
export default class NoAccess extends Vue {
......
......@@ -6,7 +6,7 @@
</template>
<script lang="ts">
import { Vue, Component, Prop, Watch, Emit, Ref } from 'vue-property-decorator';
import { Vue, Component } from 'vue-property-decorator'
@Component
export default class About extends Vue {
......
import { RouterMount, createRouter, RoutesRule } from 'uni-simple-router';
import { RouterMount, createRouter, RoutesRule } from 'uni-simple-router'
const pages = require('./pages.ts')
const RouterPages: RoutesRule[] = [
......@@ -18,12 +18,12 @@ const router = createRouter({
return { name: '404' }
}
}]
});
})
// 路由前置守卫
router.beforeEach((to, from, next) => {
next();
});
next()
})
// 路由后置守卫
router.afterEach((to, from) => {
......
import { Component, Vue } from 'vue-property-decorator'
import { mapState } from 'vuex'
import store from "./index"
import store from './index'
// 尝试将用户在根目录中的store/index.js的vuex的state变量,全部加载到全局变量中
let $uStoreKey: string[] = [];
try{
$uStoreKey = store.state ? Object.keys(store.state) : [];
}catch(e){ }
let $uStoreKey: string[] = []
try {
$uStoreKey = store.state ? Object.keys(store.state) : []
} catch (e) { }
@Component({
computed: {
......@@ -14,7 +14,7 @@ try{
}
})
export class VuexMixin extends Vue {
private created() {
private created () {
// 此处的types声明在src/models/uview/index.ts定义
// 将vuex方法挂在到$u中
// 使用方法为:如果要修改vuex的state中的user.name变量为"史诗" => this.$u.vuex('user.name', '史诗')
......
import Vue from 'vue'
import Vuex from 'vuex'
import { Store } from 'vuex';
import Vuex, { Store } from 'vuex'
Vue.use(Vuex)
let lifeData: any = {};
let lifeData: any = {}
// 尝试获取本地是否存在lifeData变量,第一次启动APP时是不存在的
try{
lifeData = uni.getStorageSync('lifeData');
}catch(e){ }
try {
lifeData = uni.getStorageSync('lifeData')
} catch (e) { }
// 需要永久存储,且下次APP启动需要取出的,在state中的变量名
const saveStateKeys = ['vuex_user', 'vuex_token'];
const saveStateKeys = ['vuex_user', 'vuex_token']
// 保存变量到本地存储中
const saveLifeData = function(key: string, value: any) {
const saveLifeData = function (key: string, value: any) {
// 判断变量名是否在需要存储的数组中
if (saveStateKeys.indexOf(key) != -1) {
if (saveStateKeys.indexOf(key) !== -1) {
// 获取本地存储的lifeData对象,将变量添加到对象中
let tmp = uni.getStorageSync('lifeData');
let tmp = uni.getStorageSync('lifeData')
// 第一次打开APP,不存在lifeData变量,故放一个{}空对象
tmp = tmp ? tmp : {};
tmp[key] = value;
tmp = tmp || {}
tmp[key] = value
// 执行这一步后,所有需要存储的变量,都挂载在本地的lifeData对象中
uni.setStorageSync('lifeData', tmp);
uni.setStorageSync('lifeData', tmp)
}
}
......@@ -35,17 +34,17 @@ const store = new Vuex.Store({
vuex_user: lifeData.vuex_user ? lifeData.vuex_user : { name: '测试名', corpid: '2333' },
vuex_token: lifeData.vuex_token ? lifeData.vuex_token : '',
// 如果vuex_version无需保存到本地永久存储,无需lifeData.vuex_version方式
vuex_version: '1.0.1',
vuex_version: '1.0.1'
},
mutations: {
$uStore(state: any, payload: any) {
$uStore (state: any, payload: any) {
// 判断是否多层级调用,state中为对象存在的情况,诸如user.info.score = 1
let nameArr = payload.name.split('.') as string[]
let saveKey = '';
let len = nameArr.length;
if(len >= 2) {
let obj = state[nameArr[0]];
for(let i = 1; i < len - 1; i ++) {
const nameArr = payload.name.split('.') as string[]
let saveKey = ''
const len = nameArr.length
if (len >= 2) {
let obj = state[nameArr[0]]
for (let i = 1; i < len - 1; i++) {
obj = obj[nameArr[i]]
}
// obj[nameArr[len - 1]] = payload.value;
......@@ -55,7 +54,7 @@ const store = new Vuex.Store({
// 单层级变量,在state就是一个普通变量的情况
// state[payload.name] = payload.value;
Vue.set(state, payload.name, payload.value)
saveKey = payload.name;
saveKey = payload.name
}
// 保存变量到本地,见顶部函数定义
saveLifeData(saveKey, state[saveKey])
......
const fs = require('fs')
let versionCode = '0.0.1'
const path = require('path')
const versionCode = '0.0.1'
// try {
// const execSync = require('child_process').execSync // 同步子进程
// const commit = execSync('git show -s --format=%d').toString().trim()
......@@ -15,7 +16,7 @@ let versionCode = '0.0.1'
* qa----测试
* @type {{qa: string, prod: string}}
*/
const paths = {
const paths = {
qa: 'https://测试环境域名地址/' + versionCode + '/build/h5',
prod: 'https://正式环境域名地址/' + versionCode + '/build/h5'
}
......@@ -121,7 +122,7 @@ const data = {
}
}
},
publicPath: publicPath,
publicPath,
title: 'h5模板',
router: {
mode: 'history',
......@@ -142,7 +143,7 @@ const data = {
const env = process.env.VUE_APP_ENV === 'online' ? '正式环境' : '测试环境'
console.log(`uni-app: publicPath-${env}:${publicPath}`)
fs.writeFile(
`${__dirname}/../manifest.json`,
path.join(__dirname, '../manifest.json'),
JSON.stringify(data),
(e) => (e ? console.error(e) : console.log('manifest.json 配置文件更新成功'))
)
const fs = require('fs')
const path = require('path')
const pages = require('../router/pages.ts')
const tabBar = require('./tabbarList')
......@@ -28,7 +29,7 @@ const data = {
}
}
fs.writeFile(
`${__dirname}/../pages.json`,
path.join(__dirname, '../pages.json'),
JSON.stringify(data),
(e) => (e ? console.error(e) : console.log('pages.json 配置文件更新成功'))
)
//vue.config.js
// vue.config.js
const TransformPages = require('uni-read-pages')
const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin')
const {webpack} = new TransformPages()
const { webpack } = new TransformPages()
module.exports = {
configureWebpack: {
plugins: [
configureWebpack: (config) => {
config.plugins = [
new webpack.DefinePlugin({
ROUTES: webpack.DefinePlugin.runtimeValue(() => {
const tfPages = new TransformPages({
includes: ['path', 'name', 'aliasPath']
});
})
return JSON.stringify(tfPages.routes)
}, true )
}, true)
})
]
},
configureWebpack: (config) => {
// 限制工作线程使用1024MB内存
// get a reference to the existing ForkTsCheckerWebpackPlugin
const existingForkTsChecker = config.plugins.filter(
p => p instanceof ForkTsCheckerWebpackPlugin,
p => p instanceof ForkTsCheckerWebpackPlugin
)[0]
// remove the existing ForkTsCheckerWebpackPlugin
// so that we can replace it with our modified version
config.plugins = config.plugins.filter(
p => !(p instanceof ForkTsCheckerWebpackPlugin),
);
p => !(p instanceof ForkTsCheckerWebpackPlugin)
)
// copy the options from the original ForkTsCheckerWebpackPlugin
// instance and add the memoryLimit property
const forkTsCheckerOptions = existingForkTsChecker.options;
forkTsCheckerOptions.memoryLimit = 1024;
config.plugins.push(new ForkTsCheckerWebpackPlugin(forkTsCheckerOptions));
const forkTsCheckerOptions = existingForkTsChecker.options
forkTsCheckerOptions.memoryLimit = 1024
config.plugins.push(new ForkTsCheckerWebpackPlugin(forkTsCheckerOptions))
},
transpileDependencies: ['uview-ui']
}
This diff is collapsed.
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