feat: 增加判断用户是否为创建者的逻辑,优化收藏功能
This commit is contained in:
parent
bae9098fed
commit
8eeea1742a
@ -240,10 +240,21 @@ function onSearchInput() {
|
||||
|
||||
function canToggleFavorite(plan) {
|
||||
if (!plan || !plan._id) return false;
|
||||
if (isCreatedByCurrentUser(plan)) return false;
|
||||
if (activeViewType.value !== 'my') return true;
|
||||
return Boolean(plan.isFavorite);
|
||||
}
|
||||
|
||||
function isCreatedByCurrentUser(plan = {}) {
|
||||
const userId = getUserId();
|
||||
if (!userId) return false;
|
||||
if (String(plan.createor || plan.creator || '') === userId) return true;
|
||||
const signature = plan.creatorSignature && typeof plan.creatorSignature === 'object'
|
||||
? plan.creatorSignature
|
||||
: null;
|
||||
return signature?.type === 'personal' && String(signature.person?.userId || '') === userId;
|
||||
}
|
||||
|
||||
async function toggleFavorite(plan) {
|
||||
const corpId = getCorpId();
|
||||
const userId = getUserId();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user