123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100 |
- /*
- * @Author: xvying 1615026511@qq.com
- * @Date: 2022-10-09 11:40:36
- * @LastEditors: xvying 1615026511@qq.com
- * @LastEditTime: 2022-11-21 13:14:52
- * @FilePath: /party/src/main.js
- * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
- */
- import Vue from "vue";
- import "normalize.css/normalize.css"; // A modern alternative to CSS resets
- import "jquery";
- import ElementUI from "element-ui";
- import "element-ui/lib/theme-chalk/index.css";
- import locale from "element-ui/lib/locale/lang/en"; // lang i18n
- import "@/styles/index.scss"; // global css
- import App from "./App";
- import store from "./store";
- import router from "./router";
- import "@/icons"; // icon
- import "@/permission"; // permission control
- /**
- * If you don't want to use mock-server
- * you want to use MockJs for mock api
- * you can execute: mockXHR()
- *
- * Currently MockJs will be used in the production environment,
- * please remove it before going online ! ! !
- */
- //if (process.env.NODE_ENV === 'production') {
- //const { mockXHR } = require('../mock')
- //mockXHR()
- //}
- Vue.prototype.base_url =
- process.env.ENV === "development"
- ? "http://api.party.site.ximengnaikang.com" // 开发地址
- : process.env.ENV === "production"
- ? "http://api.party.demo.xmnk.cn" // 生产地址
- : "http://api.party.demo.xmnk.cn"; // 测试地址
- // set ElementUI lang to EN
- //Vue.use(ElementUI, { locale })
- // 如果想要中文版 element-ui,按如下方式声明
- Vue.use(ElementUI);
- Vue.config.productionTip = false;
- // 注册 EventBus
- Vue.prototype.$event = new Vue();
- // 注册全局自定义快速读取 excel `v-read-excel`
- Vue.directive("read-excel", {
- inserted: (el, { value }) => {
- const id = Date.now();
- const input = document.createElement("input");
- el["read-excel-id"] = id;
- input.id = id;
- input.type = "file";
- input.accept = ".xlsx, .xls";
- input.style.display = "none";
- document.body.appendChild(input);
- input.onchange = ({
- target: {
- files: [excel],
- },
- }) => {
- try {
- const XLSX = require("xlsx");
- const reader = new FileReader();
- reader.onload = async ({ target: { result } }) => {
- const workbook = XLSX.read(result, { type: "array" });
- value &&
- value(
- XLSX.utils.sheet_to_json(workbook.Sheets[workbook.SheetNames[0]])
- );
- };
- reader.readAsArrayBuffer(excel);
- } catch (e) {
- console.log(e);
- this.$message.error("上传文件失败,请刷新重试");
- }
- };
- el.addEventListener("click", () => {
- input.value = "";
- input.click();
- });
- },
- unbind: (el) => document.getElementById(el["read-excel-id"]).remove(),
- });
- new Vue({
- el: "#app",
- router,
- store,
- render: (h) => h(App),
- });
|