const toBool = (val) => {
return [
false, 'false', '', null, 'null', undefined, 'undefined',
'0', 0, 'no', 'n', 'off', 'nao', 'não', 'no', 'n', 'off',
].includes(val);
}
const expandDebugContent_FromLs = () => {
if (typeof localStorage !== 'undefined') {
return toBool(localStorage?.getItem('expandDebugContent'), false);
}
return null;
};
// -------------- most important
const expandDebugContent = useState('expandDebugContent', expandDebugContent_FromLs);
if (expandDebugContent.value === null) {
expandDebugContent.value = expandDebugContent_FromLs();
}
watch(
() => expandDebugContent.value,
() => {
if (typeof localStorage !== 'undefined') {
localStorage.setItem('expandDebugContent', expandDebugContent.value);
}
}
)
// -------------- most important end
Last active
June 24, 2025 16:46
-
-
Save tiagofrancafernandes/685adf700ea85e830ba969bed6ca86b3 to your computer and use it in GitHub Desktop.
dev-nuxt Snippets
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment