0

ビルド中のアプリケーションのビルド プロセス (Ext JS + 別のアプリのバックエンドを使用) を作成し、ローカル URL を変更する「ベスト プラクティス」の方法 (例: data/my-data. json) を開発サーバーのバックエンドに送信し、その後、運用サーバーのバックエンドに送信します。

私のストアには現在、次のコードがあります。

Ext.define('APP.store.DataRecords', {
    extend: 'Ext.data.Store',
    model: 'APP.model.DataRecord',
    autoLoad: true,

    proxy: {
        type: 'ajax',
        api: {
            read: 'data/data-records.json',
            update: 'data/update-data-records.json'
        },
        reader: {
            type: 'json',
            root: 'records',
            successProperty: 'success'
        }
    }
});

sencha build コマンドを実行すると、ストアが次のように変換されるのが理想的です。

Ext.define('APP.store.DataRecords', {
    extend: 'Ext.data.Store',
    model: 'APP.model.DataRecord',
    autoLoad: true,

    proxy: {
        type: 'ajax',
        api: {
            read: 'http://mydevserver/.../data-records.json',
            update: 'http://mydevserver/.../update-data-records.json'
        },
        reader: {
            type: 'json',
            root: 'records',
            successProperty: 'success'
        }
    }
});

「直接的な」アプローチがない場合、最初にすべての URL を再マップし、次に sencha コンパイラを呼び出す追加のスクリプトを作成する必要があると思います。

PS通常、これはすべて「相対」URL を使用して透過的に行われることを理解していますが、やり取りしているバックエンドにはいくつかの制限があり、これが妨げられています。

考え?

前もって感謝します!

4

2 に答える 2

1

ストアに接続するときに完全な URL を使用しないことをお勧めします。Ajax 呼び出しを使用していて、別のドメイン名にアクセスしようとすると、そのような呼び出しはクロスサイト呼び出しとして扱われ、ブラウザーはそれらをブロックします。

于 2012-04-23T10:32:55.410 に答える
0

app.json で

    /**
     * override objects for setting build environment specific
     * settings.
     */
    "production": {
      "api_url": "http://example.com"
    },

    "testing": {
      "api_url": "http://localhost:3000"
    },

    "development": {
      "api_url": "http://localhost:3000"
    },

ストアのプロキシ設定で

    proxy: {
      type: 'rest',
      url: Ext.manifest.api_url + '/products',
      format: 'json',
      withCredentials: true,
      useDefaultXhrHeader: false,
      reader: {
        type: 'json',
        rootProperty: '',
        totalProperty: ''
      },
      writer: {
        type: 'json'
      }
    }

于 2015-04-02T10:52:47.030 に答える