Skip to content

Commit c9fe14e

Browse files
authored
Merge pull request #58 from xianshenglu:feat_vue3
chore(vue@3): migrate ref to useTemplateRef
2 parents 29f2356 + 506cca7 commit c9fe14e

File tree

7 files changed

+101
-10
lines changed

7 files changed

+101
-10
lines changed

.github/workflows/vue@3-master.yml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node
2+
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions
3+
4+
name: Vue@3-PR
5+
6+
on:
7+
push:
8+
branches:
9+
- master
10+
paths:
11+
- 'demo/vue@3'
12+
jobs:
13+
build:
14+
runs-on: ubuntu-18.04
15+
16+
strategy:
17+
matrix:
18+
node-version: [22.x]
19+
20+
steps:
21+
- uses: actions/checkout@v2
22+
23+
- name: Merge master into current branch
24+
run: |
25+
git fetch master
26+
git merge master
27+
28+
- name: Use Node.js ${{ matrix.node-version }}
29+
uses: actions/setup-node@v1
30+
with:
31+
node-version: ${{ matrix.node-version }}
32+
33+
- name: Install
34+
run: npm ci
35+
36+
# - name: Lint
37+
# run: npm run lint
38+
39+
# - name: Unit Test
40+
# run: npm run test
41+
42+
# - name: EndToEnd Test
43+
# run: npm run e2e:headless
44+
45+
- name: Build
46+
run: npm run build

.github/workflows/vue@3-pr.yml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node
2+
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions
3+
4+
name: Vue@3-PR
5+
6+
on:
7+
pull_request:
8+
types: [opened, synchronize]
9+
paths:
10+
- 'demo/vue@3'
11+
jobs:
12+
build:
13+
runs-on: ubuntu-18.04
14+
15+
strategy:
16+
matrix:
17+
node-version: [22.x]
18+
19+
steps:
20+
- uses: actions/checkout@v2
21+
22+
- name: Merge master into current branch
23+
run: |
24+
git fetch master
25+
git merge master
26+
27+
- name: Use Node.js ${{ matrix.node-version }}
28+
uses: actions/setup-node@v1
29+
with:
30+
node-version: ${{ matrix.node-version }}
31+
32+
- name: Install
33+
run: npm ci
34+
35+
# - name: Lint
36+
# run: npm run lint
37+
38+
# - name: Unit Test
39+
# run: npm run test
40+
41+
# - name: EndToEnd Test
42+
# run: npm run e2e:headless
43+
44+
- name: Build
45+
run: npm run build

demo/vue@3/src/App.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,14 @@
1818
</template>
1919

2020
<script lang="ts" setup>
21-
import { ref, onMounted, computed, type Ref } from 'vue'
21+
import { onMounted, computed, useTemplateRef } from 'vue'
2222
import { useStore } from 'vuex'
2323
2424
import AppHeader from '@/components/AppHeader.vue'
2525
import AppLoading from './components/AppLoading.vue'
2626
import PlayerMed from './views/player/PlayerMed.vue'
2727
28-
const audioEl: Ref<HTMLAudioElement | null> = ref(null)
28+
const audioEl = useTemplateRef<HTMLAudioElement | null>('audioEl')
2929
const store = useStore()
3030
3131
const isPlayerMedShow = computed(() => store.state.player.isPlayerMedShow)

demo/vue@3/src/modules/PubList.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
</template>
2525

2626
<script lang="ts" setup generic="Item extends { imgUrl: string; title: string; path: string }">
27-
import { ref, watch, nextTick, computed } from 'vue';
27+
import { ref, watch, nextTick, computed, useTemplateRef } from 'vue';
2828
import { useStore } from 'vuex';
2929
import { lazyLoad } from '@/utils';
3030
interface Props {
@@ -36,7 +36,7 @@ const props = withDefaults(defineProps<Props>(), {
3636
3737
const store = useStore();
3838
const lazyImageElements = ref<(HTMLImageElement | null)[]>([]);
39-
const lazyLoadRoot = ref(null);
39+
const lazyLoadRoot = useTemplateRef<HTMLUListElement | null>('lazyLoadRoot');
4040
4141
const logo__grey = computed(() => store.state.images.logo__grey);
4242

demo/vue@3/src/views/player/PlayerProgress.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@
99
</template>
1010

1111
<script lang="ts" setup>
12-
import { ref, computed, onMounted, onUnmounted, nextTick } from 'vue'
12+
import { ref, computed, onMounted, onUnmounted, nextTick, useTemplateRef } from 'vue'
1313
import { useStore } from 'vuex'
1414
import { secondToMin } from '@/utils'
1515
1616
const store = useStore()
17-
const progressBar = ref<HTMLDivElement | null>(null)
17+
const progressBar = useTemplateRef<HTMLDivElement | null>('progressBar')
1818
1919
const audioEl = computed(() => store.state.player.audioEl)
2020

demo/vue@3/src/views/search/Search.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
</template>
3737

3838
<script lang="ts" setup>
39-
import { ref, computed, onMounted, onUnmounted } from 'vue'
39+
import { ref, computed, onMounted, onUnmounted, useTemplateRef } from 'vue'
4040
import { useStore } from 'vuex'
4141
import { useRoute, useRouter } from 'vue-router'
4242
@@ -51,7 +51,7 @@ const route = useRoute()
5151
const router = useRouter()
5252
const { startLoading, stopLoading, setLoadingExcludeSearchForm } = useLoading()
5353
54-
const searchCont = ref<HTMLElement | null>(null)
54+
const searchCont = useTemplateRef<HTMLElement | null>('searchCont')
5555
5656
const title = ref('搜索')
5757
const searchType = ref('最近热门')

demo/vue@3/src/views/singer/SingerList.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
</template>
2323

2424
<script setup>
25-
import { ref, computed, watch, nextTick, onMounted } from 'vue'
25+
import { ref, computed, watch, nextTick, onMounted, useTemplateRef } from 'vue'
2626
import { useStore } from 'vuex'
2727
import { useRoute } from 'vue-router'
2828
@@ -36,7 +36,7 @@ const store = useStore()
3636
const route = useRoute()
3737
const { startLoading, stopLoading, setLoadingExcludeHeader } = useLoading()
3838
39-
const lazyLoadRoot = ref(null)
39+
const lazyLoadRoot = useTemplateRef<HTMLUListElement | null>('lazyLoadRoot')
4040
const lazyImageElements = ref([])
4141
4242
const logo__grey = computed(() => store.state.images.logo__grey)

0 commit comments

Comments
 (0)