Skip to content

Commit 0d7a92e

Browse files
committed
fix: 修复一些小问题
1. 缩进问题 2. CSS 属性拼写错误 3. v-for 加 key 属性 4. 增加 .eslintignore
1 parent d547dc3 commit 0d7a92e

27 files changed

+140
-134
lines changed

.eslintignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
**/*.ejs

app/electron.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -42,15 +42,15 @@ function createMainWindow () {
4242
const installExtension = require('electron-devtools-installer')
4343

4444
installExtension.default(installExtension.VUEJS_DEVTOOLS)
45-
.then(name => win.webContents.openDevTools())
46-
.catch(err => console.log('An error occurred: ', err))
45+
.then(name => win.webContents.openDevTools())
46+
.catch(err => console.log('An error occurred: ', err))
4747
}
4848

4949
win.on('closed', () => {
5050
console.log('触发 closed')
5151
mainWindow = null
5252
backgroundWindow = null
53-
// 在Mac中完全退出程序,而不会留在dock中
53+
// 在Mac中完全退出程序,而不会留在dock中
5454
app.quit()
5555
})
5656

app/main.ejs

+8-8
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,16 @@
22
<html>
33

44
<head>
5-
<meta charset="utf-8">
6-
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0, shrink-to-fit=no">
7-
<title>
8-
<%= htmlWebpackPlugin.options.title %>
9-
</title>
5+
<meta charset="utf-8">
6+
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0, shrink-to-fit=no">
7+
<title>
8+
<%= htmlWebpackPlugin.options.title %>
9+
</title>
1010
</head>
1111

1212
<body style="display:block;">
13-
<div id="app"></div>
14-
<!-- webpack builds are automatically injected -->
13+
<div id="app"></div>
14+
<!-- webpack builds are automatically injected -->
1515
</body>
1616

17-
</html>
17+
</html>

app/src/background/excelUtils.js

+9-9
Original file line numberDiff line numberDiff line change
@@ -42,23 +42,23 @@ Excel.prototype = {
4242
return {}
4343
},
4444
readByData (data) {
45-
// 用于前端上传文件,如:上传按钮和拖拽上传
45+
// 用于前端上传文件,如:上传按钮和拖拽上传
4646
this.workbook = xlsx.read(data, { type: 'binary' })
4747
},
4848
readByPath (filename) {
49-
// 用于 Node 直接通过路径读取文件
49+
// 用于 Node 直接通过路径读取文件
5050
this.workbook = xlsx.readFile(filename)
5151
},
5252
initData () {
53-
// 表名列表
53+
// 表名列表
5454
this.sheetNameList = this.workbook.SheetNames
5555

56-
// 插入每个sheet的数据(json格式)
56+
// 插入每个sheet的数据(json格式)
5757
this.sheetNameList.forEach((curSheetName, index) => {
5858
this[curSheetName] = xlsx.utils.sheet_to_json(this.workbook.Sheets[curSheetName])
5959
})
6060

61-
// 获取表头
61+
// 获取表头
6262
this.sheetNameList.forEach((curSheetName, index) => {
6363
const curSheetData = this.workbook.Sheets[curSheetName]
6464
const scope = this.workbook.Sheets[curSheetName]['!ref'].split(':') // A1 F5
@@ -87,14 +87,14 @@ Excel.prototype = {
8787
wbTem = null
8888
})
8989
sheetNameList = null
90-
// console.log(finalWB)
90+
// console.log(finalWB)
9191
ipcRenderer.send('sync-saveFile-dialog', {
9292
filename: '过滤后的文件.xlsx',
9393
data: finalWB
9494
})
95-
// console.log(xlsx.writeFile(finalWB, fileName)) // Node导出
96-
// let wbout = XLSX.write(finalWB, {bookType:'xlsx', bookSST:false, type: 'binary'});
97-
// saveAs(new Blob([s2ab(wbout)],{type:'application/octet-stream'}), fileName)
95+
// console.log(xlsx.writeFile(finalWB, fileName)) // Node导出
96+
// let wbout = XLSX.write(finalWB, {bookType:'xlsx', bookSST:false, type: 'binary'});
97+
// saveAs(new Blob([s2ab(wbout)],{type:'application/octet-stream'}), fileName)
9898
},
9999

100100
jsonToWBForOneSheet (json, colkeys, sheetName) {

app/src/background/filterUtils.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@ const filterUtils = {
1717
}
1818
return this.filterUnit({ operator, curVal, target })
1919
},
20-
// 双列范围逻辑的【非or、and】,即表单3.1
20+
// 双列范围逻辑的【非or、and】,即表单3.1
2121
filterByDoubleColsRange ({ row, colKeys, filterCol, operator, target, needConformColIndex }) {
2222
let passCounter = 0
2323

24-
// 判断每列中是否有一列符合单一逻辑,即3.1
24+
// 判断每列中是否有一列符合单一逻辑,即3.1
2525
for (let i = 0, len = filterCol.length; i < len; i++) {
2626
const selectKey = filterCol[i]
2727
const curKey = colKeys[selectKey]
@@ -40,9 +40,9 @@ const filterUtils = {
4040
}
4141
return false
4242
},
43-
// 第二个表单:多列运算逻辑
43+
// 第二个表单:多列运算逻辑
4444
filterByMultiColCalc ({ row, colKeys, filterCol, operator, target, colOperator }) {
45-
// 此处 filterCol 是数组
45+
// 此处 filterCol 是数组
4646
const rowCalcResult = this.calcMultiCol({
4747
row,
4848
colOperator,
@@ -56,7 +56,7 @@ const filterUtils = {
5656
target
5757
})
5858
},
59-
// 计算每行是否符合要求
59+
// 计算每行是否符合要求
6060
calcMultiCol ({ row, colOperator, colKeys, filterCol }) {
6161
let calcResult
6262

app/src/background/index.html

+8-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
1-
<!doctype html>
1+
<!DOCTYPE html>
22
<html>
33
<head>
44
<meta charset="utf-8">
5-
<script src="index.js"></script>
5+
<script src="./index.js"></script>
66
</head>
77
<body>
8+
<!-- 注意:
9+
先 npm run build,以生成 dist/background/index.html
10+
因为 background 目前并没有使用 webpack
11+
具体引入代码在 app/electron.js 文件中的 23 行代码
12+
-->
813
</body>
9-
</html>
14+
</html>

app/src/background/index.js

+9-9
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,14 @@ let filRow = {}
1414

1515
window.addEventListener('load', event => {
1616
ipcRenderer.on('readFile-start', (event, { data, activeSheetIndex }) => {
17-
/* excelData 的数据结构
18-
{
19-
sheetNameN: [] 所有行
20-
sheetNameN_headers: [] 所有列标题
21-
sheetNameList: []
22-
workbook: {} Excel 相关
23-
}
24-
*/
17+
/* excelData 的数据结构
18+
{
19+
sheetNameN: [] 所有行
20+
sheetNameN_headers: [] 所有列标题
21+
sheetNameList: []
22+
workbook: {} Excel 相关
23+
}
24+
*/
2525
excelData = new Excel().init(data)
2626
oriRow = {}
2727
filRow = {}
@@ -124,7 +124,7 @@ function filterHandler ({ filterTagList, filterWay, uniqueCols }) {
124124
const tagLogicChar = cTag.logicOperator === 'and' ? '&&' : '||'
125125
let groupExpStr = ''
126126

127-
// 遍历当前组的 filters
127+
// 遍历当前组的 filters
128128
cFilters.forEach((cF, index) => {
129129
const filterLogicChar = cF.logicOperator === 'and' ? '&&' : '||'
130130
const filterType = cF.filterType

app/src/components/FirstScreenPageView/ColSelDialog.vue

+1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
</p>
2525
<ul v-else>
2626
<li v-for="(item, index) in curColKeys"
27+
:key="index"
2728
@click="toggleSelect(index)"
2829
:class="{'active': selectedGroup.includes(index)}">
2930
<div>

app/src/components/FirstScreenPageView/FilterFormDoubleColsRange.vue

+1
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
<span class="select">
3434
<select v-model="operator">
3535
<option v-for="op in filterOptions"
36+
:key="op.char"
3637
:value="op.char">
3738
{{ op.words }}
3839
</option>

app/src/components/FirstScreenPageView/FilterFormMultiCalc.vue

+2
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
<span class="select">
2323
<select v-model="colOperatorSelect">
2424
<option v-for="op in colOperator"
25+
:key="op.char"
2526
:value="op.char">
2627
{{ op.words }}
2728
</option>
@@ -35,6 +36,7 @@
3536
<span class="select">
3637
<select v-model="operator">
3738
<option v-for="op in filteredOpt"
39+
:key="op.char"
3840
:value="op.char">
3941
{{ op.words }}
4042
</option>

app/src/components/FirstScreenPageView/FilterFormSingleLogic.vue

+1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
<span class="select">
2323
<select v-model="operator">
2424
<option v-for="op in filterOptions"
25+
:key="op.char"
2526
:value="op.char">
2627
{{ op.words }}
2728
</option>

app/src/components/FirstScreenPageView/FilterFormUnique.vue

+25-27
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,29 @@
11
<template>
2-
<form class="unique_form" @submit.prevent="addUniqueHandler" @keyup.stop>
3-
<table class="table">
4-
<tbody>
5-
<tr>
6-
<td>多列去重逻辑</td>
7-
<td>
8-
<span class="select disabled">
9-
<select v-model="logicOperator" disabled>
10-
<option value="and">且</option>
11-
</select>
12-
<p class="val_mask">{{ getLogicOperatorWords(logicOperator)}}</p>
13-
</span>
14-
</td>
15-
<td>
16-
<p class="col_placeholder" @click="showColSelectDialog">
17-
{{operatorCol.length === 0 ? "请选择列" : formatColGroup}}
18-
</p>
19-
</td>
20-
21-
<td>
22-
<button type="submit">添加</button>
23-
</td>
24-
</tr>
25-
</tbody>
26-
</table>
27-
</form>
2+
<form class="unique_form" @submit.prevent="addUniqueHandler" @keyup.stop>
3+
<table class="table">
4+
<tbody>
5+
<tr>
6+
<td>多列去重逻辑</td>
7+
<td>
8+
<span class="select disabled">
9+
<select v-model="logicOperator" disabled>
10+
<option value="and">且</option>
11+
</select>
12+
<p class="val_mask">{{ getLogicOperatorWords(logicOperator)}}</p>
13+
</span>
14+
</td>
15+
<td>
16+
<p class="col_placeholder" @click="showColSelectDialog">
17+
{{operatorCol.length === 0 ? "请选择列" : formatColGroup}}
18+
</p>
19+
</td>
20+
<td>
21+
<button type="submit">添加</button>
22+
</td>
23+
</tr>
24+
</tbody>
25+
</table>
26+
</form>
2827
</template>
2928

3029
<script>
@@ -105,7 +104,6 @@ export default {
105104
106105
</script>
107106

108-
109107
<style lang="scss" soped>
110108
.unique_form {
111109
tr {

app/src/components/FirstScreenPageView/FilterTag.vue

+2-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
{{ getCharCol(filterTag.groupId) }}
88
</span>
99
<ul>
10-
<li v-for="(filter, index) in filterTag.filters">
10+
<li v-for="(filter, index) in filterTag.filters"
11+
:key="index">
1112
<span class="logic_char" v-if="index !== 0">
1213
{{ getLogicOperator(filter.logicOperator) }}
1314
</span>

app/src/components/FirstScreenPageView/GroupSelect.vue

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
<option value="-1">组别</option>
55
<!-- v-for 整数迭代是从1开始 -->
66
<option
7-
v-for="index in groupNum" :value="index - 1">
7+
v-for="index in groupNum" :value="index - 1"
8+
:key="index">
89
{{ getGroupValue(index - 1) }}
910
</option>
1011
</select>

app/src/components/FirstScreenPageView/SheetOfExcel.vue

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
<tr>
77
<th></th>
88
<!-- v-for 整数迭代是从1开始 -->
9-
<th v-for="col in curColCount" :title="'即第' + col + '行'">
9+
<th v-for="col in curColCount" :title="'即第' + col + '行'"
10+
:key="col">
1011
{{ getCharCol(col - 1) }}
1112
</th>
1213
</tr>
@@ -50,7 +51,6 @@ export default {
5051
getNumCol
5152
}
5253
}
53-
5454
</script>
5555

5656
<style lang="scss" scoped>

app/src/components/common/FileList.vue

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
<div class="file_list">
44
<ul>
55
<li title="双击文件名即可导入"
6-
v-for="(file, index) in fileListByQuery"
6+
v-for="(file) in fileListByQuery"
7+
:key="file.path"
78
:class="{cur_file: file.path === fileList[0].path}"
89
@dblclick="confirmRead(file.path ,file)">
910
<span>{{ file.extname.replace(/^./, "") }}</span>

app/src/components/common/UpdateDialog.vue

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<template>
2-
<div class="update_modal" @keyup :class="{'active': updateDialogStatus}">
2+
<div class="update_modal" @keyup.prevent :class="{'active': updateDialogStatus}">
33
<div class="update_dialog" :class="isHasNewVersion ? 'has_new' : 'no_new'">
44
<template v-if="isHasNewVersion">
55
<div class="update_dialog_header">
@@ -172,7 +172,7 @@ export default {
172172
flex-shrink: 0;
173173
>div {
174174
display: flex;
175-
align-item: stretch;
175+
align-items: stretch;
176176
height: 50px;
177177
}
178178
button {

app/src/store/modules/excel.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ const actions = {
3838
setActiveSheet ({ state, commit, rootState }, index) {
3939
commit(types.SET_ACTIVE_SHEET, index)
4040
},
41-
// 筛选后的数据,目前只有 行数
41+
// 筛选后的数据,目前只有 行数
4242
setFilteredData ({ state, commit, rootState }, filRow) {
4343
commit(types.SET_FILTERED_DATA, filRow)
4444
}

app/src/store/modules/file.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ const state = {
1919
}
2020

2121
const getters = {
22-
// getters 包含所有模块的getters(扁平化后),rootState 与 actions 相同
22+
// getters 包含所有模块的getters(扁平化后),rootState 与 actions 相同
2323
getUploadFiles: (state, getters, rootState) => state.fileList,
2424
getSearchVal: (state, getters, rootState) => state.searchVal,
2525
getFileStatus: (state, getters, rootState) => state.fileStatus,
@@ -83,7 +83,7 @@ const mutations = {
8383

8484
setLocal('uploadFiles', state.fileList)
8585
},
86-
// 去掉复数
86+
// 去掉复数
8787
[types.DEL_UPLOAD_FILES] (state, fileObj) {
8888
for (let i = 0, len = state.fileList.length; i < len; i++) {
8989
const file = state.fileList[i]
@@ -94,7 +94,7 @@ const mutations = {
9494
}
9595
setLocal('uploadFiles', state.fileList)
9696
},
97-
// 命名要改
97+
// 命名要改
9898
[types.SET_FILE_STATUS] (state, status) {
9999
state.fileStatus = status
100100
}

0 commit comments

Comments
 (0)