2016-07-19 3 views
0

OSX(エル・キャピタン+ヨセミテ)のwebviewでlocalStorageに問題があります。OSX webviewのlocalStorageがページのリロードに永続しない - Office365 Addin

私はでOffice365アプリケーションを作っています。それはWindows上でもMac上でもSafariでもうまくいきます。それは面倒なことを証明しているMacのwebviewだけです。ホストされたドメイン上にあるため、thisは問題ではありません。

以下のテストコードからわかるように、情報をlocalStorageに保存してから、変数に値を設定しています。つまり、ある時点でlocalStorageに保存しておく必要がありますが、ページを更新するとデータが失われます。注:私のアプリのすべてのデータが失われているわけではなく、ちょっとしたものです。

私はQUOTA_EXCEEDED_ERRを保存していません。

ここでは、リフレッシュに失敗したテストコードです。

$scope.initTest = function() { 

    $scope.errorsRecorded += "************** Initialize **************"; 

    var notNested = localStorage.getItem('lclNotNested'); 
    if (!notNested) { 
     $scope.errorsRecorded += "*_*__NOT NESTED NOT SAVED"; 
     $scope.notNested = "NOTSET"; 
    } else { 
     $scope.errorsRecorded += "*_*__NOT NESTED ___ val=" + notNested + ';'; 
     $scope.notNested = JSON.parse(notNested); 
    } 
}; 
$scope.initTest(); 


// Button press event 

$scope.setSingle = function() { 
    // Set the value to localStorage, then get it back for the UI 
    // so we know the value was set. 
    try { 
     localStorage.setItem('lclNotNested', JSON.stringify(Date.now())); 
    } catch (e) { 
     $scope.errorsRecorded = $scope.errorsRecorded + '.....<br/>\r\n ' + e; 
    } 

    $scope.notNested = JSON.parse(localStorage.getItem('lclNotNested')); 
}; 

正しく設定された後、読み込みに失敗するスクリーンショットがあります。

localStorage being set

fail to get data on load

私はそれを理解しようとして時間を費やしてきたし、それをデバッグする方法を見つけることができません。基本的なWebviewコードにアクセスすることはできません。マイクロソフトが提供するものの上にあるWebアプリケーションです。

何が起こっているのか、どのようにデバッグすることができますか(MacのwebviewのlocalStorageファイルを表示するなど)。ヘッドの全体の負荷が傷やアプリにしようとするこのjsfiddleを作成した後

答えて

0

議論

...質問を削除するが、これは他のうちの誰かをキャッチするためにバインドされている、Office 365のドンをアプリと思われます現時点では、OSX上のwebviewで期待通りにlocalStorageを保持しています。

一部の情報がドキュメントに保存されていたことが、私の混乱の原因です。他の(それほど重要ではない)情報はlocalStorageにのみ保存されていたため、永続化されませんでした。

私の場合の回答は、ページの再読み込みで永続性を持たせたい場合や、Office 365アプリを保存してから再度開いてドキュメントに保存する場合です。何かのためにlocalStorageに頼らないでください。

jsfiddleのためのコード:

<script> 


     function deletMany() { 

      var getManyNumber = parseInt(document.getElementById('setManyNumber').value); 

      for (var i = 0; i < getManyNumber; i++) { 
       try { 
        localStorage.removeItem('many' + i); 
       } catch (e) {     
       } 
      } 

      getMany(); 
     } 

     function getMany() { 
      var outputText = ''; 

      var getManyNumber = parseInt(document.getElementById('setManyNumber').value); 


      for (var i = 0; i < getManyNumber; i++) { 
       try { 
        var ot = localStorage.getItem('many' + i); 

        outputText += (ot) ? ot + '_' : i + " - no set <br/>"; 
       } catch (e) { 
        outputText += '|||' + i + '-' + e; 
       } 
      } 

      var elm = document.getElementById('results'); 
      elm.innerHTML = outputText; 
     } 

     function setMany() { 

      var getManyNumber = parseInt(document.getElementById('setManyNumber').value); 

      for (var i = 0; i < getManyNumber; i++) { 
       localStorage.setItem('many' + i, "MANY" + i); 
      } 
     } 


     //--------- 

     function deleteFewWithLots() { 

      var getLotsNumber = parseInt(document.getElementById('setLotsNumber').value); 

      for (var i = 0; i < getLotsNumber; i++) { 
       try { 
        localStorage.removeItem('few' + i); 
       } catch (e) { 

       } 
      } 

      getFewWithLots(); 

     } 

     function getFewWithLots() { 
      var outputText = ''; 

      var getLotsNumber = parseInt(document.getElementById('setLotsNumber').value); 

      for (var i = 0; i < getLotsNumber; i++) { 
       try { 
        var ot = localStorage.getItem('few' + i); 

        outputText += (ot) ? i + ':' + ot + '_' : i + " - no set <br/> \r\n___"; 
       } catch (e) { 
        outputText += '|||' + i + '-' + e; 
       } 
      } 

      var elm = document.getElementById('results'); 
      elm.innerHTML = outputText; 
     } 

     function setFewWithLots() { 

      var getLotsNumber = parseInt(document.getElementById('setLotsNumber').value); 

      for (var i = 0; i < getLotsNumber; i++) { 
       localStorage.setItem('few' + i, "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Section 1.10.32 of de Finibus Bonorum et Malorum, written by Cicero in 45 BC. Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem. Ut enim ad minima veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut aliquid ex ea commodi consequatur? Quis autem vel eum iure reprehenderit qui in ea voluptate velit esse quam nihil molestiae consequatur, vel illum qui dolorem eum fugiat quo voluptas nulla pariatur? 1914 translation by H. Rackham. But I must explain to you how all this mistaken idea of denouncing pleasure and praising pain was born and I will give you a complete account of the system, and expound the actual teachings of the great explorer of the truth, the master-builder of human happiness. No one rejects, dislikes, or avoids pleasure itself, because it is pleasure, but because those who do not know how to pursue pleasure rationally encounter consequences that are extremely painful. Nor again is there anyone who loves or pursues or desires to obtain pain of itself, because it is pain, but because occasionally circumstances occur in which toil and pain can procure him some great pleasure. To take a trivial example, which of us ever undertakes laborious physical exercise, except to obtain some advantage from it? But who has any right to find fault with a man who chooses to enjoy a pleasure that has no annoying consequences, or one who avoids a pain that produces no resultant pleasure?" + i + '______________________________________________________________________ __________________________________________ ____________________________'); 
      } 
     } 


    </script> 


<body> 

    <hr /> 
    <button onclick="deletMany()">Delete Many</button> 
    <button onclick="getMany()">Get Many</button> 
    <input id="setManyNumber" type="number" value="1" style="width:75px;" /> 
    <button onclick="setMany()">Set Many</button> 
    <button onclick="deleteFewWithLots()">Delete Few Items With Lots</button> 
    <button onclick="getFewWithLots()">Get Few Items With Lots</button> 
    <input id="setLotsNumber" type="number" value="1" style="width:75px;" /> 
    <button onclick="setFewWithLots()">Set Few Items With Lots</button> 
    <hr /> 
    <div style="background-color:aqua; word-break:break-all; width:500px;margin-left:100px; position: absolute; z-index: 10000;"> 
     <div id="results"></div> 
    </div> 

</body> 
関連する問題