Browse Source

fix:落笔留痕demo修改

master
15881625488@163.com 6 days ago
parent
commit
70e6a3c226
3 changed files with 8 additions and 5 deletions
  1. +1
    -1
      src/views/lblh/components/AutoSaveManager.js
  2. +6
    -3
      src/views/lblh/components/storage/ServerStorage.js
  3. +1
    -1
      src/views/lblh/index.vue

+ 1
- 1
src/views/lblh/components/AutoSaveManager.js View File

@ -15,7 +15,7 @@ class AutoSaveManager {
try {
this.storages = {
// memory: new MemoryStorage(key),
localStorage: new LocalStorage(key),
// localStorage: new LocalStorage(key),
// sessionStorage: new SessionStorage(key),
indexedDB: new IndexedDBStorage(key),
server: new ServerStorage(key, serverOptions)

+ 6
- 3
src/views/lblh/components/storage/ServerStorage.js View File

@ -1,3 +1,5 @@
import { getToken } from '@/utils/auth'
/**
* 服务器存储策略
* 支持离线队列网络恢复后自动重传
@ -6,9 +8,9 @@ class ServerStorage {
constructor(key, options = {}) {
this.key = key;
this.options = {
endpoint: options.endpoint || '/api/save-text',
syncEndpoint: options.syncEndpoint || '/api/sync-text',
historyEndpoint: options.historyEndpoint || '/api/text-history',
endpoint: options.endpoint || '/system/business/test/testLblh',
syncEndpoint: options.syncEndpoint || '/system/business/test/testLblhHistory',
historyEndpoint: options.historyEndpoint || '/system/business/test/testLblhHistory',
retryCount: options.retryCount || 3, //最多重试次数
retryDelay: options.retryDelay || 1000,//重试等待 毫秒
...options
@ -102,6 +104,7 @@ class ServerStorage {
const xhr = new XMLHttpRequest();
xhr.open('POST', this.options.endpoint);
xhr.setRequestHeader('Content-Type', 'application/json');
xhr.setRequestHeader('Authorization', 'Bearer ' + getToken()); // 让每个请求携带自定义token 请根据实际情况自行修改
xhr.onload = () => {
if (xhr.status === 200 || xhr.status === 201) {

+ 1
- 1
src/views/lblh/index.vue View File

@ -36,7 +36,7 @@
<h2>分层存储数据流向用户输入 本地持久化 云端</h2>
<p> 1.服务器存储云端同步跨设备访问</p>
<p> 2.IndexedDB存储浏览器内置 NoSQL 数据库所有pc浏览器都支持移动端浏览器也支持存储数据可达50%的磁盘容量并且支持事务索引关闭标签页/窗口 数据保留刷新页面 数据保留</p>
<p> 3.LocalStorage本地存储 持久化跨会话保存关闭标签页/窗口 数据保留刷新页面 数据保留</p>
<p> 3.LocalStorage本地存储 持久化跨会话保存关闭标签页/窗口 数据保留刷新页面 数据保留如果IndexedDB初始化失败则启用</p>
<h2>实时保存</h2>
<p>3.输入结束失去焦点后触发多存储并行保存</p>
<p>4.页面关闭前强制同步保存</p>

Loading…
Cancel
Save