This commit is contained in:
nevermoregb 2025-03-14 16:16:37 +09:00
parent f761e3e15e
commit 74be397b5d
3 changed files with 49 additions and 2 deletions

View File

@ -0,0 +1,27 @@
/*
작성자 : 박성용
작성일 : 2025-03-14
수정자 :
수정일 :
설명 : 게시글 수정 비밀번호 적재용.
*/
import { ref, computed } from 'vue';
import { defineStore } from 'pinia';
export const useBoardAccessStore = defineStore('access', () => {
const password = ref(null);
function setBoardPassword(input) {
password.value = input;
}
function $reset() {
password.value = null;
}
return {
password,
setBoardPassword,
$reset,
};
});

View File

@ -85,11 +85,13 @@
import { ref, onMounted, computed, watch, inject } from 'vue';
import { useRoute, useRouter } from 'vue-router';
import { useToastStore } from '@s/toastStore';
import { useBoardAccessStore } from '@s/useBoardAccessStore';
import axios from '@api';
//
const $common = inject('common');
const toastStore = useToastStore();
const accessStore = useBoardAccessStore();
//
const title = ref('');
@ -118,9 +120,18 @@
//
const fetchBoardDetails = async () => {
try {
const response = await axios.get(`board/${currentBoardId.value}`);
const data = response.data.data;
//
const params = {
password: accessStore.password?.value || '',
};
//const response = await axios.get(`board/${currentBoardId.value}`);
const response = await axios.post(`board/${currentBoardId.value}`, params);
if (response.data.code !== 200) {
toastStore.onToast(response.data.message, 'e');
router.go(-1);
}
const data = response.data.data;
//
if (data.hasAttachment && data.attachments.length > 0) {
attachFiles.value = addDisplayFileName([...data.attachments]);

View File

@ -137,7 +137,9 @@
import { useRoute, useRouter } from 'vue-router';
import { useUserInfoStore } from '@/stores/useUserInfoStore';
import { useToastStore } from '@s/toastStore';
import { useBoardAccessStore } from '@s/useBoardAccessStore';
import axios from '@api';
//
const profileName = ref('');
const boardTitle = ref('제목 없음');
@ -157,6 +159,8 @@
const router = useRouter();
const userStore = useUserInfoStore();
const toastStore = useToastStore();
const accessStore = useBoardAccessStore();
const currentBoardId = ref(Number(route.params.id));
const unknown = computed(() => profileName.value === '익명');
const currentUserId = computed(() => userStore?.user?.id); // id
@ -598,14 +602,19 @@
});
if (response.data.code === 200 && response.data.data === true) {
accessStore.setBoardPassword(password);
console.log('password: ', password.value);
console.log('accessStore.password: ', accessStore.password.value);
boardPasswordAlert.value = '';
isPassword.value = false;
if (lastClickedButton.value === 'edit') {
router.push({ name: 'BoardEdit', params: { id: currentBoardId.value } });
return;
} else if (lastClickedButton.value === 'delete') {
await deletePost();
}
accessStore.$reset();
lastClickedButton.value = null;
} else {
boardPasswordAlert.value = '비밀번호가 일치하지 않습니다.';