wzyyy 3 years ago
parent
commit
e2f114c6b7

+ 2 - 2
config/proxy.ts

@@ -9,8 +9,8 @@
 export default {
   dev: {
     '/api': {
-      target: 'http://192.168.32.28:8844/',
-      ws: 'ws://192.168.32.28:8844/',
+      // target: 'http://192.168.32.28:8844/',
+      // ws: 'ws://192.168.32.28:8844/',
       // 开发环境
       target: 'http://120.79.18.123:8844/',
       ws: 'ws://120.79.18.123:8844/',

+ 1 - 1
src/app.tsx

@@ -243,7 +243,7 @@ export const layout: RunTimeLayoutConfig = ({ initialState }) => {
   // console.log({ ...initialState });
   const ico: any = document.querySelector('link[rel="icon"]');
   if (ico !== null) {
-    Service.settingDetail('basis').then((res) => {
+    Service.settingDetail('front').then((res) => {
       if (res.status === 200) {
         // console.log(res.result.ico)
         ico.href = res.result.ico;

+ 14 - 0
src/pages/home/index.tsx

@@ -7,10 +7,12 @@ import Ops from './ops';
 import Api from './Api';
 import Service from './service';
 import { Skeleton } from 'antd';
+import { useModel } from '@@/plugin-model/useModel';
 
 export const service = new Service();
 const Home = () => {
   type ViewType = keyof typeof ViewMap;
+  const { initialState, setInitialState } = useModel<any>('@@initialState');
   const [current, setCurrent] = useState<ViewType>('init'); // 默认为初始化
   const [loading, setLoading] = useState(true);
   const [detail, setDetail] = useState<any>({});
@@ -36,6 +38,18 @@ const Home = () => {
   };
 
   useEffect(() => {
+    service.settingDetail(['front']).then((res) => {
+      if (res.status === 200) {
+        setInitialState({
+          ...initialState,
+          settings: {
+            ...res.result[0].properties,
+          },
+        });
+      }
+    });
+  }, []);
+  useEffect(() => {
     service.userDetail().then((res) => {
       if (res.status === 200) {
         //三方用户

+ 5 - 0
src/pages/home/service.ts

@@ -38,6 +38,11 @@ class Service {
       method: 'POST',
       data,
     });
+  settingDetail = (data?: any) =>
+    request(`/${SystemConst.API_BASE}/system/config/scopes`, {
+      method: 'POST',
+      data,
+    });
 }
 
 export default Service;

+ 8 - 5
src/pages/init-home/components/basis.tsx

@@ -20,20 +20,21 @@ const Basis = forwardRef((props: Props, ref) => {
       if (formData) {
         const item = [
           {
-            scope: 'basis',
+            scope: 'front',
             properties: {
               ...formData,
               apikey: '',
+              basePath: '',
             },
           },
           {
-            scope: 'api',
+            scope: 'amap',
             properties: {
               api: formData.apikey,
             },
           },
           {
-            scope: 'basePath',
+            scope: 'paths',
             properties: {
               basePath: formData.basePath,
             },
@@ -47,6 +48,7 @@ const Basis = forwardRef((props: Props, ref) => {
             settings: {
               ...initialState?.settings,
               logo: formData.logo,
+              title: formData.title,
             },
           });
           const ico: any = document.querySelector('link[rel="icon"]');
@@ -109,10 +111,11 @@ const Basis = forwardRef((props: Props, ref) => {
           <Form.Item
             label="base-path"
             name="basePath"
-            tooltip="界面访问后台服务器的URL(统一资源定位符)"
+            tooltip="系统后台访问的url"
             required
+            rules={[{ required: true, message: 'base-path必填' }]}
           >
-            <Input />
+            <Input placeholder="请输入" />
           </Form.Item>
           <Row gutter={[24, 24]}>
             <Col>

+ 1 - 0
src/pages/init-home/index.tsx

@@ -29,6 +29,7 @@ const InitHome = () => {
   };
 
   useEffect(() => {
+    document.title = '';
     service.getInit().then((res) => {
       if (res.status === 200 && res.result.length) {
         // jump()

+ 11 - 11
src/pages/system/Basis/index.tsx

@@ -20,9 +20,9 @@ const Basis = () => {
   const detail = async (data: any) => {
     const res = await service.detail(data);
     if (res.status === 200) {
-      const basis = res.result?.filter((item: any) => item.scope === 'basis');
-      const api = res?.result.filter((item: any) => item.scope === 'api');
-      const basePath = res?.result.filter((item: any) => item.scope === 'basePath');
+      const basis = res.result?.filter((item: any) => item.scope === 'front');
+      const api = res.result?.filter((item: any) => item.scope === 'amap');
+      const basePath = res.result?.filter((item: any) => item.scope === 'paths');
       localStorage.setItem(SystemConst.AMAP_KEY, api[0].properties.api);
       form.setFieldsValue({
         ...basis[0].properties,
@@ -39,11 +39,10 @@ const Basis = () => {
   };
   const save = async () => {
     const formData = await form.validateFields();
-    console.log(formData);
     if (formData) {
       const item = [
         {
-          scope: 'basis',
+          scope: 'front',
           properties: {
             ...formData,
             apikey: '',
@@ -51,13 +50,13 @@ const Basis = () => {
           },
         },
         {
-          scope: 'api',
+          scope: 'amap',
           properties: {
             api: formData.apikey,
           },
         },
         {
-          scope: 'basePath',
+          scope: 'paths',
           properties: {
             basePath: formData.basePath,
           },
@@ -66,13 +65,13 @@ const Basis = () => {
       const res = await service.save(item);
       if (res.status === 200) {
         onlyMessage('保存成功');
-        detail(['basis', 'api', 'basePath']);
+        detail(['front', 'amap', 'paths']);
       }
     }
   };
 
   useEffect(() => {
-    detail(['basis', 'api', 'basePath']);
+    detail(['front', 'amap', 'paths']);
   }, []);
   return (
     <PageContainer>
@@ -111,10 +110,11 @@ const Basis = () => {
               <Form.Item
                 label="base-path"
                 name="basePath"
-                tooltip="界面访问后台服务器的URL(统一资源定位符)"
+                tooltip="访问后台服务器的url"
                 required
+                rules={[{ required: true, message: 'base-path必填' }]}
               >
-                <Input />
+                <Input placeholder="请输入" />
               </Form.Item>
               <Row gutter={[24, 24]}>
                 <Col>