Skip to content

Commit

Permalink
feat(userConfig): 增加用户配置文件模板
Browse files Browse the repository at this point in the history
  • Loading branch information
aitexiaoy committed Jul 7, 2019
1 parent 0acb7c1 commit cdbe450
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 3 deletions.
6 changes: 6 additions & 0 deletions .electron-vue/webpack.main.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ process.env.BABEL_ENV = 'main'
const path = require('path')
const { dependencies } = require('../package.json')
const webpack = require('webpack')
const fs= require('fs')
// 检测是否有用户配置文件,没有的话根据模板生成一个
const userConfigPath=path.resolve(__dirname,'../.user-config1.js')
if(fs.existsSync(userConfigPath)){
fs.copyFileSync(path.resolve(__dirname,'../user-config.template.js'), userConfigPath)
}

let mainConfig = {
entry: {
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ node_modules/
npm-debug.log
npm-debug.log.*
thumbs.db
.user-config.json
.user-config.js
!.gitkeep
.vscode
5 changes: 4 additions & 1 deletion src/api/api.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@


import userConfig from '../../.user-config.js'

const axios = require('axios')
const { baiDuTranslationAppId, baiDuTranslationAppKey } = require('../../.user-config.json')

const { baiDuTranslationAppId, baiDuTranslationAppKey } = userConfig
const { MD5: swMd5 } = require('./baidu-md5')
const { apiBaseUrl } = require('../utils/config')

Expand Down
6 changes: 5 additions & 1 deletion src/main/mail.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@

import userConfig from '../../.user-config.js'

const nodemailer = require('nodemailer')
const { emailUserName, emailPassword } = require('../../.user-config.json')

const { emailUserName, emailPassword } = userConfig


/**
* 发送一封邮件
Expand Down
11 changes: 11 additions & 0 deletions user-config.template.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/**
* 用户的自定义配置文件,存放用户的一些账号信息。
* 执行npm命令后会自动生成.user-config.js文件。
* 目前相关信息只会影响到电子邮箱与关键词的翻译
*/
export default {
emailUserName: '', // 电子邮箱账号
emailPassword: '', // 电子邮箱的授权码
baiDuTranslationAppId: '', // 百度翻译的appID
baiDuTranslationAppKey: '' // 百度翻译的appKey
}

0 comments on commit cdbe450

Please sign in to comment.