mercuryseries/flashy 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

mercuryseries/flashy

Composer 安装命令:

composer require mercuryseries/flashy

包简介

Easy flash notifications

README 文档

README

Example of Error Notification

Copyright

Inspired by Jeffrey Way's Flash Package. Added following Jeffrey Ωmega's request.

Installation

Video Tutorial

Watch a Video Tutorial here

You like text ?

First, pull in the package through Composer.

Run composer require mercuryseries/flashy

And then, if using Laravel 5, include the service provider within config/app.php.

'providers' => [
    MercurySeries\Flashy\FlashyServiceProvider::class,
];

And, for convenience, add a facade alias to this same file at the bottom:

'aliases' => [
    'Flashy' => MercurySeries\Flashy\Flashy::class,
];

Usage

Within your controllers, before you perform a redirect...

public function store()
{
    Flashy::message('Welcome Aboard!', 'http://your-awesome-link.com');

    return Redirect::home();
}

You may also do:

  • Flashy::info('Message', 'http://your-awesome-link.com')
  • Flashy::success('Message', 'http://your-awesome-link.com')
  • Flashy::error('Message', 'http://your-awesome-link.com')
  • Flashy::warning('Message', 'http://your-awesome-link.com')
  • Flashy::primary('Message', 'http://your-awesome-link.com')
  • Flashy::primaryDark('Message', 'http://your-awesome-link.com')
  • Flashy::muted('Message', 'http://your-awesome-link.com')
  • Flashy::mutedDark('Message', 'http://your-awesome-link.com')

Again, if using Laravel, this will set a few keys in the session:

  • 'flashy_notification.message' - The message you're flashing
  • 'flashy_notification.type' - A string that represents the type of notification (good for applying HTML class names)
  • 'flashy_notification.link' - The URL to redirect to on click

Alternatively, again, if you're using Laravel, you may reference the flashy() helper function, instead of the facade. Here's an example:

/**
 * Destroy the user's session (logout).
 *
 * @return Response
 */
public function destroy()
{
    Auth::logout();

    flashy()->success('You have been logged out.', 'http://your-awesome-link.com');

    return home();
}

Or, for a general information flash, just do: flashy('Some message', 'http://your-awesome-link.com');.

With this message flashed to the session, you may now display it in your view(s). Maybe something like:

@if(Session::has('flashy_notification.message'))
<script id="flashy-template" type="text/template">
    <div class="flashy flashy--{{ Session::get('flashy_notification.type') }}">
        <i class="material-icons">speaker_notes</i>
        <a href="#" class="flashy__body" target="_blank"></a>
    </div>
</script>

<script>
    flashy("{{ Session::get('flashy_notification.message') }}", "{{ Session::get('flashy_notification.link') }}");
</script>
@endif

Because flash messages are so common, if you want, you may use (or modify) the views that are included with this package. Simply append to your layout view:

@include('flashy::message')

Note that this package has jQuery has dependency. It's also better to load flashy before your body close tag.

Example

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
</head>
<body>

<div class="container">

    <p>Welcome to my website...</p>
</div>

<script src="//code.jquery.com/jquery.js"></script>
@include('flashy::message')
</body>
</html>

If you need to modify the flash message partials, you can run:

php artisan vendor:publish

The two package views will now be located in the app/views/packages/mercuryseries/flashy/ directory.

Flashy::message('Welcome aboard!', 'http://your-awesome-link.com');

return Redirect::home();
Flashy::error('Sorry! Please try again.', 'http://your-awesome-link.com');

return Redirect::home();

Nice rendering

For a nice rendering you may include these lines in your head:

<link href="//fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<link href='//fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,600,700' rel='stylesheet'>

and override the following sections of the default flashy view:

<style type="text/css">
.flashy {
    font-family: "Source Sans Pro", Arial, sans-serif;
    padding: 11px 30px;
    border-radius: 4px;
    font-weight: 400;
    position: fixed;
    bottom: 20px;
    right: 20px;
    font-size: 16px;
    color: #fff;
}
</style>

<script id="flashy-template" type="text/template">
    <div class="flashy flashy--{{ Session::get('flashy_notification.type') }}">
        <i class="material-icons">speaker_notes</i>
        <a href="#" class="flashy__body" target="_blank"></a>
    </div>
</script>

mercuryseries/flashy 适用场景与选型建议

mercuryseries/flashy 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 57.51k 次下载、GitHub Stars 达 444, 最近一次更新时间为 2016 年 01 月 11 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 mercuryseries/flashy 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 mercuryseries/flashy 我们能提供哪些服务?
定制开发 / 二次开发

基于 mercuryseries/flashy 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 57.51k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 447
  • 点击次数: 20
  • 依赖项目数: 2
  • 推荐数: 0

GitHub 信息

  • Stars: 444
  • Watchers: 19
  • Forks: 44
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2016-01-11