Kaynağa Gözat

fix : 增加静态资源发布命令功能

tuon 1 yıl önce
ebeveyn
işleme
8f000767d1

+ 2 - 1
.eslintrc.cjs

@@ -10,6 +10,7 @@ module.exports = {
   plugins: ['react-refresh'],
   rules: {
     'react-refresh/only-export-components': 'warn',
-      '@typescript-eslint/ban-ts-comment':"warn"
+      '@typescript-eslint/ban-ts-comment':"warn",
+      '@typescript-eslint/no-explicit-any': 'off'
   },
 }

Dosya farkı çok büyük olduğundan ihmal edildi
+ 0 - 0
dist/assets/index-368e395a.js


Dosya farkı çok büyük olduğundan ihmal edildi
+ 0 - 0
dist/assets/index-6d10be3a.css


+ 2 - 2
dist/index.html

@@ -4,7 +4,7 @@
     <meta name="viewport" content="width=device-width, initial-scale=1.0">
     <title>NginxUI</title>
     <script type="application/javascript" src="./config.js"></script>
-    <script crossorigin="">import('/nginx-ui/assets/index-153b30b8.js').finally(() => {
+    <script crossorigin="">import('/nginx-ui/assets/index-368e395a.js').finally(() => {
             
     const qiankunLifeCycle = window.moudleQiankunAppLifeCycles && window.moudleQiankunAppLifeCycles['nginx-ui'];
     if (qiankunLifeCycle) {
@@ -15,7 +15,7 @@
     }
   
           })</script>
-    <link rel="stylesheet" href="/nginx-ui/assets/index-a05d96d7.css">
+    <link rel="stylesheet" href="/nginx-ui/assets/index-6d10be3a.css">
   </head>
   <body>
     <div id="nginx_ui_root"></div>

+ 2 - 1
src/api/nginx.ts

@@ -97,6 +97,7 @@ export type IDeployReq  ={
    * 是否清空文件夹再部署
    */
   clear?: boolean
+  cmd?: string
 }
 /**
  * 文件上传
@@ -123,4 +124,4 @@ export const uploadApis = {
     })
   },
   deploy:(data: IDeployReq)=>request.post(`/nginx/${data.nginxId}/file/deploy`, data, {timeout: 120000}),
-}
+}

+ 1 - 0
src/models/nginx.ts

@@ -226,6 +226,7 @@ export type INginxLocation = Omit<NgxModuleData, "data"> & {
    * 临时数据,表示
    */
   __index__?: number
+  __deploy__?: any
 }
 
 export type PLocation = Partial<INginxLocation>

+ 19 - 4
src/pages/nginx/components/location/index.tsx

@@ -22,9 +22,10 @@ import {renderLocation} from "./utils.ts";
 /**
  * 部分的重要信息
  * @param data
+ * @param onChange
  * @constructor
  */
-const LocationInfo = ({data}:{ data: INginxLocation})=>{
+const LocationInfo = ({data, onChange}:{ data: INginxLocation, onChange?: (data: INginxLocation) => void})=>{
 
     const rootDir = ()=>{
         if (data.alias){
@@ -39,7 +40,7 @@ const LocationInfo = ({data}:{ data: INginxLocation})=>{
             data.proxy_type === 'proxy' ? <div>{`proxy: ${data.proxy_pass}`}</div> : null
         }
         {
-            data.proxy_type === 'static' ? <div>{rootDir()}<SiteInput location={data} /></div>:null
+            data.proxy_type === 'static' ? <div>{rootDir()}<SiteInput onChange={onChange} location={data} /></div>:null
         }
         <div>
             {
@@ -173,6 +174,20 @@ export const LocationInput = ({value, onChange }: AutoTypeInputProps) => {
         setEditData(undefined)
     }
 
+  /**
+   * 部署数据变化,不重新渲染
+   * @param data
+   */
+  const onDeployDataChange = (data: INginxLocation) => {
+    const newList = locations.map(item=>{
+      if (item.id === data.id){
+        return { ...item, ...data}
+      }
+      return item;
+    });
+    onChange?.(newList)
+  }
+
     const renderPreview = (data: INginxLocation)=>{
         let content ='';
         let rows = 0;
@@ -224,7 +239,7 @@ export const LocationInput = ({value, onChange }: AutoTypeInputProps) => {
             dataIndex: 'proxy_pass',
             title: '代理或路径',
             render: (_,record: any)=>{
-                return (<LocationInfo data={record} />)
+                return (<LocationInfo onChange={onDeployDataChange} data={record} />)
             }
         },
         {
@@ -278,4 +293,4 @@ export const LocationInput = ({value, onChange }: AutoTypeInputProps) => {
 }
 
 
-AdvanceInputConfigs['locations'] = LocationInput
+AdvanceInputConfigs['locations'] = LocationInput

+ 1 - 1
src/pages/nginx/components/location/utils.ts

@@ -71,7 +71,7 @@ export const renderLocation = (origin: INginxLocation) => {
         if (blacklist[k]){
             return;
         }
-        if (k.startsWith("tmp" || k.startsWith("temp"))){
+        if (k.startsWith("tmp" || k.startsWith("temp")) || k.startsWith("__")){
             return;
         }
         let value = (loc as any)[k];

+ 20 - 6
src/pages/nginx/components/site/index.tsx

@@ -14,6 +14,7 @@ import {useAppSelector} from "../../../../store";
 
 type IProps = {
     location: INginxLocation
+  onChange?: (location: INginxLocation) => void
 }
 
 /**
@@ -23,7 +24,7 @@ type IProps = {
  * @param column
  * @constructor
  */
-export const SiteInput = ({ location }: IProps) => {
+export const SiteInput = ({ location, onChange }: IProps) => {
 
     const [editData,setEditData] = useState<Partial<IDeployReq>>()
 
@@ -43,17 +44,29 @@ export const SiteInput = ({ location }: IProps) => {
             return;
         }
         const initialData :Partial<IDeployReq> = {
+          clear: false,
+          ...location.__deploy__ as any,
             nginxId: nginx.id,
-            clear: false
         }
-        if (location.alias){
+        if (!initialData.dir){
+          if (location.alias){
             initialData.dir = location.alias
-        }else if (location.root){
+          }else if (location.root){
             initialData.dir = location.root
+          }
         }
         setEditData(initialData)
     }
 
+    const updateLocation = (deployData: IDeployReq) => {
+      const cacheData = {
+        cmd: deployData.cmd,
+        clear: deployData.clear,
+        dir: deployData.dir,
+      };
+      onChange?.({ ...location, __deploy__: cacheData})
+    }
+
     const onSubmitData = async ()=>{
       if (!nginx?.id){
           return
@@ -71,7 +84,8 @@ export const SiteInput = ({ location }: IProps) => {
         }
       uploadApis.deploy(postData)
           .then(()=>{
-              Message.success('部署成功!')
+              Message.success('部署成功!');
+              updateLocation(postData);
           })
           .finally(()=>{
               setLoading(false)
@@ -109,7 +123,7 @@ export const SiteInput = ({ location }: IProps) => {
                                name="clear" label="全量部署" tooltip={{title: "全量部署会删除已有的文件,请注意"}}>
                         <Switch />
                     </Form.Item>
-                    <Form.Item label="部署命令" tooltip="文件更新后执行该命令,谨慎操作">
+                    <Form.Item label="部署命令" name="cmd" tooltip="文件更新后执行该命令,谨慎操作">
                         <Input.TextArea rows={1}/>
                     </Form.Item>
                     <Form.Item name="files" label="资源更新">

+ 6 - 0
src/styles/index.less

@@ -87,3 +87,9 @@
     }
   }
 }
+
+.ant-message{
+  .ant-message-notice-content{
+    max-width: 900px;
+  }
+}

Bu fark içinde çok fazla dosya değişikliği olduğu için bazı dosyalar gösterilmiyor