Cool Unix Development Scaffold

repository·main·Indexed 43 days ago

https://github.com/cool-team-official/cool-unix

A cross-platform development scaffold built on uni-app x version 8.1.0. It features built-in UI components, TailwindCSS compatibility (including dark mode and important modifiers), and AI-assisted internationalization via the cool-i18n CLI. Includes specialized modules such as cool-canvas for high-definition graphics rendering, cool-open-web for unified URL handling, and cool-vibrate for cross-platform haptic feedback across iOS, Android, Web, and Mini-programs.

Tokens
6.3K
Snippets
33
Records
38
Agent score
54%

What's inside Cool Unix

  1. Overview of Cool Unix

    main
    Cool Unix is a high-efficiency project scaffold based on uni-app x for cross-platform application development. It is designed to provide a powerful technical foundation for developers by including built-in UI component libraries, Service request handling, TailwindCSS support, and AI-powered multi-language translation tools.
  2. How PassThrough works for component customization

    main

    PassThrough (pt) is an API that allows developers to access and manipulate the internal DOM structure of a component. By using the :pt prop, you can apply arbitrary attributes, styles (via className), and listeners directly to specific internal elements of a component (like icons, labels, or loading indicators). This bypasses the limitations of the component's primary public API and provides deep customization capabilities.

    Example of customizing a cl-button internal elements:

    <cl-button
    	:pt="{
        className: '!rounded-2xl',
        icon: {
          size: 50,
          className: 'mr-5',
        },
        label: {
          color: 'red',
          className: 'font-bold',
        },
        loading: {
          size: 50,
        },
      }"
    >
    	点击
    </cl-button>
  3. Install and initialize Cool Unix

    main

    To use Cool Unix as a standalone component library in your project, first install the CLI globally, then initialize your project root. The unix-init command automatically integrates the necessary configurations and dependency files into your project.

    npm install -g @cool-vue/unix-cli
    
    # Run this in your project root
    nunix-init
  4. Implement Multi-language Support with AI Translation

    main

    Cool Unix supports multi-language development without manual maintenance of translation tables. You can use the t function for simple translations or $t for translations with dynamic parameters. After configuring your project, you can use the CLI to trigger an AI-driven process that automatically retrieves and translates the entire content of your application.

    To initialize or run the translation process, use: npx cool-i18n create

    <text>{{ t('你好') }}</text>
    import { $t, t } from "@/.cool";
    import { useUi } from "@/uni_modules/cool-ui";
    
    const ui = useUi();
    
    ui.showToast({
    	message: t("操作成功")
    });
    
    ui.showToast({
    	message: $t("欢迎回来,{name}", { name: "神仙都没用" })
    });
    npx cool-i18n create
  5. Use TailwindCSS with Cool Unix

    main

    Cool Unix is deeply compatible with TailwindCSS. Unlike many UI libraries that only provide basic styles, Cool Unix supports advanced TailwindCSS operators such as dark: for dark mode and ! for important modifiers, allowing for highly flexible and extensible styling.

    <view class="bg-surface-100 dark:!bg-surface-900">
    	<text class="text-surface-700 dark:!text-white">Cool Unix</text>
    </view>
  6. Image Cropping Modes

    main

    When using image(), the mode property determines how the source image is mapped to the target width and height on the canvas:

    • scaleToFill: Stretches the image to fill the area (may distort aspect ratio).
    • aspectFit: Scales the image to fit entirely within the area (may leave empty space).
    • aspectFill: Scales the image to cover the entire area (may crop edges).
    • center: Centers the image without scaling (may crop edges).
    • top, bottom, left, right: Aligns the image to the specified edge and centers it on the opposite axis.
    • topLeft, topRight, bottomLeft, bottomRight: Aligns the image to a specific corner.
  7. Customize component internals using PassThrough (pt)

    main

    The PassThrough (or pt) API allows you to access and modify the internal DOM structure of a component. By passing a :pt object, you can apply arbitrary attributes, styles, or listeners directly to specific sub-elements (like icons, labels, or loading indicators) within a component, bypassing the limitations of the standard component props.

    <cl-button
    	:pt="{
        className: '!rounded-2xl',
        icon: {
          size: 50,
          className: 'mr-5',
        },
        label: {
          color: 'red',
          className: 'font-bold',
        },
        loading: {
          size: 50,
        },
      }"
    >
    	点击
    </cl-button>