Skip to content

Commit 374b9ee

Browse files
committed
fix: formate code
1 parent ade5fd6 commit 374b9ee

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+598
-1109
lines changed

.eslintrc.cjs

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ module.exports = {
6262
// 强制在对象字面量的键和值之间使用一致的空格
6363
'key-spacing': ['error', { 'mode': 'strict' }],
6464
// 强制在函数括号内使用一致的换行, 函数参数超过2个换行
65-
'function-paren-newline': ['error', { 'minItems': 2 }],
65+
'function-paren-newline': ['error', { 'minItems': 3 }],
6666
// 强制回调函数最大嵌套深度
6767
'max-nested-callbacks': ['warn', 3],
6868
// 强制关键字周围空格的一致性 关键字前后必须有空格

alias.config.js

+1-9
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,2 @@
11
const path = require('path');
2-
module.exports = {
3-
resolve: {
4-
alias: {
5-
'@': path.resolve(
6-
__dirname, 'src'
7-
)
8-
}
9-
}
10-
};
2+
module.exports = { resolve: { alias: { '@': path.resolve(__dirname, 'src') } } };

src/assets/js/formateLocaltion.js

+6-16
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,10 @@
11
const { log } = require('console');
22
const fs = require('fs');
33
const path = require('path');
4-
fs.readFile(
5-
path.resolve(
6-
__dirname, './location.json'
7-
), (
8-
err, data
9-
) => {
10-
if (err) throw err;
11-
formate(JSON.parse(data));
12-
}
13-
);
4+
fs.readFile(path.resolve(__dirname, './location.json'), (err, data) => {
5+
if (err) throw err;
6+
formate(JSON.parse(data));
7+
});
148

159
const formate = (locationJson) => {
1610
let arr = [];
@@ -50,9 +44,7 @@ const formate = (locationJson) => {
5044
cityList: []
5145
};
5246
if (item.label.includes('自治区')) {
53-
item.label = item.label.replace(
54-
/|||/, ''
55-
);
47+
item.label = item.label.replace(/|||/, '');
5648
}
5749
for (let cityKey in val.cities) {
5850
item.cityList.push({
@@ -67,9 +59,7 @@ const formate = (locationJson) => {
6759

6860
}
6961
fs.writeFile(
70-
path.resolve(
71-
__dirname, './region.json'
72-
), JSON.stringify(arr), (err) => {
62+
path.resolve(__dirname, './region.json'), JSON.stringify(arr), (err) => {
7363
if (err) throw err;
7464
console.log('写入成功');
7565
}

src/components/Base/CategoryTab.vue

+2-6
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,10 @@ const emit = defineEmits(['update:modelValue']);
1111
let activeIndex = ref(0);
1212
let categoryValue = ref(props.list[0]);
1313
14-
const handleClick = (
15-
item:string, index:number
16-
) => {
14+
const handleClick = (item:string, index:number) => {
1715
activeIndex.value = index;
1816
categoryValue.value = item;
19-
emit(
20-
'update:modelValue', item
21-
);
17+
emit('update:modelValue', item);
2218
};
2319
</script>
2420

src/components/Base/ListLoading.vue

+9-11
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,15 @@ export interface ListLoadingProps {
1111
loadMore?:(loadSuccess:() => void) => void;
1212
noMore:boolean,
1313
}
14-
const props = withDefaults(
15-
defineProps<ListLoadingProps>(), {
16-
wrapHeight: '40px',
17-
show: true,
18-
size: 'medium',
19-
strokeWidth: undefined,
20-
stroke: undefined,
21-
description: '',
22-
loadMore: () => {}
23-
}
24-
);
14+
const props = withDefaults(defineProps<ListLoadingProps>(), {
15+
wrapHeight: '40px',
16+
show: true,
17+
size: 'medium',
18+
strokeWidth: undefined,
19+
stroke: undefined,
20+
description: '',
21+
loadMore: () => {}
22+
});
2523
const loadingTarget = ref<HTMLElement | null>(null);
2624
let loadStatus:'pending' | 'loading' | 'done' = 'pending';// 当前加载状态锁
2725
let firstVisible = ref<boolean | undefined>(); // 首次显示的值

src/components/Base/LoadImg.vue

+3-5
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,9 @@ export default defineComponent({
6060
myPreviewDisabled.value = false;
6161
await nextTick();
6262
(e.target as HTMLElement).click();
63-
setTimeout(
64-
() => {
65-
myPreviewDisabled.value = true;
66-
}, 1000
67-
);
63+
setTimeout(() => {
64+
myPreviewDisabled.value = true;
65+
}, 1000);
6866
}
6967
};
7068
};

src/components/Base/SliderBar.vue

+12-34
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,12 @@
22
import { useElementHover } from '@vueuse/core';
33
import { useThemeVars } from 'naive-ui';
44
import { onMounted, onUnmounted, ref } from 'vue';
5-
const props = withDefaults(
6-
defineProps<{
5+
const props = withDefaults(defineProps<{
76
modelValue:number;
87
loadValue?:number;
98
width?:number;
109
height?:number;
11-
}>(), { width: 500, height: 4, loadValue: 0 }
12-
);
10+
}>(), { width: 500, height: 4, loadValue: 0 });
1311
let isTargetClick = ref(false);
1412
let startWidth = props.width * (props.modelValue / 100);
1513
const mousePosition = { y: 0, x: 0 };// 鼠标坐标
@@ -28,9 +26,7 @@ const handleSliderMouseDown = (e:MouseEvent) => {
2826
if (isTargetClick.value) return;
2927
let { offsetX } = e;
3028
let percentage = calcPercentage(offsetX);
31-
emit(
32-
'update:modelValue', percentage
33-
);
29+
emit('update:modelValue', percentage);
3430
startWidth = getProgressWidth(percentage);
3531
emit('change');
3632
emit('onDone');
@@ -46,13 +42,9 @@ const handleMouseMove = (e:MouseEvent) => {
4642
if (!isTargetClick.value) return;
4743
moveDiff.x += e.clientX - mousePosition.x;
4844
if (moveDiff.x > 0) {
49-
moveDiff.x = Math.min(
50-
props.width, moveDiff.x
51-
);
45+
moveDiff.x = Math.min(props.width, moveDiff.x);
5246
} else {
53-
moveDiff.x = Math.max(
54-
-props.width, moveDiff.x
55-
);
47+
moveDiff.x = Math.max(-props.width, moveDiff.x);
5648
}
5749
let value;
5850
if (e.clientX > mousePosition.x) {
@@ -61,12 +53,8 @@ const handleMouseMove = (e:MouseEvent) => {
6153
value = calcPercentage(startWidth + moveDiff.x);
6254
}
6355
if (value >= 0 && value <= 100 && value !== props.modelValue) {
64-
emit(
65-
'update:modelValue', value
66-
);
67-
emit(
68-
'change', value
69-
);
56+
emit('update:modelValue', value);
57+
emit('change', value);
7058
}
7159
mousePosition.x = e.clientX;
7260
};
@@ -96,23 +84,13 @@ const handleMouseOut = (evt:any) => {
9684
};
9785
const getProgressWidth = (percentage:number) => props.width * (percentage / 100);
9886
onMounted(() => {
99-
document.body.addEventListener(
100-
'mousemove', handleMouseMove
101-
);
102-
document.body.addEventListener(
103-
'mouseup', handleMouseUp
104-
);
105-
document.body.addEventListener(
106-
'mouseout', handleMouseOut
107-
);
87+
document.body.addEventListener('mousemove', handleMouseMove);
88+
document.body.addEventListener('mouseup', handleMouseUp);
89+
document.body.addEventListener('mouseout', handleMouseOut);
10890
});
10991
onUnmounted(() => {
110-
document.body.removeEventListener(
111-
'mousemove', handleMouseMove
112-
);
113-
document.body.removeEventListener(
114-
'mouseup', handleMouseUp
115-
);
92+
document.body.removeEventListener('mousemove', handleMouseMove);
93+
document.body.removeEventListener('mouseup', handleMouseUp);
11694
11795
});
11896

src/components/Base/VideoPlayer.vue

+8-12
Original file line numberDiff line numberDiff line change
@@ -41,20 +41,16 @@ defineExpose({
4141
}
4242
});
4343
44-
watch(
45-
() => props.url, (
46-
url, oldUrl
47-
) => {
48-
if (url && url !== oldUrl) {
49-
if (!player) {
50-
initPlayer();
51-
} else {
52-
player.src = url;
53-
player.reload();
54-
}
44+
watch(() => props.url, (url, oldUrl) => {
45+
if (url && url !== oldUrl) {
46+
if (!player) {
47+
initPlayer();
48+
} else {
49+
player.src = url;
50+
player.reload();
5551
}
5652
}
57-
);
53+
});
5854
onDeactivated(() => {
5955
player.pause();
6056
});

src/components/CommentList/CommentList.vue

+4-12
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,7 @@ export interface CommentListProps{
1111
commentTotalNum?:string|number;
1212
type?:number;//资源类型0: 歌曲 1: mv2: 歌单3: 专辑4: 电台5: 视频6: 动态
1313
}
14-
const props = withDefaults(
15-
defineProps<CommentListProps>(), { type: 1, commentTotalNum: 0 }
16-
);
14+
const props = withDefaults(defineProps<CommentListProps>(), { type: 1, commentTotalNum: 0 });
1715
const currentClickedComment = ref<any>();
1816
const emit = defineEmits(['updateCommentList', 'updateCommentLiked']);
1917
@@ -32,15 +30,11 @@ const handleClickComment = (index:number) => {
3230
};
3331
3432
const handleUpdateCommentList = (comment:any) => {
35-
emit(
36-
'updateCommentList', comment
37-
);
33+
emit('updateCommentList', comment);
3834
currentClickedComment.value = null;
3935
};
4036
// 点赞
41-
const handleLikedClick = (
42-
item:any, index:number
43-
) => {
37+
const handleLikedClick = (item:any, index:number) => {
4438
userCheckLogin(() => {
4539
let t = item.liked
4640
? 0
@@ -57,9 +51,7 @@ const handleLikedClick = (
5751
? '取消点赞成功'
5852
:' 点赞成功';
5953
window.$message.success(message);
60-
emit(
61-
'updateCommentLiked', { index, liked: t }
62-
);
54+
emit('updateCommentLiked', { index, liked: t });
6355
}
6456
});
6557
});

src/components/CommentList/RepliedCommentModal.vue

+2-4
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,15 @@ import { sendComment } from '@/service';
55
const showModal = ref(false);
66
const commentBtnLoading = ref(false);
77
const commentContent = ref('');
8-
const props = withDefaults(
9-
defineProps<{
8+
const props = withDefaults(defineProps<{
109
commentPlaceholder?:string;
1110
title:string;
1211
resourceId:number;//资源id
1312
type?:number;//资源类型0: 歌曲 1: mv2: 歌单3: 专辑4: 电台5: 视频6: 动态
1413
commentId?:number;
1514
t?:number;//评论类型1: 发送 2: 回复
1615
updateCommentList:(comment:any)=>void;
17-
}>(), { commentPlaceholder: '请输入评论', title: '评论', type: 1, commentId: 0, t: 2 }
18-
);
16+
}>(), { commentPlaceholder: '请输入评论', title: '评论', type: 1, commentId: 0, t: 2 });
1917
2018
defineExpose({
2119
show() {

src/components/Layout/Layout.vue

-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ onMounted(() => {
1616
dialog.info({
1717
title: '提示',
1818
content: '由于网易云接口限制,建议请先登录'
19-
2019
});
2120
}
2221
});

src/components/Layout/components/LayoutHeader.vue

+15-24
Original file line numberDiff line numberDiff line change
@@ -18,28 +18,22 @@ const userDetail = ref<AnyObject>();
1818
const showUserPopover = ref(false);
1919
const signBtnLoading = ref(false);
2020
21-
watch(
22-
() => active.value, () => {
23-
mainStore.changeTheme();
24-
}
25-
);
21+
watch(() => active.value, () => {
22+
mainStore.changeTheme();
23+
});
2624
// 监听登录状态 获取用户信息
27-
watch(
28-
() => mainStore.isLogin, (val) => {
29-
if (val) {
30-
getUserProfile();
31-
}
25+
watch(() => mainStore.isLogin, (val) => {
26+
if (val) {
27+
getUserProfile();
3228
}
33-
);
34-
onClickOutside(
35-
popoverContainerRef, (event:MouseEvent) => {
36-
let target = event.target as HTMLElement;
37-
// 如果点击的不是不是触发弹出选择的元素
38-
if (!target.classList.contains('trigger')) {
39-
showUserPopover.value = false;
40-
}
41-
}
42-
);
29+
});
30+
onClickOutside(popoverContainerRef, (event:MouseEvent) => {
31+
let target = event.target as HTMLElement;
32+
// 如果点击的不是不是触发弹出选择的元素
33+
if (!target.classList.contains('trigger')) {
34+
showUserPopover.value = false;
35+
}
36+
});
4337
// 获取用户账号数据
4438
const getUserProfile = () => {
4539
// 如果已经设置过,则从store读取userId
@@ -74,9 +68,7 @@ const checkLoginStatus = () => {
7468
});
7569
};
7670
const handlePositiveClick = () => {
77-
window.$message.loading(
78-
'退出登录中...', { duration: 0 }
79-
);
71+
window.$message.loading('退出登录中...', { duration: 0 });
8072
logout().then(res => {
8173
if (res.data.code === 200) {
8274
mainStore.isLogin = false;
@@ -114,7 +106,6 @@ if (mainStore.isLogin) {
114106
<span class=" truncate">奇妙音乐屋!</span>
115107
<layout-header-search />
116108
</div>
117-
118109
<div class="flex items-center">
119110
<!-- 用户信息入口 -->
120111
<div v-if="mainStore.isLogin">

0 commit comments

Comments
 (0)