import auth from '@/services/auth';

const useUser = () => {
	/**
	 * 退出登录
	 */
	const logout = async () => {
		const response = await auth.userAuth.logout();

		if (response.success) {
			window.localStorage.removeItem('employee');
			window.localStorage.removeItem('admin');
			window.localStorage.removeItem('roleSlug');

			window.location.href =
				process.env.UMI_APP_SSO_LOGIN_URL +
				encodeURIComponent(process.env.UMI_APP_OPERATION_URL || '');
		}
	};

	return {
		logout,
	};
};

export default useUser;
