first commit
0
docs/.nojekyll
Executable file
1
docs/.pydio
Normal file
@@ -0,0 +1 @@
|
||||
bea3cae9-474d-415a-a5d3-98173ba38eac
|
||||
41
docs/README.md
Executable file
@@ -0,0 +1,41 @@
|
||||
|
||||
## Strawberry Wallpaper 草莓壁纸 🍓
|
||||
|
||||
### 一款追求更好用的桌面壁纸APP
|
||||
|
||||
<img src="./img/bk1.png" width="100%" />
|
||||
|
||||
|
||||
###### `Strawberry Wallpaper` 是一款针对macOS以及windows的一款精美壁纸应用。自动更新各大图库的高清壁纸,非常适合寻找各种美的图片的你。
|
||||
|
||||
##### 功能:
|
||||
|
||||
- 目前支持pexels、500px、paper、unsplash、wallhaven、NASA每日一图、 themoviedb(类似豆瓣)
|
||||
- 同时支持macOS与windows
|
||||
- 支持壁纸预览,通过缩略图就可预览众多壁纸,同时对壁纸的尺寸做了明显的标记
|
||||
- 支持关键词搜索,想要什么样的图片一触即得
|
||||
- 支持定时自动设置壁纸
|
||||
- 支持方向、尺寸筛选,
|
||||
- 支持设置壁纸平铺方式(mac系统)
|
||||
- 支持网页模式,在浏览原生网页的时候也可以设置壁纸
|
||||
- 对设置过的壁纸存放到固定目录,方便随时查看
|
||||
- 长期更新、完全免费
|
||||
|
||||
##### 亮点:
|
||||
|
||||
###### 简单而又不失优雅的UI设计(仿Pap.er)
|
||||
|
||||
<img src="./img/bk.png" width="100%" />
|
||||
|
||||
###### 支持不同图库的自由切换以及支持自动定时更新壁纸
|
||||
|
||||
<img src="./img/bk2.png" width="100%" />
|
||||
|
||||
###### 支持网页模式
|
||||
可在网页中对图库图片进行搜索、下载、设置为壁纸
|
||||
|
||||
<img src="http://file.qiniu.taoacat.com/stwallpaper-6.png" width="700px" />
|
||||
|
||||
##### [项目地址](https://github.com/aitexiaoy/Strawberry-Wallpaper)
|
||||
##### [Windows下载](http://sw.taoacat.com/Strawberry%20Wallpaper-win.exe)
|
||||
##### [Mac下载](http://sw.taoacat.com/Strawberry%20Wallpaper-mac.dmg)
|
||||
10
docs/_coverpage.md
Executable file
@@ -0,0 +1,10 @@
|
||||
# Strawberry Wallpaper
|
||||
|
||||
> 一款非常好用的桌面壁纸APP
|
||||
|
||||
[GitHub](https://github.com/aitexiaoy/Strawberry-Wallpaper)
|
||||
[Get Started](#quick-start)
|
||||
|
||||

|
||||
|
||||

|
||||
8
docs/_sidebar.md
Executable file
@@ -0,0 +1,8 @@
|
||||
* 开发笔记
|
||||
* [如何利用Node进行图片的抓取](zh-cn/reptile.md)
|
||||
* [将图片保存到本地](zh-cn/save-image.md)
|
||||
* [如何设置壁纸](zh-cn/set-wallpaper.md)
|
||||
* [项目搭建](zh-cn/start.md)
|
||||
* [主窗口定位-tarbar](zh-cn/tarbar.md)
|
||||
* [如何进行远程升级](zh-cn/updata.md)
|
||||
* [遇到的问题](zh-cn/problem.md)
|
||||
1
docs/img/.pydio
Normal file
@@ -0,0 +1 @@
|
||||
6ab41161-5a2a-45ad-b5a8-89b0c8421b13
|
||||
BIN
docs/img/bk.png
Executable file
|
After Width: | Height: | Size: 942 KiB |
BIN
docs/img/bk1.png
Executable file
|
After Width: | Height: | Size: 863 KiB |
BIN
docs/img/bk2.png
Executable file
|
After Width: | Height: | Size: 2.7 MiB |
BIN
docs/img/logo.png
Executable file
|
After Width: | Height: | Size: 4.1 KiB |
BIN
docs/img/stwallpaper-1.png
Executable file
|
After Width: | Height: | Size: 1.9 MiB |
BIN
docs/img/stwallpaper-2.png
Executable file
|
After Width: | Height: | Size: 2.7 MiB |
BIN
docs/img/stwallpaper-3.png
Executable file
|
After Width: | Height: | Size: 1.8 MiB |
BIN
docs/img/stwallpaper-4.png
Executable file
|
After Width: | Height: | Size: 1.2 MiB |
BIN
docs/img/stwallpaper-5.png
Executable file
|
After Width: | Height: | Size: 1.7 MiB |
BIN
docs/img/stwallpaper-6.png
Executable file
|
After Width: | Height: | Size: 1.9 MiB |
213
docs/index.html
Executable file
@@ -0,0 +1,213 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>strawberrywallpaper - a wallpaper app by electron</title>
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
|
||||
<meta name="description" content="Description">
|
||||
<meta name="viewport"
|
||||
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
|
||||
<link rel="stylesheet" href="//unpkg.com/docsify/lib/themes/vue.css">
|
||||
<link rel="stylesheet" href="//unpkg.com/vuep/dist/vuep.css">
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
|
||||
<link rel="icon" type="image/x-icon" class="js-site-favicon" href="./image/favicon.ico">
|
||||
<!-- 引入element样式 -->
|
||||
<link rel="stylesheet" href="https://unpkg.com/element-ui/lib/theme-chalk/index.css">
|
||||
|
||||
|
||||
<style>
|
||||
.sidebar-nav-parent-li {
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.sidebar-nav {
|
||||
padding-right: 10px;
|
||||
}
|
||||
|
||||
.sidebar-nav .ul-after {
|
||||
content: '';
|
||||
width: 10px;
|
||||
height: 30px;
|
||||
/* background: red; */
|
||||
position: absolute;
|
||||
right: 10px;
|
||||
top: 0px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.ul-after-sanjiao {
|
||||
width: 0;
|
||||
height: 0;
|
||||
border-left: 8px solid #cecece;
|
||||
border-top: 8px solid transparent;
|
||||
border-bottom: 8px solid transparent;
|
||||
transition: transform 0.3s;
|
||||
position: relative;
|
||||
|
||||
}
|
||||
|
||||
.ul-after-sanjiao::after {
|
||||
content: '';
|
||||
width: 0;
|
||||
height: 0;
|
||||
position: absolute;
|
||||
top: -8px;
|
||||
left: -11px;
|
||||
border-left: 8px solid #fff;
|
||||
border-top: 8px solid transparent;
|
||||
border-bottom: 8px solid transparent;
|
||||
}
|
||||
|
||||
.ul-after-sanjiao:hover {
|
||||
border-left: 8px solid #42b983;
|
||||
}
|
||||
|
||||
.sidebar-nav-parent-li-shouqi .ul-after-sanjiao {
|
||||
transform: rotate(90deg);
|
||||
transition: transform 0.3s;
|
||||
}
|
||||
|
||||
.return-top {
|
||||
position: fixed;
|
||||
bottom: 20px;
|
||||
right: 20px;
|
||||
display: none;
|
||||
width: 50px;
|
||||
height: 50px;
|
||||
border-radius: 100%;
|
||||
background: #d8d7d7;
|
||||
display: flex;
|
||||
text-align: center;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.return-top-div {
|
||||
margin-left: 5px;
|
||||
width: 40px;
|
||||
height: 40px;
|
||||
margin-top: 5px;
|
||||
font-size: 14px;
|
||||
color: #5f5959;
|
||||
line-height: 16px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
|
||||
}
|
||||
|
||||
.return-top:hover {
|
||||
background: #42b983;
|
||||
}
|
||||
|
||||
.return-top:hover .return-top-div {
|
||||
font-size: 18px;
|
||||
color: #fff;
|
||||
}
|
||||
</style>
|
||||
|
||||
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<nav></nav>
|
||||
<div id="app">loading...</div>
|
||||
|
||||
<!-- vue文件在线编辑 -->
|
||||
<script src="//unpkg.com/vue/dist/vue.min.js"></script>
|
||||
<script src="https://unpkg.com/babel-standalone@6/babel.min.js"></script>
|
||||
<!-- 引入组件库 -->
|
||||
<script src="https://unpkg.com/element-ui/lib/index.js"></script>
|
||||
|
||||
<script src="//unpkg.com/docsify-demo-box-vue/dist/docsify-demo-box-vue.min.js"></script>
|
||||
<!-- 在线编辑运行Vue的插件 -->
|
||||
<script src="//unpkg.com/vuep/dist/vuep.min.js"></script>
|
||||
|
||||
|
||||
|
||||
<script>
|
||||
// 引入docsify-demo-box-vue
|
||||
var jsResources = '<scr' + 'ipt src="//unpkg.com/vue/dist/vue.js"></scr' + 'ipt>'
|
||||
var cssResources = '@import url("//cdnjs.cloudflare.com/ajax/libs/normalize/7.0.0/normalize.min.css");'
|
||||
var bootCode = 'var globalVariable = "leon"'
|
||||
var globalVariable = "leon"
|
||||
|
||||
window.$docsify = {
|
||||
// name: 'strawberry wallpaper',
|
||||
loadNavbar: true,
|
||||
maxLevel: 6,
|
||||
auto2top: true,
|
||||
autoHeader: true,
|
||||
// loadSidebar: true,
|
||||
subMaxLevel: 3,
|
||||
// disqus: 'yangpeng',
|
||||
// 搜索完整配置参数
|
||||
search: {
|
||||
placeholder: '请输入关键字',
|
||||
noData: '暂无结果',
|
||||
// 搜索标题的最大程级, 1 - 6
|
||||
depth: 6
|
||||
},
|
||||
|
||||
plugins: [
|
||||
DemoBoxVue.create(jsResources, cssResources, bootCode),
|
||||
function (hook) {
|
||||
hook.doneEach(function () {
|
||||
//回到顶部
|
||||
let return_top = $('<div class="return-top"><div class="return-top-div">顶</div></div>')
|
||||
$('html').append(return_top);
|
||||
$(window).scroll(function () {
|
||||
var scroll = $(window).scrollTop();
|
||||
if (scroll > 1000) {
|
||||
$(return_top).show();
|
||||
} else {
|
||||
$(return_top).hide();
|
||||
}
|
||||
})
|
||||
return_top.on('click', function (e) {
|
||||
$('html,body').animate({
|
||||
scrollTop: 0
|
||||
}, 500)
|
||||
})
|
||||
})
|
||||
}
|
||||
]
|
||||
}
|
||||
</script>
|
||||
|
||||
<script src="//unpkg.com/docsify/lib/docsify.min.js"></script>
|
||||
|
||||
<!-- 复制到剪切板 -->
|
||||
<script src="https://unpkg.com/docsify-copy-code@2"></script>
|
||||
|
||||
<!-- 搜索 -->
|
||||
<script src="//unpkg.com/docsify/lib/plugins/search.min.js"></script>
|
||||
|
||||
<!-- 图片放大 -->
|
||||
<script src="//unpkg.com/docsify/lib/plugins/zoom-image.js"></script>
|
||||
|
||||
<script src="//unpkg.com/docsify/lib/plugins/external-script.min.js"></script>
|
||||
|
||||
<!-- Disqus 评论系统-->
|
||||
<!-- <script src="//unpkg.com/docsify/lib/plugins/disqus.min.js"></script> -->
|
||||
|
||||
|
||||
<!-- 分页导航插件 -->
|
||||
<!-- <script src="//unpkg.com/docsify-pagination/dist/docsify-pagination.min.js"></script> -->
|
||||
|
||||
<!-- 引入代码块的颜色支持 -->
|
||||
<script src="//unpkg.com/prismjs/components/prism-bash.min.js"></script>
|
||||
<script src="//unpkg.com/prismjs/components/prism-json.min.js"></script>
|
||||
<script src="//unpkg.com/prismjs/components/prism-javascript.min.js"></script>
|
||||
<script src="//unpkg.com/prismjs/components/prism-diff.min.js"></script>
|
||||
<!-- <script src="//unpkg.com/docsify/lib/plugins/ga.min.js"></script> -->
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</body>
|
||||
|
||||
</html>
|
||||
1
docs/zh-cn/.pydio
Normal file
@@ -0,0 +1 @@
|
||||
d51c4cfd-204c-4d1f-b63f-975d8241cdaa
|
||||
30
docs/zh-cn/problem.md
Executable file
@@ -0,0 +1,30 @@
|
||||
### 软件在window下会存在重复运行的问题
|
||||
即双击打开软件,在windows下会创建一个新的运行程序。
|
||||
|
||||
#### 解决方法
|
||||
```js
|
||||
// 创建程序锁,保证只能打开单个实例
|
||||
if (isWin()) {
|
||||
const gotTheLock = app.requestSingleInstanceLock()
|
||||
if (!gotTheLock) {
|
||||
app.quit()
|
||||
} else {
|
||||
app.on('second-instance', (event, commandLine, workingDirectory) => {
|
||||
if (mainWindow) {
|
||||
if (!mainWindow.isVisible()) {
|
||||
mainWindowShow()
|
||||
}
|
||||
mainWindow.focus()
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### win.setPosition方法报错
|
||||
##### 原因:setPosition方法中的参数不支持浮点数,只支持整数
|
||||
|
||||
### 远程升级相关问题
|
||||
#### 1.远程升级只能在build后生效
|
||||
#### 2.mac端远程升级需要development ID 到官网申请
|
||||
#### 3.安装最新的electron-update后,运行提示缺少`whenReady()`方法,那是因为`electron-vue`的`electron`版本为2.7的而`whenReady()`为electron3.0.0更新的。解决办法就是升级electron
|
||||
8
docs/zh-cn/reptile.md
Executable file
@@ -0,0 +1,8 @@
|
||||
### 分析网页接口
|
||||
> 在此处拿https://www.pexels.com 的图库进行分析
|
||||
|
||||
pexels为一个面版权的图库网站,
|
||||
|
||||
### 模拟请求
|
||||
|
||||
### 处理DOM
|
||||
94
docs/zh-cn/save-image.md
Executable file
@@ -0,0 +1,94 @@
|
||||
#### 文件代码在 src/file.js
|
||||
|
||||
起初采用axios进行图片的下载,但是axios在服务端不支持进度条,最后又换成了request请求。
|
||||
|
||||
```js
|
||||
export const downloadPic = async function (src, mainWindow) {
|
||||
// 返回一个Promise方便处理
|
||||
return new Promise((resolve, reject) => {
|
||||
// 先检测目录,没有相关目录的话会自动创建新的目录
|
||||
mkdirSync(hostdir)
|
||||
// 自动重命名
|
||||
let dstpath = `${hostdir}/${(new Date()).getTime()}_${(new Date()).getMilliseconds()}`
|
||||
// webp格式的图片标志,500px下载的图片为webp格式的
|
||||
let isWebp = false
|
||||
// 判断图片格式
|
||||
if (src.match('webp=true')) {
|
||||
dstpath += '.webp'
|
||||
isWebp = true
|
||||
} else {
|
||||
dstpath += '.jpg'
|
||||
isWebp = false
|
||||
}
|
||||
|
||||
// 已经接受的文件的大小
|
||||
let receivedBytes = 0
|
||||
// 文件总的字大小
|
||||
let totalBytes = 0
|
||||
|
||||
// 创建一个文件流
|
||||
const writeStream = fs.createWriteStream(dstpath, {
|
||||
autoClose: true
|
||||
})
|
||||
// 创建一个请求
|
||||
myRequest = request({
|
||||
url: src,
|
||||
headers: browserHeader,
|
||||
})
|
||||
myRequest.pipe(writeStream)
|
||||
myRequest.on('response', (data) => {
|
||||
// 更新总文件字节大小
|
||||
totalBytes = parseInt(data.headers['content-length'], 10)
|
||||
})
|
||||
myRequest.on('data', (chunk) => {
|
||||
// 更新下载的文件块字节大小
|
||||
receivedBytes += chunk.length
|
||||
// 更新进度条
|
||||
mainWindow.webContents.send('datainfo', {
|
||||
type: 'updaterProgress',
|
||||
data: parseFloat(((receivedBytes / totalBytes) * 100))
|
||||
})
|
||||
})
|
||||
|
||||
myRequest.on('finish', () => {
|
||||
myRequest = null
|
||||
})
|
||||
myRequest.on('error', () => {
|
||||
reject()
|
||||
})
|
||||
writeStream.on('finish', () => {
|
||||
writeStream.end()
|
||||
myRequest = null
|
||||
if (receivedBytes === totalBytes){
|
||||
if (isWebp) {
|
||||
// 将webp图片转成jpg图片
|
||||
webp.dwebp(dstpath, dstpath.replace('webp', 'jpg'), '-o', (status) => {
|
||||
// status 101->fails || 100->successful
|
||||
if (status === '100'){
|
||||
fs.unlink(dstpath, (err) => {
|
||||
if (err) throw err
|
||||
// console.log('文件已删除')
|
||||
})
|
||||
resolve(dstpath.replace('webp', 'jpg'))
|
||||
} else {
|
||||
reject()
|
||||
}
|
||||
})
|
||||
} else {
|
||||
resolve(dstpath)
|
||||
}
|
||||
} else {
|
||||
fs.unlink(dstpath, (err) => {
|
||||
if (err) throw err
|
||||
})
|
||||
// 更新进度条
|
||||
mainWindow.webContents.send('datainfo', {
|
||||
type: 'updaterProgress',
|
||||
data: 0
|
||||
})
|
||||
reject()
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
```
|
||||
1
docs/zh-cn/set-wallpaper.md
Executable file
@@ -0,0 +1 @@
|
||||
不支持
|
||||
1
docs/zh-cn/start.md
Executable file
@@ -0,0 +1 @@
|
||||
xiangmudajian
|
||||
79
docs/zh-cn/tarbar.md
Executable file
@@ -0,0 +1,79 @@
|
||||
#### 定位
|
||||
```js
|
||||
appTray.on('click', (event, bounds, position) => {
|
||||
// mainWindow === null ? createWindow() : mainWindow.close()
|
||||
// return
|
||||
// 点击时显示窗口,并修改窗口的显示位置
|
||||
function setMainWinPosition(win, trayBounds) {
|
||||
try {
|
||||
const { screen } = electron
|
||||
const winWidth = mainWindow.getSize()[0]
|
||||
const winHeight = mainWindow.getSize()[1]
|
||||
const cursorPosition = screen.getCursorScreenPoint()
|
||||
const currentScreen = screen.getDisplayNearestPoint(cursorPosition)
|
||||
const screens = screen.getAllDisplays()
|
||||
|
||||
let screenWidth = 0
|
||||
|
||||
// 这目前判断多屏都是横着拼的多屏,
|
||||
for (let i = 0; i < screens.length; i++) {
|
||||
screenWidth += screens[i].workAreaSize.width
|
||||
}
|
||||
|
||||
cursorPosition.x = trayBounds.x + trayBounds.width / 2
|
||||
|
||||
const parallelType = cursorPosition.x < screenWidth / 2 ? 'left' : 'right'
|
||||
const verticaType = cursorPosition.y < currentScreen.workAreaSize.height / 2 ? 'top' : 'bottom'
|
||||
|
||||
let trayPositionType = '' // 任务栏的位置
|
||||
let trayPositionSize = 0
|
||||
|
||||
if (currentScreen.workAreaSize.height < currentScreen.size.height) {
|
||||
trayPositionType = verticaType === 'top' ? 'top' : 'bottom'
|
||||
trayPositionSize = currentScreen.size.height - currentScreen.workAreaSize.height
|
||||
} else if (currentScreen.workAreaSize.width < currentScreen.size.width) {
|
||||
trayPositionType = parallelType === 'left' ? 'left' : 'right'
|
||||
trayPositionSize = currentScreen.size.width - currentScreen.workAreaSize.width
|
||||
}
|
||||
|
||||
let winPositionX = 1
|
||||
let winPositionY = 1
|
||||
|
||||
if (trayPositionType === 'top') {
|
||||
winPositionX = Math.max(Math.min(screenWidth - winWidth, cursorPosition.x - (winWidth / 2)), 1)
|
||||
winPositionY = trayBounds.height + 2
|
||||
} else if (trayPositionType === 'bottom') {
|
||||
winPositionX = Math.max(Math.min(screenWidth - winWidth, cursorPosition.x - (winWidth / 2)), 1)
|
||||
winPositionY = currentScreen.size.height - trayPositionSize - winHeight
|
||||
} else if (trayPositionType === 'left') {
|
||||
winPositionX = trayPositionSize
|
||||
winPositionY = Math.max(Math.min(currentScreen.size.height - winHeight, cursorPosition.y - (winHeight / 2)), 1)
|
||||
} else if (trayPositionType === 'right') {
|
||||
winPositionX = screenWidth - trayPositionSize - winWidth
|
||||
winPositionY = Math.max(Math.min(currentScreen.size.height - winHeight, cursorPosition.y - (winHeight / 2)), 1)
|
||||
}
|
||||
win.setPosition(parseInt(winPositionX, 10), winPositionY)
|
||||
} catch (error) {
|
||||
log.error(error)
|
||||
}
|
||||
}
|
||||
try {
|
||||
if (mainWindow.isVisible()) {
|
||||
mainWindow.webContents.send('datainfo', {
|
||||
type: 'windowShow',
|
||||
data: false
|
||||
})
|
||||
mainWindowHide()
|
||||
} else {
|
||||
mainWindow.webContents.send('datainfo', {
|
||||
type: 'windowShow',
|
||||
data: true
|
||||
})
|
||||
mainWindowShow()
|
||||
setMainWinPosition(mainWindow, bounds)
|
||||
}
|
||||
} catch (error) {
|
||||
log.error(error)
|
||||
}
|
||||
})
|
||||
```
|
||||
3
docs/zh-cn/updata.md
Executable file
@@ -0,0 +1,3 @@
|
||||
### 远程升级
|
||||
|
||||
采用`electron-updater`模块
|
||||