mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2025-09-12 13:10:05 +00:00
commit
b47f968414
1 changed files with 124 additions and 125 deletions
|
@ -1,132 +1,131 @@
|
||||||
{{ define "page/blocked_domains" }}
|
{{ template "page/head_start" .}}
|
||||||
<template>
|
{{ template "page/head_end" .}}
|
||||||
<div>
|
|
||||||
<a-card :title="i18n('menu.blocked_domains')">
|
{{ template "page/body_start" .}}
|
||||||
<a-button type="primary" @click="showAddModal = true" style="margin-bottom: 16px;">
|
<a-layout id="app" v-cloak :class="themeSwitcher.currentTheme">
|
||||||
{{ i18n "add" }}
|
<a-sidebar></a-sidebar>
|
||||||
</a-button>
|
<a-layout id="content-layout">
|
||||||
<a-table-sortable
|
<a-layout-content>
|
||||||
:data-source="domains"
|
<a-card :title="i18n('menu.blocked_domains')">
|
||||||
:row-key="'id'"
|
<a-button type="primary" @click="showAddModal = true" style="margin-bottom: 16px;">
|
||||||
:pagination="false"
|
[[ i18n('add') ]]
|
||||||
style="margin-bottom: 16px;"
|
</a-button>
|
||||||
>
|
<a-table-sortable
|
||||||
<a-table-column title="#" :customRender="(_, __, i) => i + 1" width="50" />
|
:data-source="domains"
|
||||||
<a-table-column title="{{ i18n "domain" }}" dataIndex="domain" key="domain" />
|
:row-key="'id'"
|
||||||
<a-table-column title="{{ i18n "comment" }}" dataIndex="comment" key="comment" />
|
:pagination="false"
|
||||||
<a-table-column
|
style="margin-bottom: 16px;"
|
||||||
:title="i18n('action')"
|
>
|
||||||
key="action"
|
<a-table-column title="#" :customRender="(_, __, i) => i + 1" width="50" />
|
||||||
:customRender="(_, record) => actionRender(record)"
|
<a-table-column title="[[ i18n('domain') ]]" dataIndex="domain" key="domain" />
|
||||||
width="120"
|
<a-table-column title="[[ i18n('comment') ]]" dataIndex="comment" key="comment" />
|
||||||
/>
|
<a-table-column
|
||||||
</a-table-sortable>
|
:title="i18n('action')"
|
||||||
<a-modal v-model="showAddModal" :title="i18n('add_domain')" @ok="addDomain">
|
key="action"
|
||||||
<a-form :model="addForm">
|
:customRender="(_, record) => actionRender(record)"
|
||||||
<a-form-item :label="i18n('domain')">
|
width="120"
|
||||||
<a-input v-model="addForm.domain" />
|
/>
|
||||||
</a-form-item>
|
</a-table-sortable>
|
||||||
<a-form-item :label="i18n('comment')">
|
<a-modal v-model="showAddModal" :title="i18n('add_domain')" @ok="addDomain">
|
||||||
<a-input v-model="addForm.comment" />
|
<a-form :model="addForm">
|
||||||
</a-form-item>
|
<a-form-item :label="i18n('domain')">
|
||||||
</a-form>
|
<a-input v-model="addForm.domain" />
|
||||||
</a-modal>
|
</a-form-item>
|
||||||
<a-modal v-model="showEditModal" :title="i18n('edit_domain')" @ok="editDomain">
|
<a-form-item :label="i18n('comment')">
|
||||||
<a-form :model="editForm">
|
<a-input v-model="addForm.comment" />
|
||||||
<a-form-item :label="i18n('domain')">
|
</a-form-item>
|
||||||
<a-input v-model="editForm.domain" />
|
</a-form>
|
||||||
</a-form-item>
|
</a-modal>
|
||||||
<a-form-item :label="i18n('comment')">
|
<a-modal v-model="showEditModal" :title="i18n('edit_domain')" @ok="editDomain">
|
||||||
<a-input v-model="editForm.comment" />
|
<a-form :model="editForm">
|
||||||
</a-form-item>
|
<a-form-item :label="i18n('domain')">
|
||||||
</a-form>
|
<a-input v-model="editForm.domain" />
|
||||||
</a-modal>
|
</a-form-item>
|
||||||
</a-card>
|
<a-form-item :label="i18n('comment')">
|
||||||
</div>
|
<a-input v-model="editForm.comment" />
|
||||||
</template>
|
</a-form-item>
|
||||||
|
</a-form>
|
||||||
|
</a-modal>
|
||||||
|
</a-card>
|
||||||
|
</a-layout-content>
|
||||||
|
</a-layout>
|
||||||
|
</a-layout>
|
||||||
|
|
||||||
|
{{ template "page/body_scripts" .}}
|
||||||
|
{{ template "component/aSidebar" .}}
|
||||||
|
{{ template "component/aThemeSwitch" .}}
|
||||||
<script>
|
<script>
|
||||||
new Vue({
|
const app = new Vue({
|
||||||
el: '#app',
|
delimiters: ['[[', ']]'],
|
||||||
data() {
|
el: '#app',
|
||||||
return {
|
data() {
|
||||||
domains: [],
|
return {
|
||||||
showAddModal: false,
|
domains: [],
|
||||||
showEditModal: false,
|
showAddModal: false,
|
||||||
addForm: { domain: '', comment: '' },
|
showEditModal: false,
|
||||||
editForm: { id: null, domain: '', comment: '' },
|
addForm: { domain: '', comment: '' },
|
||||||
};
|
editForm: { id: null, domain: '', comment: '' },
|
||||||
},
|
|
||||||
methods: {
|
|
||||||
i18n(key) {
|
|
||||||
// Простейший i18n, можно заменить на глобальный
|
|
||||||
const dict = {
|
|
||||||
'menu.blocked_domains': 'Запрещённые сайты',
|
|
||||||
'add': 'Добавить',
|
|
||||||
'domain': 'Домен',
|
|
||||||
'comment': 'Комментарий',
|
|
||||||
'action': 'Действия',
|
|
||||||
'add_domain': 'Добавить домен',
|
|
||||||
'edit_domain': 'Редактировать домен',
|
|
||||||
'edit': 'Редактировать',
|
|
||||||
'delete': 'Удалить',
|
|
||||||
};
|
};
|
||||||
return dict[key] || key;
|
|
||||||
},
|
},
|
||||||
fetchDomains() {
|
methods: {
|
||||||
axios.get('blocked-domains/').then(res => {
|
i18n(key) {
|
||||||
if (res.data.success) {
|
return I18nManager ? I18nManager.t(key) : key;
|
||||||
this.domains = res.data.obj;
|
},
|
||||||
|
fetchDomains() {
|
||||||
|
axios.get('blocked-domains/').then(res => {
|
||||||
|
if (res.data.success) {
|
||||||
|
this.domains = res.data.obj;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
addDomain() {
|
||||||
|
axios.post('blocked-domains/', this.addForm).then(res => {
|
||||||
|
if (res.data.success) {
|
||||||
|
this.showAddModal = false;
|
||||||
|
this.addForm = { domain: '', comment: '' };
|
||||||
|
this.fetchDomains();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
editDomain() {
|
||||||
|
axios.put(`blocked-domains/${this.editForm.id}`, this.editForm).then(res => {
|
||||||
|
if (res.data.success) {
|
||||||
|
this.showEditModal = false;
|
||||||
|
this.editForm = { id: null, domain: '', comment: '' };
|
||||||
|
this.fetchDomains();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
deleteDomain(id) {
|
||||||
|
this.$confirm({
|
||||||
|
title: this.i18n('delete'),
|
||||||
|
content: this.i18n('domain') + '?',
|
||||||
|
onOk: () => {
|
||||||
|
axios.delete(`blocked-domains/${id}`).then(res => {
|
||||||
|
if (res.data.success) {
|
||||||
|
this.fetchDomains();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
});
|
||||||
|
},
|
||||||
|
actionRender(record) {
|
||||||
|
return (
|
||||||
|
`<a @click=\"editDomainShow(${record.id})\">${this.i18n('edit')}</a> | ` +
|
||||||
|
`<a @click=\"deleteDomain(${record.id})\">${this.i18n('delete')}</a>`
|
||||||
|
);
|
||||||
|
},
|
||||||
|
editDomainShow(id) {
|
||||||
|
const d = this.domains.find(x => x.id === id);
|
||||||
|
if (d) {
|
||||||
|
this.editForm = { ...d };
|
||||||
|
this.showEditModal = true;
|
||||||
}
|
}
|
||||||
});
|
},
|
||||||
},
|
},
|
||||||
addDomain() {
|
mounted() {
|
||||||
axios.post('blocked-domains/', this.addForm).then(res => {
|
this.fetchDomains();
|
||||||
if (res.data.success) {
|
|
||||||
this.showAddModal = false;
|
|
||||||
this.addForm = { domain: '', comment: '' };
|
|
||||||
this.fetchDomains();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
editDomain() {
|
});
|
||||||
axios.put(`blocked-domains/${this.editForm.id}`, this.editForm).then(res => {
|
|
||||||
if (res.data.success) {
|
|
||||||
this.showEditModal = false;
|
|
||||||
this.editForm = { id: null, domain: '', comment: '' };
|
|
||||||
this.fetchDomains();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
},
|
|
||||||
deleteDomain(id) {
|
|
||||||
this.$confirm({
|
|
||||||
title: this.i18n('delete'),
|
|
||||||
content: this.i18n('domain') + '?',
|
|
||||||
onOk: () => {
|
|
||||||
axios.delete(`blocked-domains/${id}`).then(res => {
|
|
||||||
if (res.data.success) {
|
|
||||||
this.fetchDomains();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
},
|
|
||||||
});
|
|
||||||
},
|
|
||||||
actionRender(record) {
|
|
||||||
return (
|
|
||||||
`<a @click="editDomainShow(${record.id})">${this.i18n('edit')}</a> |
|
|
||||||
<a @click="deleteDomain(${record.id})">${this.i18n('delete')}</a>`
|
|
||||||
);
|
|
||||||
},
|
|
||||||
editDomainShow(id) {
|
|
||||||
const d = this.domains.find(x => x.id === id);
|
|
||||||
if (d) {
|
|
||||||
this.editForm = { ...d };
|
|
||||||
this.showEditModal = true;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
},
|
|
||||||
mounted() {
|
|
||||||
this.fetchDomains();
|
|
||||||
},
|
|
||||||
});
|
|
||||||
</script>
|
</script>
|
||||||
{{ end }}
|
{{ template "page/body_end" .}}
|
Loading…
Reference in a new issue