Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
.then(res => {
console.log(res)
if (res.data.length > 0) {
Taro.setStorage({
key: 'config_gitter',
data: res.data[0]
})
}
})
.catch(err => {
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 })
}
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
});
}
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()
}
})
}
function updateStorage(data = {}) {
return Promise.all([
Taro.setStorage({ key: 'token', data: data['3rdSession'] || '' }),
Taro.setStorage({ key: 'uid', data: data['uid'] || ''})
])
}
.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 => {
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,