temp
This commit is contained in:
parent
d251734267
commit
57a6944ec5
@ -201,7 +201,9 @@ public class BookmarkServiceImpl implements BookmarkService {
|
||||
bookmark.setUserId(userId);
|
||||
bookmark.setCreateTime(System.currentTimeMillis());
|
||||
bookmark.setAddTime(bookmark.getCreateTime());
|
||||
if (bookmark.getIcon() == null) {
|
||||
bookmark.setIcon(getIconBase64(bookmark.getUrl()));
|
||||
}
|
||||
//文件夹和书签都建立搜索key
|
||||
pinYinService.changeBookmark(bookmark);
|
||||
bookmarkDao.insertOne(bookmark);
|
||||
|
@ -1,6 +1,12 @@
|
||||
window.envType = 'background';
|
||||
window.token = localStorage.getItem('token');
|
||||
|
||||
axios.defaults.baseURL = 'https://fleyx.com/bookmark/api';
|
||||
axios.defaults.headers.common['jwt-token'] = window.token;
|
||||
axios.defaults.headers.post['Content-Type'] = 'application/json';
|
||||
axios.defaults.headers.put['Content-Type'] = 'application/json';
|
||||
|
||||
|
||||
let token = null;
|
||||
let globalPort = null;
|
||||
|
||||
@ -13,6 +19,7 @@ chrome.extension.onConnect.addListener(port => {
|
||||
console.log(msg);
|
||||
localStorage.setItem('token', msg.data);
|
||||
window.token = msg.data;
|
||||
axios.defaults.headers.common['jwt-token'] = window.token;
|
||||
token = msg.data;
|
||||
break;
|
||||
default:
|
||||
@ -24,15 +31,29 @@ chrome.extension.onConnect.addListener(port => {
|
||||
chrome.contextMenus.create(
|
||||
{
|
||||
title: '添加到书签',
|
||||
onclick: function (info, tab) {
|
||||
onclick: async function (info, tab) {
|
||||
console.log(info, tab);
|
||||
alert(tab.title);
|
||||
httpUtil.put('/bookmark', {
|
||||
let { favIconUrl, title, url } = tab;
|
||||
let icon = await axios.get(favIconUrl, { responseType: 'arraybuffer' });
|
||||
console.log(icon);
|
||||
icon = `data:` + icon.headers['content-type'] + ';base64,' + window.btoa(String.fromCharCode(...new Uint8Array(icon.data)));
|
||||
let body = {
|
||||
path: "",
|
||||
name: title,
|
||||
url,
|
||||
type: 0,
|
||||
path: '',
|
||||
name: tab.title,
|
||||
url: tab.url,
|
||||
});
|
||||
icon
|
||||
}
|
||||
chrome.tabs.sendMessage(tab.id, { code: "addBookmark", body }, res => {
|
||||
log.info("send to content");
|
||||
console.log(res);
|
||||
})
|
||||
let res = await axios.put("/bookmark", body);
|
||||
if (res.data.code == -1) {
|
||||
alert("还未登录,点击拓展按钮进行登录");
|
||||
} else if (res.data.code == 0) {
|
||||
alert("系统错误");
|
||||
}
|
||||
},
|
||||
},
|
||||
() => {
|
||||
@ -48,3 +69,9 @@ chrome.contextMenus.create(
|
||||
function createMsg (code, data) {
|
||||
return JSON.stringify({ code, data });
|
||||
}
|
||||
|
||||
// 接收background发送的消息
|
||||
chrome.runtime.onMessage.addListener((req, sender, sendResponse) => {
|
||||
console.log(req);
|
||||
sendResponse("收到");
|
||||
})
|
@ -13,7 +13,7 @@
|
||||
"default_popup": "popup/index.html"
|
||||
},
|
||||
"background": {
|
||||
"scripts": ["static/js/jquery.js", "background.js"]
|
||||
"scripts": ["static/js/jquery.js", "static/js/axios.min.js", "background.js"]
|
||||
},
|
||||
"options_ui": {
|
||||
"page": "options/index.html",
|
||||
@ -22,7 +22,7 @@
|
||||
"content_scripts": [
|
||||
{
|
||||
"matches": ["*://*/*"],
|
||||
"js": ["static/js/jquery.js", "static/js/sso.js"]
|
||||
"js": ["static/js/jquery.js", "static/js/axios.min.js", "static/js/sso.js"]
|
||||
}
|
||||
]
|
||||
}
|
||||
|
@ -1 +0,0 @@
|
||||
document.getElementById('content').innerText = 'Hello world!';
|
@ -11,8 +11,10 @@
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<h1>chrome-plugin-test</h1>
|
||||
<a href="https://fleyx.com/userSpace/ssoAuth" target="_blank">点击登录</a>
|
||||
<p id="content"></p>
|
||||
<script src="popup.js"></script>
|
||||
<script>
|
||||
console.log("popup");
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
0
浏览器插件/bookmarkBrowserPlugin/static/js/config.js
Normal file
0
浏览器插件/bookmarkBrowserPlugin/static/js/config.js
Normal file
@ -31,3 +31,10 @@ window.addEventListener('message', function(event) {
|
||||
console.error('未知的事件', event);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
// 接收background发送的消息
|
||||
chrome.runtime.onMessage.addListener((req, sender, sendResponse) => {
|
||||
console.log(req);
|
||||
sendResponse("收到");
|
||||
})
|
Loading…
x
Reference in New Issue
Block a user