Skip to content

Commit

Permalink
avoid duplicate data
Browse files Browse the repository at this point in the history
  • Loading branch information
alireza0 committed May 14, 2024
1 parent c0aef19 commit 609132a
Show file tree
Hide file tree
Showing 8 changed files with 36 additions and 0 deletions.
3 changes: 3 additions & 0 deletions frontend/src/locales/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ export default {
online: "Online",
version: "Version",
commaSeparated: "(comma separated)",
error: {
dplData: "Duplicate Data",
},
pages: {
login: "Login",
home: "Home",
Expand Down
3 changes: 3 additions & 0 deletions frontend/src/locales/fa.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ export default {
online: "آنلاین",
version: "نسخه",
commaSeparated: "(جداشده با کاما)",
error: {
dplData: "داده تکراری",
},
pages: {
login: "ورود",
home: "خانه",
Expand Down
3 changes: 3 additions & 0 deletions frontend/src/locales/vi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ export default {
online: "Trực tuyến",
version: "Phiên bản",
commaSeparated: "(được phân tách bằng dấu phẩy)",
error: {
dplData: "Dữ liệu trùng lặp",
},
pages: {
login: "Đăng nhập",
home: "Trang chủ",
Expand Down
3 changes: 3 additions & 0 deletions frontend/src/locales/zhcn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ export default {
online: "在线",
version: "版本",
commaSeparated: "(逗号分隔)",
error: {
dplData: "重复数据",
},
pages: {
login: "登录",
home: "主页",
Expand Down
3 changes: 3 additions & 0 deletions frontend/src/locales/zhtw.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ export default {
online: "在線",
version: "版本",
commaSeparated: "(逗號分隔)",
error: {
dplData: "重複數據",
},
pages: {
login: "登錄",
home: "主頁",
Expand Down
7 changes: 7 additions & 0 deletions frontend/src/views/Clients.vue
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,8 @@ import { Config, V2rayApiStats } from '@/types/config'
import { InTypes, Inbound,InboundWithUser, ShadowTLS, VLESS } from '@/types/inbounds'
import { Link, LinkUtil } from '@/plugins/link'
import { HumanReadable } from '@/plugins/utils'
import Message from '@/store/modules/message'
import { i18n } from '@/locales'

const clients = computed((): any[] => {
return Data().clients
Expand Down Expand Up @@ -177,6 +179,11 @@ const closeModal = () => {
modal.value.visible = false
}
const saveModal = (data:any, stats:boolean) => {
if (clients.value.findIndex(c => c.name == data.name) != modal.value.index) {
const sb = Message()
sb.showMessage(i18n.global.t('error.dplData') + ': ' + i18n.global.t('client.name') ,'error', 5000)
return
}
const inboundTags: string[] = data.inbounds.split(',')?? []
let oldName:string = ""
if(modal.value.index == -1) {
Expand Down
7 changes: 7 additions & 0 deletions frontend/src/views/Inbounds.vue
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,8 @@ import { computed, ref } from 'vue'
import { InTypes, Inbound, InboundWithUser, ShadowTLS, VLESS } from '@/types/inbounds'
import { Client } from '@/types/clients'
import { Link, LinkUtil } from '@/plugins/link'
import Message from '@/store/modules/message'
import { i18n } from '@/locales'

const appConfig = computed((): Config => {
return <Config> Data().config
Expand Down Expand Up @@ -156,6 +158,11 @@ const closeModal = () => {
modal.value.visible = false
}
const saveModal = (data:Inbound, stats: boolean) => {
if (inbounds.value.findIndex(c => c.tag == data.tag) != modal.value.id) {
const sb = Message()
sb.showMessage(i18n.global.t('error.dplData') + ': ' + i18n.global.t('objects.tag') ,'error', 5000)
return
}
// New or Edit
if (modal.value.id == -1) {
inbounds.value.push(data)
Expand Down
7 changes: 7 additions & 0 deletions frontend/src/views/Outbounds.vue
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ import Stats from '@/layouts/modals/Stats.vue'
import { Config, V2rayApiStats } from '@/types/config';
import { Outbound } from '@/types/outbounds';
import { computed, ref } from 'vue'
import Message from '@/store/modules/message';
import { i18n } from '@/locales';

const appConfig = computed((): Config => {
return <Config> Data().config
Expand Down Expand Up @@ -137,6 +139,11 @@ const closeModal = () => {
modal.value.visible = false
}
const saveModal = (data:Outbound, stats: boolean) => {
if (outbounds.value.findIndex(c => c.tag == data.tag) != modal.value.id) {
const sb = Message()
sb.showMessage(i18n.global.t('error.dplData') + ': ' + i18n.global.t('objects.tag') ,'error', 5000)
return
}
// New or Edit
if (modal.value.id == -1) {
outbounds.value.push(data)
Expand Down

0 comments on commit 609132a

Please sign in to comment.