Skip to content

Commit 1a1d25b

Browse files
committed
feat: 修改example
1 parent 8d3bcec commit 1a1d25b

26 files changed

+11971
-1
lines changed

.npmignore

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
.DS_Store
2+
node_modules/
3+
/dist/
4+
/demo
5+
npm-debug.log*
6+
yarn-debug.log*
7+
yarn-error.log*
8+
/test/unit/coverage/
9+
/test/e2e/reports/
10+
selenium-debug.log
11+
.example/
12+
example/
13+
test/
14+
15+
16+
# Editor directories and files
17+
.idea
18+
.vscode
19+
*.suo
20+
*.ntvs*
21+
*.njsproj
22+
*.sln

example/.editorconfig

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
root = true
2+
3+
[*]
4+
charset = utf-8
5+
indent_style = space
6+
indent_size = 2
7+
end_of_line = lf
8+
insert_final_newline = true
9+
trim_trailing_whitespace = true

example/.eslintignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
/build/
2+
/config/
3+
/dist/
4+
/*.js
5+
/test/unit/coverage/

example/.eslintrc.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
module.exports = {
2+
extends: [
3+
'standard',
4+
'plugin:vue/recommended'
5+
],
6+
rules: {
7+
8+
},
9+
globals: {
10+
__webpack_public_path__: true
11+
}
12+
}

example/.gitignore

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
.DS_Store
2+
node_modules/
3+
/dist/
4+
/demo
5+
npm-debug.log*
6+
yarn-debug.log*
7+
yarn-error.log*
8+
/test/unit/coverage/
9+
/test/e2e/reports/
10+
selenium-debug.log
11+
.example/
12+
13+
# Editor directories and files
14+
.idea
15+
.vscode
16+
*.suo
17+
*.ntvs*
18+
*.njsproj
19+
*.sln

example/.postcssrc.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// https://github.com/michael-ciniawsky/postcss-load-config
2+
3+
module.exports = {
4+
"plugins": {
5+
"postcss-import": {},
6+
"postcss-url": {},
7+
// to edit target browsers: use "browserslist" field in package.json
8+
"autoprefixer": {}
9+
}
10+
}

example/.stylelintrc.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"extends": "stylelint-config-standard",
3+
"ignoreFiles": ["./node_modules/**/*.css","./dist/**/*.css"]
4+
}

example/README.md

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# [vue-code-diff](https://www.npmjs.com/package/vue-code-diff)
2+
3+
> 代码比对展示 [demo](http://diff.xjie.me/)
4+
5+
## 安装
6+
```shell
7+
yarn add vue-code-diff
8+
```
9+
10+
## 使用
11+
```vue
12+
<template>
13+
<div>
14+
<code-diff :old-string="oldStr" :new-string="newStr" :context="10" />
15+
</div>
16+
</template>
17+
18+
import CodeDiff from 'vue-code-diff'
19+
export default {
20+
components: {CodeDiff},
21+
data(){
22+
return {
23+
oldStr: 'old code',
24+
newStr: 'new code'
25+
}
26+
}
27+
}
28+
```
29+
30+
## 参数说明
31+
32+
| 参数 | 说明 | 类型 | 可选值 | 默认值 |
33+
|---------- |-------- |---------- |------------- |-------- |
34+
| old-string| 陈旧的字符串| string |||
35+
| new-string| 新的字符串| string |||
36+
| context| 不同地方上下间隔多少行不隐藏 | number |||
37+
| outputFormat| 展示的方式 | string | line-by-line,side-by-side | line-by-line |
38+
| drawFileList | 展示对比文件列表 | boolean | - | false |
39+
| renderNothingWhenEmpty | 当无对比时不渲染 | boolean | - | false |
40+
| diffStyle | 每行中对比差异级别 | string | word, char | word |
41+
| fileName | 文件名 | string | - | |
42+
| isShowNoChange | 当无对比时展示源代码 | boolean | - | false |
43+
44+
45+
## 效果展示
46+
47+
### line-by-line
48+
![image](https://github.com/ddchef/vue-code-diff/blob/master/2018-06-01.png?raw=true)
49+
50+
### side-by-side
51+
![image](https://github.com/ddchef/vue-code-diff/blob/master/2018050615272.png?raw=true)
52+
53+
## LICENSE
54+
[MIT](LICENSE)

example/babel.config.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
module.exports = {
2+
presets: [
3+
[
4+
'@vue/app'
5+
]
6+
],
7+
plugins: [
8+
[
9+
'@babel/plugin-transform-runtime',{
10+
corejs: 3,
11+
}
12+
]
13+
]
14+
}

example/build/build.js

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
const webpack = require('webpack')
2+
const ora = require('ora')
3+
const chalk = require('chalk')
4+
const webpackConfig = require('./config')
5+
6+
webpackConfig().then(({ prodConfig }) => {
7+
const isAnalyzer = process.argv[2] === 'analyzer'
8+
if (isAnalyzer) {
9+
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin
10+
prodConfig.plugins.push(
11+
new BundleAnalyzerPlugin()
12+
)
13+
}
14+
const spinner = ora('Builing for production...').start()
15+
webpack(prodConfig, (err, stats) => {
16+
spinner.stop()
17+
if (err) throw err
18+
process.stdout.write(stats.toString({
19+
modules: false,
20+
colors: true,
21+
// 添加 children 信息
22+
children: false,
23+
// 添加 chunk 信息(设置为 `false` 能允许较少的冗长输出)
24+
chunks: false,
25+
// 将构建模块信息添加到 chunk 信息
26+
chunkModules: false
27+
}) + '\n\n')
28+
if (stats.hasErrors()) {
29+
console.log(chalk.red('Build failed with errors.\n'))
30+
process.exit(1)
31+
}
32+
console.log(chalk.cyan('Build complete.\n'))
33+
if (!isAnalyzer) process.exit(0)
34+
})
35+
})

0 commit comments

Comments
 (0)