Skip to content

Commit

Permalink
feat: 记住浏览的tab
Browse files Browse the repository at this point in the history
  • Loading branch information
ttop5 committed Aug 6, 2019
1 parent 48551a1 commit daeacd1
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 12 deletions.
4 changes: 1 addition & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@

## 最近更新

大佬们心心念念的左侧菜单定制功能来啦!

![屏幕快照 2019-08-02 18 15 12](https://user-images.githubusercontent.com/9512362/62363287-9ea36e80-b551-11e9-8e1c-06955c99093c.png)
[https://github.com/ttop5/to-be-slack/releases](https://github.com/ttop5/to-be-slack/releases)


## 使用截图
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ToBeSlack",
"version": "0.0.1",
"version": "1.3.1",
"description": "摸鱼愉快",
"productName": "今日热榜",
"cordovaId": "org.cordova.quasar.app",
Expand Down
2 changes: 1 addition & 1 deletion src-ext/manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"manifest_version": 2,
"name": "今日热榜",
"version": "0.0.3",
"version": "1.3.1",
"description": "摸鱼愉快",
"icons":
{
Expand Down
13 changes: 8 additions & 5 deletions src/layouts/MyLayout.vue
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@
</q-toolbar>
</q-header>

<q-drawer v-model="leftDrawerOpen" bordered content-class="bg-grey-2"
>
<q-drawer v-model="leftDrawerOpen" bordered content-class="bg-grey-2">
<q-list separator class="rounded-borders text-primary q-pa-md">
<q-item-label header class="flex">
<q-item-section>Links</q-item-section>
Expand Down Expand Up @@ -53,6 +52,7 @@
:key="item.id"
:to="`/?id=${item.id}`"
:active="$route.query.id === item.id"
@click="clickHandler(item.id)"
>
<q-item-section>{{ item.title }}</q-item-section>
<q-item-section side top>
Expand Down Expand Up @@ -87,7 +87,7 @@ export default {
watch: {
typeList: {
handler: function saveLinks(newValue) {
localStorage.setItem('slackLinks', JSON.stringify(newValue));
localStorage.setItem('slackTabs', JSON.stringify(newValue));
},
deep: true,
},
Expand Down Expand Up @@ -122,10 +122,13 @@ export default {
showAll() {
this.getType();
},
clickHandler(id) {
localStorage.setItem('slackActiveTab', id);
},
},
created() {
if (localStorage.getItem('slackLinks')) {
this.$set(this, 'typeList', JSON.parse(localStorage.getItem('slackLinks')));
if (localStorage.getItem('slackTabs')) {
this.$set(this, 'typeList', JSON.parse(localStorage.getItem('slackTabs')));
this.typeList.forEach((item) => {
this.typeListObj[item.id] = item.title;
});
Expand Down
2 changes: 1 addition & 1 deletion src/pages/Index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
v-ripple
tag="a"
target="_blank"
:style="`color: ${(readedLinks.includes(item.url)) ? 'gray' : 'unset'}`"
:style="`color: ${(readedLinks.includes(item.url)) ? 'grey' : 'unset'}`"
:href="item.url"
:key="item.index"
@click="clickHandler(item)"
Expand Down
3 changes: 2 additions & 1 deletion src/router/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ export default function (/* { store, ssrContext } */) {

Router.beforeEach((to, from, next) => {
if (to.fullPath === '/') {
next('/?id=1');
const id = localStorage.getItem('slackActiveTab');
next(`/?id=${id}`);
} else {
next();
}
Expand Down

0 comments on commit daeacd1

Please sign in to comment.