Add config page (#49)
This commit is contained in:
1 parent
87e83f3432
commit
bf01192bd2
786 files changed
+30678
-24247
No files matched your search
@@ -0,0 +1,137 @@
|
||||
<template>
|
||||
<el-dialog v-model="editing" :title="title" width="400px">
|
||||
<el-tag
|
||||
v-for="(item, itemKey) in value"
|
||||
:key="itemKey"
|
||||
closable
|
||||
round
|
||||
class="mr-2 mb-2"
|
||||
:disable-transitions="false"
|
||||
@close="onClose(item)"
|
||||
>
|
||||
{{ item }}
|
||||
</el-tag>
|
||||
<el-input
|
||||
v-if="inputVisible"
|
||||
ref="input"
|
||||
v-model="inputValue"
|
||||
class="block"
|
||||
size="small"
|
||||
@keyup.enter="onInputConfirm"
|
||||
@blur="onInputConfirm"
|
||||
/>
|
||||
<el-button v-else round class="block" size="small" @click="onNewItem"> + </el-button>
|
||||
<span class="block tip">{{ tip }}</span>
|
||||
<template #footer>
|
||||
<span class="dialog-footer">
|
||||
<el-button round @click="onCancel">{{ $t('common.button.cancel') }}</el-button>
|
||||
<el-button round type="primary" @click="onConfirm">{{ $t('common.button.confirm') }}</el-button>
|
||||
</span>
|
||||
</template>
|
||||
</el-dialog>
|
||||
<span class="edit" @click="editing = true">
|
||||
<el-icon class="icon">
|
||||
<edit />
|
||||
</el-icon>
|
||||
</span>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { defineComponent } from 'vue';
|
||||
import { ElDialog, ElInput, ElButton, ElIcon, ElTag, ElMessage } from 'element-plus';
|
||||
import { Edit } from '@element-plus/icons-vue';
|
||||
|
||||
export default defineComponent({
|
||||
name: 'EditText',
|
||||
components: {
|
||||
ElDialog,
|
||||
ElInput,
|
||||
ElButton,
|
||||
ElIcon,
|
||||
ElTag,
|
||||
Edit
|
||||
},
|
||||
props: {
|
||||
modelValue: {
|
||||
type: Array,
|
||||
required: true
|
||||
},
|
||||
title: {
|
||||
type: String,
|
||||
required: true
|
||||
},
|
||||
placeholder: {
|
||||
type: String,
|
||||
required: true
|
||||
},
|
||||
tip: {
|
||||
type: String,
|
||||
default: undefined
|
||||
},
|
||||
min: {
|
||||
type: Number,
|
||||
default: undefined
|
||||
},
|
||||
minErrorMessage: {
|
||||
type: String,
|
||||
default: undefined
|
||||
}
|
||||
},
|
||||
emits: ['confirm', 'cancel'],
|
||||
data() {
|
||||
return {
|
||||
inputVisible: false,
|
||||
inputValue: '',
|
||||
editing: false,
|
||||
value: JSON.parse(JSON.stringify(this.modelValue))
|
||||
};
|
||||
},
|
||||
methods: {
|
||||
onCancel() {
|
||||
this.editing = false;
|
||||
},
|
||||
onConfirm() {
|
||||
if (this.min !== undefined && this.value.length < this.min) {
|
||||
ElMessage.error(this.minErrorMessage);
|
||||
return;
|
||||
}
|
||||
this.$emit('confirm', this.value);
|
||||
this.editing = false;
|
||||
},
|
||||
onClose(item: any) {
|
||||
this.value.splice(this.value.indexOf(item), 1);
|
||||
},
|
||||
onInputConfirm() {
|
||||
const inputValue = this.inputValue;
|
||||
if (inputValue) {
|
||||
this.value.push(inputValue);
|
||||
}
|
||||
this.inputVisible = false;
|
||||
this.inputValue = '';
|
||||
},
|
||||
onNewItem() {
|
||||
this.inputVisible = true;
|
||||
this.$nextTick(() => {
|
||||
// @ts-ignore
|
||||
this.$refs.input.focus();
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
.edit {
|
||||
cursor: pointer;
|
||||
margin-left: 5px;
|
||||
position: relative;
|
||||
top: 2px;
|
||||
.icon {
|
||||
font-size: 14px;
|
||||
}
|
||||
}
|
||||
.tip {
|
||||
color: var(--el-text-color-secondary);
|
||||
font-size: 12px;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,119 @@
|
||||
<template>
|
||||
<el-dialog v-model="editing" :title="title" width="400px">
|
||||
<div>
|
||||
<el-upload
|
||||
v-model:file-list="fileList"
|
||||
name="file"
|
||||
:limit="5"
|
||||
:multiple="true"
|
||||
:action="uploadUrl"
|
||||
list-type="picture"
|
||||
:on-exceed="onExceed"
|
||||
:on-error="onError"
|
||||
:headers="headers"
|
||||
>
|
||||
<el-button round type="primary" class="btn btn-upload">
|
||||
<font-awesome-icon icon="fa-solid fa-upload" class="icon mr-2" />
|
||||
{{ $t('site.button.upload') }}
|
||||
</el-button>
|
||||
<template #tip>
|
||||
<div class="el-upload__tip">
|
||||
{{ tip }}
|
||||
</div>
|
||||
</template>
|
||||
</el-upload>
|
||||
</div>
|
||||
<template #footer>
|
||||
<span class="dialog-footer">
|
||||
<el-button round @click="onCancel">{{ $t('common.button.cancel') }}</el-button>
|
||||
<el-button round type="primary" @click="onConfirm">{{ $t('common.button.confirm') }}</el-button>
|
||||
</span>
|
||||
</template>
|
||||
</el-dialog>
|
||||
<span class="edit" @click="editing = true">
|
||||
<el-icon class="icon">
|
||||
<edit />
|
||||
</el-icon>
|
||||
</span>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { defineComponent } from 'vue';
|
||||
import { ElDialog, ElButton, ElIcon, ElMessage, ElUpload, UploadFiles, UploadFile } from 'element-plus';
|
||||
import { Edit } from '@element-plus/icons-vue';
|
||||
import { getBaseUrlPlatform } from '@/utils';
|
||||
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome';
|
||||
|
||||
export default defineComponent({
|
||||
name: 'EditImage',
|
||||
components: {
|
||||
ElDialog,
|
||||
ElButton,
|
||||
FontAwesomeIcon,
|
||||
ElIcon,
|
||||
Edit,
|
||||
ElUpload
|
||||
},
|
||||
props: {
|
||||
modelValue: {
|
||||
type: String,
|
||||
required: true
|
||||
},
|
||||
title: {
|
||||
type: String,
|
||||
required: true
|
||||
},
|
||||
tip: {
|
||||
type: String,
|
||||
required: true
|
||||
}
|
||||
},
|
||||
emits: ['confirm', 'cancel'],
|
||||
data() {
|
||||
return {
|
||||
editing: false,
|
||||
value: this.modelValue,
|
||||
fileList: [],
|
||||
uploadUrl: getBaseUrlPlatform() + '/api/v1/files/'
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
headers() {
|
||||
return {
|
||||
Authorization: `Bearer ${this.$store.state.token.access}`
|
||||
};
|
||||
},
|
||||
urls() {
|
||||
// @ts-ignore
|
||||
return this.fileList.map((file: UploadFile) => file?.response?.file_url);
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
onCancel() {
|
||||
this.editing = false;
|
||||
},
|
||||
onConfirm() {
|
||||
this.$emit('confirm', this.urls?.[0]);
|
||||
this.editing = false;
|
||||
},
|
||||
onExceed() {
|
||||
ElMessage.warning(this.$t('site.message.uploadImageExceed'));
|
||||
},
|
||||
onError() {
|
||||
ElMessage.error(this.$t('site.message.uploadImageError'));
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
.edit {
|
||||
cursor: pointer;
|
||||
margin-left: 5px;
|
||||
position: relative;
|
||||
top: 2px;
|
||||
.icon {
|
||||
font-size: 14px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,77 @@
|
||||
<template>
|
||||
<el-dialog v-model="editing" :title="title" width="400px">
|
||||
<div>
|
||||
<el-input v-model="value" :placeholder="placeholder" />
|
||||
</div>
|
||||
<template #footer>
|
||||
<span class="dialog-footer">
|
||||
<el-button round @click="onCancel">{{ $t('common.button.cancel') }}</el-button>
|
||||
<el-button round type="primary" @click="onConfirm">{{ $t('common.button.confirm') }}</el-button>
|
||||
</span>
|
||||
</template>
|
||||
</el-dialog>
|
||||
<span class="edit" @click="editing = true">
|
||||
<el-icon class="icon">
|
||||
<edit />
|
||||
</el-icon>
|
||||
</span>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { defineComponent } from 'vue';
|
||||
import { ElDialog, ElInput, ElButton, ElIcon } from 'element-plus';
|
||||
import { Edit } from '@element-plus/icons-vue';
|
||||
|
||||
export default defineComponent({
|
||||
name: 'EditText',
|
||||
components: {
|
||||
ElDialog,
|
||||
ElInput,
|
||||
ElButton,
|
||||
ElIcon,
|
||||
Edit
|
||||
},
|
||||
props: {
|
||||
modelValue: {
|
||||
type: String,
|
||||
required: true
|
||||
},
|
||||
title: {
|
||||
type: String,
|
||||
required: true
|
||||
},
|
||||
placeholder: {
|
||||
type: String,
|
||||
required: true
|
||||
}
|
||||
},
|
||||
emits: ['confirm', 'cancel'],
|
||||
data() {
|
||||
return {
|
||||
editing: false,
|
||||
value: this.modelValue
|
||||
};
|
||||
},
|
||||
methods: {
|
||||
onCancel() {
|
||||
this.editing = false;
|
||||
},
|
||||
onConfirm() {
|
||||
this.$emit('confirm', this.value);
|
||||
this.editing = false;
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
.edit {
|
||||
cursor: pointer;
|
||||
margin-left: 5px;
|
||||
position: relative;
|
||||
top: 2px;
|
||||
.icon {
|
||||
font-size: 14px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
Reference in new issue
Block a user