Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: Tencent/omi
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v7.3.10
Choose a base ref
...
head repository: Tencent/omi
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: cab6846b6bdbc7bd8b64a0e725e9901eb0b4999a
Choose a head ref
  • 3 commits
  • 5 files changed
  • 2 contributors

Commits on Jan 1, 2024

  1. docs: readme

    dntzhang committed Jan 1, 2024

    Verified

    This commit was signed with the committer’s verified signature.
    aurelius0523 Tan Kim Loong
    Copy the full SHA
    4f052d1 View commit details
  2. Verified

    This commit was signed with the committer’s verified signature.
    aurelius0523 Tan Kim Loong
    Copy the full SHA
    a743ef9 View commit details

Commits on Jan 2, 2024

  1. docs:

    dntzhang committed Jan 2, 2024

    Verified

    This commit was signed with the committer’s verified signature.
    aurelius0523 Tan Kim Loong
    Copy the full SHA
    cab6846 View commit details
Showing with 36 additions and 7 deletions.
  1. +14 −3 README.CN.md
  2. +14 −2 README.md
  3. +1 −1 packages/omi-router/package.json
  4. +6 −0 packages/omi-router/src/router-view.tsx
  5. +1 −1 packages/omi/README.md
17 changes: 14 additions & 3 deletions README.CN.md
Original file line number Diff line number Diff line change
@@ -24,7 +24,7 @@ function sub() {
}

@tag('counter-demo')
class CounterDemo extends Component {
export class CounterDemo extends Component {
static css = 'span { color: red; }'

render() {
@@ -37,10 +37,21 @@ class CounterDemo extends Component {
)
}
}
```

使用该组件:

```tsx
import { h } from 'omi'
import './counter-demo'

render(<counter-demo />, document.body)
```

// 或者
import { CounterDemo, Other } from './counter-demo'
// 当需要导入其他东西的时候,防止被 tree shaking
render(<CounterDemo.tagName />, document.body)
```

## 安装

@@ -75,7 +86,7 @@ $ npm run build # release
- [`omi-cli`](https://github.com/omijs/cli) - 快速创建 Omi + Vite + TS/JS 项目。
- 入门套件 (未发布到 npm)
- [`omi-elements`](https://github.com/Tencent/omi/tree/master/packages/omi-elements) - 官方推出 Tailwind Omi 套件。
- [`omi-starter-spa`](https://github.com/Tencent/omi/tree/master/packages/omi-starter-spa) - 快速创建单页应用(SPA),内置了 Omi + OmiRouter + Tailwindcss + TypeScript + Vite。
- [`omi-starter-spa`](https://github.com/Tencent/omi/tree/master/packages/omi-starter-spa) - 快速创建单页应用(SPA),内置了 Omi + OmiRouter + Tailwindcss + TypeScript + Vite + Prettier
- [`omi-starter-ts`](https://github.com/Tencent/omi/tree/master/packages/omi-starter-ts) - 基于 Vite + Omi + TypeScript 的模板。
- [`omi-starter-tailwind`](https://github.com/Tencent/omi/tree/master/packages/omi-starter-tailwind) - 基于 Vite + Omi + TypeScript + Tailwindcss 的模板。
- [`omi-starter-js`](https://github.com/Tencent/omi/tree/master/packages/omi-starter-js) - 基于 Vite + Omi + JavaScript 的模板。
16 changes: 14 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -24,7 +24,7 @@ function sub() {
}

@tag('counter-demo')
class CounterDemo extends Component {
export class CounterDemo extends Component {
static css = 'span { color: red; }'

render() {
@@ -37,8 +37,20 @@ class CounterDemo extends Component {
)
}
}
```

Use this component:

```tsx
import { h } from 'omi'
import './counter-demo'

render(<counter-demo />, document.body)

// or
import { CounterDemo, Other } from './counter-demo'
// Prevent tree Shaking when importing other things
render(<CounterDemo.tagName />, document.body)
```

## Install
@@ -74,7 +86,7 @@ $ npm run build # release
- [`omi-cli`](https://github.com/omijs/cli) - To quickly create an Omi + Vite + TS/JS project.
- Starter kits (not published to npm)
- [`omi-elements`](https://github.com/Tencent/omi/tree/master/packages/omi-elements) - Tailwind Element Omi UI KIT.
- [`omi-starter-spa`](https://github.com/Tencent/omi/tree/master/packages/omi-starter-spa) - A starter repo for building single page app using Omi + OmiRouter + Tailwindcss + TypeScript + Vite.
- [`omi-starter-spa`](https://github.com/Tencent/omi/tree/master/packages/omi-starter-spa) - A starter repo for building single page app using Omi + OmiRouter + Tailwindcss + TypeScript + Vite + Prettier.
- [`omi-starter-ts`](https://github.com/Tencent/omi/tree/master/packages/omi-starter-ts) - A starter repo for building web app or reusable components using Omi in TypeScript base on Vite.
- [`omi-starter-tailwind`](https://github.com/Tencent/omi/tree/master/packages/omi-starter-tailwind) - A starter repo for building web app or reusable components using Omi + Tailwindcss + TypeScript + Vite.
- [`omi-starter-js`](https://github.com/Tencent/omi/tree/master/packages/omi-starter-js) - A starter repo for building web app or reusable components using Omi in JavaScript base on Vite.
2 changes: 1 addition & 1 deletion packages/omi-router/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "omi-router",
"version": "4.1.3",
"version": "4.1.4",
"description": "Router for Omi",
"main": "dist/index.es.js",
"exports": {
6 changes: 6 additions & 0 deletions packages/omi-router/src/router-view.tsx
Original file line number Diff line number Diff line change
@@ -14,6 +14,7 @@ export interface Route {
transition?: string;
keys?: Key[];
regex?: RegExp;
redirect?: string;
}

interface Props {
@@ -103,6 +104,11 @@ export class RouterView extends Component<Props> {
for (const route of this.routes) {
const match = route.regex?.exec(path)
if (match) {
if(route.redirect) {
const newPath = this.isHashMode ? `#${route.redirect}` : route.redirect;
window.location.href = window.location.origin + newPath;
return;
}
if (route.beforeEnter) {
const shouldProceed = route.beforeEnter({ path }, { path: window.location.pathname })
if (shouldProceed === false) {
2 changes: 1 addition & 1 deletion packages/omi/README.md
Original file line number Diff line number Diff line change
@@ -72,7 +72,7 @@ $ npm run build # release
- [`omi-cli`](https://github.com/omijs/cli) - To quickly create an Omi + Vite + TS/JS project.
- Starter kits (not published to npm)
- [`omi-elements`](https://github.com/Tencent/omi/tree/master/packages/omi-elements) - Tailwind Element Omi UI KIT.
- [`omi-starter-spa`](https://github.com/Tencent/omi/tree/master/packages/omi-starter-spa) - A starter repo for building single page app using Omi + OmiRouter + Tailwindcss + TypeScript + Vite.
- [`omi-starter-spa`](https://github.com/Tencent/omi/tree/master/packages/omi-starter-spa) - A starter repo for building single page app using Omi + OmiRouter + Tailwindcss + TypeScript + Vite + Prettier.
- [`omi-starter-ts`](https://github.com/Tencent/omi/tree/master/packages/omi-starter-ts) - A starter repo for building web app or reusable components using Omi in TypeScript base on Vite.
- [`omi-starter-tailwind`](https://github.com/Tencent/omi/tree/master/packages/omi-starter-tailwind) - A starter repo for building web app or reusable components using Omi + Tailwindcss + TypeScript + Vite.
- [`omi-starter-js`](https://github.com/Tencent/omi/tree/master/packages/omi-starter-js) - A starter repo for building web app or reusable components using Omi in JavaScript base on Vite.