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