├── .babelrc ├── .electron-vue ├── build.config.js ├── build.js ├── dev-client.js ├── dev-runner.js ├── webpack.main.config.js ├── webpack.renderer.config.js └── webpack.web.config.js ├── .eslintignore ├── .eslintrc.js ├── .gitignore ├── .travis.yml ├── README.md ├── appveyor.yml ├── build └── icons │ ├── 256x256.png │ ├── icon.icns │ └── icon.ico ├── dist ├── electron │ └── .gitkeep └── web │ └── .gitkeep ├── package-lock.json ├── package.json ├── src ├── index.ejs ├── main │ ├── index.dev.js │ ├── index.js │ └── menu.js └── renderer │ ├── app.vue │ ├── assets │ ├── bgm-nodata.png │ ├── empty-icon.png │ ├── no-data.png │ └── no_more.png │ ├── common │ ├── copyGif.js │ ├── hotWords.js │ ├── imageManager.js │ ├── imgProcess.js │ └── storage.js │ ├── components │ ├── Empty.vue │ ├── app-header.vue │ ├── expression-item.vue │ ├── expression-list.vue │ ├── expression-types.vue │ ├── loading.vue │ └── showLinks.js │ ├── constants.js │ ├── main.js │ ├── pages │ ├── collect-panel.vue │ └── search-panel │ │ ├── expression.vue │ │ ├── index.vue │ │ └── package │ │ ├── index.vue │ │ ├── package-detail.vue │ │ └── package-list.vue │ ├── router.js │ ├── service │ ├── expPackage.js │ ├── picBed.js │ └── queryEngine.js │ ├── store.js │ ├── styles │ ├── fonts │ │ ├── icomoon.svg │ │ ├── icomoon.ttf │ │ └── icomoon.woff │ ├── global.scss │ ├── icons.scss │ ├── index.scss │ └── variables.scss │ └── util │ ├── bus.js │ ├── copy.js │ ├── helper.js │ └── linkBuilder.js ├── static ├── .gitkeep └── temp_image │ └── .placeholder └── summary.gif /.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "comments": false, 3 | "env": { 4 | "main": { 5 | "presets": [ 6 | ["env", { 7 | "targets": { "node": 7 } 8 | }], 9 | "stage-0" 10 | ] 11 | }, 12 | "renderer": { 13 | "presets": [ 14 | ["env", { 15 | "modules": false 16 | }], 17 | "stage-0" 18 | ] 19 | }, 20 | "web": { 21 | "presets": [ 22 | ["env", { 23 | "modules": false 24 | }], 25 | "stage-0" 26 | ] 27 | } 28 | }, 29 | "plugins": ["transform-runtime"] 30 | } 31 | -------------------------------------------------------------------------------- /.electron-vue/build.config.js: -------------------------------------------------------------------------------- 1 | const path = require('path') 2 | 3 | /** 4 | * `electron-packager` options 5 | * https://simulatedgreg.gitbooks.io/electron-vue/content/en/using-electron-packager.html 6 | */ 7 | module.exports = { 8 | arch: 'x64', 9 | asar: false, 10 | dir: path.join(__dirname, '../'), 11 | icon: path.join(__dirname, '../build/icons/icon'), 12 | ignore: /(^\/(src|test|\.[a-z]+|README|yarn|static|dist\/web))|\.gitkeep/, 13 | out: path.join(__dirname, '../build'), 14 | overwrite: true, 15 | platform: process.env.BUILD_TARGET || 'all' 16 | } 17 | -------------------------------------------------------------------------------- /.electron-vue/build.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | process.env.NODE_ENV = 'production' 4 | 5 | const { say } = require('cfonts') 6 | const chalk = require('chalk') 7 | const del = require('del') 8 | const packager = require('electron-packager') 9 | const webpack = require('webpack') 10 | const Multispinner = require('multispinner') 11 | 12 | const buildConfig = require('./build.config') 13 | const mainConfig = require('./webpack.main.config') 14 | const rendererConfig = require('./webpack.renderer.config') 15 | const webConfig = require('./webpack.web.config') 16 | 17 | const doneLog = chalk.bgGreen.white(' DONE ') + ' ' 18 | const errorLog = chalk.bgRed.white(' ERROR ') + ' ' 19 | const okayLog = chalk.bgBlue.white(' OKAY ') + ' ' 20 | const isCI = process.env.CI || false 21 | 22 | if (process.env.BUILD_TARGET === 'clean') clean() 23 | else if (process.env.BUILD_TARGET === 'web') web() 24 | else build() 25 | 26 | function clean () { 27 | del.sync(['build/*', '!build/icons', '!build/icons/icon.*']) 28 | console.log(`\n${doneLog}\n`) 29 | process.exit() 30 | } 31 | 32 | function build () { 33 | greeting() 34 | 35 | del.sync(['dist/electron/*', '!.gitkeep']) 36 | 37 | const tasks = ['main', 'renderer'] 38 | const m = new Multispinner(tasks, { 39 | preText: 'building', 40 | postText: 'process' 41 | }) 42 | 43 | let results = '' 44 | 45 | m.on('success', () => { 46 | process.stdout.write('\x1B[2J\x1B[0f') 47 | console.log(`\n\n${results}`) 48 | console.log(`${okayLog}take it away ${chalk.yellow('`electron-packager`')}\n`) 49 | bundleApp() 50 | }) 51 | 52 | pack(mainConfig).then(result => { 53 | results += result + '\n\n' 54 | m.success('main') 55 | }).catch(err => { 56 | m.error('main') 57 | console.log(`\n ${errorLog}failed to build main process`) 58 | console.error(`\n${err}\n`) 59 | process.exit(1) 60 | }) 61 | 62 | pack(rendererConfig).then(result => { 63 | results += result + '\n\n' 64 | m.success('renderer') 65 | }).catch(err => { 66 | m.error('renderer') 67 | console.log(`\n ${errorLog}failed to build renderer process`) 68 | console.error(`\n${err}\n`) 69 | process.exit(1) 70 | }) 71 | } 72 | 73 | function pack (config) { 74 | return new Promise((resolve, reject) => { 75 | webpack(config, (err, stats) => { 76 | if (err) reject(err.stack || err) 77 | else if (stats.hasErrors()) { 78 | let err = '' 79 | 80 | stats.toString({ 81 | chunks: false, 82 | colors: true 83 | }) 84 | .split(/\r?\n/) 85 | .forEach(line => { 86 | err += ` ${line}\n` 87 | }) 88 | 89 | reject(err) 90 | } else { 91 | resolve(stats.toString({ 92 | chunks: false, 93 | colors: true 94 | })) 95 | } 96 | }) 97 | }) 98 | } 99 | 100 | function bundleApp () { 101 | packager(buildConfig, (err, appPaths) => { 102 | if (err) { 103 | console.log(`\n${errorLog}${chalk.yellow('`electron-packager`')} says...\n`) 104 | console.log(err + '\n') 105 | } else { 106 | console.log(`\n${doneLog}\n`) 107 | } 108 | }) 109 | } 110 | 111 | function web () { 112 | del.sync(['dist/web/*', '!.gitkeep']) 113 | webpack(webConfig, (err, stats) => { 114 | if (err || stats.hasErrors()) console.log(err) 115 | 116 | console.log(stats.toString({ 117 | chunks: false, 118 | colors: true 119 | })) 120 | 121 | process.exit() 122 | }) 123 | } 124 | 125 | function greeting () { 126 | const cols = process.stdout.columns 127 | let text = '' 128 | 129 | if (cols > 85) text = 'lets-build' 130 | else if (cols > 60) text = 'lets-|build' 131 | else text = false 132 | 133 | if (text && !isCI) { 134 | say(text, { 135 | colors: ['yellow'], 136 | font: 'simple3d', 137 | space: false 138 | }) 139 | } else console.log(chalk.yellow.bold('\n lets-build')) 140 | console.log() 141 | } 142 | -------------------------------------------------------------------------------- /.electron-vue/dev-client.js: -------------------------------------------------------------------------------- 1 | const hotClient = require('webpack-hot-middleware/client?noInfo=true&reload=true') 2 | 3 | hotClient.subscribe(event => { 4 | /** 5 | * Reload browser when HTMLWebpackPlugin emits a new index.html 6 | * 7 | * Currently disabled until jantimon/html-webpack-plugin#680 is resolved. 8 | * https://github.com/SimulatedGREG/electron-vue/issues/437 9 | * https://github.com/jantimon/html-webpack-plugin/issues/680 10 | */ 11 | // if (event.action === 'reload') { 12 | // window.location.reload() 13 | // } 14 | 15 | /** 16 | * Notify `mainWindow` when `main` process is compiling, 17 | * giving notice for an expected reload of the `electron` process 18 | */ 19 | if (event.action === 'compiling') { 20 | document.body.innerHTML += ` 21 | 34 | 35 |
36 | Compiling Main Process... 37 |
38 | ` 39 | } 40 | }) 41 | -------------------------------------------------------------------------------- /.electron-vue/dev-runner.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const chalk = require('chalk') 4 | const electron = require('electron') 5 | const path = require('path') 6 | const { say } = require('cfonts') 7 | const { spawn } = require('child_process') 8 | const webpack = require('webpack') 9 | const WebpackDevServer = require('webpack-dev-server') 10 | const webpackHotMiddleware = require('webpack-hot-middleware') 11 | 12 | const mainConfig = require('./webpack.main.config') 13 | const rendererConfig = require('./webpack.renderer.config') 14 | 15 | let electronProcess = null 16 | let manualRestart = false 17 | let hotMiddleware 18 | 19 | function logStats (proc, data) { 20 | let log = '' 21 | 22 | log += chalk.yellow.bold(`┏ ${proc} Process ${new Array((19 - proc.length) + 1).join('-')}`) 23 | log += '\n\n' 24 | 25 | if (typeof data === 'object') { 26 | data.toString({ 27 | colors: true, 28 | chunks: false 29 | }).split(/\r?\n/).forEach(line => { 30 | log += ' ' + line + '\n' 31 | }) 32 | } else { 33 | log += ` ${data}\n` 34 | } 35 | 36 | log += '\n' + chalk.yellow.bold(`┗ ${new Array(28 + 1).join('-')}`) + '\n' 37 | 38 | console.log(log) 39 | } 40 | 41 | function startRenderer () { 42 | return new Promise((resolve, reject) => { 43 | rendererConfig.entry.renderer = [path.join(__dirname, 'dev-client')].concat(rendererConfig.entry.renderer) 44 | 45 | const compiler = webpack(rendererConfig) 46 | hotMiddleware = webpackHotMiddleware(compiler, { 47 | log: false, 48 | heartbeat: 2500 49 | }) 50 | 51 | compiler.plugin('compilation', compilation => { 52 | compilation.plugin('html-webpack-plugin-after-emit', (data, cb) => { 53 | hotMiddleware.publish({ action: 'reload' }) 54 | cb() 55 | }) 56 | }) 57 | 58 | compiler.plugin('done', stats => { 59 | logStats('Renderer', stats) 60 | }) 61 | 62 | const server = new WebpackDevServer( 63 | compiler, 64 | { 65 | contentBase: path.join(__dirname, '../'), 66 | quiet: true, 67 | before (app, ctx) { 68 | app.use(hotMiddleware) 69 | ctx.middleware.waitUntilValid(() => { 70 | resolve() 71 | }) 72 | } 73 | } 74 | ) 75 | 76 | server.listen(9080) 77 | }) 78 | } 79 | 80 | function startMain () { 81 | return new Promise((resolve, reject) => { 82 | mainConfig.entry.main = [path.join(__dirname, '../src/main/index.dev.js')].concat(mainConfig.entry.main) 83 | 84 | const compiler = webpack(mainConfig) 85 | 86 | compiler.plugin('watch-run', (compilation, done) => { 87 | logStats('Main', chalk.white.bold('compiling...')) 88 | hotMiddleware.publish({ action: 'compiling' }) 89 | done() 90 | }) 91 | 92 | compiler.watch({}, (err, stats) => { 93 | if (err) { 94 | console.log(err) 95 | return 96 | } 97 | 98 | logStats('Main', stats) 99 | 100 | if (electronProcess && electronProcess.kill) { 101 | manualRestart = true 102 | process.kill(electronProcess.pid) 103 | electronProcess = null 104 | startElectron() 105 | 106 | setTimeout(() => { 107 | manualRestart = false 108 | }, 5000) 109 | } 110 | 111 | resolve() 112 | }) 113 | }) 114 | } 115 | 116 | function startElectron () { 117 | electronProcess = spawn(electron, ['--inspect=5858', path.join(__dirname, '../dist/electron/main.js')]) 118 | 119 | electronProcess.stdout.on('data', data => { 120 | electronLog(data, 'blue') 121 | }) 122 | electronProcess.stderr.on('data', data => { 123 | electronLog(data, 'red') 124 | }) 125 | 126 | electronProcess.on('close', () => { 127 | if (!manualRestart) process.exit() 128 | }) 129 | } 130 | 131 | function electronLog (data, color) { 132 | let log = '' 133 | data = data.toString().split(/\r?\n/) 134 | data.forEach(line => { 135 | log += ` ${line}\n` 136 | }) 137 | if (/[0-9A-z]+/.test(log)) { 138 | console.log( 139 | chalk[color].bold('┏ Electron -------------------') + 140 | '\n\n' + 141 | log + 142 | chalk[color].bold('┗ ----------------------------') + 143 | '\n' 144 | ) 145 | } 146 | } 147 | 148 | function init () { 149 | Promise.all([startRenderer(), startMain()]) 150 | .then(() => { 151 | startElectron() 152 | }) 153 | .catch(err => { 154 | console.error(err) 155 | }) 156 | } 157 | 158 | init() 159 | -------------------------------------------------------------------------------- /.electron-vue/webpack.main.config.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | process.env.BABEL_ENV = 'main' 4 | 5 | const path = require('path') 6 | const { dependencies } = require('../package.json') 7 | const webpack = require('webpack') 8 | 9 | const BabiliWebpackPlugin = require('babili-webpack-plugin') 10 | 11 | let mainConfig = { 12 | entry: { 13 | main: path.join(__dirname, '../src/main/index.js') 14 | }, 15 | externals: [ 16 | ...Object.keys(dependencies || {}) 17 | ], 18 | module: { 19 | rules: [ 20 | { 21 | test: /\.(js)$/, 22 | enforce: 'pre', 23 | exclude: /node_modules/, 24 | use: { 25 | loader: 'eslint-loader', 26 | options: { 27 | formatter: require('eslint-friendly-formatter') 28 | } 29 | } 30 | }, 31 | { 32 | test: /\.js$/, 33 | use: 'babel-loader', 34 | exclude: /node_modules/ 35 | }, 36 | { 37 | test: /\.node$/, 38 | use: 'node-loader' 39 | } 40 | ] 41 | }, 42 | node: { 43 | __dirname: process.env.NODE_ENV !== 'production', 44 | __filename: process.env.NODE_ENV !== 'production' 45 | }, 46 | output: { 47 | filename: '[name].js', 48 | libraryTarget: 'commonjs2', 49 | path: path.join(__dirname, '../dist/electron') 50 | }, 51 | plugins: [ 52 | new webpack.NoEmitOnErrorsPlugin() 53 | ], 54 | resolve: { 55 | extensions: ['.js', '.json', '.node'] 56 | }, 57 | target: 'electron-main' 58 | } 59 | 60 | /** 61 | * Adjust mainConfig for development settings 62 | */ 63 | if (process.env.NODE_ENV !== 'production') { 64 | mainConfig.plugins.push( 65 | new webpack.DefinePlugin({ 66 | '__static': `"${path.join(__dirname, '../static').replace(/\\/g, '\\\\')}"` 67 | }) 68 | ) 69 | } 70 | 71 | /** 72 | * Adjust mainConfig for production settings 73 | */ 74 | if (process.env.NODE_ENV === 'production') { 75 | mainConfig.plugins.push( 76 | new BabiliWebpackPlugin(), 77 | new webpack.DefinePlugin({ 78 | 'process.env.NODE_ENV': '"production"' 79 | }) 80 | ) 81 | } 82 | 83 | module.exports = mainConfig 84 | -------------------------------------------------------------------------------- /.electron-vue/webpack.renderer.config.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | process.env.BABEL_ENV = 'renderer' 4 | 5 | const path = require('path') 6 | const { dependencies } = require('../package.json') 7 | const webpack = require('webpack') 8 | 9 | const BabiliWebpackPlugin = require('babili-webpack-plugin') 10 | const CopyWebpackPlugin = require('copy-webpack-plugin') 11 | const ExtractTextPlugin = require('extract-text-webpack-plugin') 12 | const HtmlWebpackPlugin = require('html-webpack-plugin') 13 | const del = require('del') 14 | 15 | // remove all static/temp_image images 16 | del.sync(['static/temp_image/*', '!static/temp_image/.placeholder']) 17 | 18 | /** 19 | * List of node_modules to include in webpack bundle 20 | * 21 | * Required for specific packages like Vue UI libraries 22 | * that provide pure *.vue files that need compiling 23 | * https://simulatedgreg.gitbooks.io/electron-vue/content/en/webpack-configurations.html#white-listing-externals 24 | */ 25 | let whiteListedModules = ['vue'] 26 | 27 | let rendererConfig = { 28 | devtool: '#cheap-module-eval-source-map', 29 | entry: { 30 | renderer: path.join(__dirname, '../src/renderer/main.js') 31 | }, 32 | externals: [ 33 | ...Object.keys(dependencies || {}).filter(d => !whiteListedModules.includes(d)) 34 | ], 35 | module: { 36 | rules: [ 37 | { 38 | test: /\.(js|vue)$/, 39 | enforce: 'pre', 40 | exclude: /node_modules/, 41 | use: { 42 | loader: 'eslint-loader', 43 | options: { 44 | formatter: require('eslint-friendly-formatter') 45 | } 46 | } 47 | }, 48 | { 49 | test: /\.scss$/, 50 | use: ExtractTextPlugin.extract({ 51 | fallback: 'style-loader', 52 | use: 'css-loader!sass-loader' 53 | }) 54 | }, 55 | { 56 | test: /\.html$/, 57 | use: 'vue-html-loader' 58 | }, 59 | { 60 | test: /\.js$/, 61 | use: 'babel-loader', 62 | exclude: /node_modules/ 63 | }, 64 | { 65 | test: /\.node$/, 66 | use: 'node-loader' 67 | }, 68 | { 69 | test: /\.vue$/, 70 | use: { 71 | loader: 'vue-loader', 72 | options: { 73 | extractCSS: process.env.NODE_ENV === 'production', 74 | loaders: { 75 | sass: 'vue-style-loader!css-loader!sass-loader?indentedSyntax=1', 76 | scss: 'vue-style-loader!css-loader!sass-loader' 77 | } 78 | } 79 | } 80 | }, 81 | { 82 | test: /\.(png|jpe?g|gif|svg)(\?.*)?$/, 83 | use: { 84 | loader: 'url-loader', 85 | query: { 86 | limit: 10000, 87 | name: 'imgs/[name]--[folder].[ext]' 88 | } 89 | } 90 | }, 91 | { 92 | test: /\.(mp4|webm|ogg|mp3|wav|flac|aac)(\?.*)?$/, 93 | loader: 'url-loader', 94 | options: { 95 | limit: 10000, 96 | name: 'media/[name]--[folder].[ext]' 97 | } 98 | }, 99 | { 100 | test: /\.(woff2?|eot|ttf|otf)(\?.*)?$/, 101 | use: { 102 | loader: 'url-loader', 103 | query: { 104 | limit: 10000, 105 | name: 'fonts/[name]--[folder].[ext]' 106 | } 107 | } 108 | } 109 | ] 110 | }, 111 | node: { 112 | __dirname: process.env.NODE_ENV !== 'production', 113 | __filename: process.env.NODE_ENV !== 'production' 114 | }, 115 | plugins: [ 116 | new ExtractTextPlugin('styles.css'), 117 | new HtmlWebpackPlugin({ 118 | filename: 'index.html', 119 | template: path.resolve(__dirname, '../src/index.ejs'), 120 | minify: { 121 | collapseWhitespace: true, 122 | removeAttributeQuotes: true, 123 | removeComments: true 124 | }, 125 | nodeModules: process.env.NODE_ENV !== 'production' 126 | ? path.resolve(__dirname, '../node_modules') 127 | : false 128 | }), 129 | new webpack.HotModuleReplacementPlugin(), 130 | new webpack.NoEmitOnErrorsPlugin() 131 | ], 132 | output: { 133 | filename: '[name].js', 134 | libraryTarget: 'commonjs2', 135 | path: path.join(__dirname, '../dist/electron') 136 | }, 137 | resolve: { 138 | alias: { 139 | '@': path.join(__dirname, '../src/renderer'), 140 | 'vue$': 'vue/dist/vue.esm.js' 141 | }, 142 | extensions: ['.js', '.vue', '.json', '.css', '.node'] 143 | }, 144 | target: 'electron-renderer' 145 | } 146 | 147 | /** 148 | * Adjust rendererConfig for development settings 149 | */ 150 | if (process.env.NODE_ENV !== 'production') { 151 | rendererConfig.plugins.push( 152 | new webpack.DefinePlugin({ 153 | '__static': `"${path.join(__dirname, '../static').replace(/\\/g, '\\\\')}"` 154 | }) 155 | ) 156 | } 157 | 158 | /** 159 | * Adjust rendererConfig for production settings 160 | */ 161 | if (process.env.NODE_ENV === 'production') { 162 | rendererConfig.devtool = '' 163 | 164 | rendererConfig.plugins.push( 165 | new BabiliWebpackPlugin(), 166 | new CopyWebpackPlugin([ 167 | { 168 | from: path.join(__dirname, '../static'), 169 | to: path.join(__dirname, '../dist/electron/static') 170 | } 171 | ]), 172 | new webpack.DefinePlugin({ 173 | 'process.env.NODE_ENV': '"production"' 174 | }), 175 | new webpack.LoaderOptionsPlugin({ 176 | minimize: true 177 | }) 178 | ) 179 | } 180 | 181 | module.exports = rendererConfig 182 | -------------------------------------------------------------------------------- /.electron-vue/webpack.web.config.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | process.env.BABEL_ENV = 'web' 4 | 5 | const path = require('path') 6 | const webpack = require('webpack') 7 | 8 | const BabiliWebpackPlugin = require('babili-webpack-plugin') 9 | const CopyWebpackPlugin = require('copy-webpack-plugin') 10 | const ExtractTextPlugin = require('extract-text-webpack-plugin') 11 | const HtmlWebpackPlugin = require('html-webpack-plugin') 12 | 13 | let webConfig = { 14 | devtool: '#cheap-module-eval-source-map', 15 | entry: { 16 | web: path.join(__dirname, '../src/renderer/main.js') 17 | }, 18 | module: { 19 | rules: [ 20 | { 21 | test: /\.(js|vue)$/, 22 | enforce: 'pre', 23 | exclude: /node_modules/, 24 | use: { 25 | loader: 'eslint-loader', 26 | options: { 27 | formatter: require('eslint-friendly-formatter') 28 | } 29 | } 30 | }, 31 | { 32 | test: /\.css$/, 33 | use: ExtractTextPlugin.extract({ 34 | fallback: 'style-loader', 35 | use: 'css-loader' 36 | }) 37 | }, 38 | { 39 | test: /\.html$/, 40 | use: 'vue-html-loader' 41 | }, 42 | { 43 | test: /\.js$/, 44 | use: 'babel-loader', 45 | include: [ path.resolve(__dirname, '../src/renderer') ], 46 | exclude: /node_modules/ 47 | }, 48 | { 49 | test: /\.vue$/, 50 | use: { 51 | loader: 'vue-loader', 52 | options: { 53 | extractCSS: true, 54 | loaders: { 55 | sass: 'vue-style-loader!css-loader!sass-loader?indentedSyntax=1', 56 | scss: 'vue-style-loader!css-loader!sass-loader' 57 | } 58 | } 59 | } 60 | }, 61 | { 62 | test: /\.(png|jpe?g|gif|svg)(\?.*)?$/, 63 | use: { 64 | loader: 'url-loader', 65 | query: { 66 | limit: 10000, 67 | name: 'imgs/[name].[ext]' 68 | } 69 | } 70 | }, 71 | { 72 | test: /\.(woff2?|eot|ttf|otf)(\?.*)?$/, 73 | use: { 74 | loader: 'url-loader', 75 | query: { 76 | limit: 10000, 77 | name: 'fonts/[name].[ext]' 78 | } 79 | } 80 | } 81 | ] 82 | }, 83 | plugins: [ 84 | new ExtractTextPlugin('styles.css'), 85 | new HtmlWebpackPlugin({ 86 | filename: 'index.html', 87 | template: path.resolve(__dirname, '../src/index.ejs'), 88 | minify: { 89 | collapseWhitespace: true, 90 | removeAttributeQuotes: true, 91 | removeComments: true 92 | }, 93 | nodeModules: false 94 | }), 95 | new webpack.DefinePlugin({ 96 | 'process.env.IS_WEB': 'true' 97 | }), 98 | new webpack.HotModuleReplacementPlugin(), 99 | new webpack.NoEmitOnErrorsPlugin() 100 | ], 101 | output: { 102 | filename: '[name].js', 103 | path: path.join(__dirname, '../dist/web') 104 | }, 105 | resolve: { 106 | alias: { 107 | '@': path.join(__dirname, '../src/renderer'), 108 | 'vue$': 'vue/dist/vue.esm.js' 109 | }, 110 | extensions: ['.js', '.vue', '.json', '.css'] 111 | }, 112 | target: 'web' 113 | } 114 | 115 | /** 116 | * Adjust webConfig for production settings 117 | */ 118 | if (process.env.NODE_ENV === 'production') { 119 | webConfig.devtool = '' 120 | 121 | webConfig.plugins.push( 122 | new BabiliWebpackPlugin(), 123 | new CopyWebpackPlugin([ 124 | { 125 | from: path.join(__dirname, '../static'), 126 | to: path.join(__dirname, '../dist/web/static'), 127 | ignore: ['.*'] 128 | } 129 | ]), 130 | new webpack.DefinePlugin({ 131 | 'process.env.NODE_ENV': '"production"' 132 | }), 133 | new webpack.LoaderOptionsPlugin({ 134 | minimize: true 135 | }) 136 | ) 137 | } 138 | 139 | module.exports = webConfig 140 | -------------------------------------------------------------------------------- /.eslintignore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ywwhack/aidou-electron/d9270401082e43ec7850dd2df62cca8e1e106f69/.eslintignore -------------------------------------------------------------------------------- /.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | root: true, 3 | parser: 'babel-eslint', 4 | parserOptions: { 5 | sourceType: 'module' 6 | }, 7 | env: { 8 | browser: true, 9 | node: true 10 | }, 11 | extends: 'standard', 12 | globals: { 13 | __static: true 14 | }, 15 | plugins: [ 16 | 'html' 17 | ], 18 | 'rules': { 19 | // allow paren-less arrow functions 20 | 'arrow-parens': 0, 21 | // allow async-await 22 | 'generator-star-spacing': 0, 23 | // allow debugger during development 24 | 'no-debugger': process.env.NODE_ENV === 'production' ? 2 : 0, 25 | // allow variable not used, but gives a warning 26 | 'no-unused-vars': process.env.NODE_ENV === 'production' ? 2 : 1, 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | dist/electron/* 3 | dist/web/* 4 | build/* 5 | !build/icons 6 | node_modules/ 7 | npm-debug.log 8 | npm-debug.log.* 9 | thumbs.db 10 | !.gitkeep 11 | static/temp_image/* 12 | !static/temp_image/.placeholder 13 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | osx_image: xcode8.3 2 | sudo: required 3 | dist: trusty 4 | language: c 5 | matrix: 6 | include: 7 | - os: osx 8 | - os: linux 9 | env: CC=clang CXX=clang++ npm_config_clang=1 10 | compiler: clang 11 | cache: 12 | directories: 13 | - node_modules 14 | - "$HOME/.electron" 15 | - "$HOME/.cache" 16 | addons: 17 | apt: 18 | packages: 19 | - libgnome-keyring-dev 20 | - icnsutils 21 | before_install: 22 | - mkdir -p /tmp/git-lfs && curl -L https://github.com/github/git-lfs/releases/download/v1.2.1/git-lfs-$([ 23 | "$TRAVIS_OS_NAME" == "linux" ] && echo "linux" || echo "darwin")-amd64-1.2.1.tar.gz 24 | | tar -xz -C /tmp/git-lfs --strip-components 1 && /tmp/git-lfs/git-lfs pull 25 | - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo apt-get install --no-install-recommends -y icnsutils graphicsmagick xz-utils; fi 26 | install: 27 | - nvm install 7 28 | - curl -o- -L https://yarnpkg.com/install.sh | bash 29 | - source ~/.bashrc 30 | - npm install -g xvfb-maybe 31 | - yarn 32 | script: 33 | - yarn run build 34 | branches: 35 | only: 36 | - master 37 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | > aidou - 斗图从未如此简单~ 2 | 3 | 在这个斗图的时代,没有几个表情怕是聊不了天了。为了防止「图穷」的尴尬处境,做了一个表情搜索 app 4 | 5 | ![](summary.gif) 6 | 7 | #### 用法 8 | 1. 根据关键字搜索表情 9 | 2. 鼠标点击表情一键复制到系统粘贴板 10 | 3. 微信/github/etc 都可直接粘贴使用 11 | 12 | #### 下载 & 安装 13 | 14 | 目前仅支持 mac 版本 [下载](https://github.com/ywwhack/aidou-electron/releases) 15 | 16 | chrome 插件版本 [aidou](https://github.com/kinglisky/aidou) 17 | -------------------------------------------------------------------------------- /appveyor.yml: -------------------------------------------------------------------------------- 1 | version: 0.1.{build} 2 | 3 | branches: 4 | only: 5 | - master 6 | 7 | image: Visual Studio 2017 8 | platform: 9 | - x64 10 | 11 | cache: 12 | - node_modules 13 | - '%APPDATA%\npm-cache' 14 | - '%USERPROFILE%\.electron' 15 | - '%USERPROFILE%\AppData\Local\Yarn\cache' 16 | 17 | init: 18 | - git config --global core.autocrlf input 19 | 20 | install: 21 | - ps: Install-Product node 8 x64 22 | - choco install yarn --ignore-dependencies 23 | - git reset --hard HEAD 24 | - yarn 25 | - node --version 26 | 27 | build_script: 28 | - yarn build 29 | 30 | test: off 31 | -------------------------------------------------------------------------------- /build/icons/256x256.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ywwhack/aidou-electron/d9270401082e43ec7850dd2df62cca8e1e106f69/build/icons/256x256.png -------------------------------------------------------------------------------- /build/icons/icon.icns: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ywwhack/aidou-electron/d9270401082e43ec7850dd2df62cca8e1e106f69/build/icons/icon.icns -------------------------------------------------------------------------------- /build/icons/icon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ywwhack/aidou-electron/d9270401082e43ec7850dd2df62cca8e1e106f69/build/icons/icon.ico -------------------------------------------------------------------------------- /dist/electron/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ywwhack/aidou-electron/d9270401082e43ec7850dd2df62cca8e1e106f69/dist/electron/.gitkeep -------------------------------------------------------------------------------- /dist/web/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ywwhack/aidou-electron/d9270401082e43ec7850dd2df62cca8e1e106f69/dist/web/.gitkeep -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "aidou-electron", 3 | "productName": "aidou", 4 | "version": "0.0.1", 5 | "author": "ywwhack ", 6 | "description": "aidou electron project", 7 | "license": "", 8 | "main": "./dist/electron/main.js", 9 | "scripts": { 10 | "build": "node .electron-vue/build.js", 11 | "build:darwin": "cross-env BUILD_TARGET=darwin node .electron-vue/build.js", 12 | "build:dmg": "npm run build:darwin && electron-installer-dmg --overwrite build/aidou-darwin-x64/aidou.app build/aidou", 13 | "build:mas": "cross-env BUILD_TARGET=mas node .electron-vue/build.js", 14 | "build:linux": "cross-env BUILD_TARGET=linux node .electron-vue/build.js", 15 | "build:win32": "cross-env BUILD_TARGET=win32 node .electron-vue/build.js", 16 | "build:clean": "cross-env BUILD_TARGET=clean node .electron-vue/build.js", 17 | "build:web": "cross-env BUILD_TARGET=web node .electron-vue/build.js", 18 | "dev": "node .electron-vue/dev-runner.js", 19 | "lint": "eslint --ext .js,.vue -f ./node_modules/eslint-friendly-formatter src", 20 | "lint:fix": "eslint --ext .js,.vue -f ./node_modules/eslint-friendly-formatter --fix src", 21 | "pack": "npm run pack:main && npm run pack:renderer", 22 | "pack:main": "cross-env NODE_ENV=production webpack --progress --colors --config .electron-vue/webpack.main.config.js", 23 | "pack:renderer": "cross-env NODE_ENV=production webpack --progress --colors --config .electron-vue/webpack.renderer.config.js", 24 | "postinstall": "npm run lint:fix" 25 | }, 26 | "dependencies": { 27 | "axios": "^0.16.1", 28 | "is-gif": "^2.0.0", 29 | "nodobjc": "^2.1.0", 30 | "sweetalert": "^2.1.0", 31 | "vue": "^2.3.3", 32 | "vue-electron": "^1.0.6", 33 | "vue-router": "^3.0.1" 34 | }, 35 | "devDependencies": { 36 | "babel-core": "^6.25.0", 37 | "babel-eslint": "^7.2.3", 38 | "babel-loader": "^7.1.1", 39 | "babel-plugin-transform-runtime": "^6.23.0", 40 | "babel-preset-env": "^1.6.0", 41 | "babel-preset-stage-0": "^6.24.1", 42 | "babel-register": "^6.24.1", 43 | "babili-webpack-plugin": "^0.1.2", 44 | "cfonts": "^1.1.3", 45 | "chalk": "^2.1.0", 46 | "copy-webpack-plugin": "^4.0.1", 47 | "cross-env": "^5.0.5", 48 | "css-loader": "^0.28.4", 49 | "del": "^3.0.0", 50 | "devtron": "^1.4.0", 51 | "electron": "^1.7.5", 52 | "electron-debug": "^1.4.0", 53 | "electron-devtools-installer": "^2.2.0", 54 | "electron-installer-dmg": "^0.2.1", 55 | "electron-packager": "^8.5.0", 56 | "electron-rebuild": "^1.1.3", 57 | "eslint": "^4.4.1", 58 | "eslint-config-standard": "^10.2.1", 59 | "eslint-friendly-formatter": "^3.0.0", 60 | "eslint-loader": "^1.9.0", 61 | "eslint-plugin-html": "^3.1.1", 62 | "eslint-plugin-import": "^2.7.0", 63 | "eslint-plugin-node": "^5.1.1", 64 | "eslint-plugin-promise": "^3.5.0", 65 | "eslint-plugin-standard": "^3.0.1", 66 | "extract-text-webpack-plugin": "^3.0.0", 67 | "file-loader": "^0.11.2", 68 | "html-webpack-plugin": "^2.30.1", 69 | "multispinner": "^0.2.1", 70 | "node-loader": "^0.6.0", 71 | "node-sass": "^4.7.2", 72 | "sass-loader": "^6.0.6", 73 | "style-loader": "^0.18.2", 74 | "url-loader": "^0.5.9", 75 | "vue-html-loader": "^1.2.4", 76 | "vue-loader": "^13.0.5", 77 | "vue-style-loader": "^3.0.1", 78 | "vue-template-compiler": "^2.4.2", 79 | "webpack": "^3.5.2", 80 | "webpack-dev-server": "^2.7.1", 81 | "webpack-hot-middleware": "^2.18.2" 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /src/index.ejs: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | aidou 6 | <% if (htmlWebpackPlugin.options.nodeModules) { %> 7 | 8 | 11 | <% } %> 12 | 13 | 14 |
15 | 16 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /src/main/index.dev.js: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is used specifically and only for development. It installs 3 | * `electron-debug` & `vue-devtools`. There shouldn't be any need to 4 | * modify this file, but it can be used to extend your development 5 | * environment. 6 | */ 7 | 8 | /* eslint-disable */ 9 | 10 | // Set environment for development 11 | process.env.NODE_ENV = 'development' 12 | 13 | // Install `electron-debug` with `devtron` 14 | require('electron-debug')() 15 | 16 | // Install `vue-devtools` 17 | require('electron').app.on('ready', () => { 18 | let installExtension = require('electron-devtools-installer') 19 | installExtension.default(installExtension.VUEJS_DEVTOOLS) 20 | .then(() => {}) 21 | .catch(err => { 22 | console.log('Unable to install `vue-devtools`: \n', err) 23 | }) 24 | }) 25 | 26 | // Require `main` process to boot app 27 | require('./index') 28 | -------------------------------------------------------------------------------- /src/main/index.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | import { app, BrowserWindow } from 'electron' 4 | import createMenu from './menu' 5 | 6 | /** 7 | * Set `__static` path to static files in production 8 | * https://simulatedgreg.gitbooks.io/electron-vue/content/en/using-static-assets.html 9 | */ 10 | if (process.env.NODE_ENV !== 'development') { 11 | global.__static = require('path').join(__dirname, '/static').replace(/\\/g, '\\\\') 12 | } 13 | 14 | let mainWindow 15 | let willQuitApp = false 16 | const winURL = process.env.NODE_ENV === 'development' 17 | ? `http://localhost:9080` 18 | : `file://${__dirname}/index.html` 19 | 20 | function createWindow () { 21 | /** 22 | * Initial window options 23 | */ 24 | mainWindow = new BrowserWindow({ 25 | webPreferences: { 26 | webSecurity: false 27 | } 28 | }) 29 | 30 | mainWindow.loadURL(winURL) 31 | 32 | mainWindow.on('close', e => { 33 | if (willQuitApp) { 34 | // user want to quit app 35 | mainWindow = null 36 | } else { 37 | // user just want hide app 38 | e.preventDefault() 39 | mainWindow.hide() 40 | } 41 | }) 42 | } 43 | 44 | app.on('ready', () => { 45 | createWindow() 46 | createMenu(app) 47 | }) 48 | 49 | app.on('before-quit', () => { 50 | willQuitApp = true 51 | }) 52 | 53 | app.on('activate', () => { 54 | if (mainWindow) { 55 | mainWindow.show() 56 | } 57 | }) 58 | -------------------------------------------------------------------------------- /src/main/menu.js: -------------------------------------------------------------------------------- 1 | import { 2 | Menu 3 | } from 'electron' 4 | 5 | export default function createMenu (app) { 6 | const template = [ 7 | { 8 | label: 'View', 9 | submenu: [ 10 | { role: 'reload' }, 11 | { role: 'forcereload' }, 12 | { role: 'toggledevtools' }, 13 | { type: 'separator' }, 14 | { role: 'togglefullscreen' } 15 | ] 16 | }, 17 | { 18 | label: 'Action', 19 | submenu: [ 20 | { role: 'undo' }, 21 | { role: 'redo' }, 22 | { role: 'cut' }, 23 | { role: 'paste' }, 24 | { role: 'selectall' } 25 | ] 26 | }, 27 | { 28 | role: 'window', 29 | submenu: [ 30 | { role: 'minimize' }, 31 | { role: 'close' } 32 | ] 33 | } 34 | ] 35 | 36 | if (process.platform === 'darwin') { 37 | template.unshift({ 38 | label: app.getName(), 39 | submenu: [ 40 | { role: 'about' }, 41 | { type: 'separator' }, 42 | { role: 'hide' }, 43 | { role: 'unhide' }, 44 | { type: 'separator' }, 45 | { role: 'quit' } 46 | ] 47 | }) 48 | } 49 | 50 | const menu = Menu.buildFromTemplate(template) 51 | Menu.setApplicationMenu(menu) 52 | } 53 | -------------------------------------------------------------------------------- /src/renderer/app.vue: -------------------------------------------------------------------------------- 1 | 13 | 14 | 23 | 24 | 50 | -------------------------------------------------------------------------------- /src/renderer/assets/bgm-nodata.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ywwhack/aidou-electron/d9270401082e43ec7850dd2df62cca8e1e106f69/src/renderer/assets/bgm-nodata.png -------------------------------------------------------------------------------- /src/renderer/assets/empty-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ywwhack/aidou-electron/d9270401082e43ec7850dd2df62cca8e1e106f69/src/renderer/assets/empty-icon.png -------------------------------------------------------------------------------- /src/renderer/assets/no-data.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ywwhack/aidou-electron/d9270401082e43ec7850dd2df62cca8e1e106f69/src/renderer/assets/no-data.png -------------------------------------------------------------------------------- /src/renderer/assets/no_more.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ywwhack/aidou-electron/d9270401082e43ec7850dd2df62cca8e1e106f69/src/renderer/assets/no_more.png -------------------------------------------------------------------------------- /src/renderer/common/copyGif.js: -------------------------------------------------------------------------------- 1 | import $ from 'nodobjc' 2 | import path from 'path' 3 | import { 4 | IMAGE_SAVE_DIR 5 | } from '@/constants' 6 | 7 | $.framework('Foundation') 8 | $.framework('AppKit') 9 | 10 | export default function copyGif (filename) { 11 | const pool = $.NSAutoreleasePool('alloc')('init') 12 | 13 | const $pasteboard = $.NSPasteboard('generalPasteboard') 14 | $pasteboard('clearContents') 15 | const $url = $.NSURL('alloc')('initFileURLWithPath', $.NSString('stringWithUTF8String', path.resolve(IMAGE_SAVE_DIR, filename))) 16 | const $filesToCopy = $.NSMutableArray('alloc')('init') 17 | $filesToCopy('addObject', $url) 18 | $pasteboard('writeObjects', $filesToCopy) 19 | 20 | pool('drain') 21 | } 22 | -------------------------------------------------------------------------------- /src/renderer/common/hotWords.js: -------------------------------------------------------------------------------- 1 | export default [ 2 | 'bug', 3 | '代码有毒', 4 | '大佬', 5 | 'hentai', 6 | '变态', 7 | '40米', 8 | '哈哈', 9 | '嘿嘿', 10 | '滑稽', 11 | '原谅', 12 | '喜欢', 13 | '秋裤', 14 | '盒子精', 15 | '吃鸡', 16 | '阿卡林', 17 | '元旦快乐', 18 | '新年快乐', 19 | '康娜', 20 | '赞', 21 | '2b', 22 | '正面上我', 23 | 'bilibili', 24 | '胖次', 25 | '飞机', 26 | '哲学', 27 | '鸡鸡', 28 | '2233', 29 | '233', 30 | '蕾姆', 31 | '拉姆', 32 | 'niconiconi', 33 | '图样图森破', 34 | '非战斗人员', 35 | '天依', 36 | '绅士', 37 | '今天的风儿', 38 | '战5渣', 39 | '楼上', 40 | '楼下', 41 | '女装', 42 | '吸猫', 43 | '二次元', 44 | '新吧唧', 45 | 'poi', 46 | '提督', 47 | '咸鱼', 48 | '滴滴', 49 | '老司机', 50 | '香菜', 51 | '金馆长', 52 | '笑', 53 | '机智', 54 | '撩', 55 | '套路', 56 | '洪荒之力', 57 | '傲娇', 58 | '一言不合', 59 | '百合', 60 | '白学家', 61 | '电学', 62 | '白色相册', 63 | '诚哥', 64 | '本子', 65 | '香蕉君', 66 | '金坷垃', 67 | '舰娘', 68 | '圣杯', 69 | '呆毛', 70 | '咖喱棒', 71 | '金闪闪', 72 | '吃土', 73 | '小目标', 74 | 'FFF团', 75 | '友谊的小船', 76 | '狗带', 77 | '没想到你是这样的', 78 | '懵逼', 79 | '我好方', 80 | '辣眼睛', 81 | '猴赛雷', 82 | '吓死宝宝了', 83 | '宝宝', 84 | '咋不上天', 85 | '重要的事', 86 | '城会玩', 87 | 'A4腰', 88 | '城会玩', 89 | '厉害了我的哥', 90 | '感觉身体被掏空', 91 | '互相伤害', 92 | '北京瘫', 93 | '葛优躺', 94 | '一颗赛艇', 95 | '因吹斯汀', 96 | '醒醒', 97 | '社会我', 98 | '萝莉', 99 | '御姐', 100 | '正太', 101 | 'Loli', 102 | '单身狗', 103 | '逗比', 104 | '坟头草', 105 | '你开心', 106 | '裤子都脱了', 107 | '算我输', 108 | '修仙', 109 | '老哥稳', 110 | '奶子', 111 | '小姐姐', 112 | '石乐志', 113 | '皮皮虾我们走', 114 | '我们走', 115 | '小拳拳', 116 | '把我的意大利' 117 | ] 118 | -------------------------------------------------------------------------------- /src/renderer/common/imageManager.js: -------------------------------------------------------------------------------- 1 | import axios from 'axios' 2 | import fs from 'fs' 3 | import path from 'path' 4 | import { 5 | promisify 6 | } from 'util' 7 | import { 8 | IMAGE_SAVE_DIR 9 | } from '@/constants' 10 | import copyGif from '@/common/copyGif' 11 | import isGif from 'is-gif' 12 | import { 13 | clipboard, 14 | nativeImage 15 | } from 'electron' 16 | 17 | class ImageManger { 18 | constructor (url) { 19 | this.url = url 20 | this.imageData = axios.get(url, { responseType: 'blob' }) 21 | } 22 | 23 | async copy () { 24 | let filename = this.url.split('/').pop() 25 | // 如果没有后缀,给一个默认的 .jpg 26 | if (!filename.includes('.')) { 27 | filename += '.jpg' 28 | } 29 | 30 | try { 31 | const { data } = await this.imageData 32 | const reader = new FileReader() 33 | reader.readAsArrayBuffer(data) 34 | // 先将文件下载到本地 35 | const buffer = await new Promise(resolve => { 36 | reader.onloadend = () => { 37 | const buffer = Buffer.from(reader.result) 38 | const filePath = path.resolve(IMAGE_SAVE_DIR, filename) 39 | promisify(fs.writeFile)(filePath, buffer) 40 | resolve(buffer) 41 | } 42 | }) 43 | // 拷贝到剪切板 44 | if (isGif(buffer)) { 45 | copyGif(filename) 46 | } else { 47 | clipboard.writeImage(nativeImage.createFromBuffer(buffer)) 48 | } 49 | } catch (e) { 50 | console.error(e) 51 | // todo: error handler 52 | } 53 | } 54 | 55 | async toBase64 () { 56 | try { 57 | const { data } = await this.imageData 58 | const reader = new FileReader() 59 | reader.readAsDataURL(data) 60 | return new Promise(resolve => { 61 | reader.onloadend = () => resolve(reader.result) 62 | }) 63 | } catch (e) { 64 | console.error(e) 65 | // todo: error handler 66 | } 67 | } 68 | } 69 | 70 | export default ImageManger 71 | -------------------------------------------------------------------------------- /src/renderer/common/imgProcess.js: -------------------------------------------------------------------------------- 1 | import axios from 'axios' 2 | 3 | export function fetchImgToBase64 (url) { 4 | return axios.get(url, { responseType: 'blob' }) 5 | .then(({ data }) => new Promise((resolve, reject) => { 6 | const reader = new window.FileReader() 7 | reader.onloadend = () => resolve(reader.result) 8 | reader.onerror = reject 9 | reader.readAsDataURL(data) 10 | })) 11 | } 12 | 13 | // 搜狐表情返回的图片资源是不带 content-type 所以不能直接往 github 上贴链接(链接无效) 14 | // 这里将图片转成 base64 时为图片加上正确的 type 15 | export function standardizeBase64 (base64, type) { 16 | return base64.replace(/^data:.*;/, `data:image/${type};`) 17 | } 18 | 19 | export function removeBase64Head (base64) { 20 | return base64.replace(/^data:.*base64,/, '') 21 | } 22 | 23 | export function dataURItoBlob (dataURI) { 24 | const data = dataURI.split(';base64,') 25 | const byte = window.atob(data[1]) 26 | const mime = data[0].split(':')[1] 27 | const ab = new ArrayBuffer(byte.length) 28 | const ia = new Uint8Array(ab) 29 | for (let i = 0; i < byte.length; i++) { 30 | ia[i] = byte.charCodeAt(i) 31 | } 32 | return new window.Blob([ab], { type: mime }) 33 | } 34 | -------------------------------------------------------------------------------- /src/renderer/common/storage.js: -------------------------------------------------------------------------------- 1 | export default { 2 | get (key) { 3 | try { 4 | return JSON.parse(localStorage.getItem(key)) 5 | } catch (e) {} 6 | }, 7 | 8 | set (key, value) { 9 | try { 10 | localStorage.setItem(key, JSON.stringify(value)) 11 | return true 12 | } catch (e) { 13 | return false 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/renderer/components/Empty.vue: -------------------------------------------------------------------------------- 1 | 7 | 8 | 15 | 16 | 32 | -------------------------------------------------------------------------------- /src/renderer/components/app-header.vue: -------------------------------------------------------------------------------- 1 | 24 | 25 | 138 | 139 | 268 | -------------------------------------------------------------------------------- /src/renderer/components/expression-item.vue: -------------------------------------------------------------------------------- 1 | 12 | 13 | 150 | 151 | 197 | -------------------------------------------------------------------------------- /src/renderer/components/expression-list.vue: -------------------------------------------------------------------------------- 1 | 18 | 19 | 96 | 97 | 133 | -------------------------------------------------------------------------------- /src/renderer/components/expression-types.vue: -------------------------------------------------------------------------------- 1 | 11 | 12 | 42 | 43 | 65 | -------------------------------------------------------------------------------- /src/renderer/components/loading.vue: -------------------------------------------------------------------------------- 1 | 8 | 9 | 29 | 30 | 96 | -------------------------------------------------------------------------------- /src/renderer/components/showLinks.js: -------------------------------------------------------------------------------- 1 | import Vue from 'vue' 2 | import main from './links-panel' 3 | 4 | const Ctor = Vue.extend(main) 5 | 6 | let ins = null 7 | 8 | export default function showLinks (url) { 9 | if (!ins) { 10 | ins = new Ctor({ propsData: { url } }).$mount() 11 | } else { 12 | ins.url = url 13 | } 14 | return ins.$el 15 | } 16 | -------------------------------------------------------------------------------- /src/renderer/constants.js: -------------------------------------------------------------------------------- 1 | const path = require('path') 2 | 3 | // 表情存放的本地目录 4 | export const IMAGE_SAVE_DIR = path.resolve(__static, 'temp_image') 5 | 6 | // 表情类型 - 表情 | 表情包 7 | export const EXPRESSION_TYPE_MAP = { 8 | expression: '表情', 9 | package: '表情包' 10 | } 11 | -------------------------------------------------------------------------------- /src/renderer/main.js: -------------------------------------------------------------------------------- 1 | import Vue from 'vue' 2 | import swal from 'sweetalert' 3 | import App from './app' 4 | import './styles/index.scss' 5 | import store from './store' 6 | import router from './router' 7 | 8 | // add default timer(1s) to sweetalert 9 | Vue.prototype.$swal = function (options) { 10 | if (options.timer === undefined) { 11 | options.timer = 1000 12 | } 13 | swal(options) 14 | } 15 | Vue.prototype.$store = store 16 | if (!process.env.IS_WEB) Vue.use(require('vue-electron')) 17 | 18 | Vue.config.productionTip = false 19 | 20 | /* eslint-disable no-new */ 21 | new Vue({ 22 | el: '#app', 23 | router, 24 | render: h => h(App) 25 | }) 26 | -------------------------------------------------------------------------------- /src/renderer/pages/collect-panel.vue: -------------------------------------------------------------------------------- 1 | 8 | 9 | 28 | -------------------------------------------------------------------------------- /src/renderer/pages/search-panel/expression.vue: -------------------------------------------------------------------------------- 1 | 9 | 10 | 75 | -------------------------------------------------------------------------------- /src/renderer/pages/search-panel/index.vue: -------------------------------------------------------------------------------- 1 | 14 | 15 | 57 | 58 | 84 | -------------------------------------------------------------------------------- /src/renderer/pages/search-panel/package/index.vue: -------------------------------------------------------------------------------- 1 | 4 | -------------------------------------------------------------------------------- /src/renderer/pages/search-panel/package/package-detail.vue: -------------------------------------------------------------------------------- 1 | 8 | 9 | 51 | -------------------------------------------------------------------------------- /src/renderer/pages/search-panel/package/package-list.vue: -------------------------------------------------------------------------------- 1 | 24 | 25 | 85 | 86 | 139 | -------------------------------------------------------------------------------- /src/renderer/router.js: -------------------------------------------------------------------------------- 1 | import Vue from 'vue' 2 | import VueRouter from 'vue-router' 3 | import CollectPanel from '@/pages/collect-panel' 4 | import SearchPanel from '@/pages/search-panel' 5 | import Expression from '@/pages/search-panel/expression' 6 | 7 | // package pages 8 | import Package from '@/pages/search-panel/package' 9 | import PackageList from '@/pages/search-panel/package/package-list' 10 | import PackageDetail from '@/pages/search-panel/package/package-detail' 11 | 12 | Vue.use(VueRouter) 13 | 14 | const router = new VueRouter({ 15 | routes: [ 16 | { path: '/', redirect: '/search-panel' }, 17 | { 18 | path: '/search-panel', 19 | component: SearchPanel, 20 | children: [ 21 | { path: '', component: Expression }, 22 | { path: 'expression', name: 'expression', component: Expression }, 23 | { 24 | path: 'package', 25 | component: Package, 26 | children: [ 27 | { path: '', name: 'package', component: PackageList }, 28 | { path: 'list', name: 'package-list', component: PackageList }, 29 | { path: 'detail', name: 'package-detail', component: PackageDetail } 30 | ] 31 | } 32 | ] 33 | }, 34 | { path: '/collect-panel', component: CollectPanel } 35 | ] 36 | }) 37 | 38 | export default router 39 | -------------------------------------------------------------------------------- /src/renderer/service/expPackage.js: -------------------------------------------------------------------------------- 1 | /** 2 | * 表情包搜索服务 3 | * 搜狗上并没有提供相关 api,但是前端可以模仿「爬虫」的方式获取 4 | */ 5 | import axios from 'axios' 6 | 7 | export function searchPackages (keyword) { 8 | return axios.get('https://pic.sogou.com/pic/emo/searchList.jsp', { 9 | params: { keyword }, 10 | responseType: 'document' 11 | }).then(response => { 12 | const doc = response.data 13 | const expContainerNodes = doc.querySelectorAll('.recall-module') 14 | return Array.from(expContainerNodes).map(container => { 15 | const linkNode = container.querySelector('.emo-tit-recall') 16 | const link = linkNode.href 17 | // match package id from link 18 | const id = /id=([^&]*)/.exec(link)[1] 19 | const title = linkNode.innerText 20 | // 获取表情包数量 21 | const countNode = container.querySelector('.more-emo') 22 | const count = countNode.innerText.slice(0, -1) 23 | // 取表情包的第一张图片作为预览 24 | const preview = container.querySelector('img[rsrc]').getAttribute('rsrc') 25 | return { 26 | id, 27 | title, 28 | count, 29 | preview 30 | } 31 | }) 32 | }) 33 | } 34 | 35 | export function getPackage (id) { 36 | return axios.get('http://pic.sogou.com/pic/emo/groupDetail.jsp', { 37 | params: { id, from: 'emo_search_gname' }, 38 | responseType: 'document' 39 | }).then(response => { 40 | const doc = response.data 41 | const container = doc.getElementById('groupEmojiListUl') 42 | const expNodes = container.querySelectorAll('img[rsrc]') 43 | return Array.from(expNodes).map(node => node.getAttribute('rsrc')) 44 | }) 45 | } 46 | -------------------------------------------------------------------------------- /src/renderer/service/picBed.js: -------------------------------------------------------------------------------- 1 | import axios from 'axios' 2 | import { 3 | dataURItoBlob, 4 | removeBase64Head 5 | } from '@/common/imgProcess' 6 | 7 | const CONFIG = { 8 | SM: { 9 | API: 'https://sm.ms/api/upload' 10 | }, 11 | WEIBO: { 12 | API: 'http://picupload.service.weibo.com/interface/pic_upload.php?ori=1&mime=image%2Fjpeg&data=base64&url=0&markpos=1&logo=&nick=0&marks=1&app=miniblog' 13 | } 14 | } 15 | 16 | // 👇这些工具函数是微博图床用 17 | const TABLE = '00000000 77073096 EE0E612C 990951BA 076DC419 706AF48F E963A535 9E6495A3 0EDB8832 79DCB8A4 E0D5E91E 97D2D988 09B64C2B 7EB17CBD E7B82D07 90BF1D91 1DB71064 6AB020F2 F3B97148 84BE41DE 1ADAD47D 6DDDE4EB F4D4B551 83D385C7 136C9856 646BA8C0 FD62F97A 8A65C9EC 14015C4F 63066CD9 FA0F3D63 8D080DF5 3B6E20C8 4C69105E D56041E4 A2677172 3C03E4D1 4B04D447 D20D85FD A50AB56B 35B5A8FA 42B2986C DBBBC9D6 ACBCF940 32D86CE3 45DF5C75 DCD60DCF ABD13D59 26D930AC 51DE003A C8D75180 BFD06116 21B4F4B5 56B3C423 CFBA9599 B8BDA50F 2802B89E 5F058808 C60CD9B2 B10BE924 2F6F7C87 58684C11 C1611DAB B6662D3D 76DC4190 01DB7106 98D220BC EFD5102A 71B18589 06B6B51F 9FBFE4A5 E8B8D433 7807C9A2 0F00F934 9609A88E E10E9818 7F6A0DBB 086D3D2D 91646C97 E6635C01 6B6B51F4 1C6C6162 856530D8 F262004E 6C0695ED 1B01A57B 8208F4C1 F50FC457 65B0D9C6 12B7E950 8BBEB8EA FCB9887C 62DD1DDF 15DA2D49 8CD37CF3 FBD44C65 4DB26158 3AB551CE A3BC0074 D4BB30E2 4ADFA541 3DD895D7 A4D1C46D D3D6F4FB 4369E96A 346ED9FC AD678846 DA60B8D0 44042D73 33031DE5 AA0A4C5F DD0D7CC9 5005713C 270241AA BE0B1010 C90C2086 5768B525 206F85B3 B966D409 CE61E49F 5EDEF90E 29D9C998 B0D09822 C7D7A8B4 59B33D17 2EB40D81 B7BD5C3B C0BA6CAD EDB88320 9ABFB3B6 03B6E20C 74B1D29A EAD54739 9DD277AF 04DB2615 73DC1683 E3630B12 94643B84 0D6D6A3E 7A6A5AA8 E40ECF0B 9309FF9D 0A00AE27 7D079EB1 F00F9344 8708A3D2 1E01F268 6906C2FE F762575D 806567CB 196C3671 6E6B06E7 FED41B76 89D32BE0 10DA7A5A 67DD4ACC F9B9DF6F 8EBEEFF9 17B7BE43 60B08ED5 D6D6A3E8 A1D1937E 38D8C2C4 4FDFF252 D1BB67F1 A6BC5767 3FB506DD 48B2364B D80D2BDA AF0A1B4C 36034AF6 41047A60 DF60EFC3 A867DF55 316E8EEF 4669BE79 CB61B38C BC66831A 256FD2A0 5268E236 CC0C7795 BB0B4703 220216B9 5505262F C5BA3BBE B2BD0B28 2BB45A92 5CB36A04 C2D7FFA7 B5D0CF31 2CD99E8B 5BDEAE1D 9B64C2B0 EC63F226 756AA39C 026D930A 9C0906A9 EB0E363F 72076785 05005713 95BF4A82 E2B87A14 7BB12BAE 0CB61B38 92D28E9B E5D5BE0D 7CDCEFB7 0BDBDF21 86D3D2D4 F1D4E242 68DDB3F8 1FDA836E 81BE16CD F6B9265B 6FB077E1 18B74777 88085AE6 FF0F6A70 66063BCA 11010B5C 8F659EFF F862AE69 616BFFD3 166CCF45 A00AE278 D70DD2EE 4E048354 3903B3C2 A7672661 D06016F7 4969474D 3E6E77DB AED16A4A D9D65ADC 40DF0B66 37D83BF0 A9BCAE53 DEBB9EC5 47B2CF7F 30B5FFE9 BDBDF21C CABAC28A 53B39330 24B4A3A6 BAD03605 CDD70693 54DE5729 23D967BF B3667A2E C4614AB8 5D681B02 2A6F2B94 B40BBE37 C30C8EA1 5A05DF1B 2D02EF8D' 18 | 19 | function crc32 (pid) { 20 | let crc = 0 21 | let x = 0 22 | let y = 0 23 | crc = crc ^ (-1) 24 | for (let i = 0; i < pid.length; i++) { 25 | y = (crc ^ pid.charCodeAt(i)) & 0xFF 26 | x = '0x' + TABLE.substr(y * 9, 8) 27 | crc = (crc >>> 8) ^ x 28 | } 29 | return crc ^ (-1) 30 | } 31 | 32 | function pid2url ({ pid, ext }, type = 'large') { 33 | const zone = pid[9] === 'w' 34 | ? (crc32(pid) & 3) + 1 35 | : ((pid.substr(-2, 2), 16) & 0xf) + 1 36 | return `https://ws${zone}.sinaimg.cn/${type}/${pid}${ext}` 37 | } 38 | 39 | function log () { 40 | console.log('emmm... 图传服务好像崩掉了~') 41 | } 42 | 43 | export default { 44 | sm (base64) { 45 | const api = CONFIG.SM.API 46 | const data = new window.FormData() 47 | data.append('smfile', dataURItoBlob(base64, 'temp.png')) 48 | return axios.post(api, data).then(({ data }) => { 49 | const { data: res } = data 50 | return { 51 | url: res.url, 52 | err: '', 53 | server: 'sm' 54 | } 55 | }, log) 56 | }, 57 | 58 | weibo (base64) { 59 | const api = CONFIG.WEIBO.API 60 | const data = new window.FormData() 61 | data.append('b64_data', removeBase64Head(base64)) 62 | return axios.post(api, data).then(({ data }) => { 63 | let url = '' 64 | let err = '' 65 | try { 66 | const res = JSON.parse(data.substring(data.indexOf('{"'))) 67 | const { pid, ret } = res.data.pics.pic_1 || {} 68 | if (ret === 1) { 69 | url = pid2url({ 70 | pid, 71 | ext: '.jpg' 72 | }) 73 | } else { 74 | err = '微博图床需要登录微博' 75 | } 76 | } catch (e) { 77 | url = '' 78 | err = '微博图床发生一些错误' 79 | } 80 | return { 81 | url, 82 | err, 83 | server: 'weibo' 84 | } 85 | }, log) 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /src/renderer/service/queryEngine.js: -------------------------------------------------------------------------------- 1 | import axios from 'axios' 2 | import { 3 | merge, 4 | serialize 5 | } from '@/util/helper' 6 | 7 | const CONFIG = { 8 | SOGOU: { 9 | API: 'https://pic.sogou.com/pics/json.jsp', 10 | PARAMS: { 11 | query: '', 12 | st: 5, 13 | start: 0, 14 | xml_len: 100, 15 | reqFrom: 'wap_result' 16 | }, 17 | HOT_SEARCH: 'https://pic.sogou.com/pic/emo/' 18 | } 19 | } 20 | 21 | function log (e) { 22 | // todo: error handler 23 | } 24 | 25 | export default { 26 | // 搜狗表情服务 27 | sogou ({ query, page, size }) { 28 | const api = CONFIG.SOGOU.API 29 | const defParams = CONFIG.SOGOU.PARAMS 30 | const params = merge(defParams, { 31 | query: `${query}`, 32 | start: (page - 1) * size, 33 | xml_len: size 34 | }) 35 | const queryURL = `${api}?${serialize(params)}` 36 | return axios.get(queryURL).then(({ data = {} }) => { 37 | return { 38 | data: (data.items || []).map(it => ({ 39 | link: it.locImageLink, 40 | suffix: it.type 41 | })), 42 | total: data.totalNum || 0 43 | } 44 | }, log) 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/renderer/store.js: -------------------------------------------------------------------------------- 1 | import Vue from 'vue' 2 | import storage from '@/common/storage' 3 | 4 | // 初始化配置 5 | const collectData = storage.get('collect_data') || {} 6 | 7 | export default new Vue({ 8 | data: { 9 | collectData, 10 | 11 | query: '' 12 | }, 13 | 14 | watch: { 15 | 'collectData': { 16 | immediate: true, 17 | deep: true, 18 | handler (value) { 19 | storage.set('collect_data', value) 20 | } 21 | } 22 | }, 23 | 24 | methods: { 25 | updateQuery (query) { 26 | this.query = query 27 | } 28 | } 29 | }) 30 | -------------------------------------------------------------------------------- /src/renderer/styles/fonts/icomoon.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Generated by IcoMoon 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /src/renderer/styles/fonts/icomoon.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ywwhack/aidou-electron/d9270401082e43ec7850dd2df62cca8e1e106f69/src/renderer/styles/fonts/icomoon.ttf -------------------------------------------------------------------------------- /src/renderer/styles/fonts/icomoon.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ywwhack/aidou-electron/d9270401082e43ec7850dd2df62cca8e1e106f69/src/renderer/styles/fonts/icomoon.woff -------------------------------------------------------------------------------- /src/renderer/styles/global.scss: -------------------------------------------------------------------------------- 1 | * { 2 | box-sizing: border-box; 3 | padding: 0; 4 | margin: 0; 5 | } 6 | 7 | html, 8 | body { 9 | height: 100%; 10 | font-size: 12px; 11 | } 12 | 13 | ul { 14 | list-style: none; 15 | } 16 | 17 | .common-input { 18 | padding: 4px 8px; 19 | border: 1px solid #eee; 20 | border-radius: 4px; 21 | outline: none; 22 | } 23 | 24 | .common-btn { 25 | padding: 4px 8px; 26 | border: none; 27 | border-radius: 4px; 28 | outline: none; 29 | cursor: pointer; 30 | transition: opacity .2s; 31 | 32 | &.confirm { 33 | color: #fff; 34 | background: #4ad9d9; 35 | } 36 | 37 | &.cancel { 38 | background: #ccc; 39 | } 40 | 41 | &:hover { 42 | opacity: .8; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/renderer/styles/icons.scss: -------------------------------------------------------------------------------- 1 | @font-face { 2 | font-family: 'aidou'; 3 | src: 4 | url('fonts/icomoon.ttf?ixqlam') format('truetype'), 5 | url('fonts/icomoon.woff?ixqlam') format('woff'), 6 | url('fonts/icomoon.svg?ixqlam#icomoon') format('svg'); 7 | font-weight: normal; 8 | font-style: normal; 9 | } 10 | 11 | [class^="icon-"], [class*=" icon-"] { 12 | /* use !important to prevent issues with browser extensions that change fonts */ 13 | font-family: 'aidou' !important; 14 | speak: none; 15 | font-style: normal; 16 | font-weight: normal; 17 | font-variant: normal; 18 | text-transform: none; 19 | line-height: 1; 20 | 21 | /* Better Font Rendering =========== */ 22 | -webkit-font-smoothing: antialiased; 23 | -moz-osx-font-smoothing: grayscale; 24 | } 25 | 26 | .icon-rewind:before { 27 | content: "\e900"; 28 | } 29 | .icon-delete_forever:before { 30 | content: "\e902"; 31 | } 32 | .icon-favorite:before { 33 | content: "\e903"; 34 | } 35 | .icon-shuffle:before { 36 | content: "\e904"; 37 | } 38 | .icon-refresh:before { 39 | content: "\e905"; 40 | } 41 | .icon-settings:before { 42 | content: "\e906"; 43 | } 44 | .icon-favorite_border:before { 45 | content: "\e907"; 46 | } 47 | .icon-search:before { 48 | content: "\e908"; 49 | } 50 | .icon-close:before { 51 | content: "\e909"; 52 | } 53 | -------------------------------------------------------------------------------- /src/renderer/styles/index.scss: -------------------------------------------------------------------------------- 1 | @import './variables.scss'; 2 | @import './icons.scss'; 3 | @import './global.scss'; 4 | -------------------------------------------------------------------------------- /src/renderer/styles/variables.scss: -------------------------------------------------------------------------------- 1 | $main-color: #4ad9d9; 2 | $info-color: #929aa3; 3 | -------------------------------------------------------------------------------- /src/renderer/util/bus.js: -------------------------------------------------------------------------------- 1 | import Vue from 'vue' 2 | const eventHub = new Vue() 3 | export default eventHub 4 | -------------------------------------------------------------------------------- /src/renderer/util/copy.js: -------------------------------------------------------------------------------- 1 | const HIDDEN_INPUT = document.createElement('textarea') 2 | HIDDEN_INPUT.style.position = 'fixed' 3 | HIDDEN_INPUT.style.left = '-1000px' 4 | document.body.appendChild(HIDDEN_INPUT) 5 | 6 | export default function copy (v, cb) { 7 | if (!HIDDEN_INPUT || !HIDDEN_INPUT.select) return 8 | HIDDEN_INPUT.value = v 9 | HIDDEN_INPUT.focus() 10 | HIDDEN_INPUT.select() 11 | let suc = false 12 | try { 13 | document.execCommand('copy') 14 | suc = true 15 | } catch (e) { 16 | console.log(e) 17 | } 18 | cb && cb(suc) 19 | HIDDEN_INPUT.blur() 20 | HIDDEN_INPUT.value = '' 21 | } 22 | -------------------------------------------------------------------------------- /src/renderer/util/helper.js: -------------------------------------------------------------------------------- 1 | export function merge (...args) { 2 | return Object.assign({}, ...args) 3 | } 4 | 5 | export function serialize (params) { 6 | return Object.keys(params).map(key => `${key}=${params[key]}`).join('&') 7 | } 8 | 9 | export function transformMap (map, options) { 10 | const { 11 | key = 'key', 12 | value = 'value' 13 | } = options || {} 14 | return Object.keys(map).map(item => ({ 15 | [key]: item, 16 | [value]: map[item] 17 | })) 18 | } 19 | -------------------------------------------------------------------------------- /src/renderer/util/linkBuilder.js: -------------------------------------------------------------------------------- 1 | export default { 2 | url (url) { 3 | return url 4 | }, 5 | ubb (url) { 6 | return `[IMG]${url}[/IMG]` 7 | }, 8 | img (url) { 9 | return `` 10 | }, 11 | markdown (url) { 12 | return `![](${url})` 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /static/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ywwhack/aidou-electron/d9270401082e43ec7850dd2df62cca8e1e106f69/static/.gitkeep -------------------------------------------------------------------------------- /static/temp_image/.placeholder: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ywwhack/aidou-electron/d9270401082e43ec7850dd2df62cca8e1e106f69/static/temp_image/.placeholder -------------------------------------------------------------------------------- /summary.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ywwhack/aidou-electron/d9270401082e43ec7850dd2df62cca8e1e106f69/summary.gif --------------------------------------------------------------------------------