Skip to content

Commit

Permalink
hotfix
Browse files Browse the repository at this point in the history
  • Loading branch information
r74tech committed Aug 26, 2023
1 parent c3d5f59 commit 5890ad3
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 16 deletions.
2 changes: 1 addition & 1 deletion src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<style id="innercss"></style>
<style id="theme"></style>
<style id="init"></style>
<script type="module" src="./main.ts"></script>
<script type="module" src="/main.ts"></script>
<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-6712436328053318"
crossorigin="anonymous"></script>
<script async src="https://www.googletagmanager.com/gtag/js?id=G-Q9CR0QHZF8"></script>
Expand Down
33 changes: 20 additions & 13 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -225,8 +225,9 @@ const handleShareButtonClick = async () => {
console.error('Error sending data to GAS:', error);
}
} else {
const shortId = isSharePath;
const dataToSend = {
shortid: isSharePath,
shortid: shortId,
title: edittitleField.value,
source: editpageField.value
};
Expand Down Expand Up @@ -322,7 +323,7 @@ const handleDOMContentLoaded = async () => {


async function getDataFromGAS(shortId) {
const apiUrl = `https://script.google.com/macros/s/AKfycbxSUyNRMa0k3LJVLJbQ8UgZrj1SrNtO-BhSkSNJPoZ3G4Ljl2bVDGVYbZ_6h-gCUf3nzg/exec?shortid=${shortId}`;
const apiUrl = `https://script.google.com/macros/s/AKfycbxZUHdkLbrd6OtbCLEgBRqcd8gi3qmEQg7fmxewaOMCEu9skF9xoTj3pRJ1cx7kP-hofQ/exec?shortid=${shortId}`;

try {
const response = await fetch(apiUrl);
Expand All @@ -337,27 +338,33 @@ async function getDataFromGAS(shortId) {
}
}

function getCurrentShortId() {
const path = window.location.pathname;
if (path.startsWith('/share/')) {
const shortid = path.substring('/share/'.length);
return shortid;
}
return null;
}

const postDataToGAS = async (data) => {
const url = 'https://script.google.com/macros/s/AKfycbxSUyNRMa0k3LJVLJbQ8UgZrj1SrNtO-BhSkSNJPoZ3G4Ljl2bVDGVYbZ_6h-gCUf3nzg/exec';
const url = 'https://script.google.com/macros/s/AKfycbxZUHdkLbrd6OtbCLEgBRqcd8gi3qmEQg7fmxewaOMCEu9skF9xoTj3pRJ1cx7kP-hofQ/exec';

// データを x-www-form-urlencoded 形式にエンコードする
const formData = new URLSearchParams(data).toString();

const response = await fetch(url, {
method: 'POST',
headers: {
'Content-Type': 'application/json'
'Content-Type': 'application/x-www-form-urlencoded'
},
body: JSON.stringify(data)
body: formData
});

return response.json();
};


function getCurrentShortId() {
const path = window.location.pathname;
if (path.startsWith('/share/')) {
const shortid = path.substring('/share/'.length);
return shortid;
}
return null;
}
// Event listeners...
document.addEventListener('DOMContentLoaded', handleDOMContentLoaded);
if (editpageField) editpageField.addEventListener('input', handleEditpageInput);
Expand Down
4 changes: 2 additions & 2 deletions vite.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import path from 'path'
const root = join(process.cwd(), './src');
module.exports = {
mode: process.env.MODE,
base: './',
base: '/',
root: root,
publicDir: "./public",
server: {
Expand All @@ -29,7 +29,7 @@ module.exports = {
target: 'es2020',
polyfillDynamicImport: false,
minify: process.env.MODE === 'development' ? false : 'terser',
base: '',
base: '/',
outDir: join(process.cwd(), 'dist'),
rollupOptions: {
input: {
Expand Down

0 comments on commit 5890ad3

Please sign in to comment.