first commit

This commit is contained in:
zhbaor 2021-10-30 23:36:07 +08:00
commit e40b2117b5
21 changed files with 17956 additions and 0 deletions

2
frontend/.env.development Executable file
View file

@ -0,0 +1,2 @@
VUE_APP_BASE_URL="/"
VUE_APP_AXIOS_BASE_URL="http://localhost:3000"

2
frontend/.env.production Executable file
View file

@ -0,0 +1,2 @@
VUE_APP_BASE_URL="/"
VUE_APP_AXIOS_BASE_URL=""

23
frontend/.gitignore vendored Executable file
View file

@ -0,0 +1,23 @@
.DS_Store
node_modules
/dist
# local env files
.env.local
.env.*.local
# Log files
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
# Editor directories and files
.idea
.vscode
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?

24
frontend/README.md Executable file
View file

@ -0,0 +1,24 @@
# csv2html
## Project setup
```
npm install
```
### Compiles and hot-reloads for development
```
npm run serve
```
### Compiles and minifies for production
```
npm run build
```
### Lints and fixes files
```
npm run lint
```
### Customize configuration
See [Configuration Reference](https://cli.vuejs.org/config/).

12
frontend/babel.config.js Executable file
View file

@ -0,0 +1,12 @@
module.exports = {
presets: [["@babel/preset-env", { modules: false }]],
plugins: [
[
"component",
{
libraryName: "element-ui",
styleLibraryName: "theme-chalk",
},
],
],
};

BIN
frontend/dist.tar Normal file

Binary file not shown.

5
frontend/jsconfig.json Executable file
View file

@ -0,0 +1,5 @@
{
"include": [
"./src/**/*"
]
}

15356
frontend/package-lock.json generated Executable file

File diff suppressed because it is too large Load diff

54
frontend/package.json Executable file
View file

@ -0,0 +1,54 @@
{
"name": "csv2html",
"version": "0.1.0",
"private": true,
"scripts": {
"serve": "vue-cli-service serve",
"build": "vue-cli-service build",
"lint": "vue-cli-service lint"
},
"dependencies": {
"axios": "^0.21.4",
"core-js": "^3.18.1",
"element-ui": "^2.15.6",
"gridmanager-vue": "^1.10.3",
"lodash": "^4.17.21",
"validator": "^13.6.0",
"vue": "^2.6.11",
"vue-axios": "^3.3.7",
"vue-lodash": "^2.1.2"
},
"devDependencies": {
"@babel/preset-env": "^7.15.6",
"@vue/cli-plugin-babel": "~4.5.0",
"@vue/cli-plugin-eslint": "~4.5.0",
"@vue/cli-service": "~4.5.0",
"babel-eslint": "^10.1.0",
"babel-plugin-component": "^1.1.1",
"eslint": "^6.7.2",
"eslint-plugin-html": "^6.2.0",
"eslint-plugin-vue": "^6.2.2",
"npm": "^7.24.1",
"vue-cli-plugin-element": "~1.0.1",
"vue-template-compiler": "^2.6.11"
},
"eslintConfig": {
"root": true,
"env": {
"node": true
},
"extends": [
"plugin:vue/essential",
"eslint:recommended"
],
"parserOptions": {
"parser": "babel-eslint"
},
"rules": {}
},
"browserslist": [
"> 1%",
"last 2 versions",
"not dead"
]
}

BIN
frontend/public/favicon.ico Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

30
frontend/public/index.html Executable file
View file

@ -0,0 +1,30 @@
<!DOCTYPE html>
<html lang="">
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width,initial-scale=1.0" />
<link rel="icon" href="<%= BASE_URL %>favicon.ico" />
<title><%= htmlWebpackPlugin.options.title %></title>
<style>
* {
font-family: "Helvetica Neue", Helvetica, "PingFang SC",
"Hiragino Sans GB", "Microsoft YaHei", "微软雅黑", Arial, sans-serif;
}
body {
margin: 0;
}
</style>
</head>
<body>
<noscript>
<strong
>We're sorry but <%= htmlWebpackPlugin.options.title %> doesn't work
properly without JavaScript enabled. Please enable it to
continue.</strong
>
</noscript>
<div id="app"></div>
<!-- built files will be auto injected -->
</body>
</html>

63
frontend/src/App.vue Executable file
View file

@ -0,0 +1,63 @@
<template>
<div>
<el-tabs type="border-card">
<el-tab-pane :key="i" v-for="(csv, i) in csvFiles" :label="csv">
<CSVTable :csv-file="csv" :paging="paging"></CSVTable>
</el-tab-pane>
</el-tabs>
<div class="options">
<el-checkbox v-model="paging">分页</el-checkbox>
</div>
</div>
</template>
<script>
import CSVTable from "./components/CSVTable.vue";
export default {
components: {
CSVTable,
},
data: function () {
return {
paging: true,
csvFiles: [],
};
},
created: function () {
this.axios.get("/files").then((response) => {
this.csvFiles = response.data;
});
},
mounted: function () {
if (localStorage.paging) {
this.paging = localStorage.paging == "true";
}
},
watch: {
paging: function () {
localStorage.paging = this.paging;
},
},
};
</script>
<style scoped>
.el-tabs {
box-sizing: border-box;
height: 100vh;
}
.el-tabs >>> .el-tabs__content {
padding: 0;
}
.options {
position: absolute;
right: 0;
top: 0;
height: 40px;
padding: 10px;
margin-right: 10px;
}
</style>

View file

@ -0,0 +1,60 @@
<template>
<grid-manager
class="table"
v-if="ready"
:option="gridOption"
:key="renderKey"
></grid-manager>
</template>
<script>
export default {
props: {
csvFile: String,
paging: Boolean,
},
data: function () {
return {
ready: false,
columnData: {},
renderKey: 0,
};
},
computed: {
gridOption: function () {
return {
columnData: this.columnData,
ajaxData: `${this.axios.defaults.baseURL}/csv/${this.csvFile}`,
gridManagerName: this.csvFile,
supportCheckbox: false,
supportAjaxPage: this.paging,
supportMenu: false,
disableCache: false,
height: "100vh - 40px",
width: "100vw",
};
},
},
watch: {
paging: function () {
this.renderKey++;
},
},
created: function () {
this.axios.get(`/column/${this.csvFile}`).then((response) => {
for (let d of response.data) {
d.template = (val) => {
let escVal = this._.escape(val);
if (this.validator.isURL(val)) {
return `<el-link type="primary" href="${escVal}" target="_blank">${escVal}</el-link>`;
} else {
return escVal;
}
};
}
this.columnData = response.data;
this.ready = true;
});
},
};
</script>

27
frontend/src/main.js Executable file
View file

@ -0,0 +1,27 @@
import Vue from "vue";
Vue.config.productionTip = false;
import "./plugins/element.js";
import GridManager from "gridmanager-vue";
import "gridmanager-vue/css/gm-vue.css";
Vue.use(GridManager);
import axios from "axios";
import VueAxios from "vue-axios";
axios.defaults.baseURL = process.env.VUE_APP_AXIOS_BASE_URL;
Vue.use(VueAxios, axios);
import VueLodash from "vue-lodash";
import lodash from "lodash";
Vue.use(VueLodash, { name: "custom", lodash: lodash });
import validator from "validator";
Vue.prototype.validator = validator;
import App from "./App.vue";
new Vue({
render: (h) => h(App),
}).$mount("#app");

View file

@ -0,0 +1,7 @@
import Vue from "vue";
import { Tabs, TabPane, Link, Checkbox } from "element-ui";
Vue.use(Tabs);
Vue.use(TabPane);
Vue.use(Link);
Vue.use(Checkbox);

10
frontend/vue.config.js Executable file
View file

@ -0,0 +1,10 @@
module.exports = {
publicPath: process.env.VUE_APP_BASE_URL,
configureWebpack: {
resolve: {
alias: {
vue$: "vue/dist/vue.esm.js",
},
},
},
};