Skip to content
This repository has been archived by the owner on Mar 20, 2024. It is now read-only.

响应data数据连在一个chunk包里了 #11

Closed
nephen opened this issue Apr 9, 2023 · 8 comments
Closed

响应data数据连在一个chunk包里了 #11

nephen opened this issue Apr 9, 2023 · 8 comments

Comments

@nephen
Copy link
Contributor

nephen commented Apr 9, 2023

data包中间可能没有加\r\n造成的?

{
    "message": {
        "id": "c1375983-8681-4978-959b-e5bfc39b157b",
        "author": {
            "role": "assistant",
            "name": null,
            "metadata": {}
        },
        "create_time": 1681017612.273399,
        "update_time": null,
        "content": {
            "content_type": "text",
            "parts": ["\u5728Vue\u4e2d\uff0c\u53ef\u4ee5\u4f7f\u7528\u6d4f\u89c8\u5668\u7684\u672c\u5730\u5b58\u50a8\uff08LocalStorage\uff09\u6765\u7f13\u5b58input\u7684\u503c\uff0c\u8fd9\u6837\u5373\u4f7f\u5237\u65b0\u9875\u9762\u6216\u8005\u5173\u95ed\u518d\u6253\u5f00\u9875\u9762\uff0c\u8f93\u5165\u6846\u4e2d\u7684\u503c\u4e5f\u80fd\u591f\u88ab\u4fdd\u7559\u4e0b\u6765\u3002\u4e0b\u9762\u662f\u4e00\u4e2a\u57fa\u4e8eLocalStorage\u7684\u7b80\u5355\u793a\u4f8b\uff1a\n\n1. \u5b9a\u4e49\u4e00\u4e2aMixin\uff0c\u5728\u5176\u4e2d\u5b9e\u73b0\u5bf9LocalStorage\u7684\u8bfb\u5199\u64cd\u4f5c\uff1a\n\n```\nconst CacheMixin = {\n  methods: {\n    setCache(key, value) {\n      localStorage.setItem(key, JSON.stringify(value));\n    },\n    getCache(key) {\n      const value = localStorage.getItem(key);\n      if (value) {\n        return JSON.parse(value);\n      }\n      return null;\n    },\n  },\n};\n```\n\n2. \u5728input\u7ec4\u4ef6\u4e2d\u4f7f\u7528Mixin\ufdata:{"message": {"id": "c1375983-8681-4978-959b-e5bfc39b157b", "author": {"role": "assistant", "name": null, "metadata": {}}, "create_time": 1681017612.273399, "update_time": null, "content": {"content_type": "text", "parts": ["\u5728Vue\u4e2d\uff0c\u53ef\u4ee5\u4f7f\u7528\u6d4f\u89c8\u5668\u7684\u672c\u5730\u5b58\u50a8\uff08LocalStorage\uff09\u6765\u7f13\u5b58input\u7684\u503c\uff0c\u8fd9\u6837\u5373\u4f7f\u5237\u65b0\u9875\u9762\u6216\u8005\u5173\u95ed\u518d\u6253\u5f00\u9875\u9762\uff0c\u8f93\u5165\u6846\u4e2d\u7684\u503c\u4e5f\u80fd\u591f\u88ab\u4fdd\u7559\u4e0b\u6765\u3002\u4e0b\u9762\u662f\u4e00\u4e2a\u57fa\u4e8eLocalStorage\u7684\u7b80\u5355\u793a\u4f8b\uff1a\n\n1. \u5b9a\u4e49\u4e00\u4e2aMixin\uff0c\u5728\u5176\u4e2d\u5b9e\u73b0\u5bf9LocalStorage\u7684\u8bfb\u5199\u64cd\u4f5c\uff1a\n\n```\nconst CacheMixin = {\n  methods: {\n    setCache(key, value) {\n      localStorage.setItem(key, JSON.stringify(value));\n
                        },\n    getCache(key) {\n      const value = localStorage.getItem(key);\n      if (value) {\n        return JSON.parse(value);\n
                            }\n      return null;\n
                        },\n
                    },\n
                };\n```\n\n2. \u5728input\u7ec4\u4ef6\u4e2d\u4f7f\u7528Mixin\uff0c\u5e76\u5728mounted\u751f\u547d\u5468\u671f\u4e2d\u8bfb\u53d6\u7f13\u5b58\u7684\u503c\u5e76\u8bbe\u7f6e\u5230input\u4e2d\uff1a\n\n```\n<template>\n  <div>\n    <input type=\"text\" v-model=\"value\" />\n  </div>\n</template>\n\n<script>\nimport CacheMixin from \"@/mixins/cache\";\n\nexport default {\n  mixins: [CacheMixin],\n  data() {\n    return {\n      value: \"\",\n    };\n  },\n  mounted() {\n    const cacheValue = this.getCache(\"inputValue\");\n    if (cacheValue) {\n      this.value = cacheValue;\n    }\n  },\n  watch: {\n    value(newVal) {\n      this.setCache(\"inputValue\", newVal);\n    },\n  },\n};\n</script>\n```\n\n\u8fd9\u91cc\u6211\u4eec\u5b9a\u4e49\u4e86\u4e00\u4e2aCacheMixin\uff0c\u901a\u8fc7\u8c03\u7528getCache\u548csetCache\u65b9\u6cd5\u5b9e\u73b0"
            ]
        },
        "end_turn": null,
        "weight": 1.0,
        "metadata": {
            "message_type": "next",
            "model_slug": "text-davinci-002-render-sha"
        },
        "recipient": "all"
    },
    "conversation_id": "0d4755ce-762c-4b3d-a3c3-8b95e1af4138",
    "error": null
}data: {
    "message": {
        "id": "c1375983-8681-4978-959b-e5bfc39b157b",
        "author": {
            "role": "assistant",
            "name": null,
            "metadata": {}
        },
        "create_time": 1681017612.273399,
        "update_time": null,
        "content": {
            "content_type": "text",
            "parts": [
                "\u5728Vue\u4e2d\uff0c\u53ef\u4ee5\u4f7f\u7528\u6d4f\u89c8\u5668\u7684\u672c\u5730\u5b58\u50a8\uff08LocalStorage\uff09\u6765\u7f13\u5b58input\u7684\u503c\uff0c\u8fd9\u6837\u5373\u4f7f\u5237\u65b0\u9875\u9762\u6216\u8005\u5173\u95ed\u518d\u6253\u5f00\u9875\u9762\uff0c\u8f93\u5165\u6846\u4e2d\u7684\u503c\u4e5f\u80fd\u591f\u88ab\u4fdd\u7559\u4e0b\u6765\u3002\u4e0b\u9762\u662f\u4e00\u4e2a\u57fa\u4e8eLocalStorage\u7684\u7b80\u5355\u793a\u4f8b\uff1a\n\n1. \u5b9a\u4e49\u4e00\u4e2aMixin\uff0c\u5728\u5176\u4e2d\u5b9e\u73b0\u5bf9LocalStorage\u7684\u8bfb\u5199\u64cd\u4f5c\uff1a\n\n```\nconst CacheMixin = {\n  methods: {\n    setCache(key, value) {\n      localStorage.setItem(key, JSON.stringify(value));\n    },\n    getCache(key) {\n      const value = localStorage.getItem(key);\n      if (value) {\n        return JSON.parse(value);\n      }\n      return null;\n    },\n  },\n};\n```\n\n2. \u5728input\u7ec4\u4ef6\u4e2d\u4f7f\u7528Mixin\uff0c\u5e76\u5728mounted\u751f\u547d\u5468\u671f\u4e2d\u8bfb\u53d6\u7f13\u5b58\u7684\u503c\u5e76\u8bbe\u7f6e\u5230input\u4e2d\uff1a\n\n```\n<template>\n  <div>\n    <input type=\"text\" v-model=\"value\" />\n  </div>\n</template>\n\n<script>\nimport CacheMixin from \"@/mixins/cache\";\n\nexport default {\n  mixins: [CacheMixin],\n  data() {\n    return {\n      value: \"\",\n    };\n  },\n  mounted() {\n    const cacheValue = this.getCache(\"inputValue\");\n    if (cacheValue) {\n      this.value = cacheValue;\n    }\n  },\n  watch: {\n    value(newVal) {\n      this.setCache(\"inputValue\", newVal);\n    },\n  },\n};\n</script>\n```\n\n\u8fd9\u91cc\u6211\u4eec\u5b9a\u4e49\u4e86\u4e00\u4e2aCacheMixin\uff0c\u901a\u8fc7\u8c03\u7528getCache\u548csetCache\u65b9\u6cd5\u5b9e\u73b0\u8bfb\u5199LocalStorage\u3002\u5728input\u7ec4\u4ef6\u4e2d\u4f7f\u7528Mixin\uff0c\u5e76\u5728mounted\u751f\u547d\u5468\u671f\u4e2d"
            ]
        },
        "end_turn": null,
        "weight": 1.0,
        "metadata": {
            "message_type": "next",
            "model_slug": "text-davinci-002-render-sha"
        },
        "recipient": "all"
    },
    "conversation_id": "0d4755ce-762c-4b3d-a3c3-8b95e1af4138",
    "error": null
}data: {
    "message": {
        "id": "c1375983-8681-4978-959b-e5bfc39b157b",
        "author": {
            "role": "assistant",
            "name": null,
            "metadata": {}
        },
        "create_time": 1681017612.273399,
        "update_time": null,
        "content": {
            "content_type": "text",
            "parts": [
                "\u5728Vue\u4e2d\uff0c\u53ef\u4ee5\u4f7f\u7528\u6d4f\u89c8\u5668\u7684\u672c\u5730\u5b58\u50a8\uff08LocalStorage\uff09\u6765\u7f13\u5b58input\u7684\u503c\uff0c\u8fd9\u6837\u5373\u4f7f\u5237\u65b0\u9875\u9762\u6216\u8005\u5173\u95ed\u518d\u6253\u5f00\u9875\u9762\uff0c\u8f93\u5165\u6846\u4e2d\u7684\u503c\u4e5f\u80fd\u591f\u88ab\u4fdd\u7559\u4e0b\u6765\u3002\u4e0b\u9762\u662f\u4e00\u4e2a\u57fa\u4e8eLocalStorage\u7684\u7b80\u5355\u793a\u4f8b\uff1a\n\n1. \u5b9a\u4e49\u4e00\u4e2aMixin\uff0c\u5728\u5176\u4e2d\u5b9e\u73b0\u5bf9LocalStorage\u7684\u8bfb\u5199\u64cd\u4f5c\uff1a\n\n```\nconst CacheMixin = {\n  methods: {\n    setCache(key, value) {\n      localStorage.setItem(key, JSON.stringify(value));\n    },\n    getCache(key) {\n      const value = localStorage.getItem(key);\n      if (value) {\n        return JSON.parse(value);\n      }\n      return null;\n    },\n  },\n};\n```\n\n2. \u5728input\u7ec4\u4ef6\u4e2d\u4f7f\u7528Mixin\uff0c\u5e76\u5728mounted\u751f\u547d\u5468\u671f\u4e2d\u8bfb\u53d6\u7f13\u5b58\u7684\u503c\u5e76\u8bbe\u7f6e\u5230input\u4e2d\uff1a\n\n```\n<template>\n  <div>\n    <input type=\"text\" v-model=\"value\" />\n  </div>\n</template>\n\n<script>\nimport CacheMixin from \"@/mixins/cache\";\n\nexport default {\n  mixins: [CacheMixin],\n  data() {\n    return {\n      value: \"\",\n    };\n  },\n  mounted() {\n    const cacheValue = this.getCache(\"inputValue\");\n    if (cacheValue) {\n      this.value = cacheValue;\n    }\n  },\n  watch: {\n    value(newVal) {\n      this.setCache(\"inputValue\", newVal);\n    },\n  },\n};\n</script>\n```\n\n\u8fd9\u91cc\u6211\u4eec\u5b9a\u4e49\u4e86\u4e00\u4e2aCacheMixin\uff0c\u901a\u8fc7\u8c03\u7528getCache\u548csetCache\u65b9\u6cd5\u5b9e\u73b0\u8bfb\u5199LocalStorage\u3002\u5728input\u7ec4\u4ef6\u4e2d\u4f7f\u7528Mixin\uff0c\u5e76\u5728mounted\u751f\u547d\u5468\u671f\u4e2d\u8bfb\u53d6\u7f13\u5b58\u7684\u503c\u5e76\u8bbe\u7f6e"
            ]
        },
        "end_turn": null,
        "weight": 1.0,
        "metadata": {
            "message_type": "next",
            "model_slug": "text-davinci-002-render-sha"
        },
        "recipient": "all"
    },
    "conversation_id": "0d4755ce-762c-4b3d-a3c3-8b95e1af4138",
    "error": null
}data: {
    "message": {
        "id": "c1375983-8681-4978-959b-e5bfc39b157b",
        "author": {
            "role": "assistant",
            "name": null,
            "metadata": {}
        },
        "create_time": 1681017612.273399,
        "update_time": null,
        "content": {
            "content_type": "text",
            "parts": [
                "\u5728Vue\u4e2d\uff0c\u53ef\u4ee5\u4f7f\u7528\u6d4f\u89c8\u5668\u7684\u672c\u5730\u5b58\u50a8\uff08LocalStorage\uff09\u6765\u7f13\u5b58input\u7684\u503c\uff0c\u8fd9\u6837\u5373\u4f7f\u5237\u65b0\u9875\u9762\u6216\u8005\u5173\u95ed\u518d\u6253\u5f00\u9875\u9762\uff0c\u8f93\u5165\u6846\u4e2d\u7684\u503c\u4e5f\u80fd\u591f\u88ab\u4fdd\u7559\u4e0b\u6765\u3002\u4e0b\u9762\u662f\u4e00\u4e2a\u57fa\u4e8eLocalStorage\u7684\u7b80\u5355\u793a\u4f8b\uff1a\n\n1. \u5b9a\u4e49\u4e00\u4e2aMixin\uff0c\u5728\u5176\u4e2d\u5b9e\u73b0\u5bf9LocalStorage\u7684\u8bfb\u5199\u64cd\u4f5c\uff1a\n\n```\nconst CacheMixin = {\n  methods: {\n    setCache(key, value) {\n      localStorage.setItem(key, JSON.stringify(value));\n    },\n    getCache(key) {\n      const value = localStorage.getItem(key);\n      if (value) {\n        return JSON.parse(value);\n      }\n      return null;\n    },\n  },\n};\n```\n\n2. \u5728input\u7ec4\u4ef6\u4e2d\u4f7f\u7528Mixin\uff0c\u5e76\u5728mounted\u751f\u547d\u5468\u671f\u4e2d\u8bfb\u53d6\u7f13\u5b58\u7684\u503c\u5e76\u8bbe\u7f6e\u5230input\u4e2d\uff1a\n\n```\n<template>\n  <div>\n    <input type=\"text\" v-model=\"value\" />\n  </div>\n</template>\n\n<script>\nimport CacheMixin from \"@/mixins/cache\";\n\nexport default {\n  mixins: [CacheMixin],\n  data() {\n    return {\n      value: \"\",\n    };\n  },\n  mounted() {\n    const cacheValue = this.getCache(\"inputValue\");\n    if (cacheValue) {\n      this.value = cacheValue;\n    }\n  },\n  watch: {\n    value(newVal) {\n      this.setCache(\"inputValue\", newVal);\n    },\n  },\n};\n</script>\n```\n\n\u8fd9\u91cc\u6211\u4eec\u5b9a\u4e49\u4e86\u4e00\u4e2aCacheMixin\uff0c\u901a\u8fc7\u8c03\u7528getCache\u548csetCache\u65b9\u6cd5\u5b9e\u73b0\u8bfb\u5199LocalStorage\u3002\u5728input\u7ec4\u4ef6\u4e2d\u4f7f\u7528Mixin\uff0c\u5e76\u5728mounted\u751f\u547d\u5468\u671f\u4e2d\u8bfb\u53d6\u7f13\u5b58\u7684\u503c\u5e76\u8bbe\u7f6e\u5230input\u4e2d\uff0c\u5728input\u7684watch\u4e2d\u76d1\u542cvalue\u7684\u53d8\u5316\uff0c\u5e76\u5c06\u5176"
            ]
        },
        "end_turn": null,
        "weight": 1.0,
        "metadata": {
            "message_type": "next",
            "model_slug": "text-davinci-002-render-sha"
        },
        "recipient": "all"
    },
    "conversation_id": "0d4755ce-762c-4b3d-a3c3-8b95e1af4138",
    "error": null
}data: {
    "message": {
        "id": "c1375983-8681-4978-959b-e5bfc39b157b",
        "author": {
            "role": "assistant",
            "name": null,
            "metadata": {}
        },
        "create_time": 1681017612.273399,
        "update_time": null,
        "content": {
            "content_type": "text",
            "parts": [
                "\u5728Vue\u4e2d\uff0c\u53ef\u4ee5\u4f7f\u7528\u6d4f\u89c8\u5668\u7684\u672c\u5730\u5b58\u50a8\uff08LocalStorage\uff09\u6765\u7f13\u5b58input\u7684\u503c\uff0c\u8fd9\u6837\u5373\u4f7f\u5237\u65b0\u9875\u9762\u6216\u8005\u5173\u95ed\u518d\u6253\u5f00\u9875\u9762\uff0c\u8f93\u5165\u6846\u4e2d\u7684\u503c\u4e5f\u80fd\u591f\u88ab\u4fdd\u7559\u4e0b\u6765\u3002\u4e0b\u9762\u662f\u4e00\u4e2a\u57fa\u4e8eLocalStorage\u7684\u7b80\u5355\u793a\u4f8b\uff1a\n\n1. \u5b9a\u4e49\u4e00\u4e2aMixin\uff0c\u5728\u5176\u4e2d\u5b9e\u73b0\u5bf9LocalStorage\u7684\u8bfb\u5199\u64cd\u4f5c\uff1a\n\n```\nconst CacheMixin = {\n  methods: {\n    setCache(key, value) {\n      localStorage.setItem(key, JSON.stringify(value));\n    },\n    getCache(key) {\n      const value = localStorage.getItem(key);\n      if (value) {\n        return JSON.parse(value);\n      }\n      return null;\n    },\n  },\n};\n```\n\n2. \u5728input\u7ec4\u4ef6\u4e2d\u4f7f\u7528Mixin\uff0c\u5e76\u5728mounted\u751f\u547d\u5468\u671f\u4e2d\u8bfb\u53d6\u7f13\u5b58\u7684\u503c\u5e76\u8bbe\u7f6e\u5230input\u4e2d\uff1a\n\n```\n<template>\n  <div>\n    <input type=\"text\" v-model=\"value\" />\n  </div>\n</template>\n\n<script>\nimport CacheMixin from \"@/mixins/cache\";\n\nexport default {\n  mixins: [CacheMixin],\n  data() {\n    return {\n      value: \"\",\n    };\n  },\n  mounted() {\n    const cacheValue = this.getCache(\"inputValue\");\n    if (cacheValue) {\n      this.value = cacheValue;\n    }\n  },\n  watch: {\n    value(newVal) {\n      this.setCache(\"inputValue\", newVal);\n    },\n  },\n};\n</script>\n```\n\n\u8fd9\u91cc\u6211\u4eec\u5b9a\u4e49\u4e86\u4e00\u4e2aCacheMixin\uff0c\u901a\u8fc7\u8c03\u7528getCache\u548csetCache\u65b9\u6cd5\u5b9e\u73b0\u8bfb\u5199LocalStorage\u3002\u5728input\u7ec4\u4ef6\u4e2d\u4f7f\u7528Mixin\uff0c\u5e76\u5728mounted\u751f\u547d\u5468\u671f\u4e2d\u8bfb\u53d6\u7f13\u5b58\u7684\u503c\u5e76\u8bbe\u7f6e\u5230input\u4e2d\uff0c\u5728input\u7684watch\u4e2d\u76d1\u542cvalue\u7684\u53d8\u5316\uff0c\u5e76\u5c06\u5176\u5b58\u5165LocalStorage"
            ]
        },
        "end_turn": null,
        "weight": 1.0,
        "metadata": {
            "message_type": "next",
            "model_slug": "text-davinci-002-render-sha"
        },
        "recipient": "all"
    },
    "conversation_id": "0d4755ce-762c-4b3d-a3c3-8b95e1af4138",
    "error": null
}data: {
    "message": {
        "id": "c1375983-8681-4978-959b-e5bfc39b157b",
        "author": {
            "role": "assistant",
            "name": null,
            "metadata": {}
        },
        "create_time": 1681017612.273399,
        "update_time": null,
        "content": {
            "content_type": "text",
            "parts": [
                "\u5728Vue\u4e2d\uff0c\u53ef\u4ee5\u4f7f\u7528\u6d4f\u89c8\u5668\u7684\u672c\u5730\u5b58\u50a8\uff08LocalStorage\uff09\u6765\u7f13\u5b58input\u7684\u503c\uff0c\u8fd9\u6837\u5373\u4f7f\u5237\u65b0\u9875\u9762\u6216\u8005\u5173\u95ed\u518d\u6253\u5f00\u9875\u9762\uff0c\u8f93\u5165\u6846\u4e2d\u7684\u503c\u4e5f\u80fd\u591f\u88ab\u4fdd\u7559\u4e0b\u6765\u3002\u4e0b\u9762\u662f\u4e00\u4e2a\u57fa\u4e8eLocalStorage\u7684\u7b80\u5355\u793a\u4f8b\uff1a\n\n1. \u5b9a\u4e49\u4e00\u4e2aMixin\uff0c\u5728\u5176\u4e2d\u5b9e\u73b0\u5bf9LocalStorage\u7684\u8bfb\u5199\u64cd\u4f5c\uff1a\n\n```\nconst CacheMixin = {\n  methods: {\n    setCache(key, value) {\n      localStorage.setItem(key, JSON.stringify(value));\n    },\n    getCache(key) {\n      const value = localStorage.getItem(key);\n      if (value) {\n        return JSON.parse(value);\n      }\n      return null;\n    },\n  },\n};\n```\n\n2. \u5728input\u7ec4\u4ef6\u4e2d\u4f7f\u7528Mixin\uff0c\u5e76\u5728mounted\u751f\u547d\u5468\u671f\u4e2d\u8bfb\u53d6\u7f13\u5b58\u7684\u503c\u5e76\u8bbe\u7f6e\u5230input\u4e2d\uff1a\n\n```\n<template>\n  <div>\n    <input type=\"text\" v-model=\"value\" />\n  </div>\n</template>\n\n<script>\nimport CacheMixin from \"@/mixins/cache\";\n\nexport default {\n  mixins: [CacheMixin],\n  data() {\n    return {\n      value: \"\",\n    };\n  },\n  mounted() {\n    const cacheValue = this.getCache(\"inputValue\");\n    if (cacheValue) {\n      this.value = cacheValue;\n    }\n  },\n  watch: {\n    value(newVal) {\n      this.setCache(\"inputValue\", newVal);\n    },\n  },\n};\n</script>\n```\n\n\u8fd9\u91cc\u6211\u4eec\u5b9a\u4e49\u4e86\u4e00\u4e2aCacheMixin\uff0c\u901a\u8fc7\u8c03\u7528getCache\u548csetCache\u65b9\u6cd5\u5b9e\u73b0\u8bfb\u5199LocalStorage\u3002\u5728input\u7ec4\u4ef6\u4e2d\u4f7f\u7528Mixin\uff0c\u5e76\u5728mounted\u751f\u547d\u5468\u671f\u4e2d\u8bfb\u53d6\u7f13\u5b58\u7684\u503c\u5e76\u8bbe\u7f6e\u5230input\u4e2d\uff0c\u5728input\u7684watch\u4e2d\u76d1\u542cvalue\u7684\u53d8\u5316\uff0c\u5e76\u5c06\u5176\u5b58\u5165LocalStorage\u4e2d"
            ]
        },
        "end_turn": null,
        "weight": 1.0,
        "metadata": {
            "message_type": "next",
            "model_slug": "text-davinci-002-render-sha"
        },
        "recipient": "all"
    },
    "conversation_id": "0d4755ce-762c-4b3d-a3c3-8b95e1af4138",
    "error": null
}data: {
    "message": {
        "id": "c1375983-8681-4978-959b-e5bfc39b157b",
        "author": {
            "role": "assistant",
            "name": null,
            "metadata": {}
        },
        "create_time": 1681017612.273399,
        "update_time": null,
        "content": {
            "content_type": "text",
            "parts": [
                "\u5728Vue\u4e2d\uff0c\u53ef\u4ee5\u4f7f\u7528\u6d4f\u89c8\u5668\u7684\u672c\u5730\u5b58\u50a8\uff08LocalStorage\uff09\u6765\u7f13\u5b58input\u7684\u503c\uff0c\u8fd9\u6837\u5373\u4f7f\u5237\u65b0\u9875\u9762\u6216\u8005\u5173\u95ed\u518d\u6253\u5f00\u9875\u9762\uff0c\u8f93\u5165\u6846\u4e2d\u7684\u503c\u4e5f\u80fd\u591f\u88ab\u4fdd\u7559\u4e0b\u6765\u3002\u4e0b\u9762\u662f\u4e00\u4e2a\u57fa\u4e8eLocalStorage\u7684\u7b80\u5355\u793a\u4f8b\uff1a\n\n1. \u5b9a\u4e49\u4e00\u4e2aMixin\uff0c\u5728\u5176\u4e2d\u5b9e\u73b0\u5bf9LocalStorage\u7684\u8bfb\u5199\u64cd\u4f5c\uff1a\n\n```\nconst CacheMixin = {\n  methods: {\n    setCache(key, value) {\n      localStorage.setItem(key, JSON.stringify(value));\n    },\n    getCache(key) {\n      const value = localStorage.getItem(key);\n      if (value) {\n        return JSON.parse(value);\n      }\n      return null;\n    },\n  },\n};\n```\n\n2. \u5728input\u7ec4\u4ef6\u4e2d\u4f7f\u7528Mixin\uff0c\u5e76\u5728mounted\u751f\u547d\u5468\u671f\u4e2d\u8bfb\u53d6\u7f13\u5b58\u7684\u503c\u5e76\u8bbe\u7f6e\u5230input\u4e2d\uff1a\n\n```\n<template>\n  <div>\n    <input type=\"text\" v-model=\"value\" />\n  </div>\n</template>\n\n<script>\nimport CacheMixin from \"@/mixins/cache\";\n\nexport default {\n  mixins: [CacheMixin],\n  data() {\n    return {\n      value: \"\",\n    };\n  },\n  mounted() {\n    const cacheValue = this.getCache(\"inputValue\");\n    if (cacheValue) {\n      this.value = cacheValue;\n    }\n  },\n  watch: {\n    value(newVal) {\n      this.setCache(\"inputValue\", newVal);\n    },\n  },\n};\n</script>\n```\n\n\u8fd9\u91cc\u6211\u4eec\u5b9a\u4e49\u4e86\u4e00\u4e2aCacheMixin\uff0c\u901a\u8fc7\u8c03\u7528getCache\u548csetCache\u65b9\u6cd5\u5b9e\u73b0\u8bfb\u5199LocalStorage\u3002\u5728input\u7ec4\u4ef6\u4e2d\u4f7f\u7528Mixin\uff0c\u5e76\u5728mounted\u751f\u547d\u5468\u671f\u4e2d\u8bfb\u53d6\u7f13\u5b58\u7684\u503c\u5e76\u8bbe\u7f6e\u5230input\u4e2d\uff0c\u5728input\u7684watch\u4e2d\u76d1\u542cvalue\u7684\u53d8\u5316\uff0c\u5e76\u5c06\u5176\u5b58\u5165LocalStorage\u4e2d\u3002\n\n\u8fd9\u6837\u5373\u4f7f\u5728\u5f00\u542f\u591a\u4e2a\u76f8\u540c\u7f51\u9875\u9875\u9762\u7684\u60c5\u51b5\u4e0b"
            ]
        },
        "end_turn": null,
        "weight": 1.0,
        "metadata": {
            "message_type": "next",
            "model_slug": "text-davinci-002-render-sha"
        },
        "recipient": "all"
    },
    "conversation_id": "0d4755ce-762c-4b3d-a3c3-8b95e1af4138",
    "error": null
}data: {
    "message": {
        "id": "c1375983-8681-4978-959b-e5bfc39b157b",
        "author": {
            "role": "assistant",
            "name": null,
            "metadata": {}
        },
        "create_time": 1681017612.273399,
        "update_time": null,
        "content": {
            "content_type": "text",
            "parts": [
                "\u5728Vue\u4e2d\uff0c\u53ef\u4ee5\u4f7f\u7528\u6d4f\u89c8\u5668\u7684\u672c\u5730\u5b58\u50a8\uff08LocalStorage\uff09\u6765\u7f13\u5b58input\u7684\u503c\uff0c\u8fd9\u6837\u5373\u4f7f\u5237\u65b0\u9875\u9762\u6216\u8005\u5173\u95ed\u518d\u6253\u5f00\u9875\u9762\uff0c\u8f93\u5165\u6846\u4e2d\u7684\u503c\u4e5f\u80fd\u591f\u88ab\u4fdd\u7559\u4e0b\u6765\u3002\u4e0b\u9762\u662f\u4e00\u4e2a\u57fa\u4e8eLocalStorage\u7684\u7b80\u5355\u793a\u4f8b\uff1a\n\n1. \u5b9a\u4e49\u4e00\u4e2aMixin\uff0c\u5728\u5176\u4e2d\u5b9e\u73b0\u5bf9LocalStorage\u7684\u8bfb\u5199\u64cd\u4f5c\uff1a\n\n```\nconst CacheMixin = {\n  methods: {\n    setCache(key, value) {\n      localStorage.setItem(key, JSON.stringify(value));\n    },\n    getCache(key) {\n      const value = localStorage.getItem(key);\n      if (value) {\n        return JSON.parse(value);\n      }\n      return null;\n    },\n  },\n};\n```\n\n2. \u5728input\u7ec4\u4ef6\u4e2d\u4f7f\u7528Mixin\uff0c\u5e76\u5728mounted\u751f\u547d\u5468\u671f\u4e2d\u8bfb\u53d6\u7f13\u5b58\u7684\u503c\u5e76\u8bbe\u7f6e\u5230input\u4e2d\uff1a\n\n```\n<template>\n  <div>\n    <input type=\"text\" v-model=\"value\" />\n  </div>\n</template>\n\n<script>\nimport CacheMixin from \"@/mixins/cache\";\n\nexport default {\n  mixins: [CacheMixin],\n  data() {\n    return {\n      value: \"\",\n    };\n  },\n  mounted() {\n    const cacheValue = this.getCache(\"inputValue\");\n    if (cacheValue) {\n      this.value = cacheValue;\n    }\n  },\n  watch: {\n    value(newVal) {\n      this.setCache(\"inputValue\", newVal);\n    },\n  },\n};\n</script>\n```\n\n\u8fd9\u91cc\u6211\u4eec\u5b9a\u4e49\u4e86\u4e00\u4e2aCacheMixin\uff0c\u901a\u8fc7\u8c03\u7528getCache\u548csetCache\u65b9\u6cd5\u5b9e\u73b0\u8bfb\u5199LocalStorage\u3002\u5728input\u7ec4\u4ef6\u4e2d\u4f7f\u7528Mixin\uff0c\u5e76\u5728mounted\u751f\u547d\u5468\u671f\u4e2d\u8bfb\u53d6\u7f13\u5b58\u7684\u503c\u5e76\u8bbe\u7f6e\u5230input\u4e2d\uff0c\u5728input\u7684watch\u4e2d\u76d1\u542cvalue\u7684\u53d8\u5316\uff0c\u5e76\u5c06\u5176\u5b58\u5165LocalStorage\u4e2d\u3002\n\n\u8fd9\u6837\u5373\u4f7f\u5728\u5f00\u542f\u591a\u4e2a\u76f8\u540c\u7f51\u9875\u9875\u9762\u7684\u60c5\u51b5\u4e0b\uff0c\u6bcf\u4e2a\u9875\u9762\u90fd\u80fd\u72ec\u7acb\u7f13\u5b58\u81ea\u5df1\u7684"
            ]
        },
        "end_turn": null,
        "weight": 1.0,
        "metadata": {
            "message_type": "next",
            "model_slug": "text-davinci-002-render-sha"
        },
        "recipient": "all"
    },
    "conversation_id": "0d4755ce-762c-4b3d-a3c3-8b95e1af4138",
    "error": null
}data: {
    "message": {
        "id": "c1375983-8681-4978-959b-e5bfc39b157b",
        "author": {
            "role": "assistant",
            "name": null,
            "metadata": {}
        },
        "create_time": 1681017612.273399,
        "update_time": null,
        "content": {
            "content_type": "text",
            "parts": [
                "\u5728Vue\u4e2d\uff0c\u53ef\u4ee5\u4f7f\u7528\u6d4f\u89c8\u5668\u7684\u672c\u5730\u5b58\u50a8\uff08LocalStorage\uff09\u6765\u7f13\u5b58input\u7684\u503c\uff0c\u8fd9\u6837\u5373\u4f7f\u5237\u65b0\u9875\u9762\u6216\u8005\u5173\u95ed\u518d\u6253\u5f00\u9875\u9762\uff0c\u8f93\u5165\u6846\u4e2d\u7684\u503c\u4e5f\u80fd\u591f\u88ab\u4fdd\u7559\u4e0b\u6765\u3002\u4e0b\u9762\u662f\u4e00\u4e2a\u57fa\u4e8eLocalStorage\u7684\u7b80\u5355\u793a\u4f8b\uff1a\n\n1. \u5b9a\u4e49\u4e00\u4e2aMixin\uff0c\u5728\u5176\u4e2d\u5b9e\u73b0\u5bf9LocalStorage\u7684\u8bfb\u5199\u64cd\u4f5c\uff1a\n\n```\nconst CacheMixin = {\n  methods: {\n    setCache(key, value) {\n      localStorage.setItem(key, JSON.stringify(value));\n    },\n    getCache(key) {\n      const value = localStorage.getItem(key);\n      if (value) {\n        return JSON.parse(value);\n      }\n      return null;\n    },\n  },\n};\n```\n\n2. \u5728input\u7ec4\u4ef6\u4e2d\u4f7f\u7528Mixin\uff0c\u5e76\u5728mounted\u751f\u547d\u5468\u671f\u4e2d\u8bfb\u53d6\u7f13\u5b58\u7684\u503c\u5e76\u8bbe\u7f6e\u5230input\u4e2d\uff1a\n\n```\n<template>\n  <div>\n    <input type=\"text\" v-model=\"value\" />\n  </div>\n</template>\n\n<script>\nimport CacheMixin from \"@/mixins/cache\";\n\nexport default {\n  mixins: [CacheMixin],\n  data() {\n    return {\n      value: \"\",\n    };\n  },\n  mounted() {\n    const cacheValue = this.getCache(\"inputValue\");\n    if (cacheValue) {\n      this.value = cacheValue;\n    }\n  },\n  watch: {\n    value(newVal) {\n      this.setCache(\"inputValue\", newVal);\n    },\n  },\n};\n</script>\n```\n\n\u8fd9\u91cc\u6211\u4eec\u5b9a\u4e49\u4e86\u4e00\u4e2aCacheMixin\uff0c\u901a\u8fc7\u8c03\u7528getCache\u548csetCache\u65b9\u6cd5\u5b9e\u73b0\u8bfb\u5199LocalStorage\u3002\u5728input\u7ec4\u4ef6\u4e2d\u4f7f\u7528Mixin\uff0c\u5e76\u5728mounted\u751f\u547d\u5468\u671f\u4e2d\u8bfb\u53d6\u7f13\u5b58\u7684\u503c\u5e76\u8bbe\u7f6e\u5230input\u4e2d\uff0c\u5728input\u7684watch\u4e2d\u76d1\u542cvalue\u7684\u53d8\u5316\uff0c\u5e76\u5c06\u5176\u5b58\u5165LocalStorage\u4e2d\u3002\n\n\u8fd9\u6837\u5373\u4f7f\u5728\u5f00\u542f\u591a\u4e2a\u76f8\u540c\u7f51\u9875\u9875\u9762\u7684\u60c5\u51b5\u4e0b\uff0c\u6bcf\u4e2a\u9875\u9762\u90fd\u80fd\u72ec\u7acb\u7f13\u5b58\u81ea\u5df1\u7684input\u503c\u3002\u4f46\u9700\u8981\u6ce8\u610f\u7684\u662f\uff0cLocalStorage\u7f13\u5b58\u662f"
            ]
        },
        "end_turn": null,
        "weight": 1.0,
        "metadata": {
            "message_type": "next",
            "model_slug": "text-davinci-002-render-sha"
        },
        "recipient": "all"
    },
    "conversation_id": "0d4755ce-762c-4b3d-a3c3-8b95e1af4138",
    "error": null
}data: {
    "message": {
        "id": "c1375983-8681-4978-959b-e5bfc39b157b",
        "author": {
            "role": "assistant",
            "name": null,
            "metadata": {}
        },
        "create_time": 1681017612.273399,
        "update_time": null,
        "content": {
            "content_type": "text",
            "parts": [
                "\u5728Vue\u4e2d\uff0c\u53ef\u4ee5\u4f7f\u7528\u6d4f\u89c8\u5668\u7684\u672c\u5730\u5b58\u50a8\uff08LocalStorage\uff09\u6765\u7f13\u5b58input\u7684\u503c\uff0c\u8fd9\u6837\u5373\u4f7f\u5237\u65b0\u9875\u9762\u6216\u8005\u5173\u95ed\u518d\u6253\u5f00\u9875\u9762\uff0c\u8f93\u5165\u6846\u4e2d\u7684\u503c\u4e5f\u80fd\u591f\u88ab\u4fdd\u7559\u4e0b\u6765\u3002\u4e0b\u9762\u662f\u4e00\u4e2a\u57fa\u4e8eLocalStorage\u7684\u7b80\u5355\u793a\u4f8b\uff1a\n\n1. \u5b9a\u4e49\u4e00\u4e2aMixin\uff0c\u5728\u5176\u4e2d\u5b9e\u73b0\u5bf9LocalStorage\u7684\u8bfb\u5199\u64cd\u4f5c\uff1a\n\n```\nconst CacheMixin = {\n  methods: {\n    setCache(key, value) {\n      localStorage.setItem(key, JSON.stringify(value));\n    },\n    getCache(key) {\n      const value = localStorage.getItem(key);\n      if (value) {\n        return JSON.parse(value);\n      }\n      return null;\n    },\n  },\n};\n```\n\n2. \u5728input\u7ec4\u4ef6\u4e2d\u4f7f\u7528Mixin\uff0c\u5e76\u5728mounted\u751f\u547d\u5468\u671f\u4e2d\u8bfb\u53d6\u7f13\u5b58\u7684\u503c\u5e76\u8bbe\u7f6e\u5230input\u4e2d\uff1a\n\n```\n<template>\n  <div>\n    <input type=\"text\" v-model=\"value\" />\n  </div>\n</template>\n\n<script>\nimport CacheMixin from \"@/mixins/cache\";\n\nexport default {\n  mixins: [CacheMixin],\n  data() {\n    return {\n      value: \"\",\n    };\n  },\n  mounted() {\n    const cacheValue = this.getCache(\"inputValue\");\n    if (cacheValue) {\n      this.value = cacheValue;\n    }\n  },\n  watch: {\n    value(newVal) {\n      this.setCache(\"inputValue\", newVal);\n    },\n  },\n};\n</script>\n```\n\n\u8fd9\u91cc\u6211\u4eec\u5b9a\u4e49\u4e86\u4e00\u4e2aCacheMixin\uff0c\u901a\u8fc7\u8c03\u7528getCache\u548csetCache\u65b9\u6cd5\u5b9e\u73b0\u8bfb\u5199LocalStorage\u3002\u5728input\u7ec4\u4ef6\u4e2d\u4f7f\u7528Mixin\uff0c\u5e76\u5728mounted\u751f\u547d\u5468\u671f\u4e2d\u8bfb\u53d6\u7f13\u5b58\u7684\u503c\u5e76\u8bbe\u7f6e\u5230input\u4e2d\uff0c\u5728input\u7684watch\u4e2d\u76d1\u542cvalue\u7684\u53d8\u5316\uff0c\u5e76\u5c06\u5176\u5b58\u5165LocalStorage\u4e2d\u3002\n\n\u8fd9\u6837\u5373\u4f7f\u5728\u5f00\u542f\u591a\u4e2a\u76f8\u540c\u7f51\u9875\u9875\u9762\u7684\u60c5\u51b5\u4e0b\uff0c\u6bcf\u4e2a\u9875\u9762\u90fd\u80fd\u72ec\u7acb\u7f13\u5b58\u81ea\u5df1\u7684input\u503c\u3002\u4f46\u9700\u8981\u6ce8\u610f\u7684\u662f\uff0cLocalStorage\u7f13\u5b58\u662f\u57fa\u4e8e\u6d4f\u89c8\u5668"
            ]
        },
        "end_turn": null,
        "weight": 1.0,
        "metadata": {
            "message_type": "next",
            "model_slug": "text-davinci-002-render-sha"
        },
        "recipient": "all"
    },
    "conversation_id": "0d4755ce-762c-4b3d-a3c3-8b95e1af4138",
    "error": null
}data: {
    "message": {
        "id": "c1375983-8681-4978-959b-e5bfc39b157b",
        "author": {
            "role": "assistant",
            "name": null,
            "metadata": {}
        },
        "create_time": 1681017612.273399,
        "update_time": null,
        "content": {
            "content_type": "text",
            "parts": [
                "\u5728Vue\u4e2d\uff0c\u53ef\u4ee5\u4f7f\u7528\u6d4f\u89c8\u5668\u7684\u672c\u5730\u5b58\u50a8\uff08LocalStorage\uff09\u6765\u7f13\u5b58input\u7684\u503c\uff0c\u8fd9\u6837\u5373\u4f7f\u5237\u65b0\u9875\u9762\u6216\u8005\u5173\u95ed\u518d\u6253\u5f00\u9875\u9762\uff0c\u8f93\u5165\u6846\u4e2d\u7684\u503c\u4e5f\u80fd\u591f\u88ab\u4fdd\u7559\u4e0b\u6765\u3002\u4e0b\u9762\u662f\u4e00\u4e2a\u57fa\u4e8eLocalStorage\u7684\u7b80\u5355\u793a\u4f8b\uff1a\n\n1. \u5b9a\u4e49\u4e00\u4e2aMixin\uff0c\u5728\u5176\u4e2d\u5b9e\u73b0\u5bf9LocalStorage\u7684\u8bfb\u5199\u64cd\u4f5c\uff1a\n\n```\nconst CacheMixin = {\n  methods: {\n    setCache(key, value) {\n      localStorage.setItem(key, JSON.stringify(value));\n    },\n    getCache(key) {\n      const value = localStorage.getItem(key);\n      if (value) {\n        return JSON.parse(value);\n      }\n      return null;\n    },\n  },\n};\n```\n\n2. \u5728input\u7ec4\u4ef6\u4e2d\u4f7f\u7528Mixin\uff0c\u5e76\u5728mounted\u751f\u547d\u5468\u671f\u4e2d\u8bfb\u53d6\u7f13\u5b58\u7684\u503c\u5e76\u8bbe\u7f6e\u5230input\u4e2d\uff1a\n\n```\n<template>\n  <div>\n    <input type=\"text\" v-model=\"value\" />\n  </div>\n</template>\n\n<script>\nimport CacheMixin from \"@/mixins/cache\";\n\nexport default {\n  mixins: [CacheMixin],\n  data() {\n    return {\n      value: \"\",\n    };\n  },\n  mounted() {\n    const cacheValue = this.getCache(\"inputValue\");\n    if (cacheValue) {\n      this.value = cacheValue;\n    }\n  },\n  watch: {\n    value(newVal) {\n      this.setCache(\"inputValue\", newVal);\n    },\n  },\n};\n</script>\n```\n\n\u8fd9\u91cc\u6211\u4eec\u5b9a\u4e49\u4e86\u4e00\u4e2aCacheMixin\uff0c\u901a\u8fc7\u8c03\u7528getCache\u548csetCache\u65b9\u6cd5\u5b9e\u73b0\u8bfb\u5199LocalStorage\u3002\u5728input\u7ec4\u4ef6\u4e2d\u4f7f\u7528Mixin\uff0c\u5e76\u5728mounted\u751f\u547d\u5468\u671f\u4e2d\u8bfb\u53d6\u7f13\u5b58\u7684\u503c\u5e76\u8bbe\u7f6e\u5230input\u4e2d\uff0c\u5728input\u7684watch\u4e2d\u76d1\u542cvalue\u7684\u53d8\u5316\uff0c\u5e76\u5c06\u5176\u5b58\u5165LocalStorage\u4e2d\u3002\n\n\u8fd9\u6837\u5373\u4f7f\u5728\u5f00\u542f\u591a\u4e2a\u76f8\u540c\u7f51\u9875\u9875\u9762\u7684\u60c5\u51b5\u4e0b\uff0c\u6bcf\u4e2a\u9875\u9762\u90fd\u80fd\u72ec\u7acb\u7f13\u5b58\u81ea\u5df1\u7684input\u503c\u3002\u4f46\u9700\u8981\u6ce8\u610f\u7684\u662f\uff0cLocalStorage\u7f13\u5b58\u662f\u57fa\u4e8e\u6d4f\u89c8\u5668\u7684\uff0c\u4e0d\u540c\u6d4f\u89c8"
            ]
        },
        "end_turn": null,
        "weight": 1.0,
        "metadata": {
            "message_type": "next",
            "model_slug": "text-davinci-002-render-sha"
        },
        "recipient": "all"
    },
    "conversation_id": "0d4755ce-762c-4b3d-a3c3-8b95e1af4138",
    "error": null
}data: {
    "message": {
        "id": "c1375983-8681-4978-959b-e5bfc39b157b",
        "author": {
            "role": "assistant",
            "name": null,
            "metadata": {}
        },
        "create_time": 1681017612.273399,
        "update_time": null,
        "content": {
            "content_type": "text",
            "parts": [
                "\u5728Vue\u4e2d\uff0c\u53ef\u4ee5\u4f7f\u7528\u6d4f\u89c8\u5668\u7684\u672c\u5730\u5b58\u50a8\uff08LocalStorage\uff09\u6765\u7f13\u5b58input\u7684\u503c\uff0c\u8fd9\u6837\u5373\u4f7f\u5237\u65b0\u9875\u9762\u6216\u8005\u5173\u95ed\u518d\u6253\u5f00\u9875\u9762\uff0c\u8f93\u5165\u6846\u4e2d\u7684\u503c\u4e5f\u80fd\u591f\u88ab\u4fdd\u7559\u4e0b\u6765\u3002\u4e0b\u9762\u662f\u4e00\u4e2a\u57fa\u4e8eLocalStorage\u7684\u7b80\u5355\u793a\u4f8b\uff1a\n\n1. \u5b9a\u4e49\u4e00\u4e2aMixin\uff0c\u5728\u5176\u4e2d\u5b9e\u73b0\u5bf9LocalStorage\u7684\u8bfb\u5199\u64cd\u4f5c\uff1a\n\n```\nconst CacheMixin = {\n  methods: {\n    setCache(key, value) {\n      localStorage.setItem(key, JSON.stringify(value));\n    },\n    getCache(key) {\n      const value = localStorage.getItem(key);\n      if (value) {\n        return JSON.parse(value);\n      }\n      return null;\n    },\n  },\n};\n```\n\n2. \u5728input\u7ec4\u4ef6\u4e2d\u4f7f\u7528Mixin\uff0c\u5e76\u5728mounted\u751f\u547d\u5468\u671f\u4e2d\u8bfb\u53d6\u7f13\u5b58\u7684\u503c\u5e76\u8bbe\u7f6e\u5230input\u4e2d\uff1a\n\n```\n<template>\n  <div>\n    <input type=\"text\" v-model=\"value\" />\n  </div>\n</template>\n\n<script>\nimport CacheMixin from \"@/mixins/cache\";\n\nexport default {\n  mixins: [CacheMixin],\n  data() {\n    return {\n      value: \"\",\n    };\n  },\n  mounted() {\n    const cacheValue = this.getCache(\"inputValue\");\n    if (cacheValue) {\n      this.value = cacheValue;\n    }\n  },\n  watch: {\n    value(newVal) {\n      this.setCache(\"inputValue\", newVal);\n    },\n  },\n};\n</script>\n```\n\n\u8fd9\u91cc\u6211\u4eec\u5b9a\u4e49\u4e86\u4e00\u4e2aCacheMixin\uff0c\u901a\u8fc7\u8c03\u7528getCache\u548csetCache\u65b9\u6cd5\u5b9e\u73b0\u8bfb\u5199LocalStorage\u3002\u5728input\u7ec4\u4ef6\u4e2d\u4f7f\u7528Mixin\uff0c\u5e76\u5728mounted\u751f\u547d\u5468\u671f\u4e2d\u8bfb\u53d6\u7f13\u5b58\u7684\u503c\u5e76\u8bbe\u7f6e\u5230input\u4e2d\uff0c\u5728input\u7684watch\u4e2d\u76d1\u542cvalue\u7684\u53d8\u5316\uff0c\u5e76\u5c06\u5176\u5b58\u5165LocalStorage\u4e2d\u3002\n\n\u8fd9\u6837\u5373\u4f7f\u5728\u5f00\u542f\u591a\u4e2a\u76f8\u540c\u7f51\u9875\u9875\u9762\u7684\u60c5\u51b5\u4e0b\uff0c\u6bcf\u4e2a\u9875\u9762\u90fd\u80fd\u72ec\u7acb\u7f13\u5b58\u81ea\u5df1\u7684input\u503c\u3002\u4f46\u9700\u8981\u6ce8\u610f\u7684\u662f\uff0cLocalStorage\u7f13\u5b58\u662f\u57fa\u4e8e\u6d4f\u89c8\u5668\u7684\uff0c\u4e0d\u540c\u6d4f\u89c8\u5668\u95f4\u662f\u4e0d\u80fd\u5171\u4eab"
            ]
        },
        "end_turn": null,
        "weight": 1.0,
        "metadata": {
            "message_type": "next",
            "model_slug": "text-davinci-002-render-sha"
        },
        "recipient": "all"
    },
    "conversation_id": "0d4755ce-762c-4b3d-a3c3-8b95e1af4138",
    "error": null
}data: {
    "message": {
        "id": "c1375983-8681-4978-959b-e5bfc39b157b",
        "author": {
            "role": "assistant",
            "name": null,
            "metadata": {}
        },
        "create_time": 1681017612.273399,
        "update_time": null,
        "content": {
            "content_type": "text",
            "parts": [
                "\u5728Vue\u4e2d\uff0c\u53ef\u4ee5\u4f7f\u7528\u6d4f\u89c8\u5668\u7684\u672c\u5730\u5b58\u50a8\uff08LocalStorage\uff09\u6765\u7f13\u5b58input\u7684\u503c\uff0c\u8fd9\u6837\u5373\u4f7f\u5237\u65b0\u9875\u9762\u6216\u8005\u5173\u95ed\u518d\u6253\u5f00\u9875\u9762\uff0c\u8f93\u5165\u6846\u4e2d\u7684\u503c\u4e5f\u80fd\u591f\u88ab\u4fdd\u7559\u4e0b\u6765\u3002\u4e0b\u9762\u662f\u4e00\u4e2a\u57fa\u4e8eLocalStorage\u7684\u7b80\u5355\u793a\u4f8b\uff1a\n\n1. \u5b9a\u4e49\u4e00\u4e2aMixin\uff0c\u5728\u5176\u4e2d\u5b9e\u73b0\u5bf9LocalStorage\u7684\u8bfb\u5199\u64cd\u4f5c\uff1a\n\n```\nconst CacheMixin = {\n  methods: {\n    setCache(key, value) {\n      localStorage.setItem(key, JSON.stringify(value));\n    },\n    getCache(key) {\n      const value = localStorage.getItem(key);\n      if (value) {\n        return JSON.parse(value);\n      }\n      return null;\n    },\n  },\n};\n```\n\n2. \u5728input\u7ec4\u4ef6\u4e2d\u4f7f\u7528Mixin\uff0c\u5e76\u5728mounted\u751f\u547d\u5468\u671f\u4e2d\u8bfb\u53d6\u7f13\u5b58\u7684\u503c\u5e76\u8bbe\u7f6e\u5230input\u4e2d\uff1a\n\n```\n<template>\n  <div>\n    <input type=\"text\" v-model=\"value\" />\n  </div>\n</template>\n\n<script>\nimport CacheMixin from \"@/mixins/cache\";\n\nexport default {\n  mixins: [CacheMixin],\n  data() {\n    return {\n      value: \"\",\n    };\n  },\n  mounted() {\n    const cacheValue = this.getCache(\"inputValue\");\n    if (cacheValue) {\n      this.value = cacheValue;\n    }\n  },\n  watch: {\n    value(newVal) {\n      this.setCache(\"inputValue\", newVal);\n    },\n  },\n};\n</script>\n```\n\n\u8fd9\u91cc\u6211\u4eec\u5b9a\u4e49\u4e86\u4e00\u4e2aCacheMixin\uff0c\u901a\u8fc7\u8c03\u7528getCache\u548csetCache\u65b9\u6cd5\u5b9e\u73b0\u8bfb\u5199LocalStorage\u3002\u5728input\u7ec4\u4ef6\u4e2d\u4f7f\u7528Mixin\uff0c\u5e76\u5728mounted\u751f\u547d\u5468\u671f\u4e2d\u8bfb\u53d6\u7f13\u5b58\u7684\u503c\u5e76\u8bbe\u7f6e\u5230input\u4e2d\uff0c\u5728input\u7684watch\u4e2d\u76d1\u542cvalue\u7684\u53d8\u5316\uff0c\u5e76\u5c06\u5176\u5b58\u5165LocalStorage\u4e2d\u3002\n\n\u8fd9\u6837\u5373\u4f7f\u5728\u5f00\u542f\u591a\u4e2a\u76f8\u540c\u7f51\u9875\u9875\u9762\u7684\u60c5\u51b5\u4e0b\uff0c\u6bcf\u4e2a\u9875\u9762\u90fd\u80fd\u72ec\u7acb\u7f13\u5b58\u81ea\u5df1\u7684input\u503c\u3002\u4f46\u9700\u8981\u6ce8\u610f\u7684\u662f\uff0cLocalStorage\u7f13\u5b58\u662f\u57fa\u4e8e\u6d4f\u89c8\u5668\u7684\uff0c\u4e0d\u540c\u6d4f\u89c8\u5668\u95f4\u662f\u4e0d\u80fd\u5171\u4eab\u7f13\u5b58\u7684\uff0c\u4e5f\u4e0d"
            ]
        },
        "end_turn": null,
        "weight": 1.0,
        "metadata": {
            "message_type": "next",
            "model_slug": "text-davinci-002-render-sha"
        },
        "recipient": "all"
    },
    "conversation_id": "0d4755ce-762c-4b3d-a3c3-8b95e1af4138",
    "error": null
}data: {
    "message": {
        "id": "c1375983-8681-4978-959b-e5bfc39b157b",
        "author": {
            "role": "assistant",
            "name": null,
            "metadata": {}
        },
        "create_time": 1681017612.273399,
        "update_time": null,
        "content": {
            "content_type": "text",
            "parts": [
                "\u5728Vue\u4e2d\uff0c\u53ef\u4ee5\u4f7f\u7528\u6d4f\u89c8\u5668\u7684\u672c\u5730\u5b58\u50a8\uff08LocalStorage\uff09\u6765\u7f13\u5b58input\u7684\u503c\uff0c\u8fd9\u6837\u5373\u4f7f\u5237\u65b0\u9875\u9762\u6216\u8005\u5173\u95ed\u518d\u6253\u5f00\u9875\u9762\uff0c\u8f93\u5165\u6846\u4e2d\u7684\u503c\u4e5f\u80fd\u591f\u88ab\u4fdd\u7559\u4e0b\u6765\u3002\u4e0b\u9762\u662f\u4e00\u4e2a\u57fa\u4e8eLocalStorage\u7684\u7b80\u5355\u793a\u4f8b\uff1a\n\n1. \u5b9a\u4e49\u4e00\u4e2aMixin\uff0c\u5728\u5176\u4e2d\u5b9e\u73b0\u5bf9LocalStorage\u7684\u8bfb\u5199\u64cd\u4f5c\uff1a\n\n```\nconst CacheMixin = {\n  methods: {\n    setCache(key, value) {\n      localStorage.setItem(key, JSON.stringify(value));\n    },\n    getCache(key) {\n      const value = localStorage.getItem(key);\n      if (value) {\n        return JSON.parse(value);\n      }\n      return null;\n    },\n  },\n};\n```\n\n2. \u5728input\u7ec4\u4ef6\u4e2d\u4f7f\u7528Mixin\uff0c\u5e76\u5728mounted\u751f\u547d\u5468\u671f\u4e2d\u8bfb\u53d6\u7f13\u5b58\u7684\u503c\u5e76\u8bbe\u7f6e\u5230input\u4e2d\uff1a\n\n```\n<template>\n  <div>\n    <input type=\"text\" v-model=\"value\" />\n  </div>\n</template>\n\n<script>\nimport CacheMixin from \"@/mixins/cache\";\n\nexport default {\n  mixins: [CacheMixin],\n  data() {\n    return {\n      value: \"\",\n    };\n  },\n  mounted() {\n    const cacheValue = this.getCache(\"inputValue\");\n    if (cacheValue) {\n      this.value = cacheValue;\n    }\n  },\n  watch: {\n    value(newVal) {\n      this.setCache(\"inputValue\", newVal);\n    },\n  },\n};\n</script>\n```\n\n\u8fd9\u91cc\u6211\u4eec\u5b9a\u4e49\u4e86\u4e00\u4e2aCacheMixin\uff0c\u901a\u8fc7\u8c03\u7528getCache\u548csetCache\u65b9\u6cd5\u5b9e\u73b0\u8bfb\u5199LocalStorage\u3002\u5728input\u7ec4\u4ef6\u4e2d\u4f7f\u7528Mixin\uff0c\u5e76\u5728mounted\u751f\u547d\u5468\u671f\u4e2d\u8bfb\u53d6\u7f13\u5b58\u7684\u503c\u5e76\u8bbe\u7f6e\u5230input\u4e2d\uff0c\u5728input\u7684watch\u4e2d\u76d1\u542cvalue\u7684\u53d8\u5316\uff0c\u5e76\u5c06\u5176\u5b58\u5165LocalStorage\u4e2d\u3002\n\n\u8fd9\u6837\u5373\u4f7f\u5728\u5f00\u542f\u591a\u4e2a\u76f8\u540c\u7f51\u9875\u9875\u9762\u7684\u60c5\u51b5\u4e0b\uff0c\u6bcf\u4e2a\u9875\u9762\u90fd\u80fd\u72ec\u7acb\u7f13\u5b58\u81ea\u5df1\u7684input\u503c\u3002\u4f46\u9700\u8981\u6ce8\u610f\u7684\u662f\uff0cLocalStorage\u7f13\u5b58\u662f\u57fa\u4e8e\u6d4f\u89c8\u5668\u7684\uff0c\u4e0d\u540c\u6d4f\u89c8\u5668\u95f4\u662f\u4e0d\u80fd\u5171\u4eab\u7f13\u5b58\u7684\uff0c\u4e5f\u4e0d\u9002\u7528\u4e8e\u670d\u52a1\u5668\u7aef\u6e32\u67d3\u7b49\u573a"
            ]
        },
        "end_turn": null,
        "weight": 1.0,
        "metadata": {
            "message_type": "next",
            "model_slug": "text-davinci-002-render-sha"
        },
        "recipient": "all"
    },
    "conversation_id": "0d4755ce-762c-4b3d-a3c3-8b95e1af4138",
    "error": null
}data: {
    "message": {
        "id": "c1375983-8681-4978-959b-e5bfc39b157b",
        "author": {
            "role": "assistant",
            "name": null,
            "metadata": {}
        },
        "create_time": 1681017612.273399,
        "update_time": null,
        "content": {
            "content_type": "text",
            "parts": [
                "\u5728Vue\u4e2d\uff0c\u53ef\u4ee5\u4f7f\u7528\u6d4f\u89c8\u5668\u7684\u672c\u5730\u5b58\u50a8\uff08LocalStorage\uff09\u6765\u7f13\u5b58input\u7684\u503c\uff0c\u8fd9\u6837\u5373\u4f7f\u5237\u65b0\u9875\u9762\u6216\u8005\u5173\u95ed\u518d\u6253\u5f00\u9875\u9762\uff0c\u8f93\u5165\u6846\u4e2d\u7684\u503c\u4e5f\u80fd\u591f\u88ab\u4fdd\u7559\u4e0b\u6765\u3002\u4e0b\u9762\u662f\u4e00\u4e2a\u57fa\u4e8eLocalStorage\u7684\u7b80\u5355\u793a\u4f8b\uff1a\n\n1. \u5b9a\u4e49\u4e00\u4e2aMixin\uff0c\u5728\u5176\u4e2d\u5b9e\u73b0\u5bf9LocalStorage\u7684\u8bfb\u5199\u64cd\u4f5c\uff1a\n\n```\nconst CacheMixin = {\n  methods: {\n    setCache(key, value) {\n      localStorage.setItem(key, JSON.stringify(value));\n    },\n    getCache(key) {\n      const value = localStorage.getItem(key);\n      if (value) {\n        return JSON.parse(value);\n      }\n      return null;\n    },\n  },\n};\n```\n\n2. \u5728input\u7ec4\u4ef6\u4e2d\u4f7f\u7528Mixin\uff0c\u5e76\u5728mounted\u751f\u547d\u5468\u671f\u4e2d\u8bfb\u53d6\u7f13\u5b58\u7684\u503c\u5e76\u8bbe\u7f6e\u5230input\u4e2d\uff1a\n\n```\n<template>\n  <div>\n    <input type=\"text\" v-model=\"value\" />\n  </div>\n</template>\n\n<script>\nimport CacheMixin from \"@/mixins/cache\";\n\nexport default {\n  mixins: [CacheMixin],\n  data() {\n    return {\n      value: \"\",\n    };\n  },\n  mounted() {\n    const cacheValue = this.getCache(\"inputValue\");\n    if (cacheValue) {\n      this.value = cacheValue;\n    }\n  },\n  watch: {\n    value(newVal) {\n      this.setCache(\"inputValue\", newVal);\n    },\n  },\n};\n</script>\n```\n\n\u8fd9\u91cc\u6211\u4eec\u5b9a\u4e49\u4e86\u4e00\u4e2aCacheMixin\uff0c\u901a\u8fc7\u8c03\u7528getCache\u548csetCache\u65b9\u6cd5\u5b9e\u73b0\u8bfb\u5199LocalStorage\u3002\u5728input\u7ec4\u4ef6\u4e2d\u4f7f\u7528Mixin\uff0c\u5e76\u5728mounted\u751f\u547d\u5468\u671f\u4e2d\u8bfb\u53d6\u7f13\u5b58\u7684\u503c\u5e76\u8bbe\u7f6e\u5230input\u4e2d\uff0c\u5728input\u7684watch\u4e2d\u76d1\u542cvalue\u7684\u53d8\u5316\uff0c\u5e76\u5c06\u5176\u5b58\u5165LocalStorage\u4e2d\u3002\n\n\u8fd9\u6837\u5373\u4f7f\u5728\u5f00\u542f\u591a\u4e2a\u76f8\u540c\u7f51\u9875\u9875\u9762\u7684\u60c5\u51b5\u4e0b\uff0c\u6bcf\u4e2a\u9875\u9762\u90fd\u80fd\u72ec\u7acb\u7f13\u5b58\u81ea\u5df1\u7684input\u503c\u3002\u4f46\u9700\u8981\u6ce8\u610f\u7684\u662f\uff0cLocalStorage\u7f13\u5b58\u662f\u57fa\u4e8e\u6d4f\u89c8\u5668\u7684\uff0c\u4e0d\u540c\u6d4f\u89c8\u5668\u95f4\u662f\u4e0d\u80fd\u5171\u4eab\u7f13\u5b58\u7684\uff0c\u4e5f\u4e0d\u9002\u7528\u4e8e\u670d\u52a1\u5668\u7aef\u6e32\u67d3\u7b49\u573a\u666f\u3002"
            ]
        },
        "end_turn": true,
        "weight": 1.0,
        "metadata": {
            "message_type": "next",
            "model_slug": "text-davinci-002-render-sha",
            "finish_details": {
                "type": "stop",
                "stop": "<|im_end|>"
            }
        },
        "recipient": "all"
    },
    "conversation_id": "0d4755ce-762c-4b3d-a3c3-8b95e1af4138",
    "error": null
}
@linweiyuan
Copy link
Owner

可以必现吗,输入是什么

@nephen
Copy link
Contributor Author

nephen commented Apr 9, 2023

vue里面的input值怎么缓存,在开多个相同网页页面的情况下,写长点

我用这个复现了两次

@linweiyuan
Copy link
Owner

试了十几次都没试到,是最新镜像不?可能修复了

@nephen
Copy link
Contributor Author

nephen commented Apr 9, 2023

是最新的,偶尔能复现到

@nephen
Copy link
Contributor Author

nephen commented Apr 9, 2023

尝试修复了下,#12

@linweiyuan
Copy link
Owner

看来问题的根源在这里,XHR 每次都是返回一堆 data: xxx\n\n,如果这些返回的数据含有处理这部分数据的时候的分隔符,还是会有问题

2023-04-09_09-06

@nephen
Copy link
Contributor Author

nephen commented Apr 9, 2023

厉害了,我没有看浏览器那端的数据

@linweiyuan
Copy link
Owner

经过反复测试发现应该搞错了,返回的数据的换行全部转义了,这个假数据我自己弄来测试,真正的响应应该不会这样

这样就又不知道为何数据不完整了

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants