Skip to content
This repository was archived by the owner on May 7, 2022. It is now read-only.

Commit 39c0796

Browse files
committed
docs: wip profiles demo
1 parent f6950d4 commit 39c0796

15 files changed

+659
-10
lines changed

auto-imports.d.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
// Generated by 'unplugin-auto-import'
2+
// We suggest you to commit this file into source control
3+
declare global {}
4+
export {};

components.d.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
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 {}

demo/App.vue

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
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>

demo/components/Assets.vue

Whitespace-only changes.

demo/components/Links.vue

Whitespace-only changes.

demo/components/Notes.vue

Whitespace-only changes.

demo/components/Profiles.vue

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
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>

demo/components/Tree.vue

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
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>

demo/env.d.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
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+
}

demo/index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
<title>RSS3-SDK demo</title>
77
</head>
88
<body>
9+
<div id="app"></div>
910
<script type="module" src="./index.ts"></script>
1011
</body>
1112
</html>

demo/index.ts

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,17 @@
1+
import Vue, { createApp } from 'vue';
2+
import App from './App.vue';
13
import RSS3 from '../src/index';
2-
(<any>window).RSS3 = RSS3;
4+
import ElementPlus from 'element-plus';
5+
import 'element-plus/dist/index.css';
36

4-
console.log(RSS3);
5-
(<any>window).rss3 = new RSS3({
7+
const rss3 = new RSS3({
68
endpoint: 'http://test-pregod.rss3.dev/v0.4.0/',
7-
appName: 'Demo',
9+
appName: 'demo',
810
});
11+
12+
const app = createApp(App);
13+
14+
app.config.globalProperties.rss3 = rss3;
15+
16+
app.use(ElementPlus);
17+
app.mount('#app');

package.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,15 @@
3535
},
3636
"devDependencies": {
3737
"@types/node": "17.0.21",
38+
"@vitejs/plugin-vue": "2.3.1",
39+
"element-plus": "2.1.9",
3840
"husky": "6.0.0",
3941
"lint-staged": "11.0.0",
4042
"prettier": "2.3.0",
4143
"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"
4348
}
4449
}

tsconfig.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
{
22
"compilerOptions": {
33
"strict": true,
4-
"module": "commonjs",
4+
"module": "esnext",
55
"esModuleInterop": true,
66
"allowSyntheticDefaultImports": true,
77
"strictPropertyInitialization": false,
8-
"target": "es6",
8+
"target": "esnext",
99
"declaration": true,
1010
"noImplicitAny": true,
1111
"moduleResolution": "node",

vite.config.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
import { defineConfig } from 'vite';
22
import path from 'path';
33
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';
48

59
export default defineConfig({
610
build: {
@@ -17,4 +21,13 @@ export default defineConfig({
1721
server: {
1822
base: '/demo/',
1923
},
24+
plugins: [
25+
vue(),
26+
AutoImport({
27+
resolvers: [ElementPlusResolver()],
28+
}),
29+
Components({
30+
resolvers: [ElementPlusResolver()],
31+
}),
32+
],
2033
});

0 commit comments

Comments
 (0)