Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import Vue from "nativescript-vue";
- import Vuex from "vuex";
- Vue.use(Vuex);
- import { handleOpenURL } from 'nativescript-urlhandler';
- new Vue({
- mounted() {
- handleOpenURL( (appURL) => {
- console.log(appURL)
- // Settings is the variable that equals the component - in this case settings.
- this.$navigateTo(Settings);
- });
- },
- render: h => h("frame", [h(Home)]),
- store: ccStore
- }).$start();
- import Vue from "nativescript-vue";
- import Vuex from "vuex";
- Vue.use(Vuex);
- ....
- import { handleOpenURL } from 'nativescript-urlhandler';
- import ccStore from './store/store';
- handleOpenURL(function(appURL) {
- // I have hardwired 'Settings' in for testing purposes - but this would be the appURL
- ccStore.dispatch('openAppURL', 'Settings');
- });
- ....
- new Vue({
- render: h => h("frame", [h(Home)]),
- store: ccStore
- }).$start();
- const ccStore = new Vuex.Store({
- state: {
- user: {
- authToken: null,
- refreshToken: null,
- },
- routes: [
- {
- name: "Home",
- component: Home
- },
- {
- name: "Log In",
- component: Login
- },
- ...
- ],
- currentRoute: {
- //INITIALIZE THIS WITH YOUR HOME PAGE
- name: "Home",
- component: Home //COMPONENT
- },
- history: [],
- },
- mutations: {
- navigateTo(state, newRoute, options) {
- state.history.push({
- route: newRoute,
- options
- });
- },
- },
- actions: {
- openAppURL({state, commit}, routeName ) {
- const URL = state.routes[state.routes.map( (route) => {
- return route.name;
- }).indexOf(routeName)];
- return setTimeout(() => {
- commit('navigateTo', URL, { animated: false, clearHistory: true });
- }, 10000);
- },
- ....
- }
- etc....
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement