cretueusebiu / laravel-vue-spa

A Laravel-Vue SPA starter kit.
https://laravel-vue-spa.cretueusebiu.com
MIT License
3.04k stars 961 forks source link

Guide #57

Closed cretueusebiu closed 6 years ago

cretueusebiu commented 6 years ago

Write a quick guide for pages, layouts, routes and middleware.

redaced commented 6 years ago

hello why removed middleware code form source code ?

yeungc commented 6 years ago

Hi, don't think new layout system is a good idea, for example if I have a search bar in top menu and inputted something, old layout system will keep it when I go to next page in same layout, only "child" component will be updated.

It's also not good for performance, even next page have same layout, all elements in body need to generate again.

In my opinions, this change make layout system worse than before.

cretueusebiu commented 6 years ago

@redaced It was removed from routes.js and you have to define it on the component level in order to fix an issue when you click back in your browser and the layout was not changing correctly.

@yeungc You're right about the layout, it's back now. Didn't thought about that. The problem with layouts not changing when you go back was from how the middleware worked before. But it's fixed now.

bhoggett commented 6 years ago

+1 for the Guide. Understanding how a template works is critical to its usefulness.

hobby10 commented 6 years ago

@cretueusebiu .. is there any guide, please ?

hobby10 commented 6 years ago

could i use this project as a web with vuejs and also as a restful api for mobile app ... i tried to make calls using postman for login but i get nothing ?!!

@cretueusebiu advice please

luhegi commented 6 years ago

@cretueusebiu how to make facebook open graph able to get our defined meta?

cretueusebiu commented 6 years ago

@luhegi this project has nothing to do with Facebook.

yob-yob commented 6 years ago

Is Anyone Writing a quick guide?

yob-yob commented 6 years ago

I didn't really understand this part.

  computed: mapGetters({
    user: 'auth/user'
  })

This line of codes can be found in /Resources/assets/js/layouts/default.vue

Can anyone explain?

I wan't to understand it because I want to add a new computed property.

this one:

computed: {
  now: function () {
    return Date.now()
  }
}

I tried to add a new computed property like this but an error will occur

  computed: {
    mapGetters({
      user: 'auth/user'
    }),
    now: function () {
      return Date.now()
    }
  }
cretueusebiu commented 6 years ago

@MerrySean See the vuex docs.

yob-yob commented 6 years ago

@cretueusebiu Hi, I was just wondering where did you get the ".role" in line 4 in this file

laravel-vue-spa/resources/assets/js/middleware/admin.js

because I was looking for it on the user's table which was stored in the database, there was no Role column, I also looked at the model of User, I only saw that you append the "photo_url" but not the Role?

so where did you get it?

cretueusebiu commented 6 years ago

@MerrySean that's not implemented, it's there just as an example.

ZHamsiou commented 6 years ago

Hello, I would like to add a new language but firstly, I don't know how you could add to the drop-down menu the two letters that refer to a certain language. I would like french or Italian as a new language. Secondly, I didn't understand why you had all the textual content in the folder "/public/js/lang-(es or en or zn)" when you can use the js like in the folder "\resources\assets\js\lang". By the way, it's a really good SPA but some comments can be useful.

modemb commented 6 years ago

i have actually added French on my end go to config and add a new language there, it will be added to the drop-down

ZHamsiou commented 6 years ago

Thanks, it's done, but I try to figure out how to bind my js file lang-fr in the public folder so it can display the spa in French. Any advice?

cretueusebiu commented 6 years ago

The translation files should be placed in resources/assets/js/lang in order to be imported with webpack's dynamic import. Then you'll have to defined them in config/app.php.

ZHamsiou commented 6 years ago

Well, there are some probs I had noticed : First, I add the french file that I named "lang-fr.6eef95981ab9638804ce.js" in /public/js, the translation files in resources/assets/js/lang, I defined them in config/app.php like here --> 'locales' => [ 'en' => 'EN', 'zh-CN' => '中文', 'es' => 'ES', 'fr' => 'FR' I also add that in this file : /public/js/app.js --> line 89

script.src = __webpack_require__.p + "js/" + ({"0":"lang-zh-CN","1":"lang-es","2":"lang-en","3":"lang-fr"}

In addition, I update the file /resources/assets/js/componets/Navbar.vue -> line 29

(By the way, I work with wamp) And when I enter in my command line: php artisan serve so I can use the localhost:8000 address. The application makes a long time to process and the result is a full blank page. Can you tell me if I miss something, please ? Secondly, i don't think that the json files in /resources/assets/js/lang are useful. Cause, when you change the content of those files, it that does not effect what you see with the display. The only files that change the text you can see on screen are in the "/public/js" folder
cretueusebiu commented 6 years ago

@ZHamsiou You don't create / update dist files. Those are generated by the build scripts. Just add them as I said in my previous comment.