Auto Commit

上级 e03c7aac
...@@ -3,13 +3,13 @@ import * as echarts from 'echarts'; ...@@ -3,13 +3,13 @@ import * as echarts from 'echarts';
import Author from './Author.vue' import Author from './Author.vue'
import { tableColumns } from './const' import { tableColumns } from './const'
import { getRemoteCsdnGrade } from '../service/csdnApi' import { getRemoteCsdnGrade } from '../service/csdnApi'
import { onMounted, reactive, onUnmounted } from 'vue'; import { onMounted, reactive, onUnmounted, nextTick } from 'vue';
const state = reactive({ const state = reactive({
loading: false, loading: false,
searchValue: localStorage.getItem('csdnUid')||'', searchValue: localStorage.getItem('csdnUid') || '',
firstChart: null, firstChart: null,
columns: tableColumns, columns: tableColumns,
dataSource: [], dataSource: localStorage.getItem('csdnUidData') ? JSON.parse(localStorage.getItem('csdnUidData')) : [],
pagination: { pagination: {
total: 0, total: 0,
current: 1, current: 1,
...@@ -22,6 +22,8 @@ const state = reactive({ ...@@ -22,6 +22,8 @@ const state = reactive({
onChange: changePage,//点击页码事件 onChange: changePage,//点击页码事件
} }
}) })
// storage
function changePage(page, pageSize) { function changePage(page, pageSize) {
state.pagination.current = page state.pagination.current = page
state.pagination.pageSize = pageSize state.pagination.pageSize = pageSize
...@@ -41,6 +43,7 @@ const getCsdnData = (uId) => { ...@@ -41,6 +43,7 @@ const getCsdnData = (uId) => {
state.pagination.total = state.dataSource.length state.pagination.total = state.dataSource.length
state.loading = false state.loading = false
initFirstData() initFirstData()
window.localStorage.setItem('csdnUidData', JSON.stringify(state.dataSource))
}).catch((r) => { }).catch((r) => {
state.pagination.total = 0 state.pagination.total = 0
console.log(r) console.log(r)
...@@ -149,9 +152,9 @@ function initFirstData() { ...@@ -149,9 +152,9 @@ function initFirstData() {
} }
} }
}, },
data: [{ type: 'average', name: '平均分' }] data: [{ type: 'average', name: '平均分' }]
}
} }
}
] ]
}; };
// 使用刚指定的配置项和数据显示图表。 // 使用刚指定的配置项和数据显示图表。
...@@ -169,12 +172,16 @@ function initFirstData() { ...@@ -169,12 +172,16 @@ function initFirstData() {
}); });
onMounted(() => { onMounted(() => {
const storageUid = window.localStorage.getItem('csdnUid') // const storageUid = window.localStorage.getItem('csdnUid')
console.log('window.localStorage', window.localStorage) // console.log('window.localStorage', window.localStorage)
console.log('storageUid', storageUid) // console.log('storageUid', storageUid)
if (storageUid) { // if (storageUid) {
state.searchValue = storageUid // state.searchValue = storageUid
onSearch() // onSearch()
// }
// storage
if (state.dataSource) {
initFirstData();
} }
}) })
onUnmounted(() => { onUnmounted(() => {
...@@ -182,6 +189,9 @@ function initFirstData() { ...@@ -182,6 +189,9 @@ function initFirstData() {
if (state.searchValue) { if (state.searchValue) {
window.localStorage.setItem('csdnUid', state.searchValue) window.localStorage.setItem('csdnUid', state.searchValue)
} }
if (state.dataSource) {
window.localStorage.setItem('csdnUidData', JSON.stringify(state.dataSource))
}
}) })
} }
</script> </script>
...@@ -196,8 +206,8 @@ function initFirstData() { ...@@ -196,8 +206,8 @@ function initFirstData() {
</div> </div>
<br> <br>
<div> <div>
<a-input-search v-model:value="state.searchValue" :disabled="state.loading" placeholder="输入用户id(如 qq_38870145)" enter-button <a-input-search v-model:value="state.searchValue" :disabled="state.loading" placeholder="输入用户id(如 qq_38870145)"
@search="onSearch" /> enter-button @search="onSearch" />
</div> </div>
<br> <br>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册