Skip to content

Commit

Permalink
feat(main): delete ,
Browse files Browse the repository at this point in the history
  • Loading branch information
aitexiaoy committed Sep 18, 2019
1 parent e1f38c2 commit 854a2cd
Show file tree
Hide file tree
Showing 7 changed files with 46 additions and 46 deletions.
16 changes: 8 additions & 8 deletions src/api/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,15 @@ export const apiTranslation = val => new Promise((resolve, reject) => {
resolve(val)
return
}
const appid = baiDuTranslationAppId;
const key = baiDuTranslationAppKey;
const salt = (new Date()).getTime();
const query = val;
const appid = baiDuTranslationAppId
const key = baiDuTranslationAppKey
const salt = (new Date()).getTime()
const query = val
// 多个query可以用\n连接 如 query='apple\norange\nbanana\npear'
const from = 'zh';
const to = 'en';
const str1 = appid + query + salt + key;
const sign = swMd5(str1);
const from = 'zh'
const to = 'en'
const str1 = appid + query + salt + key
const sign = swMd5(str1)

axios({
url: 'http://api.fanyi.baidu.com/api/trans/vip/translate',
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export default {
}
})
}
};
}
</script>

<style lang="less">
Expand Down
6 changes: 3 additions & 3 deletions src/renderer/assets/js/common-fn.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export const deepClone = function (obj, cache = []) {
* @param {*} obj
*/
export const typeOf = (obj) => {
const { toString } = Object.prototype;
const { toString } = Object.prototype
const map = {
'[object Boolean]': 'boolean',
'[object Number]': 'number',
Expand All @@ -49,6 +49,6 @@ export const typeOf = (obj) => {
'[object Undefined]': 'undefined',
'[object Null]': 'null',
'[object Object]': 'object'
};
return map[toString.call(obj)];
}
return map[toString.call(obj)]
}
22 changes: 11 additions & 11 deletions src/renderer/assets/js/local-storage.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
*/
const setStore = (name, value) => {
if (!name) {
return false;
return false
}
if (typeof value !== 'string') {
value = JSON.stringify(value);
value = JSON.stringify(value)
}
window.localStorage.setItem(name, value);
window.localStorage.setItem(name, value)
return true
}

Expand All @@ -20,29 +20,29 @@ const setStore = (name, value) => {
* @param {String} name
*/
const getStore = (name) => {
if (!name) return false;
if (!name) return false
try {
if (window.localStorage.getItem(name) && window.localStorage.getItem(name).length > 1) {
const returnString = window.localStorage.getItem(name);
const returnString = window.localStorage.getItem(name)
try {
return JSON.parse(returnString);
return JSON.parse(returnString)
} catch (error) {
return returnString;
return returnString
}
}
} catch (error) {
console.log(error);
console.log(error)
}
return '';
return ''
}

/**
* 删除指定的localStorage
* @param {String} name
*/
const removeStore = (name) => {
if (!name || !window.localStorage.getItem(name)) return false;
window.localStorage.removeItem(name);
if (!name || !window.localStorage.getItem(name)) return false
window.localStorage.removeItem(name)
return true
}

Expand Down
2 changes: 1 addition & 1 deletion src/renderer/assets/js/vue-fn.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export default {
Vue.prototype.$deepClone = deepClone
Vue.prototype.$localStorage = localStorage
Vue.prototype.$typeOf = typeOf
Vue.prototype.$ipcRenderer = ipcRenderer;
Vue.prototype.$ipcRenderer = ipcRenderer
Vue.prototype.$http = axios
},
}
36 changes: 18 additions & 18 deletions src/renderer/components/image-match/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ export default {
// tip 的展示方向
Vue.directive('imagematch', {
bind(el, binding) {
const matchType = ['width', 'height', 'auto'];
const q = matchType.filter(placement => binding.modifiers[placement]);
let time = 0;
el._type = q.length ? q[0] : 'auto';
const matchType = ['width', 'height', 'auto']
const q = matchType.filter(placement => binding.modifiers[placement])
let time = 0
el._type = q.length ? q[0] : 'auto'

// eslint-disable-next-line camelcase
function _choponent_size_fn(e) {
const parentWidth = el.clientWidth;
const parentHeight = el.clientHeight;
const parentWidth = el.clientWidth
const parentHeight = el.clientHeight

// 宽度与高度自适应
if (el._type === 'auto') {
Expand Down Expand Up @@ -42,22 +42,22 @@ export default {
// return;
// }
time = window.setTimeout(() => {
window.clearTimeout(time);
time = 0;
_choponent_size_fn(e);
window.clearTimeout(time)
time = 0
_choponent_size_fn(e)
}, 100)
}

let children = document.createElement('img');
children.src = binding.value;
el.appendChild(children);
let children = document.createElement('img')
children.src = binding.value
el.appendChild(children)
children.onload = function () {
el._childrenWidth = children.width;
el._childrenHeight = children.height;
el._children = children;
_choponent_size_fn();
el._childrenWidth = children.width
el._childrenHeight = children.height
el._children = children
_choponent_size_fn()
window.addEventListener('resize', () => {
el._choponent_size();
el._choponent_size()
})
}

Expand All @@ -77,7 +77,7 @@ export default {

unbind(el) {
if (el._choponent_size) {
window.removeEventListener('resize', el._choponent_size);
window.removeEventListener('resize', el._choponent_size)
}
}
})
Expand Down
8 changes: 4 additions & 4 deletions src/renderer/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ import vueFn from './assets/js/vue-fn'

Vue.use(require('vue-electron'))

Vue.use(ElementUI);
Vue.use(vueModules);
Vue.use(vueFn);
Vue.use(ElementUI)
Vue.use(vueModules)
Vue.use(vueFn)

const mainVue = new Vue({
components: { App },
Expand All @@ -25,4 +25,4 @@ const mainVue = new Vue({
template: '<App/>'
}).$mount('#app')

global.Vue = mainVue;
global.Vue = mainVue

0 comments on commit 854a2cd

Please sign in to comment.