fix
This commit is contained in:
parent
c4f31dd08e
commit
823c5727df
@ -7,7 +7,7 @@ module.exports = {
|
|||||||
propList: ['*'], // 能转化为vw的属性列表
|
propList: ['*'], // 能转化为vw的属性列表
|
||||||
viewportUnit: 'vw', // 希望使用的视口单位
|
viewportUnit: 'vw', // 希望使用的视口单位
|
||||||
fontViewportUnit: 'vw', // 字体使用的视口单位
|
fontViewportUnit: 'vw', // 字体使用的视口单位
|
||||||
selectorBlackList: [], // 需要忽略的CSS选择器,不会转为视口单位,使用原有的px等单位。
|
selectorBlackList: ['.bg-middle'], // 需要忽略的CSS选择器,不会转为视口单位,使用原有的px等单位。
|
||||||
minPixelValue: 1, // 设置最小的转换数值,如果为1的话,只有大于1的值会被转换
|
minPixelValue: 1, // 设置最小的转换数值,如果为1的话,只有大于1的值会被转换
|
||||||
mediaQuery: false, // 媒体查询里的单位是否需要转换单位
|
mediaQuery: false, // 媒体查询里的单位是否需要转换单位
|
||||||
replace: true, // 是否直接更换属性值,而不添加备用属性
|
replace: true, // 是否直接更换属性值,而不添加备用属性
|
||||||
|
@ -43,6 +43,7 @@ export const logout = () =>
|
|||||||
// })
|
// })
|
||||||
|
|
||||||
export const getNonce = (params) =>
|
export const getNonce = (params) =>
|
||||||
|
|
||||||
request({
|
request({
|
||||||
url: '/webapp/index.php?c=Market&a=getNonce',
|
url: '/webapp/index.php?c=Market&a=getNonce',
|
||||||
method: 'get',
|
method: 'get',
|
||||||
|
@ -62,6 +62,7 @@ export default class ChainManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public async login() {
|
public async login() {
|
||||||
|
|
||||||
if (!AppModule.step) {
|
if (!AppModule.step) {
|
||||||
try {
|
try {
|
||||||
await this.bc.connect(true)
|
await this.bc.connect(true)
|
||||||
@ -75,6 +76,7 @@ export default class ChainManager {
|
|||||||
|
|
||||||
public async checkNance() {
|
public async checkNance() {
|
||||||
try {
|
try {
|
||||||
|
|
||||||
let nonce = AppModule.nonce
|
let nonce = AppModule.nonce
|
||||||
if (!nonce) {
|
if (!nonce) {
|
||||||
const preRequest: any = await getNonce({
|
const preRequest: any = await getNonce({
|
||||||
@ -101,6 +103,7 @@ export default class ChainManager {
|
|||||||
public async getNance() {
|
public async getNance() {
|
||||||
console.log('need get nance')
|
console.log('need get nance')
|
||||||
try {
|
try {
|
||||||
|
|
||||||
const preRequest: any = await getNonce({
|
const preRequest: any = await getNonce({
|
||||||
account: AppModule.accountId,
|
account: AppModule.accountId,
|
||||||
net_id: AppModule.chainId
|
net_id: AppModule.chainId
|
||||||
|
@ -100,6 +100,7 @@ export class Blockchain {
|
|||||||
this.subscribeToEvents()
|
this.subscribeToEvents()
|
||||||
const accounts = await this.web3.eth.getAccounts()
|
const accounts = await this.web3.eth.getAccounts()
|
||||||
if (accounts && accounts.length > 0) {
|
if (accounts && accounts.length > 0) {
|
||||||
|
|
||||||
AppModule.updateAccount(accounts[0])
|
AppModule.updateAccount(accounts[0])
|
||||||
}
|
}
|
||||||
if (!this.currentChain) this.currentChain = chainId
|
if (!this.currentChain) this.currentChain = chainId
|
||||||
|
@ -66,17 +66,21 @@ function click(event) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const formatAddress = computed(() => {
|
const formatAddress = computed(() => {
|
||||||
if (AppModule.accountId.length >= 10) {
|
console.log(AppModule.accountId.value,'AppModule.accountId');
|
||||||
|
if(!AppModule.accountId.value){
|
||||||
|
return '-'
|
||||||
|
}
|
||||||
|
if (AppModule.accountId.value.length >= 10) {
|
||||||
return (
|
return (
|
||||||
AppModule.accountId.substring(0, 6) +
|
AppModule.accountId.value.substring(0, 6) +
|
||||||
"......" +
|
"......" +
|
||||||
AppModule.accountId.substring(AppModule.accountId.length - 4)
|
AppModule.accountId.value.substring(AppModule.accountId.value.length - 4)
|
||||||
);
|
);
|
||||||
} else if (
|
} else if (
|
||||||
AppModule.accountId.length > 0 &&
|
AppModule.accountId.value.length > 0 &&
|
||||||
AppModule.accountId.length < 10
|
AppModule.accountId.value.length < 10
|
||||||
) {
|
) {
|
||||||
return AppModule.accountId;
|
return AppModule.accountId.value
|
||||||
} else {
|
} else {
|
||||||
return "-";
|
return "-";
|
||||||
}
|
}
|
||||||
|
@ -27,6 +27,7 @@ export const useAppStore = defineStore('app', () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function updateAccount(_accountId) {
|
function updateAccount(_accountId) {
|
||||||
|
|
||||||
accountId.value = _accountId;
|
accountId.value = _accountId;
|
||||||
}
|
}
|
||||||
function updateChainID(_chainId) {
|
function updateChainID(_chainId) {
|
||||||
|
@ -1,76 +1,93 @@
|
|||||||
import { defineStore } from 'pinia';
|
import { defineStore } from "pinia";
|
||||||
import { ref } from 'vue';
|
import { ref } from "vue";
|
||||||
import { getToken, setToken, removeToken } from '@/utils/cookies';
|
import {
|
||||||
import glodata from './user_global';
|
getToken,
|
||||||
|
setToken,
|
||||||
|
removeToken,
|
||||||
|
getAccountId,
|
||||||
|
setAccountId,
|
||||||
|
removeAccountId
|
||||||
|
} from "@/utils/cookies";
|
||||||
|
import glodata from "./user_global";
|
||||||
|
|
||||||
import pinia from '@/store'
|
import pinia from "@/store";
|
||||||
import { useAppStore } from '@/store/app'
|
import { useAppStore } from "@/store/app";
|
||||||
const AppModule = useAppStore(pinia);
|
const AppModule = useAppStore(pinia);
|
||||||
glodata.token = getToken();
|
glodata.token = getToken();
|
||||||
glodata.accountId = AppModule.accountId;
|
glodata.accountId = AppModule.accountId.value;
|
||||||
glodata.chainId = AppModule.chainId;
|
glodata.chainId = AppModule.chainId.value;
|
||||||
import { login } from '@/api/User';
|
import { login } from "@/api/User";
|
||||||
|
|
||||||
export const useUserStore = defineStore('user', () => {
|
|
||||||
|
|
||||||
|
export const useUserStore = defineStore("user", () => {
|
||||||
const EIP721_DOMAIN_DATA = [
|
const EIP721_DOMAIN_DATA = [
|
||||||
{ name: 'name', type: 'string' },
|
{ name: "name", type: "string" },
|
||||||
{ name: 'version', type: 'string' }
|
{ name: "version", type: "string" },
|
||||||
];
|
];
|
||||||
|
|
||||||
const token = ref(getToken());
|
const token = ref(getToken());
|
||||||
|
const accountId = ref(getAccountId());
|
||||||
|
AppModule.updateAccount(accountId);
|
||||||
|
if(token.value && accountId.value){
|
||||||
|
|
||||||
|
AppModule.updateStep(1);
|
||||||
|
}
|
||||||
|
|
||||||
async function Login({bcInstance, account, chainId, nonce}) {
|
async function Login({ bcInstance, account, chainId, nonce }) {
|
||||||
nonce += ''
|
nonce += "";
|
||||||
const tips = 'This signature is only used for verify your account'
|
const tips = "This signature is only used for verify your account";
|
||||||
const signMsg = {
|
const signMsg = {
|
||||||
tips,
|
tips,
|
||||||
nonce
|
nonce,
|
||||||
}
|
};
|
||||||
|
|
||||||
const signObj = {
|
const signObj = {
|
||||||
types: {
|
types: {
|
||||||
EIP712Domain: EIP721_DOMAIN_DATA,
|
EIP712Domain: EIP721_DOMAIN_DATA,
|
||||||
set: [
|
set: [
|
||||||
{ name: 'tips', type: 'string' },
|
{ name: "tips", type: "string" },
|
||||||
{ name: 'nonce', type: 'string' }
|
{ name: "nonce", type: "string" },
|
||||||
]
|
],
|
||||||
},
|
},
|
||||||
primaryType: 'set',
|
primaryType: "set",
|
||||||
domain: {
|
domain: {
|
||||||
name: 'Auth',
|
name: "Auth",
|
||||||
version: '1'
|
version: "1",
|
||||||
},
|
},
|
||||||
message: signMsg
|
message: signMsg,
|
||||||
}
|
};
|
||||||
const signature = await bcInstance.signData(signObj, account)
|
const signature = await bcInstance.signData(signObj, account);
|
||||||
const authData = {
|
const authData = {
|
||||||
account,
|
account,
|
||||||
nonce,
|
nonce,
|
||||||
signature,
|
signature,
|
||||||
tips,
|
tips,
|
||||||
net_id: chainId
|
net_id: chainId,
|
||||||
}
|
};
|
||||||
console.log('login data: ', authData)
|
console.log("login data: ", authData);
|
||||||
const res = await login(authData)
|
const res = await login(authData);
|
||||||
if (!res.errcode && res.token) {
|
if (!res.errcode && res.token) {
|
||||||
setToken(res.token)
|
setToken(res.token);
|
||||||
|
console.log(res, "resres");
|
||||||
|
setAccountId(account);
|
||||||
AppModule.updateToken(res.token);
|
AppModule.updateToken(res.token);
|
||||||
token.value = res.token;
|
token.value = res.token;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function Logout() {
|
function Logout() {
|
||||||
if (token==='') {
|
if (token === "") {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
removeAccountId()
|
||||||
removeToken();
|
removeToken();
|
||||||
token.value = '';
|
token.value = "";
|
||||||
|
accountId.value=''
|
||||||
|
AppModule.updateAccount('')
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
token,
|
token,
|
||||||
Login,
|
Login,
|
||||||
Logout,
|
Logout,
|
||||||
}
|
};
|
||||||
})
|
});
|
||||||
|
@ -14,6 +14,11 @@ export const setMini = (mini: string) => Cookies.set(miniKey, mini)
|
|||||||
|
|
||||||
// User
|
// User
|
||||||
const tokenKey = 'vue_typescript_access_token'
|
const tokenKey = 'vue_typescript_access_token'
|
||||||
|
const accountIdKey = 'vue_typescript_access_accountId'
|
||||||
export const getToken = () => localStorage.getItem(tokenKey)
|
export const getToken = () => localStorage.getItem(tokenKey)
|
||||||
export const setToken = (token: string) => localStorage.setItem(tokenKey, token)
|
export const setToken = (token: string) => localStorage.setItem(tokenKey, token)
|
||||||
export const removeToken = () => localStorage.removeItem(tokenKey)
|
export const removeToken = () => localStorage.removeItem(tokenKey)
|
||||||
|
|
||||||
|
export const getAccountId = () => localStorage.getItem(accountIdKey)
|
||||||
|
export const setAccountId = (accountId: string) => localStorage.setItem(accountIdKey, accountId)
|
||||||
|
export const removeAccountId = () => localStorage.removeItem(accountIdKey)
|
Loading…
x
Reference in New Issue
Block a user