Commit 390a9e0b by liguokang

feat: 🎨

parent f077e999
...@@ -2,11 +2,17 @@ ...@@ -2,11 +2,17 @@
* @Author: liguokang * @Author: liguokang
* @Date: 2021-07-14 20:36:28 * @Date: 2021-07-14 20:36:28
* @LastEditors: liguokang * @LastEditors: liguokang
* @LastEditTime: 2021-07-28 11:17:40 * @LastEditTime: 2021-07-29 14:07:58
* @Description: * @Description:
* @Copyrigh: ©2021 杭州杰竞科技有限公司 版权所有 * @Copyrigh: ©2021 杭州杰竞科技有限公司 版权所有
--> -->
## 描述 ## git husky使用描述
### 教程链接
https://blog.csdn.net/Xinshenbaba/article/details/117191983
### commitlint 规范地址
https://commitlint.js.org/#/reference-rules
此处为 git 相关文件 此处为 git 相关文件
#!/bin/sh
if [ -z "$husky_skip_init" ]; then
debug () {
[ "$HUSKY_DEBUG" = "1" ] && echo "husky (debug) - $1"
}
readonly hook_name="$(basename "$0")"
debug "starting $hook_name..."
if [ "$HUSKY" = "0" ]; then
debug "HUSKY env variable is set to 0, skipping hook"
exit 0
fi
if [ -f ~/.huskyrc ]; then
debug "sourcing ~/.huskyrc"
. ~/.huskyrc
fi
export readonly husky_skip_init=1
sh -e "$0" "$@"
exitCode="$?"
if [ $exitCode != 0 ]; then
echo "husky - $hook_name hook exited with code $exitCode (error)"
fi
exit $exitCode
fi
...@@ -15,7 +15,7 @@ const service = axios.create({ ...@@ -15,7 +15,7 @@ const service = axios.create({
// request拦截器 // request拦截器
service.interceptors.request.use( service.interceptors.request.use(
config => { (config) => {
if (config.url.indexOf('public/') === -1 && User.token()) { if (config.url.indexOf('public/') === -1 && User.token()) {
return config; return config;
} else if (config.headers.module) { } else if (config.headers.module) {
...@@ -27,7 +27,7 @@ service.interceptors.request.use( ...@@ -27,7 +27,7 @@ service.interceptors.request.use(
return config; return config;
} }
}, },
error => { (error) => {
// Do something with request error // Do something with request error
Promise.reject(error); Promise.reject(error);
}, },
...@@ -35,29 +35,18 @@ service.interceptors.request.use( ...@@ -35,29 +35,18 @@ service.interceptors.request.use(
// response 拦截器 // response 拦截器
service.interceptors.response.use( service.interceptors.response.use(
response => { (response) => {
const { data } = response; const { data } = response;
const { code, result, message } = data; const { code, result, message } = data;
const rejectCode = [ // 坚决禁止在response中做业务异常操作
'LOGIN_OVERDUE', const rejectCode = [];
'10000',
'10001',
'10002',
'RPC_FAIL',
'ILLEGAL_ARGUMENT',
'BASIC_INFO_ERROR',
'SCHEDULE_HAS_REMOVE',
'SCHEDULE_NONE_STUDENT',
'NONE_PERMISSION_JOIN',
'VERIFY_CODE_ERROR',
];
if (code < 200 || code > 300) { if (code < 200 || code > 300) {
if (code == 418) { if (code == 418) {
window.location.href = 'https://www.xiaomai5.com/maintain.html'; window.location.href = 'https://www.xiaomai5.com/maintain.html';
} else if (code == 401 || code == 403) { } else if (code == 401 || code == 403) {
User.loginIn(); User.loginIn();
} else { } else {
processHttpError(data); processHttpError(response);
} }
return data; return data;
// return Promise.reject(new Error('error')); // return Promise.reject(new Error('error'));
...@@ -67,13 +56,14 @@ service.interceptors.response.use( ...@@ -67,13 +56,14 @@ service.interceptors.response.use(
time: new Date().toString(), time: new Date().toString(),
code, code,
errorInfo: message || result, errorInfo: message || result,
path: response.config.url,
}); });
// return Promise.reject(data); // return Promise.reject(data);
} }
return data; return data;
} }
}, },
error => { (error) => {
let code = 0; let code = 0;
try { try {
code = error.response.data.status; code = error.response.data.status;
...@@ -82,7 +72,7 @@ service.interceptors.response.use( ...@@ -82,7 +72,7 @@ service.interceptors.response.use(
} else if (code == 401 || code == 403) { } else if (code == 401 || code == 403) {
User.loginIn(); User.loginIn();
} else { } else {
processHttpError(error.response.data); processHttpError(error.response);
} }
} catch (e) { } catch (e) {
if (error.toString().indexOf('Error: timeout') !== -1) { if (error.toString().indexOf('Error: timeout') !== -1) {
...@@ -104,7 +94,8 @@ service.interceptors.response.use( ...@@ -104,7 +94,8 @@ service.interceptors.response.use(
return Promise.reject(error); return Promise.reject(error);
}, },
); );
function processHttpError(data) { function processHttpError(response) {
const { data } = response;
let message = ''; let message = '';
const status = Number(data.code) > 0 ? Number(data.code) : Number(data.status); const status = Number(data.code) > 0 ? Number(data.code) : Number(data.status);
const code = Number(data.code); const code = Number(data.code);
...@@ -122,9 +113,10 @@ function processHttpError(data) { ...@@ -122,9 +113,10 @@ function processHttpError(data) {
message = data.message; message = data.message;
} }
console.table({ console.table({
time: new Date().toString(),
code: code > 0 ? code : status, code: code > 0 ? code : status,
time: new Date().toString(),
errorInfo: message, errorInfo: message,
path: response.config.url,
}); });
Vue.$wheatToast({ Vue.$wheatToast({
message: message, message: message,
......
#! /usr/bin/env node
/*
* @Author: 吴文洁
* @Date: 2020-06-05 14:59:14
* @LastEditors: liguokang
* @LastEditTime: 2021-07-29 13:37:55
* @Description:
* @Copyrigh: © 2020 杭州杰竞科技有限公司 版权所有
*/
const fs = require('fs')
console.log(process);
const [
messageFile,
commitType,
] = process.env.$1.split(' ');
if (commitType == null) {
const currentMessage = fs.readFileSync(messageFile, 'utf8');
// eslint-disable-next-line no-console
const pattern = new RegExp('(feat|fix|style|docs|refactor|pref|test):');
const _currentMessage = currentMessage.replace('\n', '');
if (!pattern.test(currentMessage) && currentMessage.indexOf('Merge branch') === -1) {
// eslint-disable-next-line no-console
console.error(`\x1b[31m ${_currentMessage}不符合commit-msg规范,具体规范请访问 http://wiki.ixm5.cn/pages/viewpage.action?pageId=2918494 \x1b[31m`);
process.exit(1);
}
if (_currentMessage.length <= 10) {
// eslint-disable-next-line no-console
console.error(`\x1b[31m ${_currentMessage}提交的信息字数不得少于5个字符`);
process.exit(1);
}
process.exit(0);
}
#! /usr/bin/env node
/*
* @Author: 吴文洁
* @Date: 2020-06-05 09:38:03
* @LastEditors: louzhedong
* @LastEditTime: 2020-12-26 16:08:19
* @Description:
* @Copyrigh: © 2020 杭州杰竞科技有限公司 版权所有
*/
const execSync = require('child_process').execSync;
// 获取当前分支名称
const branchName = execSync('git rev-parse --abbrev-ref HEAD').toString().trim();
// 校验分支名是否合法
const firstPattern = new RegExp('dev|rc|gray|master');
const secondPattern = new RegExp('(feature|hotfix)/[a-z]{4,}/[0-9]{8,}/[0-9a-zA-Z-]{3,}');
const firstMatch = firstPattern.test(branchName);
const secondMatch = secondPattern.test(branchName);
if (!firstMatch && !secondMatch) {
// eslint-disable-next-line no-console
console.error(`\x1b[31m ${branchName}不符合分支规范,具体规范请访问 http://wiki.ixm5.cn/pages/viewpage.action?pageId=2918496 \x1b[31m`);
process.exit(1);
}
// 获取缓存区内容
// 通过diff指令获得所有改动过(不包括删除)的js文件路径
const fileNameStr = execSync('git diff --diff-filter=AM --cached HEAD --name-only').toString();
// 过滤掉空格
const fileNameList = fileNameStr.split('\n').filter((item) => !!item);
// 获取需要检测的文件
const detectedFileList = fileNameList.filter((file) => {
// 过滤掉空的和hooks文件夹下所有的文件
return file && file.indexOf('hooks') < 0;
});
// 遍历需要检测的文件
let errorFileList = [];
detectedFileList.forEach((file) => {
const results = execSync(`git diff --cached ${file}`);
const pattern = /^http\:\/\/.{1,}/;
if (pattern.test(results.toString())) {
errorFileList.push(file);
}
});
if (errorFileList.length > 0) {
const errorFileStr = JSON.stringify(errorFileList);
// eslint-disable-next-line no-console
console.error(`\x1b[31m ${errorFileStr}文件中存在不合法的http://,请将http替换为https \x1b[31m`);
process.exit(1);
}
// 校验是否有冲突
const conflictPattern = new RegExp('^<<<<<<<\\s|^=======$|^>>>>>>>\\s');
const conflictFileList = [];
fileNameList.forEach((file) => {
const results = execSync(`git diff --cached ${file}`);
if (conflictPattern.test(results)) {
conflictFileList.push(file);
}
});
if (conflictFileList.length > 0) {
const conflictFileStr = JSON.stringify(conflictFileList);
// eslint-disable-next-line no-console
console.error(`\x1b[31m ${conflictFileStr}文件中存在冲突,请解决冲突之后再提交 \x1b[31m`);
process.exit(1);
}
process.exit(0);
import { actionTypes } from './action-types'; import { actionTypes } from './actionTypes';
export function changeCity(city) { export function changeCity(city) {
return { return {
......
...@@ -2,12 +2,12 @@ ...@@ -2,12 +2,12 @@
* @Author: liguokang * @Author: liguokang
* @Date: 2021-07-15 10:12:48 * @Date: 2021-07-15 10:12:48
* @LastEditors: liguokang * @LastEditors: liguokang
* @LastEditTime: 2021-07-15 10:26:23 * @LastEditTime: 2021-07-29 14:09:11
* @Description: * @Description:
* @Copyrigh: ©2021 杭州杰竞科技有限公司 版权所有 * @Copyrigh: ©2021 杭州杰竞科技有限公司 版权所有
*/ */
import { actionTypes } from '../action/action-types'; import { actionTypes } from '../action/actionTypes';
let initState = { let initState = {
city: '', city: '',
......
This diff is collapsed. Click to expand it.
...@@ -2,8 +2,7 @@ html, ...@@ -2,8 +2,7 @@ html,
body { body {
padding: 0; padding: 0;
margin: 0; margin: 0;
font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Oxygen, font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Oxygen, Ubuntu, Cantarell, Fira Sans, Droid Sans, Helvetica Neue, sans-serif;
Ubuntu, Cantarell, Fira Sans, Droid Sans, Helvetica Neue, sans-serif;
font-size: 14px; font-size: 14px;
} }
......
Markdown is supported
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