使用electron+Dexie.js在mac上运行很慢,在windows上运行流畅?

使用electron+Dexie.js在mac上运行很慢,在windows上运行流畅?

为什么使用electron+electron-vue+Dexie.js在mac上运行很慢(占用cpu90%,且很不稳定),在windows上运行流畅?

希望大佬们给点建议

-- 问题是一涉及到数据库操作,占用率直接就炸了

部分代码

--db.js

import Dexie from 'dexie';

export class User extends Dexie {

static getInstance(name) {

return new User(name)

}

constructor(name) {

// run the super constructor Dexie(databaseName) to create the IndexedDB

// database.

super(name || `User`);

this.version(1).stores({

chatInRooms: 'roomIdAndId,roomId,topStatus,msgDoNotDisturb,avatar,resend,isFirst,lastReadMsgId,isOffLineMsg,logo,msg,msgCount,nikeName,name,msgType,sendTime,msgId,unReadNum',

chatLocalMsg: 'msgId,roomIdAndId,isTips,isMine,msg,msgType,isRead,isResending,replyType,sendTime,photo,nikeName,redStatus',

});

this.open()

this.chatInRooms = this.table('chatInRooms')

this.chatLocalMsg = this.table('chatLocalMsg')

}

}

import { User, realDBName } from "./db";

export default class chatLocalMsgDAO {

static getInstance() {

return new chatLocalMsgDAO();

}

getUserInstance() {

let name = realDBName();

return User.getInstance(name);

}

newInfo() {

return this.getUserInstance().chatLocalMsg;

}

get(option = {}) {

let order = option.order || "msgId";

return this.newInfo()

.orderBy(order)

.reverse()

.toArray();

}

add(item) {

this.find(item.msgId).then((result) => {

if (!result) {

return this.newInfo().add({...item });

} else {

//return this.newInfo().update(item.msgId, { ...item });

}

})

}

}

--使用

let getInstance = chatLocalMsgDAO.getInstance();

getInstance.find(offLineData.msgId).then(result => {

if (!result) {

offLineData.roomId = zid

offLineData.id = zid

offLineData.roomIdAndId = setRoomIdsId(offLineData.roomId, offLineData.roomType)

chatLocalMsgDAO.getInstance().add(offLineData);

Bus.$emit("imgList", offLineData.roomIdAndId)

getInstance

.get()

.then((result) => {})

.catch((e) => {

console.log("err_or: ", e);

});

}

})


回答:

信息太少,无法判断。建议先想办法把高占用率稳定重现出来,然后想办法修复。

以上是 使用electron+Dexie.js在mac上运行很慢,在windows上运行流畅? 的全部内容, 来源链接: utcz.com/p/937296.html

回到顶部