Advertisement
Guest User

Untitled

a guest
Jun 16th, 2019
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.99 KB | None | 0 0
  1. import Vue from "nativescript-vue";
  2. import Vuex from "vuex";
  3. Vue.use(Vuex);
  4.  
  5. import { handleOpenURL } from 'nativescript-urlhandler';
  6.  
  7. new Vue({
  8. mounted() {
  9. handleOpenURL( (appURL) => {
  10. console.log(appURL)
  11. // Settings is the variable that equals the component - in this case settings.
  12. this.$navigateTo(Settings);
  13. });
  14. },
  15. render: h => h("frame", [h(Home)]),
  16. store: ccStore
  17. }).$start();
  18.  
  19. import Vue from "nativescript-vue";
  20. import Vuex from "vuex";
  21. Vue.use(Vuex);
  22. ....
  23. import { handleOpenURL } from 'nativescript-urlhandler';
  24. import ccStore from './store/store';
  25.  
  26.  
  27. handleOpenURL(function(appURL) {
  28. // I have hardwired 'Settings' in for testing purposes - but this would be the appURL
  29. ccStore.dispatch('openAppURL', 'Settings');
  30. });
  31.  
  32. ....
  33.  
  34. new Vue({
  35. render: h => h("frame", [h(Home)]),
  36. store: ccStore
  37. }).$start();
  38.  
  39. const ccStore = new Vuex.Store({
  40. state: {
  41. user: {
  42. authToken: null,
  43. refreshToken: null,
  44. },
  45. routes: [
  46. {
  47. name: "Home",
  48. component: Home
  49. },
  50. {
  51. name: "Log In",
  52. component: Login
  53. },
  54. ...
  55. ],
  56. currentRoute: {
  57. //INITIALIZE THIS WITH YOUR HOME PAGE
  58. name: "Home",
  59. component: Home //COMPONENT
  60. },
  61. history: [],
  62. },
  63. mutations: {
  64. navigateTo(state, newRoute, options) {
  65. state.history.push({
  66. route: newRoute,
  67. options
  68. });
  69. },
  70. },
  71. actions: {
  72. openAppURL({state, commit}, routeName ) {
  73. const URL = state.routes[state.routes.map( (route) => {
  74. return route.name;
  75. }).indexOf(routeName)];
  76.  
  77. return setTimeout(() => {
  78. commit('navigateTo', URL, { animated: false, clearHistory: true });
  79. }, 10000);
  80. },
  81. ....
  82. }
  83. etc....
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement