chore(buyer): 落地 ESLint 9 并清理调试代码

- 新增 eslint.config.js(flat config, vue3-essential),移除废弃的 .eslintrc.js/.eslintignore(引用已废弃的 babel-eslint),package.json 增加 lint/lint:fix 脚本
- 清理 17 处调试 console.log;修复 24 处空 catch(15 处补 console.warn 业务提示,9 处加注释说明可安全忽略)
- 修复存量 lint error:9 处 prop 默认值改为函数形式、3 处未使用组件、1 处 v-if/v-for 同级、1 处空 else
- vue.config.js 生产环境 terser 开启 drop_console 兜底
This commit is contained in:
pikachu1995@126.com
2026-10-09 09:45:59 +08:00
parent 3ec3f11d5b
commit 89711af0e6
40 changed files with 630 additions and 98 deletions

View File

@@ -58,10 +58,14 @@ export default {
// 站点配置解析失败时使用缓存
}
}
}).catch(() => {});
}).catch((err) => {
console.warn('获取站点配置失败', err);
});
},
getTheme() {
fetchAndApplyTheme(getThemeSetting).catch(() => {});
fetchAndApplyTheme(getThemeSetting).catch((err) => {
console.warn('获取主题配置失败', err);
});
},
},
};

View File

@@ -242,7 +242,9 @@ export default {
loadHotWords() {
hotWords({ count: 5 }).then((res) => {
if (res.success && res.result) this.applyHotWords(res.result)
}).catch(() => {})
}).catch(() => {
// 热词为可选数据,失败时沿用缓存或默认热词
})
storage.setItem('hotWordsReloadTime', new Date().getTime())
}
},

View File

@@ -119,7 +119,6 @@ export default {
// 获取地址详情
getAddrDetail(id).then((res) => {
if (res.success) {
console.log(res);
const data = res.result;
data.address = res.result.consigneeAddressPath.replace(/,/g, ' ');
this.formData = data;

View File

@@ -136,7 +136,9 @@ export default {
loadStore(id) {
getStoreById(id).then((res) => {
if (res.success && res.result) this.store = res.result;
}).catch(() => {});
}).catch((err) => {
console.warn('获取店铺信息失败', err);
});
},
// 按销量取店内商品,去掉当前商品,最多 4 个
loadRecommend(id) {
@@ -151,14 +153,18 @@ export default {
this.recommends = records
.filter((item) => String(item.goodsId) !== String(this.goodsId))
.slice(0, 4);
}).catch(() => {});
}).catch(() => {
// 推荐商品为可选数据,加载失败时静默
});
},
// 同时有 token 和用户信息才查收藏,避免残留 userInfo 触发登录跳转
loadCollected(id) {
if (!this.Cookies.getItem("accessToken") || !this.Cookies.getItem("userInfo")) return;
isStoreCollection("STORE", id).then((res) => {
if (res.success && res.result) this.collected = true;
}).catch(() => {});
}).catch(() => {
// 收藏状态为可选数据,失败时静默
});
},
goStore() {
this.$router.push({ path: "/merchant", query: { id: this.storeId } });

View File

@@ -28,6 +28,8 @@
userInfo.nickName ? userInfo.nickName : userInfo.username ) }}</span>
</div>
<transition name='fade'>
<!-- 下拉菜单通过父级 hover 的 CSS 控制显隐,transition 内无需 v-if/v-show -->
<!-- eslint-disable-next-line vue/require-toggle-inside-transition -->
<ul class="drop-items">
<li @click="goUserCenter('/home')">我的主页</li>
<li @click="goUserCenter('/home/Coupons')">优惠券</li>

View File

@@ -63,7 +63,7 @@ export default {
props: {
data: {
type: Object,
default: {}
default: () => ({})
}
},
data () {

View File

@@ -55,7 +55,7 @@ export default {
props: {
data: {
type: Object,
default: {},
default: () => ({}),
},
},

View File

@@ -15,9 +15,8 @@
</div>
</div>
<!-- 商品部分 -->
<div class="only-goods-list flex-j-sb">
<div class="only-goods-list flex-j-sb" v-if="paramData.options">
<div
v-if="paramData.options"
class="only-goods-list-item "
v-for="(item, index) in paramData.options.list.filter((client) => {
return client.___index == current;
@@ -50,7 +49,7 @@ export default {
props: {
paramData: {
type: Object,
default: {},
default: () => ({}),
},
},
data() {

View File

@@ -22,7 +22,7 @@ export default {
props: {
data: {
type: Object,
default: {}
default: () => ({})
}
},
components: {

View File

@@ -17,7 +17,7 @@ export default {
props: {
data: {
type: Object,
default: {}
default: () => ({})
}
},
data () {

View File

@@ -28,7 +28,7 @@ export default {
props: {
data: {
type: Object,
default: {},
default: () => ({}),
},
},
data() {

View File

@@ -117,7 +117,9 @@ export default {
that.addrContent = positionResult;
});
})
.catch((e) => { });
.catch((e) => {
console.warn('地图组件加载失败', e);
});
},
searchOfMap(val) {
// 地图搜索

View File

@@ -176,7 +176,9 @@ export default {
// 存放分类信息
localStorage.setItem("category", JSON.stringify(res.result));
}
}).catch(() => {});
}).catch((err) => {
console.warn('获取分类失败', err);
});
},
showDetail(index) {
// 展示全部分类

View File

@@ -244,7 +244,6 @@
<script>
import { Message, Modal } from "@/utils/message";
import Promotion from "@/components/goodsDetail/Promotion";
import Search from "@/components/Search";
import * as APICart from "@/api/cart";
import * as APIMember from "@/api/member";
import { isECoupon } from "@/constants/goodsType";
@@ -255,7 +254,6 @@ export default {
next();
},
components: {
Search,
Promotion,
},
data() {

View File

@@ -137,7 +137,9 @@ export default {
},
});
})
.catch(() => {});
.catch((err) => {
console.warn('领取优惠券失败', err);
});
},
// 发行量已领完
isFinished(item) {

View File

@@ -171,7 +171,7 @@ export default {
Message.warning(res.message);
}
}).catch(() => { this.loading = false; });
} else {}
}
});
},
handleSubmit () { // 提交密码
@@ -189,7 +189,6 @@ export default {
apiLogin.resetPassword(params).then(res => {
this.loading1 = false;
console.log(res);
if (res.success) {
Message.success('修改密码成功');
this.$router.push('login');

View File

@@ -78,7 +78,6 @@ export default {
: this.Cookies.getItem("distributionId");
// 如果有分销信息
if (distributionId) {
console.log(distributionId);
// 先存储
this.Cookies.setItem("distributionId", params.distributionId);
let _this = this;

View File

@@ -265,7 +265,9 @@ export default {
.then((res) => {
if (res.success) this.recommendList = res.result.records || [];
})
.catch(() => {});
.catch(() => {
// 推荐列表为可选数据,加载失败不阻塞搜索页
});
},
getParams(val) {
// 筛选条件回显

View File

@@ -42,7 +42,6 @@
</template>
<script>
import { InfoFilled } from '@element-plus/icons-vue';
import Search from '@/components/Search';
import ModelForm from '@/components/indexDecorate/ModelForm';
import HoverSearch from '@/components/header/hoverSearch';
@@ -145,14 +144,18 @@ export default {
}
storage.setItem('getTimes',datas)//存储缓存
}
}).catch(() => {});
}).catch((err) => {
console.warn('获取自动发券信息失败', err);
});
},
handleReachBottom(){
} ,
getIndexData () {
if(this.pageData){
this.parsePageData(JSON.stringify(this.pageData)).catch(() => {});
this.parsePageData(JSON.stringify(this.pageData)).catch(() => {
// 装修数据解析失败时保持默认空楼层
});
}
else{
// 获取首页装修数据
@@ -164,7 +167,9 @@ export default {
// 装修数据解析失败时保持默认空楼层
}
}
}).catch(() => {});
}).catch((err) => {
console.warn('获取首页装修数据失败', err);
});
}
},
@@ -212,7 +217,7 @@ export default {
components: { Search,
ModelForm,
HoverSearch,
fixedBar, InfoFilled }
fixedBar }
};
</script>

View File

@@ -206,7 +206,9 @@ export default {
} else {
Message.error(res.message);
}
}).catch(() => {});
}).catch((err) => {
console.warn('短信登录失败', err);
});
}
}
});

View File

@@ -133,7 +133,6 @@ import {
import {goodsList} from "@/api/goods";
import Search from "@/components/Search";
import ModelForm from "@/components/indexDecorate/ModelForm";
import HoverSearch from "@/components/header/hoverSearch";
import storage from "@/plugins/storage";
import {getFloorStoreData} from "@/api/index.js";
import { seckillByDay } from "@/api/promotion";
@@ -141,7 +140,7 @@ import imTalk from '@/components/mixes/talkIm'
export default {
name: "Merchant",
components: { Search, ModelForm, HoverSearch, StarFilled, ArrowDown },
components: { Search, ModelForm, StarFilled, ArrowDown },
mixins: [imTalk],
data() {
return {
@@ -249,7 +248,9 @@ export default {
this.storeCollected = true;
}
})
.catch(() => {});
.catch(() => {
// 收藏状态查询失败不影响店铺页展示,静默处理
});
},
getStoreMsg() {
const storeId = this.$route.query.id;
@@ -283,7 +284,6 @@ export default {
getCateById(this.$route.query.id).then((res) => {
if (res.success) {
this.cateList = res.result;
console.log(this.cateList,'cateList')
}
});
},
@@ -296,7 +296,8 @@ export default {
this.total = res.result.total;
}
})
.catch(() => {
.catch((err) => {
console.warn('获取商品列表失败', err);
});
},
goGoodsDetail(skuId, goodsId) {
@@ -309,7 +310,6 @@ export default {
},
search(val) {
// 搜索本店商品
console.log(val);
this.params.keyword = val;
this.getGoodsList();
},

View File

@@ -158,8 +158,12 @@ export default {
} else {
Message.warning(res.message || '注册失败');
}
}).catch(() => {});
}).catch(() => {});
}).catch((err) => {
console.warn('注册请求失败', err);
});
}).catch(() => {
// 表单校验使用回调模式,此 catch 仅为兜底
});
},
// 发送短信验证码
sendCode () {

View File

@@ -23,7 +23,6 @@ export default {
async init(id) {
const res = await getTopicData(id)
if (res.success) {
console.log(res.result)
// 直接复用首页就行
if (res.result.pageData) {
this.pageData = JSON.parse(res.result.pageData)

View File

@@ -186,7 +186,6 @@ export default {
this.buynow(item.skuId, item.goodsId)
},
buynow(skuId, goodsId,storeId) { // 跳转详情
console.log(this.params.type)
let url
if (this.params.type === 'STORE') {
url = this.$router.resolve({

View File

@@ -156,7 +156,9 @@ export default {
try {
const userInfo = JSON.parse(rawUserInfo);
if (userInfo && userInfo.mobile) this.mobile = userInfo.mobile;
} catch (e) {}
} catch {
// 缓存的用户信息解析失败时忽略,改走接口获取
}
}
if (!storage.getItem('accessToken')) return;
getMemberMsg().then(res => {
@@ -164,7 +166,9 @@ export default {
storage.setItem('userInfo', res.result);
this.mobile = res.result.mobile || '';
}
}).catch(() => {});
}).catch((err) => {
console.warn('获取会员信息失败', err);
});
},
normalizePwdError (message) {
if (!message) return '修改失败,请稍后重试';

View File

@@ -54,7 +54,9 @@ export default {
this.detail = res.result
sessionStorage.setItem(CACHE_KEY, JSON.stringify(res.result))
}
}).catch(() => {}).finally(() => {
}).catch((err) => {
console.warn('获取消息详情失败', err)
}).finally(() => {
this.loaded = true
this.markRead()
})
@@ -76,7 +78,9 @@ export default {
this.detail.status = 'ALREADY_READY'
refreshUnreadMessage()
}
}).catch(() => {})
}).catch(() => {
// 标记已读为尽力而为操作,失败可忽略
})
},
goBack () {
this.$router.push({ name: 'MsgList' })

View File

@@ -111,7 +111,6 @@ export default {
// 获取地址详情
getAddrDetail(id).then((res) => {
if (res.success) {
console.log(res);
const data = res.result;
data.address = res.result.consigneeAddressPath.replace(/,/g, " ");
this.formData = data;

View File

@@ -113,7 +113,6 @@ export default {
data () {
const checkNum = (rule, value, callback) => {
if (value === '') {
console.log(RegExp);
callback(new Error('请填写提交数量'));
} else if (value > this.info.num) {
callback(new Error('提交数量不能大于购买数量'));

View File

@@ -78,7 +78,6 @@ export default {
getAddrList () {
// 获取地址列表
memberAddress().then((res) => {
console.log(res);
if (res.success) {
this.list = res.result.records;
}

View File

@@ -260,7 +260,9 @@ export default {
this.getList();
}
})
.catch(() => {})
.catch((err) => {
console.warn('激活礼品卡失败', err);
})
.finally(() => {
this.activatingId = "";
});

View File

@@ -205,7 +205,7 @@ export default {
emits: ['change'],
props: {
content: {
default: {},
default: () => ({}),
type: Object
}
},
@@ -311,8 +311,6 @@ export default {
.catch(() => {
this.loading = false;
});
} else {
console.log('error');
}
});
},

View File

@@ -46,7 +46,7 @@ export default {
emits: ['change'],
props: {
content: {
default: {},
default: () => ({}),
type: Object
}
},
@@ -84,8 +84,6 @@ export default {
.catch(() => {
this.loading = false;
});
} else {
console.log('error');
}
});
}

View File

@@ -168,7 +168,9 @@ export default {
if (res.success && res.result) {
this.assignApplyData(res.result);
}
}).catch(() => {});
}).catch((err) => {
console.warn('获取入驻申请状态失败', err);
});
},
// 下一步:先拉最新申请数据,再切步骤,避免第三步挂载后再改 content 触发校验
async nextPage(step) {

View File

@@ -109,7 +109,7 @@ export default {
emits: ['change'],
props: {
content: {
default: {},
default: () => ({}),
type: Object
}
},
@@ -164,8 +164,6 @@ export default {
.catch(() => {
this.loading = false;
});
} else {
console.log('error');
}
});
},