feat:初始化项目
This commit is contained in:
commit
b0d3902e8d
26 files changed
+807
No files matched your search
+26
@@ -0,0 +1,26 @@
|
||||
<template>
|
||||
<div id="app">
|
||||
<div id="nav">
|
||||
<router-link to="/">Home</router-link> |
|
||||
<router-link to="/about">About</router-link>
|
||||
</div>
|
||||
<router-view />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style lang="scss">
|
||||
@import "@/styles";
|
||||
|
||||
#nav {
|
||||
padding: 30px;
|
||||
|
||||
a {
|
||||
font-weight: bold;
|
||||
color: #2c3e50;
|
||||
|
||||
&.router-link-exact-active {
|
||||
color: #42b983;
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,12 @@
|
||||
import ajax from "@/lib/ajax";
|
||||
import config from "@/config";
|
||||
|
||||
// host
|
||||
const HOST = config.host("/zuul", "/mrxf");
|
||||
|
||||
// 来访总量统计列表
|
||||
const petitionReportTotal = param => {
|
||||
return ajax.post(`${HOST}/petitionReport/total`, param);
|
||||
};
|
||||
|
||||
export { petitionReportTotal };
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 6.7 KiB |
@@ -0,0 +1,130 @@
|
||||
<template>
|
||||
<div class="hello">
|
||||
<h1 class="border-1px">{{ msg }}</h1>
|
||||
<p>
|
||||
For a guide and recipes on how to configure / customize this project,<br />
|
||||
check out the
|
||||
<a href="https://cli.vuejs.org" target="_blank" rel="noopener"
|
||||
>vue-cli documentation</a
|
||||
>.
|
||||
</p>
|
||||
<h3>Installed CLI Plugins</h3>
|
||||
<ul>
|
||||
<li>
|
||||
<a
|
||||
href="https://github.com/vuejs/vue-cli/tree/dev/packages/%40vue/cli-plugin-babel"
|
||||
target="_blank"
|
||||
rel="noopener"
|
||||
>babel</a
|
||||
>
|
||||
</li>
|
||||
<li>
|
||||
<a
|
||||
href="https://github.com/vuejs/vue-cli/tree/dev/packages/%40vue/cli-plugin-router"
|
||||
target="_blank"
|
||||
rel="noopener"
|
||||
>router</a
|
||||
>
|
||||
</li>
|
||||
<li>
|
||||
<a
|
||||
href="https://github.com/vuejs/vue-cli/tree/dev/packages/%40vue/cli-plugin-vuex"
|
||||
target="_blank"
|
||||
rel="noopener"
|
||||
>vuex</a
|
||||
>
|
||||
</li>
|
||||
<li>
|
||||
<a
|
||||
href="https://github.com/vuejs/vue-cli/tree/dev/packages/%40vue/cli-plugin-eslint"
|
||||
target="_blank"
|
||||
rel="noopener"
|
||||
>eslint</a
|
||||
>
|
||||
</li>
|
||||
</ul>
|
||||
<h3>Essential Links</h3>
|
||||
<ul>
|
||||
<li>
|
||||
<a href="https://vuejs.org" target="_blank" rel="noopener">Core Docs</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="https://forum.vuejs.org" target="_blank" rel="noopener"
|
||||
>Forum</a
|
||||
>
|
||||
</li>
|
||||
<li>
|
||||
<a href="https://chat.vuejs.org" target="_blank" rel="noopener"
|
||||
>Community Chat</a
|
||||
>
|
||||
</li>
|
||||
<li>
|
||||
<a href="https://twitter.com/vuejs" target="_blank" rel="noopener"
|
||||
>Twitter</a
|
||||
>
|
||||
</li>
|
||||
<li>
|
||||
<a href="https://news.vuejs.org" target="_blank" rel="noopener">News</a>
|
||||
</li>
|
||||
</ul>
|
||||
<h3>Ecosystem</h3>
|
||||
<ul>
|
||||
<li>
|
||||
<a href="https://router.vuejs.org" target="_blank" rel="noopener"
|
||||
>vue-router</a
|
||||
>
|
||||
</li>
|
||||
<li>
|
||||
<a href="https://vuex.vuejs.org" target="_blank" rel="noopener">vuex</a>
|
||||
</li>
|
||||
<li>
|
||||
<a
|
||||
href="https://github.com/vuejs/vue-devtools#vue-devtools"
|
||||
target="_blank"
|
||||
rel="noopener"
|
||||
>vue-devtools</a
|
||||
>
|
||||
</li>
|
||||
<li>
|
||||
<a href="https://vue-loader.vuejs.org" target="_blank" rel="noopener"
|
||||
>vue-loader</a
|
||||
>
|
||||
</li>
|
||||
<li>
|
||||
<a
|
||||
href="https://github.com/vuejs/awesome-vue"
|
||||
target="_blank"
|
||||
rel="noopener"
|
||||
>awesome-vue</a
|
||||
>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
name: "HelloWorld",
|
||||
props: {
|
||||
msg: String
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<!-- Add "scoped" attribute to limit CSS to this component only -->
|
||||
<style scoped lang="scss">
|
||||
h3 {
|
||||
margin: 40px 0 0;
|
||||
}
|
||||
ul {
|
||||
list-style-type: none;
|
||||
padding: 0;
|
||||
}
|
||||
li {
|
||||
display: inline-block;
|
||||
margin: 0 10px;
|
||||
}
|
||||
a {
|
||||
color: #42b983;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,24 @@
|
||||
// 应用的名称
|
||||
const appName = "每日信访动态报送";
|
||||
|
||||
// 是否启用YApi
|
||||
const YApi = false;
|
||||
|
||||
// 代理环境,1测试环境,2生产环境
|
||||
const VUE_APP_PROXY = process.env.VUE_APP_PROXY
|
||||
? parseInt(process.env.VUE_APP_PROXY)
|
||||
: 1;
|
||||
|
||||
const host = (PASSID, GATEWAY) => {
|
||||
// host
|
||||
const HOST = YApi ? `/mock/73/${GATEWAY}` : `${PASSID}${GATEWAY}`;
|
||||
|
||||
return HOST;
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
appName,
|
||||
YApi,
|
||||
VUE_APP_PROXY,
|
||||
host
|
||||
};
|
||||
Executable
+55
@@ -0,0 +1,55 @@
|
||||
import axios from "axios";
|
||||
|
||||
// 添加公共请求头
|
||||
const getHeader = function(options) {
|
||||
if (options === "form") {
|
||||
return Object.assign({
|
||||
"content-type": "application/x-www-form-urlencoded"
|
||||
});
|
||||
} else if (options === "file") {
|
||||
return Object.assign({ "content-type": "multipart/form-data" });
|
||||
}
|
||||
};
|
||||
|
||||
const request = function(method, url, params, options) {
|
||||
return new Promise(function(resolve, reject) {
|
||||
axios
|
||||
.request({
|
||||
headers: getHeader(options),
|
||||
url: url,
|
||||
method: method,
|
||||
withCredentials: true,
|
||||
data: method === "post" ? params : {},
|
||||
params: method === "get" ? params : {},
|
||||
timeout: 120000,
|
||||
responseType: "json"
|
||||
})
|
||||
.then(function(response) {
|
||||
let data = response.data || JSON.parse(response.request.responseText);
|
||||
resolve(data);
|
||||
})
|
||||
.catch(function(error) {
|
||||
if (typeof error.response === "undefined") {
|
||||
if (
|
||||
location.hostname == "127.0.0.1" ||
|
||||
location.hostname == "localhost"
|
||||
) {
|
||||
reject(error);
|
||||
} else {
|
||||
location.reload();
|
||||
}
|
||||
} else {
|
||||
reject(error);
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
export default {
|
||||
get: function(url, params, options) {
|
||||
return request("get", url, params, options);
|
||||
},
|
||||
post: function(url, params, options) {
|
||||
return request("post", url, params, options);
|
||||
}
|
||||
};
|
||||
Executable
+118
@@ -0,0 +1,118 @@
|
||||
/* eslint-disable */
|
||||
import XLSX from 'xlsx';
|
||||
|
||||
function auto_width(ws, data){
|
||||
/*set worksheet max width per col*/
|
||||
const colWidth = data.map(row => row.map(val => {
|
||||
/*if null/undefined*/
|
||||
if (val == null) {
|
||||
return {'wch': 10};
|
||||
}
|
||||
/*if chinese*/
|
||||
else if (val.toString().charCodeAt(0) > 255) {
|
||||
return {'wch': val.toString().length * 2};
|
||||
} else {
|
||||
return {'wch': val.toString().length};
|
||||
}
|
||||
}))
|
||||
/*start in the first row*/
|
||||
let result = colWidth[0];
|
||||
for (let i = 1; i < colWidth.length; i++) {
|
||||
for (let j = 0; j < colWidth[i].length; j++) {
|
||||
if (result[j]['wch'] < colWidth[i][j]['wch']) {
|
||||
result[j]['wch'] = colWidth[i][j]['wch'];
|
||||
}
|
||||
}
|
||||
}
|
||||
ws['!cols'] = result;
|
||||
}
|
||||
|
||||
function json_to_array(key, jsonData){
|
||||
return jsonData.map(v => key.map(j => { return v[j] }));
|
||||
}
|
||||
|
||||
// fix data,return string
|
||||
function fixdata(data) {
|
||||
let o = ''
|
||||
let l = 0
|
||||
const w = 10240
|
||||
for (; l < data.byteLength / w; ++l) o += String.fromCharCode.apply(null, new Uint8Array(data.slice(l * w, l * w + w)))
|
||||
o += String.fromCharCode.apply(null, new Uint8Array(data.slice(l * w)))
|
||||
return o
|
||||
}
|
||||
|
||||
// get head from excel file,return array
|
||||
function get_header_row(sheet) {
|
||||
const headers = []
|
||||
const range = XLSX.utils.decode_range(sheet['!ref'])
|
||||
let C
|
||||
const R = range.s.r /* start in the first row */
|
||||
for (C = range.s.c; C <= range.e.c; ++C) { /* walk every column in the range */
|
||||
var cell = sheet[XLSX.utils.encode_cell({ c: C, r: R })] /* find the cell in the first row */
|
||||
var hdr = 'UNKNOWN ' + C // <-- replace with your desired default
|
||||
if (cell && cell.t) hdr = XLSX.utils.format_cell(cell)
|
||||
headers.push(hdr)
|
||||
}
|
||||
return headers
|
||||
}
|
||||
|
||||
// export const export_table_to_excel= (id, filename) => {
|
||||
// const table = document.getElementById(id);
|
||||
// const wb = XLSX.utils.table_to_book(table);
|
||||
// XLSX.writeFile(wb, filename);
|
||||
|
||||
// /* the second way */
|
||||
// // const table = document.getElementById(id);
|
||||
// // const wb = XLSX.utils.book_new();
|
||||
// // const ws = XLSX.utils.table_to_sheet(table);
|
||||
// // XLSX.utils.book_append_sheet(wb, ws, filename);
|
||||
// // XLSX.writeFile(wb, filename);
|
||||
// }
|
||||
export const export_table_to_excel= (table, filename) => {
|
||||
if(!table) return;
|
||||
const wb = XLSX.utils.table_to_book(table);
|
||||
XLSX.writeFile(wb, filename)
|
||||
}
|
||||
|
||||
export const export_json_to_excel = ({data, key, title, filename, autoWidth}) => {
|
||||
const wb = XLSX.utils.book_new();
|
||||
data.unshift(title);
|
||||
const ws = XLSX.utils.json_to_sheet(data, {header: key, skipHeader: true});
|
||||
if(autoWidth){
|
||||
const arr = json_to_array(key, data);
|
||||
auto_width(ws, arr);
|
||||
}
|
||||
XLSX.utils.book_append_sheet(wb, ws, filename);
|
||||
XLSX.writeFile(wb, filename + '.xlsx');
|
||||
}
|
||||
|
||||
export const export_array_to_excel = ({key, data, title, filename, autoWidth}) => {
|
||||
const wb = XLSX.utils.book_new();
|
||||
const arr = json_to_array(key, data);
|
||||
arr.unshift(title);
|
||||
const ws = XLSX.utils.aoa_to_sheet(arr);
|
||||
if(autoWidth){
|
||||
auto_width(ws, arr);
|
||||
}
|
||||
XLSX.utils.book_append_sheet(wb, ws, filename);
|
||||
XLSX.writeFile(wb, filename + '.xlsx');
|
||||
}
|
||||
|
||||
export const read = (data, type) => {
|
||||
/* if type == 'base64' must fix data first */
|
||||
// const fixedData = fixdata(data)
|
||||
// const workbook = XLSX.read(btoa(fixedData), { type: 'base64' })
|
||||
const workbook = XLSX.read(data, { type: type });
|
||||
const firstSheetName = workbook.SheetNames[0];
|
||||
const worksheet = workbook.Sheets[firstSheetName];
|
||||
const header = get_header_row(worksheet);
|
||||
const results = XLSX.utils.sheet_to_json(worksheet);
|
||||
return {header, results};
|
||||
}
|
||||
|
||||
export default {
|
||||
export_table_to_excel,
|
||||
export_array_to_excel,
|
||||
export_json_to_excel,
|
||||
read
|
||||
}
|
||||
+121
@@ -0,0 +1,121 @@
|
||||
import { CookieStorage } from "cookie-storage";
|
||||
import config from "@/config";
|
||||
|
||||
const cookieStorage = new CookieStorage();
|
||||
|
||||
const systemCode = config.systemCode;
|
||||
|
||||
// 随机长度字符串
|
||||
const randomString = len => {
|
||||
len = len || 10;
|
||||
var chars = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
||||
var maxPos = chars.length;
|
||||
var str = "";
|
||||
for (let i = 0; i < len; i++) {
|
||||
str += chars.charAt(Math.floor(Math.random() * maxPos));
|
||||
}
|
||||
return str;
|
||||
};
|
||||
|
||||
// 设置localStorage
|
||||
const _setItem = (key, data) => {
|
||||
localStorage.setItem(key, JSON.stringify(data));
|
||||
};
|
||||
|
||||
// 获取localStorage
|
||||
const _getItem = key => {
|
||||
let data = localStorage.getItem(key);
|
||||
if (data) data = JSON.parse(data);
|
||||
return data;
|
||||
};
|
||||
|
||||
// 删除localStorage
|
||||
const _removeItem = key => {
|
||||
localStorage.removeItem(key);
|
||||
};
|
||||
|
||||
// 缓存用户信息
|
||||
const setUserInfoCache = info => {
|
||||
let data = {
|
||||
account: info.account,
|
||||
avatar: info.avatar,
|
||||
userId: info.userId,
|
||||
userName: info.userName
|
||||
};
|
||||
_setItem("__UserInfo__", data);
|
||||
};
|
||||
|
||||
// 获取缓存的用户信息
|
||||
const getUserInfoCache = () => {
|
||||
let data = _getItem("__UserInfo__");
|
||||
return data;
|
||||
};
|
||||
|
||||
// 删除用户信息
|
||||
const removeUserInfoCache = () => {
|
||||
_removeItem("__UserInfo__");
|
||||
};
|
||||
|
||||
// 缓存token
|
||||
const setToken = value => {
|
||||
let curDate = new Date();
|
||||
let nextDate = new Date(curDate.getTime() + 24 * 60 * 60 * 1000);
|
||||
|
||||
cookieStorage.setItem("Authorization", value, {
|
||||
domain: document.domain,
|
||||
expires: nextDate
|
||||
});
|
||||
};
|
||||
|
||||
// 获取token
|
||||
const getToken = () => {
|
||||
return cookieStorage.getItem("Authorization");
|
||||
};
|
||||
|
||||
// 删除token
|
||||
const removeToken = () => {
|
||||
cookieStorage.removeItem("Authorization");
|
||||
};
|
||||
|
||||
// 缓存用户权限
|
||||
const setUserPowerCache = arr => {
|
||||
let map = {};
|
||||
for (let i = 0; i < arr.length; i++) {
|
||||
let k = arr[i].powerCode;
|
||||
map[k] = arr[i];
|
||||
}
|
||||
_setItem(`__UserPower_${systemCode}__`, map);
|
||||
};
|
||||
|
||||
// 获取缓存的用户权限
|
||||
const getUserPowerCache = () => {
|
||||
let data = _getItem(`__UserPower_${systemCode}__`);
|
||||
return data;
|
||||
};
|
||||
|
||||
// 获取指定的用户权限
|
||||
const getUserSomeonePowerCache = code => {
|
||||
let data = getUserPowerCache();
|
||||
let item = null;
|
||||
if (data) item = data[code];
|
||||
return item;
|
||||
};
|
||||
|
||||
// 删除用户权限
|
||||
const removeUserPowerCache = () => {
|
||||
_removeItem(`__UserPower_${systemCode}__`);
|
||||
};
|
||||
|
||||
export {
|
||||
randomString,
|
||||
setUserInfoCache,
|
||||
getUserInfoCache,
|
||||
removeUserInfoCache,
|
||||
setToken,
|
||||
getToken,
|
||||
removeToken,
|
||||
setUserPowerCache,
|
||||
getUserPowerCache,
|
||||
removeUserPowerCache,
|
||||
getUserSomeonePowerCache
|
||||
};
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
import Vue from "vue";
|
||||
import App from "./App.vue";
|
||||
import router from "./router";
|
||||
import store from "./store";
|
||||
|
||||
Vue.config.productionTip = false;
|
||||
|
||||
new Vue({
|
||||
router,
|
||||
store,
|
||||
render: h => h(App)
|
||||
}).$mount("#app");
|
||||
@@ -0,0 +1,28 @@
|
||||
import Vue from "vue";
|
||||
import VueRouter from "vue-router";
|
||||
import Home from "../views/Home.vue";
|
||||
|
||||
Vue.use(VueRouter);
|
||||
|
||||
const routes = [
|
||||
{
|
||||
path: "/",
|
||||
name: "Home",
|
||||
component: Home
|
||||
},
|
||||
{
|
||||
path: "/about",
|
||||
name: "About",
|
||||
// route level code-splitting
|
||||
// this generates a separate chunk (about.[hash].js) for this route
|
||||
// which is lazy-loaded when the route is visited.
|
||||
component: () =>
|
||||
import(/* webpackChunkName: "about" */ "../views/About.vue")
|
||||
}
|
||||
];
|
||||
|
||||
const router = new VueRouter({
|
||||
routes
|
||||
});
|
||||
|
||||
export default router;
|
||||
@@ -0,0 +1,11 @@
|
||||
import Vue from "vue";
|
||||
import Vuex from "vuex";
|
||||
|
||||
Vue.use(Vuex);
|
||||
|
||||
export default new Vuex.Store({
|
||||
state: {},
|
||||
mutations: {},
|
||||
actions: {},
|
||||
modules: {}
|
||||
});
|
||||
@@ -0,0 +1,29 @@
|
||||
html,body,#app {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
margin: 0;
|
||||
}
|
||||
h1,h2,h3,h4,h5,p,dl,dt,dd,ol,ul,li {
|
||||
padding: 0;
|
||||
margin: 0
|
||||
}
|
||||
#app {
|
||||
font-family: "Helvetica","Helvetica Neue", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", SimSun, sans-serif;
|
||||
-webkit-font-smoothing: antialiased;
|
||||
-moz-osx-font-smoothing: grayscale;
|
||||
color: #2c3e50;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
@svg 1px-border {
|
||||
height: 2px;
|
||||
@rect {
|
||||
fill: var(--color, black);
|
||||
width: 100%;
|
||||
height: 50%;
|
||||
}
|
||||
}
|
||||
.border-1px {
|
||||
border: 1px solid transparent;
|
||||
border-image: svg(1px-border param(--color #00b1ff)) 2 2 stretch;
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
|
||||
@import "./global.scss";
|
||||
@@ -0,0 +1,5 @@
|
||||
<template>
|
||||
<div class="about">
|
||||
<h1>This is an about page</h1>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,18 @@
|
||||
<template>
|
||||
<div class="home">
|
||||
<img alt="Vue logo" src="../assets/logo.png" />
|
||||
<HelloWorld msg="Welcome to Your Vue.js App" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
// @ is an alias to /src
|
||||
import HelloWorld from "@/components/HelloWorld.vue";
|
||||
|
||||
export default {
|
||||
name: "Home",
|
||||
components: {
|
||||
HelloWorld
|
||||
}
|
||||
};
|
||||
</script>
|
||||
Reference in new issue
Block a user