Skip to content

[Code scan] Restore the saved language from storage instead of overwriting it #563

Description

@njzjz

This issue was found during a Codex global code scan of the repository.

Baseline commit: e3c5b38

Problem

The mounted hook calls the storage setter when it appears to intend to read the saved language.

Code references:

dpgui/src/App.vue

Lines 101 to 103 in e3c5b38

mounted: function () {
this.$i18n.locale =
this.$storage.setStorageSync("lang") || this.$i18n.locale;

dpgui/src/App.vue

Lines 208 to 211 in e3c5b38

updatelang: function (value) {
this.$i18n.locale = value;
this.$storage.setStorageSync("lang", value);
this.update_navi();

Relevant snippet:

this.$i18n.locale =
  this.$storage.setStorageSync("lang") || this.$i18n.locale;

Impact

A previously selected language is not restored on reload. Depending on the storage helper behavior, the call may also overwrite the saved lang value with an empty value.

Suggested fix

Use getStorageSync("lang") in mounted() and keep setStorageSync("lang", value) only in the language update handler.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    Status
    Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions