Update github actions
This commit is contained in:
22
.github/workflows/github-actions-builder.yml
vendored
22
.github/workflows/github-actions-builder.yml
vendored
@@ -15,9 +15,9 @@ jobs:
|
|||||||
|
|
||||||
runs-on: ${{ matrix.platform }}
|
runs-on: ${{ matrix.platform }}
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v4
|
||||||
- name: setup node
|
- name: setup node
|
||||||
uses: actions/setup-node@v3
|
uses: actions/setup-node@v4
|
||||||
with:
|
with:
|
||||||
node-version: 21
|
node-version: 21
|
||||||
- id: set_var_win
|
- id: set_var_win
|
||||||
@@ -29,13 +29,9 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
echo "VERSION_JSON=$(jq -c . < version.json)" >> $GITHUB_ENV
|
echo "VERSION_JSON=$(jq -c . < version.json)" >> $GITHUB_ENV
|
||||||
- name: install pnpm
|
- name: install pnpm
|
||||||
uses: pnpm/action-setup@v2
|
uses: pnpm/action-setup@v3
|
||||||
with:
|
with:
|
||||||
version: 8
|
version: latest
|
||||||
- name: install Rust stable
|
|
||||||
uses: actions-rs/toolchain@v1
|
|
||||||
with:
|
|
||||||
toolchain: stable
|
|
||||||
- name: install dependencies (ubuntu only)
|
- name: install dependencies (ubuntu only)
|
||||||
if: matrix.platform == 'ubuntu-latest'
|
if: matrix.platform == 'ubuntu-latest'
|
||||||
run: |
|
run: |
|
||||||
@@ -46,7 +42,7 @@ jobs:
|
|||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT
|
echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT
|
||||||
- uses: actions/cache@v3
|
- uses: actions/cache@v4
|
||||||
name: Setup pnpm cache
|
name: Setup pnpm cache
|
||||||
with:
|
with:
|
||||||
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }}
|
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }}
|
||||||
@@ -58,7 +54,7 @@ jobs:
|
|||||||
- if: matrix.platform == 'ubuntu-latest'
|
- if: matrix.platform == 'ubuntu-latest'
|
||||||
run: pnpm tauri build --target x86_64-unknown-linux-gnu
|
run: pnpm tauri build --target x86_64-unknown-linux-gnu
|
||||||
- if: matrix.platform == 'ubuntu-latest'
|
- if: matrix.platform == 'ubuntu-latest'
|
||||||
uses: "softprops/action-gh-release@v1"
|
uses: "softprops/action-gh-release@v2"
|
||||||
with:
|
with:
|
||||||
repo_token: "${{ secrets.GITHUB_TOKEN }}"
|
repo_token: "${{ secrets.GITHUB_TOKEN }}"
|
||||||
automatic_release_tag: "latest"
|
automatic_release_tag: "latest"
|
||||||
@@ -75,7 +71,7 @@ jobs:
|
|||||||
- if: matrix.platform == 'macos-latest'
|
- if: matrix.platform == 'macos-latest'
|
||||||
run: pnpm tauri build --target aarch64-apple-darwin
|
run: pnpm tauri build --target aarch64-apple-darwin
|
||||||
- if: matrix.platform == 'macos-latest'
|
- if: matrix.platform == 'macos-latest'
|
||||||
uses: "softprops/action-gh-release@v1"
|
uses: "softprops/action-gh-release@v2"
|
||||||
with:
|
with:
|
||||||
repo_token: "${{ secrets.GITHUB_TOKEN }}"
|
repo_token: "${{ secrets.GITHUB_TOKEN }}"
|
||||||
automatic_release_tag: "latest"
|
automatic_release_tag: "latest"
|
||||||
@@ -88,7 +84,7 @@ jobs:
|
|||||||
- if: matrix.platform == 'windows-latest'
|
- if: matrix.platform == 'windows-latest'
|
||||||
run: pnpm tauri build
|
run: pnpm tauri build
|
||||||
- if: matrix.platform == 'windows-latest'
|
- if: matrix.platform == 'windows-latest'
|
||||||
uses: "softprops/action-gh-release@v1"
|
uses: "softprops/action-gh-release@v2"
|
||||||
with:
|
with:
|
||||||
repo_token: "${{ secrets.GITHUB_TOKEN }}"
|
repo_token: "${{ secrets.GITHUB_TOKEN }}"
|
||||||
automatic_release_tag: "latest"
|
automatic_release_tag: "latest"
|
||||||
@@ -103,7 +99,7 @@ jobs:
|
|||||||
run: zip -r built_code.zip dist
|
run: zip -r built_code.zip dist
|
||||||
# then, publish the zip file
|
# then, publish the zip file
|
||||||
- if: matrix.platform == 'ubuntu-latest'
|
- if: matrix.platform == 'ubuntu-latest'
|
||||||
uses: "softprops/action-gh-release@v1"
|
uses: "softprops/action-gh-release@v2"
|
||||||
with:
|
with:
|
||||||
repo_token: "${{ secrets.GITHUB_TOKEN }}"
|
repo_token: "${{ secrets.GITHUB_TOKEN }}"
|
||||||
automatic_release_tag: "latest"
|
automatic_release_tag: "latest"
|
||||||
|
|||||||
24
src/main.ts
24
src/main.ts
@@ -4,6 +4,7 @@ import App from "./App.svelte";
|
|||||||
import { loadData } from "./ts/storage/globalApi";
|
import { loadData } from "./ts/storage/globalApi";
|
||||||
import { initHotkey } from "./ts/hotkey";
|
import { initHotkey } from "./ts/hotkey";
|
||||||
import { polyfill } from "./ts/polyfill";
|
import { polyfill } from "./ts/polyfill";
|
||||||
|
import { preLoadCheck } from "./preload";
|
||||||
|
|
||||||
const errorHandler = (event: ErrorEvent) => {
|
const errorHandler = (event: ErrorEvent) => {
|
||||||
console.error(event.error)
|
console.error(event.error)
|
||||||
@@ -23,18 +24,21 @@ export const removeDefaultHandler = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let app: App;
|
let app: App;
|
||||||
try {
|
|
||||||
polyfill()
|
|
||||||
|
|
||||||
app = new App({
|
if(preLoadCheck()){
|
||||||
target: document.getElementById("app"),
|
try {
|
||||||
});
|
polyfill()
|
||||||
|
|
||||||
loadData()
|
app = new App({
|
||||||
initHotkey()
|
target: document.getElementById("app"),
|
||||||
} catch (error) {
|
});
|
||||||
console.error(error, error.stack)
|
|
||||||
alert(error)
|
loadData()
|
||||||
|
initHotkey()
|
||||||
|
} catch (error) {
|
||||||
|
console.error(error, error.stack)
|
||||||
|
alert(error)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default app;
|
export default app;
|
||||||
29
src/preload.ts
Normal file
29
src/preload.ts
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
|
||||||
|
export function preLoadCheck(){
|
||||||
|
const searchParams = new URLSearchParams(location.search);
|
||||||
|
|
||||||
|
//@ts-ignore
|
||||||
|
const isTauri = !!window.__TAURI__
|
||||||
|
//@ts-ignore
|
||||||
|
const isNodeServer = !!globalThis.__NODE__
|
||||||
|
|
||||||
|
const isWeb = !isTauri && !isNodeServer && location.hostname !== 'risuai.xyz';
|
||||||
|
|
||||||
|
|
||||||
|
// Check if the user has visited the main page
|
||||||
|
if(!isWeb) {
|
||||||
|
localStorage.setItem('mainpage', 'visited');
|
||||||
|
}
|
||||||
|
else if(searchParams.has('mainpage')) {
|
||||||
|
localStorage.setItem('mainpage', searchParams.get('main-page'));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Redirect to the main page if the user has not visited the main page
|
||||||
|
if(localStorage.getItem('mainpage') !== 'visited') {
|
||||||
|
localStorage.setItem('mainpage', 'visited');
|
||||||
|
location.replace('https://risuai.net');
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user