feat: 3.5版本规划
This commit is contained in:
@@ -1,4 +1,10 @@
|
||||
import { getUser } from './auth';
|
||||
import tracker from './tracker';
|
||||
|
||||
function getCurrentPageRoute(): string {
|
||||
const pages = getCurrentPages();
|
||||
return pages[pages.length - 1]?.route || '';
|
||||
}
|
||||
|
||||
export interface FavoriteRecord {
|
||||
_id: string;
|
||||
@@ -31,7 +37,9 @@ export async function addFavorite(worksheetId: string): Promise<boolean> {
|
||||
data: { action: 'add', worksheetId },
|
||||
});
|
||||
const result = (res?.result as any) || {};
|
||||
return result.code === 0;
|
||||
const success = result.code === 0;
|
||||
if (success) tracker.reportFavorite(getCurrentPageRoute(), worksheetId, true);
|
||||
return success;
|
||||
} catch (e) {
|
||||
console.error('addFavorite failed', e);
|
||||
return false;
|
||||
@@ -49,7 +57,11 @@ export async function removeFavorite(worksheetId: string): Promise<boolean> {
|
||||
data: { action: 'remove', worksheetId },
|
||||
});
|
||||
const result = (res?.result as any) || {};
|
||||
return result.code === 0;
|
||||
const success = result.code === 0;
|
||||
if (success) {
|
||||
tracker.reportFavorite(getCurrentPageRoute(), worksheetId, false);
|
||||
}
|
||||
return success;
|
||||
} catch (e) {
|
||||
console.error('removeFavorite failed', e);
|
||||
return false;
|
||||
@@ -133,4 +145,3 @@ export async function batchCheckFavorited(
|
||||
return {};
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user