Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
meme_image
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
刘续中
meme_image
Commits
5ad2708a
Commit
5ad2708a
authored
Jun 22, 2024
by
brent
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add bus
parent
efd7f4d6
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
69 additions
and
30 deletions
+69
-30
package-lock.json
package-lock.json
+7
-7
package.json
package.json
+1
-1
Header.vue
src/components/Header.vue
+18
-10
eventBus.js
src/eventBus.js
+3
-3
Index.vue
src/views/Index.vue
+22
-1
User.vue
src/views/User.vue
+18
-8
No files found.
package-lock.json
View file @
5ad2708a
...
...
@@ -8,7 +8,7 @@
"name"
:
"AONET"
,
"version"
:
"0.0.0"
,
"dependencies"
:
{
"aonweb"
:
"^1.0.
0
"
,
"aonweb"
:
"^1.0.
1
"
,
"aos"
:
"^2.3.4"
,
"axios"
:
"^1.6.8"
,
"element-plus"
:
"^2.7.5"
,
...
...
@@ -1853,9 +1853,9 @@
}
},
"node_modules/aonweb"
:
{
"version"
:
"1.0.
0
"
,
"resolved"
:
"https://registry.npmjs.org/aonweb/-/aonweb-1.0.
0
.tgz"
,
"integrity"
:
"sha512-
5BEDJb15A1cRu3/uAm4YIbGhmXiuyM9mrO3X0TvQIGcFkb3zeO30G0vNHLGAgwS9DAKNWFkFol0POuVp4dawXA
=="
,
"version"
:
"1.0.
1
"
,
"resolved"
:
"https://registry.npmjs.org/aonweb/-/aonweb-1.0.
1
.tgz"
,
"integrity"
:
"sha512-
oh5cjsy4T1yWykh31ATbCQCmXQXVekpKXGS34O22DrC0mME6ci6S6qHZuEpEfkbLpeWCZw5G8BXMg+qeyFrL4w
=="
,
"dependencies"
:
{
"@fingerprintjs/fingerprintjs"
:
"^4.4.0"
,
"bignumber.js"
:
"^9.1.2"
,
...
...
@@ -5621,9 +5621,9 @@
}
},
"aonweb"
:
{
"version"
:
"1.0.
0
"
,
"resolved"
:
"https://registry.npmjs.org/aonweb/-/aonweb-1.0.
0
.tgz"
,
"integrity"
:
"sha512-
5BEDJb15A1cRu3/uAm4YIbGhmXiuyM9mrO3X0TvQIGcFkb3zeO30G0vNHLGAgwS9DAKNWFkFol0POuVp4dawXA
=="
,
"version"
:
"1.0.
1
"
,
"resolved"
:
"https://registry.npmjs.org/aonweb/-/aonweb-1.0.
1
.tgz"
,
"integrity"
:
"sha512-
oh5cjsy4T1yWykh31ATbCQCmXQXVekpKXGS34O22DrC0mME6ci6S6qHZuEpEfkbLpeWCZw5G8BXMg+qeyFrL4w
=="
,
"requires"
:
{
"@fingerprintjs/fingerprintjs"
:
"^4.4.0"
,
"bignumber.js"
:
"^9.1.2"
,
...
...
package.json
View file @
5ad2708a
...
...
@@ -11,7 +11,7 @@
"type-check"
:
"vue-tsc --build --force"
},
"dependencies"
:
{
"
aonweb
"
:
"
^1.0.
0
"
,
"
aonweb
"
:
"
^1.0.
1
"
,
"
aos
"
:
"
^2.3.4
"
,
"
axios
"
:
"
^1.6.8
"
,
"
element-plus
"
:
"
^2.7.5
"
,
...
...
src/components/Header.vue
View file @
5ad2708a
...
...
@@ -21,9 +21,9 @@ import {
computed
}
from
'
vue
'
;
import
{
useRouter
,
useRoute
}
from
'
vue-router
'
//
import { User } from 'aonweb'
import
{
User
}
from
'
aonweb
'
// import eventB
us from '../eventBus.js';
import
b
us
from
'
../eventBus.js
'
;
const
router
=
useRouter
()
const
route
=
useRoute
()
...
...
@@ -53,20 +53,28 @@ const goUser = () => {
};
// const balance = async () => {
// let user = new User()
// let result = await user.balance()
// if (result && result._balances && result._balances.length) {
// balanceValue = result._balances[0]
// balanceValue = balanceValue / 1000000000000000000n
// }
// };
const
balance
=
async
()
=>
{
console
.
log
(
"
balance in
"
)
let
user
=
new
User
()
let
result
=
await
user
.
balance
()
console
.
log
(
"
Header balance
"
,
result
)
if
(
result
&&
result
.
_balances
&&
result
.
_balances
.
length
)
{
let
temp
=
result
.
_balances
[
0
]
balanceValue
.
value
=
temp
/
1000000000000000000
n
}
console
.
log
(
"
Header balanceValue.value
"
,
balanceValue
.
value
)
};
// const handleBalance = (message) => {
// console.log("handleBalance",message)
// balance()
// }
bus
.
on
(
'
get_balance
'
,
(
data
)
=>
{
console
.
log
(
"
get_balance
"
,
data
)
balance
()
});
const
checkIfUserPage
=
()
=>
{
isUserPage
.
value
=
route
.
path
===
'
/user
'
};
...
...
src/eventBus.js
View file @
5ad2708a
import
{
createApp
}
from
'
vue
'
;
const
eventBus
=
createApp
({});
export
default
eventBus
;
\ No newline at end of file
import
mitt
from
'
mitt
'
;
const
bus
=
mitt
();
export
default
bus
;
\ No newline at end of file
src/views/Index.vue
View file @
5ad2708a
...
...
@@ -75,12 +75,13 @@ import { ref, onMounted } from 'vue';
import
{
showToast
}
from
'
vant
'
;
import
{
useRouter
}
from
'
vue-router
'
import
{
AI
,
AIOptions
}
from
'
aonweb
'
import
{
AI
,
AIOptions
,
User
}
from
'
aonweb
'
import
{
getTemplate
}
from
'
../lib/getTemplate
'
import
'
vant/lib/index.css
'
;
import
Header
from
'
../components/Header.vue
'
;
import
Loading
from
'
../components/Loading.vue
'
;
import
bus
from
'
../eventBus.js
'
;
const
router
=
useRouter
()
...
...
@@ -191,6 +192,7 @@ const formSubmit = async () => {
let
price
=
10
let
response
=
await
aonet
.
prediction
(
"
/predictions/ai/pulid
"
,
data
,
price
)
console
.
log
(
"
test
"
,
response
)
bus
.
emit
(
'
get_balance
'
,
"
prediction
"
);
if
(
response
&&
response
.
code
==
200
&&
response
.
data
)
{
response
=
response
.
data
}
...
...
@@ -232,8 +234,27 @@ function selectTemplate(id, imageUrl, prompt_) {
prompt
.
value
=
prompt_
}
async
function
login
()
{
console
.
log
(
'
index login
'
)
let
user
=
new
User
()
let
temp
=
await
user
.
islogin
()
if
(
!
temp
)
{
console
.
log
(
'
index islogin
'
)
await
user
.
login
((
acc
,
userId
,
error
)
=>
{
console
.
log
(
"
getWeb3 account
"
,
acc
)
console
.
log
(
"
getWeb3 userId
"
,
userId
)
console
.
log
(
"
getWeb3 error
"
,
error
)
bus
.
emit
(
'
get_balance
'
,
"
login
"
);
// eventBus.config.globalProperties.$emit('balance');
})
}
bus
.
emit
(
'
get_balance
'
,
"
login
"
);
console
.
log
(
'
index islogin sssss
'
,
temp
)
}
onMounted
(()
=>
{
getTemplateList
()
login
()
})
</
script
>
...
...
src/views/User.vue
View file @
5ad2708a
...
...
@@ -43,7 +43,7 @@ import { Options, User } from 'aonweb'
import
{
showToast
}
from
'
vant
'
;
import
Header
from
'
../components/Header.vue
'
;
// import eventB
us from '../eventBus.js';
import
b
us
from
'
../eventBus.js
'
;
...
...
@@ -78,13 +78,23 @@ async function getAccount() {
//User 的使用方法
let
user
=
new
User
()
await
user
.
login
((
acc
,
userId
,
error
)
=>
{
console
.
log
(
"
getWeb3 account
"
,
account
)
console
.
log
(
"
getWeb3 userId
"
,
userId
)
console
.
log
(
"
getWeb3 error
"
,
error
)
account
.
value
=
acc
// eventBus.config.globalProperties.$emit('balance');
})
if
(
!
await
user
.
islogin
())
{
await
user
.
login
((
acc
,
userId
,
error
)
=>
{
console
.
log
(
"
getWeb3 account
"
,
acc
)
console
.
log
(
"
getWeb3 userId
"
,
userId
)
console
.
log
(
"
getWeb3 error
"
,
error
)
account
.
value
=
acc
bus
.
emit
(
'
get_balance
'
,
"
login
"
);
// eventBus.config.globalProperties.$emit('balance');
})
}
else
{
let
ethereum
=
await
detectEthereumProvider
()
let
get_account
=
await
ethereum
.
request
({
method
:
'
eth_requestAccounts
'
})
get_account
=
get_account
[
0
]
account
.
value
=
get_account
bus
.
emit
(
'
get_balance
'
,
"
login
"
);
}
// console.log("getWeb3 account", addr)
// account.value = addr[0]
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment