Quellcode durchsuchen

perf: dynamic options demo

ckl1 vor 2 Jahren
Ursprung
Commit
9a3b6177aa
4 geänderte Dateien mit 18 neuen und 2 gelöschten Zeilen
  1. 2 0
      src/config/axios/index.ts
  2. 2 1
      src/locales/en.ts
  3. 2 1
      src/locales/zh-CN.ts
  4. 12 0
      src/views/Components/Search.vue

+ 2 - 0
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

+ 2 - 1
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'

+ 2 - 1
src/locales/zh-CN.ts

@@ -338,7 +338,8 @@ export default {
     position: '位置',
     left: '左',
     center: '中',
-    right: '右'
+    right: '右',
+    dynamicOptions: '动态选项'
   },
   stickyDemo: {
     sticky: '黏性'

+ 12 - 0
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')">