|
Æ»¹ûIOSϵͳ¼òµ¥Õ¹Ê¾Ò»ÏÂH5½çÃæAIWORK WebView ʾÀý
- //½»Á÷QQȺ711841924
- //¼òµ¥Õ¹Ê¾Ò»ÏÂH5½çÃæAIWORK WebView ʾÀý
- var web = new WebView()
- web.show();
- web.loadHtml(`
- <!DOCTYPE html>
- <html lang="zh-CN">
- <head>
- <meta charset="UTF-8">
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <title>AIWORK WebView ʾÀý</title>
- <style>
- * {
- margin: 0;
- padding: 0;
- box-sizing: border-box;
- }
-
- body {
- font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Microsoft YaHei", sans-serif;
- background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
- color: #333;
- line-height: 1.6;
- padding: 20px;
- min-height: 100vh;
- }
-
- .container {
- max-width: 800px;
- margin: 0 auto;
- background: rgba(255, 255, 255, 0.95);
- border-radius: 15px;
- box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
- overflow: hidden;
- }
-
- header {
- background: linear-gradient(90deg, #4b6cb7, #182848);
- color: white;
- padding: 25px;
- text-align: center;
- }
-
- h1 {
- font-size: 28px;
- margin-bottom: 10px;
- }
-
- .subtitle {
- font-size: 16px;
- opacity: 0.9;
- }
-
- .content {
- padding: 30px;
- }
-
- .section {
- margin-bottom: 30px;
- padding: 20px;
- border-radius: 10px;
- background: #f8f9fa;
- box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
- }
-
- h2 {
- color: #4b6cb7;
- margin-bottom: 15px;
- font-size: 22px;
- }
-
- .input-group {
- margin-bottom: 15px;
- }
-
- label {
- display: block;
- margin-bottom: 5px;
- font-weight: 500;
- }
-
- input, textarea {
- width: 100%;
- padding: 12px;
- border: 1px solid #ddd;
- border-radius: 6px;
- font-size: 16px;
- transition: border-color 0.3s;
- }
-
- input:focus, textarea:focus {
- outline: none;
- border-color: #4b6cb7;
- box-shadow: 0 0 0 2px rgba(75, 108, 183, 0.2);
- }
-
- .button-group {
- display: flex;
- flex-wrap: wrap;
- gap: 10px;
- margin-top: 15px;
- }
-
- button {
- flex: 1;
- min-width: 120px;
- padding: 12px 20px;
- border: none;
- border-radius: 6px;
- font-size: 16px;
- font-weight: 500;
- cursor: pointer;
- transition: all 0.3s ease;
- box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
- }
-
- button:active {
- transform: translateY(1px);
- }
-
- .btn-primary {
- background: linear-gradient(90deg, #4b6cb7, #182848);
- color: white;
- }
-
- .btn-success {
- background: linear-gradient(90deg, #56ab2f, #a8e063);
- color: white;
- }
-
- .btn-warning {
- background: linear-gradient(90deg, #ffb347, #ffcc33);
- color: white;
- }
-
- .btn-danger {
- background: linear-gradient(90deg, #ff416c, #ff4b2b);
- color: white;
- }
-
- .result {
- margin-top: 20px;
- padding: 15px;
- background: #e3f2fd;
- border-radius: 6px;
- border-left: 4px solid #2196f3;
- display: none;
- }
-
- .result.show {
- display: block;
- }
-
- .result h3 {
- margin-bottom: 10px;
- color: #0d47a1;
- }
-
- .result-content {
- font-family: monospace;
- background: white;
- padding: 10px;
- border-radius: 4px;
- white-space: pre-wrap;
- word-break: break-all;
- }
-
- footer {
- text-align: center;
- padding: 20px;
- background: #f8f9fa;
- color: #6c757d;
- font-size: 14px;
- }
-
- @media (max-width: 600px) {
- .container {
- margin: 10px;
- border-radius: 10px;
- }
-
- .content {
- padding: 20px;
- }
-
- h1 {
- font-size: 24px;
- }
-
- .button-group {
- flex-direction: column;
- }
-
- button {
- width: 100%;
- }
- }
- </style>
- </head>
- <body>
- <div class="container">
- <header>
- <h1>WebView ¹¦ÄÜÑÝʾ</h1>
- <p class="subtitle">չʾ H5 ÓëÔÉúÓ¦ÓõĽ»»¥¹¦ÄÜ</p>
- </header>
-
- <div class="content">
- <div class="section">
- <h2>ÅäÖùÜÀí</h2>
- <div class="input-group">
- <label for="configKey">ÅäÖüü:</label>
- <input type="text" id="configKey" placeholder="ÊäÈëÅäÖüü" value="user_name">
- </div>
- <div class="input-group">
- <label for="configValue">ÅäÖÃÖµ:</label>
- <input type="text" id="configValue" placeholder="ÊäÈëÅäÖÃÖµ" value="AIWORK Óû§">
- </div>
- <div class="button-group">
- <button class="btn-primary" onclick="setConfigValue()">ÉèÖÃÅäÖÃ</button>
- <button class="btn-success" onclick="getConfigValue()">»ñÈ¡ÅäÖÃ</button>
- </div>
- <div class="result" id="configResult">
- <h3>²Ù×÷½á¹û</h3>
- <div class="result-content" id="configResultContent"></div>
- </div>
- </div>
-
- <div class="section">
- <h2>ÏûÏ¢Ìáʾ</h2>
- <div class="input-group">
- <label for="toastMessage">ÌáʾÏûÏ¢:</label>
- <input type="text" id="toastMessage" placeholder="ÊäÈëÒªÏÔʾµÄÏûÏ¢" value="ÕâÊÇÒ»ÌõÌáʾÏûÏ¢">
- </div>
- <div class="button-group">
- <button class="btn-warning" onclick="showToast()">ÏÔʾÌáʾ</button>
- </div>
- </div>
-
- <div class="section">
- <h2>½Å±¾Ö´ÐÐ</h2>
- <div class="input-group">
- <label for="scriptCode">½Å±¾´úÂë:</label>
- <textarea id="scriptCode" rows="4" placeholder="ÊäÈëÒªÖ´ÐеĽű¾´úÂë">printl("ÕâÊÇ´ÓWebViewÖ´ÐеĽű¾");
- toast("½Å±¾Ö´Ðгɹ¦");</textarea>
- </div>
- <div class="button-group">
- <button class="btn-danger" onclick="runScript()">Ö´Ðнű¾</button>
- </div>
- <div class="result" id="scriptResult">
- <h3>Ö´Ðнá¹û</h3>
- <div class="result-content" id="scriptResultContent">½Å±¾ÒÑÖ´ÐУ¬Çë²é¿´ÔÉúÓ¦ÓÃÈÕÖ¾</div>
- </div>
- </div>
-
- <div class="section">
- <h2>Ó¦ÓÿØÖÆ</h2>
- <div class="button-group">
- <button class="btn-danger" onclick="closeWebView()">¹Ø±Õ½çÃæ</button>
- </div>
- </div>
- </div>
-
- <footer>
- <p>AIWORK WebView ʾÀý | ÓÃÓÚÑÝʾ H5 ÓëÔÉúÓ¦Óý»»¥</p>
- </footer>
- </div>
- <script>
- // ÏÔʾ½á¹û
- function showResult(elementId) {
- const resultElement = document.getElementById(elementId);
- resultElement.classList.add('show');
- setTimeout(() => {
- resultElement.classList.remove('show');
- }, 5000);
- }
-
- // ÉèÖÃÅäÖÃ
- function setConfigValue() {
- const key = document.getElementById('configKey').value;
- const value = document.getElementById('configValue').value;
-
- if (!key) {
- alert('ÇëÊäÈëÅäÖüü');
- return;
- }
-
- setConfig(key, value);
- document.getElementById('configResultContent').textContent =
- 'ÅäÖÃÒÑÉèÖÃ:\\n¼ü: ' + key + '\\nÖµ: ' + value;
- showResult('configResult');
- }
-
- // »ñÈ¡ÅäÖÃ
- async function getConfigValue() {
- const key = document.getElementById('configKey').value;
-
- if (!key) {
- alert('ÇëÊäÈëÅäÖüü');
- return;
- }
-
- try {
- const value = await getConfig(key);
- document.getElementById('configResultContent').textContent =
- '»ñÈ¡µ½ÅäÖÃ:\\n¼ü: ' + key + '\\nÖµ: ' + value;
- } catch (error) {
- document.getElementById('configResultContent').textContent =
- '»ñÈ¡ÅäÖÃʧ°Ü: ' + error;
- }
- showResult('configResult');
- }
-
- // ÏÔʾÌáʾ
- function showToast() {
- const message = document.getElementById('toastMessage').value;
- if (message) {
- toast(message);
- }
- }
-
- // Ö´Ðнű¾
- function runScript() {
- const scriptCode = document.getElementById('scriptCode').value;
- runJS(() => {
- try {
- eval(scriptCode);
- showResult('scriptResult');
- } catch (error) {
- document.getElementById('scriptResultContent').textContent =
- '½Å±¾Ö´Ðгö´í: ' + error;
- showResult('scriptResult');
- }
- });
- }
-
- // ¹Ø±Õ½çÃæ
- function closeWebView() {
- if (confirm('È·¶¨Òª¹Ø±Õµ±Ç°½çÃæÂð£¿')) {
- dismiss();
- }
- }
-
- // Ò³Ãæ¼ÓÔØÍê³ÉºóÌáʾ
- window.onload = function() {
- toast("WebViewÒ³Ãæ¼ÓÔØÍê³É");
- }
- </script>
- </body>
- </html>
- `);
¸´ÖÆ´úÂë
|
|