Merge branch 'dev' of fanxb/bookmark into master
This commit is contained in:
commit
faffadeba9
@ -6,10 +6,10 @@
|
|||||||
</a-form-model-item>
|
</a-form-model-item>
|
||||||
<template v-if="form.type !== 'file'">
|
<template v-if="form.type !== 'file'">
|
||||||
<a-form-model-item prop="name" label="名称" :required="false">
|
<a-form-model-item prop="name" label="名称" :required="false">
|
||||||
<a-input v-model="form.name" placeholder="名称" />
|
<a-input v-model="form.name" placeholder="名称" @pressEnter="submit" ref="inputName" />
|
||||||
</a-form-model-item>
|
</a-form-model-item>
|
||||||
<a-form-model-item v-if="form.type === 'bookmark'" prop="url" label="URL">
|
<a-form-model-item v-if="form.type === 'bookmark'" prop="url" label="URL">
|
||||||
<a-input v-model="form.url" placeholder="url" />
|
<a-input v-model="form.url" placeholder="url" @pressEnter="submit" />
|
||||||
</a-form-model-item>
|
</a-form-model-item>
|
||||||
<div class="btns">
|
<div class="btns">
|
||||||
<a-button type="primary" @click="submit" :loading="loading" :disabled="loading">提交</a-button>
|
<a-button type="primary" @click="submit" :loading="loading" :disabled="loading">提交</a-button>
|
||||||
@ -78,6 +78,12 @@ export default {
|
|||||||
}
|
}
|
||||||
this.token = this.$store.state.globalConfig.token;
|
this.token = this.$store.state.globalConfig.token;
|
||||||
this.form.path = !this.targetNode ? "" : this.targetNode.path + (this.isAdd ? "." + this.targetNode.bookmarkId : "");
|
this.form.path = !this.targetNode ? "" : this.targetNode.path + (this.isAdd ? "." + this.targetNode.bookmarkId : "");
|
||||||
|
|
||||||
|
this.$nextTick(() => {
|
||||||
|
if (this.$refs.inputName) {
|
||||||
|
this.$refs.inputName.focus();
|
||||||
|
}
|
||||||
|
});
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
/**
|
/**
|
||||||
|
@ -65,7 +65,7 @@
|
|||||||
@drop="onDrop"
|
@drop="onDrop"
|
||||||
>
|
>
|
||||||
<a-dropdown :trigger="['contextmenu']" slot="nodeTitle" slot-scope="rec">
|
<a-dropdown :trigger="['contextmenu']" slot="nodeTitle" slot-scope="rec">
|
||||||
<div class="titleContext">
|
<div class="titleContext" :title="rec.dataRef.url">
|
||||||
<a-icon type="folder" v-if="!rec.dataRef.isLeaf" />
|
<a-icon type="folder" v-if="!rec.dataRef.isLeaf" />
|
||||||
<img v-else-if="rec.dataRef.icon.length > 0" :src="rec.dataRef.icon" style="width: 16px" />
|
<img v-else-if="rec.dataRef.icon.length > 0" :src="rec.dataRef.icon" style="width: 16px" />
|
||||||
<a-icon type="book" v-else />
|
<a-icon type="book" v-else />
|
||||||
|
@ -2,8 +2,8 @@
|
|||||||
<div class="ssoAddBookmark">
|
<div class="ssoAddBookmark">
|
||||||
<div class="body">
|
<div class="body">
|
||||||
<div>
|
<div>
|
||||||
<a-input placeholder="标题" v-model="form.name" />
|
<a-input placeholder="标题" v-model="form.name" @pressEnter="addBookmark" ref="nameInput" />
|
||||||
<a-input placeholder="网址" v-model="form.url" />
|
<a-input placeholder="网址" v-model="form.url" @pressEnter="addBookmark" />
|
||||||
</div>
|
</div>
|
||||||
<div class="list">
|
<div class="list">
|
||||||
<div class="path">
|
<div class="path">
|
||||||
@ -16,18 +16,23 @@
|
|||||||
</a-breadcrumb>
|
</a-breadcrumb>
|
||||||
</div>
|
</div>
|
||||||
<div class="folderList">
|
<div class="folderList">
|
||||||
<div class="item" v-for="item in folderList" :key="item.bookmarkId" @click="folderClick(item)">{{ item.name }}</div>
|
<div :class="{ item: true, bg: item.type == 1 }" v-for="item in dataList" :key="item.bookmarkId" :title="item.url">
|
||||||
|
<span class="text" @click="folderClick(item)">{{ item.name }}</span>
|
||||||
|
<a-popconfirm class="actionBar" placement="left" title="确认删除?" ok-text="是" cancel-text="否" @confirm="deleteOne(item, $event)">
|
||||||
|
<a-icon type="delete" />
|
||||||
|
</a-popconfirm>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="action">
|
<div class="action">
|
||||||
<div v-if="showAddInput" style="display: flex">
|
<div v-if="showAddInput" style="display: flex">
|
||||||
<a-input v-model="addFolderName" style="width: 8em" />
|
<a-input v-model="addFolderName" style="width: 8em" @pressEnter="addFolder" ref="folderInput" />
|
||||||
<a-button shape="circle" icon="close" @click="showAddInput = false" />
|
<a-button shape="circle" icon="close" @click="showAddInput = false" />
|
||||||
<a-button type="primary" shape="circle" icon="check" @click="addFolder" />
|
<a-button type="primary" shape="circle" icon="check" @click="addFolder" />
|
||||||
</div>
|
</div>
|
||||||
<a-button v-else type="link" @click="showAddInput = true">新建文件夹</a-button>
|
<a-button v-else type="link" @click="showFolderInput">新建文件夹</a-button>
|
||||||
<div>
|
<div>
|
||||||
<a-button style="marging-right: 1em" type="" @click="closeIframe">取消</a-button>
|
<a-button style="marging-right: 1em" type="" @click="closeIframe">取消</a-button>
|
||||||
<a-button type="primary" @click="addBookmark">{{ breadList.length === 0 ? "保存到根" : "保存" }}</a-button>
|
<a-button type="primary" @click="addBookmark">{{ breadList.length === 0 ? "保存到根" : "保存" }}</a-button>
|
||||||
@ -39,7 +44,7 @@
|
|||||||
<script>
|
<script>
|
||||||
import HttpUtil from "@/util/HttpUtil";
|
import HttpUtil from "@/util/HttpUtil";
|
||||||
import { mapState } from "vuex";
|
import { mapState } from "vuex";
|
||||||
import { TREE_DATA, TOTAL_TREE_DATA, addNode } from "@/store/modules/treeData";
|
import { TREE_DATA, TOTAL_TREE_DATA, addNode, deleteData } from "@/store/modules/treeData";
|
||||||
export default {
|
export default {
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
@ -58,9 +63,9 @@ export default {
|
|||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
...mapState(TREE_DATA, [TOTAL_TREE_DATA]),
|
...mapState(TREE_DATA, [TOTAL_TREE_DATA]),
|
||||||
folderList() {
|
dataList() {
|
||||||
let path = this.getCurrentPath();
|
let path = this.getCurrentPath();
|
||||||
return this.totalTreeData[path] ? this.totalTreeData[path].filter((item) => item.type == 1) : [];
|
return this.totalTreeData[path] ? this.totalTreeData[path] : [];
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
@ -76,11 +81,11 @@ export default {
|
|||||||
this.form.url = event.data.data.url;
|
this.form.url = event.data.data.url;
|
||||||
this.form.icon = event.data.data.icon;
|
this.form.icon = event.data.data.icon;
|
||||||
this.form.iconUrl = event.data.data.iconUrl;
|
this.form.iconUrl = event.data.data.iconUrl;
|
||||||
// this.addBookmark();
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
console.log("向父节点获取数据");
|
console.log("向父节点获取数据");
|
||||||
window.parent.postMessage({ code: "getBookmarkData", receiver: "content" }, "*");
|
window.parent.postMessage({ code: "getBookmarkData", receiver: "content" }, "*");
|
||||||
|
this.$refs.nameInput.focus();
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
closeIframe() {
|
closeIframe() {
|
||||||
@ -155,6 +160,20 @@ export default {
|
|||||||
return lastOne.path + "." + lastOne.bookmarkId;
|
return lastOne.path + "." + lastOne.bookmarkId;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
//删除一个
|
||||||
|
async deleteOne(item) {
|
||||||
|
let body = { pathList: [], bookmarkIdList: [] };
|
||||||
|
item.type == 0 ? body.bookmarkIdList.push(item.bookmarkId) : body.pathList.push(item.path + "." + item.bookmarkId);
|
||||||
|
await HttpUtil.post("/bookmark/batchDelete", null, body);
|
||||||
|
await this.$store.dispatch(TREE_DATA + "/" + deleteData, body);
|
||||||
|
this.$message.success("删除成功");
|
||||||
|
},
|
||||||
|
//显示输入框
|
||||||
|
showFolderInput() {
|
||||||
|
this.showAddInput = true;
|
||||||
|
console.log(this.$refs);
|
||||||
|
this.$nextTick(() => this.$refs.folderInput.focus());
|
||||||
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
@ -203,14 +222,36 @@ export default {
|
|||||||
margin-left: 0.5em;
|
margin-left: 0.5em;
|
||||||
|
|
||||||
.item {
|
.item {
|
||||||
cursor: pointer;
|
display: flex;
|
||||||
|
|
||||||
|
.text {
|
||||||
|
flex: 1;
|
||||||
|
width: 0;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
text-overflow: ellipsis;
|
text-overflow: ellipsis;
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
}
|
}
|
||||||
|
|
||||||
.item:hover {
|
.actionBar {
|
||||||
background: green;
|
display: none;
|
||||||
|
width: 2em;
|
||||||
|
align-items: center;
|
||||||
|
color: red;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.bg {
|
||||||
|
cursor: pointer;
|
||||||
|
color: rgb(24, 144, 255);
|
||||||
|
}
|
||||||
|
|
||||||
|
.bg:hover {
|
||||||
|
background: rgba(74, 74, 74, 0.3);
|
||||||
|
}
|
||||||
|
|
||||||
|
.item:hover .actionBar {
|
||||||
|
display: flex;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,14 +4,14 @@ chrome.runtime.onInstalled.addListener(() => {
|
|||||||
title: '添加到书签',
|
title: '添加到书签',
|
||||||
id: "addBookmark",
|
id: "addBookmark",
|
||||||
},
|
},
|
||||||
() => console.log("创建右键菜单成功")
|
() => console.debug("创建右键菜单成功")
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
chrome.contextMenus.onClicked.addListener(async function (info, tab) {
|
chrome.contextMenus.onClicked.addListener(async function (info, tab) {
|
||||||
console.log(info, tab);
|
console.debug(info, tab);
|
||||||
let body = {
|
let body = {
|
||||||
name: tab.title,
|
name: tab.title,
|
||||||
url: tab.url,
|
url: tab.url,
|
||||||
@ -27,7 +27,7 @@ chrome.runtime.onMessage.addListener(async (data, sender, sendResponse) => {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
sendResponse("ok");
|
sendResponse("ok");
|
||||||
console.log("收到消息:", data, sender);
|
console.debug("收到消息:", data, sender);
|
||||||
if (data.code == 'setToken') {
|
if (data.code == 'setToken') {
|
||||||
await setVal("token", data.data);
|
await setVal("token", data.data);
|
||||||
// sendToContent
|
// sendToContent
|
||||||
@ -47,10 +47,10 @@ chrome.runtime.onMessage.addListener(async (data, sender, sendResponse) => {
|
|||||||
* @param {*} data
|
* @param {*} data
|
||||||
*/
|
*/
|
||||||
function sendToContent (tabId, data) {
|
function sendToContent (tabId, data) {
|
||||||
console.log(tabId, data);
|
console.debug(tabId, data);
|
||||||
data.receiver = "content";
|
data.receiver = "content";
|
||||||
chrome.tabs.sendMessage(tabId, data, res => {
|
chrome.tabs.sendMessage(tabId, data, res => {
|
||||||
console.log("接受响应", res);
|
console.debug("接受响应", res);
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -60,7 +60,7 @@ function sendToContent (tabId, data) {
|
|||||||
*/
|
*/
|
||||||
function sendToPopup (data) {
|
function sendToPopup (data) {
|
||||||
data.receiver = "popup";
|
data.receiver = "popup";
|
||||||
chrome.runtime.sendMessage(data, res => console.log(res));
|
chrome.runtime.sendMessage(data, res => console.debug(res));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -72,7 +72,7 @@ function sendToPopup (data) {
|
|||||||
function setVal (key, val) {
|
function setVal (key, val) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
chrome.storage.local.set({ [key]: val }, function () {
|
chrome.storage.local.set({ [key]: val }, function () {
|
||||||
console.log("设置值成功:", key, val)
|
console.debug("设置值成功:", key, val)
|
||||||
resolve();
|
resolve();
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
@ -87,11 +87,11 @@ function getVal (key) {
|
|||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
chrome.storage.local.get([key], async function (res) {
|
chrome.storage.local.get([key], async function (res) {
|
||||||
if (key === 'token' && !checkTokenValid(res[key])) {
|
if (key === 'token' && !checkTokenValid(res[key])) {
|
||||||
console.log("token过期");
|
console.debug("token过期");
|
||||||
await clearVal("token");
|
await clearVal("token");
|
||||||
res[key] = null;
|
res[key] = null;
|
||||||
}
|
}
|
||||||
console.log("取值成功", res);
|
console.debug("取值成功", res);
|
||||||
resolve(res[key]);
|
resolve(res[key]);
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
@ -100,7 +100,7 @@ function getVal (key) {
|
|||||||
function clearVal (key) {
|
function clearVal (key) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
chrome.storage.local.remove(key, function () {
|
chrome.storage.local.remove(key, function () {
|
||||||
console.log("remove成功", key);
|
console.debug("remove成功", key);
|
||||||
resolve();
|
resolve();
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
console.log("asdf");
|
console.debug("asdf");
|
||||||
console.log(bookmarkHost);
|
console.debug(bookmarkHost);
|
||||||
|
|
||||||
var token;
|
var token;
|
||||||
var login = document.getElementById("login");
|
var login = document.getElementById("login");
|
||||||
@ -14,7 +14,7 @@ var action = document.getElementById("action");
|
|||||||
let newestBlock = document.getElementById("newestVersion");
|
let newestBlock = document.getElementById("newestVersion");
|
||||||
newestBlock.href = bookmarkHost + "/static/bookmarkBrowserPlugin.zip";
|
newestBlock.href = bookmarkHost + "/static/bookmarkBrowserPlugin.zip";
|
||||||
let res = await axios.get("/common/config/global");
|
let res = await axios.get("/common/config/global");
|
||||||
console.log(res);
|
console.debug(res);
|
||||||
newestBlock.innerText = res.data.data.map.pluginVersion;
|
newestBlock.innerText = res.data.data.map.pluginVersion;
|
||||||
})();
|
})();
|
||||||
|
|
||||||
@ -22,7 +22,7 @@ var action = document.getElementById("action");
|
|||||||
* 退出登陆
|
* 退出登陆
|
||||||
*/
|
*/
|
||||||
document.getElementById("logout").addEventListener("click", () => {
|
document.getElementById("logout").addEventListener("click", () => {
|
||||||
console.log("click");
|
console.debug("click");
|
||||||
sendToBg("clearToken", null);
|
sendToBg("clearToken", null);
|
||||||
action.style.display = "none";
|
action.style.display = "none";
|
||||||
login.style.display = "block";
|
login.style.display = "block";
|
||||||
@ -33,7 +33,7 @@ document.getElementById("logout").addEventListener("click", () => {
|
|||||||
* @param {*} data
|
* @param {*} data
|
||||||
*/
|
*/
|
||||||
function sendToBg (code, data) {
|
function sendToBg (code, data) {
|
||||||
chrome.runtime.sendMessage({ code, data, receiver: "background" }, res => console.log(res));
|
chrome.runtime.sendMessage({ code, data, receiver: "background" }, res => console.debug(res));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -43,7 +43,7 @@ chrome.runtime.onMessage.addListener(async (data, sender, sendResponse) => {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
sendResponse("ok");
|
sendResponse("ok");
|
||||||
console.log("popup收到消息:", data);
|
console.debug("popup收到消息:", data);
|
||||||
if (data.code == 'setToken') {
|
if (data.code == 'setToken') {
|
||||||
token = data.data;
|
token = data.data;
|
||||||
if (token) {
|
if (token) {
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
var bookmarkHost = "https://fleyx.com";
|
// var bookmarkHost = "https://fleyx.com";
|
||||||
// var bookmarkHost = "http://localhost:8080";
|
var bookmarkHost = "http://localhost:8080";
|
||||||
|
|
||||||
var version = "0.1.2";
|
var version = "0.1.2";
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
console.log('注入了页面');
|
console.debug('注入了页面');
|
||||||
|
|
||||||
var bookmarkInfo = null;
|
var bookmarkInfo = null;
|
||||||
var addBlockDiv = null;
|
var addBlockDiv = null;
|
||||||
@ -8,11 +8,11 @@ var iframe = null;
|
|||||||
* 接收当前注入页面传来的消息
|
* 接收当前注入页面传来的消息
|
||||||
*/
|
*/
|
||||||
window.addEventListener('message', function (event) {
|
window.addEventListener('message', function (event) {
|
||||||
console.log(event);
|
console.debug(event);
|
||||||
if (event.data.code === undefined) {
|
if (event.data.code === undefined) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
console.log('接受到网页消息:', event.data);
|
console.debug('接受到网页消息:', event.data);
|
||||||
if (event.data.code === 'getBookmarkData') {
|
if (event.data.code === 'getBookmarkData') {
|
||||||
iframe.contentWindow.postMessage({ code: "addBookmarkAction", data: bookmarkInfo }, "*");
|
iframe.contentWindow.postMessage({ code: "addBookmarkAction", data: bookmarkInfo }, "*");
|
||||||
} else if (event.data.code === 'setToken') {
|
} else if (event.data.code === 'setToken') {
|
||||||
@ -31,7 +31,7 @@ chrome.runtime.onMessage.addListener(async (data, sender, sendResponse) => {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
sendResponse("ok");
|
sendResponse("ok");
|
||||||
console.log('收到消息:', data);
|
console.debug('收到消息:', data);
|
||||||
if (data.code == 'setTokenOk') {
|
if (data.code == 'setTokenOk') {
|
||||||
sendToPage(data);
|
sendToPage(data);
|
||||||
} else if (data.code == 'addBookmark') {
|
} else if (data.code == 'addBookmark') {
|
||||||
@ -49,13 +49,13 @@ async function addBookmark (data) {
|
|||||||
try {
|
try {
|
||||||
if (data.data.iconUrl) {
|
if (data.data.iconUrl) {
|
||||||
let icon = await axios.get(data.data.iconUrl, { responseType: 'arraybuffer' });
|
let icon = await axios.get(data.data.iconUrl, { responseType: 'arraybuffer' });
|
||||||
console.log(JSON.stringify(new Uint8Array(icon.data)));
|
console.debug(JSON.stringify(new Uint8Array(icon.data)));
|
||||||
data.data.icon = `data:` + icon.headers['content-type'] + ';base64,' + window.btoa(String.fromCharCode(...new Uint8Array(icon.data)));
|
data.data.icon = `data:` + icon.headers['content-type'] + ';base64,' + window.btoa(String.fromCharCode(...new Uint8Array(icon.data)));
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error);
|
console.error(error);
|
||||||
}
|
}
|
||||||
console.log("新增书签", data.data);
|
console.debug("新增书签", data.data);
|
||||||
bookmarkInfo = data.data;
|
bookmarkInfo = data.data;
|
||||||
addBlockDiv = document.createElement("div");
|
addBlockDiv = document.createElement("div");
|
||||||
addBlockDiv.setAttribute("style", "position:fixed;width:100%;height:100vh;z-index:100000;left:0;top:0;background:rgba(211, 211, 205, 0.8)");
|
addBlockDiv.setAttribute("style", "position:fixed;width:100%;height:100vh;z-index:100000;left:0;top:0;background:rgba(211, 211, 205, 0.8)");
|
||||||
@ -73,7 +73,7 @@ async function addBookmark (data) {
|
|||||||
function sendToBg (data) {
|
function sendToBg (data) {
|
||||||
data.receiver = "background";
|
data.receiver = "background";
|
||||||
chrome.runtime.sendMessage(data, response => {
|
chrome.runtime.sendMessage(data, response => {
|
||||||
console.log(response);
|
console.debug(response);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user