Skip to content

Commit 0f55eee

Browse files
committed
rewrite 、update struct
1 parent 35ab867 commit 0f55eee

32 files changed

+7619
-6422
lines changed

.browserslistrc

+1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
> 1%
22
last 2 versions
3+
not dead

.eslintrc.js

+6-12
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,13 @@ module.exports = {
1414
ecmaVersion: 2020
1515
},
1616
rules: {
17-
'no-console': process.env.NODE_ENV === 'production' ? 'error' : 'off',
18-
'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off',
19-
indent: [
20-
'error',
21-
4,
22-
{
23-
SwitchCase: 1
24-
}
25-
],
17+
'no-console': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
18+
'no-debugger': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
2619
'prefer-const': ['error', { destructuring: 'all' }],
20+
'no-async-promise-executor': 'off',
21+
'@typescript-eslint/explicit-module-boundary-types': 'off',
22+
'@typescript-eslint/ban-types': 'off',
2723
'@typescript-eslint/no-explicit-any': 'off',
28-
'vue/html-indent': ['error', 4],
29-
'@typescript-eslint/interface-name-prefix': 'off',
30-
'@typescript-eslint/camelcase': 'off'
24+
'@typescript-eslint/no-non-null-assertion': 'off'
3125
}
3226
};

.gitignore

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
.DS_Store
22
node_modules
3-
/temp
43
# /dist
54

5+
66
# local env files
77
.env.local
88
.env.*.local
@@ -11,10 +11,11 @@ node_modules
1111
npm-debug.log*
1212
yarn-debug.log*
1313
yarn-error.log*
14+
pnpm-debug.log*
1415

1516
# Editor directories and files
1617
.idea
17-
# .vscode
18+
.vscode
1819
*.suo
1920
*.ntvs*
2021
*.njsproj

.npmrc

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
registry=https://registry.npm.taobao.org
1+
registry=https://registry.npm.taobao.org/

.prettierignore

+1
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
dist
2+
package.json

.prettierrc

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,6 @@
33
"trailingComma": "none",
44
"tabWidth": 4,
55
"endOfLine": "auto",
6-
"printWidth": 120
6+
"printWidth": 120,
7+
"arrowParens": "avoid"
78
}

.travis.yml

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
language: node_js
22
node_js:
3-
- stable
3+
- '14.15.4'
4+
install:
5+
- npm install
46
script:
57
- npm run lint
6-
- npm run build
8+
- npm run build

.vscode/settings.json

-10
This file was deleted.

babel.config.js

+1-8
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,3 @@
11
module.exports = {
2-
presets: [
3-
[
4-
'@vue/cli-plugin-babel/preset',
5-
{
6-
useBuiltIns: false
7-
}
8-
]
9-
]
2+
presets: ['@vue/cli-plugin-babel/preset']
103
};

lint-staged.config.js

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module.exports = {
2+
'*.{js,jsx,vue,ts,tsx}': 'vue-cli-service lint'
3+
};

package-lock.json

+6,959-5,673
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+23-23
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@
1010
"registry": "https://registry.npmjs.org"
1111
},
1212
"scripts": {
13+
"dev": "npm run serve",
1314
"serve": "vue-cli-service serve",
1415
"build": "sh scripts/build.sh",
15-
"vue-build": "vue-cli-service build --target lib ./src/VueGitComment/index.ts",
16+
"vue-build": "vue-cli-service build --target lib --name vue-git-comment src/VueGitComment/index.ts",
1617
"report": "npm run vue-build -- --report",
17-
"lint": "vue-cli-service lint",
18-
"format": "prettier --write \"./**/*.@(ts|js|vue)\""
18+
"lint": "vue-cli-service lint"
1919
},
2020
"repository": {
2121
"type": "git",
@@ -34,31 +34,31 @@
3434
},
3535
"homepage": "https://github.com/shalldie/vue-git-comment#readme",
3636
"dependencies": {
37-
"core-js": "^3.6.4",
37+
"core-js": "^3.8.3",
3838
"vue": "^2.6.11",
39-
"vue-class-component": "^7.2.2",
40-
"vue-property-decorator": "^8.3.0"
39+
"vue-class-component": "^7.2.3",
40+
"vue-property-decorator": "^9.1.2"
4141
},
4242
"devDependencies": {
43-
"@typescript-eslint/eslint-plugin": "^2.18.0",
44-
"@typescript-eslint/parser": "^2.18.0",
45-
"@vue/cli-plugin-babel": "~4.2.0",
46-
"@vue/cli-plugin-eslint": "~4.2.0",
47-
"@vue/cli-plugin-typescript": "~4.2.0",
48-
"@vue/cli-service": "~4.2.0",
43+
"@typescript-eslint/eslint-plugin": "^4.15.1",
44+
"@typescript-eslint/parser": "^4.15.1",
45+
"@vue/cli-plugin-babel": "~5.0.0-alpha.8",
46+
"@vue/cli-plugin-eslint": "~5.0.0-alpha.8",
47+
"@vue/cli-plugin-typescript": "~5.0.0-alpha.8",
48+
"@vue/cli-service": "~5.0.0-alpha.8",
4949
"@vue/eslint-config-prettier": "^6.0.0",
50-
"@vue/eslint-config-typescript": "^5.0.1",
51-
"eslint": "^6.7.2",
52-
"eslint-plugin-prettier": "^3.1.1",
53-
"eslint-plugin-vue": "^6.1.2",
54-
"prettier": "^1.19.1",
55-
"sass": "^1.25.0",
56-
"sass-loader": "^8.0.2",
57-
"typescript": "~3.7.5",
50+
"@vue/eslint-config-typescript": "^7.0.0",
51+
"eslint": "^7.20.0",
52+
"eslint-plugin-prettier": "^3.3.1",
53+
"eslint-plugin-vue": "^7.6.0",
54+
"lint-staged": "^10.5.4",
55+
"prettier": "^2.2.1",
56+
"sass": "^1.32.7",
57+
"sass-loader": "^11.0.1",
58+
"typescript": "~4.1.5",
5859
"vue-template-compiler": "^2.6.11"
5960
},
60-
"engines": {
61-
"node": ">= 6.0.0",
62-
"npm": ">= 3.0.0"
61+
"gitHooks": {
62+
"pre-commit": "lint-staged"
6363
}
6464
}

scripts/build.sh

-3
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,6 @@ BASE_PATH=$(cd `dirname $BASE_PATH`; pwd)
77
# 定位到 root
88
cd $BASE_PATH
99

10-
# 删除旧的产出
11-
rm -rf dist
12-
1310
# 构建
1411
npm run vue-build
1512

src/App.vue

+30-23
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,37 @@
11
<template>
2-
<div id="app">
3-
<button @click="toggleBgcolor" style="padding: 4px;">toggle backgroundColor</button>
4-
<br />
5-
<br />
6-
<br />
2+
<div id="app" :class="{ dark: dark }">
3+
<div class="btn-wrap">
4+
<button @click="toggle">toggle backgroundColor</button>
5+
</div>
76
<VueGitComment :options="options" />
87
</div>
98
</template>
109

1110
<script lang="ts">
12-
import { Component, Vue } from 'vue-property-decorator';
11+
import { Component, BaseComponent } from '~/lib/decorators';
12+
import { TOptions } from './lib/store';
1313
import VueGitComment from './VueGitComment';
1414
15-
import { StateStore } from './lib/store';
16-
1715
@Component({
1816
components: {
1917
VueGitComment
2018
}
2119
})
22-
export default class App extends Vue {
23-
options: StateStore['options'] = {
24-
client_id: '3a657823527f57a63864',
25-
client_secret: '80714a6e5a35b36043a5dfbd15d43795e95aaa9b',
20+
export default class App extends BaseComponent {
21+
dark = false;
22+
23+
options: TOptions = {
24+
clientID: '3a657823527f57a63864',
25+
clientSecret: '80714a6e5a35b36043a5dfbd15d43795e95aaa9b',
2626
owner: 'shalldie',
2727
repo: 'gitment-store',
2828
uuid: 'esaffffdfdsaflgfdjsa',
29+
// uuid: '/article/cmd-entrypoint-in-dockerfile',
2930
language: 'zh-CN'
3031
};
3132
32-
toggleBgcolor() {
33-
const body = document.body;
34-
if (body.hasAttribute('style')) {
35-
body.removeAttribute('style');
36-
return;
37-
}
38-
body.setAttribute('style', 'background: #f8f8f8');
33+
toggle() {
34+
this.dark = !this.dark;
3935
}
4036
}
4137
</script>
@@ -48,14 +44,25 @@ body {
4844
background: #fff;
4945
}
5046
#app {
51-
font-family: 'Avenir', Helvetica, Arial, sans-serif;
47+
font-family: Avenir, Helvetica, Arial, sans-serif;
5248
-webkit-font-smoothing: antialiased;
5349
-moz-osx-font-smoothing: grayscale;
50+
5451
color: #333;
55-
max-width: 800px;
52+
max-width: 1000px;
5653
margin: 50px auto 0;
57-
padding: 0 15px;
54+
padding: 20px;
5855
box-sizing: border-box;
59-
/* border: 1px solid #ddd; */
56+
57+
&.dark {
58+
background: #f8f8f8;
59+
}
60+
61+
.btn-wrap {
62+
margin-bottom: 50px;
63+
button {
64+
padding: 4px;
65+
}
66+
}
6067
}
6168
</style>

src/VueGitComment/VueGitComment.vue

+11-19
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@
88
</template>
99

1010
<script lang="ts">
11-
import { Component, Vue, Prop, Watch, Provide } from 'vue-property-decorator';
12-
import store, { StateStore } from '../lib/store';
13-
import gitComment from '../lib/gitComment';
14-
import CommentHeader from '@/components/CommentHeader.vue';
15-
import CommentBody from '@/components/CommentBody.vue';
16-
import CommentPagination from '@/components/CommentPagination.vue';
17-
import CommentEditor from '@/components/CommentEditor.vue';
11+
import { Component, Prop, Watch, BaseComponent } from '~/lib/decorators';
12+
import CommentHeader from '~/components/CommentHeader.vue';
13+
import CommentBody from '~/components/CommentBody.vue';
14+
import CommentPagination from '~/components/CommentPagination.vue';
15+
import CommentEditor from '~/components/CommentEditor.vue';
16+
import { gm } from '~/lib/gitcomment';
17+
import { TOptions } from '~/lib/store';
1818
1919
@Component({
2020
components: {
@@ -24,25 +24,19 @@ import CommentEditor from '@/components/CommentEditor.vue';
2424
CommentEditor
2525
}
2626
})
27-
export default class VueGitComment extends Vue {
27+
export default class VueGitComment extends BaseComponent {
2828
/**
2929
* 组件配置
3030
*/
3131
@Prop()
32-
private options!: StateStore['options'];
33-
34-
/**
35-
* 全局store
36-
*/
37-
@Provide()
38-
store = store;
32+
options!: TOptions;
3933
4034
/**
4135
* 当配置更新,重新初始化组件
4236
*/
4337
@Watch('options', { deep: true })
44-
handleOptionsChange(options: StateStore['options']) {
45-
gitComment.init(options);
38+
handleOptionsChange(options: TOptions) {
39+
gm.init(options);
4640
}
4741
4842
mounted() {
@@ -52,8 +46,6 @@ export default class VueGitComment extends Vue {
5246
</script>
5347

5448
<style lang="scss">
55-
@import '../assets/styles/github-markdown.css';
56-
5749
@keyframes vue-git-comment-rotate {
5850
from {
5951
transform: rotate(0);

src/VueGitComment/index.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1+
import '~/assets/styles/github-markdown.css';
12
import VueGitComment from './VueGitComment.vue';
23

3-
VueGitComment['install'] = function(Vue) {
4-
Vue.component('vue-git-comment', VueGitComment);
4+
VueGitComment['install'] = Vue => {
5+
Vue.component(VueGitComment.name, VueGitComment);
56
};
67

78
export default VueGitComment;

0 commit comments

Comments
 (0)