Skip to content

Commit

Permalink
feat(commitlint): add commitlint
Browse files Browse the repository at this point in the history
  • Loading branch information
ibwei committed Apr 7, 2021
1 parent 8bce871 commit 2296748
Show file tree
Hide file tree
Showing 13 changed files with 52,287 additions and 10,044 deletions.
1 change: 1 addition & 0 deletions .husky/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
_
4 changes: 4 additions & 0 deletions .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

npx --no-install commitlint --edit $1
3 changes: 3 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"
npx lint-staged
16 changes: 10 additions & 6 deletions .prettierrc.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
module.exports = {
singleQuote: true,
semi: false,
trailingComma: 'none',
endOfLine: 'lf'
}
// reference:: https://prettier.io/docs/en/options.html
module.exports = {
singleQuote: true,
semi: false,
trailingComma: 'none',
endOfLine: 'lf',
printWidth: 999,
proseWrap: 'never',
arrowParens:'avoid'
}
41,559 changes: 41,559 additions & 0 deletions package-lock.json

Large diffs are not rendered by default.

15 changes: 8 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,27 +19,28 @@
"test-dev:unit": "vue-cli-service test:unit --watch",
"test:api": "vue-cli-service test:unit ./tests/api/*.spec.ts",
"test-dev:api": "vue-cli-service test:unit ./tests/api/*.spec.ts --watch",
"analysis": "cross-env use_analyzer=true vue-cli-service build"
"analysis": "cross-env use_analyzer=true vue-cli-service build",
"prepare": "husky install"
},
"main": "dist/index.js",
"files": [
"@types"
],
"dependencies": {
"@vue/composition-api": "^1.0.0-beta.14",
"@vueuse/core": "^4.0.0-beta.16",
"ant-design-vue": "^2.0.0-beta.9",
"axios": "^0.20.0",
"core-js": "^3.6.5",
"moment": "^2.27.0",
"vue": "^3.0.0",
"vue-class-component": "^8.0.0-0",
"vue-composable": "^1.0.0-beta.10",
"vue-router": "^4.0.0-0",
"vuex": "^4.0.0-0",
"vuex-persistedstate": "^3.1.0"
},
"devDependencies": {
"@commitlint/cli": "^12.0.1",
"@commitlint/config-conventional": "^12.0.1",
"@types/chai": "^4.2.11",
"@types/lodash": "^4.14.161",
"@types/mocha": "^5.2.4",
Expand All @@ -60,6 +61,7 @@
"babel-plugin-import": "^1.13.0",
"chai": "^4.1.2",
"commitizen": "^4.2.1",
"cross-env": "^7.0.3",
"cz-conventional-changelog": "3.3.0",
"deepmerge": "^4.2.2",
"eslint": "^6.7.2",
Expand All @@ -71,18 +73,17 @@
"eslint-plugin-standard": "^4.0.0",
"eslint-plugin-vue": "^7.0.0-0",
"http-server": "^0.12.3",
"husky": "^6.0.0",
"less": "^2.7.0",
"less-loader": "^5.0.0",
"lint-staged": "^10.5.1",
"prettier": "^1.19.1",
"style-resources-loader": "^1.3.2",
"ts-node": "^9.0.0",
"typedoc": "^0.19.0",
"typescript": "~3.9.3",
"typescript": "4.0.2",
"vue-cli-plugin-style-resources-loader": "~0.1.4",
"vue-property-decorator": "^9.0.0",
"webpack-bundle-analyzer": "^4.3.0",
"cross-env": "^7.0.3"
"webpack-bundle-analyzer": "^4.3.0"
},
"gitHooks": {
"pre-commit": "lint-staged"
Expand Down
12 changes: 3 additions & 9 deletions src/i18n/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,8 @@ export const i18nInstance = useI18n({
* @description 自动加载 antd-vue 需要的语言模版
*/
function loadAtdLocales() {
const files = require.context(
'../../node_modules/ant-design-vue/es/locale-provider',
true,
/\.js$/
)
files.keys().forEach((key) => {
const files = require.context('../../node_modules/ant-design-vue/es/locale-provider', true, /\.js$/)
files.keys().forEach(key => {
const fileName = key.slice(2, key.lastIndexOf('.'))
if (includes(TranslateTable, fileName)) {
const localeKey = findKeyByValue(TranslateTable, fileName)
Expand Down Expand Up @@ -84,9 +80,7 @@ function _set(lang: keyof typeof TranslateTable): keyof typeof TranslateTable {
* @param {string} lang - 将要更换的语言
* @return {string} lang - 返回将要更改的语言明后才能
*/
export function setLang(
lang: string
): Promise<keyof typeof TranslateTable | 'same'> {
export function setLang(lang: string): Promise<keyof typeof TranslateTable | 'same'> {
if (lang === i18nInstance.locale.value) {
return Promise.resolve('same')
}
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { createApp } from 'vue'
*/
export function loadAllPlugins(app: ReturnType<typeof createApp>) {
const files = require.context('.', true, /\.ts$/)
files.keys().forEach((key) => {
files.keys().forEach(key => {
if (typeof files(key).default === 'function') {
if (key !== './index.ts') files(key).default(app)
}
Expand Down
29 changes: 5 additions & 24 deletions src/store/modules/console/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,7 @@ const consoleActions = {
},

// 获取团队列表
async getTeamList(
context: Store<StateType>,
params: HttpListQuery
): Promise<HttpResponse | number> {
async getTeamList(context: Store<StateType>, params: HttpListQuery): Promise<HttpResponse | number> {
const res = await TeamService.list({ ...params })
if (res.status === 200) {
const data = res.data.data
Expand All @@ -40,30 +37,17 @@ const consoleActions = {
},

// 获取某个团队的所有成员信息
async getTeamMemberList(
context: Store<StateType>,
id: number
): Promise<HttpResponse | number> {
async getTeamMemberList(context: Store<StateType>, id: number): Promise<HttpResponse | number> {
const res = await TeamService.memberList(id as number)
if (res.status === 200) {
const memberList = res.data.data.rows.filter((item: any) =>
[
RoleType['团队超级管理员'],
RoleType['团队成员'],
RoleType['团队访客'],
RoleType['团队管理员']
].includes(item.roleId)
)
const memberList = res.data.data.rows.filter((item: any) => [RoleType['团队超级管理员'], RoleType['团队成员'], RoleType['团队访客'], RoleType['团队管理员']].includes(item.roleId))
setStoreState('console', 'selectedTeamMemberList', memberList)
}
return 0
},

// 获取某个团队的详细信息
async getTeamDetail(
context: Store<StateType>,
id: number
): Promise<HttpResponse | number> {
async getTeamDetail(context: Store<StateType>, id: number): Promise<HttpResponse | number> {
console.log('chufa')
const res = await TeamService.detail(id)
if (res.status === 200) {
Expand All @@ -89,10 +73,7 @@ const consoleActions = {
},

// 获取当前选择团队下所有的云角色列表
async getTeamCloudRoleList(
context: Store<StateType>,
teamId: number
): Promise<HttpResponse | number> {
async getTeamCloudRoleList(context: Store<StateType>, teamId: number): Promise<HttpResponse | number> {
console.log(`id=${teamId}`)
const res = await CloudRoleService.list(teamId)
if (res.status === 200) {
Expand Down
18 changes: 7 additions & 11 deletions src/store/modules/console/getters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,13 @@ const consoleGetter = {
// 获取云角色列表
getTeamClouldList() {
// 获取用户列表以及云角色列表
const memberList = store.state.console.selectedTeamMemberList.map(
(item) => {
let cloudRoleList: number[] = []
if (item.cloudRole) {
cloudRoleList = item.cloudRole.split(',').map((id) => Number(id))
}
return { ...item, cloudRoleList: cloudRoleList }
const memberList = store.state.console.selectedTeamMemberList.map(item => {
let cloudRoleList: number[] = []
if (item.cloudRole) {
cloudRoleList = item.cloudRole.split(',').map(id => Number(id))
}
)
return { ...item, cloudRoleList: cloudRoleList }
})

const cloudRoleList = [...store.state.console.selectedTeamCloudRoleList]

Expand All @@ -23,9 +21,7 @@ const consoleGetter = {
for (let i = 0; i < cloudRoleList.length; i++) {
list.push({ ...cloudRoleList[i], members: [] })
for (let j = 0; j < memberList.length; j++) {
if (
memberList[j].cloudRoleList.includes(cloudRoleList[i].cloudRoleId)
) {
if (memberList[j].cloudRoleList.includes(cloudRoleList[i].cloudRoleId)) {
list[i].members.push(memberList[j])
}
}
Expand Down
5 changes: 1 addition & 4 deletions src/store/modules/console/mutations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,7 @@ export default {
const currentPath = router.currentRoute.value.fullPath
const newBackPathList = [...backPathList]

if (
backPathList.length < 0 ||
backPathList[backPathList.length - 1] !== currentPath
) {
if (backPathList.length < 0 || backPathList[backPathList.length - 1] !== currentPath) {
newBackPathList.push(currentPath)
}

Expand Down
9 changes: 7 additions & 2 deletions src/views/AboutMe.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ const AboutMe = defineComponent({
console.log('mounted is creatd')
})
const root = ref(null)
return { root }
return {
root
}
},
data() {
return {
Expand All @@ -26,7 +28,10 @@ const AboutMe = defineComponent({
},
methods: {
caculatePageName(): string {
return this.book.pageName.split('-').reverse().join()
return this.book.pageName
.split('-')
.reverse()
.join()
}
}
})
Expand Down
Loading

0 comments on commit 2296748

Please sign in to comment.