1
0
mirror of https://github.com/BoostIo/Boostnote synced 2025-12-14 10:16:26 +00:00

rebase and prefer const in node list

This commit is contained in:
lurong
2018-02-25 22:50:51 +08:00
parent 97600e526b
commit aef603ed8c

View File

@@ -681,13 +681,14 @@ class NoteList extends React.Component {
const selectedNotes = findNotesByKeys(notes, selectedNoteKeys) const selectedNotes = findNotesByKeys(notes, selectedNoteKeys)
const firstNote = selectedNotes[0] const firstNote = selectedNotes[0]
const config = ConfigManager.get() const config = ConfigManager.get()
let {address, token, authMethod, username, password} = config.blog const {address, token, authMethod, username, password} = config.blog
let authToken = ''
if (authMethod === 'USER') { if (authMethod === 'USER') {
token = `Basic ${window.btoa(`${username}:${password}`)}` authToken = `Basic ${window.btoa(`${username}:${password}`)}`
} else { } else {
token = `Bearer ${token}` authToken = `Bearer ${token}`
} }
let contentToRender = firstNote.content.replace(`# ${firstNote.title}`, '') const contentToRender = firstNote.content.replace(`# ${firstNote.title}`, '')
var data = { var data = {
title: firstNote.title, title: firstNote.title,
content: markdown.render(contentToRender), content: markdown.render(contentToRender),
@@ -708,7 +709,7 @@ class NoteList extends React.Component {
method: method, method: method,
body: JSON.stringify(data), body: JSON.stringify(data),
headers: { headers: {
'Authorization': token, 'Authorization': authToken,
'Content-Type': 'application/json' 'Content-Type': 'application/json'
} }
}).then(res => res.json()) }).then(res => res.json())