46 lines
1.2 KiB
JavaScript
46 lines
1.2 KiB
JavaScript
/*
|
|
작성자 : 박성용
|
|
작성일 : 2025-03-14
|
|
수정자 :
|
|
수정일 :
|
|
설명 : 게시글 수정 시 비밀번호 적재용.
|
|
*/
|
|
import { ref } from 'vue';
|
|
import { defineStore } from 'pinia';
|
|
|
|
export const useBoardAccessStore = defineStore(
|
|
'access',
|
|
() => {
|
|
const password = ref('');
|
|
|
|
// watch(password, newValue => {
|
|
// localStorage.setItem('tempPassword', JSON.stringify(newValue.value));
|
|
// });
|
|
|
|
if (localStorage.getItem('tempPassword')) {
|
|
// 저장된 값을 불러와 상태에 할당
|
|
const tempPassword = localStorage.getItem('tempPassword');
|
|
if (typeof tempPassword === 'string') password.value = JSON.parse(tempPassword);
|
|
}
|
|
|
|
function setBoardPassword(input) {
|
|
password.value = input;
|
|
if (typeof input === 'string') JSON.stringify(localStorage.setItem('tempPassword', input));
|
|
}
|
|
|
|
function $reset() {
|
|
password.value = '';
|
|
localStorage.removeItem('tempPassword');
|
|
}
|
|
|
|
return {
|
|
password,
|
|
setBoardPassword,
|
|
$reset,
|
|
};
|
|
},
|
|
{
|
|
persist: true,
|
|
},
|
|
);
|