게시판 수정 페이지 비밀번호
This commit is contained in:
parent
5c39cb3dad
commit
60069ecaae
@ -13,28 +13,30 @@ export const useBoardAccessStore = defineStore(
|
||||
() => {
|
||||
const password = ref('');
|
||||
|
||||
// watch(password, newValue => {
|
||||
// localStorage.setItem('tempPassword', JSON.stringify(newValue.value));
|
||||
// });
|
||||
|
||||
if (localStorage.getItem('tempPassword')) {
|
||||
// 저장된 값을 불러와 상태에 할당
|
||||
const storedState = JSON.parse(localStorage.getItem('tempPassword'));
|
||||
password.value = storedState;
|
||||
const tempPassword = localStorage.getItem('tempPassword');
|
||||
if (typeof tempPassword === 'String') password.value = tempPassword;
|
||||
}
|
||||
|
||||
watch(password, newValue => {
|
||||
localStorage.setItem('tempPassword', JSON.stringify(newValue.value));
|
||||
});
|
||||
|
||||
function setBoardPassword(input) {
|
||||
password.value = input;
|
||||
if (typeof input === 'String') localStorage.setItem('tempPassword', input);
|
||||
}
|
||||
|
||||
function $reset() {
|
||||
password.value = '';
|
||||
localStorage.removeItem('tempPassword', newValue);
|
||||
localStorage.removeItem('tempPassword');
|
||||
}
|
||||
|
||||
return {
|
||||
password,
|
||||
setBoardPassword,
|
||||
getTempPassword,
|
||||
$reset,
|
||||
};
|
||||
},
|
||||
|
||||
@ -120,11 +120,10 @@
|
||||
// 게시물 데이터 로드
|
||||
const fetchBoardDetails = async () => {
|
||||
// 수정 데이터 전송
|
||||
const password = accessStore.password.value;
|
||||
const password = accessStore.password;
|
||||
const params = {
|
||||
password: password || '',
|
||||
};
|
||||
console.log('params: ', params);
|
||||
//const response = await axios.get(`board/${currentBoardId.value}`);
|
||||
const { data } = await axios.post(`board/${currentBoardId.value}`, params);
|
||||
|
||||
@ -154,6 +153,7 @@
|
||||
|
||||
// 목록 페이지로 이동
|
||||
const goList = () => {
|
||||
accessStore.$reset();
|
||||
router.push('/board');
|
||||
};
|
||||
|
||||
@ -228,38 +228,37 @@
|
||||
const updateBoard = async () => {
|
||||
if (checkValidation()) return;
|
||||
|
||||
try {
|
||||
// 수정 데이터 전송
|
||||
const boardData = {
|
||||
LOCBRDTTL: title.value.trim(),
|
||||
LOCBRDCON: JSON.stringify(content.value),
|
||||
LOCBRDSEQ: currentBoardId.value,
|
||||
};
|
||||
// 수정 데이터 전송
|
||||
const boardData = {
|
||||
LOCBRDTTL: title.value.trim(),
|
||||
LOCBRDCON: JSON.stringify(content.value),
|
||||
LOCBRDSEQ: currentBoardId.value,
|
||||
};
|
||||
|
||||
// 업로드 된 첨부파일의 삭제목록
|
||||
if (delFileIdx.value && delFileIdx.value.length > 0) {
|
||||
boardData.delFileIdx = [...delFileIdx.value];
|
||||
}
|
||||
// 업로드 된 첨부파일의 삭제목록
|
||||
if (delFileIdx.value && delFileIdx.value.length > 0) {
|
||||
boardData.delFileIdx = [...delFileIdx.value];
|
||||
}
|
||||
|
||||
const fileArray = newFileFilter(attachFiles);
|
||||
const formData = new FormData();
|
||||
const fileArray = newFileFilter(attachFiles);
|
||||
const formData = new FormData();
|
||||
|
||||
// formData에 boardData 추가
|
||||
Object.entries(boardData).forEach(([key, value]) => {
|
||||
formData.append(key, value);
|
||||
});
|
||||
// formData에 boardData 추가
|
||||
Object.entries(boardData).forEach(([key, value]) => {
|
||||
formData.append(key, value);
|
||||
});
|
||||
|
||||
// formData에 새로 추가한 파일 추가
|
||||
fileArray.forEach((file, idx) => {
|
||||
formData.append('files', file);
|
||||
});
|
||||
// formData에 새로 추가한 파일 추가
|
||||
fileArray.forEach((file, idx) => {
|
||||
formData.append('files', file);
|
||||
});
|
||||
|
||||
await axios.put(`board/${currentBoardId.value}`, formData, { isFormData: true });
|
||||
const { data } = await axios.put(`board/${currentBoardId.value}`, formData, { isFormData: true });
|
||||
if (data.code === 200 && data.data === true) {
|
||||
toastStore.onToast('게시물이 수정되었습니다.', 's');
|
||||
goList();
|
||||
} catch (error) {
|
||||
console.error('게시물 수정 중 오류 발생:', error);
|
||||
toastStore.onToast('게시물 수정에 실패했습니다.');
|
||||
} else {
|
||||
toastStore.onToast('게시물 수정에 실패했습니다.', 'e');
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@ -610,15 +610,13 @@
|
||||
}
|
||||
|
||||
try {
|
||||
const response = await axios.post(`board/${currentBoardId.value}/password`, {
|
||||
const { data } = await axios.post(`board/${currentBoardId.value}/password`, {
|
||||
LOCBRDPWD: password.value,
|
||||
LOCBRDSEQ: currentBoardId.value,
|
||||
});
|
||||
|
||||
if (response.data.code === 200 && response.data.data === true) {
|
||||
accessStore.setBoardPassword(password);
|
||||
console.log('password: ', password.value);
|
||||
console.log('accessStore.password: ', accessStore.password.value);
|
||||
if (data.code === 200 && data.data === true) {
|
||||
accessStore.setBoardPassword(password.value);
|
||||
boardPasswordAlert.value = '';
|
||||
isPassword.value = false;
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user