emptyNames = new HashSet<>();
+ for (PropertyDescriptor pd : pds) {
+ Object srcValue = src.getPropertyValue(pd.getName());
+ if (srcValue == null){
+ emptyNames.add(pd.getName());
+ }
+ }
+ String[] result = new String[emptyNames.size()];
+ return emptyNames.toArray(result);
+ }
+
+ /**
+ * 非空拷贝
+ * @param source
+ * @param target
+ */
+ public static void copyNotNullBean(Object source, Object target) {
+ BeanUtils.copyProperties(source, target, getNullPropertyNames(source));
+ }
+}
diff --git a/backend/src/main/java/com/universe/utils/ChUtils/HttpContextUtils.java b/backend/src/main/java/com/universe/utils/ChUtils/HttpContextUtils.java
new file mode 100644
index 0000000..08ebecd
--- /dev/null
+++ b/backend/src/main/java/com/universe/utils/ChUtils/HttpContextUtils.java
@@ -0,0 +1,12 @@
+package com.universe.utils.ChUtils;
+
+import org.springframework.web.context.request.RequestContextHolder;
+import org.springframework.web.context.request.ServletRequestAttributes;
+
+import javax.servlet.http.HttpServletRequest;
+
+public class HttpContextUtils {
+ public static HttpServletRequest getHttpServletRequest(){
+ return ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
+ }
+}
diff --git a/backend/src/main/java/com/universe/utils/ChUtils/IpUtils.java b/backend/src/main/java/com/universe/utils/ChUtils/IpUtils.java
new file mode 100644
index 0000000..dfd1afb
--- /dev/null
+++ b/backend/src/main/java/com/universe/utils/ChUtils/IpUtils.java
@@ -0,0 +1,62 @@
+package com.universe.utils.ChUtils;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.util.StringUtils;
+
+import javax.servlet.http.HttpServletRequest;
+
+/****
+ *
+ * Project Name:spring-boot-seckill
+ * 从http请求中获取ip地址
+ *
+ * @ClassName: IPUtils
+ * @date 2019年1月3日 下午6:30:02
+ *
+ * @author youqiang.xiong
+ * @version 1.0
+ * @since
+ * @see
+ */
+
+
+public class IpUtils {
+ private static Logger logger = LoggerFactory.getLogger(IpUtils.class);
+
+ /**
+ * 获取IP地址
+ * 使用Nginx等反向代理软件, 则不能通过request.getRemoteAddr()获取IP地址
+ * 如果使用了多级反向代理的话,X-Forwarded-For的值并不止一个,而是一串IP地址,X-Forwarded-For中第一个非unknown的有效IP字符串,则为真实IP地址
+ */
+ public static String getIpAddr(HttpServletRequest request) {
+ String ip = null;
+ try {
+ ip = request.getHeader("x-forwarded-for");
+ if (StringUtils.isEmpty(ip) || "unknown".equalsIgnoreCase(ip)) {
+ ip = request.getHeader("Proxy-Client-IP");
+ }
+ if (StringUtils.isEmpty(ip) || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
+ ip = request.getHeader("WL-Proxy-Client-IP");
+ }
+ if (StringUtils.isEmpty(ip) || "unknown".equalsIgnoreCase(ip)) {
+ ip = request.getHeader("HTTP_CLIENT_IP");
+ }
+ if (StringUtils.isEmpty(ip) || "unknown".equalsIgnoreCase(ip)) {
+ ip = request.getHeader("HTTP_X_FORWARDED_FOR");
+ }
+ if (StringUtils.isEmpty(ip) || "unknown".equalsIgnoreCase(ip)) {
+ ip = request.getRemoteAddr();
+ }
+ } catch (Exception e) {
+ logger.error("IPUtils ERROR ", e);
+ }
+ // 使用代理,则获取第一个IP地址
+ if (StringUtils.isEmpty(ip) && ip.length() > 15) {
+ if (ip.indexOf(",") > 0) {
+ ip = ip.substring(0, ip.indexOf(","));
+ }
+ }
+ return ip;
+ }
+}
diff --git a/backend/src/main/java/com/universe/utils/ChUtils/JWTUtils.java b/backend/src/main/java/com/universe/utils/ChUtils/JWTUtils.java
new file mode 100644
index 0000000..9363643
--- /dev/null
+++ b/backend/src/main/java/com/universe/utils/ChUtils/JWTUtils.java
@@ -0,0 +1,40 @@
+package com.universe.utils.ChUtils;
+
+import io.jsonwebtoken.Jwt;
+import io.jsonwebtoken.JwtBuilder;
+import io.jsonwebtoken.Jwts;
+import io.jsonwebtoken.SignatureAlgorithm;
+
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Map;
+
+public class JWTUtils {
+
+ private static final String jwtToken = "123456chhh!@#$$";
+
+ public static String createToken(String userId){
+ Map claims = new HashMap<>();
+ claims.put("userId",userId);
+ System.out.println("!!!!!");
+ JwtBuilder jwtBuilder = Jwts.builder()
+ .signWith(SignatureAlgorithm.HS256, jwtToken) // 签发算法,秘钥为jwtToken
+ .setClaims(claims) // body数据,要唯一,自行设置
+ .setIssuedAt(new Date()) // 设置签发时间
+ .setExpiration(new Date(System.currentTimeMillis() + 24 * 60 * 60 * 60 * 1000));// 一天的有效时间
+ String token = jwtBuilder.compact();
+ return token;
+ }
+
+ public static Map checkToken(String token){
+ try {
+ Jwt parse = Jwts.parser().setSigningKey(jwtToken).parse(token);
+ return (Map) parse.getBody();
+ }catch (Exception e){
+ e.printStackTrace();
+ }
+ return null;
+
+ }
+
+}
diff --git a/backend/src/main/java/com/universe/utils/ChUtils/UserThreadLocal.java b/backend/src/main/java/com/universe/utils/ChUtils/UserThreadLocal.java
new file mode 100644
index 0000000..faf0d7c
--- /dev/null
+++ b/backend/src/main/java/com/universe/utils/ChUtils/UserThreadLocal.java
@@ -0,0 +1,22 @@
+/*
+package com.universe.utils.ChUtils;
+
+
+import com.pojo.po.User;
+
+public class UserThreadLocal {
+ //线程变量隔离
+ private UserThreadLocal(){}
+ private static final ThreadLocal LOCAL = new ThreadLocal<>();
+
+ public static void put(User user){
+ LOCAL.set(user);
+ }
+ public static User get(){
+ return LOCAL.get();
+ }
+ public static void remove(){
+ LOCAL.remove();
+ }
+}
+*/
diff --git a/backend/src/main/java/com/universe/utils/ConstantsConfig.java b/backend/src/main/java/com/universe/utils/ConstantsConfig.java
new file mode 100644
index 0000000..3862df5
--- /dev/null
+++ b/backend/src/main/java/com/universe/utils/ConstantsConfig.java
@@ -0,0 +1,20 @@
+package com.universe.utils;
+
+/**
+ * 常量类
+ * @author yuanjs
+ * @description:
+ * @date 2020-04-04 22:05
+ */
+public class ConstantsConfig {
+ /**
+ * 用户绑定小程序时对应的角色代码
+ */
+ public static final String ROLE_CUSTOMER ="1001";
+
+ public static final String ROLE_ADMIN ="1";
+
+ public static final String COUPON_GIFT="赠货券";
+ public static final String COUPON_MONEY="满减券";
+
+}
diff --git a/backend/src/main/java/com/universe/utils/ExportXlsHandler.java b/backend/src/main/java/com/universe/utils/ExportXlsHandler.java
new file mode 100644
index 0000000..84ba4f8
--- /dev/null
+++ b/backend/src/main/java/com/universe/utils/ExportXlsHandler.java
@@ -0,0 +1,93 @@
+package com.universe.utils;
+
+import com.github.pagehelper.PageInfo;
+import io.swagger.annotations.ApiModelProperty;
+import org.apache.poi.hssf.usermodel.HSSFRow;
+import org.apache.poi.hssf.usermodel.HSSFSheet;
+import org.apache.poi.hssf.usermodel.HSSFWorkbook;
+
+import java.io.ByteArrayOutputStream;
+import java.lang.reflect.Field;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * 导出Excel工具类
+ * @author yuanjs
+ * @description:
+ * @date 2020-05-05 20:19
+ */
+public class ExportXlsHandler {
+
+ public static String toString(Object obj) {
+ StringBuilder sb = new StringBuilder("{");
+ Field[] fields = obj.getClass().getDeclaredFields();
+ for (Field field : fields) {
+ ApiModelProperty apiModelProperty = field.getAnnotation(ApiModelProperty.class);
+ try {
+ if (apiModelProperty != null) {
+ field.setAccessible(true);
+ if (field.get(obj) != null) {
+ if (sb.length() > 1)
+ sb.append(",");
+ sb.append(String.format("%s:%s", apiModelProperty.value(), field.get(obj).toString()));
+ }
+ }
+ } catch (IllegalAccessException e) {
+ e.printStackTrace();
+ }
+
+ }
+ sb.append("}\r\n");
+ return sb.toString();
+ }
+
+ public static byte[] export(PageInfo pageInfo) throws Exception {
+ List list = pageInfo.getList();
+ List fields = new ArrayList();
+ if (list.size() > 0) {
+ //创建工作薄对象
+ HSSFWorkbook workbook = new HSSFWorkbook();//这里也可以设置sheet的Name
+ //创建工作表对象
+ HSSFSheet sheet = workbook.createSheet();
+
+ Object obj = list.get(0);
+ Class> cls = obj.getClass();
+ while (cls != null) {
+ Field[] fields1 = cls.getDeclaredFields();
+
+ for (Field field : fields1) {
+ ApiModelProperty apiOperation = field.getAnnotation(ApiModelProperty.class);
+ if (apiOperation != null) {
+ field.setAccessible(true);
+ fields.add(field);
+ }
+ }
+ cls=cls.getSuperclass();
+ }
+ HSSFRow row = sheet.createRow(0);//设置第一行,从零开始
+ for (int i = 0; i < fields.size(); i++) {
+ row.createCell(i).setCellValue(fields.get(i).getAnnotation(ApiModelProperty.class).value());
+ }
+ for (int k = 0; k < list.size(); k++) {
+ row = sheet.createRow(k + 1);
+ Object obj1 = list.get(k);
+ for (int i = 0; i < fields.size(); i++) {
+ if (fields.get(i).get(obj1) != null) {
+ row.createCell(i).setCellValue(fields.get(i).get(obj1).toString());
+ }
+ }
+ }
+ ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
+ workbook.write(outputStream);
+ byte[] byt = outputStream.toByteArray();
+ outputStream.close();
+ workbook.close();
+ return byt;
+ }
+ return new byte[0];
+
+ }
+
+
+}
diff --git a/backend/src/main/java/com/universe/utils/Handler.java b/backend/src/main/java/com/universe/utils/Handler.java
new file mode 100644
index 0000000..a7287da
--- /dev/null
+++ b/backend/src/main/java/com/universe/utils/Handler.java
@@ -0,0 +1,70 @@
+package com.universe.utils;
+
+import com.alibaba.fastjson.JSONObject;
+import lombok.extern.slf4j.Slf4j;
+
+import java.io.BufferedReader;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.net.HttpURLConnection;
+import java.net.URL;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.Map;
+
+/**
+ * 常用工具类
+ * @author yuanjs
+ * @description:
+ * @date 2020-01-10 22:41
+ */
+@Slf4j
+public class Handler {
+ public static String getDateTime(){
+ Date date = new Date();
+ SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+ return sf.format(date);
+ }
+ public static String getDate(){
+ Date date = new Date();
+ SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd");
+ return sf.format(date);
+ }
+ public static Map httpRequest(String req_url) {
+ StringBuffer buffer = new StringBuffer();
+ try {
+ URL url = new URL(req_url);
+ HttpURLConnection httpUrlConn = (HttpURLConnection) url.openConnection();
+
+ httpUrlConn.setDoOutput(false);
+ httpUrlConn.setDoInput(true);
+ httpUrlConn.setUseCaches(false);
+
+ httpUrlConn.setRequestMethod("GET");
+ httpUrlConn.connect();
+
+ // 将返回的输入流转换成字符串
+ InputStream inputStream = httpUrlConn.getInputStream();
+ InputStreamReader inputStreamReader = new InputStreamReader(inputStream, "utf-8");
+ BufferedReader bufferedReader = new BufferedReader(inputStreamReader);
+
+ String str = null;
+ while ((str = bufferedReader.readLine()) != null) {
+ buffer.append(str);
+ }
+ bufferedReader.close();
+ inputStreamReader.close();
+ // 释放资源
+ inputStream.close();
+ inputStream = null;
+ httpUrlConn.disconnect();
+
+ } catch (Exception e) {
+ log.error(e.getStackTrace().toString());
+ }
+ String r=buffer.toString();
+ log.debug("打印微信服务器返回json对象:"+r);
+ JSONObject jb = JSONObject.parseObject(r);
+ return (Map)jb;
+ }
+}
diff --git a/backend/src/main/java/com/universe/utils/HttpUtil.java b/backend/src/main/java/com/universe/utils/HttpUtil.java
new file mode 100644
index 0000000..c067891
--- /dev/null
+++ b/backend/src/main/java/com/universe/utils/HttpUtil.java
@@ -0,0 +1,53 @@
+package com.universe.utils;
+
+import org.springframework.http.*;
+import org.springframework.util.MultiValueMap;
+import org.springframework.web.client.RestTemplate;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * @author yuanjs
+ * @version 1.0.0
+ * @ClassName HttpUtil
+ * @Description TODO
+ * @createTime 2021年04月29日 07:55:00
+ */
+public class HttpUtil {
+ /**
+ * 向目的URL发送post请求
+ * @param url 目的url
+ * @param params 发送的参数
+ * @return ResultVO
+ */
+ public static ResultVO sendPostRequest(String url, HashMap params){
+ RestTemplate client = new RestTemplate();
+ HttpHeaders headers = new HttpHeaders();
+ HttpMethod method = HttpMethod.POST;
+ // 以表单的方式提交
+ headers.setContentType(MediaType.APPLICATION_JSON);
+ //将请求头部和参数合成一个请求
+ HttpEntity> requestEntity = new HttpEntity<>(params, headers);
+ //执行HTTP请求,将返回的结构使用ResultVO类格式化
+ ResponseEntity response = client.exchange(url, method, requestEntity, ResultVO.class);
+
+ return response.getBody();
+ }
+
+ public static Map cookieToMap(String value) {
+ Map map = new HashMap();
+ value = value.replace(" ", "");
+ if (value.contains(";")) {
+ String values[] = value.split(";");
+ for (String val : values) {
+ String vals[] = val.split("=");
+ map.put(vals[0], vals[1]);
+ }
+ } else {
+ String values[] = value.split("=");
+ map.put(values[0], values[1]);
+ }
+ return map;
+ }
+}
diff --git a/backend/src/main/java/com/universe/utils/Md5Util.java b/backend/src/main/java/com/universe/utils/Md5Util.java
new file mode 100644
index 0000000..446e079
--- /dev/null
+++ b/backend/src/main/java/com/universe/utils/Md5Util.java
@@ -0,0 +1,24 @@
+package com.universe.utils;
+
+import org.apache.shiro.crypto.hash.Md5Hash;
+
+/**
+ * @author zhuxiaomeng
+ * @date 2017/12/7.
+ * @email lenospmiller@gmail.com
+ * 采用md5加密 确保数据安全性
+ */
+public class Md5Util {
+ public static String getMD5(String msg,String salt){
+ return new Md5Hash(msg,salt,4).toString();
+ }
+
+ /**
+ * 测试
+ * @param args
+ */
+ public static void main(String[] args) {
+ String str= getMD5("111111","manager");
+ System.out.println(str);
+ }
+}
diff --git a/backend/src/main/java/com/universe/utils/ResultVO.java b/backend/src/main/java/com/universe/utils/ResultVO.java
new file mode 100644
index 0000000..417d20d
--- /dev/null
+++ b/backend/src/main/java/com/universe/utils/ResultVO.java
@@ -0,0 +1,36 @@
+package com.universe.utils;
+
+import lombok.Data;
+
+/**
+ * @author yuanjs
+ * @version 1.0.0
+ * @ClassName ResultVO
+ * @Description TODO
+ * @createTime 2021年04月29日 07:56:00
+ */
+@Data
+public class ResultVO {
+
+ private Integer code;
+
+ private String message;
+
+ private T data;
+
+ public ResultVO() {
+ }
+
+ public ResultVO(Integer code, String message) {
+ this.code = code;
+ this.message = message;
+ }
+
+ public ResultVO(Integer code, String message, T data) {
+ this.code = code;
+ this.message = message;
+ this.data = data;
+ }
+
+
+}
\ No newline at end of file
diff --git a/backend/src/main/java/com/universe/utils/UUIDUtils.java b/backend/src/main/java/com/universe/utils/UUIDUtils.java
new file mode 100644
index 0000000..15fb7f0
--- /dev/null
+++ b/backend/src/main/java/com/universe/utils/UUIDUtils.java
@@ -0,0 +1,14 @@
+package com.universe.utils;
+
+import java.util.UUID;
+
+/**
+ * @author yuanjs
+ * @description:
+ * @date 2020-08-01 18:05
+ */
+public class UUIDUtils {
+ public static String generateId() {
+ return UUID.randomUUID().toString().replace("-","");
+ }
+}
diff --git a/backend/src/main/java/com/universe/utils/UuidUtil.java b/backend/src/main/java/com/universe/utils/UuidUtil.java
new file mode 100644
index 0000000..fa6154f
--- /dev/null
+++ b/backend/src/main/java/com/universe/utils/UuidUtil.java
@@ -0,0 +1,14 @@
+package com.universe.utils;
+
+import java.util.UUID;
+
+/**
+ * @author zxm
+ * @date 2019-11-15.
+ */
+public class UuidUtil {
+
+ public static String getUuid() {
+ return UUID.randomUUID().toString().replace("-", "").toLowerCase();
+ }
+}
diff --git a/backend/src/main/resources/WIeFb1sm1s.txt b/backend/src/main/resources/WIeFb1sm1s.txt
new file mode 100644
index 0000000..4f3e234
--- /dev/null
+++ b/backend/src/main/resources/WIeFb1sm1s.txt
@@ -0,0 +1 @@
+1004568cc30d6d90534f8b516015ee42
\ No newline at end of file
diff --git a/backend/src/main/resources/application-dev.yml b/backend/src/main/resources/application-dev.yml
new file mode 100644
index 0000000..347695f
--- /dev/null
+++ b/backend/src/main/resources/application-dev.yml
@@ -0,0 +1,36 @@
+server:
+ port: 8080
+
+#showSql
+logging:
+ level:
+ com.universe : debug
+spring:
+ datasource:
+ username: team5
+ password: iop890
+ url: jdbc:postgresql://www.victorysoft.online:5432/team5?currentSchema=public&useUnicode=true&characterEncoding=utf8
+ driver-class-name: org.postgresql.Driver
+ redis:
+ host: 110.40.152.26
+ port: 6379
+ password: c.h.2000.1125
+
+ main:
+ allow-bean-definition-overriding: true
+
+pagehelper:
+ helperDialect: postgresql
+ reasonable: true
+ supportMethodsArguments: true
+ params: count=countSql
+
+#mybatis-plus
+mybatis-plus:
+ mapper-locations: classpath:mapping/*.xml
+ configuration:
+ log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
+ map-underscore-to-camel-case: true
+
+
+
diff --git a/backend/src/main/resources/application.yml b/backend/src/main/resources/application.yml
new file mode 100644
index 0000000..76bdfdf
--- /dev/null
+++ b/backend/src/main/resources/application.yml
@@ -0,0 +1,8 @@
+spring:
+ servlet:
+ multipart:
+ max-file-size: 20MB
+ profiles:
+ active: dev
+
+
diff --git a/backend/src/main/resources/logback-spring.xml b/backend/src/main/resources/logback-spring.xml
new file mode 100644
index 0000000..377f310
--- /dev/null
+++ b/backend/src/main/resources/logback-spring.xml
@@ -0,0 +1,70 @@
+
+
+
+
+
+ %d{yyyy-MM-dd HH:mm:ss.SSS} [ %thread ] - [ %-5level ] [ %logger{50} : %line ] - %msg%n
+
+
+
+
+ DEBUG
+ ACCEPT
+ DENY
+
+ true
+
+ %d{yyyy-MM-dd HH:mm:ss.SSS} [ %thread ] - [ %-5level ] [ %logger{50} : %line ] - %msg%n
+
+
+ ${LOG_HOME}/debug.%d.log
+
+
+
+
+ INFO
+ ACCEPT
+ DENY
+
+ true
+
+ %d{yyyy-MM-dd HH:mm:ss.SSS} [ %thread ] - [ %-5level ] [ %logger{50} : %line ] - %msg%n
+
+
+ ${LOG_HOME}/info.%d.log
+
+
+
+
+ WARN
+ ACCEPT
+ DENY
+
+ true
+
+ %d{yyyy-MM-dd HH:mm:ss.SSS} [ %thread ] - [ %-5level ] [ %logger{50} : %line ] - %msg%n
+
+
+ ${LOG_HOME}/warn.%d.log
+
+
+
+
+ ERROR
+
+ true
+
+ %d{yyyy-MM-dd HH:mm:ss.SSS} [ %thread ] - [ %-5level ] [ %logger{50} : %line ] - %msg%n
+
+
+ ${LOG_HOME}/error.%d.log
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/backend/src/main/resources/mapping/ProductMapping.xml b/backend/src/main/resources/mapping/ProductMapping.xml
new file mode 100644
index 0000000..c3d05cb
--- /dev/null
+++ b/backend/src/main/resources/mapping/ProductMapping.xml
@@ -0,0 +1,35 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/backend/src/main/resources/mapping/ProductStoreMapping.xml b/backend/src/main/resources/mapping/ProductStoreMapping.xml
new file mode 100644
index 0000000..0c4495f
--- /dev/null
+++ b/backend/src/main/resources/mapping/ProductStoreMapping.xml
@@ -0,0 +1,45 @@
+
+
+
+
+
+
+
+
+
+
+ update product_store
+ set total=#{count}
+ where product_store.product_id =#{pId}
+
+
+
\ No newline at end of file
diff --git a/backend/src/main/resources/mapping/PurchaseMapping.xml b/backend/src/main/resources/mapping/PurchaseMapping.xml
new file mode 100644
index 0000000..a697008
--- /dev/null
+++ b/backend/src/main/resources/mapping/PurchaseMapping.xml
@@ -0,0 +1,36 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/backend/src/main/resources/mapping/PurchaseSonMapping.xml b/backend/src/main/resources/mapping/PurchaseSonMapping.xml
new file mode 100644
index 0000000..907ad1d
--- /dev/null
+++ b/backend/src/main/resources/mapping/PurchaseSonMapping.xml
@@ -0,0 +1,10 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/backend/src/main/resources/mapping/PurchaseSwapMaping.xml b/backend/src/main/resources/mapping/PurchaseSwapMaping.xml
new file mode 100644
index 0000000..acc71a3
--- /dev/null
+++ b/backend/src/main/resources/mapping/PurchaseSwapMaping.xml
@@ -0,0 +1,37 @@
+
+
+
+
+ insert into purchase_swap(purchase_id,id) values
+
+ ('${purchaseId}', '${id}')
+
+
+
+
+
\ No newline at end of file
diff --git a/frontend/.eslintrc.js b/frontend/.eslintrc.js
new file mode 100644
index 0000000..a1b7974
--- /dev/null
+++ b/frontend/.eslintrc.js
@@ -0,0 +1,441 @@
+module.exports = {
+ root: true,
+ env: {
+ node: true,
+ es6: true,
+ browser: true,
+ },
+ extends: [
+ 'plugin:vue/essential',
+ 'eslint:recommended',
+ /*'@vue/prettier ',*/
+ '@vue/airbnb',
+ ],
+ /*plusins:[
+ 'vue'
+ ],*/
+ rules: {
+ //"off"或者0 关闭规则关闭
+ //"warn"或者1 在打开的规则作为警告(不影响退出代码)
+ //"error"或者2 把规则作为一个错误(退出代码触发时为1)
+ 'no-console': process.env.NODE_ENV === 'production' ? 'error' : 'off',
+ 'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off',
+ "linebreak-style": [0,"error", "windows"],
+ "prettier/prettier": [
+ "error",
+ {
+ // tab缩进大小,默认为2
+ "tabWidth": 4,
+ // 使用tab缩进,默认false
+ "useTabs": true,
+ // 使用分号, 默认true
+ "semi": true,
+ // 使用单引号, 默认false(在jsx中配置无效, 默认都是双引号)
+ "singleQuote": false,
+ // 行尾逗号,默认none,可选 none|es5|all
+ // es5 包括es5中的数组、对象
+ // all 包括函数对象等所有可选
+ "trailingComma": 'none',
+ // 对象中的空格 默认true
+ // true: { foo: bar }
+ // false: {foo: bar}
+ "bracketSpacing": true,
+ // JSX标签闭合位置 默认false
+ // false:
+ // true:
+ "jsxBracketSameLine": false,
+ // 箭头函数参数括号 默认avoid 可选 avoid| always
+ // avoid 能省略括号的时候就省略 例如x => x
+ // always 总是有括号
+ "arrowParens": 'always'
+ }
+ ],
+ "no-alert": 0, //禁止使用alert confirm prompt
+ "no-array-constructor": 2, //禁止使用数组构造器
+ "no-bitwise": 0, //禁止使用按位运算符
+ "no-caller": 1, //禁止使用arguments.caller或arguments.callee
+ "no-catch-shadow": 2, //禁止catch子句参数与外部作用域变量同名
+ "no-class-assign": 2, //禁止给类赋值
+ "no-cond-assign": 2, //禁止在条件表达式中使用赋值语句
+ "no-const-assign": 2, //禁止修改const声明的变量
+ "no-constant-condition": 2, //禁止在条件中使用常量表达式 if(true) if(1)
+ "no-continue": 0, //禁止使用continue
+ "no-control-regex": 2, //禁止在正则表达式中使用控制字符
+ "no-delete-var": 2, //不能对var声明的变量使用delete操作符
+ "no-div-regex": 1, //不能使用看起来像除法的正则表达式/=foo/
+ "no-dupe-keys": 2, //在创建对象字面量时不允许键重复 {a:1,a:1}
+ "no-dupe-args": 2, //函数参数不能重复
+ "no-duplicate-case": 2, //switch中的case标签不能重复
+ "no-else-return": 2, //如果if语句里面有return,后面不能跟else语句
+ "no-empty": 2, //块语句中的内容不能为空
+ "no-empty-character-class": 2, //正则表达式中的[]内容不能为空
+ "no-empty-label": 0, //禁止使用空label
+ "no-eq-null": 2, //禁止对null使用==或!=运算符
+ "no-eval": 1, //禁止使用eval
+ "no-ex-assign": 2, //禁止给catch语句中的异常参数赋值
+ "no-extend-native": 2, //禁止扩展native对象
+ "no-extra-bind": 2, //禁止不必要的函数绑定
+ "no-extra-boolean-cast": 2, //禁止不必要的bool转换
+ "no-extra-parens": 2, //禁止非必要的括号
+ "no-extra-semi": 2, //禁止多余的冒号
+ "no-fallthrough": 1, //禁止switch穿透
+ "no-floating-decimal": 2, //禁止省略浮点数中的0 .5 3.
+ "no-func-assign": 2, //禁止重复的函数声明
+ "no-implicit-coercion": 1, //禁止隐式转换
+ "no-implied-eval": 2, //禁止使用隐式eval
+ "no-inline-comments": 0, //禁止行内备注
+ "no-inner-declarations": [2, "functions"], //禁止在块语句中使用声明(变量或函数)
+ "no-invalid-regexp": 2, //禁止无效的正则表达式
+ "no-invalid-this": 2, //禁止无效的this,只能用在构造器,类,对象字面量
+ "no-irregular-whitespace": 2, //不能有不规则的空格
+ "no-iterator": 2, //禁止使用__iterator__ 属性
+ "no-label-var": 2, //label名不能与var声明的变量名相同
+ "no-labels": 2, //禁止标签声明
+ "no-lone-blocks": 2, //禁止不必要的嵌套块
+ "no-lonely-if": 2, //禁止else语句内只有if语句
+ "no-loop-func": 1, //禁止在循环中使用函数(如果没有引用外部变量不形成闭包就可以)
+ "no-mixed-requires": [0, false], //声明时不能混用声明类型
+ "no-mixed-spaces-and-tabs": [2, true], //禁止混用tab和空格
+ "no-multi-spaces": 1, //不能用多余的空格
+ "no-multi-str": 2, //字符串不能用\换行
+ "no-multiple-empty-lines": [1, {
+ "max": 2
+ }], //空行最多不能超过2行
+ "no-native-reassign": 2, //不能重写native对象
+ "no-negated-in-lhs": 2, //in 操作符的左边不能有!
+ "no-nested-ternary": 0, //禁止使用嵌套的三目运算
+ "no-new": 1, //禁止在使用new构造一个实例后不赋值
+ "no-new-func": 1, //禁止使用new Function
+ "no-new-object": 2, //禁止使用new Object()
+ "no-new-require": 2, //禁止使用new require
+ "no-new-wrappers": 2, //禁止使用new创建包装实例,new String new Boolean new Number
+ "no-obj-calls": 2, //不能调用内置的全局对象,比如Math() JSON()
+ "no-octal": 2, //禁止使用八进制数字
+ "no-octal-escape": 2, //禁止使用八进制转义序列
+ "no-param-reassign": 2, //禁止给参数重新赋值
+ "no-path-concat": 0, //node中不能使用__dirname或__filename做路径拼接
+ "no-plusplus": 0, //禁止使用++,--
+ "no-process-env": 0, //禁止使用process.env
+ "no-process-exit": 0, //禁止使用process.exit()
+ "no-proto": 2, //禁止使用__proto__属性
+ "no-redeclare": 2, //禁止重复声明变量
+ "no-regex-spaces": 2, //禁止在正则表达式字面量中使用多个空格 /foo bar/
+ "no-restricted-modules": 0, //如果禁用了指定模块,使用就会报错
+ "no-return-assign": 1, //return 语句中不能有赋值表达式
+ "no-script-url": 0, //禁止使用javascript:void(0)
+ "no-self-compare": 2, //不能比较自身
+ "no-sequences": 0, //禁止使用逗号运算符
+ "no-shadow": 2, //外部作用域中的变量不能与它所包含的作用域中的变量或参数同名
+ "no-shadow-restricted-names": 2, //严格模式中规定的限制标识符不能作为声明时的变量名使用
+ "no-spaced-func": 2, //函数调用时 函数名与()之间不能有空格
+ "no-sparse-arrays": 2, //禁止稀疏数组, [1,,2]
+ "no-sync": 0, //nodejs 禁止同步方法
+ "no-ternary": 0, //禁止使用三目运算符
+ "no-trailing-spaces": 1, //一行结束后面不要有空格
+ "no-this-before-super": 0, //在调用super()之前不能使用this或super
+ "no-throw-literal": 2, //禁止抛出字面量错误 throw "error";
+ "no-undef": 1, //不能有未定义的变量
+ "no-undef-init": 2, //变量初始化时不能直接给它赋值为undefined
+ "no-undefined": 2, //不能使用undefined
+ "no-unexpected-multiline": 2, //避免多行表达式
+ "no-underscore-dangle": 1, //标识符不能以_开头或结尾
+ "no-unneeded-ternary": 2, //禁止不必要的嵌套 var isYes = answer === 1 ? true : false;
+ "no-unreachable": 2, //不能有无法执行的代码
+ "no-unused-expressions": 2, //禁止无用的表达式
+ "no-unused-vars": [2, {
+ "vars": "all",
+ "args": "after-used"
+ }], //不能有声明后未被使用的变量或参数
+ "no-use-before-define": 2, //未定义前不能使用
+ "no-useless-call": 2, //禁止不必要的call和apply
+ "no-void": 2, //禁用void操作符
+ "no-var": 0, //禁用var,用let和const代替
+ "no-warning-comments": [1, {
+ "terms": ["todo", "fixme", "xxx"],
+ "location": "start"
+ }], //不能有警告备注
+ "no-with": 2, //禁用with
+
+ "array-bracket-spacing": [2, "never"], //是否允许非空数组里面有多余的空格
+ "arrow-parens": 0, //箭头函数用小括号括起来
+ "arrow-spacing": 0, //=>的前/后括号
+ "accessor-pairs": 0, //在对象中使用getter/setter
+ "block-scoped-var": 0, // 在块级作用域外访问块内定义的变量是否报错提示
+ "brace-style": [2, '1tbs', {'allowSingleLine': true}], //if while function 后面的{必须与if在同一行,java风格。
+ "callback-return": 1, //避免多次调用回调什么的
+ "camelcase": 2, //强制驼峰法命名
+ "comma-dangle": [2, "always"], // 数组和对象键值对最后一个逗号, never参数:不能带末尾的逗号, always参数:必须带末尾的逗号,
+ "comma-spacing": 0, //逗号前后的空格
+ "comma-style": [2, "last"], //逗号风格,换行时在行首还是行尾
+ "complexity": [0, 11], //循环复杂度
+ "computed-property-spacing": [0, "never"], //是否允许计算后的键名什么的
+ "consistent-return": 0, //return 后面是否允许省略
+ "consistent-this": [2, "that"], //this别名
+ "constructor-super": 0, //非派生类不能调用super,派生类必须调用super
+ "curly": [2, "all"], //必须使用 if(){} 中的{}
+ "default-case": 0, //switch语句最后必须有default
+ "dot-location": 0, //对象访问符的位置,换行的时候在行首还是行尾
+ "dot-notation": [0, {
+ "allowKeywords": true
+ }], //避免不必要的方括号
+ "eol-last": 0, //文件以单一的换行符结束
+ "eqeqeq": 2, //必须使用全等
+ "func-names": 0, //函数表达式必须有名字
+ "func-style": [0, "declaration"], //函数风格,规定只能使用函数声明/函数表达式
+ "generator-star-spacing": 0, //生成器函数*的前后空格
+ "guard-for-in": 0, //for in循环要用if语句过滤
+ "handle-callback-err": 0, //nodejs 处理错误
+ "id-length": 0, //变量名长度
+ "indent": ['error', 2, {'SwitchCase': 1}], //缩进风格
+ "init-declarations": 0, //声明时必须赋初值
+ "key-spacing": [0, {
+ "beforeColon": false,
+ "afterColon": true
+ }], //对象字面量中冒号的前后空格
+ "lines-around-comment": 0, //行前/行后备注
+ "max-depth": [0, 4], //嵌套块深度
+ "max-len": ["error", {code : 300}] , //字符串最大长度
+ "max-nested-callbacks": [0, 2], //回调嵌套深度
+ "max-params": [0, 3], //函数最多只能有3个参数
+ "max-statements": [0, 10], //函数内最多有几个声明
+ "new-cap": 2, //函数名首行大写必须使用new方式调用,首行小写必须用不带new方式调用
+ "new-parens": 2, //new时必须加小括号
+ "newline-after-var": 2, //变量声明后是否需要空一行
+ "object-curly-spacing": [0, "never"], //大括号内是否允许不必要的空格
+ "object-shorthand": 0, //强制对象字面量缩写语法
+ "one-var": 0, //连续声明
+ "operator-assignment": [0, "always"], //赋值运算符 += -=什么的
+ "operator-linebreak": [2, "after"], //换行时运算符在行尾还是行首
+ "padded-blocks": 0, //块语句内行首行尾是否要空行
+ "prefer-const": 0, //首选const
+ "prefer-spread": 0, //首选展开运算
+ "prefer-reflect": 0, //首选Reflect的方法
+ "quotes": [1, "double"], //引号类型 `` "double" 'single'
+ "quote-props": [0, "always"], //对象字面量中的属性名是否强制双引号
+ "radix": 2, //parseInt必须指定第二个参数
+ "id-match": 0, //命名检测
+ "require-yield": 0, //生成器函数必须有yield
+ "semi": [0, "always"], //语句强制分号结尾
+ "semi-spacing": [0, {
+ "before": false,
+ "after": true
+ }], //分号前后空格
+ "sort-vars": 0, //变量声明时排序
+ "space-after-keywords": [0, "always"], //关键字后面是否要空一格
+ "space-before-blocks": [0, "always"], //不以新行开始的块{前面要不要有空格
+ "space-before-function-paren": [0, "always"], //函数定义时括号前面要不要有空格
+ "space-in-parens": [0, "never"], //小括号里面要不要有空格
+ "space-infix-ops": 0, //中缀操作符周围要不要有空格
+ "space-return-throw-case": 0, //return throw case后面要不要加空格
+ "space-unary-ops": [0, {
+ "words": true,
+ "nonwords": false
+ }], //一元运算符的前/后要不要加空格
+ "spaced-comment": 0, //注释风格要不要有空格什么的
+ "strict": 2, //使用严格模式
+ "use-isnan": 2, //禁止比较时使用NaN,只能用isNaN()
+ "valid-jsdoc": 0, //jsdoc规则
+ "valid-typeof": 2, //必须使用合法的typeof的值
+ "vars-on-top": 2, //var必须放在作用域顶部
+ "wrap-iife": [2, "inside"], //立即执行函数表达式的小括号风格
+ "wrap-regex": 0, //正则表达式字面量用小括号包起来
+ "yoda": [2, "never"], //禁止尤达条件
+
+
+ /* for vue */
+
+ // 禁止重复的二级键名
+
+ // @off 没必要限制
+
+ 'vue/no-dupe-keys': 'off',
+
+ // 禁止出现语法错误
+
+ 'vue/no-parsing-error': 'error',
+
+ // 禁止覆盖保留字
+
+ 'vue/no-reservered-keys': 'error',
+
+ // 组件的 data 属性的值必须是一个函数
+
+ 'vue/no-shared-component-data': 'off',
+
+ // 禁止
使用 key 属性
+
+ 'vue/no-template-key': 'off',
+
+ // render 函数必须有返回值
+
+ 'vue/require-render-return': 'error',
+
+ // prop 的默认值必须匹配它的类型
+
+ 'vue/require-valid-default-prop': 'off',
+
+ // 计算属性必须有返回值
+
+ 'vue/return-in-computed-property': 'error',
+
+ // template 的根节点必须合法
+
+ 'vue/valid-template-root': 'error',
+
+ // v-bind 指令必须合法
+
+ 'vue/valid-v-bind': 'error',
+
+ // v-cloak 指令必须合法
+
+ 'vue/valid-v-cloak': 'error',
+
+ // v-else-if 指令必须合法
+
+ 'vue/valid-v-else-if': 'error',
+
+ // v-else 指令必须合法
+
+ 'vue/valid-v-else': 'error',
+
+ // v-for 指令必须合法
+
+ 'vue/valid-v-for': 'error',
+
+ // v-html 指令必须合法
+
+ 'vue/valid-v-html': 'error',
+
+ // v-if 指令必须合法
+
+ 'vue/valid-v-if': 'error',
+
+ // v-model 指令必须合法
+
+ 'vue/valid-v-model': 'error',
+
+ // v-on 指令必须合法
+
+ 'vue/valid-v-on': 'error',
+
+ // v-once 指令必须合法
+
+ 'vue/valid-v-once': 'error',
+
+ // v-pre 指令必须合法
+
+ 'vue/valid-v-pre': 'error',
+
+ // v-show 指令必须合法
+
+ 'vue/valid-v-show': 'error',
+
+ // v-text 指令必须合法
+
+ 'vue/valid-v-text': 'error',
+
+ //
+ // 最佳实践
+ //
+ // @fixable html 的结束标签必须符合规定
+ // @off 有的标签不必严格符合规定,如
或
都应该是合法的
+
+ 'vue/html-end-tags': 'off',
+
+ // 计算属性禁止包含异步方法
+
+ 'vue/no-async-in-computed-properties': 'error',
+
+ // 禁止出现难以理解的 v-if 和 v-for
+
+ 'vue/no-confusing-v-for-v-if': 'error',
+
+ // 禁止出现重复的属性
+
+ 'vue/no-duplicate-attributes': 'error',
+
+ // 禁止在计算属性中对属性修改
+
+ 'vue/no-side-effects-in-computed-properties': 'off',
+
+ // 禁止在