File tree 5 files changed +76
-23
lines changed
5 files changed +76
-23
lines changed Original file line number Diff line number Diff line change 4
4
< meta charset ="UTF-8 " />
5
5
< link rel ="icon " type ="image/svg+xml " href ="/vite.svg " />
6
6
< meta name ="viewport " content ="width=device-width, initial-scale=1.0 " />
7
- < title > Vite + Vue </ title >
7
+ < title > RECIPE AI </ title >
8
8
</ head >
9
9
< body >
10
10
< div id ="app "> </ div >
Original file line number Diff line number Diff line change 9
9
"preview" : " vite preview"
10
10
},
11
11
"dependencies" : {
12
+ "axios" : " ^1.6.7" ,
12
13
"openai" : " ^4.28.0" ,
13
14
"vue" : " ^3.4.19"
14
15
},
Original file line number Diff line number Diff line change 1
1
<script setup>
2
- import HelloWorld from ' ./components/HelloWorld.vue'
2
+ import { ref } from ' vue' ;
3
+
4
+ import { getImage } from ' ./features/getImage' ;
5
+ const searchQuery = ref (' ' ); // 検索キーワード変数
6
+ const thumbnailUrl = ref (' ' ); // サムネイルURL変数
7
+
8
+ // サムネイルURLを取得する
9
+ const getThumbnailUrl = async () => {
10
+ let url = await getImage (searchQuery .value );
11
+ console .log (url);
12
+ thumbnailUrl .value = url;
13
+ };
3
14
</script >
4
15
5
16
<template >
6
17
<div >
7
- <a href =" https://vitejs.dev" target =" _blank" >
8
- <img src =" /vite.svg" class =" logo" alt =" Vite logo" />
9
- </a >
10
- <a href =" https://vuejs.org/" target =" _blank" >
11
- <img src =" ./assets/vue.svg" class =" logo vue" alt =" Vue logo" />
12
- </a >
18
+ <label >Wikimediaから画像を取得する</label >
19
+ <input type =" text" v-model =" searchQuery" />
20
+ <input type =" button" value =" get image" @click =" getThumbnailUrl()" />
21
+ <p >result: {{ thumbnailUrl }}</p >
13
22
</div >
14
- <HelloWorld msg =" Vite + Vue" />
15
23
</template >
16
24
17
- <style scoped>
18
- .logo {
19
- height : 6em ;
20
- padding : 1.5em ;
21
- will-change : filter;
22
- transition : filter 300ms ;
23
- }
24
- .logo :hover {
25
- filter : drop-shadow (0 0 2em #646cffaa );
26
- }
27
- .logo.vue :hover {
28
- filter : drop-shadow (0 0 2em #42b883aa );
29
- }
30
- </style >
25
+ <style scoped></style >
Original file line number Diff line number Diff line change
1
+ import axios from 'axios' ;
2
+
3
+ export const getImage = async ( query ) => {
4
+ // query 検索ワード
5
+ const result = await axios . get ( 'https://en.wikipedia.org/w/api.php' , {
6
+ params : {
7
+ origin : '*' ,
8
+ action : 'query' ,
9
+ prop : 'pageimages' ,
10
+ gsrsearch : query ,
11
+ generator : 'search' ,
12
+ pithumbsize : 300 ,
13
+ format : 'json' ,
14
+ } ,
15
+ headers : {
16
+ withCredentials : false ,
17
+ 'Access-Control-Allow-Credentials' : false ,
18
+ } ,
19
+ } ) ;
20
+
21
+ return result . data . query ;
22
+ } ;
You can’t perform that action at this time.
0 commit comments