Skip to content

Commit

Permalink
Merge pull request #16 from LanyuanXiaoyao-Studio/dev
Browse files Browse the repository at this point in the history
  • Loading branch information
lanyuanxiaoyao authored Feb 20, 2021
2 parents fa78bc7 + fc8eb74 commit c477f4c
Show file tree
Hide file tree
Showing 15 changed files with 87 additions and 56 deletions.
2 changes: 2 additions & 0 deletions .env.electrondev
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
VUE_APP_MODE=electron
NODE_ENV=development
2 changes: 2 additions & 0 deletions .env.utoolsdev
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
VUE_APP_MODE=utools
NODE_ENV=development
6 changes: 6 additions & 0 deletions .github/workflows/node.js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,12 @@ jobs:
runs-on: ${{matrix.os}}
steps:
- uses: actions/checkout@v2
- name: Load private files
uses: DamianReeves/[email protected]
with:
path: src/private/StatisticsApi.js
contents: ${{ secrets.STATISTICS_API }}
write-mode: overwrite
- name: Use Node.js ${{matrix.node-version}} in ${{matrix.os}}
uses: actions/setup-node@v1
with:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/release-note.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
- 👏 新增 score 和 other 标签。
- ⚡️ 订阅页面点击标题跳转详情页面。
- ⚡️ 简化规则源码显示,不显示 null 值字段。
- ⚡️ 修复侧边栏在 Windows 和 Linux 下出现多余的横向滚动条。 #15
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "searchx",
"productName": "SearchX",
"version": "1.1.1",
"version": "1.1.2",
"author": {
"name": "lanyuanxiaoyao",
"email": "[email protected]"
Expand All @@ -12,11 +12,11 @@
"web:serve": "node scripts/pre-build-web.js && vue-cli-service serve --mode webdev",
"web:build": "node scripts/pre-build-web.js && vue-cli-service build --mode web",
"web:image": "node scripts/pre-build-web.js && vue-cli-service build --mode web && /bin/bash scripts/suf-build-web.sh",
"electron:serve": "node scripts/pre-build-electron.js && vue-cli-service electron:serve --mode electron",
"electron:serve": "node scripts/pre-build-electron.js && vue-cli-service electron:serve --mode electrondev",
"electron:build": "node scripts/pre-build-electron.js && vue-cli-service electron:build --mode electron",
"postinstall": "electron-builder install-app-deps",
"postuninstall": "electron-builder install-app-deps",
"utools:serve": "node scripts/pre-build-utools.js && vue-cli-service serve --mode utools",
"utools:serve": "node scripts/pre-build-utools.js && vue-cli-service serve --mode utoolsdev",
"utools:build": "node scripts/pre-build-utools.js && vue-cli-service build --mode utools",
"clear": "node scripts/clear.js"
},
Expand Down
37 changes: 21 additions & 16 deletions public_electron/preload.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,34 +17,37 @@ window.isFileExists = path => fs.existsSync(path)
window.singleFileSelect = () => {
let paths = dialog.showOpenDialogSync({
properties: ['openFile'],
filters: [{name: 'JSON File', extensions: ['json']}]
filters: [{name: 'JSON File', extensions: ['json']}],
})
if (paths && paths.length > 0) return paths[0]
return ''
}
window.readTextFromFile = path => {
return new Promise((resolve, reject) =>
fs.readFile(path, {encoding: 'utf8'}, (error, data) => {
if (error) reject(error)
resolve(data)
})
fs.readFile(path, {encoding: 'utf8'}, (error, data) => {
if (error) reject(error)
resolve(data)
}),
)
}
const http = url => url.indexOf('https') === 0 ? require('https') : require('http')
window.readTextFromUrl = url => {
return new Promise((resolve, reject) => {
// console.log(url, url.indexOf('https'), http(url))
let request = http(url)
.get(url, response => {
let result = ''
response.on('data', data => result += data)
response.on('end', () => resolve(result))
})
.get(url, response => {
let result = ''
response.on('data', data => result += data)
response.on('end', () => resolve(result))
})
request.on('error', e => reject(e))
})
}
const platform = require('os')
.platform()
window.statistic = (options) => {
let request = require('https').request(
let request = require('https')
.request(
{
host: options.host,
method: options.method,
Expand All @@ -54,11 +57,13 @@ window.statistic = (options) => {
response => {
let result = ''
response.on('data', data => result += data)
response.on('end', () => {})
}
)
request.setHeader('mode', 'desktop')
Object.keys(options.headers).forEach(key => request.setHeader(key, options.headers[key]))
response.on('end', () => {
})
},
)
request.setHeader('mode', `desktop-${platform}`)
Object.keys(options.headers)
.forEach(key => request.setHeader(key, options.headers[key]))
request.end()
}
window.openInExternal = url => shell.openExternal(url)
Expand Down
33 changes: 18 additions & 15 deletions public_utools/preload.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,34 +18,35 @@ window.isFileExists = path => fs.existsSync(path)
window.singleFileSelect = () => {
let paths = utools.showOpenDialog({
properties: ['openFile'],
filters: [{name: 'JSON File', extensions: ['json']}]
filters: [{name: 'JSON File', extensions: ['json']}],
})
if (paths && paths.length > 0) return paths[0]
return ''
}
window.readTextFromFile = path => {
return new Promise((resolve, reject) =>
fs.readFile(path, {encoding: 'utf8'}, (error, data) => {
if (error) reject(error)
resolve(data)
})
fs.readFile(path, {encoding: 'utf8'}, (error, data) => {
if (error) reject(error)
resolve(data)
}),
)
}
const http = url => url.indexOf('https') === 0 ? require('https') : require('http')
window.readTextFromUrl = url => {
return new Promise((resolve, reject) => {
// console.log(url, url.indexOf('https'), http(url))
let request = http(url)
.get(url, response => {
let result = ''
response.on('data', data => result += data)
response.on('end', () => resolve(result))
})
.get(url, response => {
let result = ''
response.on('data', data => result += data)
response.on('end', () => resolve(result))
})
request.on('error', e => reject(e))
})
}
window.statistic = (options) => {
let request = require('https').request(
let request = require('https')
.request(
{
host: options.host,
method: options.method,
Expand All @@ -55,11 +56,13 @@ window.statistic = (options) => {
response => {
let result = ''
response.on('data', data => result += data)
response.on('end', () => {})
}
)
response.on('end', () => {
})
},
)
request.setHeader('mode', 'utools')
Object.keys(options.headers).forEach(key => request.setHeader(key, options.headers[key]))
Object.keys(options.headers)
.forEach(key => request.setHeader(key, options.headers[key]))
request.end()
}
window.openInExternal = url => utools.shellOpenExternal(url)
Expand Down
16 changes: 10 additions & 6 deletions scripts/pre-build-utools.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ let publicSourcePath = path.join(__dirname, '..', 'public_utools')
let packageFile = fs.readFileSync(path.join(__dirname, '..', 'package.json'), {encoding: 'utf-8'})
let version = JSON.parse(packageFile)['version']
let pluginFile = JSON.stringify({
'pluginName': 'SearchX',
'pluginName': 'SearchX (资源搜索)',
'author': 'lanyuanxiaoyao',
'homepage': 'https://github.com/LanyuanXiaoyao-Studio/SearchX',
'description': '海纳百川, 搜遍天下',
Expand All @@ -20,7 +20,11 @@ let pluginFile = JSON.stringify({
'preload': 'preload.js',
'pluginSetting': {
'single': true,
'height': 580
'height': 580,
},
'development': {
'main': 'http://127.0.0.1:8080/index.html',
'preload': './preload.js',
},
'features': [
{
Expand All @@ -31,10 +35,10 @@ let pluginFile = JSON.stringify({
'BT',
'资源搜索',
'种子搜索',
'SearchX'
]
}
]
'SearchX',
],
},
],
})
fs.writeFileSync(`${publicPath}/plugin.json`, pluginFile)

Expand Down
5 changes: 4 additions & 1 deletion src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ import {mapGetters} from 'vuex'
import {isEmpty, isNil} from 'licia';
import DevelopmentTag from '@/components/DevelopmentTag'
const isDevelopment = process.env.NODE_ENV !== 'production'
export default {
name: 'App',
components: {
Expand All @@ -72,7 +74,7 @@ export default {
}
},
mounted() {
if (process.env.NODE_ENV !== 'development') {
if (!isDevelopment) {
squirrel.services.checkUpdate()
.then(result => {
if (result.cmp < 0) {
Expand Down Expand Up @@ -166,6 +168,7 @@ export default {
.sider-menu
height 100%
overflow-y auto
overflow-x hidden
.site-icon
margin-right 10px
Expand Down
2 changes: 1 addition & 1 deletion src/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ app.on('ready', async () => {
{label: '全选', role: 'selectall'}
]
})
if (!process.env.IS_TEST) {
if (isDevelopment) {
appMenuTemplate.push({
label: '开发',
submenu: [
Expand Down
2 changes: 1 addition & 1 deletion src/squirrel/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ else {
squirrelWrapper.info()
.then(result => console.log(result))
.catch(error => console.log(error))
squirrelWrapper.debug('true')
squirrelWrapper.debug('false')

window.squirrel = squirrelWrapper

Expand Down
20 changes: 10 additions & 10 deletions src/squirrel/squirrel-web.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import superagent from 'superagent'
import store from '@/store'
import Vue from 'vue'
import {isNil, base64, strToBytes} from 'licia'
import {base64, isNil, strToBytes} from 'licia'

const env = process.env.NODE_ENV
const isDevelopment = process.env.NODE_ENV !== 'production'

const base = env === 'development' ? 'http://localhost:10086/management' : '/management'
const base = isDevelopment ? 'http://localhost:10086/management' : '/management'

window.download = async url => (await superagent.get(`${base}/simpleGet?url=${base64.encode(strToBytes(url))}`)).text
window.squirrelInitialReady = async () => {
Expand All @@ -24,10 +24,10 @@ window.readTextFromFile = path => {
window.readTextFromUrl = async url => (await superagent.get(`${base}/simpleGet?url=${base64.encode(strToBytes(url))}`)).text
window.statistic = options => {
superagent.get(options.url)
.set(options.headers)
.set('mode', 'web')
.then(result => console.log(result))
.catch(error => console.log(error))
.set(options.headers)
.set('mode', 'web')
.then(result => console.log(result))
.catch(error => console.log(error))
}
window.openInExternal = url => window.open(url)
window.copyText = async text => {
Expand All @@ -41,14 +41,14 @@ window.copyText = async text => {
textArea.focus()
textArea.select()
try {
let successful = document.execCommand('copy');
let successful = document.execCommand('copy')
if (!successful) {
throw new Error('Copy Failure')
}
} catch (err) {
throw new Error('Copy Failure')
}
document.body.removeChild(textArea);
document.body.removeChild(textArea)
}
if (!navigator.clipboard) {
fallback(text)
Expand All @@ -60,7 +60,7 @@ window.notify = (text, callback) => {
let notify = () => {
let notification = new Notification('SearchX', {
body: text,
requireInteraction: !isNil(callback)
requireInteraction: !isNil(callback),
})
if (!isNil(callback)) {
notification.onclick = callback
Expand Down
2 changes: 1 addition & 1 deletion src/store/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const store = new Vuex.Store({
state: {
currentUrl: '/',
statisticUrl: 'http://127.0.0.1:8080/analysis/record',
version: '1.1.1',
version: '1.1.2',
sites: [],
categories: {},
settings: {
Expand Down
3 changes: 2 additions & 1 deletion src/store/update-info.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,11 @@ export default {
'⚡️ 其他代码改进。',
],
[
'<b>1.1.1</b>',
'<b>1.1.2</b>',
'👏 新增 score 和 other 标签。',
'⚡️ 订阅页面点击标题跳转详情页面。',
'⚡️ 简化规则源码显示,不显示 null 值字段。',
'⚡️ 修复侧边栏在 Windows 和 Linux 下出现多余的横向滚动条。 #15',
],
],
}),
Expand Down
6 changes: 5 additions & 1 deletion src/utils/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import {isEmpty, isFn, isNil, isPromise} from 'licia'
import Vue from 'vue'
import store from '@/store'

const isDevelopment = process.env.NODE_ENV !== 'production'

export default {
generateTagList(item) {
let tagList = []
Expand Down Expand Up @@ -110,6 +112,8 @@ export default {
},
// 统计埋点
statistic(path, event) {
// 如果是开发模式, 不发送统计信息
if (isDevelopment) return
let query = {}
query['path'] = path
if (!isNil(event)) {
Expand All @@ -119,7 +123,7 @@ export default {
let api = require('@/private/StatisticsApi')
if (!isNil(api)) {
let options = api.default.tencentApi()
.options(query)
.options(query)
console.log('options', options)
if (!isNil(options)) {
window.statistic(options)
Expand Down

0 comments on commit c477f4c

Please sign in to comment.