tg-blog 1.0.3 → 1.0.4-alpha1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +22 -1
- package/package.json +3 -1
- package/src/views/PostView.vue +3 -5
- package/src/views/TgBlog.vue +11 -4
package/README.md
CHANGED
|
@@ -9,7 +9,8 @@ Demo: TODO
|
|
|
9
9
|
#### 1. Install dependencies
|
|
10
10
|
|
|
11
11
|
```
|
|
12
|
-
yarn add tg-blog
|
|
12
|
+
yarn add tg-blog element-plus
|
|
13
|
+
yarn add -D unplugin-vue-components unplugin-auto-import
|
|
13
14
|
```
|
|
14
15
|
|
|
15
16
|
#### 2. Import CSS in your `main.ts`
|
|
@@ -31,6 +32,26 @@ export default defineConfig({
|
|
|
31
32
|
});
|
|
32
33
|
```
|
|
33
34
|
|
|
35
|
+
#### 3. In your `vite.config.ts`, you shall configure autoimport
|
|
36
|
+
|
|
37
|
+
```ts
|
|
38
|
+
import AutoImport from 'unplugin-auto-import/vite'
|
|
39
|
+
import Components from 'unplugin-vue-components/vite'
|
|
40
|
+
import {ElementPlusResolver} from "unplugin-vue-components/resolvers";
|
|
41
|
+
|
|
42
|
+
export default defineConfig({
|
|
43
|
+
plugins: [
|
|
44
|
+
vue(),
|
|
45
|
+
AutoImport({
|
|
46
|
+
resolvers: [ElementPlusResolver()],
|
|
47
|
+
}),
|
|
48
|
+
Components({
|
|
49
|
+
resolvers: [ElementPlusResolver()],
|
|
50
|
+
}),
|
|
51
|
+
],
|
|
52
|
+
});
|
|
53
|
+
```
|
|
54
|
+
|
|
34
55
|
#### 4. Import components
|
|
35
56
|
|
|
36
57
|
```ts
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tg-blog",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.4-alpha1",
|
|
4
4
|
"scripts": {
|
|
5
5
|
"dev": "vite",
|
|
6
6
|
"serve": "vite",
|
|
@@ -30,6 +30,8 @@
|
|
|
30
30
|
"vue": "^3.2.33",
|
|
31
31
|
"vue-class-component": "^8.0.0-rc.1",
|
|
32
32
|
"vue-property-decorator": "^10.0.0-rc.3",
|
|
33
|
+
"unplugin-vue-components": "^0.22.12",
|
|
34
|
+
"unplugin-auto-import": "^0.12.1",
|
|
33
35
|
"vue-tsc": "^1.0.11"
|
|
34
36
|
},
|
|
35
37
|
"files": [
|
package/src/views/PostView.vue
CHANGED
|
@@ -193,12 +193,10 @@ export default class PostView extends Vue
|
|
|
193
193
|
.info
|
|
194
194
|
display: flex
|
|
195
195
|
color: lighten($color-text-main, 40)
|
|
196
|
+
white-space: nowrap
|
|
197
|
+
overflow: hidden
|
|
196
198
|
font-size: 0.9em
|
|
197
|
-
|
|
198
|
-
margin: 0 10px
|
|
199
|
-
|
|
200
|
-
div:first-child, div:last-child
|
|
201
|
-
margin: 0
|
|
199
|
+
gap: 10px
|
|
202
200
|
|
|
203
201
|
i
|
|
204
202
|
font-size: 0.8em
|
package/src/views/TgBlog.vue
CHANGED
|
@@ -3,11 +3,11 @@
|
|
|
3
3
|
<h2>Failed loading posts from: <br>{{postsUrl}}</h2>
|
|
4
4
|
{{fail}}
|
|
5
5
|
</div>
|
|
6
|
-
<div id="Life" v-if="posts.length !== 0">
|
|
7
|
-
<PostView :p="
|
|
8
|
-
<AudioPlayer :audio="audio" v-if="audio"
|
|
9
|
-
@prev="audioNext(-1)" @next="audioNext(1)"/>
|
|
6
|
+
<div v-infinite-scroll="infiniteScroll" id="Life" v-if="posts.length !== 0">
|
|
7
|
+
<PostView :p="posts[i]" :postsUrl="postsUrl" v-for="(n, i) in count" :key="i" @play="a => audio = a" />
|
|
10
8
|
</div>
|
|
9
|
+
<AudioPlayer :audio="audio" v-if="audio"
|
|
10
|
+
@prev="audioNext(-1)" @next="audioNext(1)"/>
|
|
11
11
|
</template>
|
|
12
12
|
|
|
13
13
|
<script lang="ts">
|
|
@@ -23,6 +23,7 @@ import AudioPlayer from "@/views/AudioPlayer.vue";
|
|
|
23
23
|
export default class TgBlog extends Vue
|
|
24
24
|
{
|
|
25
25
|
posts: Post[] = []
|
|
26
|
+
count = 20
|
|
26
27
|
|
|
27
28
|
@Prop({required: true}) postsUrl: string
|
|
28
29
|
|
|
@@ -45,6 +46,12 @@ export default class TgBlog extends Vue
|
|
|
45
46
|
return new URL(url, this.postsUrl).toString();
|
|
46
47
|
}
|
|
47
48
|
|
|
49
|
+
infiniteScroll()
|
|
50
|
+
{
|
|
51
|
+
console.log("Infinite Scroll - Load more")
|
|
52
|
+
this.count = Math.min(this.count + 10, this.posts.length)
|
|
53
|
+
}
|
|
54
|
+
|
|
48
55
|
created(): void
|
|
49
56
|
{
|
|
50
57
|
fetch(this.postsUrl).then(it => it.json()).then(it => {
|