Some checks failed
Build and Deploy Front / deploy (push) Failing after 7s
Co-authored-by: Cursor <cursoragent@cursor.com>
425 lines
9.0 KiB
Vue
425 lines
9.0 KiB
Vue
<template>
|
||
<div class="h5-assistant-page">
|
||
<div v-if="!isLoggedIn" class="h5-assistant-guest h5-enter">
|
||
<p>{{ t('h5.assistant.guestTip') }}</p>
|
||
<H5GuestAuthCta
|
||
compact
|
||
:register-label="t('h5.assistant.guestRegister')"
|
||
:login-label="t('h5.assistant.guestLogin')"
|
||
@register="promptGuestRegister"
|
||
@login="promptGuestLogin"
|
||
/>
|
||
</div>
|
||
|
||
<!-- 查价预填上下文(运单上下文由 Shell 自带条展示) -->
|
||
<div v-if="priceContext" class="h5-ctx h5-enter">
|
||
<span class="h5-ctx__blob" aria-hidden="true" />
|
||
<div class="h5-ctx__main">
|
||
<strong>{{ t('h5.assistant.tip.priceTitle') }}</strong>
|
||
<span class="h5-ctx__desc">{{ priceContext }}</span>
|
||
</div>
|
||
<button type="button" class="h5-ctx__clear" @click="clearPriceContext">
|
||
{{ t('h5.assistant.clearContext') }}
|
||
</button>
|
||
</div>
|
||
|
||
<div class="h5-assistant-shell">
|
||
<AiAdvisorShell ref="shellRef" round-send />
|
||
</div>
|
||
</div>
|
||
</template>
|
||
|
||
<script lang="ts" setup>
|
||
import { computed, ref } from 'vue';
|
||
import { useRoute, useRouter } from 'vue-router';
|
||
import { useI18n } from 'vue-i18n';
|
||
import AiAdvisorShell from '@/components/NanaAssistant/AiAdvisorShell.vue';
|
||
import { parseWaybillContextFromQuery } from '@/composables/useAskAdvisor';
|
||
import { isLogin } from '@/utils/auth';
|
||
import H5GuestAuthCta from '../components/H5GuestAuthCta.vue';
|
||
import { ensureH5Login } from '../composables/useH5LoginGate';
|
||
import { startH5WeChatRegister } from '../composables/useH5WeChatRegister';
|
||
|
||
defineOptions({ name: 'H5Assistant' });
|
||
|
||
const { t } = useI18n();
|
||
const route = useRoute();
|
||
const router = useRouter();
|
||
const shellRef = ref<{ setInputText?: (text: string) => void } | null>(null);
|
||
|
||
const isLoggedIn = computed(() => isLogin());
|
||
|
||
const waybillCtx = computed(() => parseWaybillContextFromQuery(route.query));
|
||
|
||
const prefillText = computed(() => {
|
||
const raw = route.query.prefill;
|
||
const text = Array.isArray(raw) ? raw[0] : raw;
|
||
return typeof text === 'string' ? text.trim() : '';
|
||
});
|
||
|
||
const priceContext = computed(() => {
|
||
if (waybillCtx.value) return '';
|
||
return prefillText.value;
|
||
});
|
||
|
||
function clearPriceContext() {
|
||
const query = { ...route.query };
|
||
delete query.prefill;
|
||
router.replace({ path: '/h5/assistant', query });
|
||
shellRef.value?.setInputText?.('');
|
||
}
|
||
|
||
function promptGuestLogin() {
|
||
ensureH5Login({
|
||
reasonKey: 'h5.loginGate.reason.assistant',
|
||
redirect: route.fullPath || '/h5/assistant',
|
||
});
|
||
}
|
||
|
||
function promptGuestRegister() {
|
||
startH5WeChatRegister({ redirect: route.fullPath || '/h5/assistant' });
|
||
}
|
||
</script>
|
||
|
||
<style lang="less" scoped>
|
||
.h5-assistant-page {
|
||
height: calc(100dvh - var(--h5-dock-offset));
|
||
min-height: 360px;
|
||
padding: 10px 12px 8px;
|
||
box-sizing: border-box;
|
||
display: flex;
|
||
flex-direction: column;
|
||
gap: 8px;
|
||
background: #f5f6f8;
|
||
}
|
||
|
||
.h5-assistant-guest {
|
||
flex-shrink: 0;
|
||
padding: 12px 12px 10px;
|
||
border-radius: 12px;
|
||
background: #ffffff;
|
||
box-shadow: 0 4px 16px rgba(20, 38, 55, 0.05);
|
||
|
||
> p {
|
||
margin: 0 0 10px;
|
||
font-size: 13px;
|
||
line-height: 1.45;
|
||
color: var(--h5-text-2, #4e5969);
|
||
}
|
||
}
|
||
|
||
.h5-ctx {
|
||
position: relative;
|
||
z-index: 0;
|
||
overflow: hidden;
|
||
isolation: isolate;
|
||
display: flex;
|
||
align-items: center;
|
||
gap: 10px;
|
||
padding: 12px 12px 12px 14px;
|
||
border-radius: 14px;
|
||
border: none;
|
||
background: #ffffff;
|
||
box-shadow:
|
||
inset 0 2px 8px rgba(15, 23, 42, 0.07),
|
||
inset 0 1px 1px rgba(15, 23, 42, 0.04);
|
||
flex-shrink: 0;
|
||
}
|
||
|
||
.h5-ctx__blob {
|
||
position: absolute;
|
||
z-index: 0;
|
||
inset: -50% -10% auto auto;
|
||
width: 70%;
|
||
height: 140%;
|
||
border-radius: 42% 58% 48% 52% / 48% 42% 58% 52%;
|
||
background:
|
||
radial-gradient(
|
||
circle at 70% 60%,
|
||
color-mix(in srgb, var(--app-primary-color) 18%, transparent) 0%,
|
||
transparent 58%
|
||
);
|
||
filter: blur(12px);
|
||
opacity: 0.7;
|
||
pointer-events: none;
|
||
}
|
||
|
||
.h5-ctx__main {
|
||
position: relative;
|
||
z-index: 1;
|
||
flex: 1;
|
||
min-width: 0;
|
||
display: flex;
|
||
flex-direction: column;
|
||
gap: 3px;
|
||
|
||
strong {
|
||
font-size: 13px;
|
||
font-weight: 700;
|
||
color: var(--app-primary-color);
|
||
}
|
||
}
|
||
|
||
.h5-ctx__desc {
|
||
font-size: 12px;
|
||
color: #4e5969;
|
||
line-height: 1.4;
|
||
display: -webkit-box;
|
||
-webkit-line-clamp: 2;
|
||
-webkit-box-orient: vertical;
|
||
overflow: hidden;
|
||
}
|
||
|
||
.h5-ctx__clear {
|
||
position: relative;
|
||
z-index: 1;
|
||
flex-shrink: 0;
|
||
border: none;
|
||
height: 28px;
|
||
padding: 0 10px;
|
||
border-radius: 14px;
|
||
background: rgba(15, 23, 42, 0.05);
|
||
color: #86909c;
|
||
font-size: 12px;
|
||
font-weight: 600;
|
||
cursor: pointer;
|
||
}
|
||
|
||
.h5-assistant-shell {
|
||
position: relative;
|
||
flex: 1;
|
||
min-height: 0;
|
||
border-radius: 16px;
|
||
overflow: hidden;
|
||
background: #ffffff;
|
||
border: none;
|
||
box-shadow:
|
||
inset 0 2px 8px rgba(15, 23, 42, 0.07),
|
||
inset 0 1px 1px rgba(15, 23, 42, 0.04);
|
||
display: flex;
|
||
flex-direction: column;
|
||
|
||
:deep(.ai-advisor-root),
|
||
:deep(.ai-advisor-shell),
|
||
:deep(.ai-advisor-app),
|
||
:deep(.ai-advisor-layout) {
|
||
position: relative;
|
||
height: 100%;
|
||
min-height: 0;
|
||
}
|
||
|
||
/* H5:去掉 PC 返回,底栏已够导航 */
|
||
:deep(.ai-app-bar__back),
|
||
:deep(.ai-waybill-context__back) {
|
||
display: none !important;
|
||
}
|
||
|
||
:deep(.ai-advisor-shell--page .ai-advisor-layout) {
|
||
padding: 0;
|
||
max-width: none;
|
||
}
|
||
|
||
:deep(.ai-shell-bg) {
|
||
display: none;
|
||
}
|
||
|
||
:deep(.ai-advisor-app) {
|
||
border: none;
|
||
border-radius: 0;
|
||
box-shadow: none;
|
||
background: transparent;
|
||
backdrop-filter: none;
|
||
-webkit-backdrop-filter: none;
|
||
padding: 8px 10px 10px;
|
||
}
|
||
|
||
:deep(.ai-history-sidebar) {
|
||
position: absolute;
|
||
top: 0;
|
||
left: 0;
|
||
bottom: 0;
|
||
z-index: 20;
|
||
width: min(280px, 86%);
|
||
border-radius: 0 18px 18px 0;
|
||
}
|
||
|
||
/* 透明可点区域:点侧栏外关闭,但不加灰色遮罩 */
|
||
:deep(.ai-advisor-shell.ai-history-open .ai-history-backdrop) {
|
||
display: block !important;
|
||
position: absolute !important;
|
||
inset: 0 !important;
|
||
z-index: 19 !important;
|
||
border: none;
|
||
background: transparent !important;
|
||
cursor: pointer;
|
||
}
|
||
|
||
/* 运单上下文:移动端更紧凑 */
|
||
:deep(.ai-waybill-context) {
|
||
margin: 0 0 8px;
|
||
padding: 10px 12px;
|
||
border-radius: 12px;
|
||
border: none;
|
||
background: color-mix(in srgb, var(--app-primary-color) 10%, #fff);
|
||
color: #1d2129;
|
||
}
|
||
|
||
:deep(.ai-waybill-context__actions) {
|
||
gap: 6px;
|
||
}
|
||
|
||
:deep(.ai-waybill-context__link),
|
||
:deep(.ai-waybill-context__btn),
|
||
:deep(.ai-waybill-context__clear) {
|
||
height: 28px;
|
||
border-radius: 14px;
|
||
font-size: 12px;
|
||
}
|
||
|
||
:deep(.ai-waybill-context__clear) {
|
||
color: #86909c;
|
||
}
|
||
|
||
:deep(.ai-waybill-context svg) {
|
||
color: var(--app-primary-color);
|
||
}
|
||
|
||
/* 欢迎区 + 快捷入口 */
|
||
:deep(.ai-welcome__hero) {
|
||
padding: 8px 2px 12px;
|
||
gap: 10px;
|
||
}
|
||
|
||
:deep(.ai-welcome__avatar.nana-fab-wrap) {
|
||
width: 48px;
|
||
height: 48px;
|
||
}
|
||
|
||
:deep(.ai-welcome__hero h2) {
|
||
font-size: 1.08rem;
|
||
}
|
||
|
||
:deep(.ai-welcome__hero p) {
|
||
font-size: 0.82rem;
|
||
color: var(--color-text-3, #86909c);
|
||
}
|
||
|
||
:deep(.ai-mcp-grid) {
|
||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||
gap: 8px;
|
||
}
|
||
|
||
:deep(.ai-mcp-grid--waybill) {
|
||
grid-template-columns: 1fr 1fr;
|
||
}
|
||
|
||
:deep(.ai-mcp-card) {
|
||
background: transparent;
|
||
box-shadow: none;
|
||
min-height: 96px;
|
||
padding: 16px 12px;
|
||
border-radius: 12px;
|
||
border: 1px solid rgba(15, 23, 42, 0.08);
|
||
}
|
||
|
||
:deep(.ai-followup) {
|
||
gap: 6px;
|
||
padding: 0 0 6px;
|
||
}
|
||
|
||
:deep(.ai-followup-chip) {
|
||
border: none;
|
||
background: rgba(15, 23, 42, 0.04);
|
||
border-radius: 14px;
|
||
}
|
||
|
||
:deep(.ai-composer) {
|
||
border-radius: 16px;
|
||
}
|
||
|
||
:deep(.ai-composer-send) {
|
||
width: 32px;
|
||
height: 32px;
|
||
border: none;
|
||
border-radius: 999px;
|
||
background: #0d0d0d;
|
||
color: #fff;
|
||
box-shadow: none;
|
||
opacity: 1;
|
||
transform: none;
|
||
filter: none;
|
||
|
||
.ai-composer-send__mark,
|
||
svg {
|
||
display: block;
|
||
width: 18px;
|
||
height: 18px;
|
||
fill: none;
|
||
stroke: currentColor;
|
||
stroke-width: 2.25;
|
||
stroke-linecap: round;
|
||
stroke-linejoin: round;
|
||
}
|
||
|
||
&.is-empty,
|
||
&.is-empty:hover {
|
||
background: #ececec;
|
||
color: #9a9a9a;
|
||
cursor: default;
|
||
transform: none;
|
||
filter: none;
|
||
}
|
||
|
||
&:hover:not(:disabled):not(.is-empty) {
|
||
background: #2f2f2f;
|
||
transform: none;
|
||
filter: none;
|
||
}
|
||
|
||
&:focus-visible {
|
||
outline: 2px solid #0d0d0d;
|
||
outline-offset: 2px;
|
||
}
|
||
|
||
&:disabled:not(.is-empty) {
|
||
background: #0d0d0d;
|
||
color: #fff;
|
||
opacity: 0.45;
|
||
cursor: not-allowed;
|
||
transform: none;
|
||
filter: none;
|
||
}
|
||
|
||
&:not(:disabled):not(.is-empty):active {
|
||
background: #2f2f2f;
|
||
filter: none;
|
||
}
|
||
}
|
||
|
||
:deep(.ai-composer-footer) {
|
||
flex-direction: row;
|
||
align-items: center;
|
||
justify-content: space-between;
|
||
gap: 8px;
|
||
}
|
||
|
||
:deep(.ai-composer-hint) {
|
||
font-size: 11px;
|
||
color: #86909c;
|
||
opacity: 0.72;
|
||
}
|
||
|
||
:deep(.ai-msg-row--assistant .ai-msg-bubble) {
|
||
color: #1d2129;
|
||
}
|
||
|
||
:deep(.ai-composer-input) {
|
||
color: #1d2129;
|
||
}
|
||
|
||
:deep(.ai-msg-bubble) {
|
||
border-radius: 14px;
|
||
}
|
||
}
|
||
</style>
|