Add setting for exact date format

This commit is contained in:
lihengxin 2021-09-07 12:56:49 +08:00
parent 94d59c2737
commit 241338975d
6 changed files with 20 additions and 2 deletions

View File

@ -106,7 +106,11 @@ export default {
return filesize(this.size); return filesize(this.size);
}, },
humanTime: function () { humanTime: function () {
// TODO: setting
if (this.user.dateFormat) {
return moment(this.modified).format("YYYY-MM-DD HH:mm"); return moment(this.modified).format("YYYY-MM-DD HH:mm");
}
return moment(this.modified).fromNow();
}, },
dragStart: function () { dragStart: function () {
if (this.selectedCount === 0) { if (this.selectedCount === 0) {

View File

@ -27,6 +27,7 @@
"search": "Search", "search": "Search",
"select": "Select", "select": "Select",
"selectMultiple": "Select multiple", "selectMultiple": "Select multiple",
"setDateFormat": "Set exact date format",
"share": "Share", "share": "Share",
"shell": "Toggle shell", "shell": "Toggle shell",
"submit": "Submit", "submit": "Submit",
@ -214,6 +215,7 @@
"rules": "Rules", "rules": "Rules",
"rulesHelp": "Here you can define a set of allow and disallow rules for this specific user. The blocked files won't show up in the listings and they wont be accessible to the user. We support regex and paths relative to the users scope.\n", "rulesHelp": "Here you can define a set of allow and disallow rules for this specific user. The blocked files won't show up in the listings and they wont be accessible to the user. We support regex and paths relative to the users scope.\n",
"scope": "Scope", "scope": "Scope",
"setDateFormat": "Set exact date format",
"settingsUpdated": "Settings updated!", "settingsUpdated": "Settings updated!",
"shareDuration": "Share Duration", "shareDuration": "Share Duration",
"shareManagement": "Share Management", "shareManagement": "Share Management",

View File

@ -15,6 +15,10 @@
<input type="checkbox" v-model="singleClick" /> <input type="checkbox" v-model="singleClick" />
{{ $t("settings.singleClick") }} {{ $t("settings.singleClick") }}
</p> </p>
<p>
<input type="checkbox" v-model="dateFormat" />
{{ $t("settings.setDateFormat") }}
</p>
<h3>{{ $t("settings.language") }}</h3> <h3>{{ $t("settings.language") }}</h3>
<languages <languages
class="input input--block" class="input input--block"
@ -83,6 +87,7 @@ export default {
passwordConf: "", passwordConf: "",
hideDotfiles: false, hideDotfiles: false,
singleClick: false, singleClick: false,
dateFormat: false,
locale: "", locale: "",
}; };
}, },
@ -107,6 +112,7 @@ export default {
this.locale = this.user.locale; this.locale = this.user.locale;
this.hideDotfiles = this.user.hideDotfiles; this.hideDotfiles = this.user.hideDotfiles;
this.singleClick = this.user.singleClick; this.singleClick = this.user.singleClick;
this.dateFormat = this.user.dateFormat;
}, },
methods: { methods: {
...mapMutations(["updateUser", "setLoading"]), ...mapMutations(["updateUser", "setLoading"]),
@ -135,8 +141,9 @@ export default {
locale: this.locale, locale: this.locale,
hideDotfiles: this.hideDotfiles, hideDotfiles: this.hideDotfiles,
singleClick: this.singleClick, singleClick: this.singleClick,
dateFormat: this.dateFormat,
}; };
await api.update(data, ["locale", "hideDotfiles", "singleClick"]); await api.update(data, ["locale", "hideDotfiles", "singleClick", "dateFormat"]);
this.updateUser(data); this.updateUser(data);
this.$showSuccess(this.$t("settings.settingsUpdated")); this.$showSuccess(this.$t("settings.settingsUpdated"));
} catch (e) { } catch (e) {

View File

@ -28,6 +28,7 @@ type userInfo struct {
Commands []string `json:"commands"` Commands []string `json:"commands"`
LockPassword bool `json:"lockPassword"` LockPassword bool `json:"lockPassword"`
HideDotfiles bool `json:"hideDotfiles"` HideDotfiles bool `json:"hideDotfiles"`
DateFormat bool `json:"dateFormat"`
} }
type authToken struct { type authToken struct {
@ -184,6 +185,7 @@ func printToken(w http.ResponseWriter, _ *http.Request, d *data, user *users.Use
LockPassword: user.LockPassword, LockPassword: user.LockPassword,
Commands: user.Commands, Commands: user.Commands,
HideDotfiles: user.HideDotfiles, HideDotfiles: user.HideDotfiles,
DateFormat: user.DateFormat,
}, },
StandardClaims: jwt.StandardClaims{ StandardClaims: jwt.StandardClaims{
IssuedAt: time.Now().Unix(), IssuedAt: time.Now().Unix(),

View File

@ -16,6 +16,7 @@ type UserDefaults struct {
Perm users.Permissions `json:"perm"` Perm users.Permissions `json:"perm"`
Commands []string `json:"commands"` Commands []string `json:"commands"`
HideDotfiles bool `json:"hideDotfiles"` HideDotfiles bool `json:"hideDotfiles"`
DateFormat bool `json:"dateFormat"`
} }
// Apply applies the default options to a user. // Apply applies the default options to a user.
@ -28,4 +29,5 @@ func (d *UserDefaults) Apply(u *users.User) {
u.Sorting = d.Sorting u.Sorting = d.Sorting
u.Commands = d.Commands u.Commands = d.Commands
u.HideDotfiles = d.HideDotfiles u.HideDotfiles = d.HideDotfiles
u.DateFormat = d.DateFormat
} }

View File

@ -35,6 +35,7 @@ type User struct {
Fs afero.Fs `json:"-" yaml:"-"` Fs afero.Fs `json:"-" yaml:"-"`
Rules []rules.Rule `json:"rules"` Rules []rules.Rule `json:"rules"`
HideDotfiles bool `json:"hideDotfiles"` HideDotfiles bool `json:"hideDotfiles"`
DateFormat bool `json:"dateFormat"`
} }
// GetRules implements rules.Provider. // GetRules implements rules.Provider.