mirror of
https://github.com/rubickCenter/rubick
synced 2025-10-26 22:51:25 +08:00
Compare commits
66 Commits
v0.0.3-bet
...
v0.0.11
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e4aafb8e60 | ||
|
|
7064f504de | ||
|
|
96f2f62787 | ||
|
|
26bd47cce7 | ||
|
|
daa422b8e7 | ||
|
|
243c954ab6 | ||
|
|
6e02163752 | ||
|
|
c89ecb9c66 | ||
|
|
0a1ba91792 | ||
|
|
858bec38b2 | ||
|
|
3bd9271403 | ||
|
|
69626ed69e | ||
|
|
a16b198798 | ||
|
|
988acd7638 | ||
|
|
6a9d3517c4 | ||
|
|
96f9d41460 | ||
|
|
ace106a231 | ||
|
|
6864836399 | ||
|
|
7a1777e083 | ||
|
|
fa30074019 | ||
|
|
5f4e77f88e | ||
|
|
2df00360e4 | ||
|
|
1c893542b9 | ||
|
|
e9fa7b2276 | ||
|
|
db12d66ff7 | ||
|
|
9d3e7fc4a5 | ||
|
|
be21302738 | ||
|
|
a535c5d89b | ||
|
|
1eeb0fad9a | ||
|
|
511b357e28 | ||
|
|
87e7501c0a | ||
|
|
9242f17cde | ||
|
|
d047119076 | ||
|
|
5118fa6ca4 | ||
|
|
424c40a99c | ||
|
|
651e202ab1 | ||
|
|
614d5ae369 | ||
|
|
f287d10ca9 | ||
|
|
a04efd0d4f | ||
|
|
153d9dc5d7 | ||
|
|
de138955b5 | ||
|
|
8d340cb76c | ||
|
|
579b283a55 | ||
|
|
3858f35559 | ||
|
|
57504ab1eb | ||
|
|
0991d0ad64 | ||
|
|
e71eed00ad | ||
|
|
be5bce68dc | ||
|
|
871beba4bf | ||
|
|
f0b757c01f | ||
|
|
f480508200 | ||
|
|
247c2b7ab9 | ||
|
|
a489a8f130 | ||
|
|
d38dcab9cc | ||
|
|
64541ad651 | ||
|
|
5b1cef93c8 | ||
|
|
8dd59720e0 | ||
|
|
ee2a23a421 | ||
|
|
7dd5407bbe | ||
|
|
b58c37842a | ||
|
|
2d2743cbb1 | ||
|
|
efccc2b091 | ||
|
|
c6c57b1e01 | ||
|
|
a8c1db6ed3 | ||
|
|
4e55f14a69 | ||
|
|
bf6e95e370 |
10
.github/workflows/main.yml
vendored
10
.github/workflows/main.yml
vendored
@@ -23,7 +23,7 @@ jobs:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
os: [macos-latest, windows-2019]
|
||||
os: [ubuntu-latest, macos-latest, windows-2019]
|
||||
|
||||
# create steps
|
||||
steps:
|
||||
@@ -40,6 +40,7 @@ jobs:
|
||||
- name: Install system deps
|
||||
if: matrix.os == 'ubuntu-latest'
|
||||
run: |
|
||||
sudo apt-get install libxtst-dev libpng++-dev
|
||||
sudo apt-get install --no-install-recommends -y icnsutils graphicsmagick xz-utils
|
||||
# step3: yarn
|
||||
- name: macos Yarn install
|
||||
@@ -56,6 +57,13 @@ jobs:
|
||||
yarn global add xvfb-maybe
|
||||
npm run rebuild_win
|
||||
|
||||
- name: linux Yarn install
|
||||
if: ${{runner.os == 'Linux'}}
|
||||
run: |
|
||||
yarn
|
||||
yarn global add xvfb-maybe
|
||||
npm run rebuild_linux
|
||||
|
||||
- name: Build & release app
|
||||
run: |
|
||||
npm run release
|
||||
|
||||
11
.gitignore
vendored
11
.gitignore
vendored
@@ -1,12 +1,21 @@
|
||||
.DS_Store
|
||||
|
||||
dist/
|
||||
dist/electron/*
|
||||
dist/web/*
|
||||
|
||||
build/*
|
||||
!build/icons/
|
||||
|
||||
node_modules/
|
||||
|
||||
npm-debug.log
|
||||
npm-debug.log.*
|
||||
.pnpm-debug.log
|
||||
|
||||
thumbs.db
|
||||
!.gitkeep
|
||||
|
||||
.idea
|
||||
dist/
|
||||
.vscode
|
||||
|
||||
|
||||
13
.versionrc
Normal file
13
.versionrc
Normal file
@@ -0,0 +1,13 @@
|
||||
{
|
||||
"header": "变更日志",
|
||||
"types": [
|
||||
{"type":"feat","section":"新增功能", "hidden": false},
|
||||
{"type":"fix","section":"Bug 修复", "hidden": false},
|
||||
{"type":"ref","section":"重构", "hidden": false},
|
||||
{"type":"docs","section":"文档", "hidden": false}
|
||||
],
|
||||
"compareUrlFormat": "https://github.com/clouDr-f2e/rubick/compare/{{previousTag}}...{{currentTag}}",
|
||||
"commitUrlFormat": "https://github.com/clouDr-f2e/rubick/commit/{{hash}}",
|
||||
"issueUrlFormat": "https://github.com/clouDr-f2e/rubick/issues/{{id}}",
|
||||
"userUrlFormat": "https://github.com/{{user}}"
|
||||
}
|
||||
20
CHANGELOG.md
Normal file
20
CHANGELOG.md
Normal file
@@ -0,0 +1,20 @@
|
||||
变更日志
|
||||
### [0.0.11](https://github.com/clouDr-f2e/rubick/compare/v0.0.10...v0.0.11) (2021-09-27)
|
||||
|
||||
|
||||
### 文档
|
||||
|
||||
* 增加 changelog 功能 ([c89ecb9](https://github.com/clouDr-f2e/rubick/commit/c89ecb9c66607f5d390c564d753bc30bd180bf91))
|
||||
* 增加 changelog 功能 ([0a1ba91](https://github.com/clouDr-f2e/rubick/commit/0a1ba91792dcf71c64896d9ec26b266e2c9b0355))
|
||||
|
||||
### [0.0.10](https://github.com/clouDr-f2e/rubick/compare/v0.0.9...v0.0.10) (2021-09-23)
|
||||
|
||||
|
||||
### 新增功能
|
||||
|
||||
* 增加 changelog 功能 ([69626ed](https://github.com/clouDr-f2e/rubick/commit/69626ed69e4a19d6e85388591a5c1273806893f3))
|
||||
|
||||
|
||||
### 文档
|
||||
|
||||
* 增加 changelog 功能 ([3bd9271](https://github.com/clouDr-f2e/rubick/commit/3bd927140366da9f4b3a3e6e81cad04d92c76c55))
|
||||
46
CONTRIBUTING.md
Normal file
46
CONTRIBUTING.md
Normal file
@@ -0,0 +1,46 @@
|
||||
# Contributing to Rubick
|
||||
|
||||
## Set up
|
||||
|
||||
Install dev deps after git clone the repo.
|
||||
|
||||
```bash
|
||||
$ npm install
|
||||
$ npm run rebuild
|
||||
$ npm run dev
|
||||
```
|
||||
|
||||
## Build
|
||||
|
||||
Transform with babel and webpack.
|
||||
|
||||
```bash
|
||||
# macos
|
||||
$ npm run build
|
||||
|
||||
# other system
|
||||
$ npm run build_win
|
||||
```
|
||||
|
||||
## Docs
|
||||
|
||||
```bash
|
||||
# add doc
|
||||
$ cd docs
|
||||
$ npm i
|
||||
$ npm run docs:dev
|
||||
```
|
||||
|
||||
## Pull requests
|
||||
**Working on your first Pull Request?** You can learn how from this *free* series
|
||||
[How to Contribute to an Open Source Project on GitHub](https://egghead.io/series/how-to-contribute-to-an-open-source-project-on-github)
|
||||
|
||||
All pull requests are welcome. Thanks for taking the time to contribute.
|
||||
|
||||
- Create an issue about the features, such as new components.
|
||||
- Fork the repo to your own account.
|
||||
- Clone your fork.
|
||||
- Create a new branch base on `dev`, if you want to add new component, the branch name should be formatted as `component-[Component Name]`. (e.g. `component-steps`) And the commit info should be formatted as `[Component Name]: Info about commit`.
|
||||
- Make sure that running `npm run build_win` outputs the correct files.
|
||||
- Rebase before creating a PR to keep commit history clear. (Merge request to branch `dev`)
|
||||
- Provide some description about your PR.
|
||||
80
README.md
80
README.md
@@ -1,3 +1,5 @@
|
||||
English | [简体中文](https://github.com/clouDr-f2e/rubick/blob/master/README.zh-CN.md)
|
||||
|
||||
<div align= "center">
|
||||
<img align="center" width=200 src="https://user-images.githubusercontent.com/21073039/128333805-73e086f0-5523-46a3-a096-cba80b904c46.png" />
|
||||
</div>
|
||||
@@ -16,79 +18,91 @@
|
||||
<a href="https://github.com/clouDr-f2e/rubick/blob/master/LICENSE">
|
||||
<img alt="npm" src="https://img.shields.io/github/license/clouDr-f2e/rubick" />
|
||||
</a>
|
||||
<img alt="star" src="https://img.shields.io/github/stars/clouDr-f2e/rubick?style=social"></a>
|
||||
|
||||
<a href="https://github.com/clouDr-f2e/rubick/stargazers">
|
||||
<img alt="star" src="https://img.shields.io/github/stars/clouDr-f2e/rubick?style=social">
|
||||
</a>
|
||||
<a href="https://gitee.com/monkeyWang/rubick">
|
||||
<img alt="码云" src="https://img.shields.io/badge/Gitee--yellow.svg?style=social&logo=data:image/svg+xml;base64,PHN2ZyB0PSIxNTc0ODM3MTM4ODM3IiBjbGFzcz0iaWNvbiIgdmlld0JveD0iMCAwIDEwMjQgMTAyNCIgdmVyc2lvbj0iMS4xIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHAtaWQ9IjE3NzAiICAgICB3aWR0aD0iMTYiIGhlaWdodD0iMTYiPiAgICA8cGF0aCBkPSJNODkxIDQyOC44SDQ2NS44Yy0yMC40IDAtMzcgMTYuNS0zNyAzN3Y5Mi40YzAgMjAuNCAxNi41IDM3IDM3IDM3aDI1OC45YzIwLjQgMCAzNyAxNi42IDM3IDM3djE4LjRjMCA2MS4zLTQ5LjcgMTEwLjktMTEwLjkgMTEwLjlIMjk5LjRjLTIwLjQgMC0zNy0xNi42LTM3LTM3VjM3My4yYzAtNjEuMyA0OS43LTExMC45IDExMC45LTExMC45aDUxNy42YzIwLjQgMCAzNy0xNi41IDM3LTM3bDAuMS05Mi4zYzAtMjAuNC0xNi41LTM3LTM3LTM3SDM3My4zQzIyMC4yIDk2IDk2IDIyMC4yIDk2IDM3My4zVjg5MWMwIDIwLjQgMTYuNiAzNyAzNyAzN2g1NDUuNEM4MTYuMiA5MjggOTI4IDgxNi4zIDkyOCA2NzguNFY0NjUuOGMwLTIwLjQtMTYuNi0zNy0zNy0zN3oiICAgICAgICAgIGZpbGw9IiNkODFlMDYiIHAtaWQ9IjE3NzEiPjwvcGF0aD48L3N2Zz4="/>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
|
||||
基于 electron 的开源工具箱,自由集成丰富插件,打造极致的桌面端效能工具。Rubick(拉比克) 是 dota 里面的英雄之一,其核心技能是插件化使用其他英雄的技能,用完即走。非常符合本工具的设计理念,所以取名 Rubick。
|
||||
Based on electron open source toolbox, free integration of rich plug-ins, to create the ultimate desktop efficiency tool。Rubick is one of the heroes of Dota ,The core skill is the ability to use other heroes as plug-ins,Finished the walk 。Very consistent with the design concept of this tool,So named Rubick。
|
||||
|
||||
## 安装包
|
||||
## Installation package
|
||||
* [Rubick Mac OS](https://github.com/clouDr-f2e/rubick/releases)
|
||||
* [Rubick Windows](https://github.com/clouDr-f2e/rubick/releases)
|
||||
* [Rubick Linux](https://github.com/clouDr-f2e/rubick/releases)
|
||||
|
||||
## 支持能力
|
||||
- [x] 支持远程下载安装插件,支持插件开发者模式
|
||||
- [x] 支持插件分离
|
||||
- [x] 支持系统命令取色、截屏、帮助
|
||||
- [x] 支持超级面板,长按右击呼出
|
||||
- [x] 支持全局快捷键设置
|
||||
- [x] 支持搜索本地已安装 app 或 偏好设置
|
||||
- [x] macos touchBar 唤起插件
|
||||
- [x] 支持 Windows(目前是 mac 的 alpha 版本,功能尚不全,正在迁移中)
|
||||
- [ ] 支持 Linux
|
||||
## Feature list
|
||||
- [x] Support remote download plug-in installation, support plug-in developer mode
|
||||
- [x] Support plug-in separation
|
||||
- [x] Support system command color picker、screen capture、 help
|
||||
- [x] Support super panel, long press and right click to make a call
|
||||
- [x] Support global shortcut key Settings
|
||||
- [x] You can search for locally installed APPS or preferences
|
||||
- [x] Support macos touchBar arouse the plug-in
|
||||
- [x] Support Windows
|
||||
- [x] Support Linux
|
||||
|
||||
|
||||
|
||||

|
||||
|
||||
## 使用文档
|
||||
## Docs
|
||||
|
||||
[Rubick Docs](https://cloudr-f2e.github.io/rubick/)
|
||||
|
||||
|
||||
## 使用问题
|
||||
1. 依赖于 `robotjs` dev 环境运行请在 `install` 后执行 `npm run rebuild`
|
||||
2. windows 版本目前有了一个最基础的可用版,代码在 [feat-win](https://github.com/clouDr-f2e/rubick/tree/feat-win) 分支。完整版正在开发中,敬请期待
|
||||
## Tips
|
||||
If you're in a development environment,Run `npm run rebuild` after install。
|
||||
|
||||
## 目前支持能力
|
||||
## Current support capability
|
||||
|
||||
### touchBar 唤起插件
|
||||
macOS 支持 touchbar 快速唤起插件
|
||||
### touchBar
|
||||
macOS support touchbar Quick recall plug-in
|
||||
|
||||
<img src=https://user-images.githubusercontent.com/21073039/129727195-7dd50152-19f8-4064-9bcc-24393a896a6d.png width=500 />
|
||||

|
||||
|
||||
|
||||
### 超级面板
|
||||
长按鼠标右键,即可呼起超级面板,可以根据当前鼠标选择内容,匹配对应插件能力。比如当前选择图片后长按右击,则会呼起上传图床插件:
|
||||
### Super Panel
|
||||
Long press the right mouse button to call up the super panel. You can select content according to the current mouse and match the ability of the plug-in. For example, after selecting a picture, long press and right click to call up the plug-in to upload the picture bed.
|
||||
|
||||

|
||||
|
||||
### 模板
|
||||
模板即是一个内置 UI 样式的功能插件。
|
||||
### Template
|
||||
A template is a built-in UI-style function plug-in.
|
||||
|
||||
<img src=https://p1-juejin.byteimg.com/tos-cn-i-k3u1fbpfcp/0b113ad547974699b9c73c28bc09b9b1~tplv-k3u1fbpfcp-watermark.image width=500 />
|
||||
|
||||
### 系统命令
|
||||
#### 取色
|
||||
基于 `robot.js` 以及 `iohook` 实现。未使用 C++ 扩展。
|
||||
### System Command
|
||||
#### Color picker
|
||||
Based on `robot.js` and `iohook`。
|
||||
|
||||

|
||||
|
||||
#### 截屏
|
||||
#### Screen capture
|
||||
|
||||
<img src=https://p6-juejin.byteimg.com/tos-cn-i-k3u1fbpfcp/18023dab52e1420c9e87362cefddb2a1~tplv-k3u1fbpfcp-watermark.image width=500 />
|
||||
|
||||
|
||||
#### 全局快捷键
|
||||
#### Global Hotkeys
|
||||
|
||||
<img src=https://p9-juejin.byteimg.com/tos-cn-i-k3u1fbpfcp/62cc424eacac4c9eb178f0e055e87d9a~tplv-k3u1fbpfcp-watermark.image width=500 />
|
||||
|
||||
### 最后
|
||||
## Contributors
|
||||
|
||||
This project exists thanks to all the people who contribute. [[Contribute](CONTRIBUTING.md)]. <a href="https://github.com/clouDr-f2e/rubick/graphs/contributors"><img src="https://opencollective.com/rubick/contributors.svg?width=890&button=false" /></a>
|
||||
## Feedback
|
||||
对本项目有兴趣或者想要交流学习的同学可以扫码加下面的微信,备注 rubick,帮助我们更好的成长:
|
||||
|
||||

|
||||
|
||||
扫码关注 Rubick 官微, 获取最新动态:
|
||||
|
||||

|
||||
|
||||
## ChangeLog
|
||||
[CHANGELOG](https://github.com/clouDr-f2e/rubick/blob/master/CHANGELOG.md)
|
||||
|
||||
## License
|
||||
This project is licensed under the MIT License - see the [LICENSE.md](https://github.com/clouDr-f2e/rubick/blob/master/LICENSE) file for details.
|
||||
|
||||
111
README.zh-CN.md
Normal file
111
README.zh-CN.md
Normal file
@@ -0,0 +1,111 @@
|
||||
[English](https://github.com/clouDr-f2e/rubick/blob/master/README.md) | 简体中文
|
||||
|
||||
|
||||
<div align= "center">
|
||||
<img align="center" width=200 src="https://user-images.githubusercontent.com/21073039/128333805-73e086f0-5523-46a3-a096-cba80b904c46.png" />
|
||||
</div>
|
||||
|
||||
|
||||
<div align= "center">
|
||||
<h1>Rubick</h1>
|
||||
|
||||
<img alt="release" src="https://img.shields.io/github/downloads/clouDr-f2e/rubick/total" />
|
||||
<a href="https://github.com/clouDr-f2e/rubick/releases">
|
||||
<img alt="release" src="https://img.shields.io/github/package-json/v/clouDr-f2e/rubick" />
|
||||
</a>
|
||||
<a href="https://github.com/clouDr-f2e/rubick/actions">
|
||||
<img alt=building src=https://img.shields.io/github/workflow/status/clouDr-f2e/rubick/Build>
|
||||
</a>
|
||||
<a href="https://github.com/clouDr-f2e/rubick/blob/master/LICENSE">
|
||||
<img alt="npm" src="https://img.shields.io/github/license/clouDr-f2e/rubick" />
|
||||
</a>
|
||||
<a href="https://github.com/clouDr-f2e/rubick/stargazers">
|
||||
<img alt="star" src="https://img.shields.io/github/stars/clouDr-f2e/rubick?style=social">
|
||||
</a>
|
||||
<a href="https://gitee.com/monkeyWang/rubick">
|
||||
<img alt="码云" src="https://img.shields.io/badge/Gitee--yellow.svg?style=social&logo=data:image/svg+xml;base64,PHN2ZyB0PSIxNTc0ODM3MTM4ODM3IiBjbGFzcz0iaWNvbiIgdmlld0JveD0iMCAwIDEwMjQgMTAyNCIgdmVyc2lvbj0iMS4xIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHAtaWQ9IjE3NzAiICAgICB3aWR0aD0iMTYiIGhlaWdodD0iMTYiPiAgICA8cGF0aCBkPSJNODkxIDQyOC44SDQ2NS44Yy0yMC40IDAtMzcgMTYuNS0zNyAzN3Y5Mi40YzAgMjAuNCAxNi41IDM3IDM3IDM3aDI1OC45YzIwLjQgMCAzNyAxNi42IDM3IDM3djE4LjRjMCA2MS4zLTQ5LjcgMTEwLjktMTEwLjkgMTEwLjlIMjk5LjRjLTIwLjQgMC0zNy0xNi42LTM3LTM3VjM3My4yYzAtNjEuMyA0OS43LTExMC45IDExMC45LTExMC45aDUxNy42YzIwLjQgMCAzNy0xNi41IDM3LTM3bDAuMS05Mi4zYzAtMjAuNC0xNi41LTM3LTM3LTM3SDM3My4zQzIyMC4yIDk2IDk2IDIyMC4yIDk2IDM3My4zVjg5MWMwIDIwLjQgMTYuNiAzNyAzNyAzN2g1NDUuNEM4MTYuMiA5MjggOTI4IDgxNi4zIDkyOCA2NzguNFY0NjUuOGMwLTIwLjQtMTYuNi0zNy0zNy0zN3oiICAgICAgICAgIGZpbGw9IiNkODFlMDYiIHAtaWQ9IjE3NzEiPjwvcGF0aD48L3N2Zz4="/>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
|
||||
基于 electron 的开源工具箱,自由集成丰富插件,打造极致的桌面端效能工具。Rubick(拉比克) 是 dota 里面的英雄之一,其核心技能是插件化使用其他英雄的技能,用完即走。非常符合本工具的设计理念,所以取名 Rubick。
|
||||
|
||||
## 安装包
|
||||
* [Rubick Mac OS](https://github.com/clouDr-f2e/rubick/releases)
|
||||
* [Rubick Windows](https://github.com/clouDr-f2e/rubick/releases)
|
||||
* [Rubick Linux](https://github.com/clouDr-f2e/rubick/releases)
|
||||
|
||||
## 支持能力
|
||||
- [x] 支持远程下载安装插件,支持插件开发者模式
|
||||
- [x] 支持插件分离
|
||||
- [x] 支持系统命令取色、截屏、帮助
|
||||
- [x] 支持超级面板,长按右击呼出
|
||||
- [x] 支持全局快捷键设置
|
||||
- [x] 支持搜索本地已安装 app 或 偏好设置
|
||||
- [x] macos touchBar 唤起插件
|
||||
- [x] 支持 Windows
|
||||
- [x] 支持 Linux
|
||||
|
||||
|
||||
|
||||

|
||||
|
||||
## 使用文档
|
||||
|
||||
[Rubick Docs](https://cloudr-f2e.github.io/rubick/)
|
||||
|
||||
|
||||
## 使用问题
|
||||
依赖于 `robotjs` dev 环境运行请在 `install` 后执行 `npm run rebuild`
|
||||
|
||||
## 目前支持能力
|
||||
|
||||
### touchBar 唤起插件
|
||||
macOS 支持 touchbar 快速唤起插件
|
||||
|
||||

|
||||
|
||||
|
||||
### 超级面板
|
||||
长按鼠标右键,即可呼起超级面板,可以根据当前鼠标选择内容,匹配对应插件能力。比如当前选择图片后长按右击,则会呼起上传图床插件:
|
||||
|
||||

|
||||
|
||||
### 模板
|
||||
模板即是一个内置 UI 样式的功能插件。
|
||||
|
||||
<img src=https://p1-juejin.byteimg.com/tos-cn-i-k3u1fbpfcp/0b113ad547974699b9c73c28bc09b9b1~tplv-k3u1fbpfcp-watermark.image width=500 />
|
||||
|
||||
### 系统命令
|
||||
#### 取色
|
||||
基于 `robot.js` 以及 `iohook` 实现。未使用 C++ 扩展。
|
||||
|
||||

|
||||
|
||||
#### 截屏
|
||||
|
||||
<img src=https://p6-juejin.byteimg.com/tos-cn-i-k3u1fbpfcp/18023dab52e1420c9e87362cefddb2a1~tplv-k3u1fbpfcp-watermark.image width=500 />
|
||||
|
||||
|
||||
#### 全局快捷键
|
||||
|
||||
<img src=https://p9-juejin.byteimg.com/tos-cn-i-k3u1fbpfcp/62cc424eacac4c9eb178f0e055e87d9a~tplv-k3u1fbpfcp-watermark.image width=500 />
|
||||
|
||||
## 贡献
|
||||
This project exists thanks to all the people who contribute. [[Contribute](CONTRIBUTING.md)]. <a href="https://github.com/clouDr-f2e/rubick/graphs/contributors"><img src="https://opencollective.com/rubick/contributors.svg?width=890&button=false" /></a>
|
||||
|
||||
## 反馈
|
||||
对本项目有兴趣或者想要交流学习的同学可以扫码加下面的微信,备注 rubick,帮助我们更好的成长:
|
||||
|
||||

|
||||
|
||||
扫码关注 Rubick 官微, 获取最新动态:
|
||||
|
||||

|
||||
|
||||
## 更新日志
|
||||
[ChangeLog](https://github.com/clouDr-f2e/rubick/blob/master/CHANGELOG.md)
|
||||
|
||||
## License
|
||||
This project is licensed under the MIT License - see the [LICENSE.md](https://github.com/clouDr-f2e/rubick/blob/master/LICENSE) file for details.
|
||||
|
||||
@@ -13,6 +13,7 @@ module.exports = {
|
||||
nav: [
|
||||
{ text: '使用文档', link: '/guide/' },
|
||||
{ text: '开发者', link: '/dev/' },
|
||||
{ text: 'ChangeLog', link: 'https://github.com/clouDr-f2e/rubick/blob/master/CHANGELOG.md' },
|
||||
],
|
||||
sidebar: [
|
||||
{
|
||||
@@ -36,13 +37,8 @@ module.exports = {
|
||||
path: '/blogs/plugin/',
|
||||
},
|
||||
{
|
||||
title: '右击增强实现原理'
|
||||
},
|
||||
{
|
||||
title: '系统插件实现原理'
|
||||
},
|
||||
{
|
||||
title: '文件检索实现原理'
|
||||
title: '超级面板实现原理',
|
||||
path: '/blogs/superPannel/',
|
||||
},
|
||||
]
|
||||
},
|
||||
|
||||
175
docs/docs/blogs/superPannel/README.md
Normal file
175
docs/docs/blogs/superPannel/README.md
Normal file
@@ -0,0 +1,175 @@
|
||||
## 前言
|
||||
超级面板用于增强用户右击能力,实现快速呼起插件的能力,本次实现方式是通过 `robotjs` 以及 `iohook` 一起来完成
|
||||
|
||||
### 功能截图:
|
||||
|
||||
#### 文件夹下长按右建
|
||||
<img src=https://p6-juejin.byteimg.com/tos-cn-i-k3u1fbpfcp/9b3d6ea7a25b4b908acc471471628979~tplv-k3u1fbpfcp-watermark.image width=300 />
|
||||
|
||||
#### 选择文件后长按右键
|
||||
<img src=https://p9-juejin.byteimg.com/tos-cn-i-k3u1fbpfcp/8e220166cb464328b432f42d14ba9ab2~tplv-k3u1fbpfcp-watermark.image width=300 />
|
||||
|
||||
#### 选择文字后长按右键
|
||||
<img src=https://p1-juejin.byteimg.com/tos-cn-i-k3u1fbpfcp/f9f909d08a8441e8a506831796908ef9~tplv-k3u1fbpfcp-watermark.image width=300 />
|
||||
|
||||
## 实现原理
|
||||
|
||||
### 获取选中文案
|
||||
要实现改功能核心是要读取当前用户选中的文案或者文件,根据当前选择内容进行不同功能展示。但是核心有一个问题是如何来实现获取当前选中的内容。这个问题思考了很久很久,要想获取选中的文案,感觉唯一的办法是使用 `ctrl + c` 或者 `command + c` 来先复制到剪切板,再通过 `electron clipboard` 来获取当前剪切板内容。但是 `utools` 可不是通过先复制再长按这样的操作来实现的,而是直接选中文本或者文件长按后呼起超级面板。**所以一定要在右击长按前获取到当前选中的内容。**
|
||||
|
||||
如果要这么干,可能真的无解了,之前就因为这么想,才被无解了。正确的思路应该是先长按再获取选中的内容。别看只是掉了个个,但实现确实天壤之别:
|
||||
|
||||
1. 先获取选中内容:这就要求我们必须监听原生系统选中事件,但是 `electron` 并没有提供能力,我们也无法监听系统选择事件。
|
||||
2. 先右击,后获取内容,这样的好处在于先右击可以通过监听鼠标右击事件,相比选择事件更加容易。
|
||||
|
||||
所以思路就有了,先监听长按右击事件:
|
||||
|
||||
```js
|
||||
// macos
|
||||
const mouseEvents = require("osx-mouse");
|
||||
|
||||
const mouseTrack = mouseEvents();
|
||||
// 按下去的 time
|
||||
let down_time = 0;
|
||||
|
||||
// 是否弹起
|
||||
let isPress = false;
|
||||
|
||||
// 监听右击
|
||||
mouseTrack.on('right-down', () => {
|
||||
isPress = true;
|
||||
down_time = Date.now();
|
||||
// 长按 500ms 后触发
|
||||
setTimeout(async () => {
|
||||
if (isPress) {
|
||||
// 获取选中内容
|
||||
const copyResult = await getSelectedText();
|
||||
}, 500);
|
||||
})
|
||||
mouseTrack.on('right-up', () => {
|
||||
isPress = false;
|
||||
});
|
||||
|
||||
```
|
||||
|
||||
接下来一步就是要去实现获取选中内容,要获取选中内容有个比较骚的操作,就是:
|
||||
|
||||
1. 通过 `clipboard` 先获取当前剪切板内容,并存下 A
|
||||
2. 通过 `robot.js` 来调用系统 `command + c` 或者 `ctrl + c`
|
||||
3. 再通过 `clipboard` 先获取当前剪切板内容,并存下 B
|
||||
4. 再将 A 写到剪切板中,返回 B
|
||||
|
||||
先存剪切板内容的目的在于我们是偷偷帮用户执行了复制动作,当读取完用户选择内容后,需要回复用户之前的剪切板内容。接下来看一下简单的实现:
|
||||
|
||||
```js
|
||||
const getSelected = () => {
|
||||
return new Promise((resolve) => {
|
||||
// 缓存之前的文案
|
||||
const lastText = clipboard.readText('clipboard');
|
||||
|
||||
const platform = process.platform;
|
||||
|
||||
// 执行复制动作
|
||||
if (platform === 'darwin') {
|
||||
robot.keyTap('c', 'command');
|
||||
} else {
|
||||
robot.keyTap('c', 'control');
|
||||
}
|
||||
|
||||
setTimeout(() => {
|
||||
// 读取剪切板内容
|
||||
const text = clipboard.readText('clipboard') || ''
|
||||
const fileUrl = clipboard.read('public.file-url');
|
||||
|
||||
// 恢复剪切板内容
|
||||
clipboard.writeText(lastText);
|
||||
|
||||
resolve({
|
||||
text,
|
||||
fileUrl
|
||||
})
|
||||
}, 300);
|
||||
})
|
||||
}
|
||||
```
|
||||
### 通知超级面板窗口当前选中内容
|
||||
当获取到了选中内容后,接下来就是需要创建超级面板的 `BrowserWindow`:
|
||||
```js
|
||||
const { BrowserWindow, ipcMain, app } = require("electron");
|
||||
|
||||
module.exports = () => {
|
||||
let win;
|
||||
|
||||
let init = (mainWindow) => {
|
||||
if (win === null || win === undefined) {
|
||||
createWindow();
|
||||
}
|
||||
};
|
||||
|
||||
let createWindow = () => {
|
||||
win = new BrowserWindow({
|
||||
frame: false,
|
||||
autoHideMenuBar: true,
|
||||
width: 250,
|
||||
height: 50,
|
||||
show: false,
|
||||
alwaysOnTop: true,
|
||||
webPreferences: {
|
||||
webSecurity: false,
|
||||
enableRemoteModule: true,
|
||||
backgroundThrottling: false,
|
||||
nodeIntegration: true,
|
||||
devTools: false,
|
||||
},
|
||||
});
|
||||
win.loadURL(`file://${__static}/plugins/superPanel/index.html`);
|
||||
win.once('ready-to-show', () => win.show());
|
||||
win.on("closed", () => {
|
||||
win = undefined;
|
||||
});
|
||||
};
|
||||
|
||||
let getWindow = () => win;
|
||||
|
||||
return {
|
||||
init: init,
|
||||
getWindow: getWindow,
|
||||
};
|
||||
};
|
||||
```
|
||||
然后再通知 `superPanel` 进行内容展示:
|
||||
```js
|
||||
win.webContents.send('trigger-super-panel', {
|
||||
...copyResult,
|
||||
optionPlugin: optionPlugin.plugins,
|
||||
});
|
||||
```
|
||||
|
||||
### 超级面板点击操作
|
||||
接下来要实现超级面板点击操作,这块也是比较简单的了,直接上代码好了:
|
||||
#### 1. 打开 Terminal
|
||||
|
||||
```js
|
||||
const { spawn } = require ('child_process');
|
||||
|
||||
spawn('open', [ '-a', 'Terminal', fileUrl ]);
|
||||
```
|
||||
|
||||
#### 2. 新建文件
|
||||
|
||||
```js
|
||||
remote.dialog.showSaveDialog({
|
||||
title: "请选择要保存的文件名",
|
||||
buttonLabel: "保存",
|
||||
defaultPath: fileUrl.replace('file://', ''),
|
||||
showsTagField: false,
|
||||
nameFieldLabel: '',
|
||||
}).then(result => {
|
||||
fs.writeFileSync(result.filePath, '');
|
||||
});
|
||||
```
|
||||
|
||||
#### 3. 复制路径
|
||||
```js
|
||||
clipboard.writeText(fileUrl.replace('file://', ''))
|
||||
```
|
||||
@@ -54,3 +54,8 @@
|
||||
如果您还需要更多功能,欢迎来这里给我们提建议:[issues](https://github.com/clouDr-f2e/rubick/issues/20)
|
||||
有价值的想法我们会加入到后期的开发当中。同时也欢迎一起加入共建。
|
||||
|
||||
### 联系我们
|
||||
|
||||
扫码关注 Rubick 官微, 与我们保持联系:
|
||||
|
||||

|
||||
@@ -1,5 +1,4 @@
|
||||
## windows 本地启动项目
|
||||
**windows 项目地址目前在 `feat-win` 分支,需要切换到 `feat-win`。**
|
||||
如果您是在 `windows` 系统下使用本项目进行启动的话,如果出现了一些跑不起的情况,下面的一些经验或许可以帮助您。
|
||||
|
||||
### 安装依赖
|
||||
|
||||
23
package.json
23
package.json
@@ -1,16 +1,18 @@
|
||||
{
|
||||
"name": "rubick2",
|
||||
"version": "0.0.3-beta.4",
|
||||
"version": "0.0.11",
|
||||
"author": "muwoo <2424880409@qq.com>",
|
||||
"description": "An electron-vue project",
|
||||
"license": null,
|
||||
"main": "./dist/electron/main.js",
|
||||
"scripts": {
|
||||
"release": "node .electron-vue/build.js && electron-builder",
|
||||
"version": "standard-version",
|
||||
"release": "node .electron-vue/build.js && electron-builder --publish always",
|
||||
"build": "node .electron-vue/build.js && electron-builder",
|
||||
"dev": "node .electron-vue/dev-runner.js",
|
||||
"rebuild": " ./node_modules/.bin/electron-rebuild",
|
||||
"rebuild_win": "npm rebuild --runtime=electron --target=11.4.10 --disturl=https://atom.io/download/atom-shell --abi=85"
|
||||
"rebuild_win": "npm rebuild --runtime=electron --target=11.4.10 --disturl=https://atom.io/download/atom-shell --abi=85",
|
||||
"rebuild_linux": "npm rebuild --runtime=electron --target=11.4.10 --disturl=https://atom.io/download/atom-shell --abi=85"
|
||||
},
|
||||
"build": {
|
||||
"asar": true,
|
||||
@@ -54,7 +56,10 @@
|
||||
"allowToChangeInstallationDirectory": true
|
||||
},
|
||||
"linux": {
|
||||
"icon": "build/icons"
|
||||
"icon": "build/icons/",
|
||||
"publish": [
|
||||
"github"
|
||||
]
|
||||
}
|
||||
},
|
||||
"dependencies": {
|
||||
@@ -65,6 +70,7 @@
|
||||
"download-git-repo": "^3.0.2",
|
||||
"electron-is-dev": "^2.0.0",
|
||||
"electron-store": "^8.0.0",
|
||||
"extract-file-icon": "^0.3.2",
|
||||
"iohook": "^0.9.3",
|
||||
"is-chinese": "^1.4.2",
|
||||
"jian-pinyin": "^0.2.3",
|
||||
@@ -80,7 +86,9 @@
|
||||
"request-promise": "^4.2.6",
|
||||
"robotjs": "git+https://github.com/Toinane/robotjs.git",
|
||||
"semver": "^7.3.5",
|
||||
"shelljs": "^0.8.4",
|
||||
"sudo-prompt": "^9.2.1",
|
||||
"systeminformation": "^5.8.0",
|
||||
"unzip": "^0.1.11",
|
||||
"uuid": "^8.3.2",
|
||||
"vue": "^2.5.16",
|
||||
@@ -98,6 +106,7 @@
|
||||
"babel-preset-env": "^1.7.0",
|
||||
"babel-preset-stage-0": "^6.24.1",
|
||||
"babel-register": "^6.26.0",
|
||||
"babel-runtime": "^6.26.0",
|
||||
"cfonts": "^2.1.2",
|
||||
"chalk": "^2.4.1",
|
||||
"copy-webpack-plugin": "^4.5.1",
|
||||
@@ -105,7 +114,7 @@
|
||||
"css-loader": "^0.28.11",
|
||||
"del": "^3.0.0",
|
||||
"devtron": "^1.4.0",
|
||||
"electron": "^11.0.2",
|
||||
"electron": "^11.4.10",
|
||||
"electron-builder": "22.10.5",
|
||||
"electron-debug": "^1.5.0",
|
||||
"electron-devtools-installer": "^2.2.4",
|
||||
@@ -121,6 +130,7 @@
|
||||
"node-abi": "^2.30.0",
|
||||
"node-loader": "^0.6.0",
|
||||
"react": "^17.0.2",
|
||||
"standard-version": "^9.3.1",
|
||||
"style-loader": "^0.21.0",
|
||||
"url-loader": "^1.0.1",
|
||||
"vue-html-loader": "^1.2.4",
|
||||
@@ -140,7 +150,8 @@
|
||||
],
|
||||
"platforms": [
|
||||
"darwin",
|
||||
"win32"
|
||||
"win32",
|
||||
"linux"
|
||||
],
|
||||
"arches": [
|
||||
"x64",
|
||||
|
||||
11829
pnpm-lock.yaml
generated
Normal file
11829
pnpm-lock.yaml
generated
Normal file
File diff suppressed because it is too large
Load Diff
@@ -3,4 +3,4 @@ module.exports = () => ({
|
||||
separator: require("./separate")(),
|
||||
superPanel: require("./superPanel")(),
|
||||
main: require("./main")(),
|
||||
});
|
||||
})
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
const { BrowserWindow, protocol } = require("electron");
|
||||
const { BrowserWindow, protocol } = require("electron")
|
||||
module.exports = () => {
|
||||
let win;
|
||||
let win
|
||||
|
||||
let init = (opts) => {
|
||||
createWindow(opts);
|
||||
};
|
||||
createWindow(opts)
|
||||
}
|
||||
|
||||
let createWindow = (opts) => {
|
||||
const winURL = process.env.NODE_ENV === 'development'
|
||||
@@ -14,6 +14,7 @@ module.exports = () => {
|
||||
win = new BrowserWindow({
|
||||
height: 60,
|
||||
useContentSize: true,
|
||||
resizable: true,
|
||||
width: 800,
|
||||
frame: false,
|
||||
title: '拉比克',
|
||||
@@ -23,6 +24,7 @@ module.exports = () => {
|
||||
webSecurity: false,
|
||||
enableRemoteModule: true,
|
||||
backgroundThrottling: false,
|
||||
contextIsolation: false,
|
||||
webviewTag: true,
|
||||
nodeIntegration: true // 在网页中集成Node
|
||||
}
|
||||
@@ -31,24 +33,24 @@ module.exports = () => {
|
||||
win.loadURL(winURL)
|
||||
|
||||
protocol.interceptFileProtocol('image', (req, callback) => {
|
||||
const url = req.url.substr(8);
|
||||
callback(decodeURI(url));
|
||||
const url = req.url.substr(8)
|
||||
callback(decodeURI(url))
|
||||
}, (error) => {
|
||||
if (error) {
|
||||
console.error('Failed to register protocol');
|
||||
console.error('Failed to register protocol')
|
||||
}
|
||||
});
|
||||
})
|
||||
|
||||
win.once('ready-to-show', () => win.show());
|
||||
win.once('ready-to-show', () => win.show())
|
||||
win.on("closed", () => {
|
||||
win = undefined;
|
||||
});
|
||||
};
|
||||
win = undefined
|
||||
})
|
||||
}
|
||||
|
||||
let getWindow = () => win;
|
||||
let getWindow = () => win
|
||||
|
||||
return {
|
||||
init: init,
|
||||
getWindow: getWindow,
|
||||
};
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
const { BrowserWindow, nativeImage } = require("electron");
|
||||
const { BrowserWindow, nativeImage } = require("electron")
|
||||
|
||||
module.exports = () => {
|
||||
let win;
|
||||
let win
|
||||
|
||||
let init = (x, y) => {
|
||||
if (win === null || win === undefined) {
|
||||
createWindow();
|
||||
createWindow()
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
let createWindow = () => {
|
||||
win = new BrowserWindow({
|
||||
@@ -22,20 +22,21 @@ module.exports = () => {
|
||||
hasShadow: false,
|
||||
webPreferences: {
|
||||
nodeIntegration: true,
|
||||
contextIsolation: false,
|
||||
devTools: false,
|
||||
},
|
||||
});
|
||||
})
|
||||
|
||||
win.loadURL(`file://${__static}/plugins/picker/index.html`);
|
||||
win.loadURL(`file://${__static}/plugins/picker/index.html`)
|
||||
win.on("closed", () => {
|
||||
win = undefined;
|
||||
});
|
||||
};
|
||||
win = undefined
|
||||
})
|
||||
}
|
||||
|
||||
let getWindow = () => win;
|
||||
let getWindow = () => win
|
||||
|
||||
return {
|
||||
init: init,
|
||||
getWindow: getWindow,
|
||||
};
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
const { BrowserWindow } = require("electron");
|
||||
const { BrowserWindow } = require("electron")
|
||||
|
||||
module.exports = () => {
|
||||
let win;
|
||||
let win
|
||||
|
||||
let init = (opts) => {
|
||||
createWindow(opts);
|
||||
};
|
||||
createWindow(opts)
|
||||
}
|
||||
|
||||
let createWindow = (opts) => {
|
||||
const winURL = process.env.NODE_ENV === 'development'
|
||||
@@ -22,27 +22,28 @@ module.exports = () => {
|
||||
webSecurity: false,
|
||||
enableRemoteModule: true,
|
||||
backgroundThrottling: false,
|
||||
contextIsolation: false,
|
||||
webviewTag: true,
|
||||
nodeIntegration: true // 在网页中集成Node
|
||||
}
|
||||
});
|
||||
})
|
||||
process.env.NODE_ENV === 'development' ? win.loadURL(winURL) : win.loadFile(winURL, {
|
||||
hash: `#/plugin`,
|
||||
});
|
||||
})
|
||||
|
||||
win.webContents.executeJavaScript(`window.setPluginInfo(${opts})`).then(() => {
|
||||
win.show()
|
||||
});
|
||||
})
|
||||
|
||||
win.on("closed", () => {
|
||||
win = undefined;
|
||||
});
|
||||
};
|
||||
win = undefined
|
||||
})
|
||||
}
|
||||
|
||||
let getWindow = () => win;
|
||||
let getWindow = () => win
|
||||
|
||||
return {
|
||||
init: init,
|
||||
getWindow: getWindow,
|
||||
};
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ import pkg from '../../../package.json';
|
||||
const os = require('os');
|
||||
|
||||
const version = pkg.version;
|
||||
const releaseUrl = 'http://rubick-server.qa.91jkys.com/release/query';
|
||||
const releaseUrl = 'http://118.195.176.247:8080/release/query';
|
||||
|
||||
export async function autoUpdate() {
|
||||
let res;
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
import path from "path";
|
||||
import fs from 'fs';
|
||||
import {getlocalDataFile} from "./utils";
|
||||
import os from 'os';
|
||||
import path from "path"
|
||||
import fs from 'fs'
|
||||
import { getlocalDataFile } from "./utils"
|
||||
import os from 'os'
|
||||
|
||||
const configPath = path.join(getlocalDataFile(), './rubick-config.json');
|
||||
const configPath = path.join(getlocalDataFile(), './rubick-config.json')
|
||||
|
||||
let defaultConfig = {
|
||||
Darwin: {
|
||||
version: 2,
|
||||
version: 3,
|
||||
perf: {
|
||||
shortCut: {
|
||||
showAndHidden: 'Option+R',
|
||||
@@ -32,7 +32,32 @@ let defaultConfig = {
|
||||
global: []
|
||||
},
|
||||
Windows_NT: {
|
||||
version: 2,
|
||||
version: 3,
|
||||
perf: {
|
||||
shortCut: {
|
||||
showAndHidden: 'Option+R',
|
||||
separate: 'Ctrl+D',
|
||||
quit: 'Shift+Escape'
|
||||
},
|
||||
common: {
|
||||
start: true,
|
||||
space: true,
|
||||
},
|
||||
local: {
|
||||
search: true,
|
||||
}
|
||||
},
|
||||
superPanel: {
|
||||
baiduAPI: {
|
||||
key: '',
|
||||
appid: '',
|
||||
},
|
||||
mouseDownTime: 500
|
||||
},
|
||||
global: []
|
||||
},
|
||||
Linux: {
|
||||
version: 3,
|
||||
perf: {
|
||||
shortCut: {
|
||||
showAndHidden: 'Option+R',
|
||||
@@ -63,22 +88,22 @@ global.opConfig = {
|
||||
const platform = os.type();
|
||||
try {
|
||||
if (!opConfig.config) {
|
||||
opConfig.config = JSON.parse(fs.readFileSync(configPath) || JSON.stringify(defaultConfig[platform]));
|
||||
opConfig.config = JSON.parse(fs.readFileSync(configPath) || JSON.stringify(defaultConfig[platform]))
|
||||
}
|
||||
// 重置
|
||||
if (!opConfig.version || opConfig.version < defaultConfig[platform].version) {
|
||||
opConfig.config = defaultConfig[platform];
|
||||
fs.writeFileSync(configPath, JSON.stringify(opConfig.config));
|
||||
if (!opConfig.config.version || opConfig.config.version < defaultConfig[platform].version) {
|
||||
opConfig.config = defaultConfig[platform]
|
||||
fs.writeFileSync(configPath, JSON.stringify(opConfig.config))
|
||||
}
|
||||
return opConfig.config;
|
||||
return opConfig.config
|
||||
} catch (e) {
|
||||
opConfig.config = defaultConfig[platform]
|
||||
return opConfig.config;
|
||||
return opConfig.config
|
||||
}
|
||||
},
|
||||
set(key, value) {
|
||||
opConfig.config[key] = value;
|
||||
fs.writeFileSync(configPath, JSON.stringify(opConfig.config));
|
||||
fs.writeFileSync(configPath, JSON.stringify(opConfig.config))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
BIN
src/main/common/icons/charger.png
Normal file
BIN
src/main/common/icons/charger.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.5 KiB |
BIN
src/main/common/icons/chip.png
Normal file
BIN
src/main/common/icons/chip.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.4 KiB |
BIN
src/main/common/icons/hard-disk-drive.png
Normal file
BIN
src/main/common/icons/hard-disk-drive.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 876 B |
BIN
src/main/common/icons/internet.png
Normal file
BIN
src/main/common/icons/internet.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.5 KiB |
BIN
src/main/common/icons/power.png
Normal file
BIN
src/main/common/icons/power.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.7 KiB |
BIN
src/main/common/icons/ram.png
Normal file
BIN
src/main/common/icons/ram.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.2 KiB |
@@ -1,4 +1,14 @@
|
||||
import {app, nativeImage, BrowserWindow, clipboard, globalShortcut, ipcMain, Notification, screen, TouchBar} from "electron";
|
||||
import {
|
||||
app,
|
||||
nativeImage,
|
||||
BrowserWindow,
|
||||
clipboard,
|
||||
globalShortcut,
|
||||
ipcMain,
|
||||
Notification,
|
||||
screen,
|
||||
TouchBar
|
||||
} from 'electron';
|
||||
import {exec, spawn} from "child_process";
|
||||
import robot from "robotjs";
|
||||
import Api from "./api";
|
||||
@@ -6,6 +16,7 @@ import ioHook from 'iohook';
|
||||
import {throttle, commonConst} from './utils';
|
||||
import path from 'path';
|
||||
import fs from "fs";
|
||||
import mito from './monitor';
|
||||
|
||||
const browsers = require("../browsers")();
|
||||
const {picker, separator, superPanel} = browsers;
|
||||
@@ -53,7 +64,7 @@ class Listener {
|
||||
// 注册偏好快捷键
|
||||
globalShortcut.register(config.perf.shortCut.showAndHidden, () => {
|
||||
const {x, y} = screen.getCursorScreenPoint();
|
||||
const currentDisplay = screen.getDisplayNearestPoint({ x, y });
|
||||
const currentDisplay = screen.getDisplayNearestPoint({x, y});
|
||||
const wx = parseInt(currentDisplay.workArea.x + currentDisplay.workArea.width / 2 - 400);
|
||||
const wy = parseInt(currentDisplay.workArea.y + currentDisplay.workArea.height / 2 - 200);
|
||||
|
||||
@@ -85,11 +96,17 @@ class Listener {
|
||||
|
||||
init(mainWindow) {
|
||||
this.fn = throttle(({x, y}, picker) => {
|
||||
const img = robot.screen.capture(parseInt(x) - 5, parseInt(y) - 5, 9, 9);
|
||||
const {scaleFactor} = screen.getDisplayNearestPoint({x, y});
|
||||
const img = robot.screen.capture(
|
||||
x - parseInt(5 / scaleFactor),
|
||||
y - parseInt(5 / scaleFactor),
|
||||
10,
|
||||
10
|
||||
);
|
||||
|
||||
const colors = {}
|
||||
|
||||
for(let i = 0; i< 9; i++) {
|
||||
for (let i = 0; i < 9; i++) {
|
||||
colors[i] = {};
|
||||
for (let j = 0; j < 9; j++) {
|
||||
colors[i][j] = img.colorAt(j, i);
|
||||
@@ -135,7 +152,7 @@ class Listener {
|
||||
|
||||
const colors = {}
|
||||
|
||||
for(let i = 0; i< 9; i++) {
|
||||
for (let i = 0; i < 9; i++) {
|
||||
colors[i] = {};
|
||||
for (let j = 0; j < 9; j++) {
|
||||
colors[i][j] = img.colorAt(j, i);
|
||||
@@ -166,7 +183,7 @@ class Listener {
|
||||
let y = e.y
|
||||
const color = "#" + robot.getPixelColor(parseInt(x), parseInt(y));
|
||||
clipboard.writeText("#" + robot.getPixelColor(parseInt(x), parseInt(y)));
|
||||
new Notification({ title: 'Rubick 通知', body: `${color} 已保存到剪切板` }).show();
|
||||
new Notification({title: 'Rubick 通知', body: `${color} 已保存到剪切板`}).show();
|
||||
this.closePicker();
|
||||
}
|
||||
});
|
||||
@@ -187,7 +204,8 @@ class Listener {
|
||||
}
|
||||
|
||||
initTouchBar(mainWindow) {
|
||||
const { TouchBarButton, TouchBarGroup, TouchBarPopover } = TouchBar;
|
||||
if (!commonConst.macOS()) return;
|
||||
const {TouchBarButton, TouchBarGroup, TouchBarPopover} = TouchBar;
|
||||
let items = [];
|
||||
let system = [];
|
||||
ipcMain.on('pluginInit', (e, args) => {
|
||||
@@ -199,7 +217,6 @@ class Listener {
|
||||
|
||||
return new TouchBarButton({
|
||||
icon,
|
||||
backgroundColor: '#ff9fb4',
|
||||
click() {
|
||||
mainWindow.webContents.send('superPanel-openPlugin', {
|
||||
cmd: item.features[0].cmds.filter(cmd => typeof cmd === 'string')[0],
|
||||
@@ -211,10 +228,9 @@ class Listener {
|
||||
}).filter(Boolean);
|
||||
|
||||
system = args.plugins.map((item) => {
|
||||
if(item.type === 'system') {
|
||||
if (item.type === 'system') {
|
||||
return new TouchBarButton({
|
||||
icon: nativeImage.createFromDataURL(item.logo).resize({width: 20, height: 20}),
|
||||
backgroundColor: '#ff9fb4',
|
||||
click() {
|
||||
mainWindow.webContents.send('superPanel-openPlugin', {
|
||||
cmd: item.features[0].cmds.filter(cmd => typeof cmd === 'string')[0],
|
||||
@@ -235,10 +251,21 @@ class Listener {
|
||||
showCloseButton: true
|
||||
});
|
||||
|
||||
const monitor = new TouchBarPopover({
|
||||
items: mito.touchBar,
|
||||
label: '系统监控',
|
||||
showCloseButton: true
|
||||
});
|
||||
|
||||
const touchBar = new TouchBar({
|
||||
items: [plugin, ...system]
|
||||
items: [
|
||||
plugin,
|
||||
monitor,
|
||||
...system
|
||||
]
|
||||
});
|
||||
mainWindow.setTouchBar(touchBar);
|
||||
mito.start(mainWindow);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -347,6 +374,7 @@ class Listener {
|
||||
windowMoveInit(win) {
|
||||
let hasInit = false;
|
||||
ipcMain.on('window-move', () => {
|
||||
let bounds = win.getBounds();
|
||||
if (!hasInit) {
|
||||
hasInit = true;
|
||||
ioHook.start(false);
|
||||
@@ -360,8 +388,9 @@ class Listener {
|
||||
const cursorPosition = screen.getCursorScreenPoint();
|
||||
const dx = winStartPosition.x + cursorPosition.x - mouseStartPosition.x;
|
||||
const dy = winStartPosition.y + cursorPosition.y - mouseStartPosition.y;
|
||||
let {x, y} = {x: dx, y: dy};
|
||||
win.setPosition(parseInt(x), parseInt(y));
|
||||
bounds.x = parseInt(dx);
|
||||
bounds.y = parseInt(dy);
|
||||
win.setBounds(bounds);
|
||||
});
|
||||
|
||||
ioHook.on('mouseup', e => {
|
||||
|
||||
124
src/main/common/monitor.js
Normal file
124
src/main/common/monitor.js
Normal file
@@ -0,0 +1,124 @@
|
||||
const {TouchBar} = require('electron')
|
||||
const path = require('path')
|
||||
const si = require('systeminformation');
|
||||
const spawn = require('child_process').spawn;
|
||||
|
||||
const {TouchBarButton, TouchBarSpacer} = TouchBar;
|
||||
|
||||
const LOAD_NORMAL = "#2ecc71";
|
||||
const LOAD_MEDIUM = "#f1c40f";
|
||||
const LOAD_HIGH = "#d35400";
|
||||
const LOAD_SEVERE = "#e74c3c";
|
||||
|
||||
const cpu = new TouchBarButton({
|
||||
label: '',
|
||||
backgroundColor: "#bdc3c7",
|
||||
icon: path.join(__dirname, 'icons/chip.png'),
|
||||
iconPosition: "left",
|
||||
click: () => {
|
||||
spawn("/System/Applications/Utilities/Activity Monitor.app/Contents/MacOS/Activity\ Monitor", []);
|
||||
}
|
||||
});
|
||||
|
||||
const memory = new TouchBarButton({
|
||||
label: '',
|
||||
backgroundColor: "#bdc3c7",
|
||||
icon: path.join(__dirname, 'icons/ram.png'),
|
||||
iconPosition: "left"
|
||||
});
|
||||
|
||||
const network = new TouchBarButton({
|
||||
label: '',
|
||||
backgroundColor: '#3498db',
|
||||
icon: path.join(__dirname, 'icons/internet.png'),
|
||||
iconPosition: "left"
|
||||
});
|
||||
|
||||
const battery = new TouchBarButton({
|
||||
label: '',
|
||||
backgroundColor: "#bdc3c7",
|
||||
icon: path.join(__dirname, 'icons/power.png'),
|
||||
iconPosition: "left"
|
||||
});
|
||||
|
||||
const updateData = () => {
|
||||
si.currentLoad(function(data) {
|
||||
if (typeof data !== 'undefined' && data){
|
||||
const load = data.currentLoad.toFixed(0)
|
||||
cpu.label = load+"%"
|
||||
if (load <= 20) cpu.backgroundColor = LOAD_NORMAL;
|
||||
else if (load > 20 && load <= 40) cpu.backgroundColor = LOAD_MEDIUM;
|
||||
else if (load > 40 && load <= 80) cpu.backgroundColor = LOAD_HIGH;
|
||||
else if (load > 80 && load <= 100) cpu.backgroundColor = LOAD_SEVERE;
|
||||
}
|
||||
})
|
||||
si.mem(function(data) {
|
||||
if (typeof data !== 'undefined' && data){
|
||||
const load = ((100* data.active ) / data.total).toFixed(0)
|
||||
memory.label = load+"%"
|
||||
if (load <= 20) memory.backgroundColor = LOAD_NORMAL;
|
||||
else if (load > 20 && load <= 40) memory.backgroundColor = LOAD_MEDIUM;
|
||||
else if (load > 40 && load <= 80) memory.backgroundColor = LOAD_HIGH;
|
||||
else if (load > 80 && load <= 100) memory.backgroundColor = LOAD_SEVERE;
|
||||
}
|
||||
|
||||
})
|
||||
si.networkStats("", function(data) {
|
||||
if (typeof data !== 'undefined' && data){
|
||||
const kbtx = (data[0].tx_sec * 0.001).toFixed(0)
|
||||
const kbrx = (data[0].rx_sec * 0.001).toFixed(0)
|
||||
const l = (kbtx+kbrx).toString().length
|
||||
|
||||
network.label = "⇡"+ (kbtx*0.001).toFixed(2)
|
||||
+" ⇣"+ (kbrx*0.001).toFixed(2) +" MB/s"
|
||||
|
||||
}
|
||||
})
|
||||
|
||||
si.battery( function(data) {
|
||||
if (typeof data !== 'undefined' && data){
|
||||
if (data.ischarging){
|
||||
battery.icon = path.join(__dirname, 'icons/charger.png')
|
||||
}else{
|
||||
battery.icon = path.join(__dirname, 'icons/power.png')
|
||||
}
|
||||
const load = data.percent.toFixed(0)
|
||||
battery.label = load+"%"
|
||||
if (load <= 20) battery.backgroundColor = LOAD_SEVERE;
|
||||
else if (load > 20 && load <= 40) battery.backgroundColor = LOAD_HIGH;
|
||||
else if (load > 40 && load <= 80) battery.backgroundColor = LOAD_MEDIUM;
|
||||
else if (load > 80 && load <= 100) battery.backgroundColor = LOAD_NORMAL
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
const touchBar = new TouchBar({
|
||||
items: [
|
||||
cpu,
|
||||
new TouchBarSpacer({size: 'small'}),
|
||||
memory,
|
||||
new TouchBarSpacer({size: 'small'}),
|
||||
network,
|
||||
new TouchBarSpacer({size: 'small'}),
|
||||
battery,
|
||||
]
|
||||
})
|
||||
|
||||
let intervalObj;
|
||||
|
||||
const start = (window) => {
|
||||
window.on('blur', () => {
|
||||
clearInterval(intervalObj);
|
||||
});
|
||||
window.on('focus', () => {
|
||||
intervalObj = setInterval(() => {
|
||||
updateData();
|
||||
}, 1000);
|
||||
});
|
||||
updateData();
|
||||
}
|
||||
|
||||
export default {
|
||||
start,
|
||||
touchBar,
|
||||
}
|
||||
@@ -1,18 +1,20 @@
|
||||
import { app, globalShortcut } from 'electron'
|
||||
import '../renderer/store'
|
||||
import init from './common/common';
|
||||
import {autoUpdate} from './common/autoUpdate';
|
||||
import createTray from './tray';
|
||||
import {commonConst} from './common/utils';
|
||||
import pkg from '../../package.json';
|
||||
import init from './common/common'
|
||||
import { autoUpdate } from './common/autoUpdate'
|
||||
import createTray from './tray'
|
||||
import { commonConst } from './common/utils'
|
||||
import pkg from '../../package.json'
|
||||
import Store from 'electron-store';
|
||||
|
||||
const {main} = require("./browsers")();
|
||||
Store.initRenderer()
|
||||
|
||||
const { main } = require("./browsers")()
|
||||
|
||||
if (commonConst.production()) {
|
||||
global.__static = require('path').join(__dirname, '/static').replace(/\\/g, '\\\\')
|
||||
}
|
||||
// to fix https://github.com/electron/electron/issues/18397
|
||||
app.allowRendererProcessReuse = false;
|
||||
app.allowRendererProcessReuse = false
|
||||
|
||||
class initApp {
|
||||
launchApp() {
|
||||
@@ -28,28 +30,28 @@ class initApp {
|
||||
}
|
||||
|
||||
createWindow() {
|
||||
main.init();
|
||||
init(main.getWindow());
|
||||
main.init()
|
||||
init(main.getWindow())
|
||||
}
|
||||
|
||||
beforeReady() {
|
||||
// 系统托盘
|
||||
if (commonConst.macOS()) {
|
||||
if (commonConst.production() && !app.isInApplicationsFolder()) {
|
||||
app.moveToApplicationsFolder();
|
||||
app.moveToApplicationsFolder()
|
||||
} else {
|
||||
app.dock.hide();
|
||||
app.dock.hide()
|
||||
}
|
||||
}else {
|
||||
app.disableHardwareAcceleration();
|
||||
} else {
|
||||
app.disableHardwareAcceleration()
|
||||
}
|
||||
}
|
||||
|
||||
onReady() {
|
||||
const readyFunction = () => {
|
||||
this.createWindow();
|
||||
createTray(main.getWindow());
|
||||
autoUpdate();
|
||||
this.createWindow()
|
||||
createTray(main.getWindow())
|
||||
autoUpdate()
|
||||
}
|
||||
if (!app.isReady()) {
|
||||
app.on('ready', readyFunction)
|
||||
@@ -61,25 +63,25 @@ class initApp {
|
||||
onRunning() {
|
||||
app.on('second-instance', (event, commandLine, workingDirectory) => {
|
||||
// 当运行第二个实例时,将会聚焦到myWindow这个窗口
|
||||
const win = main.getWindow();
|
||||
const win = main.getWindow()
|
||||
if (win) {
|
||||
if (win.isMinimized()) {
|
||||
win.restore();
|
||||
win.restore()
|
||||
}
|
||||
win.focus();
|
||||
win.focus()
|
||||
}
|
||||
});
|
||||
})
|
||||
app.on('activate', () => {
|
||||
if (!main.getWindow()) {
|
||||
this.createWindow();
|
||||
this.createWindow()
|
||||
}
|
||||
});
|
||||
})
|
||||
if (commonConst.windows()) {
|
||||
app.setAppUserModelId(pkg.build.appId);
|
||||
app.setAppUserModelId(pkg.build.appId)
|
||||
}
|
||||
}
|
||||
|
||||
onQuit () {
|
||||
onQuit() {
|
||||
app.on('window-all-closed', () => {
|
||||
if (process.platform !== 'darwin') {
|
||||
app.quit()
|
||||
@@ -106,4 +108,4 @@ class initApp {
|
||||
}
|
||||
}
|
||||
|
||||
(new initApp()).launchApp();
|
||||
(new initApp()).launchApp()
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<template>
|
||||
<div @mousedown="drag" >
|
||||
<a-layout id="components-layout">
|
||||
<div @mousedown="drag">
|
||||
<a-layout id="components-layout">
|
||||
<div v-if="!searchType" class="rubick-select">
|
||||
<div class="tag-container" v-if="selected">
|
||||
<a-tag
|
||||
@@ -16,22 +16,26 @@
|
||||
<a-input
|
||||
id="search"
|
||||
:placeholder="
|
||||
subPlaceHolder && selected && selected.key === 'plugin-container'
|
||||
? subPlaceHolder
|
||||
: 'Hi, Rubick'
|
||||
"
|
||||
subPlaceHolder && selected && selected.key === 'plugin-container'
|
||||
? subPlaceHolder
|
||||
: 'Hi, Rubick'
|
||||
"
|
||||
@mousedown.stop="dragWhenInput"
|
||||
class="main-input"
|
||||
@change="(e) => search({ value: e.target.value })"
|
||||
@keydown.ctrl.86="shouldPaste"
|
||||
:value="searchValue"
|
||||
:maxLength="selected && selected.key !== 'plugin-container' ? 0 : 1000"
|
||||
:maxLength="
|
||||
selected && selected.key !== 'plugin-container' ? 0 : 1000
|
||||
"
|
||||
@keydown.down="(e) => changeCurrent(1)"
|
||||
@keydown.up="() => changeCurrent(-1)"
|
||||
@keypress.enter="
|
||||
(e) => targetSearch({ value: e.target.value, type: 'enter' })
|
||||
"
|
||||
(e) => targetSearch({ value: e.target.value, type: 'enter' })
|
||||
"
|
||||
@keypress.space="
|
||||
(e) => targetSearch({ value: e.target.value, type: 'space' })
|
||||
"
|
||||
(e) => targetSearch({ value: e.target.value, type: 'space' })
|
||||
"
|
||||
>
|
||||
<div @click="goMenu" class="suffix-tool" slot="suffix">
|
||||
<a-icon
|
||||
@@ -41,12 +45,14 @@
|
||||
/>
|
||||
<div v-if="selected && selected.icon" style="position: relative">
|
||||
<a-spin v-show="pluginLoading" class="loading">
|
||||
<a-icon slot="indicator" type="loading" style="font-size: 42px" spin />
|
||||
<a-icon
|
||||
slot="indicator"
|
||||
type="loading"
|
||||
style="font-size: 42px"
|
||||
spin
|
||||
/>
|
||||
</a-spin>
|
||||
<img
|
||||
class="icon-tool"
|
||||
:src="selected.icon"
|
||||
/>
|
||||
<img class="icon-tool" :src="selected.icon" />
|
||||
</div>
|
||||
<div v-else class="rubick-logo">
|
||||
<img src="./assets/imgs/logo.png" />
|
||||
@@ -86,19 +92,19 @@
|
||||
:placeholder="subPlaceHolder"
|
||||
class="sub-input"
|
||||
@change="
|
||||
(e) =>
|
||||
search({
|
||||
value: e.target.value,
|
||||
searchType: pluginInfo.searchType,
|
||||
})
|
||||
"
|
||||
(e) =>
|
||||
search({
|
||||
value: e.target.value,
|
||||
searchType: pluginInfo.searchType,
|
||||
})
|
||||
"
|
||||
:value="searchValue"
|
||||
@keypress.enter="
|
||||
(e) => targetSearch({ value: e.target.value, type: 'enter' })
|
||||
"
|
||||
(e) => targetSearch({ value: e.target.value, type: 'enter' })
|
||||
"
|
||||
@keypress.space="
|
||||
(e) => targetSearch({ value: e.target.value, type: 'space' })
|
||||
"
|
||||
(e) => targetSearch({ value: e.target.value, type: 'space' })
|
||||
"
|
||||
></a-input>
|
||||
</div>
|
||||
|
||||
@@ -113,13 +119,14 @@
|
||||
</template>
|
||||
<script>
|
||||
import { mapActions, mapMutations, mapState } from "vuex";
|
||||
import { ipcRenderer, remote } from "electron";
|
||||
import { ipcRenderer, remote, clipboard } from "electron";
|
||||
import {
|
||||
getWindowHeight,
|
||||
debounce,
|
||||
searchKeyValues,
|
||||
fileLists,
|
||||
} from "./assets/common/utils";
|
||||
import { commonConst } from "../main/common/utils";
|
||||
const opConfig = remote.getGlobal("opConfig");
|
||||
const { Menu, MenuItem } = remote;
|
||||
|
||||
@@ -166,20 +173,21 @@ export default {
|
||||
const feature = plugin.features;
|
||||
feature.forEach((fe) => {
|
||||
const cmd = searchKeyValues(fe.cmds, args)[0];
|
||||
const systemPlugin = fileLists.filter(
|
||||
(plugin) => {
|
||||
let has = false;
|
||||
plugin.keyWords.some(keyWord => {
|
||||
if (keyWord.toLocaleUpperCase().indexOf(args.toLocaleUpperCase()) >= 0) {
|
||||
has = keyWord;
|
||||
plugin.name = keyWord;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
});
|
||||
return has;
|
||||
}
|
||||
)[0];
|
||||
const systemPlugin = fileLists.filter((plugin) => {
|
||||
let has = false;
|
||||
plugin.keyWords.some((keyWord) => {
|
||||
if (
|
||||
keyWord.toLocaleUpperCase().indexOf(args.toLocaleUpperCase()) >=
|
||||
0
|
||||
) {
|
||||
has = keyWord;
|
||||
plugin.name = keyWord;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
});
|
||||
return has;
|
||||
})[0];
|
||||
if (cmd) {
|
||||
config = {
|
||||
cmd: cmd,
|
||||
@@ -208,7 +216,57 @@ export default {
|
||||
methods: {
|
||||
...mapActions("main", ["onSearch", "showMainUI", "openPlugin"]),
|
||||
...mapMutations("main", ["commonUpdate"]),
|
||||
shouldPaste(e) {
|
||||
let filePath = "";
|
||||
if (commonConst.windows()) {
|
||||
const rawFilePath = clipboard.read("FileNameW");
|
||||
filePath = rawFilePath.replace(
|
||||
new RegExp(String.fromCharCode(0), "g"),
|
||||
""
|
||||
);
|
||||
if (filePath.indexOf("plugin.json") >= 0) {
|
||||
this.search({
|
||||
filePath,
|
||||
disableDebounce: true,
|
||||
});
|
||||
}
|
||||
} else if (commonConst.linux()) {
|
||||
const text = clipboard.readText("selection");
|
||||
// 在gnome的文件管理器中,复制文件的结果通常是
|
||||
//
|
||||
// x-special/nautilus-clipboard
|
||||
// copy
|
||||
// file:///home/admin/dir/plugin.json
|
||||
const splitLF = text.split(" ");
|
||||
let pathUrl;
|
||||
if (
|
||||
splitLF.length == 3 &&
|
||||
splitLF[0] === "x-special/nautilus-clipboard" &&
|
||||
splitLF[1] === "copy" &&
|
||||
(pathUrl = splitLF[2]).startsWith("file://") &&
|
||||
pathUrl.indexOf("plugin.json") >= 0
|
||||
) {
|
||||
filePath = pathUrl.slice(7);
|
||||
this.search({
|
||||
filePath,
|
||||
disableDebounce: true,
|
||||
});
|
||||
}
|
||||
// 其他的发行版、文件管理器尚未测试
|
||||
}
|
||||
},
|
||||
/**
|
||||
* @param {Object} v 搜索配置对象。
|
||||
* 若v.disableDebounce为true,则不会触发防抖动保护。
|
||||
* 该值的作用是让search()方法被多个监听器同时调用时,在某些情况下无视其他监听器的防抖动保护。
|
||||
* 其他属性 v.value、v.filePath 参见 src/renderer/store/modules/main.js的onSearch函数。
|
||||
*/
|
||||
search(v) {
|
||||
console.log("search was called , param v is :", v);
|
||||
if (!v.disableDebounce) {
|
||||
this.onSearch(v);
|
||||
return;
|
||||
}
|
||||
if (!this.searchFn) {
|
||||
this.searchFn = debounce(this.onSearch, 200);
|
||||
}
|
||||
@@ -247,7 +305,7 @@ export default {
|
||||
|
||||
renderTitle(title) {
|
||||
if (typeof title !== "string") return;
|
||||
const result = title.split(this.searchValue);
|
||||
const result = title.toLowerCase().split(this.searchValue.toLowerCase());
|
||||
if (result && result.length > 1) {
|
||||
return `<div>${result[0]}<span style="color: red">${this.searchValue}</span>${result[1]}</div>`;
|
||||
} else {
|
||||
@@ -275,9 +333,13 @@ export default {
|
||||
ipcRenderer.send("changeWindowSize-rubick", {
|
||||
height: getWindowHeight([]),
|
||||
});
|
||||
this.$router.push({
|
||||
path: "/home",
|
||||
});
|
||||
if (this.$router.history.current.fullPath !== "/home") {
|
||||
// 该if是为了避免跳转到相同路由而报错。
|
||||
// (之前在输入栏为空时按退格会疯狂报错)
|
||||
this.$router.push({
|
||||
path: "/home",
|
||||
});
|
||||
}
|
||||
},
|
||||
newWindow() {
|
||||
ipcRenderer.send("new-window", {
|
||||
@@ -327,8 +389,13 @@ export default {
|
||||
this.changePath({ key: "market" });
|
||||
},
|
||||
drag() {
|
||||
ipcRenderer.send('window-move');
|
||||
}
|
||||
ipcRenderer.send("window-move");
|
||||
},
|
||||
dragWhenInput(e) {
|
||||
if (this.searchValue == "") {
|
||||
ipcRenderer.send("window-move");
|
||||
}
|
||||
},
|
||||
},
|
||||
computed: {
|
||||
...mapState("main", [
|
||||
@@ -466,7 +533,7 @@ export default {
|
||||
cursor: pointer;
|
||||
}
|
||||
.loading {
|
||||
position:absolute;
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
}
|
||||
|
||||
120
src/renderer/assets/common/darwin-app.js
Normal file
120
src/renderer/assets/common/darwin-app.js
Normal file
@@ -0,0 +1,120 @@
|
||||
import fs from "fs";
|
||||
import path from "path";
|
||||
import {nativeImage} from "electron";
|
||||
import translate from "./translate";
|
||||
import {APP_FINDER_PATH} from "./constans";
|
||||
import iconvLite from "iconv-lite";
|
||||
import bpList from "bplist-parser";
|
||||
|
||||
const fileLists = [];
|
||||
|
||||
const isZhRegex = /[\u4e00-\u9fa5]/;
|
||||
const getDisplayNameRegex = /\"(?:CFBundleDisplayName)\"\s\=\s\"(.*)\"/;
|
||||
|
||||
async function getAppZhName(rootPath, appName) {
|
||||
try {
|
||||
const ERROR_RESULT = '';
|
||||
const systemPath = path.join(rootPath, `${appName}/Contents/Resources/zh_CN.lproj/InfoPlist.strings`);
|
||||
const customizePath = path.join(rootPath, `${appName}/Contents/Resources/zh-Hans.lproj/InfoPlist.strings`);
|
||||
let appInfoPath = '';
|
||||
|
||||
if (fs.existsSync(systemPath)) {
|
||||
appInfoPath = systemPath;
|
||||
} else if (fs.existsSync(customizePath)) {
|
||||
appInfoPath = customizePath;
|
||||
} else {
|
||||
return ERROR_RESULT;
|
||||
}
|
||||
let appZhName = '';
|
||||
if (rootPath == '/Applications') {
|
||||
const container = iconvLite.decode(fs.readFileSync(appInfoPath), 'utf-16');
|
||||
if (container) {
|
||||
const res = container.match(getDisplayNameRegex);
|
||||
appZhName = res && res[1];
|
||||
} else {
|
||||
return ERROR_RESULT;
|
||||
}
|
||||
} else {
|
||||
const [{ CFBundleDisplayName = '', CFBundleName = '' }] = await bpList.parseFile(appInfoPath);
|
||||
appZhName = CFBundleDisplayName || CFBundleName;
|
||||
}
|
||||
|
||||
return appZhName;
|
||||
} catch (error) {
|
||||
return ERROR_RESULT;
|
||||
}
|
||||
}
|
||||
|
||||
function getDarwinAppList () {
|
||||
APP_FINDER_PATH.forEach((searchPath, index) => {
|
||||
fs.readdir(searchPath, async (err, files) => {
|
||||
try {
|
||||
for (let i = 0; i < files.length; i++) {
|
||||
const appName = files[i];
|
||||
const extname = path.extname(appName);
|
||||
const appSubStr = appName.split(extname)[0];
|
||||
if ((extname === '.app' || extname === '.prefPane') >= 0) {
|
||||
try {
|
||||
const path1 = path.join(searchPath, `${appName}/Contents/Resources/App.icns`);
|
||||
const path2 = path.join(searchPath, `${appName}/Contents/Resources/AppIcon.icns`);
|
||||
const path3 = path.join(searchPath, `${appName}/Contents/Resources/${appSubStr}.icns`);
|
||||
const path4 = path.join(searchPath, `${appName}/Contents/Resources/${appSubStr.replace(' ', '')}.icns`);
|
||||
let iconPath = path1;
|
||||
if (fs.existsSync(path1)) {
|
||||
iconPath = path1;
|
||||
} else if (fs.existsSync(path2)) {
|
||||
iconPath = path2;
|
||||
} else if (fs.existsSync(path3)) {
|
||||
iconPath = path3;
|
||||
} else if (fs.existsSync(path4)) {
|
||||
iconPath = path4;
|
||||
} else {
|
||||
// 性能最低的方式
|
||||
const resourceList = fs.readdirSync(path.join(searchPath, `${appName}/Contents/Resources`));
|
||||
const iconName = resourceList.filter((file) => path.extname(file) === '.icns')[0];
|
||||
iconPath = path.join(searchPath, `${appName}/Contents/Resources/${iconName}`);
|
||||
}
|
||||
const img = await nativeImage.createThumbnailFromPath(iconPath, { width: 64, height: 64 });
|
||||
|
||||
const appZhName = await getAppZhName(searchPath, appName);
|
||||
|
||||
const fileOptions = {
|
||||
value: 'plugin',
|
||||
icon: img.toDataURL(),
|
||||
desc: path.join(searchPath, appName),
|
||||
type: 'app',
|
||||
action: `open ${path.join(searchPath, appName).replace(' ', '\\ ')}`,
|
||||
keyWords: [appSubStr]
|
||||
};
|
||||
|
||||
if (appZhName && isZhRegex.test(appZhName)) {
|
||||
const py = translate(appZhName);
|
||||
const pinyinArr = py.split(',');
|
||||
const firstLatter = pinyinArr.map(py => py[0]);
|
||||
// 拼音
|
||||
fileOptions.keyWords.push(pinyinArr.join(''));
|
||||
// 缩写
|
||||
fileOptions.keyWords.push(firstLatter.join(''));
|
||||
// 中文
|
||||
fileOptions.keyWords.push(appZhName);
|
||||
}
|
||||
|
||||
fileLists.push({
|
||||
...fileOptions,
|
||||
name: appSubStr,
|
||||
names: JSON.parse(JSON.stringify(fileOptions.keyWords)),
|
||||
});
|
||||
} catch (e) {}
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
console.log(e);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
export const getApp = {
|
||||
init: getDarwinAppList,
|
||||
fileLists,
|
||||
}
|
||||
@@ -2,7 +2,7 @@ import {shell, ipcRenderer} from 'electron';
|
||||
export default {
|
||||
'rubick-help': {
|
||||
help() {
|
||||
shell.openExternal('https://u.tools/docs/guide/about-uTools.html')
|
||||
shell.openExternal('https://cloudr-f2e.github.io/rubick/')
|
||||
}
|
||||
},
|
||||
'rubick-color': {
|
||||
|
||||
@@ -1,19 +1,19 @@
|
||||
import { WINDOW_MAX_HEIGHT, WINDOW_MIN_HEIGHT, PRE_ITEM_HEIGHT, SYSTEM_PLUGINS } from './constans';
|
||||
import path from 'path';
|
||||
import fs from 'fs';
|
||||
import process from 'child_process';
|
||||
import Store from 'electron-store';
|
||||
import downloadFile from 'download';
|
||||
import { nativeImage, ipcRenderer } from 'electron';
|
||||
import { APP_FINDER_PATH } from './constans';
|
||||
import { ipcRenderer } from 'electron';
|
||||
import { getlocalDataFile } from '../../../main/common/utils';
|
||||
import iconvLite from 'iconv-lite';
|
||||
import bpList from 'bplist-parser';
|
||||
import shell from 'shelljs';
|
||||
|
||||
import translate from './translate'
|
||||
const getApp = process.platform === 'win32' ? require('./win-app').getApp : require('./darwin-app').getApp;
|
||||
|
||||
const store = new Store();
|
||||
|
||||
getApp.init();
|
||||
const fileLists = getApp.fileLists;
|
||||
|
||||
function getWindowHeight(searchList) {
|
||||
if (!searchList) return WINDOW_MAX_HEIGHT;
|
||||
if (!searchList.length) return WINDOW_MIN_HEIGHT;
|
||||
@@ -24,8 +24,8 @@ function getWindowHeight(searchList) {
|
||||
|
||||
function searchKeyValues(lists, value) {
|
||||
return lists.filter((item) => {
|
||||
if (typeof item === 'string') return item.indexOf(value) >= 0;
|
||||
return item.type.indexOf(value) >= 0;
|
||||
if (typeof item === 'string') return item.toLowerCase().indexOf(value.toLowerCase()) >= 0;
|
||||
return item.type.toLowerCase().indexOf(value.toLowerCase()) >= 0;
|
||||
});
|
||||
}
|
||||
|
||||
@@ -50,7 +50,7 @@ async function downloadZip(downloadRepoUrl, name) {
|
||||
const temp_dest = `${plugin_path}/${name}`;
|
||||
// 下载模板
|
||||
if (await existOrNot(temp_dest)) {
|
||||
await process.execSync(`rm -rf ${temp_dest}`);
|
||||
shell.rm('-rf', temp_dest);
|
||||
}
|
||||
|
||||
await downloadFile(downloadRepoUrl, plugin_path, { extract: true });
|
||||
@@ -158,110 +158,6 @@ function find(p, target = 'plugin.json') {
|
||||
console.log(e);
|
||||
}
|
||||
}
|
||||
const fileLists = [];
|
||||
// 默认搜索目录
|
||||
const isZhRegex = /[\u4e00-\u9fa5]/;
|
||||
const getDisplayNameRegex = /\"(?:CFBundleDisplayName)\"\s\=\s\"(.*)\"/;
|
||||
|
||||
async function getAppZhName(rootPath, appName) {
|
||||
try {
|
||||
const ERROR_RESULT = '';
|
||||
const systemPath = path.join(rootPath, `${appName}/Contents/Resources/zh_CN.lproj/InfoPlist.strings`);
|
||||
const customizePath = path.join(rootPath, `${appName}/Contents/Resources/zh-Hans.lproj/InfoPlist.strings`);
|
||||
let appInfoPath = '';
|
||||
|
||||
if (fs.existsSync(systemPath)) {
|
||||
appInfoPath = systemPath;
|
||||
} else if (fs.existsSync(customizePath)) {
|
||||
appInfoPath = customizePath;
|
||||
} else {
|
||||
return ERROR_RESULT;
|
||||
}
|
||||
let appZhName = '';
|
||||
if (rootPath == '/Applications') {
|
||||
const container = iconvLite.decode(fs.readFileSync(appInfoPath), 'utf-16');
|
||||
if (container) {
|
||||
const res = container.match(getDisplayNameRegex);
|
||||
appZhName = res && res[1];
|
||||
} else {
|
||||
return ERROR_RESULT;
|
||||
}
|
||||
} else {
|
||||
const [{ CFBundleDisplayName = '', CFBundleName = '' }] = await bpList.parseFile(appInfoPath);
|
||||
appZhName = CFBundleDisplayName || CFBundleName;
|
||||
}
|
||||
|
||||
return appZhName;
|
||||
} catch (error) {
|
||||
return ERROR_RESULT;
|
||||
}
|
||||
}
|
||||
APP_FINDER_PATH.forEach((searchPath, index) => {
|
||||
fs.readdir(searchPath, async (err, files) => {
|
||||
try {
|
||||
for (let i = 0; i < files.length; i++) {
|
||||
const appName = files[i];
|
||||
const extname = path.extname(appName);
|
||||
const appSubStr = appName.split(extname)[0];
|
||||
if ((extname === '.app' || extname === '.prefPane') >= 0) {
|
||||
try {
|
||||
const path1 = path.join(searchPath, `${appName}/Contents/Resources/App.icns`);
|
||||
const path2 = path.join(searchPath, `${appName}/Contents/Resources/AppIcon.icns`);
|
||||
const path3 = path.join(searchPath, `${appName}/Contents/Resources/${appSubStr}.icns`);
|
||||
const path4 = path.join(searchPath, `${appName}/Contents/Resources/${appSubStr.replace(' ', '')}.icns`);
|
||||
let iconPath = path1;
|
||||
if (fs.existsSync(path1)) {
|
||||
iconPath = path1;
|
||||
} else if (fs.existsSync(path2)) {
|
||||
iconPath = path2;
|
||||
} else if (fs.existsSync(path3)) {
|
||||
iconPath = path3;
|
||||
} else if (fs.existsSync(path4)) {
|
||||
iconPath = path4;
|
||||
} else {
|
||||
// 性能最低的方式
|
||||
const resourceList = fs.readdirSync(path.join(searchPath, `${appName}/Contents/Resources`));
|
||||
const iconName = resourceList.filter((file) => path.extname(file) === '.icns')[0];
|
||||
iconPath = path.join(searchPath, `${appName}/Contents/Resources/${iconName}`);
|
||||
}
|
||||
const img = await nativeImage.createThumbnailFromPath(iconPath, { width: 64, height: 64 });
|
||||
|
||||
const appZhName = await getAppZhName(searchPath, appName);
|
||||
|
||||
const fileOptions = {
|
||||
value: 'plugin',
|
||||
icon: img.toDataURL(),
|
||||
desc: path.join(searchPath, appName),
|
||||
type: 'app',
|
||||
action: `open ${path.join(searchPath, appName).replace(' ', '\\ ')}`,
|
||||
keyWords: [appSubStr]
|
||||
};
|
||||
|
||||
if (appZhName && isZhRegex.test(appZhName)) {
|
||||
const py = translate(appZhName);
|
||||
const pinyinArr = py.split(',');
|
||||
const firstLatter = pinyinArr.map(py => py[0]);
|
||||
// 拼音
|
||||
fileOptions.keyWords.push(pinyinArr.join(''));
|
||||
// 缩写
|
||||
fileOptions.keyWords.push(firstLatter.join(''));
|
||||
// 中文
|
||||
fileOptions.keyWords.push(appZhName);
|
||||
}
|
||||
|
||||
fileLists.push({
|
||||
...fileOptions,
|
||||
name: appSubStr,
|
||||
names: JSON.parse(JSON.stringify(fileOptions.keyWords)),
|
||||
});
|
||||
} catch (e) {}
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
console.log(e);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
function debounce(fn, delay) {
|
||||
let timer;
|
||||
|
||||
93
src/renderer/assets/common/win-app.js
Normal file
93
src/renderer/assets/common/win-app.js
Normal file
@@ -0,0 +1,93 @@
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
import os from 'os';
|
||||
import translate from './translate';
|
||||
import {shell} from 'electron';
|
||||
const fileIcon = require('extract-file-icon');
|
||||
const filePath = path.resolve('C:\\ProgramData\\Microsoft\\Windows\\Start Menu\\Programs');
|
||||
|
||||
const fileLists = [];
|
||||
const isZhRegex = /[\u4e00-\u9fa5]/;
|
||||
|
||||
const icondir = path.join(os.tmpdir(), 'ProcessIcon');
|
||||
const exists = fs.existsSync(icondir);
|
||||
if (!exists) { fs.mkdirSync(icondir) }
|
||||
|
||||
const getico = app =>{
|
||||
try {
|
||||
const buffer = fileIcon(app.desc, 32);
|
||||
const iconpath = path.join(icondir, `${app.name}.png`);
|
||||
|
||||
fs.exists(iconpath, exists => {
|
||||
if (!exists) {
|
||||
fs.writeFile(iconpath, buffer, 'base64', () => {});
|
||||
}
|
||||
});
|
||||
|
||||
} catch(e) {
|
||||
console.log(e, app.desc);
|
||||
}
|
||||
}
|
||||
|
||||
function fileDisplay(filePath){
|
||||
//根据文件路径读取文件,返回文件列表
|
||||
fs.readdir(filePath,function(err,files){
|
||||
if(err){
|
||||
console.warn(err)
|
||||
}else{
|
||||
files.forEach(function(filename){
|
||||
const filedir = path.join(filePath, filename);
|
||||
fs.stat(filedir,function(eror,stats){
|
||||
if(eror){
|
||||
console.warn('获取文件stats失败');
|
||||
} else {
|
||||
const isFile = stats.isFile(); // 是文件
|
||||
const isDir = stats.isDirectory(); // 是文件夹
|
||||
if(isFile){
|
||||
const appName = filename.split('.')[0];
|
||||
const keyWords = [appName];
|
||||
const appDetail = shell.readShortcutLink(filedir);
|
||||
if (!appDetail.target) return;
|
||||
|
||||
if (isZhRegex.test(appName)) {
|
||||
const py = translate(appName);
|
||||
const pinyinArr = py.split(',');
|
||||
const zh_firstLatter = pinyinArr.map(py => py[0]);
|
||||
// 拼音
|
||||
keyWords.push(pinyinArr.join(''));
|
||||
// 缩写
|
||||
keyWords.push(zh_firstLatter.join(''));
|
||||
} else {
|
||||
const firstLatter = appName.split(' ').map(name => name[0]).join('');
|
||||
keyWords.push(firstLatter);
|
||||
}
|
||||
|
||||
const icon = path.join(os.tmpdir(), 'ProcessIcon', `${encodeURIComponent(appName)}.png`);
|
||||
|
||||
const appInfo = {
|
||||
value: 'plugin',
|
||||
desc: appDetail.target,
|
||||
type: 'app',
|
||||
icon,
|
||||
action: `start "dummyclient" "${appDetail.target}"`,
|
||||
keyWords: keyWords,
|
||||
name: appName,
|
||||
names: JSON.parse(JSON.stringify(keyWords)),
|
||||
}
|
||||
fileLists.push(appInfo);
|
||||
getico(appInfo);
|
||||
}
|
||||
if(isDir) {
|
||||
fileDisplay(filedir); // 递归,如果是文件夹,就继续遍历该文件夹下面的文件
|
||||
}
|
||||
}
|
||||
})
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
export const getApp = {
|
||||
init: () => fileDisplay(filePath),
|
||||
fileLists
|
||||
}
|
||||
@@ -2,14 +2,19 @@
|
||||
<div class="market">
|
||||
<a-carousel v-if="bannerList && !!bannerList.length" arrows>
|
||||
<div
|
||||
slot="prevArrow"
|
||||
slot-scope="props"
|
||||
class="custom-slick-arrow"
|
||||
style="left: 10px;zIndex: 1"
|
||||
slot="prevArrow"
|
||||
slot-scope="props"
|
||||
class="custom-slick-arrow"
|
||||
style="left: 10px;zIndex: 1"
|
||||
>
|
||||
<a-icon type="left-circle" />
|
||||
</div>
|
||||
<div slot="nextArrow" slot-scope="props" class="custom-slick-arrow" style="right: 10px">
|
||||
<div
|
||||
slot="nextArrow"
|
||||
slot-scope="props"
|
||||
class="custom-slick-arrow"
|
||||
style="right: 10px"
|
||||
>
|
||||
<a-icon type="right-circle" />
|
||||
</div>
|
||||
<div v-for="banner in bannerList">
|
||||
@@ -18,38 +23,49 @@
|
||||
</a-carousel>
|
||||
<a-divider v-if="bannerList && !!bannerList.length"></a-divider>
|
||||
<h2>插件</h2>
|
||||
<a-list item-layout="horizontal" style="width: 100%" :grid="{ gutter: 16, column: 2 }" :data-source="pluginList">
|
||||
<a-list
|
||||
item-layout="horizontal"
|
||||
style="width: 100%"
|
||||
:grid="{ gutter: 16, column: 2 }"
|
||||
:data-source="pluginList"
|
||||
>
|
||||
<a-list-item slot="renderItem" slot-scope="item, index">
|
||||
<a-button v-if="showButton(item)" :loading="loading[index]" type="link" slot="actions" @click="download(index, item)">
|
||||
<a-icon v-show="!loading[index]" style="font-size: 20px;" type="cloud-download" />
|
||||
<a-button
|
||||
v-if="showButton(item)"
|
||||
:loading="loading[index]"
|
||||
type="link"
|
||||
slot="actions"
|
||||
@click="download(index, item)"
|
||||
>
|
||||
<a-icon
|
||||
v-show="!loading[index]"
|
||||
style="font-size: 20px;"
|
||||
type="cloud-download"
|
||||
/>
|
||||
</a-button>
|
||||
|
||||
|
||||
<a-list-item-meta
|
||||
@click="showPannel(item, index)"
|
||||
:description="item.description"
|
||||
@click="showPannel(item, index)"
|
||||
:description="item.description"
|
||||
>
|
||||
<div slot="title">{{ item.pluginName }}</div>
|
||||
<a-avatar
|
||||
slot="avatar"
|
||||
:src="item.logo"
|
||||
/>
|
||||
<a-avatar slot="avatar" :src="item.logo" />
|
||||
</a-list-item-meta>
|
||||
</a-list-item>
|
||||
</a-list>
|
||||
<a-drawer
|
||||
placement="right"
|
||||
:visible="show"
|
||||
@close="show=false"
|
||||
@close="show = false"
|
||||
width="100%"
|
||||
>
|
||||
<div class="plugin-market-desc" slot="title">
|
||||
<img width="80" :src="currentSelect.logo"/>
|
||||
<img width="80" :src="currentSelect.logo" />
|
||||
<div class="desc">
|
||||
<h4>{{currentSelect.pluginName}}</h4>
|
||||
<h4>{{ currentSelect.pluginName }}</h4>
|
||||
<div class="info">
|
||||
<div class="actor">
|
||||
开发者:{{currentSelect.author}}
|
||||
开发者:{{ currentSelect.author }}
|
||||
<a-button
|
||||
v-if="showButton(currentSelect)"
|
||||
:loading="loading[currentSelect.index]"
|
||||
@@ -60,7 +76,7 @@
|
||||
获取
|
||||
</a-button>
|
||||
</div>
|
||||
<div>{{currentSelect.description}}</div>
|
||||
<div>{{ currentSelect.description }}</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -70,10 +86,10 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import api from '../../../assets/api';
|
||||
import {mapActions, mapState} from 'vuex';
|
||||
import api from "../../../assets/api";
|
||||
import { mapActions, mapState } from "vuex";
|
||||
import marked from "marked";
|
||||
import {shell} from "electron";
|
||||
import { shell } from "electron";
|
||||
const rendererMD = new marked.Renderer();
|
||||
|
||||
export default {
|
||||
@@ -83,8 +99,8 @@ export default {
|
||||
loading: {},
|
||||
bannerList: [],
|
||||
show: false,
|
||||
currentSelect: {}
|
||||
}
|
||||
currentSelect: {},
|
||||
};
|
||||
},
|
||||
async created() {
|
||||
const [result, bannerRes] = await Promise.all([
|
||||
@@ -93,7 +109,7 @@ export default {
|
||||
]);
|
||||
this.pluginList = result.result;
|
||||
this.bannerList = bannerRes.result;
|
||||
console.log(bannerRes)
|
||||
console.log(bannerRes);
|
||||
},
|
||||
|
||||
methods: {
|
||||
@@ -108,7 +124,9 @@ export default {
|
||||
this.$set(this.loading, index, false);
|
||||
},
|
||||
showButton(item) {
|
||||
return !this.devPlugins.filter(plugin => (plugin.name === item.name && plugin.type === 'prod')).length;
|
||||
return !this.devPlugins.filter(
|
||||
(plugin) => plugin.name === item.name && plugin.type === "prod"
|
||||
).length;
|
||||
},
|
||||
showPannel(item, index) {
|
||||
this.show = true;
|
||||
@@ -117,13 +135,13 @@ export default {
|
||||
},
|
||||
jumpTo(link) {
|
||||
if (link) {
|
||||
shell.openExternal(link)
|
||||
shell.openExternal(link);
|
||||
}
|
||||
},
|
||||
...mapActions('main', ['downloadPlugin'])
|
||||
...mapActions("main", ["downloadPlugin"]),
|
||||
},
|
||||
computed: {
|
||||
...mapState('main', ['devPlugins']),
|
||||
...mapState("main", ["devPlugins"]),
|
||||
readme() {
|
||||
marked.setOptions({
|
||||
renderer: rendererMD,
|
||||
@@ -133,17 +151,16 @@ export default {
|
||||
pedantic: false,
|
||||
sanitize: false,
|
||||
smartLists: true,
|
||||
smartypants: false
|
||||
smartypants: false,
|
||||
});
|
||||
try {
|
||||
return marked(this.currentSelect.detail);
|
||||
} catch (e) {
|
||||
return '暂无描述信息'
|
||||
return "暂无描述信息";
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="less">
|
||||
@@ -177,49 +194,48 @@ export default {
|
||||
justify-content: space-between;
|
||||
}
|
||||
}
|
||||
.market {
|
||||
height: calc(~'100vh - 110px');
|
||||
background: #fff;
|
||||
padding: 20px;
|
||||
box-sizing: border-box;
|
||||
overflow: auto;
|
||||
.ant-carousel .slick-slide {
|
||||
text-align: center;
|
||||
height: 235px;
|
||||
line-height: 160px;
|
||||
background: #364d79;
|
||||
overflow: hidden;
|
||||
}
|
||||
.market {
|
||||
height: calc(~"100vh - 110px");
|
||||
background: #fff;
|
||||
padding: 20px;
|
||||
box-sizing: border-box;
|
||||
overflow: auto;
|
||||
.ant-carousel .slick-slide {
|
||||
text-align: center;
|
||||
height: 235px;
|
||||
line-height: 160px;
|
||||
background: #364d79;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.ant-carousel .custom-slick-arrow {
|
||||
width: 25px;
|
||||
height: 25px;
|
||||
font-size: 25px;
|
||||
color: #fff;
|
||||
background-color: rgba(31, 45, 61, 0.11);
|
||||
opacity: 0.3;
|
||||
}
|
||||
.ant-carousel .custom-slick-arrow:before {
|
||||
display: none;
|
||||
}
|
||||
.ant-carousel .custom-slick-arrow:hover {
|
||||
opacity: 0.5;
|
||||
}
|
||||
|
||||
.ant-carousel .slick-slide h3 {
|
||||
color: #fff;
|
||||
}
|
||||
.ant-list-item {
|
||||
display: flex !important;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
}
|
||||
.ant-list-item-meta-description {
|
||||
width: 200px;
|
||||
overflow: hidden;
|
||||
text-overflow:ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
}
|
||||
.ant-carousel .custom-slick-arrow {
|
||||
width: 25px;
|
||||
height: 25px;
|
||||
font-size: 25px;
|
||||
color: #fff;
|
||||
background-color: rgba(31, 45, 61, 0.11);
|
||||
opacity: 0.3;
|
||||
}
|
||||
.ant-carousel .custom-slick-arrow:before {
|
||||
display: none;
|
||||
}
|
||||
.ant-carousel .custom-slick-arrow:hover {
|
||||
opacity: 0.5;
|
||||
}
|
||||
|
||||
.ant-carousel .slick-slide h3 {
|
||||
color: #fff;
|
||||
}
|
||||
.ant-list-item {
|
||||
display: flex !important;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
}
|
||||
.ant-list-item-meta-description {
|
||||
width: 200px;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -18,15 +18,15 @@
|
||||
<div class="title">快捷键(需要使用 option/ctrl/shift/command 键修饰)</div>
|
||||
<div class="settings-item-li">
|
||||
<div class="label">显示/隐藏快捷键</div>
|
||||
<div class="value" tabIndex=-1 @keydown="(e) => changeShortCut(e, 'showAndHidden')">{{ config.perf.shortCut.showAndHidden }}</div>
|
||||
<div class="value" tabIndex=-1 @keyup="(e) => changeShortCut(e, 'showAndHidden')">{{ config.perf.shortCut.showAndHidden }}</div>
|
||||
</div>
|
||||
<div class="settings-item-li">
|
||||
<div class="label">插件分离快捷键</div>
|
||||
<div class="value" tabIndex=-1 @keydown="(e) => changeShortCut(e, 'separate')">{{ config.perf.shortCut.separate }}</div>
|
||||
<div class="value" tabIndex=-1 @keyup="(e) => changeShortCut(e, 'separate')">{{ config.perf.shortCut.separate }}</div>
|
||||
</div>
|
||||
<div class="settings-item-li">
|
||||
<div class="label">返回主界面</div>
|
||||
<div class="value" tabIndex=-1 @keydown="(e) => changeShortCut(e, 'quit')">{{ config.perf.shortCut.quit }}</div>
|
||||
<div class="value" tabIndex=-1 @keyup="(e) => changeShortCut(e, 'quit')">{{ config.perf.shortCut.quit }}</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="setting-item">
|
||||
@@ -88,7 +88,7 @@
|
||||
v-for="(item, index) in config.global"
|
||||
class="value"
|
||||
tabIndex=-1
|
||||
@keydown="(e) => changeGlobalKey(e, index)"
|
||||
@keyup="(e) => changeGlobalKey(e, index)"
|
||||
>
|
||||
{{ item.key }}
|
||||
</div>
|
||||
@@ -171,7 +171,7 @@ export default {
|
||||
changeGlobalKey(e, index) {
|
||||
let compose;
|
||||
if(e.altKey && e.keyCode !== 18){
|
||||
compose = `Option+${keycodes[e.keyCode].toUpperCase()}`;
|
||||
compose = `Alt+${keycodes[e.keyCode].toUpperCase()}`;
|
||||
}
|
||||
if(e.ctrlKey && e.keyCode !== 17){
|
||||
compose = `Ctrl+${keycodes[e.keyCode].toUpperCase()}`;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { clipboard, ipcRenderer, remote } from 'electron';
|
||||
import { v4 as uuidv4 } from 'uuid';
|
||||
import { clipboard, ipcRenderer, remote } from "electron";
|
||||
import { v4 as uuidv4 } from "uuid";
|
||||
import {
|
||||
getWindowHeight,
|
||||
searchKeyValues,
|
||||
@@ -7,34 +7,34 @@ import {
|
||||
mergePlugins,
|
||||
find,
|
||||
downloadZip,
|
||||
fileLists
|
||||
} from '../../assets/common/utils';
|
||||
import systemMethod from '../../assets/common/system';
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
import { execSync } from 'child_process';
|
||||
fileLists,
|
||||
} from "../../assets/common/utils";
|
||||
import systemMethod from "../../assets/common/system";
|
||||
import fs from "fs";
|
||||
import path from "path";
|
||||
import { execSync } from "child_process";
|
||||
|
||||
const state = {
|
||||
selected: null,
|
||||
options: [],
|
||||
showMain: false,
|
||||
current: ['market'],
|
||||
searchValue: '',
|
||||
current: ["market"],
|
||||
searchValue: "",
|
||||
devPlugins: mergePlugins(sysFile.getUserPlugins() || []),
|
||||
subPlaceHolder: '',
|
||||
subPlaceHolder: "",
|
||||
pluginLoading: true,
|
||||
pluginInfo: (() => {
|
||||
try {
|
||||
return window.pluginInfo || {};
|
||||
} catch (e) {}
|
||||
})()
|
||||
})(),
|
||||
};
|
||||
|
||||
const mutations = {
|
||||
commonUpdate(state, payload) {
|
||||
Object.keys(payload).forEach((key) => {
|
||||
state[key] = payload[key];
|
||||
if (key === 'devPlugins') {
|
||||
if (key === "devPlugins") {
|
||||
sysFile.savePlugins(payload[key]);
|
||||
}
|
||||
});
|
||||
@@ -43,11 +43,15 @@ const mutations = {
|
||||
state.subPlaceHolder = payload;
|
||||
},
|
||||
deleteDevPlugin(state, payload) {
|
||||
state.devPlugins = state.devPlugins.filter((plugin) => plugin.name !== payload.name);
|
||||
state.devPlugins = state.devPlugins.filter(
|
||||
(plugin) => plugin.name !== payload.name
|
||||
);
|
||||
sysFile.savePlugins(state.devPlugins);
|
||||
},
|
||||
deleteProdPlugin(state, payload) {
|
||||
state.devPlugins = state.devPlugins.filter((plugin) => plugin.id !== payload.id);
|
||||
state.devPlugins = state.devPlugins.filter(
|
||||
(plugin) => plugin.id !== payload.id
|
||||
);
|
||||
sysFile.savePlugins(state.devPlugins);
|
||||
// todo 删除 static 目录下的对应插件
|
||||
},
|
||||
@@ -59,124 +63,136 @@ const mutations = {
|
||||
});
|
||||
state.devPlugins = [...state.devPlugins];
|
||||
sysFile.savePlugins(state.devPlugins);
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
const actions = {
|
||||
showMainUI({ commit, state }, paylpad) {
|
||||
ipcRenderer.send('changeWindowSize-rubick', {
|
||||
height: getWindowHeight()
|
||||
ipcRenderer.send("changeWindowSize-rubick", {
|
||||
height: getWindowHeight(),
|
||||
});
|
||||
setTimeout(() => {
|
||||
commit('commonUpdate', {
|
||||
commit("commonUpdate", {
|
||||
showMain: true,
|
||||
selected: {
|
||||
key: 'market',
|
||||
name: '插件中心'
|
||||
}
|
||||
key: "market",
|
||||
name: "插件中心",
|
||||
},
|
||||
});
|
||||
}, 50);
|
||||
},
|
||||
reloadDevPlugin({ commit }, payload) {
|
||||
const config = JSON.parse(fs.readFileSync(path.join(payload.sourceFile, '../plugin.json'), 'utf-8'));
|
||||
const config = JSON.parse(
|
||||
fs.readFileSync(path.join(payload.sourceFile, "../plugin.json"), "utf-8")
|
||||
);
|
||||
const pluginConfig = {
|
||||
...config,
|
||||
sourceFile: path.join(payload.sourceFile, `../${config.main}`)
|
||||
sourceFile: path.join(payload.sourceFile, `../${config.main}`),
|
||||
};
|
||||
const devPlugins = [...state.devPlugins];
|
||||
commit('commonUpdate', {
|
||||
commit("commonUpdate", {
|
||||
devPlugins: devPlugins.map((plugin) => {
|
||||
if (plugin.name === payload.name) {
|
||||
return {
|
||||
...plugin,
|
||||
...pluginConfig
|
||||
...pluginConfig,
|
||||
};
|
||||
}
|
||||
return plugin;
|
||||
})
|
||||
}),
|
||||
});
|
||||
},
|
||||
async onSearch({ commit }, paylpad) {
|
||||
if (state.selected && state.selected.key !== 'plugin-container') {
|
||||
commit('commonUpdate', { searchValue: '' });
|
||||
/**
|
||||
* @param {Object} payload payload.filePath为配置文件的绝对路径。payload.value为搜索栏文字值。
|
||||
*/
|
||||
async onSearch({ commit }, payload) {
|
||||
if (state.selected && state.selected.key !== "plugin-container") {
|
||||
commit("commonUpdate", { searchValue: "" });
|
||||
return;
|
||||
}
|
||||
const value = paylpad.value;
|
||||
const value = payload.value;
|
||||
// 在插件界面不触发其他功能
|
||||
if ((state.selected && state.selected.key === 'plugin-container') || paylpad.searchType === 'subWindow') {
|
||||
commit('commonUpdate', { searchValue: value });
|
||||
if (
|
||||
(state.selected && state.selected.key === "plugin-container") ||
|
||||
payload.searchType === "subWindow"
|
||||
) {
|
||||
commit("commonUpdate", { searchValue: value });
|
||||
return;
|
||||
}
|
||||
const fileUrl = clipboard.read('public.file-url').replace('file://', '');
|
||||
commit('commonUpdate', { searchValue: value });
|
||||
const fileUrl =
|
||||
payload.filePath ||
|
||||
clipboard.read("public.file-url").replace("file://", "");
|
||||
commit("commonUpdate", { searchValue: value });
|
||||
// 复制文件
|
||||
if (fileUrl && value === 'plugin.json') {
|
||||
const config = JSON.parse(fs.readFileSync(fileUrl, 'utf-8'));
|
||||
if (payload.filePath || (fileUrl && value === "plugin.json")) {
|
||||
const config = JSON.parse(fs.readFileSync(fileUrl, "utf-8"));
|
||||
|
||||
const pluginConfig = {
|
||||
...config,
|
||||
sourceFile: path.join(fileUrl, `../${config.main || 'index.html'}`),
|
||||
sourceFile: path.join(fileUrl, `../${config.main || "index.html"}`),
|
||||
id: uuidv4(),
|
||||
type: 'dev',
|
||||
icon: 'image://' + path.join(fileUrl, `../${config.logo}`),
|
||||
type: "dev",
|
||||
icon: "image://" + path.join(fileUrl, `../${config.logo}`),
|
||||
subType: (() => {
|
||||
if (config.main) {
|
||||
return '';
|
||||
return "";
|
||||
}
|
||||
return 'template';
|
||||
})()
|
||||
return "template";
|
||||
})(),
|
||||
};
|
||||
commit('commonUpdate', {
|
||||
commit("commonUpdate", {
|
||||
selected: {
|
||||
key: 'plugin',
|
||||
name: 'plugin.json'
|
||||
key: "plugin",
|
||||
name: "plugin.json",
|
||||
},
|
||||
searchValue: '',
|
||||
devPlugins: [pluginConfig, ...state.devPlugins],
|
||||
searchValue: "",
|
||||
options: [
|
||||
{
|
||||
name: '新建rubick开发插件',
|
||||
value: 'new-plugin',
|
||||
icon: 'https://static.91jkys.com/activity/img/b37ff555c748489f88f3adac15b76f18.png',
|
||||
desc: '新建rubick开发插件',
|
||||
name: "新建rubick开发插件",
|
||||
value: "new-plugin",
|
||||
icon:
|
||||
"https://static.91jkys.com/activity/img/b37ff555c748489f88f3adac15b76f18.png",
|
||||
desc: "新建rubick开发插件",
|
||||
click: (router) => {
|
||||
commit('commonUpdate', {
|
||||
commit("commonUpdate", {
|
||||
showMain: true,
|
||||
devPlugins: [pluginConfig, ...state.devPlugins],
|
||||
selected: {
|
||||
key: 'plugin',
|
||||
name: '新建rubick开发插件'
|
||||
key: "plugin",
|
||||
name: "新建rubick开发插件",
|
||||
},
|
||||
current: ['dev']
|
||||
current: ["dev"],
|
||||
});
|
||||
ipcRenderer.send('changeWindowSize-rubick', {
|
||||
height: getWindowHeight()
|
||||
ipcRenderer.send("changeWindowSize-rubick", {
|
||||
height: getWindowHeight(),
|
||||
});
|
||||
router.push('/home/dev');
|
||||
}
|
||||
router.push("/home/dev");
|
||||
},
|
||||
},
|
||||
{
|
||||
name: '复制路径',
|
||||
desc: '复制路径',
|
||||
value: 'copy-path',
|
||||
icon: 'https://static.91jkys.com/activity/img/ac0d4df0247345b9a84c8cd7ea3dd696.png',
|
||||
name: "复制路径",
|
||||
desc: "复制路径",
|
||||
value: "copy-path",
|
||||
icon:
|
||||
"https://static.91jkys.com/activity/img/ac0d4df0247345b9a84c8cd7ea3dd696.png",
|
||||
click: () => {
|
||||
clipboard.writeText(fileUrl);
|
||||
commit('commonUpdate', {
|
||||
commit("commonUpdate", {
|
||||
showMain: false,
|
||||
selected: null,
|
||||
options: []
|
||||
options: [],
|
||||
});
|
||||
ipcRenderer.send('changeWindowSize-rubick', {
|
||||
height: getWindowHeight([])
|
||||
ipcRenderer.send("changeWindowSize-rubick", {
|
||||
height: getWindowHeight([]),
|
||||
});
|
||||
remote.Notification('Rubick 通知', { body: '复制成功' });
|
||||
}
|
||||
}
|
||||
]
|
||||
remote.Notification("Rubick 通知", { body: "复制成功" });
|
||||
},
|
||||
},
|
||||
],
|
||||
});
|
||||
// 调整窗口大小
|
||||
ipcRenderer.send('changeWindowSize-rubick', {
|
||||
height: getWindowHeight(state.options)
|
||||
ipcRenderer.send("changeWindowSize-rubick", {
|
||||
height: getWindowHeight(state.options),
|
||||
});
|
||||
return;
|
||||
}
|
||||
@@ -187,7 +203,7 @@ const actions = {
|
||||
if (value) {
|
||||
state.devPlugins.forEach((plugin) => {
|
||||
// dev 插件未开启
|
||||
if (plugin.type === 'dev' && !plugin.status) return;
|
||||
if (plugin.type === "dev" && !plugin.status) return;
|
||||
const feature = plugin.features;
|
||||
feature.forEach((fe) => {
|
||||
const cmds = searchKeyValues(fe.cmds, value);
|
||||
@@ -195,14 +211,19 @@ const actions = {
|
||||
...options,
|
||||
...cmds.map((cmd) => ({
|
||||
name: cmd,
|
||||
value: 'plugin',
|
||||
icon: plugin.sourceFile ? 'image://' + path.join(plugin.sourceFile, `../${plugin.logo}`) : plugin.logo,
|
||||
value: "plugin",
|
||||
icon: plugin.sourceFile
|
||||
? "image://" + path.join(plugin.sourceFile, `../${plugin.logo}`)
|
||||
: plugin.logo,
|
||||
desc: fe.explain,
|
||||
type: plugin.type,
|
||||
click: (router) => {
|
||||
actions.openPlugin({ commit }, { cmd, plugin, feature: fe, router });
|
||||
}
|
||||
}))
|
||||
actions.openPlugin(
|
||||
{ commit },
|
||||
{ cmd, plugin, feature: fe, router }
|
||||
);
|
||||
},
|
||||
})),
|
||||
];
|
||||
});
|
||||
});
|
||||
@@ -215,8 +236,12 @@ const actions = {
|
||||
if (!descMap.get(plugin)) {
|
||||
descMap.set(plugin, true);
|
||||
let has = false;
|
||||
plugin.keyWords.some(keyWord => {
|
||||
if (keyWord.toLocaleUpperCase().indexOf(value.toLocaleUpperCase()) >= 0) {
|
||||
plugin.keyWords.some((keyWord) => {
|
||||
if (
|
||||
keyWord
|
||||
.toLocaleUpperCase()
|
||||
.indexOf(value.toLocaleUpperCase()) >= 0
|
||||
) {
|
||||
has = keyWord;
|
||||
plugin.name = keyWord;
|
||||
return true;
|
||||
@@ -233,17 +258,17 @@ const actions = {
|
||||
actions.openPlugin({ commit }, { plugin });
|
||||
};
|
||||
return plugin;
|
||||
})
|
||||
}),
|
||||
];
|
||||
|
||||
descMap = null;
|
||||
}
|
||||
|
||||
commit('commonUpdate', {
|
||||
options
|
||||
commit("commonUpdate", {
|
||||
options,
|
||||
});
|
||||
ipcRenderer.send('changeWindowSize-rubick', {
|
||||
height: getWindowHeight(state.options)
|
||||
ipcRenderer.send("changeWindowSize-rubick", {
|
||||
height: getWindowHeight(state.options),
|
||||
});
|
||||
},
|
||||
async downloadPlugin({ commit }, payload) {
|
||||
@@ -251,88 +276,90 @@ const actions = {
|
||||
const fileUrl = find(distUrl);
|
||||
|
||||
// 复制文件
|
||||
const config = JSON.parse(fs.readFileSync(`${fileUrl}/plugin.json`, 'utf-8'));
|
||||
const config = JSON.parse(
|
||||
fs.readFileSync(`${fileUrl}/plugin.json`, "utf-8")
|
||||
);
|
||||
const pluginConfig = {
|
||||
...config,
|
||||
id: uuidv4(),
|
||||
sourceFile: `${fileUrl}/${config.main}`,
|
||||
type: 'prod',
|
||||
type: "prod",
|
||||
icon: payload.logo,
|
||||
subType: (() => {
|
||||
if (config.main) {
|
||||
return '';
|
||||
return "";
|
||||
}
|
||||
return 'template';
|
||||
})()
|
||||
return "template";
|
||||
})(),
|
||||
};
|
||||
commit('commonUpdate', {
|
||||
devPlugins: [pluginConfig, ...state.devPlugins]
|
||||
commit("commonUpdate", {
|
||||
devPlugins: [pluginConfig, ...state.devPlugins],
|
||||
});
|
||||
},
|
||||
openPlugin({ commit }, { cmd, plugin, feature, router, payload }) {
|
||||
if (plugin.type === 'app') {
|
||||
if (plugin.type === "app") {
|
||||
execSync(plugin.action);
|
||||
commit('commonUpdate', {
|
||||
commit("commonUpdate", {
|
||||
selected: null,
|
||||
showMain: false,
|
||||
options: [],
|
||||
searchValue: ''
|
||||
searchValue: "",
|
||||
});
|
||||
ipcRenderer.send('changeWindowSize-rubick', {
|
||||
height: getWindowHeight([])
|
||||
ipcRenderer.send("changeWindowSize-rubick", {
|
||||
height: getWindowHeight([]),
|
||||
});
|
||||
return;
|
||||
}
|
||||
commit('commonUpdate', {
|
||||
commit("commonUpdate", {
|
||||
selected: {
|
||||
key: 'plugin-container',
|
||||
key: "plugin-container",
|
||||
name: cmd.label ? cmd.label : cmd,
|
||||
icon: 'image://' + path.join(plugin.sourceFile, `../${plugin.logo}`)
|
||||
icon: "image://" + path.join(plugin.sourceFile, `../${plugin.logo}`),
|
||||
},
|
||||
searchValue: '',
|
||||
showMain: true
|
||||
searchValue: "",
|
||||
showMain: true,
|
||||
});
|
||||
ipcRenderer.send('changeWindowSize-rubick', {
|
||||
height: getWindowHeight()
|
||||
ipcRenderer.send("changeWindowSize-rubick", {
|
||||
height: getWindowHeight(),
|
||||
});
|
||||
if (plugin.type === 'system') {
|
||||
if (plugin.type === "system") {
|
||||
systemMethod[plugin.tag][feature.code]();
|
||||
commit('commonUpdate', {
|
||||
commit("commonUpdate", {
|
||||
selected: null,
|
||||
showMain: false,
|
||||
options: []
|
||||
options: [],
|
||||
});
|
||||
ipcRenderer.send('changeWindowSize-rubick', {
|
||||
height: getWindowHeight([])
|
||||
ipcRenderer.send("changeWindowSize-rubick", {
|
||||
height: getWindowHeight([]),
|
||||
});
|
||||
router.push({
|
||||
path: '/home'
|
||||
path: "/home",
|
||||
});
|
||||
return;
|
||||
}
|
||||
commit('commonUpdate', {
|
||||
commit("commonUpdate", {
|
||||
pluginInfo: {
|
||||
cmd,
|
||||
...plugin,
|
||||
detail: feature,
|
||||
payload
|
||||
}
|
||||
payload,
|
||||
},
|
||||
});
|
||||
|
||||
router.push({
|
||||
path: '/plugin',
|
||||
path: "/plugin",
|
||||
query: {
|
||||
...plugin,
|
||||
_modify: Date.now(),
|
||||
detail: JSON.stringify(feature)
|
||||
}
|
||||
detail: JSON.stringify(feature),
|
||||
},
|
||||
});
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
export default {
|
||||
namespaced: true,
|
||||
state,
|
||||
mutations,
|
||||
actions
|
||||
actions,
|
||||
};
|
||||
|
||||
@@ -4,6 +4,7 @@ const path = require('path');
|
||||
const fs = require('fs');
|
||||
const { spawn } = require ('child_process');
|
||||
const mineType = require("mime-types");
|
||||
const {extend} = require('../../utils');
|
||||
|
||||
new Vue({
|
||||
el: '#app',
|
||||
@@ -116,7 +117,8 @@ new Vue({
|
||||
this.targetOptions = this.options.common;
|
||||
} else {
|
||||
// 有文件选择
|
||||
this.targetOptions = JSON.parse(JSON.stringify(this.options.selected));
|
||||
this.targetOptions = [];
|
||||
extend(this.targetOptions, this.options.selected, true);
|
||||
// 检测上传
|
||||
(this.selectData.optionPlugin || []).forEach(plugin => {
|
||||
plugin.features.forEach(fe => {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
const {getData, getlocalDataFile, saveData} = require("./utils");
|
||||
|
||||
const axios = require('axios');
|
||||
const marked = require("marked");
|
||||
const rendererMD = new marked.Renderer();
|
||||
const path = require('path');
|
||||
@@ -22,7 +22,7 @@ function getQueryVariable(variable) {
|
||||
if (location.href.indexOf('targetFile') > -1) {
|
||||
filePath = decodeURIComponent(getQueryVariable('targetFile'));
|
||||
} else {
|
||||
filePath = process.platform === 'win32' ? location.pathname.split(':')[1] : location.pathname.replace('file://', '');
|
||||
filePath = process.platform === 'win32' ? location.pathname.replace('/', '') : location.pathname.replace('file://', '');
|
||||
}
|
||||
const {ipcRenderer, nativeImage, clipboard, remote, shell} = require('electron');
|
||||
|
||||
@@ -255,6 +255,14 @@ window.rubick = {
|
||||
|
||||
shellOpenPath(path) {
|
||||
shell.openPath(path)
|
||||
},
|
||||
|
||||
request(config = {}) {
|
||||
return axios.create({
|
||||
timeout: 10000,
|
||||
withCredentials: true,
|
||||
...config,
|
||||
});
|
||||
}
|
||||
}
|
||||
const preloadPath = getQueryVariable('preloadPath') || './preload.js';
|
||||
|
||||
@@ -20,8 +20,31 @@ function getData(path, defaultValue) {
|
||||
}
|
||||
}
|
||||
|
||||
const isArray = Array.isArray ||
|
||||
function(object){ return object instanceof Array }
|
||||
|
||||
function isPlainObject(obj) {
|
||||
return isObject(obj) && Object.getPrototypeOf(obj) == Object.prototype
|
||||
}
|
||||
|
||||
function isObject(obj) { return typeof obj == "object" }
|
||||
|
||||
|
||||
function extend(target, source, deep) {
|
||||
for (let key in source)
|
||||
if (deep && (isPlainObject(source[key]) || isArray(source[key]))) {
|
||||
if (isPlainObject(source[key]) && !isPlainObject(target[key]))
|
||||
target[key] = {}
|
||||
if (isArray(source[key]) && !isArray(target[key]))
|
||||
target[key] = []
|
||||
extend(target[key], source[key], deep)
|
||||
}
|
||||
else if (source[key] !== undefined) target[key] = source[key]
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
getlocalDataFile,
|
||||
saveData,
|
||||
getData
|
||||
getData,
|
||||
extend
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user