diff --git a/src/FuShiDemo/.eslintrc.js b/src/FuShiDemo/.eslintrc.js new file mode 100644 index 0000000..115cc02 --- /dev/null +++ b/src/FuShiDemo/.eslintrc.js @@ -0,0 +1,31 @@ +/* + * Eslint config file + * Documentation: https://eslint.org/docs/user-guide/configuring/ + * Install the Eslint extension before using this feature. + */ +module.exports = { + env: { + es6: true, + browser: true, + node: true, + }, + ecmaFeatures: { + modules: true, + }, + parserOptions: { + ecmaVersion: 2018, + sourceType: 'module', + }, + globals: { + wx: true, + App: true, + Page: true, + getCurrentPages: true, + getApp: true, + Component: true, + requirePlugin: true, + requireMiniProgram: true, + }, + // extends: 'eslint:recommended', + rules: {}, +} diff --git a/src/FuShiDemo/.gitignore b/src/FuShiDemo/.gitignore new file mode 100644 index 0000000..14ea590 --- /dev/null +++ b/src/FuShiDemo/.gitignore @@ -0,0 +1,14 @@ +# Windows +[Dd]esktop.ini +Thumbs.db +$RECYCLE.BIN/ + +# macOS +.DS_Store +.fseventsd +.Spotlight-V100 +.TemporaryItems +.Trashes + +# Node.js +node_modules/ diff --git a/src/FuShiDemo/app.js b/src/FuShiDemo/app.js new file mode 100644 index 0000000..2c70df4 --- /dev/null +++ b/src/FuShiDemo/app.js @@ -0,0 +1,10 @@ +import gulpError from './utils/gulpError'; +App({ + onShow() { + if (gulpError !== 'gulpErrorPlaceHolder') { + wx.redirectTo({ + url: `/pages/gulp-error/index?gulpError=${gulpError}`, + }); + } + }, +}); diff --git a/src/FuShiDemo/app.json b/src/FuShiDemo/app.json new file mode 100644 index 0000000..1f04b84 --- /dev/null +++ b/src/FuShiDemo/app.json @@ -0,0 +1,57 @@ +{ + "entryPagePath": "pages/record/record", + "pages": [ + "pages/my/my", + "pages/record/record", + "pages/login/login", + "pages/home/home", + "pages/useguide/useguide", + "pages/problem/problem", + "pages/articles/articles", + "pages/addPage/addarticles", + "pages/articledetail/articledetail" + ], + "usingComponents": { + "t-message": "tdesign-miniprogram/message/message", + "t-toast": "tdesign-miniprogram/toast/toast", + "t-icon": "tdesign-miniprogram/icon/icon", + "t-input": "tdesign-miniprogram/input/input", + "t-swiper": "tdesign-miniprogram/swiper/swiper", + "t-swiper-nav": "tdesign-miniprogram/swiper-nav/swiper-nav" + }, + "window": { + "backgroundTextStyle": "light", + "navigationStyle": "default", + "navigationBarBackgroundColor": "#f6f6f6", + "backgroundColor": "#f6f6f6", + "navigationBarTitleText": "智能识别", + "navigationBarTextStyle": "black" + }, + "tabBar": { + "color": "#CEC8E9", + "selectedColor": "#19DD51", + "borderStyle": "white", + "backgroundColor": "#F7FAFB", + "list": [ + { + "pagePath": "pages/record/record", + "text": "知识科普", + "iconPath": "assets/record.png", + "selectedIconPath": "assets/record_act.png" + }, + { + "pagePath": "pages/home/home", + "text": "拍照识别", + "iconPath": "assets/home.png", + "selectedIconPath": "assets/home_act.png" + }, + { + "pagePath": "pages/my/my", + "text": "ai问答", + "iconPath": "assets/mine.png", + "selectedIconPath": "assets/mine_act.png" + } + ] + }, + "sitemapLocation": "sitemap.json" +} \ No newline at end of file diff --git a/src/FuShiDemo/app.wxss b/src/FuShiDemo/app.wxss new file mode 100644 index 0000000..4269fc0 --- /dev/null +++ b/src/FuShiDemo/app.wxss @@ -0,0 +1,5 @@ +page { + background: #f6f6f6; + width: 100%; + height: 100%; +} diff --git a/src/FuShiDemo/assets/5.png b/src/FuShiDemo/assets/5.png new file mode 100644 index 0000000..9fc8f3f Binary files /dev/null and b/src/FuShiDemo/assets/5.png differ diff --git a/src/FuShiDemo/assets/6.png b/src/FuShiDemo/assets/6.png new file mode 100644 index 0000000..4cabced Binary files /dev/null and b/src/FuShiDemo/assets/6.png differ diff --git a/src/FuShiDemo/assets/8.png b/src/FuShiDemo/assets/8.png new file mode 100644 index 0000000..00a9dac Binary files /dev/null and b/src/FuShiDemo/assets/8.png differ diff --git a/src/FuShiDemo/assets/camera.jpg b/src/FuShiDemo/assets/camera.jpg new file mode 100644 index 0000000..990c21c Binary files /dev/null and b/src/FuShiDemo/assets/camera.jpg differ diff --git a/src/FuShiDemo/assets/chuyu.png b/src/FuShiDemo/assets/chuyu.png new file mode 100644 index 0000000..6f0c1ba Binary files /dev/null and b/src/FuShiDemo/assets/chuyu.png differ diff --git a/src/FuShiDemo/assets/home.png b/src/FuShiDemo/assets/home.png new file mode 100644 index 0000000..bfcc0ba Binary files /dev/null and b/src/FuShiDemo/assets/home.png differ diff --git a/src/FuShiDemo/assets/home_act.png b/src/FuShiDemo/assets/home_act.png new file mode 100644 index 0000000..c343c56 Binary files /dev/null and b/src/FuShiDemo/assets/home_act.png differ diff --git a/src/FuShiDemo/assets/kehuishou.png b/src/FuShiDemo/assets/kehuishou.png new file mode 100644 index 0000000..4fd8875 Binary files /dev/null and b/src/FuShiDemo/assets/kehuishou.png differ diff --git a/src/FuShiDemo/assets/mine.png b/src/FuShiDemo/assets/mine.png new file mode 100644 index 0000000..f5ab2fa Binary files /dev/null and b/src/FuShiDemo/assets/mine.png differ diff --git a/src/FuShiDemo/assets/mine_act.png b/src/FuShiDemo/assets/mine_act.png new file mode 100644 index 0000000..c456803 Binary files /dev/null and b/src/FuShiDemo/assets/mine_act.png differ diff --git a/src/FuShiDemo/assets/qita.png b/src/FuShiDemo/assets/qita.png new file mode 100644 index 0000000..a4513b7 Binary files /dev/null and b/src/FuShiDemo/assets/qita.png differ diff --git a/src/FuShiDemo/assets/record.png b/src/FuShiDemo/assets/record.png new file mode 100644 index 0000000..3e5104c Binary files /dev/null and b/src/FuShiDemo/assets/record.png differ diff --git a/src/FuShiDemo/assets/record_act.png b/src/FuShiDemo/assets/record_act.png new file mode 100644 index 0000000..ad4f136 Binary files /dev/null and b/src/FuShiDemo/assets/record_act.png differ diff --git a/src/FuShiDemo/assets/sw-1.png b/src/FuShiDemo/assets/sw-1.png new file mode 100644 index 0000000..de30683 Binary files /dev/null and b/src/FuShiDemo/assets/sw-1.png differ diff --git a/src/FuShiDemo/assets/sw-2.png b/src/FuShiDemo/assets/sw-2.png new file mode 100644 index 0000000..2e2f289 Binary files /dev/null and b/src/FuShiDemo/assets/sw-2.png differ diff --git a/src/FuShiDemo/assets/youhai.png b/src/FuShiDemo/assets/youhai.png new file mode 100644 index 0000000..384a0a6 Binary files /dev/null and b/src/FuShiDemo/assets/youhai.png differ diff --git a/src/FuShiDemo/config/config.js b/src/FuShiDemo/config/config.js new file mode 100644 index 0000000..d38bc1f --- /dev/null +++ b/src/FuShiDemo/config/config.js @@ -0,0 +1,3 @@ +module.exports = { + baseUrl:'http://192.168.251.13:8000', +} \ No newline at end of file diff --git a/src/FuShiDemo/miniprogram_npm/tdesign-miniprogram/action-sheet/README.en-US.md b/src/FuShiDemo/miniprogram_npm/tdesign-miniprogram/action-sheet/README.en-US.md new file mode 100644 index 0000000..0c84067 --- /dev/null +++ b/src/FuShiDemo/miniprogram_npm/tdesign-miniprogram/action-sheet/README.en-US.md @@ -0,0 +1,24 @@ +:: BASE_DOC :: + +## API +### ActionSheet Props + +name | type | default | description | required +-- | -- | -- | -- | -- +align | String | center | `0.29.0`。options:center/left | N +cancel-text | String | - | \- | N +count | Number | 8 | \- | N +description | String | - | `0.29.0` | N +items | Array | - | required。Typescript:`Array` `interface ActionSheetItem {label: string; color?: string; disabled?: boolean }`。[see more ts definition](https://github.com/Tencent/tdesign-miniprogram/tree/develop/src/action-sheet/type.ts) | Y +show-cancel | Boolean | true | \- | N +theme | String | list | options:list/grid | N +visible | Boolean | false | required | Y +default-visible | Boolean | undefined | required。uncontrolled property | Y + +### ActionSheet Events + +name | params | description +-- | -- | -- +cancel | \- | \- +close | `(trigger: TriggerSource)` | [see more ts definition](https://github.com/Tencent/tdesign-miniprogram/tree/develop/src/action-sheet/type.ts)。
`type TriggerSource = 'overlay' \| 'command' \| 'select' `
+selected | `(selected: ActionSheetItem \| string, index: number)` | \- diff --git a/src/FuShiDemo/miniprogram_npm/tdesign-miniprogram/action-sheet/README.md b/src/FuShiDemo/miniprogram_npm/tdesign-miniprogram/action-sheet/README.md new file mode 100644 index 0000000..1ba2bab --- /dev/null +++ b/src/FuShiDemo/miniprogram_npm/tdesign-miniprogram/action-sheet/README.md @@ -0,0 +1,107 @@ +--- +title: ActionSheet 动作面板 +description: 由用户操作后触发的一种特定的模态弹出框 ,呈现一组与当前情境相关的两个或多个选项。 +spline: data +isComponent: true +--- + + + +
+ + + + 该组件于 0.9.0 版本上线,请留意版本。 +
+ +## 引入 + +全局引入,在 miniprogram 根目录下的`app.json`中配置,局部引入,在需要引入的页面或组件的`index.json`中配置。 + +```json +"usingComponents": { + "t-action-sheet": "tdesign-miniprogram/action-sheet/action-sheet", +} +``` + +## 代码演示 + +### 组件类型 + +列表型动作面板 + +{{ list }} + +宫格型动作面板 + +{{ grid }} + +### 组件状态 + +宫格型动作面板 + +{{ status }} + +### 组件样式 + +列表型对齐方式 + +{{ align }} + +### 支持指令调用 + +```javascript +import ActionSheet, { ActionSheetTheme } from 'tdesign-miniprogram/action-sheet/index'; + +// 指令调用不同于组件引用不需要传入visible +const basicListOption: ActionSheetShowOption = { + theme: ActionSheetTheme.List, + selector: '#t-action-sheet', + items: [ + { + label: '默认选项', + }, + { + label: '失效选项', + disabled: true, + }, + { + label: '警告选项', + color: '#e34d59', + }, + ], +}; + +const handler = ActionSheet.show(basicListOption); +``` + +指令调用的关闭如下 + +```javascript +handler.close(); +``` + + +## API +### ActionSheet Props + +名称 | 类型 | 默认值 | 说明 | 必传 +-- | -- | -- | -- | -- +align | String | center | `0.29.0`。水平对齐方式。可选项:center/left | N +cancel-text | String | - | 设置取消按钮的文本 | N +count | Number | 8 | 设置每页展示菜单的数量,仅当 type=grid 时有效 | N +description | String | - | `0.29.0`。动作面板描述文字 | N +items | Array | - | 必需。菜单项。TS 类型:`Array` `interface ActionSheetItem {label: string; color?: string; disabled?: boolean }`。[详细类型定义](https://github.com/Tencent/tdesign-miniprogram/tree/develop/src/action-sheet/type.ts) | Y +show-cancel | Boolean | true | 是否显示取消按钮 | N +theme | String | list | 展示类型,列表和表格形式展示。可选项:list/grid | N +visible | Boolean | false | 必需。显示与隐藏 | Y +default-visible | Boolean | undefined | 必需。显示与隐藏。非受控属性 | Y +external-classes | Array | - | 组件类名,用于设置组件外层元素类名。`['t-class', 't-class-content', 't-class-cancel']` | N + +### ActionSheet Events + +名称 | 参数 | 描述 +-- | -- | -- +cancel | \- | 点击取消按钮时触发 +close | `(trigger: TriggerSource)` | 关闭时触发。[详细类型定义](https://github.com/Tencent/tdesign-miniprogram/tree/develop/src/action-sheet/type.ts)。
`type TriggerSource = 'overlay' \| 'command' \| 'select' `
+selected | `(selected: ActionSheetItem \| string, index: number)` | 选择菜单项时触发 diff --git a/src/FuShiDemo/miniprogram_npm/tdesign-miniprogram/action-sheet/action-sheet.d.ts b/src/FuShiDemo/miniprogram_npm/tdesign-miniprogram/action-sheet/action-sheet.d.ts new file mode 100644 index 0000000..dd4d4bf --- /dev/null +++ b/src/FuShiDemo/miniprogram_npm/tdesign-miniprogram/action-sheet/action-sheet.d.ts @@ -0,0 +1,66 @@ +import { SuperComponent } from '../common/src/index'; +export default class ActionSheet extends SuperComponent { + static show: (options: import("./show").ActionSheetShowOption) => WechatMiniprogram.Component.TrivialInstance; + externalClasses: string[]; + properties: { + align?: { + type: StringConstructor; + value?: "center" | "left"; + }; + cancelText?: { + type: StringConstructor; + value?: string; + }; + count?: { + type: NumberConstructor; + value?: number; + }; + description?: { + type: StringConstructor; + value?: string; + }; + items: { + type: ArrayConstructor; + value?: (string | import("./type").ActionSheetItem)[]; + }; + showCancel?: { + type: BooleanConstructor; + value?: boolean; + }; + theme?: { + type: StringConstructor; + value?: "list" | "grid"; + }; + visible: { + type: BooleanConstructor; + value?: boolean; + }; + defaultVisible: { + type: BooleanConstructor; + value?: boolean; + }; + }; + data: { + prefix: string; + classPrefix: string; + gridThemeItems: any[]; + currentSwiperIndex: number; + }; + controlledProps: { + key: string; + event: string; + }[]; + ready(): void; + methods: { + onSwiperChange(e: WechatMiniprogram.TouchEvent): void; + splitGridThemeActions(): void; + show(options: any): void; + memoInitialData(): void; + close(): void; + onPopupVisibleChange({ detail }: { + detail: any; + }): void; + onSelect(event: WechatMiniprogram.TouchEvent): void; + onCancel(): void; + }; +} diff --git a/src/FuShiDemo/miniprogram_npm/tdesign-miniprogram/action-sheet/action-sheet.js b/src/FuShiDemo/miniprogram_npm/tdesign-miniprogram/action-sheet/action-sheet.js new file mode 100644 index 0000000..aa8ba4d --- /dev/null +++ b/src/FuShiDemo/miniprogram_npm/tdesign-miniprogram/action-sheet/action-sheet.js @@ -0,0 +1,94 @@ +var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; + return c > 3 && r && Object.defineProperty(target, key, r), r; +}; +import { chunk } from '../common/utils'; +import { SuperComponent, wxComponent } from '../common/src/index'; +import config from '../common/config'; +import { ActionSheetTheme, show } from './show'; +import props from './props'; +const { prefix } = config; +const name = `${prefix}-action-sheet`; +let ActionSheet = class ActionSheet extends SuperComponent { + constructor() { + super(...arguments); + this.externalClasses = [`${prefix}-class`, `${prefix}-class-content`, `${prefix}-class-cancel`]; + this.properties = Object.assign({}, props); + this.data = { + prefix, + classPrefix: name, + gridThemeItems: [], + currentSwiperIndex: 0, + }; + this.controlledProps = [ + { + key: 'visible', + event: 'visible-change', + }, + ]; + this.methods = { + onSwiperChange(e) { + const { detail: { current }, } = e; + this.setData({ + currentSwiperIndex: current, + }); + }, + splitGridThemeActions() { + if (this.data.theme !== ActionSheetTheme.Grid) + return; + this.setData({ + gridThemeItems: chunk(this.data.items, this.data.count), + }); + }, + show(options) { + this.setData(Object.assign(Object.assign(Object.assign({}, this.initialData), options), { visible: true })); + this.splitGridThemeActions(); + this.autoClose = true; + this._trigger('visible-change', { visible: true }); + }, + memoInitialData() { + this.initialData = Object.assign(Object.assign({}, this.properties), this.data); + }, + close() { + this.triggerEvent('close', { trigger: 'command' }); + this._trigger('visible-change', { visible: false }); + }, + onPopupVisibleChange({ detail }) { + if (!detail.visible) { + this.triggerEvent('close', { trigger: 'overlay' }); + this._trigger('visible-change', { visible: false }); + } + if (this.autoClose) { + this.setData({ visible: false }); + this.autoClose = false; + } + }, + onSelect(event) { + const { currentSwiperIndex, items, gridThemeItems, count, theme } = this.data; + const { index } = event.currentTarget.dataset; + const isSwiperMode = theme === ActionSheetTheme.Grid; + const item = isSwiperMode ? gridThemeItems[currentSwiperIndex][index] : items[index]; + const realIndex = isSwiperMode ? index + currentSwiperIndex * count : index; + if (item) { + this.triggerEvent('selected', { selected: item, index: realIndex }); + this.trigger('close', { trigger: 'select' }); + this._trigger('visible-change', { visible: false }); + } + }, + onCancel() { + this.triggerEvent('cancel'); + }, + }; + } + ready() { + this.memoInitialData(); + this.splitGridThemeActions(); + } +}; +ActionSheet.show = show; +ActionSheet = __decorate([ + wxComponent() +], ActionSheet); +export default ActionSheet; diff --git a/src/FuShiDemo/miniprogram_npm/tdesign-miniprogram/action-sheet/action-sheet.json b/src/FuShiDemo/miniprogram_npm/tdesign-miniprogram/action-sheet/action-sheet.json new file mode 100644 index 0000000..c1eb33e --- /dev/null +++ b/src/FuShiDemo/miniprogram_npm/tdesign-miniprogram/action-sheet/action-sheet.json @@ -0,0 +1,10 @@ +{ + "component": true, + "usingComponents": { + "t-icon": "../icon/icon", + "t-popup": "../popup/popup", + "t-grid": "../grid/grid", + "t-grid-item": "../grid-item/grid-item", + "t-swiper-nav": "../swiper-nav/swiper-nav" + } +} diff --git a/src/FuShiDemo/miniprogram_npm/tdesign-miniprogram/action-sheet/action-sheet.wxml b/src/FuShiDemo/miniprogram_npm/tdesign-miniprogram/action-sheet/action-sheet.wxml new file mode 100644 index 0000000..bf8d757 --- /dev/null +++ b/src/FuShiDemo/miniprogram_npm/tdesign-miniprogram/action-sheet/action-sheet.wxml @@ -0,0 +1,41 @@ + + + + + + + + + {{description}} + +