mirror of
https://gitee.com/niucloud-team/niucloud.git
synced 2025-12-26 07:10:16 +00:00
addon
This commit is contained in:
parent
8a600afd4f
commit
02c1436e28
36
niucloud/addon/hello_world/HelloWorld.php
Normal file
36
niucloud/addon/hello_world/HelloWorld.php
Normal file
@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace addon\hello_world;
|
||||
|
||||
/**
|
||||
* 插件安装之后单独的插件方法
|
||||
* Class HelloWorld
|
||||
* @package addon\hello_world
|
||||
*/
|
||||
class HelloWorld
|
||||
{
|
||||
/**
|
||||
* 插件安装执行
|
||||
*/
|
||||
public function install()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 插件卸载执行
|
||||
*/
|
||||
public function uninstall()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 插件升级执行
|
||||
*/
|
||||
public function upgrade()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,31 @@
|
||||
<template>
|
||||
<div class="edit-horz-blank">
|
||||
<h3 class="mb-[10px]">test信息设置</h3>
|
||||
<el-form label-width="80px" class="px-[10px]">
|
||||
<el-form-item :label="t('blankHeight')">
|
||||
<el-slider v-model="diyStore.editComponent.height" show-input size="small"
|
||||
class="ml-[10px] horz-blank-slider"/>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</div>
|
||||
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import {t} from '@/lang'
|
||||
import useDiyStore from '@/stores/modules/diy'
|
||||
|
||||
const diyStore = useDiyStore()
|
||||
|
||||
defineExpose({})
|
||||
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
.horz-blank-slider {
|
||||
.el-slider__input {
|
||||
width: 100px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
<style lang="scss" scoped></style>
|
||||
@ -0,0 +1,31 @@
|
||||
<template>
|
||||
<div class="edit-horz-blank">
|
||||
<h3 class="mb-[10px]">test文本设置</h3>
|
||||
<el-form label-width="80px" class="px-[10px]">
|
||||
<el-form-item :label="t('blankHeight')">
|
||||
<el-slider v-model="diyStore.editComponent.height" show-input size="small"
|
||||
class="ml-[10px] horz-blank-slider"/>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</div>
|
||||
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import {t} from '@/lang'
|
||||
import useDiyStore from '@/stores/modules/diy'
|
||||
|
||||
const diyStore = useDiyStore()
|
||||
|
||||
defineExpose({})
|
||||
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
.horz-blank-slider {
|
||||
.el-slider__input {
|
||||
width: 100px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
<style lang="scss" scoped></style>
|
||||
@ -0,0 +1,12 @@
|
||||
<template>
|
||||
<div class="main-container">
|
||||
<el-card class="box-card !border-none" shadow="never">
|
||||
测试页面
|
||||
</el-card>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped></style>
|
||||
@ -0,0 +1,12 @@
|
||||
<template>
|
||||
<div class="main-container">
|
||||
<el-card class="box-card !border-none" shadow="never">
|
||||
站点测试页面
|
||||
</el-card>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped></style>
|
||||
29
niucloud/addon/hello_world/app/adminapi/controller/Index.php
Normal file
29
niucloud/addon/hello_world/app/adminapi/controller/Index.php
Normal file
@ -0,0 +1,29 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | Niucloud-admin 企业快速开发的saas管理平台
|
||||
// +----------------------------------------------------------------------
|
||||
// | 官方网址:https://www.niucloud-admin.com
|
||||
// +----------------------------------------------------------------------
|
||||
// | niucloud团队 版权所有 开源版本可自由商用
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: Niucloud Team
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace addon\hello_world\app\adminapi\controller;
|
||||
|
||||
use app\adminapi\controller\BaseAdminController;
|
||||
use app\service\core\addon\CoreInstallService;
|
||||
|
||||
|
||||
class Index extends BaseAdminController
|
||||
{
|
||||
/**
|
||||
* 接口数据
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
return success("HELLO_WORLD_RETURN");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
19
niucloud/addon/hello_world/app/adminapi/route/route.php
Normal file
19
niucloud/addon/hello_world/app/adminapi/route/route.php
Normal file
@ -0,0 +1,19 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | Niucloud-admin 企业快速开发的saas管理平台
|
||||
// +----------------------------------------------------------------------
|
||||
// | 官方网址:https://www.niucloud-admin.com
|
||||
// +----------------------------------------------------------------------
|
||||
// | niucloud团队 版权所有 开源版本可自由商用
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: Niucloud Team
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
use think\facade\Route;
|
||||
|
||||
/**
|
||||
* 路由(注意最好group路由名称与插件名称一致,防止路由冲突)
|
||||
*/
|
||||
Route::group("hello_world", function () {
|
||||
Route::get('index', 'addon\hello_world\app\adminapi\controller\Index@index');
|
||||
});
|
||||
1
niucloud/addon/hello_world/app/api/route/route.php
Normal file
1
niucloud/addon/hello_world/app/api/route/route.php
Normal file
@ -0,0 +1 @@
|
||||
|
||||
32
niucloud/addon/hello_world/app/enum/diy/components.php
Normal file
32
niucloud/addon/hello_world/app/enum/diy/components.php
Normal file
@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
'BASICS' => [
|
||||
'title' => get_lang('enum_diy.component_type_basics'),
|
||||
'list' => [
|
||||
'TestInfo' => [
|
||||
'title' => '测试信息',
|
||||
'icon' => 'iconfont-iconhuiyuanzhongxin',
|
||||
'path' => 'edit-hello-info',
|
||||
'support_page' => [],
|
||||
'max_count' => 0,
|
||||
'sort' => 10007,
|
||||
'value' => [
|
||||
'height' => 20
|
||||
],
|
||||
],
|
||||
'TestText' => [
|
||||
'title' => '测试文本',
|
||||
'icon' => 'iconfont-iconhuiyuanzhongxin',
|
||||
'path' => 'edit-hello-text',
|
||||
'support_page' => [],
|
||||
'max_count' => 0,
|
||||
'sort' => 10007,
|
||||
'value' => [
|
||||
'height' => 20
|
||||
],
|
||||
],
|
||||
],
|
||||
],
|
||||
|
||||
];
|
||||
8
niucloud/addon/hello_world/app/enum/diy/links.php
Normal file
8
niucloud/addon/hello_world/app/enum/diy/links.php
Normal file
@ -0,0 +1,8 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
[
|
||||
'name' => 'HELLO_WORLD_INDEX',
|
||||
'title' => get_lang('enum_hello_world.links_hello_world_index'),
|
||||
],
|
||||
];
|
||||
4
niucloud/addon/hello_world/app/enum/diy/pages.php
Normal file
4
niucloud/addon/hello_world/app/enum/diy/pages.php
Normal file
@ -0,0 +1,4 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
];
|
||||
18
niucloud/addon/hello_world/app/enum/menu/admin.php
Normal file
18
niucloud/addon/hello_world/app/enum/menu/admin.php
Normal file
@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
[
|
||||
'menu_name' => '插件菜单',
|
||||
'menu_key' => 'niucloud_hello',
|
||||
'menu_type' => 1,
|
||||
'icon' => 'iconfont-iconyingyongshichang',
|
||||
'api_url' => '',
|
||||
'router_path' => 'hello_world',
|
||||
'view_path' => 'hello_world/index',
|
||||
'methods' => '',
|
||||
'sort' => 90,
|
||||
'status' => 1,
|
||||
'is_show' => 1,
|
||||
'en_menu_name' => '',
|
||||
],
|
||||
];
|
||||
18
niucloud/addon/hello_world/app/enum/menu/site.php
Normal file
18
niucloud/addon/hello_world/app/enum/menu/site.php
Normal file
@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
[
|
||||
'menu_name' => '插件站点菜单',
|
||||
'menu_key' => 'niucloud_site_hello',
|
||||
'menu_type' => 1,
|
||||
'icon' => 'iconfont-iconyingyongshichang',
|
||||
'api_url' => '',
|
||||
'router_path' => 'hello_world',
|
||||
'view_path' => 'hello_world/site',
|
||||
'methods' => '',
|
||||
'sort' => 90,
|
||||
'status' => 1,
|
||||
'is_show' => 1,
|
||||
'en_menu_name' => '',
|
||||
],
|
||||
];
|
||||
13
niucloud/addon/hello_world/app/enum/notice/notice.php
Normal file
13
niucloud/addon/hello_world/app/enum/notice/notice.php
Normal file
@ -0,0 +1,13 @@
|
||||
<?php
|
||||
return [
|
||||
'hello_world_test' => [
|
||||
'key' => 'hello_world_test',
|
||||
'app_type' => 'site',
|
||||
'name' => 'hello world消息',
|
||||
'title' => 'hello world演示插件消息',
|
||||
'variable' =>[
|
||||
'name' => '消息内容'
|
||||
],
|
||||
],
|
||||
|
||||
];
|
||||
7
niucloud/addon/hello_world/app/enum/notice/sms.php
Normal file
7
niucloud/addon/hello_world/app/enum/notice/sms.php
Normal file
@ -0,0 +1,7 @@
|
||||
<?php
|
||||
return [
|
||||
'hello_world_test' => [
|
||||
'content' => '检测发送信息:{name}',
|
||||
]
|
||||
|
||||
];
|
||||
9
niucloud/addon/hello_world/app/enum/notice/weapp.php
Normal file
9
niucloud/addon/hello_world/app/enum/notice/weapp.php
Normal file
@ -0,0 +1,9 @@
|
||||
<?php
|
||||
return [
|
||||
'recharge_success' => [
|
||||
'temp_key' => '111',
|
||||
'content' => [
|
||||
['消息内容', '{name}', 'keyword1'],
|
||||
],
|
||||
]
|
||||
];
|
||||
11
niucloud/addon/hello_world/app/enum/notice/wechat.php
Normal file
11
niucloud/addon/hello_world/app/enum/notice/wechat.php
Normal file
@ -0,0 +1,11 @@
|
||||
<?php
|
||||
return [
|
||||
'recharge_success' => [
|
||||
'temp_key' => 'OPENTM111',
|
||||
'first' => '',
|
||||
'content' => [
|
||||
['消息内容', '{name}', 'keyword1'],
|
||||
],
|
||||
'remark' => ''
|
||||
]
|
||||
];
|
||||
16
niucloud/addon/hello_world/app/event.php
Normal file
16
niucloud/addon/hello_world/app/event.php
Normal file
@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
//文件执行序列号
|
||||
'bind' => [
|
||||
],
|
||||
|
||||
'listen' => [
|
||||
|
||||
//应用管理
|
||||
'appManage' => ['addon\hello_world\app\listener\AppManageListener'],
|
||||
],
|
||||
|
||||
'subscribe' => [
|
||||
],
|
||||
];
|
||||
17
niucloud/addon/hello_world/app/lang/zh-cn/api.php
Normal file
17
niucloud/addon/hello_world/app/lang/zh-cn/api.php
Normal file
@ -0,0 +1,17 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | Niucloud-admin 企业快速开发的saas管理平台
|
||||
// +----------------------------------------------------------------------
|
||||
// | 官方网址:https://www.niucloud-admin.com
|
||||
// +----------------------------------------------------------------------
|
||||
// | niucloud团队 版权所有 开源版本可自由商用
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: Niucloud Team
|
||||
// +----------------------------------------------------------------------
|
||||
/**
|
||||
* 插件api接口语言
|
||||
*/
|
||||
return [
|
||||
//系统常用
|
||||
'HELLO_WORLD_RETURN' => 'hello world演示数据',
|
||||
];
|
||||
20
niucloud/addon/hello_world/app/lang/zh-cn/enum.php
Normal file
20
niucloud/addon/hello_world/app/lang/zh-cn/enum.php
Normal file
@ -0,0 +1,20 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | Niucloud-admin 企业快速开发的saas管理平台
|
||||
// +----------------------------------------------------------------------
|
||||
// | 官方网址:https://www.niucloud-admin.com
|
||||
// +----------------------------------------------------------------------
|
||||
// | niucloud团队 版权所有 开源版本可自由商用
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: Niucloud Team
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* 插件枚举语言
|
||||
*/
|
||||
return [
|
||||
'enum_hello_world' => [
|
||||
//菜单类型
|
||||
'links_hello_world_index' => 'hello world 插件',
|
||||
],
|
||||
];
|
||||
18
niucloud/addon/hello_world/app/lang/zh-cn/validate.php
Normal file
18
niucloud/addon/hello_world/app/lang/zh-cn/validate.php
Normal file
@ -0,0 +1,18 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | Niucloud-admin 企业快速开发的saas管理平台
|
||||
// +----------------------------------------------------------------------
|
||||
// | 官方网址:https://www.niucloud-admin.com
|
||||
// +----------------------------------------------------------------------
|
||||
// | niucloud团队 版权所有 开源版本可自由商用
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: Niucloud Team
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* 插件验证多语言
|
||||
*/
|
||||
return [
|
||||
'file_sort' => 100,
|
||||
|
||||
];
|
||||
@ -0,0 +1,48 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | Niucloud-admin 企业快速开发的saas管理平台
|
||||
// +----------------------------------------------------------------------
|
||||
// | 官方网址:https://www.niucloud-admin.com
|
||||
// +----------------------------------------------------------------------
|
||||
// | niucloud团队 版权所有 开源版本可自由商用
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: Niucloud Team
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
|
||||
namespace addon\hello_world\app\listener;
|
||||
|
||||
/**
|
||||
* 应用管理
|
||||
* Class AppManage
|
||||
* @package app\listener\hello_world
|
||||
*/
|
||||
class AppManageListener
|
||||
{
|
||||
/**
|
||||
* 应用管理
|
||||
* @param $data
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$data = [
|
||||
"category" => [
|
||||
//插件如果要单独分类展示,需要专门定义
|
||||
[
|
||||
"key" => "hello_world_category",
|
||||
"name" => "第三方应用",
|
||||
],
|
||||
],
|
||||
[
|
||||
"addon" => "hello_world",
|
||||
"title" => "hello world",
|
||||
"category" => "hello_world_category", //设置插件对应展示分类,默认basic
|
||||
"desc" => "hello world 应用展示",
|
||||
"icon" => addon_resource("hello_world", "icon.png"), //图标
|
||||
"cover" => "", //封面
|
||||
"url" => "/hello_world"
|
||||
],
|
||||
];
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
5
niucloud/addon/hello_world/config/admin-package.json
Normal file
5
niucloud/addon/hello_world/config/admin-package.json
Normal file
@ -0,0 +1,5 @@
|
||||
{
|
||||
"dependencies": {
|
||||
"@vueuse/core": "^9.12.0"
|
||||
}
|
||||
}
|
||||
6
niucloud/addon/hello_world/config/composer.json
Normal file
6
niucloud/addon/hello_world/config/composer.json
Normal file
@ -0,0 +1,6 @@
|
||||
{
|
||||
"require": {
|
||||
"firebase/php-jwt": "^5.0"
|
||||
|
||||
}
|
||||
}
|
||||
5
niucloud/addon/hello_world/config/uni-app-package.json
Normal file
5
niucloud/addon/hello_world/config/uni-app-package.json
Normal file
@ -0,0 +1,5 @@
|
||||
{
|
||||
"dependencies": {
|
||||
"weixin-js-sdk": "^1.6.0"
|
||||
}
|
||||
}
|
||||
14
niucloud/addon/hello_world/config/uni-app-pages.json
Normal file
14
niucloud/addon/hello_world/config/uni-app-pages.json
Normal file
@ -0,0 +1,14 @@
|
||||
{
|
||||
"pages": [ // pages数组中第一项表示应用启动页,参考:https://uniapp.dcloud.io/collocation/pages
|
||||
{
|
||||
"path": "pages/hello_world/index",
|
||||
"style": {
|
||||
// #ifdef H5
|
||||
"navigationStyle": "custom",
|
||||
// #endif
|
||||
"navigationBarTitleText": "%pages.index.index%"
|
||||
}
|
||||
}
|
||||
]
|
||||
|
||||
}
|
||||
5
niucloud/addon/hello_world/config/web-package.json
Normal file
5
niucloud/addon/hello_world/config/web-package.json
Normal file
@ -0,0 +1,5 @@
|
||||
{
|
||||
"dependencies": {
|
||||
"sass": "^1.60.0"
|
||||
}
|
||||
}
|
||||
10
niucloud/addon/hello_world/info.json
Normal file
10
niucloud/addon/hello_world/info.json
Normal file
@ -0,0 +1,10 @@
|
||||
{
|
||||
"title": "hello world",
|
||||
"desc": "Niucloud hello world演示插件",
|
||||
"key": "hello_world",
|
||||
"version": "1.0.1",
|
||||
"author": "niucloud",
|
||||
"url": "https://www.niucloud.com",
|
||||
"type": "addon",
|
||||
"support_app": "niucloud"
|
||||
}
|
||||
BIN
niucloud/addon/hello_world/resource/icon.png
Normal file
BIN
niucloud/addon/hello_world/resource/icon.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 673 B |
6
niucloud/addon/hello_world/sql/install.sql
Normal file
6
niucloud/addon/hello_world/sql/install.sql
Normal file
@ -0,0 +1,6 @@
|
||||
CREATE TABLE IF NOT EXISTS `{{prefix}}hello_world` (
|
||||
`id` int unsigned NOT NULL AUTO_INCREMENT,
|
||||
`name` varchar(255) NOT NULL DEFAULT '' COMMENT '名称',
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='演示插件表';
|
||||
INSERT INTO `{{prefix}}hello_world`(`id`, `name`) VALUES (1, '名称');
|
||||
1
niucloud/addon/hello_world/sql/uninstall.sql
Normal file
1
niucloud/addon/hello_world/sql/uninstall.sql
Normal file
@ -0,0 +1 @@
|
||||
DROP TABLE IF EXISTS `{{prefix}}hello_world`;
|
||||
@ -0,0 +1,24 @@
|
||||
<template>
|
||||
<view>
|
||||
演示插件信息——自定义组件
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { computed } from 'vue';
|
||||
import useDiyStore from '@/stores/diy';
|
||||
|
||||
const props = defineProps(['component', 'index']);
|
||||
|
||||
const diyStore = useDiyStore();
|
||||
|
||||
const diyComponent = computed(() => {
|
||||
if (diyStore.mode == 'decorate') {
|
||||
return diyStore.value[props.index];
|
||||
} else {
|
||||
return props.component;
|
||||
}
|
||||
})
|
||||
</script>
|
||||
|
||||
<style></style>
|
||||
@ -0,0 +1,24 @@
|
||||
<template>
|
||||
<view>
|
||||
演示插件文本——自定义组件
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { computed } from 'vue';
|
||||
import useDiyStore from '@/stores/diy';
|
||||
|
||||
const props = defineProps(['component', 'index']);
|
||||
|
||||
const diyStore = useDiyStore();
|
||||
|
||||
const diyComponent = computed(() => {
|
||||
if (diyStore.mode == 'decorate') {
|
||||
return diyStore.value[props.index];
|
||||
} else {
|
||||
return props.component;
|
||||
}
|
||||
})
|
||||
</script>
|
||||
|
||||
<style></style>
|
||||
@ -0,0 +1,20 @@
|
||||
<template>
|
||||
<view>
|
||||
<!-- 扩展组件 -->
|
||||
</view>
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
// 自定义扩展组件
|
||||
import { computed } from 'vue';
|
||||
import useDiyStore from '@/stores/diy';
|
||||
const props = defineProps(['component', 'index']);
|
||||
const diyStore = useDiyStore();
|
||||
const diyComponent = computed(() => {
|
||||
if (diyStore.mode == 'decorate') {
|
||||
return diyStore.value[props.index];
|
||||
} else {
|
||||
return props.component;
|
||||
}
|
||||
})
|
||||
</script>
|
||||
<style lang="scss" scoped></style>
|
||||
43
niucloud/addon/hello_world/uni-app/pages.json
Normal file
43
niucloud/addon/hello_world/uni-app/pages.json
Normal file
@ -0,0 +1,43 @@
|
||||
{
|
||||
"pages" : [ // pages数组中第一项表示应用启动页,参考:https://uniapp.dcloud.io/collocation/pages
|
||||
{
|
||||
"path": "pages/hello_world/index",
|
||||
"style": {
|
||||
// #ifdef H5
|
||||
"navigationStyle": "custom",
|
||||
// #endif
|
||||
"navigationBarTitleText": "%pages.hello_world.index%"
|
||||
}
|
||||
}
|
||||
],
|
||||
"globalStyle": {
|
||||
"navigationBarTextStyle": "black",
|
||||
"navigationBarTitleText": "",
|
||||
"navigationBarBackgroundColor": "#ffffff",
|
||||
"backgroundColor": "#F8F8F8",
|
||||
"backgroundColorTop": "#F8F8F8",
|
||||
"backgroundColorBottom": "#F8F8F8"
|
||||
},
|
||||
"tabBar": {
|
||||
"list": [
|
||||
{
|
||||
"pagePath": "pages/index/index"
|
||||
},
|
||||
{
|
||||
"pagePath": "pages/article/list"
|
||||
},
|
||||
{
|
||||
"pagePath": "pages/member/index"
|
||||
}
|
||||
]
|
||||
},
|
||||
"uniIdRouter": {},
|
||||
"easycom": {
|
||||
"custom": {
|
||||
"^u-(.*)": "uview-plus/components/u-$1/u-$1.vue",
|
||||
"diy-system-(\W.*)": "@/components/diy/system/$1/index.vue",
|
||||
"diy-core-(\W.*)": "@/components/diy/core/$1/index.vue",
|
||||
"diy-(\W.*)": "@/components/diy/$1/index.vue"
|
||||
}
|
||||
}
|
||||
}
|
||||
166
niucloud/addon/hello_world/uni-app/pages/hello_world/index.vue
Normal file
166
niucloud/addon/hello_world/uni-app/pages/hello_world/index.vue
Normal file
@ -0,0 +1,166 @@
|
||||
<template>
|
||||
<view class="bg-gray-100 min-h-[100vh]">
|
||||
<view class="fixed top-0 inset-x-0 z-10">
|
||||
<view
|
||||
class='p-[10px] bg-white border-solid border-t-0 border-l-0 border-r-0 border-b-[1px] border-gray-200'>
|
||||
<u-search :placeholder="t('searchPlaceholder')" actionText :actionStyle="{'width':0,'margin':0}"
|
||||
v-model="articleTitle" @clickIcon="searchFn"></u-search>
|
||||
</view>
|
||||
<scroll-view :scroll-x="true" :enable-flex="true"
|
||||
class="nav-list bg-white align-center px-[10px] box-border">
|
||||
<view class="flex scroll-view-wrap">
|
||||
<view
|
||||
:class="['nav-item text-[14px] mx-[5px] h-[30px] leading-[30px] my-[5px] border-t-0 border-l-0 border-r-0',{'border-solid border-b-[2px] active': currCategoryId==item.category_id}]"
|
||||
@click="loadCategory(item.category_id)" v-for="(item,index) in categoryList"
|
||||
:key="item.category_id">
|
||||
{{item.name}}
|
||||
</view>
|
||||
</view>
|
||||
</scroll-view>
|
||||
</view>
|
||||
|
||||
<mescroll-body ref="mescrollRef" @init="mescrollInit" top="220rpx" @down="downCallback" @up="getArticleListFn">
|
||||
<view v-for="(item,index) in articleList" :key="item.id"
|
||||
:class="['bg-white flex align-center p-[10px]',{'border-solid border-t-0 border-l-0 border-r-0 border-b-[1px] border-gray-200': articleList.length-1 !== index}] "
|
||||
@click="toLink(item.id)">
|
||||
<u--image width="260rpx" height="200rpx" :src="img(item.image)" v-if="item.image" model="aspectFill">
|
||||
<template #error>
|
||||
<u-icon name="photo" color="#999" size="50"></u-icon>
|
||||
</template>
|
||||
</u--image>
|
||||
<view class="flex-1 flex flex-col justify-between ml-[10px]">
|
||||
<view class="text-[16px] leading-[1.3] multi-hidden mt-[2px]">{{item.title}}</view>
|
||||
<view class="text-[14px] using-hidden mb-[auto] mt-[10px] text-gray-500">{{item.summary}}</view>
|
||||
<view class="text-[12px] text-gray-400 flex justify-between mb-[5px]">
|
||||
<text class="">{{item.create_time}}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<mescroll-empty v-if="!articleList.length && loading"></mescroll-empty>
|
||||
</mescroll-body>
|
||||
<tabbar />
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { reactive, ref, onMounted } from 'vue'
|
||||
import { onLoad } from '@dcloudio/uni-app'
|
||||
import { t } from '@/locale'
|
||||
import { redirect, img } from '@/utils/common';
|
||||
import { getArticleList, getArticleCategory } from '@/api/article';
|
||||
import MescrollBody from '@/components/mescroll/mescroll-body/mescroll-body.vue';
|
||||
import MescrollEmpty from '@/components/mescroll/mescroll-empty/mescroll-empty.vue';
|
||||
import useMescroll from '@/components/mescroll/hooks/useMescroll.js';
|
||||
import { onPageScroll, onReachBottom } from '@dcloudio/uni-app';
|
||||
const { mescrollInit, downCallback, getMescroll } = useMescroll(onPageScroll, onReachBottom);
|
||||
import { useShare } from '@/hooks/useShare'
|
||||
|
||||
const { setShare, onShareAppMessage, onShareTimeline } = useShare()
|
||||
setShare()
|
||||
onShareAppMessage()
|
||||
onShareTimeline()
|
||||
|
||||
let categoryList = ref<Array<Object>>([]);
|
||||
let articleList = ref<Array<any>>([]);
|
||||
let currCategoryId = ref<number | string>('');
|
||||
let articleTitle = ref<string>('');
|
||||
let mescrollRef = ref(null);
|
||||
let loading = ref<boolean>(false);
|
||||
|
||||
interface acceptingDataStructure {
|
||||
data : acceptingDataItemStructure,
|
||||
msg : string,
|
||||
code : number
|
||||
}
|
||||
interface acceptingDataItemStructure {
|
||||
data : object,
|
||||
[propName : string] : number | string | object
|
||||
}
|
||||
onLoad(async () => {
|
||||
await getArticleCategory().then((res : acceptingDataStructure) => {
|
||||
const initData = { name: t("all"), category_id: '' };
|
||||
categoryList.value.push(initData);
|
||||
categoryList.value = categoryList.value.concat(res.data.data);
|
||||
});
|
||||
})
|
||||
|
||||
interface mescrollStructure {
|
||||
num : number,
|
||||
size : number,
|
||||
endSuccess : Function,
|
||||
[propName : string] : any
|
||||
}
|
||||
const getArticleListFn = (mescroll : mescrollStructure) => {
|
||||
loading.value = false;
|
||||
let data : object = {
|
||||
category_id: currCategoryId.value,
|
||||
title: articleTitle.value,
|
||||
page: mescroll.num,
|
||||
limit: mescroll.size
|
||||
};
|
||||
|
||||
getArticleList(data).then((res : acceptingDataStructure) => {
|
||||
let newArr = (res.data.data as Array<Object>);
|
||||
//设置列表数据
|
||||
if (mescroll.num == 1) {
|
||||
articleList.value = []; //如果是第一页需手动制空列表
|
||||
}
|
||||
articleList.value = articleList.value.concat(newArr);
|
||||
mescroll.endSuccess(newArr.length);
|
||||
loading.value = true;
|
||||
}).catch(() => {
|
||||
loading.value = true;
|
||||
mescroll.endErr(); // 请求失败, 结束加载
|
||||
})
|
||||
}
|
||||
|
||||
const loadCategory = (id : string) => {
|
||||
currCategoryId.value = id;
|
||||
getMescroll().resetUpScroll();
|
||||
}
|
||||
|
||||
const searchFn = () => {
|
||||
getMescroll().resetUpScroll();
|
||||
}
|
||||
|
||||
const toLink = (id : string) => {
|
||||
redirect({ url: '/pages/article/detail', param: { id } })
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
setTimeout(() => {
|
||||
getMescroll().optUp.textNoMore = t("end");
|
||||
}, 500)
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.nav-item.active {
|
||||
color: $u-primary;
|
||||
}
|
||||
|
||||
.scroll-view-wrap {
|
||||
word-break: keep-all;
|
||||
}
|
||||
|
||||
/* 单行超出隐藏 */
|
||||
.using-hidden {
|
||||
word-break: break-all;
|
||||
text-overflow: ellipsis;
|
||||
overflow: hidden;
|
||||
display: -webkit-box;
|
||||
-webkit-line-clamp: 1;
|
||||
-webkit-box-orient: vertical;
|
||||
white-space: break-spaces;
|
||||
}
|
||||
|
||||
/* 多行超出隐藏 */
|
||||
.multi-hidden {
|
||||
word-break: break-all;
|
||||
text-overflow: ellipsis;
|
||||
overflow: hidden;
|
||||
display: -webkit-box;
|
||||
-webkit-line-clamp: 2;
|
||||
-webkit-box-orient: vertical;
|
||||
}
|
||||
</style>
|
||||
Loading…
x
Reference in New Issue
Block a user