refactor: switching to the use of typed props

This commit is contained in:
Shishkevich D. 2025-03-08 14:39:25 +00:00
parent c6d27a4463
commit 3f0a911c80
11 changed files with 126 additions and 56 deletions

View file

@ -461,7 +461,7 @@
</a-form-item> </a-form-item>
<a-form-item> <a-form-item>
<a-row justify="center" class="centered"> <a-row justify="center" class="centered">
<theme-switch-login></theme-switch-login> <a-theme-switch-login></a-theme-switch-login>
</a-row> </a-row>
</a-form-item> </a-form-item>
</a-form> </a-form>

View file

@ -106,9 +106,9 @@
<a-date-picker v-if="datepicker == 'gregorian'" :show-time="{ format: 'HH:mm:ss' }" <a-date-picker v-if="datepicker == 'gregorian'" :show-time="{ format: 'HH:mm:ss' }"
format="YYYY-MM-DD HH:mm:ss" :dropdown-class-name="themeSwitcher.currentTheme" format="YYYY-MM-DD HH:mm:ss" :dropdown-class-name="themeSwitcher.currentTheme"
v-model="clientsBulkModal.expiryTime"></a-date-picker> v-model="clientsBulkModal.expiryTime"></a-date-picker>
<persian-datepicker v-else placeholder='{{ i18n "pages.settings.datepickerPlaceholder" }}' <a-persian-datepicker v-else placeholder='{{ i18n "pages.settings.datepickerPlaceholder" }}'
value="clientsBulkModal.expiryTime" v-model="clientsBulkModal.expiryTime"> value="clientsBulkModal.expiryTime" v-model="clientsBulkModal.expiryTime">
</persian-datepicker> </a-persian-datepicker>
</a-form-item> </a-form-item>
<a-form-item v-if="clientsBulkModal.expiryTime != 0"> <a-form-item v-if="clientsBulkModal.expiryTime != 0">
<template slot="label"> <template slot="label">

View file

@ -34,7 +34,7 @@
{{define "commonSider"}} {{define "commonSider"}}
<a-layout-sider :theme="themeSwitcher.currentTheme" id="sider" collapsible breakpoint="md"> <a-layout-sider :theme="themeSwitcher.currentTheme" id="sider" collapsible breakpoint="md">
<theme-switch></theme-switch> <a-theme-switch></a-theme-switch>
<a-menu :theme="themeSwitcher.currentTheme" mode="inline" :selected-keys="['{{ .request_uri }}']" @click="({key}) => key.startsWith('http') ? window.open(key) : location.href = key"> <a-menu :theme="themeSwitcher.currentTheme" mode="inline" :selected-keys="['{{ .request_uri }}']" @click="({key}) => key.startsWith('http') ? window.open(key) : location.href = key">
{{template "menuItems" .}} {{template "menuItems" .}}
</a-menu> </a-menu>
@ -43,7 +43,7 @@
<div class="drawer-handle" @click="siderDrawer.change()" slot="handle"> <div class="drawer-handle" @click="siderDrawer.change()" slot="handle">
<a-icon :type="siderDrawer.visible ? 'close' : 'menu-fold'"></a-icon> <a-icon :type="siderDrawer.visible ? 'close' : 'menu-fold'"></a-icon>
</div> </div>
<theme-switch></theme-switch> <a-theme-switch></a-theme-switch>
<a-menu :theme="themeSwitcher.currentTheme" mode="inline" :selected-keys="['{{ .request_uri }}']" @click="({key}) => key.startsWith('http') ? window.open(key) : location.href = key"> <a-menu :theme="themeSwitcher.currentTheme" mode="inline" :selected-keys="['{{ .request_uri }}']" @click="({key}) => key.startsWith('http') ? window.open(key) : location.href = key">
{{template "menuItems" .}} {{template "menuItems" .}}
</a-menu> </a-menu>

View file

@ -1,26 +1,46 @@
{{define "component/passwordInput"}} {{define "component/passwordInput"}}
<template> <template>
<a-input :value="value" :type="showPassword ? 'text' : 'password'" <a-input :value="value" :type="showPassword ? 'text' : 'password'" :placeholder="placeholder"
:placeholder="placeholder" :autocomplete="autocomplete" :name="name" @input="$emit('input', $event.target.value)">
:autocomplete="autocomplete" <template v-if="icon" #prefix>
:name="name" <a-icon :type="icon" style="font-size: 16px;" />
@input="$emit('input', $event.target.value)"> </template>
<template v-if="icon" #prefix> <template #addonAfter>
<a-icon :type="icon" style="font-size: 16px;" /> <a-icon :type="showPassword ? 'eye-invisible' : 'eye'" @click="toggleShowPassword" style="font-size: 16px;" />
</template> </template>
<template #addonAfter> </a-input>
<a-icon :type="showPassword ? 'eye-invisible' : 'eye'"
@click="toggleShowPassword"
style="font-size: 16px;" />
</template>
</a-input>
</template> </template>
{{end}} {{end}}
{{define "component/password"}} {{define "component/password"}}
<script> <script>
Vue.component('password-input', { Vue.component('password-input', {
props: ["title", "value", "placeholder", "icon", "autocomplete", "name"], props: {
'title': {
type: String,
required: false,
},
'value': {
type: String,
required: false,
},
'placeholder': {
type: String,
required: false,
},
'autocomplete': {
type: String,
required: false,
},
'name': {
type: String,
required: false,
},
'icon': {
type: undefined,
required: false
}
},
template: `{{template "component/passwordInput"}}`, template: `{{template "component/passwordInput"}}`,
data() { data() {
return { return {

View file

@ -2,10 +2,10 @@
<template> <template>
<div> <div>
<a-input :value="value" type="text" v-model="date" data-jdp class="persian-datepicker" <a-input :value="value" type="text" v-model="date" data-jdp class="persian-datepicker"
@input="$emit('input', convertToGregorian($event.target.value)); jalaliDatepicker.hide();" @input="$emit('input', convertToGregorian($event.target.value)); jalaliDatepicker.hide();"
:placeholder="placeholder"> :placeholder="placeholder">
<template #addonAfter> <template #addonAfter>
<a-icon type="calendar" style="font-size: 14px; opacity: 0.5;"/> <a-icon type="calendar" style="font-size: 14px; opacity: 0.5;" />
</template> </template>
</a-input> </a-input>
</div> </div>
@ -13,15 +13,27 @@
{{end}} {{end}}
{{define "component/persianDatepicker"}} {{define "component/persianDatepicker"}}
<link rel="stylesheet" href="{{ .base_path }}assets/persian-datepicker/persian-datepicker.min.css?{{ .cur_ver }}"/> <link rel="stylesheet" href="{{ .base_path }}assets/persian-datepicker/persian-datepicker.min.css?{{ .cur_ver }}" />
<script src="{{ .base_path }}assets/moment/moment-jalali.min.js?{{ .cur_ver }}"></script> <script src="{{ .base_path }}assets/moment/moment-jalali.min.js?{{ .cur_ver }}"></script>
<script src="{{ .base_path }}assets/persian-datepicker/persian-datepicker.min.js?{{ .cur_ver }}"></script> <script src="{{ .base_path }}assets/persian-datepicker/persian-datepicker.min.js?{{ .cur_ver }}"></script>
<script> <script>
const persianDatepicker = {}; const persianDatepicker = {};
Vue.component('persian-datepicker', { Vue.component('a-persian-datepicker', {
props: ['placeholder', 'format', 'value'], props: {
'format': {
type: undefined,
required: false,
},
'value': {
type: String,
required: false,
},
'placeholder': {
type: String,
required: false,
},
},
template: `{{template "component/persianDatepickerTemplate"}}`, template: `{{template "component/persianDatepickerTemplate"}}`,
data() { data() {
return { return {

View file

@ -21,7 +21,24 @@
{{define "component/setting"}} {{define "component/setting"}}
<script> <script>
Vue.component('a-setting-list-item', { Vue.component('a-setting-list-item', {
props: ["title", "description", "paddings"], props: {
'title': {
type: String,
required: true,
},
'description': {
type: String,
required: false,
},
'paddings': {
type: String,
required: false,
defaultValue: "default",
validator: function (value) {
return ['small', 'default'].includes(value)
}
}
},
template: `{{ template "component/settingListItem" }}`, template: `{{ template "component/settingListItem" }}`,
computed: { computed: {
padding() { padding() {
@ -29,7 +46,7 @@
case "small": case "small":
return "10px 20px !important" return "10px 20px !important"
break; break;
default: case "default":
return "20px !important" return "20px !important"
break; break;
} }

View file

@ -1,9 +1,5 @@
{{define "component/sortableTableTrigger"}} {{define "component/sortableTableTrigger"}}
<a-icon type="drag" <a-icon type="drag" class="sortable-icon" style="cursor: move;" @mouseup="mouseUpHandler" @mousedown="mouseDownHandler"
class="sortable-icon"
style="cursor: move;"
@mouseup="mouseUpHandler"
@mousedown="mouseDownHandler"
@click="clickHandler" /> @click="clickHandler" />
{{end}} {{end}}
@ -28,7 +24,16 @@
newElementIndex: null, newElementIndex: null,
}; };
}, },
props: ['data-source', 'customRow'], props: {
'data-source': {
type: undefined,
required: false,
},
'customRow': {
type: undefined,
required: false,
}
},
inheritAttrs: false, inheritAttrs: false,
provide() { provide() {
const sortable = {} const sortable = {}
@ -44,7 +49,7 @@
sortable, sortable,
} }
}, },
render: function(createElement) { render: function (createElement) {
return createElement('a-table', { return createElement('a-table', {
class: { class: {
'ant-table-is-sorting': this.isDragging(), 'ant-table-is-sorting': this.isDragging(),
@ -59,7 +64,7 @@
drop: (e) => this.dropHandler(e), drop: (e) => this.dropHandler(e),
}, },
scopedSlots: this.$scopedSlots, scopedSlots: this.$scopedSlots,
}, this.$slots.default, ) }, this.$slots.default,)
}, },
created() { created() {
this.$memoSort = {}; this.$memoSort = {};
@ -163,9 +168,14 @@
} }
} }
}); });
Vue.component('table-sort-trigger', { Vue.component('a-table-sort-trigger', {
template: `{{template "component/sortableTableTrigger"}}`, template: `{{template "component/sortableTableTrigger"}}`,
props: ['item-index'], props: {
'item-index': {
type: undefined,
required: false
}
},
inject: ['sortable'], inject: ['sortable'],
methods: { methods: {
mouseDownHandler(e) { mouseDownHandler(e) {
@ -190,25 +200,31 @@
display: none; display: none;
} }
} }
.ant-table-is-sorting .draggable-row td { .ant-table-is-sorting .draggable-row td {
background-color: #ffffff !important; background-color: #ffffff !important;
} }
.dark .ant-table-is-sorting .draggable-row td { .dark .ant-table-is-sorting .draggable-row td {
background-color: var(--dark-color-surface-100) !important; background-color: var(--dark-color-surface-100) !important;
} }
.ant-table-is-sorting .dragging td { .ant-table-is-sorting .dragging td {
background-color: rgb(232 244 242) !important; background-color: rgb(232 244 242) !important;
color: rgba(0, 0, 0, 0.3); color: rgba(0, 0, 0, 0.3);
} }
.dark .ant-table-is-sorting .dragging td { .dark .ant-table-is-sorting .dragging td {
background-color: var(--dark-color-table-hover) !important; background-color: var(--dark-color-table-hover) !important;
color: rgba(255, 255, 255, 0.3); color: rgba(255, 255, 255, 0.3);
} }
.ant-table-is-sorting .dragging { .ant-table-is-sorting .dragging {
opacity: 1; opacity: 1;
box-shadow: 1px -2px 2px #008771; box-shadow: 1px -2px 2px #008771;
transition: all 0.2s; transition: all 0.2s;
} }
.ant-table-is-sorting .dragging .ant-table-row-index { .ant-table-is-sorting .dragging .ant-table-row-index {
opacity: 0.3; opacity: 0.3;
} }

View file

@ -6,9 +6,13 @@
<a-icon type="bulb" :theme="themeSwitcher.isDarkTheme ? 'filled' : 'outlined'"></a-icon> <a-icon type="bulb" :theme="themeSwitcher.isDarkTheme ? 'filled' : 'outlined'"></a-icon>
<span>Theme</span> <span>Theme</span>
</span> </span>
<a-menu-item id="change-theme" class="ant-menu-theme-switch" @mousedown="themeSwitcher.animationsOff()"> Dark <a-switch style="margin-left: 2px;" size="small" :default-checked="themeSwitcher.isDarkTheme" @change="themeSwitcher.toggleTheme()"></a-switch> <a-menu-item id="change-theme" class="ant-menu-theme-switch" @mousedown="themeSwitcher.animationsOff()"> Dark
<a-switch style="margin-left: 2px;" size="small" :default-checked="themeSwitcher.isDarkTheme"
@change="themeSwitcher.toggleTheme()"></a-switch>
</a-menu-item> </a-menu-item>
<a-menu-item id="change-theme-ultra" v-if="themeSwitcher.isDarkTheme" class="ant-menu-theme-switch" @mousedown="themeSwitcher.animationsOffUltra()"> Ultra <a-checkbox style="margin-left: 2px;" :checked="themeSwitcher.isUltra" @click="themeSwitcher.toggleUltra()"></a-checkbox> <a-menu-item id="change-theme-ultra" v-if="themeSwitcher.isDarkTheme" class="ant-menu-theme-switch"
@mousedown="themeSwitcher.animationsOffUltra()"> Ultra <a-checkbox style="margin-left: 2px;"
:checked="themeSwitcher.isUltra" @click="themeSwitcher.toggleUltra()"></a-checkbox>
</a-menu-item> </a-menu-item>
</a-sub-menu> </a-sub-menu>
</a-menu> </a-menu>
@ -17,12 +21,15 @@
{{define "component/themeSwitchTemplateLogin"}} {{define "component/themeSwitchTemplateLogin"}}
<template> <template>
<a-menu @mousedown="themeSwitcher.animationsOff()" id="change-theme" :theme="themeSwitcher.currentTheme" mode="inline" selected-keys=""> <a-menu @mousedown="themeSwitcher.animationsOff()" id="change-theme" :theme="themeSwitcher.currentTheme" mode="inline"
selected-keys="">
<a-menu-item mode="inline" class="ant-menu-theme-switch"> <a-menu-item mode="inline" class="ant-menu-theme-switch">
<a-icon type="bulb" :theme="themeSwitcher.isDarkTheme ? 'filled' : 'outlined'"></a-icon> <a-icon type="bulb" :theme="themeSwitcher.isDarkTheme ? 'filled' : 'outlined'"></a-icon>
<a-switch size="small" :default-checked="themeSwitcher.isDarkTheme" @change="themeSwitcher.toggleTheme()"></a-switch> <a-switch size="small" :default-checked="themeSwitcher.isDarkTheme"
@change="themeSwitcher.toggleTheme()"></a-switch>
<template v-if="themeSwitcher.isDarkTheme"> <template v-if="themeSwitcher.isDarkTheme">
<a-checkbox style="margin-left: 1rem; vertical-align: middle;" :checked="themeSwitcher.isUltra" @click="themeSwitcher.toggleUltra()">Ultra</a-checkbox> <a-checkbox style="margin-left: 1rem; vertical-align: middle;" :checked="themeSwitcher.isUltra"
@click="themeSwitcher.toggleUltra()">Ultra</a-checkbox>
</template> </template>
</a-menu-item> </a-menu-item>
</a-menu> </a-menu>
@ -83,8 +90,7 @@
}; };
} }
const themeSwitcher = createThemeSwitcher(); const themeSwitcher = createThemeSwitcher();
Vue.component('theme-switch', { Vue.component('a-theme-switch', {
props: [],
template: `{{template "component/themeSwitchTemplate"}}`, template: `{{template "component/themeSwitchTemplate"}}`,
data: () => ({ data: () => ({
themeSwitcher themeSwitcher
@ -96,8 +102,7 @@
document.getElementById('message').className = themeSwitcher.currentTheme; document.getElementById('message').className = themeSwitcher.currentTheme;
} }
}); });
Vue.component('theme-switch-login', { Vue.component('a-theme-switch-login', {
props: [],
template: `{{template "component/themeSwitchTemplateLogin"}}`, template: `{{template "component/themeSwitchTemplateLogin"}}`,
data: () => ({ data: () => ({
themeSwitcher themeSwitcher

View file

@ -154,8 +154,8 @@
</template> </template>
<a-date-picker v-if="datepicker == 'gregorian'" :show-time="{ format: 'HH:mm:ss' }" format="YYYY-MM-DD HH:mm:ss" <a-date-picker v-if="datepicker == 'gregorian'" :show-time="{ format: 'HH:mm:ss' }" format="YYYY-MM-DD HH:mm:ss"
:dropdown-class-name="themeSwitcher.currentTheme" v-model="client._expiryTime"></a-date-picker> :dropdown-class-name="themeSwitcher.currentTheme" v-model="client._expiryTime"></a-date-picker>
<persian-datepicker v-else placeholder='{{ i18n "pages.settings.datepickerPlaceholder" }}' <a-persian-datepicker v-else placeholder='{{ i18n "pages.settings.datepickerPlaceholder" }}'
value="client._expiryTime" v-model="client._expiryTime"></persian-datepicker> value="client._expiryTime" v-model="client._expiryTime"></a-persian-datepicker>
<a-tag color="red" v-if="isEdit && isExpiry">Expired</a-tag> <a-tag color="red" v-if="isEdit && isExpiry">Expired</a-tag>
</a-form-item> </a-form-item>
<a-form-item v-if="client.expiryTime != 0"> <a-form-item v-if="client.expiryTime != 0">

View file

@ -57,9 +57,9 @@
<a-date-picker style="width: 100%;" v-if="datepicker == 'gregorian'" :show-time="{ format: 'HH:mm:ss' }" <a-date-picker style="width: 100%;" v-if="datepicker == 'gregorian'" :show-time="{ format: 'HH:mm:ss' }"
format="YYYY-MM-DD HH:mm:ss" :dropdown-class-name="themeSwitcher.currentTheme" format="YYYY-MM-DD HH:mm:ss" :dropdown-class-name="themeSwitcher.currentTheme"
v-model="dbInbound._expiryTime"></a-date-picker> v-model="dbInbound._expiryTime"></a-date-picker>
<persian-datepicker v-else placeholder='{{ i18n "pages.settings.datepickerPlaceholder" }}' <a-persian-datepicker v-else placeholder='{{ i18n "pages.settings.datepickerPlaceholder" }}'
value="dbInbound._expiryTime" v-model="dbInbound._expiryTime"> value="dbInbound._expiryTime" v-model="dbInbound._expiryTime">
</persian-datepicker> </a-persian-datepicker>
</a-form-item> </a-form-item>
</a-form> </a-form>

View file

@ -348,7 +348,7 @@
:indent-size="0" :indent-size="0"
v-on:onSort="replaceRule"> v-on:onSort="replaceRule">
<template slot="action" slot-scope="text, rule, index"> <template slot="action" slot-scope="text, rule, index">
<table-sort-trigger :item-index="index"></table-sort-trigger> <a-table-sort-trigger :item-index="index"></a-table-sort-trigger>
<span class="ant-table-row-index"> [[ index+1 ]] </span> <span class="ant-table-row-index"> [[ index+1 ]] </span>
<a-dropdown :trigger="['click']"> <a-dropdown :trigger="['click']">
<a-icon @click="e => e.preventDefault()" type="more" style="font-size: 16px; text-decoration: bold;"></a-icon> <a-icon @click="e => e.preventDefault()" type="more" style="font-size: 16px; text-decoration: bold;"></a-icon>