修改样式
This commit is contained in:
parent
1ec2178fc9
commit
323d708d09
@ -12,6 +12,7 @@ import Notification from './components/global/Notification.vue'
|
|||||||
import { gsap } from "gsap";
|
import { gsap } from "gsap";
|
||||||
|
|
||||||
import { ScrollTrigger } from "gsap/ScrollTrigger";
|
import { ScrollTrigger } from "gsap/ScrollTrigger";
|
||||||
|
import { BlockChain } from '@/components/chain/BlockChain';
|
||||||
|
|
||||||
gsap.registerPlugin(ScrollTrigger);
|
gsap.registerPlugin(ScrollTrigger);
|
||||||
|
|
||||||
@ -21,6 +22,10 @@ const notification = ref(null);
|
|||||||
provide('addNotification', (title, message) => {
|
provide('addNotification', (title, message) => {
|
||||||
notification.value.addNotification(title, message);
|
notification.value.addNotification(title, message);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
new BlockChain().preparePassport();
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss">
|
<style lang="scss">
|
||||||
|
@ -1,20 +1,71 @@
|
|||||||
import {PassportWallet} from '@/components/chain/PassportWallet';
|
import {PassportWallet} from "@/components/chain/wallet/PassportWallet";
|
||||||
import { createSingleton } from '@/utils/singleton';
|
import { MetaMaskWallet } from '@/components/chain/wallet/MetaMaskWallet';
|
||||||
|
import { OkxWallet } from '@/components/chain/wallet/OkxWallet';
|
||||||
|
import {walletStore} from "@/store/wallet";
|
||||||
|
import WalletSelectModel from "@/components/chain/WalletSelectModel.vue";
|
||||||
|
import {createModal} from "@/utils/model.util";
|
||||||
|
import {ImtblMarket} from "@/components/chain/Market";
|
||||||
|
|
||||||
const LOCAL_WALLET_KEY = 'wallet_type';
|
export const allProviders = {
|
||||||
|
1: MetaMaskWallet,
|
||||||
class CBlockChain {
|
2: OkxWallet,
|
||||||
constructor() {
|
3: PassportWallet
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
initWallet() {
|
|
||||||
console.log('init wallet')
|
|
||||||
};
|
|
||||||
|
|
||||||
preparePassport() {
|
|
||||||
new PassportWallet()
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export const BlockChain = createSingleton(CBlockChain);
|
export class BlockChain {
|
||||||
|
constructor() {
|
||||||
|
if (BlockChain.instance) {
|
||||||
|
return BlockChain.instance;
|
||||||
|
}
|
||||||
|
this.store = walletStore();
|
||||||
|
this.store.$hydrate({runHooks: false});
|
||||||
|
this.initWallet();
|
||||||
|
BlockChain.instance = this;
|
||||||
|
this.market = new ImtblMarket()
|
||||||
|
}
|
||||||
|
|
||||||
|
initWallet() {
|
||||||
|
console.log("init blockchain instance");
|
||||||
|
console.log(this.store.address);
|
||||||
|
if (!this.store.address) {
|
||||||
|
console.log("no wallet login");
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
this.restoreWallet(this.store.walletType)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
preparePassport() {
|
||||||
|
new PassportWallet();
|
||||||
|
}
|
||||||
|
|
||||||
|
async restoreWallet(walletType) {
|
||||||
|
this.wallet = new allProviders[walletType]();
|
||||||
|
const { provider } = await this.wallet.web3Provider();
|
||||||
|
this.provider = provider
|
||||||
|
this.market.updateProvider(provider);
|
||||||
|
return provider;
|
||||||
|
}
|
||||||
|
|
||||||
|
async connect() {
|
||||||
|
const rewardModal = createModal(WalletSelectModel, {});
|
||||||
|
let result = await rewardModal.show();
|
||||||
|
if (!result.errcode) {
|
||||||
|
this.provider = result.provider;
|
||||||
|
this.market.updateProvider(this.provider);
|
||||||
|
this.wallet = new allProviders[result.wallet]();
|
||||||
|
this.store.walletType = result.wallet;
|
||||||
|
this.store.address = result.accounts[0];
|
||||||
|
this.store.$persist();
|
||||||
|
} else {
|
||||||
|
console.log(`select result : ${result.errmsg}`);
|
||||||
|
throw new Error(result.errmsg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async logout() {
|
||||||
|
this.store.reset();
|
||||||
|
this.store.$persist();
|
||||||
|
await this.wallet.logout();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
import { baseConfig } from './PassportWallet';
|
import { baseConfig } from './wallet/PassportWallet';
|
||||||
import { orderbook } from '@imtbl/sdk';
|
import { orderbook } from '@imtbl/sdk';
|
||||||
const marketAddress = import.meta.env.VUE_APP_PASSPORT_MARKET_ADDRESS
|
const marketAddress = import.meta.env.VUE_APP_PASSPORT_MARKET_ADDRESS
|
||||||
|
|
||||||
const NATIVE = 'NATIVE'
|
const NATIVE = 'NATIVE'
|
||||||
const ERC20 = 'ERC20'
|
const ERC20 = 'ERC20'
|
||||||
|
|
||||||
class ImtblMarket {
|
export class ImtblMarket {
|
||||||
constructor() {
|
constructor() {
|
||||||
this.client = new orderbook.Orderbook({ baseConfig });
|
this.client = new orderbook.Orderbook({ baseConfig });
|
||||||
}
|
}
|
||||||
@ -218,5 +218,3 @@ class ImtblMarket {
|
|||||||
return receipt;
|
return receipt;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export const Market = createSingleton(ImtblMarket)
|
|
@ -2,8 +2,19 @@
|
|||||||
<div class="chain-modal" v-if="props.visible" :class="{ mobile: 'mobile' }">
|
<div class="chain-modal" v-if="props.visible" :class="{ mobile: 'mobile' }">
|
||||||
<div class="modal-bg" @click="cancelSelect"></div>
|
<div class="modal-bg" @click="cancelSelect"></div>
|
||||||
<div class="modal-content" :class="{ mobile: 'mobile' }">
|
<div class="modal-content" :class="{ mobile: 'mobile' }">
|
||||||
<div class="modal-title">You need to connect to supported network</div>
|
<div class="modal-title">
|
||||||
<div
|
<div>Please connect your wallet</div>
|
||||||
|
<img
|
||||||
|
src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAfCAYAAACGVs+MAAAAAXNSR0IArs4c6QAAApVJREFUWEe1lj1v01AUht9zEygDA0tYYAIJVWJL3KGtUZyFAQYWggQSqkgkhuQPMDDDHwBRYKIoHaJOSIgBNUlxUoY4KQtiRvwCFopEfA+yG4fE9ce1ayJPubrnffyeDx8CgE8d62ZO0GMiOM+T1XLxnfN/1r/BrnUdOXrkxGXIp7qx8pFMc3gpJ8U3ZpyeCtoAPVg3im+zBBh0h7dBYhvAqWnc37Bpmfp71j1iavnEbEmydq28spUFRID4UVimu2SaX64I2/4KIP8/IELFAZvz+avkiO7vjWvM/BqAyBIiQpyZuaFXtE0XwIXojutM/CoriChxgJvrhvbC0Z0BZAmhKn4MIAuIJOKBACeBSCoeCuAc9LvDOpEIrAkiqq2Viwstau5aVZFz29nrc6+8eD7n/rZeqAH/oSpEWvFIBzyYOAh7Ig/TvLkXP9IBFQgAMsh2wdRYrRQ34yapEkBMTfg1WFVcKQXz0SPSMSu4JOKJAZwLg97oJYCHQdYSaGvNKG7E2T5/rpwC55LZs6oC2AbI/+HyYtpBLRoFpAygID6DYOa6XtHeqDihBBAhzu5yE/AVVYWIBYgSdwrOhv0nbGKqQEQC7PcOqgw7KOcLrRY1rOIgQgHCxIlISomm7hsyaSECAZKKq0zMMCeOAaQVTwuxuBGF5DzM9rA2i9oxmbiul/+16Ayg3xndIcEt/5BJKu5BqUK4AIPO8BaE2PGv5mnFlSAYG3ql1DoC6Fk/ALq4MKPdapdNZ3VWmWgp0vHzXOHMeWJmGvTGh0RYmi0JGYnHOMH5yaQwdWD0HEBjekEy84nf3O+IvyYY+KAbpRsuQLvdzl0oXL4P0DITv9eNknkS28Pufu4eGJJkFcD3pbP8TNO0X38BHAnKrhM25C0AAAAASUVORK5CYII="
|
||||||
|
alt="close"
|
||||||
|
class="close"
|
||||||
|
@click="cancelSelect"/>
|
||||||
|
</div>
|
||||||
|
<div class="modal-sub-title">
|
||||||
|
Connect your wallet to start your Counter Fire journey
|
||||||
|
</div>
|
||||||
|
<div class="modal-body">
|
||||||
|
<div
|
||||||
class="chain-modal-card"
|
class="chain-modal-card"
|
||||||
v-for="data in currentDatas"
|
v-for="data in currentDatas"
|
||||||
:key="data.name"
|
:key="data.name"
|
||||||
@ -13,39 +24,36 @@
|
|||||||
<img :src="data.logo" :alt="data.name" />
|
<img :src="data.logo" :alt="data.name" />
|
||||||
</div>
|
</div>
|
||||||
<div class="name">{{ data.name }}</div>
|
<div class="name">{{ data.name }}</div>
|
||||||
<div class="desc">{{ data.desc }}</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<script setup>
|
<script setup>
|
||||||
import { computed } from "vue";
|
import { computed } from "vue";
|
||||||
import { ALL_PROVIDERS } from "@/configs/configchain";
|
import { ALL_PROVIDERS } from "@/configs/configchain";
|
||||||
import { PassportWallet } from '@/components/chain/PassportWallet';
|
import { allProviders } from "@/components/chain/BlockChain"
|
||||||
import { providers } from "ethers"
|
|
||||||
|
import {walletStore} from "@/store/wallet";
|
||||||
|
|
||||||
|
const localWalletStore = walletStore()
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
visible: Boolean,
|
visible: Boolean,
|
||||||
close: Function,
|
close: Function,
|
||||||
});
|
});
|
||||||
|
|
||||||
const allProviders = {
|
|
||||||
1: window.ethereum,
|
|
||||||
2: window.okxwallet,
|
|
||||||
3: new PassportWallet().nativeProvider
|
|
||||||
}
|
|
||||||
|
|
||||||
const currentDatas = computed(() => {
|
const currentDatas = computed(() => {
|
||||||
return ALL_PROVIDERS;
|
return ALL_PROVIDERS;
|
||||||
});
|
});
|
||||||
|
|
||||||
async function cardClicked(id) {
|
async function cardClicked(id) {
|
||||||
console.log("card clicked:", id);
|
console.log("card clicked:", id);
|
||||||
const provider = allProviders[id];
|
const Provider = allProviders[id];
|
||||||
const web3Provider = new providers.Web3Provider(provider);
|
const { provider, accounts } = await new Provider().web3Provider();
|
||||||
const accounts = await web3Provider.provider.request({ method: "eth_requestAccounts" });
|
|
||||||
console.log(accounts)
|
console.log(accounts)
|
||||||
hideModal({errcode: 0, provider: web3Provider, wallet: id, accounts});
|
hideModal({errcode: 0, provider, wallet: id, accounts});
|
||||||
}
|
}
|
||||||
|
|
||||||
function cancelSelect() {
|
function cancelSelect() {
|
||||||
@ -77,84 +85,93 @@ function hideModal(result = null) {
|
|||||||
background-color: #000000a3;
|
background-color: #000000a3;
|
||||||
}
|
}
|
||||||
.modal-content {
|
.modal-content {
|
||||||
width: 500px;
|
width: 31.25vw;
|
||||||
max-height: 400px;
|
background-color: #2d2738;
|
||||||
position: absolute;
|
border-radius: 20px;
|
||||||
top: 0;
|
color: white;
|
||||||
right: 0;
|
|
||||||
bottom: 0;
|
|
||||||
left: 0;
|
|
||||||
margin: auto;
|
margin: auto;
|
||||||
display: flex;
|
display: flex;
|
||||||
|
position: relative;
|
||||||
|
margin-top: 15vh;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
.mobile {
|
.mobile {
|
||||||
width: 100vw;
|
width: 100vw;
|
||||||
}
|
}
|
||||||
.modal-title {
|
.modal-title {
|
||||||
background-color: rgb(255, 255, 255);
|
|
||||||
color: black;
|
|
||||||
border-radius: 12px 12px 0 0;
|
border-radius: 12px 12px 0 0;
|
||||||
padding: 15px 20px;
|
padding: 15px 20px;
|
||||||
border-bottom: 1px solid rgba(195, 195, 195, 0.14);
|
border-bottom: 1px solid rgba(195, 195, 195, 0.14);
|
||||||
}
|
|
||||||
.chain-modal-card {
|
|
||||||
background-color: rgb(255, 255, 255);
|
|
||||||
transition: background-color 0.2s ease-in-out 0s;
|
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: row;
|
||||||
-webkit-box-pack: center;
|
|
||||||
justify-content: center;
|
|
||||||
-webkit-box-align: center;
|
|
||||||
align-items: center;
|
align-items: center;
|
||||||
padding: 24px 16px;
|
justify-content: space-between;
|
||||||
text-align: center;
|
}
|
||||||
cursor: pointer;
|
.modal-sub-title {
|
||||||
&:first-child {
|
padding: 15px 20px;
|
||||||
border-radius: 12px 12px 0 0;
|
border-bottom: 1px solid rgba(195, 195, 195, 0.14);
|
||||||
}
|
font-size: 16px;
|
||||||
&:not(:first-child) {
|
font-weight: 400;
|
||||||
border-top: 1px solid rgba(195, 195, 195, 0.14);
|
}
|
||||||
}
|
.modal-body {
|
||||||
&:last-child {
|
padding: 0 1.5625vw 1.04167vw;
|
||||||
border-radius: 0 0 12px 12px;
|
.chain-modal-card {
|
||||||
}
|
transition: background-color 0.2s ease-in-out 0s;
|
||||||
.icon {
|
|
||||||
width: 45px;
|
|
||||||
height: 45px;
|
|
||||||
display: flex;
|
display: flex;
|
||||||
border-radius: 50%;
|
flex-direction: row;
|
||||||
overflow: visible;
|
|
||||||
box-shadow: none;
|
|
||||||
-webkit-box-pack: center;
|
-webkit-box-pack: center;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
-webkit-box-align: center;
|
-webkit-box-align: center;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
img {
|
padding: .78125vw 1.5625vw;
|
||||||
width: 100%;
|
text-align: center;
|
||||||
height: 100%;
|
cursor: pointer;
|
||||||
|
border: .10417vw solid #625a6b;
|
||||||
|
border-radius: .41667vw;
|
||||||
|
padding: .78125vw 1.5625vw;
|
||||||
|
margin: 1.04167vw 0;
|
||||||
|
// &:first-child {
|
||||||
|
// border-radius: 12px 12px 0 0;
|
||||||
|
// }
|
||||||
|
// &:not(:first-child) {
|
||||||
|
// border-top: 1px solid rgba(195, 195, 195, 0.14);
|
||||||
|
// }
|
||||||
|
// &:last-child {
|
||||||
|
// border-radius: 0 0 12px 12px;
|
||||||
|
// }
|
||||||
|
.icon {
|
||||||
|
width: 45px;
|
||||||
|
height: 45px;
|
||||||
|
display: flex;
|
||||||
|
border-radius: 50%;
|
||||||
|
overflow: visible;
|
||||||
|
box-shadow: none;
|
||||||
|
-webkit-box-pack: center;
|
||||||
|
justify-content: center;
|
||||||
|
-webkit-box-align: center;
|
||||||
|
align-items: center;
|
||||||
|
img {
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
}
|
||||||
|
.icon-svg {
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
fill: currentColor;
|
||||||
|
color: unset;
|
||||||
|
stroke: none;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
.icon-svg {
|
.name {
|
||||||
width: 100%;
|
width: 80%;
|
||||||
height: 100%;
|
font-size: 24px;
|
||||||
fill: currentColor;
|
font-weight: 700;
|
||||||
color: unset;
|
margin-top: 0.5em;
|
||||||
stroke: none;
|
text-align: left;
|
||||||
|
margin-left: 20px;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.name {
|
|
||||||
width: 100%;
|
|
||||||
font-size: 24px;
|
|
||||||
font-weight: 700;
|
|
||||||
margin-top: 0.5em;
|
|
||||||
color: rgb(12, 12, 13);
|
|
||||||
}
|
|
||||||
.desc {
|
|
||||||
width: 100%;
|
|
||||||
font-size: 18px;
|
|
||||||
margin: 0.333em 0px;
|
|
||||||
color: rgb(169, 169, 188);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
31
src/components/chain/wallet/MetaMaskWallet.js
Normal file
31
src/components/chain/wallet/MetaMaskWallet.js
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
import { providers } from "ethers"
|
||||||
|
|
||||||
|
export class MetaMaskWallet{
|
||||||
|
constructor() {
|
||||||
|
if (MetaMaskWallet.instance) {
|
||||||
|
return MetaMaskWallet.instance;
|
||||||
|
}
|
||||||
|
MetaMaskWallet.instance = this;
|
||||||
|
this._nativeProvider = window.ethereum;
|
||||||
|
}
|
||||||
|
|
||||||
|
get nativeProvider() {
|
||||||
|
return this._nativeProvider
|
||||||
|
}
|
||||||
|
async web3Provider() {
|
||||||
|
const provider = new providers.Web3Provider(this.nativeProvider);
|
||||||
|
const accounts = await this.nativeProvider.request({ method: "eth_requestAccounts" });
|
||||||
|
return { provider, accounts };
|
||||||
|
}
|
||||||
|
|
||||||
|
async logout() {
|
||||||
|
await this.nativeProvider.request({
|
||||||
|
"method": "wallet_revokePermissions",
|
||||||
|
"params": [
|
||||||
|
{
|
||||||
|
"eth_accounts": {}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
25
src/components/chain/wallet/OkxWallet.js
Normal file
25
src/components/chain/wallet/OkxWallet.js
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
import { providers } from "ethers"
|
||||||
|
|
||||||
|
export class OkxWallet{
|
||||||
|
constructor() {
|
||||||
|
if (OkxWallet.instance) {
|
||||||
|
return OkxWallet.instance;
|
||||||
|
}
|
||||||
|
OkxWallet.instance = this;
|
||||||
|
this._nativeProvider = window.okxwallet;
|
||||||
|
}
|
||||||
|
|
||||||
|
get nativeProvider() {
|
||||||
|
return this._nativeProvider
|
||||||
|
}
|
||||||
|
|
||||||
|
async web3Provider() {
|
||||||
|
const provider = new providers.Web3Provider(this.nativeProvider);
|
||||||
|
const accounts = await this.nativeProvider.request({ method: "eth_requestAccounts" });
|
||||||
|
return { provider, accounts };
|
||||||
|
}
|
||||||
|
|
||||||
|
async logout() {
|
||||||
|
await this.nativeProvider.request({ method: 'wallet_disconnect' });
|
||||||
|
}
|
||||||
|
}
|
@ -1,5 +1,4 @@
|
|||||||
import { config, passport, orderbook, checkout } from '@imtbl/sdk';
|
import { config, passport, orderbook, checkout } from '@imtbl/sdk';
|
||||||
import { createSingleton } from '@/utils/singleton';
|
|
||||||
import { providers } from 'ethers';
|
import { providers } from 'ethers';
|
||||||
|
|
||||||
const environment = process.env.NODE_ENV === 'production' ? config.Environment.PRODUCTION : config.Environment.SANDBOX;
|
const environment = process.env.NODE_ENV === 'production' ? config.Environment.PRODUCTION : config.Environment.SANDBOX;
|
||||||
@ -10,8 +9,12 @@ const logoutRedirectUri = import.meta.env.VUE_APP_PASSPORT_LOGOUT_URI
|
|||||||
|
|
||||||
|
|
||||||
export const baseConfig = { environment, publishableKey }
|
export const baseConfig = { environment, publishableKey }
|
||||||
class LPassportWallet {
|
export class PassportWallet {
|
||||||
constructor() {
|
constructor() {
|
||||||
|
if (PassportWallet.instance) {
|
||||||
|
return PassportWallet.instance;
|
||||||
|
}
|
||||||
|
PassportWallet.instance = this;
|
||||||
this.passportInstance = new passport.Passport({
|
this.passportInstance = new passport.Passport({
|
||||||
baseConfig,
|
baseConfig,
|
||||||
clientId, // replace with your client ID from Hub
|
clientId, // replace with your client ID from Hub
|
||||||
@ -55,9 +58,13 @@ class LPassportWallet {
|
|||||||
return this.passportInstance.connectEvm();
|
return this.passportInstance.connectEvm();
|
||||||
}
|
}
|
||||||
|
|
||||||
get web3Provider() {
|
async web3Provider() {
|
||||||
const passportProvider = this.passportInstance.connectEvm();
|
const passportProvider = this.passportInstance.connectEvm();
|
||||||
return new providers.Web3Provider(passportProvider);
|
const accounts = await passportProvider.request({ method: "eth_requestAccounts" });
|
||||||
|
const provider = new providers.Web3Provider(passportProvider);
|
||||||
|
let accessToken = await this.passportInstance.getAccessToken()
|
||||||
|
console.log(`accesstoken`, accessToken)
|
||||||
|
return { provider, accounts };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -70,5 +77,3 @@ class LPassportWallet {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export const PassportWallet = createSingleton(LPassportWallet)
|
|
@ -40,12 +40,12 @@
|
|||||||
<div class="immutable-cart-img">
|
<div class="immutable-cart-img">
|
||||||
<img src="@/assets/img/marketplace/Add shopping cart02.png" alt="">
|
<img src="@/assets/img/marketplace/Add shopping cart02.png" alt="">
|
||||||
</div>
|
</div>
|
||||||
<div v-if="immutableStore.accessToken" class="immutable-cart-amount">7</div>
|
<div v-if="localWalletStore.address" class="immutable-cart-amount">7</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="metaMask-login" v-if="!immutableStore.accessToken" @click="immuTableLogin">Login</div>
|
<div class="metaMask-login" v-if="!localWalletStore.address" @click="immuTableLogin">Login</div>
|
||||||
<div class="metaMask-login-active" v-else @click="showMenu = !showMenu">
|
<div class="metaMask-login-active" v-else @click="showMenu = !showMenu">
|
||||||
<div class="matamask">
|
<div class="matamask">
|
||||||
<div class="title">{{ formatAddress }}</div>
|
<div class="title">{{ localWalletStore.showAddress }}</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="menu" v-show="showMenu">
|
<div class="menu" v-show="showMenu">
|
||||||
<div class="menu-item" @click="immuTableLogout">Logout</div>
|
<div class="menu-item" @click="immuTableLogout">Logout</div>
|
||||||
@ -75,7 +75,10 @@ import WalletSelectModel from "@/components/chain/WalletSelectModel.vue"
|
|||||||
import { createModal } from "@/utils/model.util"
|
import { createModal } from "@/utils/model.util"
|
||||||
|
|
||||||
import Cart from "@/components/cart/index.vue"
|
import Cart from "@/components/cart/index.vue"
|
||||||
|
import { BlockChain } from "../chain/BlockChain";
|
||||||
|
import {walletStore} from "@/store/wallet";
|
||||||
|
|
||||||
|
const localWalletStore = walletStore()
|
||||||
const immutableStore = useImmutableStore()
|
const immutableStore = useImmutableStore()
|
||||||
const marketplaceStore = useMarketplaceStore()
|
const marketplaceStore = useMarketplaceStore()
|
||||||
const AppModule = useAppStore();
|
const AppModule = useAppStore();
|
||||||
@ -230,10 +233,11 @@ watchEffect(() => {
|
|||||||
|
|
||||||
// --------------------------------
|
// --------------------------------
|
||||||
const immuTableLogin = async () => {
|
const immuTableLogin = async () => {
|
||||||
let rewardModal = createModal(WalletSelectModel, {})
|
// let rewardModal = createModal(WalletSelectModel, {})
|
||||||
|
|
||||||
let result = await rewardModal.show()
|
// let result = await rewardModal.show()
|
||||||
console.log(`select result : ${result.errcode}`)
|
// console.log(`select result : ${result.errcode}`)
|
||||||
|
await new BlockChain().connect()
|
||||||
// try{
|
// try{
|
||||||
// const walletLogin = await new PassportWallet().connect()
|
// const walletLogin = await new PassportWallet().connect()
|
||||||
// immutableStore.accessToken = walletLogin.accessToken
|
// immutableStore.accessToken = walletLogin.accessToken
|
||||||
@ -257,14 +261,15 @@ const immuTableLogin = async () => {
|
|||||||
// console.log(e);
|
// console.log(e);
|
||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
|
//TODO::
|
||||||
const immuTableLogout = async () => {
|
const immuTableLogout = async () => {
|
||||||
try {
|
try {
|
||||||
localStorage.removeItem('assessToken')
|
await new BlockChain().logout()
|
||||||
localStorage.removeItem('assessAddress')
|
// localStorage.removeItem('assessToken')
|
||||||
immutableStore.accessToken = ''
|
// localStorage.removeItem('assessAddress')
|
||||||
immutableStore.accounts = ''
|
// immutableStore.accessToken = ''
|
||||||
await new PassportWallet().logout()
|
// immutableStore.accounts = ''
|
||||||
|
// await new PassportWallet().logout()
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log(e)
|
console.log(e)
|
||||||
}
|
}
|
||||||
|
@ -18,9 +18,6 @@ import { notification } from 'ant-design-vue';
|
|||||||
import { createPinia } from 'pinia'
|
import { createPinia } from 'pinia'
|
||||||
import piniaPluginPersistedstate from 'pinia-plugin-persistedstate'
|
import piniaPluginPersistedstate from 'pinia-plugin-persistedstate'
|
||||||
|
|
||||||
import { BlockChain } from '@/components/chain/BlockChain';
|
|
||||||
new BlockChain().preparePassport();
|
|
||||||
|
|
||||||
const pinia = createPinia()
|
const pinia = createPinia()
|
||||||
pinia.use(piniaPluginPersistedstate)
|
pinia.use(piniaPluginPersistedstate)
|
||||||
|
|
||||||
|
34
src/store/wallet.js
Normal file
34
src/store/wallet.js
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
import {defineStore} from "pinia";
|
||||||
|
import {ref, computed} from "vue";
|
||||||
|
|
||||||
|
export const walletStore = defineStore(
|
||||||
|
"localwallet",
|
||||||
|
() => {
|
||||||
|
const walletType = ref();
|
||||||
|
const address = ref();
|
||||||
|
const chainId = ref();
|
||||||
|
|
||||||
|
const showAddress = computed(() => {
|
||||||
|
if (address.value.length > 10) {
|
||||||
|
return `${address.value.slice(0, 6)}...${address.value.slice(-4)}`;
|
||||||
|
} else {
|
||||||
|
return address.value
|
||||||
|
}
|
||||||
|
})
|
||||||
|
function reset() {
|
||||||
|
walletType.value = '';
|
||||||
|
address.value = '';
|
||||||
|
chainId.value = '';
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
walletType,
|
||||||
|
address,
|
||||||
|
chainId,
|
||||||
|
showAddress,
|
||||||
|
reset,
|
||||||
|
};
|
||||||
|
},
|
||||||
|
{
|
||||||
|
persist: true,
|
||||||
|
}
|
||||||
|
);
|
Loading…
x
Reference in New Issue
Block a user