2019-12-05 02:13:42 +00:00
|
|
|
import "core-js/stable";
|
|
|
|
import "regenerator-runtime/runtime";
|
2019-05-09 04:48:10 +00:00
|
|
|
import Api from "common/api";
|
2019-11-16 22:55:56 +00:00
|
|
|
import Notify from "common/notify";
|
2019-05-21 09:54:39 +00:00
|
|
|
import Clipboard from "common/clipboard";
|
2019-05-28 00:50:22 +00:00
|
|
|
import Components from "component/components";
|
2019-06-30 00:52:12 +00:00
|
|
|
import Dialogs from "dialog/dialogs";
|
2019-11-16 21:41:14 +00:00
|
|
|
import Event from "pubsub-js";
|
|
|
|
import GetTextPlugin from "vue-gettext";
|
2019-12-02 01:43:41 +00:00
|
|
|
import Log from "common/log";
|
2019-11-16 21:41:14 +00:00
|
|
|
import PhotoPrism from "photoprism.vue";
|
|
|
|
import Router from "vue-router";
|
|
|
|
import Routes from "routes";
|
2020-04-23 12:30:28 +00:00
|
|
|
import {config, session} from "session";
|
2019-11-17 13:24:48 +00:00
|
|
|
import {Settings} from "luxon";
|
2019-11-16 21:41:14 +00:00
|
|
|
import Socket from "common/websocket";
|
|
|
|
import Viewer from "common/viewer";
|
|
|
|
import Vue from "vue";
|
|
|
|
import Vuetify from "vuetify";
|
2019-09-19 21:23:39 +00:00
|
|
|
import VueLuxon from "vue-luxon";
|
2019-06-09 02:37:02 +00:00
|
|
|
import VueFilters from "vue2-filters";
|
2019-11-16 21:41:14 +00:00
|
|
|
import VueFullscreen from "vue-fullscreen";
|
|
|
|
import VueInfiniteScroll from "vue-infinite-scroll";
|
2020-05-20 08:42:48 +00:00
|
|
|
import VueModal from "vue-js-modal";
|
2020-05-13 13:36:42 +00:00
|
|
|
import Hls from "hls.js";
|
2018-07-27 15:31:39 +00:00
|
|
|
|
2019-05-21 09:54:39 +00:00
|
|
|
// Initialize helpers
|
|
|
|
const viewer = new Viewer();
|
|
|
|
const clipboard = new Clipboard(window.localStorage, "photo_clipboard");
|
2020-04-26 12:31:33 +00:00
|
|
|
const isPublic = config.get("public");
|
2018-07-27 15:31:39 +00:00
|
|
|
|
2020-05-13 13:36:42 +00:00
|
|
|
// HTTP Live Streaming (video support)
|
|
|
|
window.Hls = Hls;
|
|
|
|
|
2019-05-21 09:54:39 +00:00
|
|
|
// Assign helpers to VueJS prototype
|
2018-07-27 15:31:39 +00:00
|
|
|
Vue.prototype.$event = Event;
|
2019-11-16 22:55:56 +00:00
|
|
|
Vue.prototype.$notify = Notify;
|
2019-05-21 09:54:39 +00:00
|
|
|
Vue.prototype.$viewer = viewer;
|
2020-01-23 06:39:04 +00:00
|
|
|
Vue.prototype.$session = session;
|
2018-07-27 15:31:39 +00:00
|
|
|
Vue.prototype.$api = Api;
|
2019-12-02 01:43:41 +00:00
|
|
|
Vue.prototype.$log = Log;
|
2019-11-16 15:06:34 +00:00
|
|
|
Vue.prototype.$socket = Socket;
|
2018-09-13 08:23:06 +00:00
|
|
|
Vue.prototype.$config = config;
|
2019-05-21 09:54:39 +00:00
|
|
|
Vue.prototype.$clipboard = clipboard;
|
2020-04-23 12:30:28 +00:00
|
|
|
Vue.prototype.$isMobile = (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent));
|
2018-07-27 15:31:39 +00:00
|
|
|
|
2019-05-07 00:05:01 +00:00
|
|
|
// Register Vuetify
|
2020-01-20 11:20:54 +00:00
|
|
|
Vue.use(Vuetify, {"theme": config.theme});
|
2018-09-06 21:58:16 +00:00
|
|
|
|
2019-12-02 18:03:41 +00:00
|
|
|
Vue.config.language = config.values.settings.language;
|
|
|
|
Settings.defaultLocale = config.values.settings.language;
|
2019-09-19 21:23:39 +00:00
|
|
|
|
2019-05-07 00:05:01 +00:00
|
|
|
// Register other VueJS plugins
|
2020-01-20 11:20:54 +00:00
|
|
|
Vue.use(GetTextPlugin, {
|
|
|
|
translations: config.translations,
|
2020-01-31 14:29:06 +00:00
|
|
|
silent: true, // !config.values.debug,
|
2020-01-20 11:20:54 +00:00
|
|
|
defaultLanguage: Vue.config.language,
|
|
|
|
});
|
|
|
|
|
2019-09-19 21:23:39 +00:00
|
|
|
Vue.use(VueLuxon);
|
2019-06-09 02:37:02 +00:00
|
|
|
Vue.use(VueInfiniteScroll);
|
2018-09-25 07:45:06 +00:00
|
|
|
Vue.use(VueFullscreen);
|
2020-05-20 08:42:48 +00:00
|
|
|
Vue.use(VueModal, { dynamic: true, dynamicDefaults: { clickToClose: true } });
|
2019-06-09 02:37:02 +00:00
|
|
|
Vue.use(VueFilters);
|
2019-05-07 00:05:01 +00:00
|
|
|
Vue.use(Components);
|
2019-06-30 00:52:12 +00:00
|
|
|
Vue.use(Dialogs);
|
2018-07-27 15:31:39 +00:00
|
|
|
Vue.use(Router);
|
|
|
|
|
2019-05-07 00:05:01 +00:00
|
|
|
// Configure client-side routing
|
2018-07-27 15:31:39 +00:00
|
|
|
const router = new Router({
|
2019-05-19 16:58:30 +00:00
|
|
|
routes: Routes,
|
2019-05-09 04:48:10 +00:00
|
|
|
mode: "history",
|
2018-07-27 15:31:39 +00:00
|
|
|
saveScrollPosition: true,
|
|
|
|
});
|
|
|
|
|
2019-11-08 05:53:40 +00:00
|
|
|
router.beforeEach((to, from, next) => {
|
2019-11-17 13:24:48 +00:00
|
|
|
if (to.matched.some(record => record.meta.admin)) {
|
2020-01-23 06:39:04 +00:00
|
|
|
if (isPublic || session.isAdmin()) {
|
2019-11-08 05:53:40 +00:00
|
|
|
next();
|
|
|
|
} else {
|
|
|
|
next({
|
|
|
|
name: "login",
|
2019-11-17 13:24:48 +00:00
|
|
|
params: {nextUrl: to.fullPath},
|
2019-11-08 05:53:40 +00:00
|
|
|
});
|
|
|
|
}
|
2019-11-17 13:24:48 +00:00
|
|
|
} else if (to.matched.some(record => record.meta.auth)) {
|
2020-01-23 06:39:04 +00:00
|
|
|
if (isPublic || session.isUser()) {
|
2019-11-08 05:53:40 +00:00
|
|
|
next();
|
|
|
|
} else {
|
|
|
|
next({
|
|
|
|
name: "login",
|
2019-11-17 13:24:48 +00:00
|
|
|
params: {nextUrl: to.fullPath},
|
2019-11-08 05:53:40 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
next();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2020-01-20 11:20:54 +00:00
|
|
|
router.afterEach((to) => {
|
|
|
|
if (to.meta.title) {
|
|
|
|
config.page.title = to.meta.title;
|
2020-05-31 00:09:52 +00:00
|
|
|
window.document.title = config.values.siteTitle + ": " + to.meta.title;
|
2020-01-20 11:20:54 +00:00
|
|
|
} else {
|
|
|
|
config.page.title = "";
|
2020-05-31 10:52:41 +00:00
|
|
|
window.document.title = config.values.siteTitle + ": " + config.values.siteCaption;
|
2020-01-20 11:20:54 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2019-05-07 00:05:01 +00:00
|
|
|
// Run app
|
2019-11-17 13:24:48 +00:00
|
|
|
new Vue({
|
2018-07-27 15:31:39 +00:00
|
|
|
router,
|
2019-05-19 16:58:30 +00:00
|
|
|
render: h => h(PhotoPrism),
|
2019-11-17 13:24:48 +00:00
|
|
|
}).$mount("#photoprism");
|