Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion frontend/components/SidebarRail.vue
Original file line number Diff line number Diff line change
Expand Up @@ -793,7 +793,7 @@ const goMiniPrograms = async () => { await navigateTo('/mini-programs') }
const goFinder = async () => { await navigateTo('/finder') }
const goPayments = async () => { await navigateTo('/payments') }
const goWrapped = async () => { await navigateTo('/wrapped') }
const goGuide = async () => { await navigateTo('/') }
const goGuide = async () => { await navigateTo({ path: '/', query: { guide: '1' } }) }
const goSettings = () => { openSettingsDialog() }

const onWindowKeydown = (event) => {
Expand Down
3 changes: 3 additions & 0 deletions frontend/pages/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -142,11 +142,14 @@ import { isFirstUseAgreementAccepted } from '~/lib/first-use-agreement'

const { listChatAccounts } = useApi()
const router = useRouter()
const route = useRoute()
const exportDialogOpen = ref(false)

onMounted(async () => {
if (!process.client || typeof window === 'undefined') return
if (!isFirstUseAgreementAccepted()) return
// 用户主动打开引导页时,保留当前页面,不执行启动时的自动跳转。
if (route.query.guide === '1') return

const enabled = readLocalBoolSetting(DESKTOP_SETTING_DEFAULT_TO_CHAT_KEY, true)
if (!enabled) return
Expand Down
9 changes: 8 additions & 1 deletion frontend/tests/startup-navigation.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const script = parse(source).descriptor.scriptSetup.content.replace(/^import .*$
const settings = readFileSync(new URL('../lib/desktop-settings.js', import.meta.url), 'utf8')
.replace(/^export /gm, '')

const runStartup = async ({ stored = null, accounts = ['ready-account'], accepted = true, fails = false } = {}) => {
const runStartup = async ({ stored = null, accounts = ['ready-account'], accepted = true, fails = false, query = {} } = {}) => {
let mounted
let contextAvailable = true
const paths = []
Expand All @@ -25,6 +25,7 @@ const runStartup = async ({ stored = null, accounts = ['ready-account'], accepte
ref: value => ({ value }),
onMounted: callback => { mounted = callback },
useRouter: getRouter,
useRoute: () => ({ query }),
navigateTo: path => getRouter().replace(path),
isFirstUseAgreementAccepted: () => accepted,
console: { warn: (...args) => warnings.push(args) },
Expand Down Expand Up @@ -57,3 +58,9 @@ test('账号请求失败时留在首页并记录原因', async () => {
assert.deepEqual(result.paths, [])
assert.equal(result.warnings.length, 1)
})

test('有数据且默认跳转开启时,主动进入引导页仍停留在引导页', async () => {
const result = await runStartup({ query: { guide: '1' } })
assert.deepEqual(result.paths, [])
assert.equal(result.warnings.length, 0)
})
Loading