@@ -167,15 +191,27 @@ export default {
},
addVisible: false,
addForm: {
+ ip: '127.0.0.1',
+ port: '8012',
room: '',
+ lang: 'zh',
data: '',
width: 150,
height: 150
},
addRules: {
+ ip: [
+ { required: true, message: this.$t('qrcode.validation.ip_required'), trigger: 'blur' }
+ ],
+ port: [
+ { required: true, message: this.$t('qrcode.validation.port_required'), trigger: 'blur' }
+ ],
room: [
{ required: true, message: this.$t('qrcode.validation.room_code_required'), trigger: 'blur' }
],
+ lang: [
+ { required: true, message: this.$t('qrcode.validation.language_required'), trigger: 'change' }
+ ],
data: [
{ required: true, message: this.$t('qrcode.validation.qrcode_data_required'), trigger: 'blur' }
],
@@ -190,15 +226,27 @@ export default {
editForm: {
qrcode_id: '',
oldRoom: '',
+ ip: '127.0.0.1',
+ port: '8012',
room_code: '',
+ lang: 'zh',
qrcode_data: '',
qrcode_width: 150,
qrcode_height: 150
},
editRules: {
+ ip: [
+ { required: true, message: this.$t('qrcode.validation.ip_required'), trigger: 'blur' }
+ ],
+ port: [
+ { required: true, message: this.$t('qrcode.validation.port_required'), trigger: 'blur' }
+ ],
room_code: [
{ required: true, message: this.$t('qrcode.validation.room_code_required'), trigger: 'blur' }
],
+ lang: [
+ { required: true, message: this.$t('qrcode.validation.language_required'), trigger: 'change' }
+ ],
qrcode_data: [
{ required: true, message: this.$t('qrcode.validation.qrcode_data_required'), trigger: 'blur' }
],
@@ -276,8 +324,11 @@ export default {
},
addQRCode() {
this.addForm = {
+ ip: '127.0.0.1',
+ port: '8012',
room: '',
- data: 'http://127.0.0.1:8012?room=',
+ lang: 'zh',
+ data: 'http://127.0.0.1:8012?room=&lang=zh',
width: 150,
height: 150
}
@@ -286,19 +337,30 @@ export default {
this.$refs.addForm && this.$refs.addForm.clearValidate()
})
},
+ handleIpChange(value) {
+ // 当IP改变时,自动更新二维码内容
+ this.updateQRCodeData()
+ },
+ handlePortChange(value) {
+ // 当端口改变时,自动更新二维码内容
+ this.updateQRCodeData()
+ },
handleRoomChange(value) {
// 当房间号改变时,自动更新二维码内容
- // 保留二维码内容中 room= 前面的部分,只更新 room= 后面的值
- const currentData = this.addForm.data || ''
- const roomIndex = currentData.indexOf('room=')
-
- if (roomIndex !== -1) {
- // 如果找到 room=,保留前面的部分,更新后面的房间号
- this.addForm.data = currentData.substring(0, roomIndex + 5) + (value || '')
- } else {
- // 如果没有找到 room=,使用默认格式
- this.addForm.data = 'http://127.0.0.1:8012?room=' + (value || '')
- }
+ this.updateQRCodeData()
+ },
+ handleLangChange(value) {
+ // 当语言改变时,自动更新二维码内容
+ this.updateQRCodeData()
+ },
+ updateQRCodeData() {
+ // 更新二维码内容,格式:http://IP:端口?room=房间号&lang=语言
+ const ip = this.addForm.ip || '127.0.0.1'
+ const port = this.addForm.port || '8012'
+ const room = this.addForm.room || ''
+ const lang = this.addForm.lang || 'zh'
+
+ this.addForm.data = `http://${ip}:${port}?room=${room}&lang=${lang}`
},
submitAdd() {
this.$refs.addForm.validate(valid => {
@@ -334,29 +396,65 @@ export default {
})
},
editQRCode(row) {
+ // 解析现有的二维码数据,提取IP、端口、房间号和语言
+ const qrcodeData = row.qrcode_data || ''
+ let ip = '127.0.0.1'
+ let port = '8012'
+ let lang = 'zh'
+
+ // 尝试从URL中提取IP和端口
+ const urlMatch = qrcodeData.match(/http:\/\/([^:]+):(\d+)/)
+ if (urlMatch) {
+ ip = urlMatch[1]
+ port = urlMatch[2]
+ }
+
+ // 尝试从URL中提取语言参数
+ const langMatch = qrcodeData.match(/[?&]lang=([^&]+)/)
+ if (langMatch) {
+ lang = langMatch[1]
+ }
+
this.editForm = {
qrcode_id: row.qrcode_id,
oldRoom: row.room_code,
+ ip: ip,
+ port: port,
room_code: row.room_code,
+ lang: lang,
qrcode_data: row.qrcode_data,
qrcode_width: Number(row.qrcode_width) || 150,
qrcode_height: Number(row.qrcode_height) || 150
}
this.editVisible = true
+ this.$nextTick(() => {
+ this.$refs.editForm && this.$refs.editForm.clearValidate()
+ })
+ },
+ handleEditIpChange(value) {
+ // 当IP改变时,自动更新二维码内容
+ this.updateEditQRCodeData()
+ },
+ handleEditPortChange(value) {
+ // 当端口改变时,自动更新二维码内容
+ this.updateEditQRCodeData()
},
handleEditRoomChange(value) {
// 当房间号改变时,自动更新二维码内容
- // 保留二维码内容中 room= 前面的部分,只更新 room= 后面的值
- const currentData = this.editForm.qrcode_data || ''
- const roomIndex = currentData.indexOf('room=')
-
- if (roomIndex !== -1) {
- // 如果找到 room=,保留前面的部分,更新后面的房间号
- this.editForm.qrcode_data = currentData.substring(0, roomIndex + 5) + (value || '')
- } else {
- // 如果没有找到 room=,使用默认格式
- this.editForm.qrcode_data = 'http://127.0.0.1:8012?room=' + (value || '')
- }
+ this.updateEditQRCodeData()
+ },
+ handleEditLangChange(value) {
+ // 当语言改变时,自动更新二维码内容
+ this.updateEditQRCodeData()
+ },
+ updateEditQRCodeData() {
+ // 更新二维码内容,格式:http://IP:端口?room=房间号&lang=语言
+ const ip = this.editForm.ip || '127.0.0.1'
+ const port = this.editForm.port || '8012'
+ const room = this.editForm.room_code || ''
+ const lang = this.editForm.lang || 'zh'
+
+ this.editForm.qrcode_data = `http://${ip}:${port}?room=${room}&lang=${lang}`
},
submitEdit() {
this.$refs.editForm.validate(valid => {
@@ -467,4 +565,3 @@ export default {
margin-bottom: 10px;
}
-
diff --git a/src/views/login.vue b/src/views/login.vue
index a2f3689..859bfcc 100644
--- a/src/views/login.vue
+++ b/src/views/login.vue
@@ -35,7 +35,6 @@
简体中文
English
- Vietnamese
@@ -122,8 +121,6 @@ export default {
this.language = 'English'
} else if (command === 'zh') {
this.language = '简体中文'
- } else if (command === 'vi') {
- this.language = 'Vietnamese'
}
},
getCode() {