CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-dcloudio--uni-mp-baidu

Baidu Mini Program runtime and compiler support for the uni-app cross-platform development framework

Pending

Quality

Pending

Does it follow best practices?

Impact

Pending

No eval scenarios have been run

SecuritybySnyk

Pending

The risk profile of this skill

Overview
Eval results
Files

navigation-apis.mddocs/

Navigation APIs

Page navigation and routing functionality for navigating between pages and mini-programs with platform-specific adaptations for Baidu Smart Programs.

Capabilities

Navigate To

Navigate to a new page within the current application.

/**
 * Navigate to a new page within the application
 * @param options - Navigation options
 * @returns Promise that resolves when navigation completes
 */
function navigateTo(options: NavigateToOptions): Promise<any>;

interface NavigateToOptions {
  url: string;
  success?(result: any): void;
  fail?(error: any): void;
  complete?(): void;
  events?: any; // EventChannel for page communication
}

Usage Examples:

import uni from "@dcloudio/uni-mp-baidu";

// Basic navigation
uni.navigateTo({
  url: '/pages/detail/detail?id=123'
});

// Navigation with success callback
uni.navigateTo({
  url: '/pages/user/profile',
  success: (res) => {
    console.log('Navigation successful', res);
  },
  fail: (err) => {
    console.error('Navigation failed', err);
  }
});

// Navigation with EventChannel (for page communication)
uni.navigateTo({
  url: '/pages/detail/detail',
  events: {
    // Listen to events sent from the target page
    acceptDataFromOpenedPage: function(data) {
      console.log('Received data:', data);
    }
  }
});

Redirect To

Redirect to a page, closing the current page.

/**
 * Redirect to a page, closing the current page
 * @param options - Redirect options
 * @returns Promise that resolves when redirect completes
 */
function redirectTo(options: RedirectToOptions): Promise<any>;

interface RedirectToOptions {
  url: string;
  success?(result: any): void;
  fail?(error: any): void;
  complete?(): void;
}

Usage Examples:

// Basic redirect
uni.redirectTo({
  url: '/pages/login/login'
});

// Redirect with callback
uni.redirectTo({
  url: '/pages/home/home',
  success: () => {
    console.log('Redirect successful');
  }
});

Navigate Back

Navigate back in the page stack.

/**
 * Navigate back in the page stack
 * @param options - Navigation back options
 * @returns Promise that resolves when navigation completes
 */
function navigateBack(options?: NavigateBackOptions): Promise<any>;

interface NavigateBackOptions {
  delta?: number; // Number of pages to go back, default is 1
  success?(result: any): void;
  fail?(error: any): void;
  complete?(): void;
}

Usage Examples:

// Go back one page (default)
uni.navigateBack();

// Go back multiple pages
uni.navigateBack({
  delta: 2
});

// Go back with callback
uni.navigateBack({
  delta: 1,
  success: () => {
    console.log('Successfully navigated back');
  }
});

Navigate To Mini Program

Navigate to another Baidu Smart Mini Program.

/**
 * Navigate to another Baidu Smart Mini Program
 * @param options - Navigation options
 * @returns Promise that resolves when navigation completes
 */
function navigateToMiniProgram(options: NavigateToMiniProgramOptions): Promise<any>;

interface NavigateToMiniProgramOptions {
  appId: string; // Target mini program app ID
  path?: string; // Path within the target mini program
  extraData?: any; // Data to pass to the target mini program
  envVersion?: 'develop' | 'trial' | 'release'; // Version of target mini program
  success?(result: any): void;
  fail?(error: any): void;
  complete?(): void;
}

Usage Examples:

// Navigate to another mini program
uni.navigateToMiniProgram({
  appId: 'target-app-id',
  path: '/pages/index/index',
  extraData: {
    from: 'current-app',
    data: { id: 123 }
  },
  envVersion: 'release',
  success: (res) => {
    console.log('Successfully navigated to mini program', res);
  }
});

Navigate Back From Mini Program

Return from another mini program to the current one.

/**
 * Return from another mini program to the current one
 * @param options - Navigation back options
 * @returns Promise that resolves when navigation completes
 */
function navigateBackMiniProgram(options?: NavigateBackMiniProgramOptions): Promise<any>;

interface NavigateBackMiniProgramOptions {
  extraData?: any; // Data to return to the calling mini program
  success?(result: any): void;
  fail?(error: any): void;
  complete?(): void;
}

Usage Examples:

// Return to calling mini program
uni.navigateBackMiniProgram({
  extraData: {
    result: 'success',
    data: { selected: 'item1' }
  }
});

Platform-Specific Notes

Baidu Smart Program Adaptations

  • navigateToMiniProgram is mapped to swan.navigateToSmartProgram
  • navigateBackMiniProgram is mapped to swan.navigateBackSmartProgram
  • All navigation methods include enhanced error handling and parameter validation
  • EventChannel support is provided for page-to-page communication in navigateTo

URL Format

All navigation URLs should follow the format: /pages/pageName/pageName?param=value

  • Must start with /
  • Parameters are passed as query string
  • Page paths are relative to the project root

Install with Tessl CLI

npx tessl i tessl/npm-dcloudio--uni-mp-baidu

docs

app-component-creation.md

automation.md

build-configuration.md

index.md

navigation-apis.md

network-apis.md

runtime-api.md

system-apis.md

vue-integration.md

tile.json