|
@@ -21,16 +21,17 @@
|
|
|
<div id="editor"></div>
|
|
|
|
|
|
<!-- 添加多选按钮 -->
|
|
|
-<input type="checkbox" id="todo" name="category" value="todo" checked>
|
|
|
-<label for="todo">todo</label>
|
|
|
-<input type="checkbox" id="work" name="category" value="工作">
|
|
|
-<label for="work">工作</label>
|
|
|
-<input type="checkbox" id="diary" name="category" value="日记">
|
|
|
-<label for="diary">日记</label>
|
|
|
-<input type="checkbox" id="dream" name="category" value="梦记">
|
|
|
-<label for="dream">梦记</label>
|
|
|
-<input type="checkbox" id="daily" name="category" value="日常">
|
|
|
-<label for="daily">日常</label>
|
|
|
+<div id="tags"></div>
|
|
|
+<!--<input type="checkbox" id="todo" name="category" value="todo" checked> <label for="todo">todo</label>-->
|
|
|
+
|
|
|
+<!--<input type="checkbox" id="work" name="category" value="工作">-->
|
|
|
+<!--<label for="work">工作</label>-->
|
|
|
+<!--<input type="checkbox" id="diary" name="category" value="日记">-->
|
|
|
+<!--<label for="diary">日记</label>-->
|
|
|
+<!--<input type="checkbox" id="dream" name="category" value="梦记">-->
|
|
|
+<!--<label for="dream">梦记</label>-->
|
|
|
+<!--<input type="checkbox" id="daily" name="category" value="日常">-->
|
|
|
+<!--<label for="daily">日常</label>-->
|
|
|
|
|
|
<br>
|
|
|
<br>
|
|
@@ -41,6 +42,40 @@
|
|
|
<script src="./js/cdn.quilljs.com_1.3.6_quill.js"></script>
|
|
|
<!--异步请求示例:requestUtil.sync('https://jsonplaceholder.typicode.com/posts/1', 'post', data, headers) .then(data => console.log(data))-->
|
|
|
<script>
|
|
|
+ let authStr = "bearer eyJhbGciOiJIUzI1NiIsImtpZCI6InYxIiwidHlwIjoiSldUIn0.eyJuYW1lIjoidGlhbnl1bnBlcmZlY3QiLCJpc3MiOiJtZW1vcyIsInN1YiI6IjEiLCJhdWQiOlsidXNlci5hY2Nlc3MtdG9rZW4iXSwiaWF0IjoxNzA5MTc5NTUyfQ.LFxWB4efya1sL7VoJ42xpXxbAip-udT_Kx2OwZ8Y3-E";
|
|
|
+ let myHeaders = {
|
|
|
+ 'Content-type': 'application/json',
|
|
|
+ 'Authorization': authStr
|
|
|
+ };
|
|
|
+ // console.log(location.href)
|
|
|
+ // console.log(location.href.indexOf(tag))
|
|
|
+ // 设置多选按钮 标签
|
|
|
+ requestUtil.async('https://memos.tianyunperfect.cn/api/v1/tag', 'get', null, {'Authorization': authStr}).then(res => {
|
|
|
+ // console.log(res); ['tag1','tag2']
|
|
|
+ // 在 id tags 里面拼接res数组 ,示例todo标签 <input type="checkbox" id="todo" name="category" value="todo" checked> <label for="todo">todo</label>
|
|
|
+ let tags = document.getElementById('tags');
|
|
|
+ res.forEach(tag => {
|
|
|
+ let input = document.createElement('input');
|
|
|
+ // 如果是location.href 包含tag,则设置为选中状态, href 要反编译以识别中文
|
|
|
+ if (decodeURI(location.href).indexOf(tag) !== -1) {
|
|
|
+ input.checked = true;
|
|
|
+ }
|
|
|
+ input.type = 'checkbox';
|
|
|
+ input.id = tag;
|
|
|
+ input.name = 'category';
|
|
|
+ input.value = tag;
|
|
|
+ let label = document.createElement('label');
|
|
|
+ // 设置margin-right 20
|
|
|
+ label.style.marginRight = '10px';
|
|
|
+ label.htmlFor = tag;
|
|
|
+ label.innerText = tag;
|
|
|
+ tags.appendChild(input);
|
|
|
+ tags.appendChild(label);
|
|
|
+ });
|
|
|
+
|
|
|
+ });
|
|
|
+
|
|
|
+
|
|
|
const quill = new Quill('#editor', {
|
|
|
theme: 'snow', // 指定使用的主题
|
|
|
modules: {
|
|
@@ -140,17 +175,16 @@
|
|
|
};
|
|
|
|
|
|
// 发送异步请求
|
|
|
- requestUtil.async('https://memos.tianyunperfect.cn/api/v1/memo', 'post', data, {
|
|
|
- 'Content-type': 'application/json',
|
|
|
- 'Authorization': 'bearer eyJhbGciOiJIUzI1NiIsImtpZCI6InYxIiwidHlwIjoiSldUIn0.eyJuYW1lIjoidGlhbnl1bnBlcmZlY3QiLCJpc3MiOiJtZW1vcyIsInN1YiI6IjEiLCJhdWQiOlsidXNlci5hY2Nlc3MtdG9rZW4iXSwiaWF0IjoxNzA5MTc5NTUyfQ.LFxWB4efya1sL7VoJ42xpXxbAip-udT_Kx2OwZ8Y3-E'
|
|
|
- }).then(res => {
|
|
|
+ requestUtil.async('https://memos.tianyunperfect.cn/api/v1/memo', 'post', data, myHeaders).then(res => {
|
|
|
// alert(JSON.stringify(res));
|
|
|
if (res['name']) {
|
|
|
- window.location.href = `https://memos.tianyunperfect.cn/m/${res['name']}`;
|
|
|
+ // window.location.href = `https://memos.tianyunperfect.cn/m/${res['name']}`;
|
|
|
+ showMsg('记录成功', 1);
|
|
|
}
|
|
|
|
|
|
logBtn.disabled = false;
|
|
|
logBtn.innerText = '记录';
|
|
|
+ quill.root.innerHTML = '';
|
|
|
|
|
|
localStorage.removeItem(contentStr);
|
|
|
});
|