feat: 增加判断用户是否为创建者的逻辑,优化收藏功能
This commit is contained in:
parent
bae9098fed
commit
8eeea1742a
@ -240,10 +240,21 @@ function onSearchInput() {
|
|||||||
|
|
||||||
function canToggleFavorite(plan) {
|
function canToggleFavorite(plan) {
|
||||||
if (!plan || !plan._id) return false;
|
if (!plan || !plan._id) return false;
|
||||||
|
if (isCreatedByCurrentUser(plan)) return false;
|
||||||
if (activeViewType.value !== 'my') return true;
|
if (activeViewType.value !== 'my') return true;
|
||||||
return Boolean(plan.isFavorite);
|
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) {
|
async function toggleFavorite(plan) {
|
||||||
const corpId = getCorpId();
|
const corpId = getCorpId();
|
||||||
const userId = getUserId();
|
const userId = getUserId();
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user