🐛 修复新建节点后没有自动清空
This commit is contained in:
1 parent
7bb0124bbe
commit
787502b88d
1 file changed
+8
-6
@@ -5,7 +5,7 @@
|
|||||||
*/
|
*/
|
||||||
async function getNode(token, id) {
|
async function getNode(token, id) {
|
||||||
try {
|
try {
|
||||||
obj = { "pid": String(id) }
|
obj = { "pid": id }
|
||||||
jsonBody = JSON.stringify(obj)
|
jsonBody = JSON.stringify(obj)
|
||||||
console.log(jsonBody)
|
console.log(jsonBody)
|
||||||
const res = await fetch('/get_notes', {
|
const res = await fetch('/get_notes', {
|
||||||
@@ -55,7 +55,7 @@ async function getNode(token, id) {
|
|||||||
async function addNode(token, pid, title, content) {
|
async function addNode(token, pid, title, content) {
|
||||||
try {
|
try {
|
||||||
obj = {
|
obj = {
|
||||||
"pid": String(pid),
|
"pid": pid,
|
||||||
"title": title,
|
"title": title,
|
||||||
"content": content
|
"content": content
|
||||||
}
|
}
|
||||||
@@ -82,9 +82,11 @@ async function addNode(token, pid, title, content) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!res.ok) {
|
if (!res.ok) {
|
||||||
throw new Error(result.message || `添加节点失败(HTTP ${res.status})`);
|
throw new Error(`添加节点失败(HTTP ${res.status})`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
input_note_title.value = "";
|
||||||
|
input_note_content.value = "";
|
||||||
getNode(token, stack[stack.length - 1]).then(load_notes);
|
getNode(token, stack[stack.length - 1]).then(load_notes);
|
||||||
|
|
||||||
//if (result.success) {
|
//if (result.success) {
|
||||||
@@ -105,7 +107,7 @@ async function addNode(token, pid, title, content) {
|
|||||||
|
|
||||||
async function deleteNode(token, id) {
|
async function deleteNode(token, id) {
|
||||||
try {
|
try {
|
||||||
obj = {"id": String(id)};
|
obj = {"id": id};
|
||||||
jsonBody = JSON.stringify(obj);
|
jsonBody = JSON.stringify(obj);
|
||||||
console.log(jsonBody);
|
console.log(jsonBody);
|
||||||
|
|
||||||
@@ -169,8 +171,8 @@ input_note_submit.addEventListener('click', function(event) {
|
|||||||
var title = input_note_title.value
|
var title = input_note_title.value
|
||||||
var content = input_note_content.value
|
var content = input_note_content.value
|
||||||
var pid = (stack.length == 0) ? 0 : stack[stack.length - 1];
|
var pid = (stack.length == 0) ? 0 : stack[stack.length - 1];
|
||||||
alert(stack.length)
|
//alert(stack.length)
|
||||||
alert(pid)
|
//alert(pid)
|
||||||
addNode(token, pid, title, content).then(result => {
|
addNode(token, pid, title, content).then(result => {
|
||||||
alert(result.message);
|
alert(result.message);
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in new issue
Block a user