Skip to content
The Chat Archive
gpt-4o-mini-2024-07-18· OpenAI WildChat-4.8M (AI2)

<p>&nbsp;</p> <style> .gradio-wrapper { width: 100%; height: 800px; position: relative;…

  1. User
        .gradio-wrapper iframe {
            width: 100%;
            height: 100%;
            border: none;
            position: absolute;
            top: 0;
            left: 0;
        }
    
        .loading-overlay {
            position: absolute;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            background: white;
            display: flex;
            align-items: center;
            justify-content: center;
            z-index: 1000;
            font-family: system-ui;
        }
    
        .spinner {
            width: 40px;
            height: 40px;
            border: 4px solid #f3f3f3;
            border-top: 4px solid #3498db;
            border-radius: 50%;
            animation: spin 1s linear infinite;
        }
    
        @keyframes spin {
            0% { transform: rotate(0deg); }
            100% { transform: rotate(360deg); }
        }
    </style>
    
        const template = document.querySelector('.gradio-wrapper').cloneNode(true);
        const style = document.querySelector('style').cloneNode(true);
        
        this.shadowRoot.appendChild(style);
        this.shadowRoot.appendChild(template);
        
        // اگر URL از طریق attribute تعیین شده باشد
        const url = this.getAttribute('src');
        if (url) {
            this.shadowRoot.querySelector('iframe').src = url;
        }
    }
    

    }

    // ثبت کامپوننت سفارشی customElements.define('gradio-element', GradioElement);

  2. Assistant

    برای اینکه صفحه‌ای که ایجاد کرده‌اید بدون لینک و متن لینک‌دار باشد و همچنین در حالت تمام‌صفحه در موبایل نمایش داده شود، می‌توانید تغییرات زیر را اعمال کنید. در اینجا به تغییر در CSS و HTML نیاز دارید:

    1. حذف لینک‌ها و متن لینک‌دار

    برای اطمینان از اینکه هیچ لینکی در صفحه وجود نداشته باشد، می‌توانید از CSS استفاده کنید:

    a {
        display: none; /* پنهان کردن لینک‌ها */
    }
    

    و اگر مطمئن نیستید که در کد شما لینک‌های اضافی وجود ندارد، می‌توانید بررسی کنید که هیچ عنصر <a> در صفحه وجود نداشته باشد.

    2. تمام صفحه در موبایل

    برای اطمینان از اینکه iframe در موبایل به صورت تمام صفحه نمایش داده شود، شما می‌توانید CSS را به صورت زیر تنظیم کنید:

    html, body {
        margin: 0;
        padding: 0;
        height: 100%;
        overflow: hidden; /* پنهان کردن اسکرول */
    }
    
    .gradio-wrapper {
        width: 100vw; /* عرض 100 درصد از عرض ویرایشگر */
        height: 100vh; /* ارتفاع 100 درصد از ارتفاع ویرایشگر */
    }
    
    .gradio-wrapper iframe {
        width: 100vw; /* عرض 100 درصد */
        height: 100vh; /* ارتفاع 100 درصد */
    }
    

    3. کد نهایی

    کد کامل شما پس از اعمال تغییرات به شکل زیر خواهد بود:

    <!DOCTYPE html>
    <html lang="fa">
    <head>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <title>صفحه سفارشی</title>
        <style>
            html, body {
                margin: 0;
                padding: 0;
                height: 100%;
                overflow: hidden; /* پنهان کردن اسکرول */
            }
    
            .gradio-wrapper {
                width: 100vw; /* عرض 100 درصد از عرض ویرایشگر */
                height: 100vh; /* ارتفاع 100 درصد از ارتفاع ویرایشگر */
                position: relative;
                overflow: hidden;
                border-radius: 8px;
                box-shadow: 0 2px 10px rgba(0,0,0,0.1);
            }
    
            .gradio-wrapper iframe {
                width: 100vw; /* عرض 100 درصد */
                height: 100vh; /* ارتفاع 100 درصد */
                border: none;
                position: absolute;
                top: 0;
                left: 0;
            }
    
            .loading-overlay {
                position: absolute;
                top: 0;
                left: 0;
                right: 0;
                bottom: 0;
                background: white;
                display: flex;
                align-items: center;
                justify-content: center;
                z-index: 1000;
                font-family: system-ui;
            }
    
            .spinner {
                width: 40px;
                height: 40px;
                border: 4px solid #f3f3f3;
                border-top: 4px solid #3498db;
                border-radius: 50%;
                animation: spin 1s linear infinite;
            }
    
            @keyframes spin {
                0% { transform: rotate(0deg); }
                100% { transform: rotate(360deg); }
            }
    
            a {
                display: none; /* پنهان کردن لینک‌ها */
            }
        </style>
    </head>
    <body>
        <div class="gradio-wrapper">
            <div class="loading-overlay">
                <div class="spinner"></div>
            </div>
            <iframe src="https://akhaliq-anychat.hf.space" onload="this.previousElementSibling.style.display='none'" allow="camera;microphone;clipboard-write;fullscreen" loading="lazy"></iframe>
        </div>
        
        <script>
            class GradioElement extends HTMLElement {
                constructor() {
                    super();
                    this.attachShadow({ mode: 'open' });
                    
                    const template = document.querySelector('.gradio-wrapper').cloneNode(true);
                    const style = document.querySelector('style').cloneNode(true);
                    
                    this.shadowRoot.appendChild(style);
                    this.shadowRoot.appendChild(template);
                    
                    // اگر URL از طریق attribute تعیین شده باشد
                    const url = this.getAttribute('src');
                    if (url) {
                        this.shadowRoot.querySelector('iframe').src = url;
                    }
                }
            }
    
            // ثبت کامپوننت سفارشی
            customElements.define('gradio-element', GradioElement);
        </script>
    </body>
    </html>
    

    این کد به صورت کل صفحه را می‌گیرد و در موبایل به صورت تمام صفحه نمایش داده می‌شود و هیچ لینکی در آن به نمایش در نمی‌آید.