Get 2024 Templates Mega Bundle!14 Bootstrap, Vue & React Templates + 3 Vector Sets
Get for 99$

I need to use store in core/config/DefaultLayoutConfig.ts file


I need to set the logo path from the store.
I have tried to import store on core/config/DefaultLayoutConfig.ts this file but it returns the error
"Uncaught ReferenceError: Cannot access '__WEBPACK_DEFAULT_EXPORT__' before initialization"

Please help me with above issue.

Thank you!


Text formatting options
Submit
Here's a how to add some HTML formatting to your comment:
  • <pre></pre> for JS codes block
  • <pre lang="html"></pre> for HTML code block
  • <pre lang="scss"></pre> for SCSS code block
  • <pre lang="php"></pre> for PHP code block
  • <code></code> for single line of code
  • <strong></strong> to make things bold
  • <em></em> to emphasize
  • <ul><li></li></ul>  to make list
  • <ol><li></li></ol>  to make ordered list
  • <h3></h3> to make headings
  • <a></a> for links
  • <img> to paste in an image
  • <blockquote></blockquote> to quote somebody
  • happy  :)
  • shocked  :|
  • sad  :(

Replies (3)


Hi Kishan,

Could you please attach a code that throws an error?

Here is an example of how you can access a Vuex store.

const store = useStore()

const store_value = computed(() => store.state.your_store_variable),


Check out Vuex official doc for more info. https://vuex.vuejs.org/

Regards,
Lauris Stepanovs,
Keenthemes Support Team



import LayoutConfigTypes from "@/core/config/LayoutConfigTypes";
import store from "@/store";
console.log(store);

const config: LayoutConfigTypes = {
themeName: "Metronic",
themeVersion: "8.1.1",
demo: "demo1",
main: {
type: "default",
primaryColor: "#009EF7",
logo: {
dark: "/media/logos/ops_logo.png",
light: "/media/logos/ops_logo.png",
},
},
illustrations: {
set: "dozzy-1",
},
loader: {
logo: "/media/logos/ops_logo.png",
display: true,
type: "spinner-message",
},
scrollTop: {
display: true,
},
header: {
display: true,
menuIcon: "font",
width: "fluid",
fixed: {
desktop: true,
tabletAndMobile: true,
},
},
toolbar: {
display: true,
width: "fluid",
fixed: {
desktop: true,
tabletAndMobile: true,
},
},
aside: {
display: true,
theme: "light",
fixed: true,
menuIcon: "font",
minimized: false,
minimize: true,
hoverable: true,
},
content: {
width: "fluid",
},
footer: {
width: "fluid",
},
};

export default config;


-------------------------------------------------------------------------------------------

Here I have added just the 2nd and 3rd lines to get the store object but it returns an error that I sent already.

above code is "/src/core/config/DefaultLayoutConfig.ts" file.

Please understand my issue properly and get back to us as this is very urgent and needs to be fixed ASAP.

Please let me know if you need anything else from me.

Thank you!



Hi,

This approach will not work since code from DefaultLayoutConfig.ts will be executed before the store is created. Instead of getting value directly in DefaultLayoutConfig.ts, you can override them using a mutation. For example, in the config you can set some default logo value, then on the first-page load, you can override this default value with a variable from your store.

To override a logo property you can use the mutation below:

store.commit(Mutations.SET_LAYOUT_CONFIG_PROPERTY, {
property: "config.property.to.override",
value: value_from_your_store,
});


Regards,
Lauris Stepanovs,
Keenthemes Support Team


Text formatting options
Submit
Here's a how to add some HTML formatting to your comment:
  • <pre></pre> for JS codes block
  • <pre lang="html"></pre> for HTML code block
  • <pre lang="scss"></pre> for SCSS code block
  • <pre lang="php"></pre> for PHP code block
  • <code></code> for single line of code
  • <strong></strong> to make things bold
  • <em></em> to emphasize
  • <ul><li></li></ul>  to make list
  • <ol><li></li></ol>  to make ordered list
  • <h3></h3> to make headings
  • <a></a> for links
  • <img> to paste in an image
  • <blockquote></blockquote> to quote somebody
  • happy  :)
  • shocked  :|
  • sad  :(
Text formatting options
Submit
Here's a how to add some HTML formatting to your comment:
  • <pre></pre> for JS codes block
  • <pre lang="html"></pre> for HTML code block
  • <pre lang="scss"></pre> for SCSS code block
  • <pre lang="php"></pre> for PHP code block
  • <code></code> for single line of code
  • <strong></strong> to make things bold
  • <em></em> to emphasize
  • <ul><li></li></ul>  to make list
  • <ol><li></li></ol>  to make ordered list
  • <h3></h3> to make headings
  • <a></a> for links
  • <img> to paste in an image
  • <blockquote></blockquote> to quote somebody
  • happy  :)
  • shocked  :|
  • sad  :(