Browse Source

fix require() actually not working after build in the frontend

pull/64/head
LouisLam 4 years ago
parent
commit
dfa9b3a0ca
  1. 8
      server/util.js
  2. 2
      src/components/CountUp.vue
  3. 2
      src/components/NotificationDialog.vue
  4. 13
      src/util-frontend.js

8
server/util.js

@ -1,9 +1,5 @@
/*
* Common functions - can be used in frontend or backend
*/
// Common JS cannot be used in frontend sadly
// sleep, ucfirst is duplicated in ../src/util-frontend.js
exports.sleep = function (ms) {
return new Promise(resolve => setTimeout(resolve, ms));

2
src/components/CountUp.vue

@ -5,7 +5,7 @@
<script>
const {sleep} = require("../../server/util")
import {sleep} from '../util-frontend'
export default {

2
src/components/NotificationDialog.vue

@ -220,7 +220,7 @@
<script>
import { Modal } from 'bootstrap'
const {ucfirst} = require("../../server/util")
import { ucfirst } from '../util-frontend'
import axios from "axios";
import { useToast } from 'vue-toastification'
import Confirm from "./Confirm.vue";

13
src/util-frontend.js

@ -5,6 +5,19 @@ import timezone from 'dayjs/plugin/timezone'
dayjs.extend(utc)
dayjs.extend(timezone)
export function sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
export function ucfirst(str) {
if (! str) {
return str;
}
const firstLetter = str.substr(0, 1);
return firstLetter.toUpperCase() + str.substr(1);
}
function getTimezoneOffset(timeZone) {
const now = new Date();

Loading…
Cancel
Save