From 9a3b6177aa0fbc99c86c5073a1c6c696e1eaf890 Mon Sep 17 00:00:00 2001
From: ckl1 <ckl1@meitu.com>
Date: Fri, 1 Jul 2022 09:46:38 +0800
Subject: [PATCH] perf: dynamic options demo

---
 src/config/axios/index.ts       |  2 ++
 src/locales/en.ts               |  3 ++-
 src/locales/zh-CN.ts            |  3 ++-
 src/views/Components/Search.vue | 12 ++++++++++++
 4 files changed, 18 insertions(+), 2 deletions(-)

diff --git a/src/config/axios/index.ts b/src/config/axios/index.ts
index ee90740..3b2ab4a 100644
--- a/src/config/axios/index.ts
+++ b/src/config/axios/index.ts
@@ -25,6 +25,8 @@ service.interceptors.request.use(
     ) {
       config.data = qs.stringify(config.data)
     }
+    // 添加token,可根据实际业务修改
+    // config!.headers!['Authorization'] = 'something'
     // get参数编码
     if (config.method === 'get' && config.params) {
       let url = config.url as string
diff --git a/src/locales/en.ts b/src/locales/en.ts
index b565a0b..8117056 100644
--- a/src/locales/en.ts
+++ b/src/locales/en.ts
@@ -341,7 +341,8 @@ export default {
     position: 'position',
     left: 'left',
     center: 'center',
-    right: 'right'
+    right: 'right',
+    dynamicOptions: 'Dynamic options'
   },
   stickyDemo: {
     sticky: 'Sticky'
diff --git a/src/locales/zh-CN.ts b/src/locales/zh-CN.ts
index 9519ebb..5f7ba06 100644
--- a/src/locales/zh-CN.ts
+++ b/src/locales/zh-CN.ts
@@ -338,7 +338,8 @@ export default {
     position: '位置',
     left: '左',
     center: '中',
-    right: '右'
+    right: '右',
+    dynamicOptions: '动态选项'
   },
   stickyDemo: {
     sticky: '黏性'
diff --git a/src/views/Components/Search.vue b/src/views/Components/Search.vue
index 5c3cf0e..652e04b 100644
--- a/src/views/Components/Search.vue
+++ b/src/views/Components/Search.vue
@@ -5,6 +5,7 @@ import { Search } from '@/components/Search'
 import { reactive, ref, unref } from 'vue'
 import { useValidator } from '@/hooks/web/useValidator'
 import { ElButton } from 'element-plus'
+import { getDictOneApi } from '@/api/common'
 
 const { required } = useValidator()
 
@@ -174,6 +175,14 @@ const changePosition = (position: string) => {
   layout.value = 'bottom'
   buttomPosition.value = position
 }
+
+const getDictOne = async () => {
+  const res = await getDictOneApi()
+  if (res) {
+    schema[1].componentProps!.options = res.data
+    console.log(res.data)
+  }
+}
 </script>
 
 <template>
@@ -196,6 +205,9 @@ const changePosition = (position: string) => {
     <ElButton @click="changePosition('right')">
       {{ t('searchDemo.bottom') }} {{ t('searchDemo.position') }}-{{ t('searchDemo.right') }}
     </ElButton>
+    <ElButton @click="getDictOne">
+      {{ t('searchDemo.dynamicOptions') }}
+    </ElButton>
   </ContentWrap>
 
   <ContentWrap :title="t('searchDemo.search')" :message="t('searchDemo.searchDes')">