mirror of
https://github.com/Megghy/vtsuru.live.git
synced 2025-12-06 18:36:55 +08:00
feat: 更新组件和配置,增强功能和用户体验, 添加签到功能
- 在 .editorconfig 中调整文件格式设置,统一代码风格。 - 在 default.d.ts 中为 naive-ui 添加 TabPaneSlots 接口声明,增强类型支持。 - 在多个组件中优化了模板和样式,提升用户交互体验。 - 在 ClientAutoAction.vue 中新增签到设置标签页,丰富功能选项。 - 在 Utils.ts 中增强 GUID 处理逻辑,增加输入验证和错误处理。 - 更新多个组件的逻辑,简化代码结构,提升可读性和维护性。
This commit is contained in:
@@ -4,6 +4,7 @@ import { POINT_API_URL } from "@/data/constants";
|
||||
import { MessageApiInjection } from "naive-ui/es/message/src/MessageProvider";
|
||||
import { defineStore } from "pinia";
|
||||
import { useAuthStore } from "./useAuthStore";
|
||||
import { GuidUtils } from "@/Utils";
|
||||
|
||||
export const usePointStore = defineStore('point', () => {
|
||||
const useAuth = useAuthStore()
|
||||
@@ -41,9 +42,54 @@ export const usePointStore = defineStore('point', () => {
|
||||
}
|
||||
return []
|
||||
}
|
||||
/**
|
||||
* 给用户添加或扣除积分
|
||||
* @param userId 用户ID
|
||||
* @param count 积分数量(正数为增加,负数为减少)
|
||||
* @param reason 积分变动原因
|
||||
* @param remark 备注信息
|
||||
* @returns 成功时返回修改后的积分值,失败时返回null
|
||||
*/
|
||||
async function addPoints(userId: string, count: number, reason: string, remark?: string) {
|
||||
if (count === 0) {
|
||||
console.warn('[point] 积分变动数量不能为0');
|
||||
return null;
|
||||
}
|
||||
|
||||
try {
|
||||
// 根据用户ID构建参数
|
||||
const params: Record<string, any> = GuidUtils.isGuidFromUserId(userId) ? {
|
||||
uId: GuidUtils.guidToLong(userId),
|
||||
count: count,
|
||||
reason: reason || '',
|
||||
} : {
|
||||
oid: userId,
|
||||
count: count,
|
||||
reason: reason || '',
|
||||
};
|
||||
|
||||
if (remark) {
|
||||
params.remark = remark;
|
||||
}
|
||||
|
||||
const data = await QueryGetAPI<number>(POINT_API_URL + 'give-point', params);
|
||||
|
||||
if (data.code === 200) {
|
||||
console.log(`[point] 用户 ${userId} 积分${count > 0 ? '增加' : '减少'} ${Math.abs(count)} 成功,当前积分:${data.data}`);
|
||||
return data.data; // 返回修改后的积分值
|
||||
} else {
|
||||
console.error('[point] 积分操作失败:', data.message);
|
||||
return null;
|
||||
}
|
||||
} catch (err) {
|
||||
console.error('[point] 积分操作出错:', err);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
GetSpecificPoint,
|
||||
GetGoods
|
||||
GetGoods,
|
||||
addPoints
|
||||
}
|
||||
})
|
||||
Reference in New Issue
Block a user