This repository has been archived by the owner on Nov 4, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
34 changed files
with
891 additions
and
382 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
export type UserAccount = { | ||
avatar: string; | ||
name: string; | ||
address: string; | ||
privateKey?: string; | ||
}; | ||
|
||
async function GetAccounts() { | ||
return new Promise<UserAccount[] | null>((resolve) => { | ||
chrome.storage.sync.get(['rss3accounts'], (accountsShowList) => { | ||
if (accountsShowList?.['rss3accounts']) { | ||
resolve(<UserAccount[]>accountsShowList['rss3accounts']); | ||
} else { | ||
resolve(null); | ||
} | ||
}); | ||
}); | ||
} | ||
|
||
export default { | ||
get: GetAccounts, | ||
set: async (account: UserAccount) => { | ||
const accountsList: UserAccount[] = (await GetAccounts()) || []; | ||
const userIndex = accountsList.findIndex((user) => { | ||
return user.privateKey === account.privateKey; | ||
}); | ||
if (userIndex === -1) { | ||
// Do not exist | ||
accountsList.push(account); | ||
} else { | ||
// Update user info | ||
accountsList[userIndex] = account; | ||
} | ||
await chrome.storage.sync.set({ | ||
rss3accounts: accountsList, | ||
}); | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
<template> | ||
<div class="user-container" :class="$props.viewType"> | ||
<div class="user"> | ||
<img class="avatar" :src="$props.user.avatar" /> | ||
<span class="username">{{ $props.user.name }}</span> | ||
</div> | ||
<div class="address"> | ||
<span> | ||
{{ | ||
$props.viewType === 'popup' | ||
? `${$props.user.address.substring(0, 3)}***${$props.user.address.substring( | ||
$props.user.address.length - 3, | ||
)}` | ||
: $props.user.address | ||
}} | ||
</span> | ||
</div> | ||
</div> | ||
</template> | ||
|
||
<script lang="ts"> | ||
import { Vue, Options } from 'vue-class-component'; | ||
@Options({ | ||
props: { | ||
viewType: String, | ||
user: { | ||
avatar: String, | ||
name: String, | ||
address: String, | ||
}, | ||
}, | ||
}) | ||
export default class SingleUser extends Vue {} | ||
</script> | ||
|
||
<style scoped lang="postcss"> | ||
@layer components { | ||
.user-container { | ||
@apply duration-200 relative cursor-pointer; | ||
&:hover { | ||
@apply bg-gray-bg; | ||
} | ||
> * { | ||
@apply inline-block; | ||
> * { | ||
@apply inline-flex items-center; | ||
} | ||
} | ||
> .user { | ||
> span.username { | ||
@apply font-semibold; | ||
} | ||
} | ||
> .address { | ||
@apply absolute right-4 text-gray-700; | ||
&::after { | ||
@apply ml-1 text-primary fill-current; | ||
content: '\279C'; | ||
} | ||
} | ||
&.popup { | ||
@apply p-2 text-xs; | ||
img.avatar { | ||
@apply w-10 h-10 rounded; | ||
} | ||
> .user { | ||
> span.username { | ||
@apply ml-2; | ||
} | ||
} | ||
> .address { | ||
@apply text-xs; | ||
> span { | ||
@apply h-10; | ||
} | ||
} | ||
} | ||
&.options { | ||
@apply p-4 text-lg; | ||
img.avatar { | ||
@apply w-14 h-14 rounded; | ||
} | ||
> .user { | ||
> span.username { | ||
@apply ml-4; | ||
} | ||
} | ||
> .address { | ||
@apply text-xs; | ||
> span { | ||
@apply h-14; | ||
} | ||
} | ||
} | ||
} | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<template> | ||
<div | ||
class="user-list" | ||
:class="{ | ||
popup: $props.viewType === 'popup', | ||
options: $props.viewType === 'options', | ||
}" | ||
> | ||
<slot /> | ||
</div> | ||
</template> | ||
|
||
<script lang="ts"> | ||
import { Vue, Options } from 'vue-class-component'; | ||
@Options({ | ||
props: { | ||
viewType: String, | ||
}, | ||
}) | ||
export default class UserList extends Vue {} | ||
</script> | ||
|
||
<style lang="postcss"> | ||
@layer components { | ||
.user-list { | ||
@apply flex flex-col divide-y divide-black divide-opacity-10 overflow-y-scroll; | ||
&.popup { | ||
@apply w-55 h-60; | ||
} | ||
&.options { | ||
@apply w-180 h-160; | ||
} | ||
} | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.