no message

This commit is contained in:
CN32479-詹红柱 2021-08-19 11:55:05 +08:00
parent adb4e7f031
commit 84f308f94e
3 changed files with 25 additions and 2 deletions

View File

@ -3,10 +3,12 @@ import AV from 'leancloud-storage'
export const saveObject = (className, params) => { export const saveObject = (className, params) => {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
const Todo = AV.Object.extend(className) const Todo = AV.Object.extend(className)
const user = AV.User.current()
var todo = new Todo() var todo = new Todo()
for (var i in params) { for (var i in params) {
todo.set(i, params[i]) todo.set(i, params[i])
} }
todo.set(user, user)
todo.save().then((res) => { todo.save().then((res) => {
resolve(res) resolve(res)
}, (error) => { }, (error) => {
@ -20,11 +22,13 @@ export const getObject = (className, params) => {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
const query = new AV.Query(className) const query = new AV.Query(className)
// 查询多个条件 // 查询多个条件
const user = AV.User.current()
for (const v in params) { for (const v in params) {
if (params[v]) { if (params[v]) {
query.equalTo(v, params[v]) query.equalTo(v, params[v])
} }
} }
query.equalTo('user', user)
query.find().then((res) => { query.find().then((res) => {
resolve(res) resolve(res)
}, (error) => { }, (error) => {

View File

@ -82,7 +82,7 @@ import Dialog from './components/Dialog.vue'
import Login from './components/Login.vue' import Login from './components/Login.vue'
import gsap from 'gsap' import gsap from 'gsap'
import { ElMessage, ElMessageBox } from 'element-plus' import { ElMessage, ElMessageBox } from 'element-plus'
import { importBookmark, exportBookmark } from './components/utils.js' import { importBookmark, exportBookmark, getRemoteList } from './components/utils.js'
import Cookie from 'js-cookie' import Cookie from 'js-cookie'
import Api from './Api/user.js' import Api from './Api/user.js'
var rowData = [] var rowData = []
@ -125,7 +125,7 @@ export default {
username: '未登录' username: '未登录'
} }
}) })
//
const setUsername = () => { const setUsername = () => {
if (Cookie.get('userInfo')) { if (Cookie.get('userInfo')) {
data.userInfo = JSON.parse(Cookie.get('userInfo')) data.userInfo = JSON.parse(Cookie.get('userInfo'))
@ -135,6 +135,8 @@ export default {
} }
setUsername() setUsername()
getRemoteList()
// //
watch( watch(
() => data.searchVal, () => data.searchVal,

View File

@ -1,3 +1,6 @@
import {saveObject, getObject} from '../Api/common.js'
import { ElMessage } from 'element-plus'
function walkBookmarksTree(root) { function walkBookmarksTree(root) {
const result = [] const result = []
// 深度优先遍历 // 深度优先遍历
@ -61,6 +64,13 @@ export function importBookmark() {
reader.onload = function () { reader.onload = function () {
mybookmark.innerHTML = reader.result mybookmark.innerHTML = reader.result
console.log(walkBookmarksTree(mybookmark)) console.log(walkBookmarksTree(mybookmark))
const formDatas = localStorage.getItem('BOOKMARK')
const params = {formDatas: formDatas}
console.log(params)
saveObject('BOOKMARK', params).then(res => {
console.log('导入成功', res)
ElMessage.success('导入成功')
})
// const myData = walkBookmarksTree(mybookmark) // const myData = walkBookmarksTree(mybookmark)
// myData && localStorage.setItem('BOOKMARK', myData) // myData && localStorage.setItem('BOOKMARK', myData)
} }
@ -85,3 +95,10 @@ export function exportBookmark() {
this.$message.warning('暂无可导出数据') this.$message.warning('暂无可导出数据')
} }
} }
// 获取远程书签
export const getRemoteList = () => {
getObject('BOOKMARK').then(res => {
console.log('获取书签', res)
})
}