Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
gitcode_dev
quicker
提交
e6dfe828
quicker
项目概览
gitcode_dev
/
quicker
上一次同步 大约 2 年
通知
6
Star
2
Fork
1
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
quicker
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
e6dfe828
编写于
11月 23, 2021
作者:
郭
郭维嘉
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat:添加搜索webview
上级
7e4bb158
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
196 addition
and
57 deletion
+196
-57
src/main/browsers/login.js
src/main/browsers/login.js
+43
-21
src/main/browsers/main.js
src/main/browsers/main.js
+1
-1
src/renderer/App.vue
src/renderer/App.vue
+2
-2
src/renderer/pages/plugins/index.vue
src/renderer/pages/plugins/index.vue
+6
-12
src/renderer/pages/search-bowser/index.vue
src/renderer/pages/search-bowser/index.vue
+125
-0
src/renderer/pages/search/subpages/settings.vue
src/renderer/pages/search/subpages/settings.vue
+16
-20
src/renderer/store/modules/main.js
src/renderer/store/modules/main.js
+3
-1
未找到文件。
src/main/browsers/login.js
浏览文件 @
e6dfe828
...
...
@@ -18,6 +18,8 @@ module.exports = () => {
ipcMain
.
on
(
"
token
"
,
(
e
,
info
)
=>
{
console
.
log
(
"
on token
"
);
const
loginNote
=
createNote
(
"
登录成功
"
);
session
.
defaultSession
.
cookies
.
get
({
url
:
url
...
...
@@ -25,27 +27,20 @@ module.exports = () => {
.
then
((
cookies
,
err
)
=>
{
const
userInfo
=
{};
cookies
.
forEach
(
cookie
=>
{
userInfo
[
cookie
.
name
]
=
decodeURI
(
cookie
.
value
);
userInfo
[
cookie
.
name
]
=
decodeURI
Component
(
cookie
.
value
);
});
userInfo
.
avatar
=
info
.
avatar
;
userInfo
.
UserAvatar
=
decodeURIComponent
(
info
.
UserAvatar
)
;
console
.
log
(
userInfo
);
global
.
opConfig
.
set
(
"
userInfo
"
,
userInfo
);
mainWindow
.
webContents
.
send
(
"
setUserInfo
"
,
userInfo
);
// ipcRenderer.send("re-register");
win
.
close
();
const
note
=
new
Notification
({
title
:
"
CSDN通知
"
,
// 通知标题
body
:
"
登录成功
"
,
// 内容
icon
:
path
.
resolve
(
__static
,
"
./icon.png
"
),
href
:
"
https://www.csdn.net/
"
});
note
.
show
();
loginNote
.
show
();
});
});
ipcMain
.
on
(
"
logout
"
,
(
e
,
info
)
=>
{
console
.
log
(
"
remove cookie
"
);
const
logoutNote
=
createNote
(
"
退出登录
"
);
session
.
defaultSession
.
cookies
.
get
({
url
:
url
...
...
@@ -55,17 +50,20 @@ module.exports = () => {
session
.
defaultSession
.
cookies
.
remove
(
url
,
cookie
.
name
,
e
=>
{});
});
mainWindow
.
webContents
.
send
(
"
setUserInfo
"
,
""
);
const
note
=
new
Notification
({
title
:
"
CSDN通知
"
,
// 通知标题
icon
:
path
.
resolve
(
__static
,
"
./icon.png
"
),
body
:
"
退出登录
"
,
// 内容
href
:
"
https://www.csdn.net/
"
});
note
.
show
();
logoutNote
.
show
();
});
});
};
let
createNote
=
note
=>
{
return
new
Notification
({
title
:
"
CSDN通知
"
,
// 通知标题
icon
:
path
.
resolve
(
__static
,
"
./icon.png
"
),
body
:
note
,
// 内容
href
:
"
https://www.csdn.net/
"
});
};
let
createWindow
=
()
=>
{
console
.
log
(
"
create window
"
);
session
.
defaultSession
.
cookies
...
...
@@ -94,13 +92,14 @@ module.exports = () => {
nodeIntegration
:
true
,
backgroundThrottling
:
false
,
devTools
:
false
,
webviewTag
:
true
,
preload
:
path
.
resolve
(
__dirname
,
"
../common/preload.js
"
)
}
});
// win.loadFile(path.resolve(__dirname, "../../../../send.html"));
// win.loadURL("https://meiyin.xyz");
win
.
loadURL
(
`https://passport.csdn.net/account/login?from=http://test-code.csdn.net/
lives
`
`https://passport.csdn.net/account/login?from=http://test-code.csdn.net/
about/quicker
`
);
win
.
on
(
"
closed
"
,
()
=>
{
win
=
undefined
;
...
...
@@ -110,20 +109,43 @@ module.exports = () => {
// win.hide();
});
win
.
webContents
.
on
(
"
did-stop-loading
"
,
()
=>
{
// (function observe() {
// const MutationObserver =
// window.MutationObserver ||
// window.WebKitMutationObserver ||
// window.MozMutationObserver;
// const observer = new MutationObserver(() => {
// const isSuccess = document.querySelector('login-success-tip')
// if(!isSuccess) return
// console.log(isSuccess)
// console.log('success')
// });
// const targetEl = document.body;
// observer.observe(targetEl, {
// childList: true,
// subtree: true
// });
// })()
// win.webContents.executeJavaScript(`
// window.onbeforeunload = function() { console.log(44444999) }
// `);
win
.
webContents
.
insertCSS
(
`
header.navbar { display:none !important; }
#csdn-toolbar, #copyright-box, #app .notes, #app .icon-list, #app .user-service-link { display: none }
#app, #app .container-main { min-width: unset!important; min-height: unset!important; }
#app .main { width: unset }
html, body { overflow: hidden }
#app .main-login { position: fixed; top: 0; left: 0; width: 100%; height: 100%; z-index: 999 }
#app .form-control-phone { width: 62%; float: right }
#app .main-process-login { width: 66%; margin-top: 20px }
.login-success-tip { display: none }
.login-success-tip, .quicker_loading { position: fixed; width: 100%; height: 100%; left: 0; top: 0; color: #fff; z-index: 2000; background: #fff }
.login-success-tip::after, .quicker_loading::after { content: '正在同步个人设置…'; color: #666; position: absolute; background: #fff; left: 50%; top: 50%; transform: translate(-50%, -50%); }
`
);
setTimeout
(()
=>
{
win
.
show
();
},
1
0
);
},
20
0
);
});
};
...
...
src/main/browsers/main.js
浏览文件 @
e6dfe828
...
...
@@ -29,7 +29,7 @@ module.exports = () => {
backgroundThrottling
:
false
,
contextIsolation
:
false
,
webviewTag
:
true
,
devTools
:
fals
e
,
devTools
:
tru
e
,
nodeIntegration
:
true
,
// 在网页中集成Node
// preload: path.resolve(__dirname, '../common/preload.js')
},
...
...
src/renderer/App.vue
浏览文件 @
e6dfe828
...
...
@@ -81,14 +81,14 @@
<img
v-if=
"userInfo"
class=
"icon-tool"
:src=
"userInfo.
a
vatar"
:src=
"userInfo.
UserA
vatar"
alt=
""
/>
<img
v-else
class=
"icon-tool"
:src=
"selected.icon"
/>
</div>
<!-- 用户头像 -->
<div
v-else
class=
"logo"
>
<img
v-if=
"userInfo"
:src=
"userInfo.
a
vatar"
alt=
""
/>
<img
v-if=
"userInfo"
:src=
"userInfo.
UserA
vatar"
alt=
""
/>
<img
v-else
src=
"./assets/imgs/quicker.png"
/>
</div>
</div>
...
...
src/renderer/pages/plugins/index.vue
浏览文件 @
e6dfe828
...
...
@@ -7,14 +7,8 @@
:preload=
"preload"
></webview>
<!-- 聚合搜索 -->
<webview
v-else-if=
"isWebview"
id=
"webview"
:src=
"webviewPath"
:preload=
"preload"
disablewebsecurity
allowpopups
></webview>
<search-bowser
v-else-if=
"isWebview"
:src=
"webviewPath"
:preload=
"preload"
>
</search-bowser>
<!-- 本地插件 -->
<div
v-else
>
<webview
id=
"webview"
:src=
"templatePath"
:preload=
"preload"
></webview>
...
...
@@ -25,14 +19,16 @@
<
script
>
import
path
from
"
path
"
;
import
{
mapMutations
,
mapState
}
from
"
vuex
"
;
import
{
remote
,
ipcRenderer
}
from
"
electron
"
;
import
{
remote
,
ipcRenderer
,
shell
}
from
"
electron
"
;
import
{
getWindowHeight
}
from
"
../../assets/common/utils
"
;
import
searchBowser
from
"
../search-bowser/index.vue
"
;
const
currentWindow
=
remote
.
getCurrentWindow
();
const
winId
=
currentWindow
.
id
;
export
default
{
name
:
"
index.vue
"
,
components
:
{
searchBowser
},
data
()
{
return
{
preload
:
`File://
${
path
.
join
(
__static
,
"
./preload.js
"
)}
`
,
...
...
@@ -42,6 +38,7 @@ export default {
},
mounted
()
{
this
.
webview
=
document
.
querySelector
(
"
webview
"
);
// if (!this.webview) return;
this
.
webview
.
addEventListener
(
"
dom-ready
"
,
()
=>
{
this
.
webview
.
send
(
"
onPluginReady
"
,
this
.
pluginInfo
);
this
.
webview
.
send
(
"
onPluginEnter
"
,
this
.
pluginInfo
);
...
...
@@ -149,9 +146,6 @@ export default {
});
return
`File://
${
this
.
pluginInfo
.
sourceFile
}
`
;
},
// webviewPath() {
// return "https://so.csdn.net/so/search?q=csdn";
// },
templatePath
()
{
return
`File://
${
path
.
join
(
__static
,
"
./plugins/tpl/index.html
"
)}
?code=
${
this
.
pluginInfo
.
detail
.
code
...
...
src/renderer/pages/search-bowser/index.vue
0 → 100644
浏览文件 @
e6dfe828
<
template
>
<!--
<div
class=
"search_bowser"
>
-->
<a-tabs
size=
"small"
v-model=
"activeTab"
type=
"editable-card"
@
edit=
"onEdit"
>
<a-tab-pane
v-for=
"tab in tabs"
:key=
"tab.key"
:tab=
"tab.title"
:closable=
"true"
>
<webview
v-open
:src=
"tab.src"
:preload=
"preload"
disablewebsecurity
></webview>
</a-tab-pane>
</a-tabs>
<!--
</div>
-->
</
template
>
<
script
>
export
default
{
props
:
{
src
:
{
type
:
String
,
default
:
""
},
preload
:
{
type
:
String
,
default
:
""
}
},
data
()
{
const
tabs
=
[{
title
:
"
搜索
"
,
key
:
"
111
"
,
src
:
this
.
src
}];
return
{
// webview: null,
newTabIndex
:
0
,
tabs
,
activeTab
:
tabs
[
0
].
key
};
},
// mounted() {
// setTimeout(() => {
// this.webview = document.querySelector("webview");
// this.webview.addEventListener("new-window", e => {
// console.log(e);
// const key = `newTab${this.newTabIndex++}`;
// // const title = e.
// this.tabs.push({
// title: "csdn",
// key,
// src: e.url
// });
// this.activeTab = key;
// });
// }, 0);
// },
directives
:
{
open
:
{
inserted
:
(
el
,
binding
,
vnode
)
=>
{
el
.
addEventListener
(
"
new-window
"
,
e
=>
{
console
.
log
(
e
);
const
_this
=
vnode
.
context
;
const
key
=
`newTab
${
_this
.
newTabIndex
++
}
`
;
const
title
=
el
.
getTitle
()
// const title = e.
_this
.
tabs
.
push
({
title
,
key
,
src
:
e
.
url
});
_this
.
activeTab
=
key
;
});
}
}
},
methods
:
{
onEdit
(
targetKey
,
action
)
{
this
[
action
](
targetKey
);
},
add
()
{
const
tabs
=
this
.
tabs
;
const
activeTab
=
`newTab
${
this
.
newTabIndex
++
}
`
;
tabs
.
push
({
title
:
"
New Tab
"
,
content
:
"
Content of new Tab
"
,
key
:
activeTab
});
this
.
tabs
=
tabs
;
this
.
activeTab
=
activeTab
;
},
remove
(
targetKey
)
{
let
activeTab
=
this
.
activeTab
;
let
lastIndex
;
this
.
tabs
.
forEach
((
pane
,
i
)
=>
{
if
(
pane
.
key
===
targetKey
)
{
lastIndex
=
i
-
1
;
}
});
const
tabs
=
this
.
tabs
.
filter
(
pane
=>
pane
.
key
!==
targetKey
);
if
(
tabs
.
length
&&
activeTab
===
targetKey
)
{
if
(
lastIndex
>=
0
)
{
activeTab
=
tabs
[
lastIndex
].
key
;
}
else
{
activeTab
=
tabs
[
0
].
key
;
}
}
this
.
tabs
=
tabs
;
this
.
activeTab
=
activeTab
;
}
}
};
</
script
>
<
style
lang=
"less"
scoped
>
webview {
height: calc(~"100vh - 100px");
width: 100%;
}
.ant-tabs {
/deep/.ant-tabs-bar {
margin: 0;
}
}
</
style
>
src/renderer/pages/search/subpages/settings.vue
浏览文件 @
e6dfe828
...
...
@@ -2,8 +2,8 @@
<div
class=
"pg-settings"
>
<div
class=
"dev-detail"
>
<div
class=
"user-panel"
>
<template
v-if=
"
config.
userInfo"
>
<a-avatar
:size=
"64"
:src=
"
config.userInfo.a
vatar"
/>
<template
v-if=
"userInfo"
>
<a-avatar
:size=
"64"
:src=
"
userInfo.UserA
vatar"
/>
<div
class=
"username"
>
{{
userInfo
.
UserNick
}}
</div>
<a-popconfirm
title=
"确认退出?"
...
...
@@ -17,7 +17,9 @@
</
template
>
<
template
v-else
>
<a-avatar
@
click=
"login"
:size=
"64"
icon=
"user"
/>
<a-button
@
click=
"login"
size=
"small"
>
登录
</a-button>
<a-button
@
click=
"login"
size=
"small"
:loading=
"signLoading"
>
登录
</a-button
>
</
template
>
</div>
<div
class=
"settings-detail"
>
...
...
@@ -177,6 +179,7 @@ export default {
return
{
currentSelect
:
[
3
],
config
:
{
...
opConfig
.
get
()
},
signLoading
:
false
,
examples
:
[
{
title
:
"
快捷键 「 Alt + W」 关键字 「 微信」
"
,
...
...
@@ -204,29 +207,18 @@ export default {
methods
:
{
...
mapMutations
(
"
main
"
,
[
"
setUserInfo
"
]),
login
()
{
this
.
signLoading
=
true
;
setTimeout
(()
=>
{
this
.
signLoading
=
false
;
},
2000
);
ipcRenderer
.
send
(
"
login
"
);
},
logout
()
{
opConfig
.
set
(
"
userInfo
"
,
""
);
this
.
config
.
userInfo
=
""
;
this
.
setUserInfo
(
''
);
this
.
setUserInfo
(
""
);
ipcRenderer
.
send
(
"
logout
"
);
},
// getUserInfo() {
// axios
// .post(
// "http://internalapi.csdn.net/uc/userinfo/userinfo/getdetailbyusername",
// {
// username: this.userInfo.UserName
// }
// )
// .then(res => {
// console.log(res);
// })
// .catch(e => {
// console.log(e);
// });
// },
changeShortCut
(
e
,
key
)
{
let
change
=
false
;
if
(
e
.
altKey
&&
e
.
keyCode
!==
18
)
{
...
...
@@ -326,7 +318,11 @@ export default {
.username {
font-size: 14px;
font-weight: bold;
margin: 10px 0 20px;
max-width: 80%;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
margin: 10px auto 20px;
}
}
}
...
...
src/renderer/store/modules/main.js
浏览文件 @
e6dfe828
...
...
@@ -14,6 +14,8 @@ import fs, { stat } from "fs";
import
path
from
"
path
"
;
import
{
execSync
}
from
"
child_process
"
;
const
opConfig
=
remote
.
getGlobal
(
"
opConfig
"
);
const
state
=
{
selected
:
null
,
options
:
[],
...
...
@@ -22,7 +24,7 @@ const state = {
searchValue
:
""
,
devPlugins
:
mergePlugins
(
sysFile
.
getUserPlugins
()
||
[]),
subPlaceHolder
:
""
,
userInfo
:
""
,
userInfo
:
{
...
opConfig
.
get
()
}.
userInfo
,
webviewPath
:
"
https://so.csdn.net/so/search?q=csdn
"
,
pluginLoading
:
true
,
pluginInfo
:
(()
=>
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录