How to use the @tarojs/taro.setStorage function in @tarojs/taro

To help you get started, we’ve selected a few @tarojs/taro examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github huangjianke / Gitter / src / app.js View on Github external
.then(res => {
        console.log(res)
        if (res.data.length > 0) {
          Taro.setStorage({
            key: 'config_gitter',
            data: res.data[0]
          })
        }
      })
      .catch(err => {
github lsqy / taro-music / src / utils / common.ts View on Github external
export const setKeywordInHistory = (keyword: string) => {
  const keywordsList: Array = Taro.getStorageSync('keywordsList') || []
  console.log('keywordsList', keywordsList)
  const index = keywordsList.findIndex((item) => item === keyword)
  if (index !== -1) {
    keywordsList.splice(index, 1)
  }
  keywordsList.unshift(keyword)
  Taro.setStorage({ key: 'keywordsList', data: keywordsList })
}
github imageslr / taro-library / src / pages / search / index.jsx View on Github external
addHistory(value) {
    value = value.trim();
    let history = this.state.history.filter(v => v !== value);
    history.unshift(value);
    if (history.length > 10) {
      history = history.slice(0, 10);
    }
    this.setState({ history });
    Taro.setStorage({
      key: "history",
      data: history
    });
  }
github huangjianke / Gitter / src / pages / search / index.js View on Github external
updateHistory(value) {
    const { history } = this.state
    for (let item of history) {
      if (value === item) {
        history.splice(history.indexOf(item), 1)
        break
      }
    }
    history.unshift(value)
    let that = this
    Taro.setStorage({
      key: 'search_history',
      data: history,
      success(res) {
        that.loadHistory()
      }
    })
  }
github qit-team / taro-yanxuan / src / utils / request.js View on Github external
function updateStorage(data = {}) {
  return Promise.all([
    Taro.setStorage({ key: 'token', data: data['3rdSession'] || '' }),
    Taro.setStorage({ key: 'uid', data: data['uid'] || ''})
  ])
}
github huangjianke / Gitter / src / pages / git / tutorials.js View on Github external
.then(res => {
        if (res.data.length > 0) {
          that.setState({
            md: base64_decode(res.data[0].content)
          })
          let key = `git_content_${item.item_id}`
          Taro.setStorage({
            key: key,
            data: res.data[0]
          })
        }
        Taro.hideLoading()
      })
      .catch(err => {
github zhixiaoqiang / taroCloud / src / pages / trending / index.js View on Github external
onChangeGithubParams = value => {
    const { githubRange } = this.state
    const [category, period, lang] = githubRange
    const [categoryIndex, periodIndex, langIndex] = value

    Taro.setStorage({
      key: 'trendingProps',
      data: {
        categoryIndex,
        periodIndex,
        langIndex,
      },
    })

    Taro.showLoading({
      title: '加载中···',
      mask: true,
    })

    if (Taro.pageScrollTo) {
      Taro.pageScrollTo({
        scrollTop: 0,