/**
 * 调试工具函数
 */

// 打印当前用户状态
export const logUserState = () => {
    console.group('用户状态');
    
    // 从localStorage获取状态
    const userData = localStorage.getItem('user');
    const token = localStorage.getItem('token');
    const isAuthor = localStorage.getItem('isAuthor');
    
    console.log('localStorage状态:');
    console.log('- token:', token ? '已设置' : '未设置');
    console.log('- isAuthor:', isAuthor);
    console.log('- user:', userData ? JSON.parse(userData) : null);
    
    // 从全局状态获取
    if (window.$pinia?.state?.value?.main) {
        const storeState = window.$pinia.state.value.main;
        console.log('Store状态:');
        console.log('- isLoggedIn:', storeState.isLoggedIn);
        console.log('- isAuthor:', storeState.isAuthor);
        console.log('- user:', storeState.user);
    } else {
        console.log('Store未初始化');
    }
    
    console.groupEnd();
};

// 导出全局调试对象
window.$debug = {
    logUserState
};

export default {
    logUserState
}; 