Commit 95285c62 authored by 一日看尽长安花's avatar 一日看尽长安花 Committed by trumansdo
Browse files

这是vue版的重构开发分支。

预计工作计划如下:
1、完成路由表
2、重构动态的搜索框组件
3、剩下就是各个接口的重写。
parent 2731ce86
admin-core/target/* */target/*
admin-console/target/*
.*
!.gitignore !.gitignore
*.iml *.iml
\ No newline at end of file .idea
\ No newline at end of file
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
<dependency> <dependency>
<groupId>mysql</groupId> <groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId> <artifactId>mysql-connector-java</artifactId>
<version>6.0.5</version> <version>8.0.17</version>
</dependency> </dependency>
</dependencies> </dependencies>
......
...@@ -8,18 +8,16 @@ import org.springframework.cache.annotation.EnableCaching; ...@@ -8,18 +8,16 @@ import org.springframework.cache.annotation.EnableCaching;
@SpringBootApplication @SpringBootApplication
@EnableCaching @EnableCaching
public class CosonleApplication extends SpringBootServletInitializer { public class CosonleApplication extends SpringBootServletInitializer {
@Override @Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) { protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(CosonleApplication.class); return application.sources(CosonleApplication.class);
} }
public static void main(String[] args) { public static void main(String[] args) {
SpringApplication.run(CosonleApplication.class, args); SpringApplication.run(CosonleApplication.class, args);
} }
}
\ No newline at end of file
}
\ No newline at end of file
app.name=SpringBoot-Plus
# 1\uFF0C1 \u662F\u7BA1\u7406\u5458\u5BC6\u7801\uFF0C\u76F8\u5F53\u4E8E\u542F\u52A8\u540E\u5C31\u767B\u5F55\uFF0C\u65B9\u4FBF\u6D4B\u8BD5\uFF0C\u7CFB\u7EDF\u9700\u8981\u53D6\u6D88\u8FD9\u4FE9\u4E2A\u914D\u7F6E
user.id=1
user.orgId=1
#\u6253\u5F00\u5BA1\u8BA1\u529F\u80FD\uFF0C\u5F00\u53D1\u6A21\u5F0F\u5E94\u8BE5\u5173\u95ED
audit.enable=false
server.port=8080
spring.datasource.baseDataSource.url=jdbc:mysql://127.0.0.1:3306/starter?useUnicode=true&characterEncoding=UTF-8&serverTimezone=GMT%2B8&useSSL=false&useInformationSchema=true spring.datasource.baseDataSource.url=jdbc:mysql://127.0.0.1:3306/starter?useUnicode=true&characterEncoding=UTF-8&serverTimezone=GMT%2B8&useSSL=false&useInformationSchema=true
spring.datasource.baseDataSource.username=root spring.datasource.baseDataSource.username=root
spring.datasource.baseDataSource.password=123456 spring.datasource.baseDataSource.password=123456
spring.datasource.baseDataSource.driver-class-name=com.mysql.cj.jdbc.Driver spring.datasource.baseDataSource.driver-class-name=com.mysql.cj.jdbc.Driver
#html\u89C6\u56FE\u4EA4\u7ED9beetl\u6E32\u67D3
beetl.suffix=html
beetlsql.ds.baseDataSource.basePackage=com beetlsql.ds.baseDataSource.basePackage=com
beetlsql.ds.baseDataSource.dbStyle=org.beetl.sql.core.db.MySqlStyle beetlsql.ds.baseDataSource.dbStyle=org.beetl.sql.core.db.MySqlStyle
#beetlsql.basePackage=com.ibeetl,com.xxx.yourpackage #beetlsql.basePackage=com.ibeetl,com.xxx.yourpackage
#有一个数据源命名为baseDataSource,你可以添加多数据源 #\u6709\u4E00\u4E2A\u6570\u636E\u6E90\u547D\u540D\u4E3AbaseDataSource,\u4F60\u53EF\u4EE5\u6DFB\u52A0\u591A\u6570\u636E\u6E90
beetlsql.mutiple.datasource=baseDataSource beetlsql.mutiple.datasource=baseDataSource
# 1,1 是管理员密码,相当于启动后就登录,方便测试,系统需要取消这俩个配置 #\u5355\u673A\u60C5\u51B5\u4E0B\u4F7F\u7528hashmap\u5B58\u653E\u56DE\u8BDD\uFF0C\u96C6\u7FA4\u4E0B\u53EF\u4EE5\u53C2\u8003springboot \u4F7F\u7528redis
user.id=1 spring.session.store-type=none
user.orgId=1
#打开审计功能,开发模式应该关闭
audit.enable=false
#单机情况下使用hashmap存放回话,集群下可以参考springboot 使用redis
spring.session.store-type=HASH_MAP
#spring.cache.type= #spring.cache.type=
spring.cache.type=simple spring.cache.type=simple
logging.level.root=info logging.level.root=info
logging.level.org.springframework.web.servlet.mvc.method.annotation=warn logging.level.org.springframework.web.servlet.mvc.method.annotation=warn
#logging.file = my.log #logging.file = my.log
server.port=8080
#html视图交给beetl渲染
beetl.suffix=html
app.name=SpringBoot-Plus
logging.pattern.console=%-4relative [%thread] %-5level %logger{256} %M %L - %msg%n logging.pattern.console=%-4relative [%thread] %-5level %logger{256} %M %L - %msg%n
#文档预览服务的调用地址,参考https://gitee.com/kekingcn/file-online-preview 安装,没有如下配置无法使用预览功能 #\u65E5\u5FD7\u6392\u9664 autoconfiguration \u8F93\u51FA
file.previewURL=http://localhost:8012/onlinePreview logging.level.org.springframework.boot.autoconfigure: ERROR
#\u6587\u6863\u9884\u89C8\u670D\u52A1\u7684\u8C03\u7528\u5730\u5740\uFF0C\u53C2\u8003https://gitee.com/kekingcn/file-online-preview \u5B89\u88C5\uFF0C\u6CA1\u6709\u5982\u4E0B\u914D\u7F6E\u65E0\u6CD5\u4F7F\u7528\u9884\u89C8\u529F\u80FD
file.previewURL=http://localhost:8012/onlinePreview
<?xml version="1.0" encoding="UTF-8"?>
<!-- Configuration后面的status,这个用于设置log4j2自身内部的信息输出,可以不设置,当设置成trace时,
你会看到log4j2内部各种详细输出。可以设置成OFF(关闭) 或 Error(只输出错误信息)。
30s 刷新此配置
-->
<configuration status="ERROR" monitorInterval="30">
<!-- 日志文件目录、压缩文件目录、日志格式配置 -->
<properties>
<Property name="fileName">/Users/admin/Code/log</Property>
<Property name="fileGz">/Users/admin/Code/log/7z</Property>
<Property name="PID">????</Property>
<Property name="LOG_PATTERN">%clr{%d{DEFAULT}}{blue} %clr{%5level} %clr{${sys:PID}}{magenta}
%clr{---}{faint} %clr{[%.15t]}{faint} %clr{%-40.40c{1.}}{cyan} %clr{信息:%m}{magenta} %clr{%l}{faint} %n%xwEx
</Property>
</properties>
<Appenders>
<!-- 输出控制台日志的配置 -->
<Console name="console" target="SYSTEM_OUT">
<!--控制台只输出level及以上级别的信息(onMatch),其他的直接拒绝(onMismatch)-->
<ThresholdFilter level="INFO" onMatch="ACCEPT" onMismatch="DENY"/>
<!-- 输出日志的格式 -->
<PatternLayout pattern="${LOG_PATTERN}"/>
</Console>
<!-- 打印出所有的信息,每次大小超过size,则这size大小的日志会自动存入按年份-月份建立的文件夹下面并进行压缩,作为存档 -->
<RollingRandomAccessFile name="infoFile" fileName="${fileName}/web-info.log" immediateFlush="false"
filePattern="${fileGz}/$${date:yyyy-MM}/%d{yyyy-MM-dd}-%i.web-info.gz">
<PatternLayout pattern="${LOG_PATTERN}"/>
<Policies>
<SizeBasedTriggeringPolicy size="20 MB"/>
</Policies>
<Filters>
<!-- 只记录info和warn级别信息 -->
<ThresholdFilter level="error" onMatch="DENY" onMismatch="NEUTRAL"/>
<ThresholdFilter level="info" onMatch="ACCEPT" onMismatch="DENY"/>
</Filters>
<!-- 指定每天的最大压缩包个数,默认7个,超过了会覆盖之前的 -->
<DefaultRolloverStrategy max="50"/>
</RollingRandomAccessFile>
<!-- 存储所有error信息 -->
<RollingRandomAccessFile name="errorFile" fileName="${fileName}/web-error.log" immediateFlush="false"
filePattern="${fileGz}/$${date:yyyy-MM}/%d{yyyy-MM-dd}-%i.web-error.gz">
<PatternLayout pattern="${LOG_PATTERN}"/>
<Policies>
<SizeBasedTriggeringPolicy size="50 MB"/>
</Policies>
<Filters>
<!-- 只记录error级别信息 -->
<ThresholdFilter level="error" onMatch="ACCEPT" onMismatch="DENY"/>
</Filters>
<!-- 指定每天的最大压缩包个数,默认7个,超过了会覆盖之前的 -->
<DefaultRolloverStrategy max="50"/>
</RollingRandomAccessFile>
</Appenders>
<!-- Mixed sync/async -->
<Loggers>
<!--<Root level="debug" includeLocation="true">-->
<!--<AppenderRef ref="console"/>-->
<!--<AppenderRef ref="infoFile"/>-->
<!--<AppenderRef ref="errorFile"/>-->
<!--</Root>-->
<AsyncRoot level="INFO" includeLocation="true">
<AppenderRef ref="console"/>
<!--<AppenderRef ref="infoFile"/>
<AppenderRef ref="errorFile"/>-->
</AsyncRoot>
</Loggers>
</configuration>
\ No newline at end of file
...@@ -11,6 +11,9 @@ ...@@ -11,6 +11,9 @@
</parent> </parent>
<properties> <properties>
<maven.test.skip>true</maven.test.skip> <maven.test.skip>true</maven.test.skip>
<druid.version>1.1.10</druid.version>
<lombok.version>1.18.2</lombok.version>
<disruptor.version>3.4.2</disruptor.version>
</properties> </properties>
<dependencies> <dependencies>
<dependency> <dependency>
...@@ -21,7 +24,6 @@ ...@@ -21,7 +24,6 @@
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId> <artifactId>spring-boot-starter-tomcat</artifactId>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId> <artifactId>spring-boot-starter-jdbc</artifactId>
...@@ -30,7 +32,6 @@ ...@@ -30,7 +32,6 @@
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-aop</artifactId> <artifactId>spring-boot-starter-aop</artifactId>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-cache</artifactId> <artifactId>spring-boot-starter-cache</artifactId>
...@@ -39,14 +40,32 @@ ...@@ -39,14 +40,32 @@
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId> <artifactId>spring-boot-starter-data-redis</artifactId>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.ibeetl</groupId> <groupId>com.ibeetl</groupId>
<artifactId>beetl-framework-starter</artifactId> <artifactId>beetl-framework-starter</artifactId>
<version>1.2.11.RELEASE</version> <version>1.2.13.RELEASE</version>
</dependency>
<!-- Log4j2 异步支持 -->
<dependency>
<groupId>com.lmax</groupId>
<artifactId>disruptor</artifactId>
<version>${disruptor.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.session</groupId>
<artifactId>spring-session-core</artifactId>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>${lombok.version}</version>
<optional>true</optional>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid-spring-boot-starter</artifactId>
<version>${druid.version}</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.zaxxer</groupId> <groupId>com.zaxxer</groupId>
<artifactId>HikariCP</artifactId> <artifactId>HikariCP</artifactId>
...@@ -55,7 +74,6 @@ ...@@ -55,7 +74,6 @@
<groupId>mysql</groupId> <groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId> <artifactId>mysql-connector-java</artifactId>
</dependency> </dependency>
<!-- <dependency> <!-- <dependency>
<groupId>com.oracle</groupId> <groupId>com.oracle</groupId>
<artifactId>ojdbc6</artifactId> <artifactId>ojdbc6</artifactId>
...@@ -66,11 +84,16 @@ ...@@ -66,11 +84,16 @@
<artifactId>jxls-reader</artifactId> <artifactId>jxls-reader</artifactId>
<version>2.0.3</version> <version>2.0.3</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.jxls</groupId> <groupId>org.jxls</groupId>
<artifactId>jxls</artifactId> <artifactId>jxls</artifactId>
<version>2.4.3</version> <version>2.4.3</version>
<exclusions>
<exclusion>
<artifactId>logback-core</artifactId>
<groupId>ch.qos.logback</groupId>
</exclusion>
</exclusions>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.jxls</groupId> <groupId>org.jxls</groupId>
...@@ -82,7 +105,6 @@ ...@@ -82,7 +105,6 @@
<artifactId>commons-lang3</artifactId> <artifactId>commons-lang3</artifactId>
<version>3.3.2</version> <version>3.3.2</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.apache.poi</groupId> <groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId> <artifactId>poi</artifactId>
...@@ -93,10 +115,5 @@ ...@@ -93,10 +115,5 @@
<artifactId>poi-ooxml</artifactId> <artifactId>poi-ooxml</artifactId>
<version>3.17</version> <version>3.17</version>
</dependency> </dependency>
</dependencies> </dependencies>
</project> </project>
...@@ -50,7 +50,7 @@ public class DBIndexHelper { ...@@ -50,7 +50,7 @@ public class DBIndexHelper {
public List<CoreFile> queryByUserId(Long userId,List<FileTag> tags){ public List<CoreFile> queryByUserId(Long userId,List<FileTag> tags){
List<CoreFile> dbDatas = fileDao.createQuery().lambda().andEq(CoreFile::getUserId, userId).select(); List<CoreFile> dbDatas = fileDao.createLambdaQuery().andEq(CoreFile::getUserId, userId).select();
return dbDatas; return dbDatas;
} }
...@@ -68,7 +68,5 @@ public class DBIndexHelper { ...@@ -68,7 +68,5 @@ public class DBIndexHelper {
List<CoreFile> dbDatas = fileDao.template(template); List<CoreFile> dbDatas = fileDao.template(template);
return dbDatas; return dbDatas;
} }
} }
# https://editorconfig.org
root = true
[*]
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
# just a flag
ENV = 'development'
# base api
VUE_APP_BASE_API = '/dev-api'
# vue-cli uses the VUE_CLI_BABEL_TRANSPILE_MODULES environment variable,
# to control whether the babel-plugin-dynamic-import-node plugin is enabled.
# It only does one thing by converting all import() to require().
# This configuration can significantly increase the speed of hot updates,
# when you have a large number of pages.
# Detail: https://github.com/vuejs/vue-cli/blob/dev/packages/@vue/babel-preset-app/index.js
VUE_CLI_BABEL_TRANSPILE_MODULES = true
# just a flag
ENV = 'production'
# base api
VUE_APP_BASE_API = '/prod-api'
NODE_ENV = production
# just a flag
ENV = 'staging'
# base api
VUE_APP_BASE_API = '/stage-api'
build/*.js
src/assets
public
dist
module.exports = {
root: true,
parserOptions: {
parser: 'babel-eslint',
sourceType: 'module'
},
env: {
browser: true,
node: true,
es6: true,
},
extends: ['plugin:vue/recommended', 'eslint:recommended'],
// add your custom rules here
//it is base on https://github.com/vuejs/eslint-config-vue
rules: {
"vue/max-attributes-per-line": [2, {
"singleline": 10,
"multiline": {
"max": 1,
"allowFirstLine": false
}
}],
"vue/singleline-html-element-content-newline": "off",
"vue/multiline-html-element-content-newline":"off",
"vue/name-property-casing": ["error", "PascalCase"],
"vue/no-v-html": "off",
'accessor-pairs': 2,
'arrow-spacing': [2, {
'before': true,
'after': true
}],
'block-spacing': [2, 'always'],
'brace-style': [2, '1tbs', {
'allowSingleLine': true
}],
'camelcase': [0, {
'properties': 'always'
}],
'comma-dangle': [2, 'never'],
'comma-spacing': [2, {
'before': false,
'after': true
}],
'comma-style': [2, 'last'],
'constructor-super': 2,
'curly': [2, 'multi-line'],
'dot-location': [2, 'property'],
'eol-last': 2,
'eqeqeq': ["error", "always", {"null": "ignore"}],
'generator-star-spacing': [2, {
'before': true,
'after': true
}],
'handle-callback-err': [2, '^(err|error)$'],
'indent': [2, 2, {
'SwitchCase': 1
}],
'jsx-quotes': [2, 'prefer-single'],
'key-spacing': [2, {
'beforeColon': false,
'afterColon': true
}],
'keyword-spacing': [2, {
'before': true,
'after': true
}],
'new-cap': [2, {
'newIsCap': true,
'capIsNew': false
}],
'new-parens': 2,
'no-array-constructor': 2,
'no-caller': 2,
'no-console': 'off',
'no-class-assign': 2,
'no-cond-assign': 2,
'no-const-assign': 2,
'no-control-regex': 0,
'no-delete-var': 2,
'no-dupe-args': 2,
'no-dupe-class-members': 2,
'no-dupe-keys': 2,
'no-duplicate-case': 2,
'no-empty-character-class': 2,
'no-empty-pattern': 2,
'no-eval': 2,
'no-ex-assign': 2,
'no-extend-native': 2,
'no-extra-bind': 2,
'no-extra-boolean-cast': 2,
'no-extra-parens': [2, 'functions'],
'no-fallthrough': 2,
'no-floating-decimal': 2,
'no-func-assign': 2,
'no-implied-eval': 2,
'no-inner-declarations': [2, 'functions'],
'no-invalid-regexp': 2,
'no-irregular-whitespace': 2,
'no-iterator': 2,
'no-label-var': 2,
'no-labels': [2, {
'allowLoop': false,
'allowSwitch': false
}],
'no-lone-blocks': 2,
'no-mixed-spaces-and-tabs': 2,
'no-multi-spaces': 2,
'no-multi-str': 2,
'no-multiple-empty-lines': [2, {
'max': 1
}],
'no-native-reassign': 2,
'no-negated-in-lhs': 2,
'no-new-object': 2,
'no-new-require': 2,
'no-new-symbol': 2,
'no-new-wrappers': 2,
'no-obj-calls': 2,
'no-octal': 2,
'no-octal-escape': 2,
'no-path-concat': 2,
'no-proto': 2,
'no-redeclare': 2,
'no-regex-spaces': 2,
'no-return-assign': [2, 'except-parens'],
'no-self-assign': 2,
'no-self-compare': 2,
'no-sequences': 2,
'no-shadow-restricted-names': 2,
'no-spaced-func': 2,
'no-sparse-arrays': 2,
'no-this-before-super': 2,
'no-throw-literal': 2,
'no-trailing-spaces': 2,
'no-undef': 2,
'no-undef-init': 2,
'no-unexpected-multiline': 2,
'no-unmodified-loop-condition': 2,
'no-unneeded-ternary': [2, {
'defaultAssignment': false
}],
'no-unreachable': 2,
'no-unsafe-finally': 2,
'no-unused-vars': [2, {
'vars': 'all',
'args': 'none'
}],
'no-useless-call': 2,
'no-useless-computed-key': 2,
'no-useless-constructor': 2,
'no-useless-escape': 0,
'no-whitespace-before-property': 2,
'no-with': 2,
'one-var': [2, {
'initialized': 'never'
}],
'operator-linebreak': [2, 'after', {
'overrides': {
'?': 'before',
':': 'before'
}
}],
'padded-blocks': [2, 'never'],
'quotes': [2, 'single', {
'avoidEscape': true,
'allowTemplateLiterals': true
}],
'semi': [2, 'never'],
'semi-spacing': [2, {
'before': false,
'after': true
}],
'space-before-blocks': [2, 'always'],
'space-before-function-paren': [2, 'never'],
'space-in-parens': [2, 'never'],
'space-infix-ops': 2,
'space-unary-ops': [2, {
'words': true,
'nonwords': false
}],
'spaced-comment': [2, 'always', {
'markers': ['global', 'globals', 'eslint', 'eslint-disable', '*package', '!', ',']
}],
'template-curly-spacing': [2, 'never'],
'use-isnan': 2,
'valid-typeof': 2,
'wrap-iife': [2, 'any'],
'yield-star-spacing': [2, 'both'],
'yoda': [2, 'never'],
'prefer-const': 2,
'no-debugger': process.env.NODE_ENV === 'production' ? 2 : 0,
'object-curly-spacing': [2, 'always', {
objectsInObjects: false
}],
'array-bracket-spacing': [2, 'never']
}
}
.DS_Store
node_modules/
dist/
npm-debug.log*
yarn-debug.log*
yarn-error.log*
**/*.log
tests/**/coverage/
tests/e2e/reports
selenium-debug.log
# Editor directories and files
.idea
.vscode
*.suo
*.ntvs*
*.njsproj
*.sln
*.local
package-lock.json
yarn.lock
language: node_js
node_js: 10
script: npm run test
notifications:
email: false
1、路由由登录后从后端动态生成发送给前端使用addRoutes添加到路由表中
\ No newline at end of file
module.exports = {
presets: [
'@vue/app'
]
}
const { run } = require('runjs')
const chalk = require('chalk')
const config = require('../vue.config.js')
const rawArgv = process.argv.slice(2)
const args = rawArgv.join(' ')
if (process.env.npm_config_preview || rawArgv.includes('--preview')) {
const report = rawArgv.includes('--report')
run(`vue-cli-service build ${args}`)
const port = 9526
const publicPath = config.publicPath
var connect = require('connect')
var serveStatic = require('serve-static')
const app = connect()
app.use(
publicPath,
serveStatic('./dist', {
index: ['index.html', '/']
})
)
app.listen(port, function () {
console.log(chalk.green(`> Preview at http://localhost:${port}${publicPath}`))
if (report) {
console.log(chalk.green(`> Report at http://localhost:${port}${publicPath}report.html`))
}
})
} else {
run(`vue-cli-service build ${args}`)
}
module.exports = {
moduleFileExtensions: ['js', 'jsx', 'json', 'vue'],
transform: {
'^.+\\.vue$': 'vue-jest',
'.+\\.(css|styl|less|sass|scss|svg|png|jpg|ttf|woff|woff2)$':
'jest-transform-stub',
'^.+\\.jsx?$': 'babel-jest'
},
moduleNameMapper: {
'^@/(.*)$': '<rootDir>/src/$1'
},
snapshotSerializers: ['jest-serializer-vue'],
testMatch: [
'**/tests/unit/**/*.spec.(js|jsx|ts|tsx)|**/__tests__/*.(js|jsx|ts|tsx)'
],
collectCoverageFrom: ['src/utils/**/*.{js,vue}', '!src/utils/auth.js', '!src/utils/request.js', 'src/components/**/*.{js,vue}'],
coverageDirectory: '<rootDir>/tests/unit/coverage',
// 'collectCoverage': true,
'coverageReporters': [
'lcov',
'text-summary'
],
testURL: 'http://localhost/'
}
import Mock from 'mockjs'
const List = []
const count = 100
const baseContent = '<p>I am testing data, I am testing data.</p><p><img src="https://wpimg.wallstcn.com/4c69009c-0fd4-4153-b112-6cb53d1cf943"></p>'
const image_uri = 'https://wpimg.wallstcn.com/e4558086-631c-425c-9430-56ffb46e70b3'
for (let i = 0; i < count; i++) {
List.push(Mock.mock({
id: '@increment',
timestamp: +Mock.Random.date('T'),
author: '@first',
reviewer: '@first',
title: '@title(5, 10)',
content_short: 'mock data',
content: baseContent,
forecast: '@float(0, 100, 2, 2)',
importance: '@integer(1, 3)',
'type|1': ['CN', 'US', 'JP', 'EU'],
'status|1': ['published', 'draft', 'deleted'],
display_time: '@datetime',
comment_disabled: true,
pageviews: '@integer(300, 5000)',
image_uri,
platforms: ['a-platform']
}))
}
export default [
{
url: '/article/list',
type: 'get',
response: config => {
const { importance, type, title, page = 1, limit = 20, sort } = config.query
let mockList = List.filter(item => {
if (importance && item.importance !== +importance) return false
if (type && item.type !== type) return false
if (title && item.title.indexOf(title) < 0) return false
return true
})
if (sort === '-id') {
mockList = mockList.reverse()
}
const pageList = mockList.filter((item, index) => index < limit * page && index >= limit * (page - 1))
return {
code: 20000,
data: {
total: mockList.length,
items: pageList
}
}
}
},
{
url: '/article/detail',
type: 'get',
response: config => {
const { id } = config.query
for (const article of List) {
if (article.id === +id) {
return {
code: 20000,
data: article
}
}
}
}
},
{
url: '/article/pv',
type: 'get',
response: _ => {
return {
code: 20000,
data: {
pvData: [
{ key: 'PC', pv: 1024 },
{ key: 'mobile', pv: 1024 },
{ key: 'ios', pv: 1024 },
{ key: 'android', pv: 1024 }
]
}
}
}
},
{
url: '/article/create',
type: 'post',
response: _ => {
return {
code: 20000,
data: 'success'
}
}
},
{
url: '/article/update',
type: 'post',
response: _ => {
return {
code: 20000,
data: 'success'
}
}
}
]
Supports Markdown
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