|
|
@@ -1,15 +1,16 @@
|
|
|
<template>
|
|
|
<div>
|
|
|
- <a-form ref="ref_form" :model="form" :style="{ width: '700px' }">
|
|
|
- <a-form-item field="平台名称" label="平台名称" :required="true">
|
|
|
- <a-input v-model="form.platform_name" placeholder="请输入平台名称" />
|
|
|
+ <a-form ref="ref_form" :model="form" :style="{ width: '900px' }" :rules="form_rules">
|
|
|
+ <a-form-item field="platform_name" :label="$t('settings.platform_name')">
|
|
|
+ <a-input v-model="form.platform_name" :placeholder="$t('settings.platform_name_placeholder')" />
|
|
|
</a-form-item>
|
|
|
|
|
|
- <a-form-item field="logo" label="logo" :required="true">
|
|
|
+ <a-form-item field="platform_logo" :label="$t('settings.platform_logo')">
|
|
|
<a-upload
|
|
|
action="/"
|
|
|
:fileList="file ? [file] : []"
|
|
|
:show-file-list="false"
|
|
|
+ :accept="'image/png,image/jpeg'"
|
|
|
@change="onChange"
|
|
|
@progress="onProgress"
|
|
|
>
|
|
|
@@ -37,8 +38,9 @@
|
|
|
</div>
|
|
|
<div class="arco-upload-picture-card" v-else>
|
|
|
<div class="arco-upload-picture-card-text">
|
|
|
- <IconPlus />
|
|
|
- <div style="margin-top: 10px; font-weight: 600">Upload</div>
|
|
|
+ <img width="82px" src="/logo.png" alt="" />
|
|
|
+ <!-- <IconPlus />
|
|
|
+ <div style="margin-top: 10px; font-weight: 600">Upload</div> -->
|
|
|
</div>
|
|
|
</div>
|
|
|
</div>
|
|
|
@@ -46,22 +48,21 @@
|
|
|
</a-upload>
|
|
|
</a-form-item>
|
|
|
|
|
|
- <a-form-item field="平台介绍" label="平台介绍" :required="true">
|
|
|
- <a-textarea v-model="form.platform_introduce" placeholder="Please enter something" allow-clear />
|
|
|
+ <a-form-item field="platform_introduce" :label="$t('settings.platform_introduce')">
|
|
|
+ <a-textarea
|
|
|
+ v-model="form.platform_introduce"
|
|
|
+ :placeholder="$t('settings.platform_introduce_placeholder')"
|
|
|
+ allow-clear
|
|
|
+ />
|
|
|
</a-form-item>
|
|
|
|
|
|
<a-form-item>
|
|
|
<div class="setting-password-btn-container">
|
|
|
<a-space>
|
|
|
- <a-button class="submit-btn">取消 </a-button>
|
|
|
-
|
|
|
- <a-button
|
|
|
- class="submit-btn"
|
|
|
- type="primary"
|
|
|
- html-type="submit"
|
|
|
- :loading="loading"
|
|
|
- @click="handleUpdatePassword"
|
|
|
- >保存
|
|
|
+ <a-button class="submit-btn">{{ $t('settings.btn_cancel') }} </a-button>
|
|
|
+
|
|
|
+ <a-button class="submit-btn" type="primary" html-type="submit" :loading="loading" @click="handleUpdate">
|
|
|
+ {{ $t('settings.btn_submit') }}
|
|
|
</a-button>
|
|
|
</a-space>
|
|
|
</div>
|
|
|
@@ -71,10 +72,18 @@
|
|
|
</template>
|
|
|
|
|
|
<script setup>
|
|
|
-import { ref, reactive, getCurrentInstance, computed } from 'vue';
|
|
|
+import { ref, reactive, getCurrentInstance, computed, onMounted } from 'vue';
|
|
|
import { useRouter } from 'vue-router';
|
|
|
-
|
|
|
import { Message } from '../3rd-libs/arco-vue-libs';
|
|
|
+import { usePlatformInformation } from '../base/store/use-platform-information';
|
|
|
+import { updateSystemInfo, uploadLogo } from '../apis/login';
|
|
|
+import { useI18n } from 'vue-i18n';
|
|
|
+
|
|
|
+import { useSettingFormRules } from '../modules/settings/use-settings-form-rules';
|
|
|
+
|
|
|
+const { t } = useI18n();
|
|
|
+
|
|
|
+const platformInformation = usePlatformInformation();
|
|
|
|
|
|
const router = useRouter();
|
|
|
|
|
|
@@ -83,6 +92,9 @@ const form = reactive({
|
|
|
platform_logo: '',
|
|
|
platform_introduce: ''
|
|
|
});
|
|
|
+const form_rules = computed(() => {
|
|
|
+ return useSettingFormRules(t);
|
|
|
+});
|
|
|
|
|
|
const loading = ref(false);
|
|
|
|
|
|
@@ -98,6 +110,58 @@ const onChange = (_, currentFile) => {
|
|
|
const onProgress = (currentFile) => {
|
|
|
file.value = currentFile;
|
|
|
};
|
|
|
+
|
|
|
+/**
|
|
|
+ * 修改系统信息
|
|
|
+ * */
|
|
|
+const updateSystemInfoFun = async () => {
|
|
|
+ try {
|
|
|
+ const res = await updateSystemInfo(form.platform_name, form.platform_introduce, form.platform_logo);
|
|
|
+ console.log(res);
|
|
|
+ if (res.code / 1 === 200) {
|
|
|
+ /**
|
|
|
+ * 获取当前时间的时间戳,作为key值存储,方便更新logo后,页面上logo及时更新
|
|
|
+ * */
|
|
|
+ const logo_key = new Date().getTime();
|
|
|
+ platformInformation.updatePlatformInformation(res.data.title, res.data.desc, logo_key);
|
|
|
+ Message.success(res.msg);
|
|
|
+ } else {
|
|
|
+ Message.error(res.msg);
|
|
|
+ }
|
|
|
+ } catch (e) {
|
|
|
+ console.log(e);
|
|
|
+ }
|
|
|
+};
|
|
|
+const uploadLogoFun = async () => {
|
|
|
+ const formData = new FormData();
|
|
|
+ formData.append('file', file.value.file);
|
|
|
+ try {
|
|
|
+ const res = await uploadLogo(formData);
|
|
|
+ console.log(res);
|
|
|
+ if (res.code / 1 === 200) {
|
|
|
+ console.log(res);
|
|
|
+ form.platform_logo = res.data.logo;
|
|
|
+ }
|
|
|
+ } catch (e) {
|
|
|
+ console.log(e);
|
|
|
+ }
|
|
|
+};
|
|
|
+
|
|
|
+const handleUpdate = async () => {
|
|
|
+ console.log('form', form);
|
|
|
+ if (!form.platform_name.trim().length || !form.platform_introduce.trim().length) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (file) {
|
|
|
+ await uploadLogoFun();
|
|
|
+ }
|
|
|
+
|
|
|
+ await updateSystemInfoFun();
|
|
|
+};
|
|
|
+onMounted(() => {
|
|
|
+ form.platform_name = platformInformation.platform_name;
|
|
|
+ form.platform_introduce = platformInformation.platform_introduce;
|
|
|
+});
|
|
|
</script>
|
|
|
|
|
|
<style scoped>
|
|
|
@@ -106,4 +170,7 @@ const onProgress = (currentFile) => {
|
|
|
justify-content: flex-end;
|
|
|
flex-grow: 1;
|
|
|
}
|
|
|
+.arco-upload-picture-card {
|
|
|
+ background-color: transparent;
|
|
|
+}
|
|
|
</style>
|