This repository was archived by the owner on May 7, 2022. It is now read-only.
File tree 15 files changed +659
-10
lines changed
15 files changed +659
-10
lines changed Original file line number Diff line number Diff line change
1
+ // Generated by 'unplugin-auto-import'
2
+ // We suggest you to commit this file into source control
3
+ declare global { }
4
+ export { } ;
Original file line number Diff line number Diff line change
1
+ // generated by unplugin-vue-components
2
+ // We suggest you to commit this file into source control
3
+ // Read more: https://github.com/vuejs/vue-next/pull/3399
4
+ import '@vue/runtime-core'
5
+
6
+ declare module '@vue/runtime-core' {
7
+ export interface GlobalComponents {
8
+ ElInput : typeof import ( 'element-plus/es' ) [ 'ElInput' ]
9
+ ElTree : typeof import ( 'element-plus/es' ) [ 'ElTree' ]
10
+ }
11
+ }
12
+
13
+ export { }
Original file line number Diff line number Diff line change
1
+ <template >
2
+ <Suspense >
3
+ <div >
4
+ <h1 >RSS3 SDK Demos</h1 >
5
+ Ethereum Address:
6
+ <div class =" input" >
7
+ <el-input
8
+ v-model =" address"
9
+ placeholder =" Please input ethereum address"
10
+ clearable
11
+ maxlength =" 42"
12
+ show-word-limit
13
+ />
14
+ </div >
15
+ <Profiles :address =" address" ></Profiles >
16
+ </div >
17
+ <template #fallback > Loading... </template >
18
+ </Suspense >
19
+ </template >
20
+
21
+ <script setup lang="ts">
22
+ import { ref , watch } from ' vue' ;
23
+ import Profiles from ' ./components/Profiles.vue' ;
24
+
25
+ const address = ref (localStorage .getItem (' address' ) || ' 0xC8b960D09C0078c18Dcbe7eB9AB9d816BcCa8944' );
26
+ watch (address , (address ) => {
27
+ localStorage .setItem (' address' , address );
28
+ });
29
+ </script >
30
+
31
+ <style >
32
+ .input {
33
+ width : 450px ;
34
+ display : inline-block ;
35
+ margin-left : 20px ;
36
+ }
37
+ </style >
Original file line number Diff line number Diff line change
1
+ <template >
2
+ <div >
3
+ <h2 >Profiles</h2 >
4
+ <h3 >Model</h3 >
5
+ <Tree :obj =" profiles" />
6
+ <h3 >View</h3 >
7
+ </div >
8
+ </template >
9
+
10
+ <script setup lang="ts">
11
+ import { getCurrentInstance } from ' vue' ;
12
+ import Tree from ' ./Tree.vue' ;
13
+
14
+ const props = defineProps ({
15
+ address: {
16
+ type: String ,
17
+ required: true ,
18
+ },
19
+ });
20
+
21
+ const rss3 = getCurrentInstance ()?.appContext .config .globalProperties .rss3 ;
22
+
23
+ const profiles = await rss3 .profiles .get ({
24
+ prefix: ' account' ,
25
+ identity: props .address ,
26
+ platform: ' ethereum' ,
27
+ });
28
+ console .log (profiles );
29
+ </script >
30
+
31
+ <style ></style >
Original file line number Diff line number Diff line change
1
+ <template >
2
+ <el-tree :data =" data" :props =" defaultProps" />
3
+ </template >
4
+
5
+ <script lang="ts" setup>
6
+ interface Tree {
7
+ label? : string ;
8
+ children? : Tree [];
9
+ }
10
+
11
+ const props = defineProps ({
12
+ obj: {
13
+ type: Object ,
14
+ required: true ,
15
+ },
16
+ });
17
+
18
+ function labelObj(obj : any ) {
19
+ const data: Tree [] = [];
20
+ for (let key in obj ) {
21
+ const child: Tree = {};
22
+ if (typeof obj [key ] === ' object' ) {
23
+ child .label = ` ${key }: ${obj [key ].constructor .name } ` ;
24
+ child .children = labelObj (obj [key ]);
25
+ } else {
26
+ child .label = ` ${key }: ${obj [key ]} ` ;
27
+ }
28
+ data .push (child );
29
+ }
30
+ return data ;
31
+ }
32
+
33
+ const data: Tree [] = labelObj (props .obj );
34
+
35
+ const defaultProps = {
36
+ children: ' children' ,
37
+ label: ' label' ,
38
+ };
39
+ </script >
Original file line number Diff line number Diff line change
1
+ /// <reference types="vite/client" />
2
+
3
+ declare module '*.vue' {
4
+ import type { DefineComponent } from 'vue' ;
5
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/ban-types
6
+ const component : DefineComponent < { } , { } , any > ;
7
+ export default component ;
8
+ }
Original file line number Diff line number Diff line change 6
6
< title > RSS3-SDK demo</ title >
7
7
</ head >
8
8
< body >
9
+ < div id ="app "> </ div >
9
10
< script type ="module " src ="./index.ts "> </ script >
10
11
</ body >
11
12
</ html >
Original file line number Diff line number Diff line change
1
+ import Vue , { createApp } from 'vue' ;
2
+ import App from './App.vue' ;
1
3
import RSS3 from '../src/index' ;
2
- ( < any > window ) . RSS3 = RSS3 ;
4
+ import ElementPlus from 'element-plus' ;
5
+ import 'element-plus/dist/index.css' ;
3
6
4
- console . log ( RSS3 ) ;
5
- ( < any > window ) . rss3 = new RSS3 ( {
7
+ const rss3 = new RSS3 ( {
6
8
endpoint : 'http://test-pregod.rss3.dev/v0.4.0/' ,
7
- appName : 'Demo ' ,
9
+ appName : 'demo ' ,
8
10
} ) ;
11
+
12
+ const app = createApp ( App ) ;
13
+
14
+ app . config . globalProperties . rss3 = rss3 ;
15
+
16
+ app . use ( ElementPlus ) ;
17
+ app . mount ( '#app' ) ;
Original file line number Diff line number Diff line change 35
35
},
36
36
"devDependencies" : {
37
37
"@types/node" : " 17.0.21" ,
38
+ "@vitejs/plugin-vue" : " 2.3.1" ,
39
+ "element-plus" : " 2.1.9" ,
38
40
"husky" : " 6.0.0" ,
39
41
"lint-staged" : " 11.0.0" ,
40
42
"prettier" : " 2.3.0" ,
41
43
"typescript" : " 4.2.4" ,
42
- "vite" : " 2.9.4"
44
+ "unplugin-auto-import" : " 0.7.1" ,
45
+ "unplugin-vue-components" : " 0.19.3" ,
46
+ "vite" : " 2.9.4" ,
47
+ "vue" : " 3.2.33"
43
48
}
44
49
}
Original file line number Diff line number Diff line change 1
1
{
2
2
"compilerOptions" : {
3
3
"strict" : true ,
4
- "module" : " commonjs " ,
4
+ "module" : " esnext " ,
5
5
"esModuleInterop" : true ,
6
6
"allowSyntheticDefaultImports" : true ,
7
7
"strictPropertyInitialization" : false ,
8
- "target" : " es6 " ,
8
+ "target" : " esnext " ,
9
9
"declaration" : true ,
10
10
"noImplicitAny" : true ,
11
11
"moduleResolution" : " node" ,
Original file line number Diff line number Diff line change 1
1
import { defineConfig } from 'vite' ;
2
2
import path from 'path' ;
3
3
import { version } from './package.json' ;
4
+ import vue from '@vitejs/plugin-vue' ;
5
+ import AutoImport from 'unplugin-auto-import/vite' ;
6
+ import Components from 'unplugin-vue-components/vite' ;
7
+ import { ElementPlusResolver } from 'unplugin-vue-components/resolvers' ;
4
8
5
9
export default defineConfig ( {
6
10
build : {
@@ -17,4 +21,13 @@ export default defineConfig({
17
21
server : {
18
22
base : '/demo/' ,
19
23
} ,
24
+ plugins : [
25
+ vue ( ) ,
26
+ AutoImport ( {
27
+ resolvers : [ ElementPlusResolver ( ) ] ,
28
+ } ) ,
29
+ Components ( {
30
+ resolvers : [ ElementPlusResolver ( ) ] ,
31
+ } ) ,
32
+ ] ,
20
33
} ) ;
You can’t perform that action at this time.
0 commit comments