<template>
  <div class="share-config">
    <el-form ref="form" :model="form" label-width="180px">
      <el-form-item label="练习题分享链接路径">
        <el-input v-model="form.exercise_share_url_path" />
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="setShareConfig">应用</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
export default {
  name: 'ShareConfig'
};
</script>

<script setup>
import { ref } from 'vue';
import { GetShareConfig, SetShareConfig } from '@/api/settings';
import { Message } from 'element-ui';

let form = ref({ exercise_share_url_path: '' });

GetShareConfig().then(({ exercise_share_url_path }) => {
  form.value = {
    exercise_share_url_path
  };
});

function setShareConfig() {
  SetShareConfig(form.value).then(() => {
    Message.success('设置分享配置成功');
  });
}
</script>

<style lang="scss" scoped>
.share-config {
  .el-input {
    width: 80%;
  }
}
</style>
