Commit 5ea9dc39 authored by liubinyu's avatar liubinyu

接口

parent 0f35f171
<!doctype html> <!doctype html>
<html lang="en"> <html lang="en">
<head>
<meta charset="UTF-8" /> <head>
<link rel="icon" type="image/svg+xml" href="/vite.svg" /> <meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> <link rel="icon" type="image/svg+xml" href="/vite.svg" />
<title>AI</title> <meta name="viewport" content="width=device-width, initial-scale=1.0" />
</head> <title>AI</title>
<body> <script src="/config.js"></script>
<div id="app"></div> </head>
<script type="module" src="/src/main.js"></script>
</body> <body>
</html> <div id="app"></div>
<script type="module" src="/src/main.js"></script>
</body>
</html>
\ No newline at end of file
window.APP_CONFIG = {
baseURL: `/api`,
}
Object.freeze(window.APP_CONFIG);
Object.defineProperty(window, 'APP_CONFIG', {
configurable: false,
writable: false,
});
\ No newline at end of file
import request from '@/utils/request.js'
export function list(params) {
return request({ url: '/system/astrologyForecastDaily/list', method: 'get', params })
}
...@@ -48,8 +48,8 @@ navClick(navList.find(i => i.route === router.currentRoute.value.name)) ...@@ -48,8 +48,8 @@ navClick(navList.find(i => i.route === router.currentRoute.value.name))
<img class="icon-lang" src="/img/lang.png" alt=""> <img class="icon-lang" src="/img/lang.png" alt="">
<template #dropdown> <template #dropdown>
<el-dropdown-menu> <el-dropdown-menu>
<el-dropdown-item command="en">English</el-dropdown-item> <el-dropdown-item command="En">English</el-dropdown-item>
<el-dropdown-item command="zh">简体中文</el-dropdown-item> <el-dropdown-item command="Cn">简体中文</el-dropdown-item>
</el-dropdown-menu> </el-dropdown-menu>
</template> </template>
</el-dropdown> </el-dropdown>
......
import { createI18n } from 'vue-i18n' import { createI18n } from 'vue-i18n'
import en from './en.json' import En from './en.json'
import zh from './zh.json' import Cn from './cn.json'
const locale = localStorage.getItem('locale') || 'en' const locale = localStorage.getItem('locale') || 'En'
const i18n = createI18n({ const i18n = createI18n({
legacy: false, legacy: false,
locale, locale,
messages: { messages: {
en, En,
zh Cn
} }
}) })
......
import { reactive } from "vue"
export default { export default {
ConstellationList: [ ConstellationList: reactive([
{ key: 'Aries', date: ['3.21', '4.19'] }, { key: 'Aries', date: ['3.21', '4.19'], zodiacSignId: '1', info: {} },
{ key: 'Taurus', date: ['4.20', '5.20'] }, { key: 'Taurus', date: ['4.20', '5.20'], zodiacSignId: '2', info: {} },
{ key: 'Gemini', date: ['5.21', '6.21'] }, { key: 'Gemini', date: ['5.21', '6.21'], zodiacSignId: '3', info: {} },
{ key: 'Cancer', date: ['6.22', '7.22'] }, { key: 'Cancer', date: ['6.22', '7.22'], zodiacSignId: '4', info: {} },
{ key: 'Leo', date: ['7.23', '8.22'] }, { key: 'Leo', date: ['7.23', '8.22'], zodiacSignId: '5', info: {} },
{ key: 'Virgo', date: ['8.23', '9.22'] }, { key: 'Virgo', date: ['8.23', '9.22'], zodiacSignId: '6', info: {} },
{ key: 'HLibra', date: ['9.23', '10.23'] }, { key: 'HLibra', date: ['9.23', '10.23'], zodiacSignId: '7', info: {} },
{ key: 'Scorpio', date: ['10.24', '11.22'] }, { key: 'Scorpio', date: ['10.24', '11.22'], zodiacSignId: '8', info: {} },
{ key: 'Sagittarius', date: ['11.23', '12.21'] }, { key: 'Sagittarius', date: ['11.23', '12.21'], zodiacSignId: '9', info: {} },
{ key: 'Capricornus', date: ['12.22', '1.19'] }, { key: 'Capricornus', date: ['12.22', '1.19'], zodiacSignId: '10', info: {} },
{ key: 'Aquarius', date: ['1.20', '2.18'] }, { key: 'Aquarius', date: ['1.20', '2.18'], zodiacSignId: '11', info: {} },
{ key: 'Pisces', date: ['2.19', '3.20'] }, { key: 'Pisces', date: ['2.19', '3.20'], zodiacSignId: '12', info: {} },
] ])
} }
\ No newline at end of file
export function globalConfig(key) {
return window.APP_CONFIG[key]
}
export function dateFormat(date, fmt = 'YYYY-MM-DD') {
if (!date || !fmt) return date;
date instanceof Date || (date = new Date(date));
const o = {
'Y+': date.getFullYear(),
'M+': date.getMonth() + 1,
'D+': date.getDate(),
'H+': date.getHours(),
'm+': date.getMinutes(),
's+': date.getSeconds(),
};
for (let k in o) {
const ret = new RegExp('(' + k + ')').exec(fmt)
if (ret) {
const v = String(o[k])
if (/(Y+)/.test(k)) {
fmt = fmt.replace(ret[1], v.substring(4 - ret[1].length))
} else {
fmt = fmt.replace(ret[1], ret[1].length === 1 ? v : v.padStart(ret[1].length, '0'))
}
}
}
return fmt;
}
import axios from 'axios'
import { globalConfig } from './index'
import { ElMessage } from 'element-plus'
const SUCCESS_CODE = 200
const service = axios.create({
timeout: 60 * 1000,
})
function requestInterceptor(config) {
config.url = globalConfig('baseURL') + config.url
return config
}
function responseInterceptor(response) {
const res = response.data
if (response.config.orginal) {
return res
} else {
if (res.code !== SUCCESS_CODE) {
!response.config.silence && ElMessage.error(res.msg || res.message || '请求失败')
return
} else {
return res || true
}
}
}
service.interceptors.request.use((config) => {
requestInterceptor(config)
config.requestInterceptor?.(config)
return config
})
service.interceptors.response.use(
response => response.config.responseInterceptor?.(response) || responseInterceptor(response),
error => {
switch (error.response?.status) {
case 500:
ElMessage.error('服务器异常')
break
case 404:
ElMessage.error('找不到资源')
break
case 401:
ElMessage.error('没有权限')
break
default:
ElMessage.error(error.message)
break
}
return Promise.resolve()
})
export default service
...@@ -3,11 +3,26 @@ import { inject, ref } from 'vue'; ...@@ -3,11 +3,26 @@ import { inject, ref } from 'vue';
const _const = inject('_const') const _const = inject('_const')
import { useRouter } from 'vue-router' import { useRouter } from 'vue-router'
const router = useRouter() const router = useRouter()
import * as api from '@/api'
const active = ref(_const.ConstellationList[0]) import { dateFormat } from '@/utils'
import { useI18n } from 'vue-i18n'
const { locale } = useI18n()
const active = ref()
async function getInfo() {
const res = await api.list({ fortuneDate: dateFormat(Date.now()), pageSize: 20 })
res?.rows?.forEach(i => {
const item = _const.ConstellationList.find(j => j.zodiacSignId === i.zodiacSignId)
if (item) {
item.info = i
}
})
}
getInfo()
function changeConstellation(item) { function changeConstellation(item) {
active.value = item active.value = item
} }
changeConstellation(_const.ConstellationList[0])
function goDetail() { function goDetail() {
router.push({ name: 'Forecast', query: { key: active.value.key } }) router.push({ name: 'Forecast', query: { key: active.value.key } })
} }
...@@ -51,15 +66,8 @@ function goDetail() { ...@@ -51,15 +66,8 @@ function goDetail() {
<img :src="`/img/xz/${active.key}1.png`" alt=""> <img :src="`/img/xz/${active.key}1.png`" alt="">
{{ $t(active.key) }} ({{ `${active.date[0]}~${active.date[1]}` }}) {{ $t(active.key) }} ({{ `${active.date[0]}~${active.date[1]}` }})
</div> </div>
<div class="desc"> <div class="desc">{{ active.info[`title${locale}`] }}</div>
Fluctuating like tides, flowing downstream! <div class="info">{{ active.info[`fortune${locale}`] }}</div>
</div>
<div class="info">
Today's Pisces seem to be at the boundary between the deep sea and the starry sky, with exceptionally sharp
intuition and inspiration. Suitable for listening to inner voices and resolving problems with emotions, but
avoid excessive indulgence in fantasies. Emotions and creativity are the shining points of today, seize the
opportunity to express yourself!
</div>
<div class="more g-flex-center" @click="goDetail"> <div class="more g-flex-center" @click="goDetail">
{{ $t('more') }} {{ $t('more') }}
<img src="/img/arrow.png" alt=""> <img src="/img/arrow.png" alt="">
...@@ -227,7 +235,8 @@ function goDetail() { ...@@ -227,7 +235,8 @@ function goDetail() {
} }
.constellation-detail .content { .constellation-detail .content {
padding: 4.375vw 3.4375vw; flex: 1;
padding: 4vw 3.4375vw;
position: relative; position: relative;
} }
...@@ -246,7 +255,7 @@ function goDetail() { ...@@ -246,7 +255,7 @@ function goDetail() {
} }
.constellation-detail .content .desc { .constellation-detail .content .desc {
margin-top: 3.75vw; margin-top: 3vw;
margin-bottom: 2.083vw; margin-bottom: 2.083vw;
font-family: Roboto-Medium; font-family: Roboto-Medium;
font-weight: 500; font-weight: 500;
...@@ -261,22 +270,23 @@ function goDetail() { ...@@ -261,22 +270,23 @@ function goDetail() {
line-height: 2.083vw; line-height: 2.083vw;
text-align: left; text-align: left;
height: 10.415vw; height: 10.415vw;
text-overflow: -o-ellipsis-lastline;
overflow: hidden; overflow: hidden;
/* text-overflow: -o-ellipsis-lastline;
text-overflow: ellipsis; text-overflow: ellipsis;
display: -webkit-box; display: -webkit-box;
-webkit-line-clamp: 5; -webkit-line-clamp: 5;
line-clamp: 5; line-clamp: 5;
-webkit-box-orient: vertical; -webkit-box-orient: vertical; */
} }
.constellation-detail .content .more { .constellation-detail .content .more {
position: absolute; position: absolute;
right: 1.5625vw; right: 1.5625vw;
bottom: 1.5625vw; bottom: 1.3vw;
font-family: Roboto-Regular; font-family: Roboto-Regular;
font-weight: 400; font-weight: 400;
font-size: 1.25vw; font-size: 1vw;
line-height: 0;
opacity: 0.8; opacity: 0.8;
cursor: pointer; cursor: pointer;
} }
...@@ -286,6 +296,7 @@ function goDetail() { ...@@ -286,6 +296,7 @@ function goDetail() {
} }
.constellation-detail .content .more img { .constellation-detail .content .more img {
height: 1.5625vw;
margin-left: 0.833vw; margin-left: 0.833vw;
} }
......
...@@ -7,8 +7,17 @@ export default defineConfig({ ...@@ -7,8 +7,17 @@ export default defineConfig({
plugins: [vue()], plugins: [vue()],
resolve: { resolve: {
alias: [ alias: [
//配置别名
{ find: '@', replacement: resolve(__dirname, './src') }, { find: '@', replacement: resolve(__dirname, './src') },
], ],
}, },
server: {
proxy: {
'/api': {
target: 'http://47.243.113.209:8081',
changeOrigin: true,
ws: true,
rewrite: (path) => path.replace('/api', '')
},
}
},
}) })
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment