Skip to content

Commit

Permalink
core: open turbo
Browse files Browse the repository at this point in the history
  • Loading branch information
windy committed Jan 20, 2025
1 parent 5db7629 commit 5675453
Show file tree
Hide file tree
Showing 12 changed files with 38 additions and 51 deletions.
2 changes: 1 addition & 1 deletion app/controllers/admin/posts_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def create
redirect_to admin_posts_path
else
flash.now[:error] = '创建失败'
render :new
render :new, status: 422
end
end

Expand Down
2 changes: 1 addition & 1 deletion app/javascript/admin/posts.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ $(document).on('turbo:load', function(){
return false
})

opt = {
var opt = {
type: 'POST',
url: "/photos",
success: function(data,status,xhr){
Expand Down
5 changes: 2 additions & 3 deletions app/javascript/base.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
// base dependency library, it should be only shared by `admin.js` and `application.js`.
//
import './libs/add_jquery'

import 'bootstrap/dist/js/bootstrap'

import RailsUjs from '@rails/ujs'
import '@hotwired/turbo'
Turbo.session.drive = false
import "@hotwired/turbo-rails"
import * as ActiveStorage from '@rails/activestorage'

// Turbo.session.drive = false
RailsUjs.start()
ActiveStorage.start()

Expand Down
2 changes: 1 addition & 1 deletion app/javascript/controllers/admin_label_controller.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Controller } from "stimulus"
import { Controller } from "@hotwired/stimulus"
import select2 from 'select2'

window.select2 = select2();
Expand Down
2 changes: 1 addition & 1 deletion app/javascript/controllers/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Load all the controllers within this directory and all subdirectories.
// Controller files must be named *_controller.js or *_controller.ts.

import { Application } from "stimulus"
import { Application } from "@hotwired/stimulus"

const application = Application.start()

Expand Down
2 changes: 1 addition & 1 deletion app/javascript/controllers/like_controller.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Controller } from "stimulus"
import { Controller } from "@hotwired/stimulus"
import Cookies from 'js-cookie'

export default class extends Controller {
Expand Down
2 changes: 1 addition & 1 deletion app/javascript/controllers/qrcode_controller.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Controller } from "stimulus"
import { Controller } from "@hotwired/stimulus"
import '../libs/qrcode'

export default class extends Controller {
Expand Down
2 changes: 1 addition & 1 deletion app/javascript/libs/qrcode.js
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ var QRCode;

// Android 2.1 bug workaround
// http://code.google.com/p/android/issues/detail?id=5141
if (this._android && this._android <= 2.1) {
if (this && this._android && this._android <= 2.1) {
var factor = 1 / window.devicePixelRatio;
var drawImage = CanvasRenderingContext2D.prototype.drawImage;
CanvasRenderingContext2D.prototype.drawImage = function (image, sx, sy, sw, sh, dx, dy, dw, dh) {
Expand Down
3 changes: 2 additions & 1 deletion app/views/layouts/admin.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ html
= action_cable_meta_tag
= content_for?(:head) ? yield(:head) : ''
= stylesheet_link_tag 'admin', media: 'all', 'data-turbo-track': 'reload'
= javascript_include_tag 'admin', 'data-turbo-track': 'reload'
/ = javascript_include_tag 'admin', 'data-turbo-track': 'reload'
= javascript_include_tag 'admin', 'data-turbo-track': Rails.env.production? ? "reload" : "", type: "module"
= favicon_link_tag asset_path("favicon.png")
body.layout-fixed.sidebar-expand-lg.bg-body-tertiary.app-loaded.sidebar-open.admin-page class=body_class
- if @full_render
Expand Down
3 changes: 2 additions & 1 deletion app/views/layouts/application.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ html
= action_cable_meta_tag
= content_for?(:head) ? yield(:head) : ''
= stylesheet_link_tag 'application', media: 'all', 'data-turbo-track': 'reload'
= javascript_include_tag 'application', 'data-turbo-track': Rails.env.production? ? "reload" : ""
= javascript_include_tag 'application', 'data-turbo-track': Rails.env.production? ? "reload" : "", type: "module"
/ = javascript_include_tag 'application', 'data-turbo-track': Rails.env.production? ? "reload" : ""
/ = javascript_tag 'ga', 'data-turbo-track': 'reload'
= favicon_link_tag asset_path("favicon.png")
body class=body_class
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
"private": true,
"dependencies": {
"@fortawesome/fontawesome-free": "^5.15.4",
"@hotwired/turbo": "^7.0.0-beta.7",
"@hotwired/stimulus": "^3.2.2",
"@hotwired/turbo-rails": "^8.0.12",
"@rails/actioncable": "^6.0.0",
"@rails/activestorage": "^6.0.0",
"@rails/ujs": "^6.0.0",
Expand All @@ -18,7 +19,6 @@
"popper.js": "^1.14.7",
"sass": "^1.83.1",
"select2": "^4.1.0-rc.0",
"stimulus": "^2.0.0",
"tempusdominus-core": "^5.19.0"
},
"version": "0.1.0",
Expand All @@ -27,6 +27,6 @@
},
"scripts": {
"build:css": "sass ./app/assets/stylesheets/application.scss:./app/assets/builds/application.css ./app/assets/stylesheets/admin.scss:./app/assets/builds/admin.css --no-source-map --load-path=node_modules --silence-deprecation=import --quiet-deps",
"build": "esbuild app/javascript/*.js --bundle --sourcemap --format=esm --outdir=app/assets/builds --public-path=/assets --loader:.ttf=file --loader:.woff2=file --loader:.woff=file"
"build": "esbuild app/javascript/*.js --bundle --sourcemap --format=esm --outdir=app/assets/builds --public-path=/assets"
}
}
58 changes: 22 additions & 36 deletions yarn.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 5675453

Please sign in to comment.