diff --git a/.env.electrondev b/.env.electrondev new file mode 100644 index 0000000..62ae251 --- /dev/null +++ b/.env.electrondev @@ -0,0 +1,2 @@ +VUE_APP_MODE=electron +NODE_ENV=development diff --git a/.env.utoolsdev b/.env.utoolsdev new file mode 100644 index 0000000..6167472 --- /dev/null +++ b/.env.utoolsdev @@ -0,0 +1,2 @@ +VUE_APP_MODE=utools +NODE_ENV=development diff --git a/.github/workflows/node.js.yml b/.github/workflows/node.js.yml index 8ab4905..84f4d85 100644 --- a/.github/workflows/node.js.yml +++ b/.github/workflows/node.js.yml @@ -44,6 +44,12 @@ jobs: runs-on: ${{matrix.os}} steps: - uses: actions/checkout@v2 + - name: Load private files + uses: DamianReeves/write-file-action@v1.0 + 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: diff --git a/.github/workflows/release-note.md b/.github/workflows/release-note.md index 2e3af01..6f76127 100644 --- a/.github/workflows/release-note.md +++ b/.github/workflows/release-note.md @@ -2,3 +2,4 @@ - 👏 新增 score 和 other 标签。 - ⚡️ 订阅页面点击标题跳转详情页面。 - ⚡️ 简化规则源码显示,不显示 null 值字段。 +- ⚡️ 修复侧边栏在 Windows 和 Linux 下出现多余的横向滚动条。 #15 diff --git a/package.json b/package.json index b44cb82..6303178 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "searchx", "productName": "SearchX", - "version": "1.1.1", + "version": "1.1.2", "author": { "name": "lanyuanxiaoyao", "email": "lanyuanxiaoyao@gmail.com" @@ -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" }, diff --git a/public_electron/preload.js b/public_electron/preload.js index d32b486..a6e0040 100644 --- a/public_electron/preload.js +++ b/public_electron/preload.js @@ -17,17 +17,17 @@ 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') @@ -35,16 +35,19 @@ 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, @@ -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) diff --git a/public_utools/preload.js b/public_utools/preload.js index f454e87..4b03016 100644 --- a/public_utools/preload.js +++ b/public_utools/preload.js @@ -18,17 +18,17 @@ 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') @@ -36,16 +36,17 @@ 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, @@ -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) diff --git a/scripts/pre-build-utools.js b/scripts/pre-build-utools.js index fc50235..b0cd0e9 100644 --- a/scripts/pre-build-utools.js +++ b/scripts/pre-build-utools.js @@ -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': '海纳百川, 搜遍天下', @@ -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': [ { @@ -31,10 +35,10 @@ let pluginFile = JSON.stringify({ 'BT', '资源搜索', '种子搜索', - 'SearchX' - ] - } - ] + 'SearchX', + ], + }, + ], }) fs.writeFileSync(`${publicPath}/plugin.json`, pluginFile) diff --git a/src/App.vue b/src/App.vue index b434f17..a669306 100644 --- a/src/App.vue +++ b/src/App.vue @@ -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: { @@ -72,7 +74,7 @@ export default { } }, mounted() { - if (process.env.NODE_ENV !== 'development') { + if (!isDevelopment) { squirrel.services.checkUpdate() .then(result => { if (result.cmp < 0) { @@ -166,6 +168,7 @@ export default { .sider-menu height 100% overflow-y auto + overflow-x hidden .site-icon margin-right 10px diff --git a/src/background.js b/src/background.js index e81827d..f20a980 100644 --- a/src/background.js +++ b/src/background.js @@ -119,7 +119,7 @@ app.on('ready', async () => { {label: '全选', role: 'selectall'} ] }) - if (!process.env.IS_TEST) { + if (isDevelopment) { appMenuTemplate.push({ label: '开发', submenu: [ diff --git a/src/squirrel/index.js b/src/squirrel/index.js index 7191225..8eacaa8 100644 --- a/src/squirrel/index.js +++ b/src/squirrel/index.js @@ -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 diff --git a/src/squirrel/squirrel-web.js b/src/squirrel/squirrel-web.js index 6ef49ac..a92f387 100644 --- a/src/squirrel/squirrel-web.js +++ b/src/squirrel/squirrel-web.js @@ -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 () => { @@ -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 => { @@ -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) @@ -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 diff --git a/src/store/index.js b/src/store/index.js index 93025b7..9ffef00 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -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: { diff --git a/src/store/update-info.js b/src/store/update-info.js index 336233f..03827ee 100644 --- a/src/store/update-info.js +++ b/src/store/update-info.js @@ -42,10 +42,11 @@ export default { '⚡️ 其他代码改进。', ], [ - '1.1.1', + '1.1.2', '👏 新增 score 和 other 标签。', '⚡️ 订阅页面点击标题跳转详情页面。', '⚡️ 简化规则源码显示,不显示 null 值字段。', + '⚡️ 修复侧边栏在 Windows 和 Linux 下出现多余的横向滚动条。 #15', ], ], }), diff --git a/src/utils/utils.js b/src/utils/utils.js index fa24b0d..9c34452 100644 --- a/src/utils/utils.js +++ b/src/utils/utils.js @@ -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 = [] @@ -110,6 +112,8 @@ export default { }, // 统计埋点 statistic(path, event) { + // 如果是开发模式, 不发送统计信息 + if (isDevelopment) return let query = {} query['path'] = path if (!isNil(event)) { @@ -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)