From c70dbbdca9f65ebd5ab7a62306d368ac70dfd5da Mon Sep 17 00:00:00 2001 From: shaoying Date: Mon, 19 Jul 2021 08:50:38 +0800 Subject: [PATCH] opt chrome --- publish/chrome/chrome.js | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/publish/chrome/chrome.js b/publish/chrome/chrome.js index e2909e1a..e2b666ca 100644 --- a/publish/chrome/chrome.js +++ b/publish/chrome/chrome.js @@ -1,4 +1,9 @@ Volcanos("chrome", { + pwd: function(can, msg, cmds, cb) { + console.log(cmds) + + cb() + }, chrome: function(can, msg, cmds, cb) { if (cmds.length == 0) { // 窗口列表 chrome.windows.getAll(function(wins) { @@ -42,22 +47,18 @@ Volcanos("chrome", { }) }, }, ["/lib/base.js", "/lib/core.js", "/lib/misc.js", "/lib/page.js", "/lib/user.js"], function(can) { - can.Conf({iceberg: "http://localhost:9020/"}) + can.run = function(event, cmds, cb, silent) { var msg = can.request(event) + can.misc.Run(event, can, {names: "http://localhost:9020/code/chrome/"+cmds[0]}, cmds.slice(1), cb) + }, + chrome.history.onVisited.addListener(function(item) { + can.run({}, ["sync", "link", item.title, item.url]) + }) + can.user.toast = function(message, title) {chrome.notifications.create(null, { message: message, title: title||can._name, iconUrl: "/favicon.ico", type: "basic", })}, - can.misc.WSS(can, {type: "chrome", name: "chrome"}, function(event, msg, cmd, arg) { - can.core.CallFunc([can, cmd], {can: can, msg: msg, cmds: arg, cb: function() { - msg.Reply() - }}) - }) - - can.run = function(event, cmds, cb, silent) { var msg = can.request(event) - can.misc.Run(event, can, {names: "code/chrome/crx"}, cmds, cb) - }, - chrome.history.onVisited.addListener(function(item) { - can.run({}, ["history", item.id, item.title, item.url]) + can.core.CallFunc([can, cmd], {can: can, msg: msg, cmds: arg, cb: function() { msg.Reply() }}) }) chrome.contextMenus.create({title: "favor", onclick: function(event) {